12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #include <stdio.h>
- #include <pthread.h>
- #include <time.h>
- #include <stdlib.h>
- #include <pwd.h>
- #include <string.h>
- #include <unistd.h>
- #include <limits.h>
- #include <termios.h>
- #include <sys/wait.h>
- #ifndef ESH_TYPES_H
- #define ESH_TYPES_H
- typedef enum {
- BACKGROUND,
- FOREGROUND
- } ESH_JOB_TYPE;
- typedef enum {
- INNER_CMD,
- EXEC_CMD
- } ESH_COMMAND_TYPE;
- typedef enum {
- NO_CONDITION, // ex. commands delimited by ';'
- PREVIOUS_EXIT_SUCCESS, // ex. commands delimited by '&&'
- PREVIOUS_EXIT_FAILED // ex. commands delimited by '||'
- } ESH_JOB_CONDITION;
- typedef struct {
- char* command;
- ESH_COMMAND_TYPE command_type;
- ESH_JOB_TYPE job_type;
- ESH_JOB_CONDITION job_start_condition;
- pid_t job_pid;
- int stdin_pipe[2];
- int stdout_pipe[2]; // 0 is for writing in child process and for reading in parent process.
- int stderr_pipe[2]; // 1 is for writing in parent process and for reading in child process.
- } EShJob;
- typedef struct {
- char* build_ref;
- struct passwd* user_data;
- char* current_working_dir;
- char* config_file_path; // path to file, containing configurations (changeable via cmd line args)
- char* history_file_path; // path to file, where entered commands history is stored (changeable via settings/cmd line args)
- int history_limit; // max lines of commands, which can be stored (changeable via settings/cmd line args)
- int max_jobs_number; // max active jobs (foreground & background) limit (changeable via settings/cmd line args)
- int max_command_length; // max length of single command (changeable via settings/cmd line args)
- int max_invite_message_len;
- char* invite_message;
- int jobs_number;
- EShJob* jobs_list;
- int exited; // used to stop threads on exiting
- } EShInfo;
- extern EShInfo* esh_info_global;
- #endif // ESH_TYPES_H
|