sh.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #ifndef SH_H
  2. # define SH_H
  3. # include "../libft/libft.h"
  4. # include "struct.h"
  5. # include "term.h"
  6. # include <stdlib.h>
  7. # include <unistd.h>
  8. # include <sys/types.h>
  9. # include <sys/wait.h>
  10. # include <dirent.h>
  11. # include <signal.h>
  12. # define PROMPT "21sh}-> "
  13. # define STDIN 0
  14. # define STDOUT 1
  15. # define STDERR 2
  16. char **g_tenv;
  17. char *g_home;
  18. char **g_path;
  19. /*
  20. ** main.c
  21. */
  22. void shell_script(t_e *e, char *script_name);
  23. void comma_split(t_e *e, char *cmd);
  24. /*
  25. ** detect_cotes.c
  26. */
  27. void init_detect_blocks(t_e *e, char *line);
  28. void detect_blocks(t_e *e, char *line, int pos, int b_pos);
  29. int coted_block(t_e *e, char *line, int pos, t_block *blk);
  30. int non_coted_block(t_e *e, char *line, int pos, t_block *blk);
  31. /*
  32. ** pipe_parsing.c
  33. */
  34. void pipe_init(t_e *e, char *all_cmd);
  35. void pipe_parsing(t_pipe *p, t_e *e, t_pipe_redir **t);
  36. int count_pipe_nbr(t_e *e, char *str);
  37. /*
  38. ** pipe_redir_parsing.c
  39. */
  40. void fill_pipe_redir_data(t_e *e, t_pipe *p, t_pipe_redir **t);
  41. void display_data(t_pipe_redir **t);
  42. int parse_redirection(t_e *e, t_pipe *p, char *str, t_pipe_redir *t);
  43. /*
  44. ** parse_redirections.c
  45. */
  46. void free_redir(t_redir *r);
  47. int check_chev_is_on_non_coted_block(t_e *e, char *str, char c);
  48. int check_before_after_chevron(char *str, int chev);
  49. void parse_and(char *str, t_redir *r, int file_pos);
  50. /*
  51. ** pipe_exec.c
  52. */
  53. void launch_pipes(t_e *e, t_pipe *p, t_pipe_redir **t);
  54. void parse_exec(t_e *e, t_pipe *p, t_pipe_redir **t);
  55. void handle_multi_piping(t_pipe *p);
  56. void remove_cotes(char **cmd);
  57. /*
  58. ** redirect.c
  59. */
  60. void redirections(t_e *e, t_pipe *p, t_redir *r);
  61. void right_redirections(t_redir *r);
  62. /*
  63. ** heredoc.c
  64. */
  65. void prompt_redirection(t_e *e, t_redir *r);
  66. char *prompt_heredoc(t_e *e, char *txt, char *eof, int i);
  67. int here_edition(t_e *h, int heredoc);
  68. /*
  69. ** herething.c
  70. */
  71. int herething(t_e *e);
  72. void exec_herething(t_e *e, int pos, char *fc);
  73. char *prompt_herething(t_e *e, int pos, char *fc);
  74. /*
  75. ** cmd_splitting.c
  76. */
  77. char **cmd_splitting(t_e *e, char *cmd, char c);
  78. int is_on_coted_block(t_e *e, int pos);
  79. char **fill_tabe(char **tabe, char *cmd, int nbr, int *poss);
  80. /*
  81. ** exec.c
  82. */
  83. int manage_cmd_1(char **cmdt);
  84. void manage_cmd_2(char **cmdt);
  85. void execute(char **cmdt);
  86. void exec_if_perm_ok(char *path, char **cmd);
  87. char **change_tilde_to_home(char **cmd);
  88. /*
  89. ** env.c
  90. */
  91. char *get_tenv(char *var);
  92. void ft_setenv(char *namevalue);
  93. void ft_unsetenv(char *name);
  94. int isenv(char *str);
  95. /*
  96. ** tabenv.c
  97. */
  98. void add_env(char *nenv);
  99. void del_env(char *old_env);
  100. /*
  101. ** cd.c
  102. */
  103. void cd(char **paths);
  104. void apply_cd(char *path, char *pwd);
  105. char *get_pwd();
  106. /*
  107. ** tools.c
  108. */
  109. void sighandler();
  110. void error_message(char *one, char *two, char *three);
  111. int check_cmd_presence(char *cmd);
  112. #endif