sh.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef SH_H
  2. # define SH_H
  3. # include "../../libft/libft.h"
  4. # include <stdlib.h>
  5. # include <unistd.h>
  6. # include <sys/types.h>
  7. # include <sys/wait.h>
  8. # include <dirent.h>
  9. # include <signal.h>
  10. # define PROMPT "21sh}-> "
  11. # define STDIN 0
  12. # define STDOUT 1
  13. # define STDERR 2
  14. char **g_tenv;
  15. char *g_home;
  16. char **g_path;
  17. /*
  18. ** main.c
  19. */
  20. void shell_script(char *script_name);
  21. void open_shell();
  22. void comma_split(char *cmd);
  23. void split_cmd_and_his_options(char *cmd);
  24. /*
  25. ** pipe.c
  26. */
  27. void launch_pipe(char *all_cmd);
  28. void pipe_parsing(int **fd, int pipe_nbr, char **cmd_pipe, int i);
  29. void handle_multi_piping(int **fd, int pipe_nbr, char ***cmd_opt, int i);
  30. /*
  31. ** cmd_split.c
  32. */
  33. char **cmd_split(char const *str, char c, char d);
  34. /*
  35. ** exec.c
  36. */
  37. void manage_cmd(char **cmdt);
  38. void execute(char **cmdt);
  39. void check_file_exist_exec_rights(char *path, char **cmd);
  40. /*
  41. ** env.c
  42. */
  43. char *get_tenv(char *var);
  44. void ft_setenv(char *namevalue);
  45. void ft_unsetenv(char *name);
  46. int isenv(char *str);
  47. /*
  48. ** tabenv.c
  49. */
  50. void add_env(char *nenv);
  51. void del_env(char *old_env);
  52. /*
  53. ** cd.c
  54. */
  55. void cd(char **path);
  56. char *get_pwd();
  57. /*
  58. ** tools.c
  59. */
  60. void sighandler();
  61. void error_message(char *one, char *two, char *three);
  62. char **change_tilde_to_home(char **cmd);
  63. int check_cmd_presence(char *cmd);
  64. #endif