-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshell.h
175 lines (104 loc) · 3.35 KB
/
shell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef _SHELL_H_
#define _SHELL_H_
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <stddef.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <dirent.h>
#include <signal.h>
/* FLAGS */
#define FL_BUFF 1
#define F_CMD_L 2
#define FL_CMDS 4
/**
* struct list_s - singly linked list
* @str: string - (malloc'ed string)
* @len: length of the string
* @next: points to the next node
*
* Description: singly linked list node structure
* for the ALX project
*/
typedef struct list_s
{
char *str;
unsigned int len;
struct list_s *next;
} list_t;
int handle_args(int ac, char **av, int *execute_file);
void sigintHandler(int __attribute__((unused))sig_num);
char *get_av_1(void);
char *env_get(char *name);
int exit_handler(char *buff, char **list_cmd, char **cmd);
int check_exit(char *buff);
int *code_exiter();
void code_exit_set(int code);
int *hist_count();
void line_cnt_updt(void);
void var_rep(char **cmd);
int line_rd(const int fd, char **line);
int line_rd_f(char **str, char **line, int fd);
int _help(char **commands);
void free_hist(void);
void hist_handler(char *buff);
int _hist(void);
list_t **last_cmd_addr();
list_t **get_hist_addr();
void *_realloc(void *ptr, unsigned int old_sz, unsigned int new_sz);
void write_hist(void);
int _alias(char **commands);
int _cd(char *path);
int _unsetenv(char *name);
int _setenv(char *name, char *value);
void env(void);
int _puts(char *str);
int get_env_postn(char *name);
int var_name_is_valid(char *name);
int env_name_verify(char *name);
char *path_finder(char *dir, char *filename);
int PATH_Handler(char **commands);
int args_counter(char *str_input, char *delimiter);
char **input_parser(char *str_input, char *delimiter);
void print_builtin_error(char *msg, char *arg);
void dispatch_error(char *msg);
int other_set_inbuilts(char **commands);
int inbuilt_envar(char **commands);
int inbuilt_handler(char **commands);
char *comment_handler(char *str_input);
int enter_handler(char **commands);
void opp_handler(char *buff, int read, char *first_av);
void or_handler(char *buff_semicolon, int read, char *first_av);
int and_handler(char *buff_or, int read, char *first_av, int prev_flag);
int execute_commands(char *buff, char **cmds_list, char *cmd,
int __attribute__((unused))read, char *first_av);
void handle_cmnd_not_found(char *buff, char **cmds_list,
char **commands, char *first_av);
size_t print_list(const list_t *h);
list_t *end_node_add(list_t **head, const char *str);
void free_list(list_t *head);
void *allc_memry(unsigned int bytes);
char *str_dup(char *str);
void free_dbl_ptr(char **dbl_ptr);
void free_allocs(char *buff, char **cmds_list, char **commands, int flags);
void build_dynamic_environ(void);
void free_dynamic_environ(void);
char *join_str(char const *s1, char const *s2);
char *strsub_f(char const *s, unsigned int start, size_t len);
void f_memdel(void **ap);
void strdel_f(char **as);
char *str_num(int num);
char *str_scan(const char *s, int c);
char *n_strcat(char *s1, const char *s2, size_t n);
char *get_av_1(void);
void aliases_handler(char **commands);
void allc_free(char *buff, char **cmds_list, char **commands, int flags);
list_t **head_alias_get();
int args_alias_handle(char **commands, list_t **out_addrs);
#endif