esh_types.h 1.8 KB

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