command.h 1016 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * File: command.h
  3. * Author: Arthur Brandao
  4. *
  5. * Created on 9 novembre 2018
  6. */
  7. #ifndef COMMAND_H
  8. #define COMMAND_H
  9. /* --- Include --- */
  10. #include <sys/types.h>
  11. #include "constante.h"
  12. /* --- Constante --- */
  13. #define NB_CMD 4
  14. /* --- Structure --- */
  15. typedef struct pid_node pid_node;
  16. struct pid_node{
  17. pid_t pid;
  18. int job;
  19. pid_node* prev;
  20. pid_node* next;
  21. };
  22. typedef struct{
  23. pid_node* first;
  24. pid_node* last;
  25. }pid_list;
  26. /* --- Extern --- */
  27. extern char* cmdlist[NB_CMD];
  28. extern boolean exitsh;
  29. /* --- Fonctions --- */
  30. void ini_pid_list(pid_list*);
  31. pid_node* add_pid(pid_list*, pid_t, int);
  32. pid_node* search_pid(pid_list*, pid_t);
  33. void remove_pid(pid_list*, pid_node*);
  34. void clean_pid(pid_list*);
  35. boolean is_internal_cmd(const char*);
  36. int launch_internal_command(Command*);
  37. /* --- Commandes --- */
  38. /**
  39. * Change le dossier de travail actuel
  40. * @param int argc
  41. * @param char** argv
  42. */
  43. int cd(int, char**);
  44. int exit_sh(int, char**);
  45. int status(int, char**);
  46. #endif /* COMMAND_H */