OS2021_Project1.Shell
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

58 lignes
1.8 KiB

il y a 3 ans
  1. #pragma once
  2. #define CMDLINE_MAX_SIZE 1024 /* max length of a single command line */
  3. #define ARGS_MAX_QUANTITY 128 /* max args on a command line */
  4. #define BUFFER_MAX_SIZE 64 /* max size of a buffer which contains parsed arguments */
  5. #define CMDLINE_DIV ' \t\r\n\a'
  6. #define CMDLINE_HISTORY_MAX_QUANTITY 256
  7. #define JOBS_MAX_QUANTITY 16
  8. #define PATH_MAX_SIZE 256
  9. #define FG 1 /* running in foreground */
  10. #define BG 2 /* running in background */
  11. #define ST 3 /* stopped */
  12. /* job_t - The job struct */
  13. struct job_t
  14. {
  15. pid_t pid; /* job PID */
  16. int jid; /* job ID [1, 2, ...] */
  17. int state; /* UNDEF, BG, FG, or ST */
  18. char cmdline[CMDLINE_MAX_SIZE]; /* command line */
  19. };
  20. /* readline - Get the command line */
  21. char *readline();
  22. /* parseline - Evaluate the command line that the user has just typed in */
  23. int parseline(char *cmdline, char **args);
  24. /* execute - Execute the command line */
  25. int execute(char *cmdline, char **args);
  26. /* builtin functions - Handle built-in command */
  27. int built_in(char **args);
  28. int builtin_cd(char **args);
  29. int builtin_ls(char **args);
  30. int builtin_history(char **args);
  31. int builtin_jobs(char **args);
  32. int builtin_mytop(char **args);
  33. /* do_bgfg - Execute background/foregroung tasks */
  34. int do_bgfg(char **args);
  35. /* addjob - Add jobs to joblist */
  36. int addjob(struct job_t *jobs, pid_t pid, int state, char *cmdline);
  37. /* pide2jid - Map process ID to job ID*/
  38. int pid2jid(pid_t pid);
  39. /* waitfg - Wait foreground jobs to finish */
  40. void waitfg(pid_t pid);
  41. /* fgpid - Return PID of current foreground job, 0 if no such job */
  42. pid_t fgpid(struct job_t *jobs);
  43. /* determine if a file is hidden */
  44. int hide(const char *path);
  45. /* */