esh_types.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 struct {
  20. char* command;
  21. ESH_COMMAND_TYPE command_type;
  22. ESH_JOB_TYPE job_type;
  23. pid_t job_pid;
  24. int stdout_pipe[2]; // 0 is for writing in child process and for reading in parent process.
  25. int stderr_pipe[2]; // 1 is for writing in parent process and for reading in child process.
  26. } EShJob;
  27. typedef struct {
  28. char* build_ref;
  29. struct passwd* user_data;
  30. char* current_working_dir;
  31. char* config_file_path; // path to file, containing configurations (changeable via settings/cmd line args)
  32. char* history_file_path; // path to file, where entered commands history is stored (changeable via settings/cmd line args)
  33. int history_limit; // max lines of commands, which can be stored (changeable via settings/cmd line args)
  34. int max_jobs_number; // max active jobs (foreground & background) limit (changeable via settings/cmd line args)
  35. int max_invite_message_len;
  36. char* invite_message;
  37. int jobs_number;
  38. EShJob* jobs_list;
  39. int exited; // used to stop threads on exiting
  40. } EShInfo;
  41. extern EShInfo* esh_info_global;
  42. #endif // ESH_TYPES_H