esh_types.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #include <stdio.h>
  2. #include <pthread.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. #include <pwd.h>
  6. #include <string.h>
  7. #include <unistd.h>
  8. #include <limits.h>
  9. #include <termios.h>
  10. #include <errno.h>
  11. #include <sys/wait.h>
  12. #ifndef ESH_TYPES_H
  13. #define ESH_TYPES_H
  14. typedef enum {
  15. BACKGROUND,
  16. FOREGROUND
  17. } ESH_JOB_TYPE;
  18. typedef enum {
  19. NO_CONDITION, // ex. commands delimited by ';'
  20. PREVIOUS_EXIT_SUCCESS, // ex. commands delimited by '&&'
  21. PREVIOUS_EXIT_FAILED // ex. commands delimited by '||'
  22. } ESH_JOB_CONDITION;
  23. typedef enum {
  24. LOGIC_AND = 1,
  25. LOGIC_OR = 2,
  26. SEMICOLON = 3,
  27. BIT_AND = 4,
  28. BIT_OR = 5,
  29. NOT_A_DELIMITER = 0
  30. } ESH_JOB_DELIMITER;
  31. typedef struct {
  32. char* command;
  33. char** command_tokens;
  34. int command_tokens_num;
  35. ESH_JOB_TYPE job_type;
  36. ESH_JOB_CONDITION job_start_condition;
  37. pid_t job_pid;
  38. int stdin_fd;
  39. int stdout_fd;
  40. int stderr_fd;
  41. } EShJob;
  42. typedef struct {
  43. char* build_ref;
  44. struct passwd* user_data;
  45. char* current_working_dir;
  46. char* config_file_path; // path to file, containing configurations (changeable via cmd line args)
  47. char* history_file_path; // path to file, where entered commands history is stored (changeable via settings/cmd line args)
  48. int history_limit; // max lines of commands, which can be stored (changeable via settings/cmd line args)
  49. // TODO: set this to max background jobs limit!
  50. int max_jobs_number; // max active jobs (foreground & background) limit (changeable via settings/cmd line args)
  51. int max_command_length; // max length of single command (changeable via settings/cmd line args)
  52. int max_command_tokens; // TODO: max arguments of single command
  53. int max_command_token_size; // TODO
  54. char** history_command_list;
  55. int history_command_list_size;
  56. int max_invite_message_len;
  57. char* invite_message;
  58. int jobs_number;
  59. EShJob* jobs_list;
  60. int exited; // used to stop threads on exiting
  61. } EShInfo;
  62. extern EShInfo* esh_info_global;
  63. #endif // ESH_TYPES_H