-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.h
65 lines (53 loc) · 1.43 KB
/
main.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
#ifndef _SIMPLE_SHELL_
#define _SIMPLE_SHELL_
#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdbool.h>
#include <errno.h>
/**
* struct env_var - Node for env variables
* @key: key of Node
* @value: value of node
* @next: Pointer to next node or NULL
*
* Description: Forms the structure of the linked list
*/
typedef struct env_var
{
char *key;
char *value;
struct env_var *next;
} envstruct;
extern char **environ;
extern char *lineptr;
void exit_cmd(int);
void env_cmd(void);
void setenv_cmd(char **argv, envstruct *head);
void unsetenv_cmd(char **argv, envstruct *head);
int cd_cmd(char **argv);
void exec_builtin_cmd(char **argv, envstruct *head);
void exec_executable_cmd(char *cmd, char **argv, char **env);
char *_getline(void);
int is_builtin_cmd(char *cmd);
char *_getenv(char *name);
char *check_cmd(char *argv);
void execve_cmd(char *cmd, char **argv, char **env);
char *_strdup(char *str);
/** char *strtok(char *str, char *sep); */
void init_env_list(envstruct *head);
envstruct *insert_end(envstruct *head, char *key, char *value);
char *get_value(envstruct *head, char *key);
int print_all(envstruct *head);
int remove_value(envstruct **head, char *key);
void free_list(envstruct *head);
typedef void (*sighandler_t)(int);
void clean_up(void);
void sig_int_handler(int signum);
#endif