esh_types.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. #ifndef ESH_TYPES_H
  10. #define ESH_TYPES_H
  11. typedef enum {
  12. BACKGROUND,
  13. FOREGROUND
  14. } ESH_JOB_TYPE;
  15. typedef enum {
  16. INNER_CMD,
  17. EXEC_CMD
  18. } ESH_COMMAND_TYPE;
  19. typedef enum {
  20. NO_CONDITION, // ex. commands delimited by ';'
  21. PREVIOUS_EXIT_SUCCESS, // ex. commands delimited by '&&'
  22. PREVIOUS_EXIT_FAILED // ex. commands delimited by '||'
  23. } ESH_JOB_CONDITION;
  24. typedef struct {
  25. char* command;
  26. ESH_COMMAND_TYPE command_type;
  27. ESH_JOB_TYPE job_type;
  28. ESH_JOB_CONDITION job_start_condition;
  29. pid_t job_pid;
  30. int stdout_pipe[2]; // 0 is for writing in child process and for reading in parent process.
  31. int stderr_pipe[2]; // 1 is for writing in parent process and for reading in child process.
  32. } EShJob;
  33. typedef struct {
  34. char* build_ref;
  35. struct passwd* user_data;
  36. char* current_working_dir;
  37. char* config_file_path; // path to file, containing configurations (changeable via cmd line args)
  38. char* history_file_path; // path to file, where entered commands history is stored (changeable via settings/cmd line args)
  39. int history_limit; // max lines of commands, which can be stored (changeable via settings/cmd line args)
  40. int max_jobs_number; // max active jobs (foreground & background) limit (changeable via settings/cmd line args)
  41. int max_command_length; // max length of single command (changeable via settings/cmd line args)
  42. int max_invite_message_len;
  43. char* invite_message;
  44. int jobs_number;
  45. EShJob* jobs_list;
  46. int exited; // used to stop threads on exiting
  47. } EShInfo;
  48. extern EShInfo* esh_info_global;
  49. #endif // ESH_TYPES_H