forked from yazgiraldoa/simple_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.h
79 lines (62 loc) · 1.72 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
#ifndef SHELL_H
#define SHELL_H
/* STD LIBRARIES */
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <errno.h>
#include <stddef.h>
#include <unistd.h>
#include <signal.h>
/*---------------------------------------------------------*/
/* MACROS */
#define SIGINT 2
extern char **environ;
extern int errno;
/*---------------------------------------------------------*/
/* PROTOTYPES */
/*-----Main functions-----*/
int shell_interactive(void);
int shell_no_interactive(int ac, char **av);
/*-----String functions-----*/
int _strlen(char *string);
int _strcmp(char *s1, char *s2);
char *_strncmp(char *PATH, char *MATCH, size_t n);
int count_words(char *str);
char *_strdup(char *str);
char *_strcat(char *dest, char *src);
char *_itoa(int i, char *strout, int base);
/*-----Aux functions-----*/
char **tokenizer(char *s, char *delim);
int (*get_builtin(char *string))();
int fork_process(char *path, char **tokens, char **environ);
char *find_path(char **tokens);
char *prompt_no_interactive(char *name_file);
char *prompt_interactive(char *name_file);
void handle_sigint(int sig);
void free_all(char **tokens);
/*-----Error_messages-----*/
void path_error(int numerr, char **tokens, char *name_file);
void permission_error(int numerr, char **tokens, char *name_file);
/*-----Built-ins-----*/
int _own_exit(void);
int env(void);
/*---------------------------------------------------------*/
/*STRUCTURES*/
/**
*struct builtin - builtin structures.
*@name: a char with a name of a file.
*@func: a int that call.
*/
typedef struct builtin
{
char *name;
int (*func)();
} built_in;
static const built_in list[] = {
{"env", env},
{"exit", _own_exit},
{NULL, NULL}};
#endif /* SHELL.H */