struct.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef STRUCT_H
  2. # define STRUCT_H
  3. /*
  4. ** Struct which contain:
  5. ** youngest struct
  6. ** the command
  7. ** oldest struct
  8. */
  9. typedef struct s_hist {
  10. struct s_hist *yng;
  11. char *cmd;
  12. struct s_hist *old;
  13. } t_hist;
  14. /*
  15. ** information about types of blocks of cmd string
  16. ** block type: 0: no cotes, 1: ''', 2: '\"', 3: '`'
  17. ** begin: begin positon of this block on the string
  18. ** end: ending positon of this block on the string
  19. */
  20. typedef struct s_block
  21. {
  22. int type;
  23. int begin;
  24. int end;
  25. } t_block;
  26. /*
  27. ** PROPMT len
  28. ** keyboard key
  29. ** current command
  30. ** open parameters, cotes
  31. ** close parameters, cotes
  32. ** cmd len
  33. ** cursor position from the beginning of the cmd
  34. ** all history
  35. ** vertical position from prompt origin
  36. ** number of current lines from the prompt orgin
  37. ** number columns in current window
  38. ** boolean value for ctrl + d in prompt
  39. ** slen: len from semicolon split: used for non-splitting inside coted blocks
  40. ** fd_file: file descriptor of file for redirection on the right
  41. ** fdout: fd backup of stdout so restore it later
  42. */
  43. typedef struct s_e {
  44. char **env;
  45. char **path;
  46. char *home;
  47. int plen;
  48. char *key;
  49. char *cmd;
  50. char *par_open;
  51. char *par_close;
  52. int len;
  53. int pos;
  54. t_hist *hist;
  55. int first;
  56. int linep;
  57. int maxline;
  58. int col_nbr;
  59. int d;
  60. int slen;
  61. t_block **b;
  62. int fd_file;
  63. int fdout;
  64. } t_e;
  65. /*
  66. ** Pipe struct
  67. ** fd: input/output fd
  68. ** pnbr: number of non-coted pipes
  69. ** nbr: number of non-coted pipes and redirections
  70. ** i: position on following arrays splitted at pipes
  71. ** cmd_pipe: array of cmd splitted at pipes
  72. ** cmd_opt: array of array splitted at pipes and cmd/subcmd/options
  73. */
  74. typedef struct s_pipe
  75. {
  76. int **fd;
  77. int pnbr;
  78. int nbr;
  79. int i;
  80. char **cmd_pipe;
  81. char ***cmd_opt;
  82. } t_pipe;
  83. /*
  84. ** itxt: could be cmd or redirection
  85. ** ifd: input fd: 1 for piping
  86. ** operator: "|", ">", ">>", "<", "<<"
  87. ** ofd: output fd: 0 for piping
  88. ** otxt: could be cmd or nothing (NULL)
  89. */
  90. typedef struct s_pipe_redir
  91. {
  92. char *itxt;
  93. int ifd;
  94. char *operator;
  95. int ofd;
  96. char *otxt;
  97. } t_pipe_redir;
  98. #endif