sh.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. ** redirect.c
  26. */
  27. void parse_redirection(t_e *e, char *str);
  28. int check_before_after_chevron(char *chev);
  29. void redirections(t_e *e, char *cmd, char *operator, char *file);
  30. void right_redirections(int *fd, char *operator, char *file);
  31. /*
  32. ** heredoc.c
  33. */
  34. void prompt_redirection(t_e *e, char *cmd, char *file);
  35. char *prompt_heredoc(t_e *e, char *txt, char *eof);
  36. /*
  37. ** herething.c
  38. */
  39. void herething(t_e *e);
  40. void pipe_herething(t_e *e, int pos, char *fc);
  41. char *prompt_herething(t_e *e, int pos, char *fc);
  42. /*
  43. ** pipe.c
  44. */
  45. void launch_pipe(char *all_cmd);
  46. void pipe_parsing(int **fd, int pipe_nbr, char **cmd_pipe, int i);
  47. void handle_multi_piping(int **fd, int pipe_nbr, char ***cmd_opt, int i);
  48. /*
  49. ** cmd_split.c
  50. */
  51. char **cmd_split(char const *str, char c, char d);
  52. int count_words(char const *s, char c, char d);
  53. /*
  54. ** exec.c
  55. */
  56. int manage_cmd_1(char **cmdt);
  57. void manage_cmd_2(char **cmdt);
  58. void execute(char **cmdt);
  59. void check_file_exist_exec_rights(char *path, char **cmd);
  60. /*
  61. ** env.c
  62. */
  63. char *get_tenv(char *var);
  64. void ft_setenv(char *namevalue);
  65. void ft_unsetenv(char *name);
  66. int isenv(char *str);
  67. /*
  68. ** tabenv.c
  69. */
  70. void add_env(char *nenv);
  71. void del_env(char *old_env);
  72. /*
  73. ** cd.c
  74. */
  75. void cd(char **path);
  76. char *get_pwd();
  77. /*
  78. ** tools.c
  79. */
  80. void sighandler();
  81. void error_message(char *one, char *two, char *three);
  82. char **change_tilde_to_home(char **cmd);
  83. int check_cmd_presence(char *cmd);
  84. #endif