-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.h
More file actions
88 lines (73 loc) · 2.3 KB
/
Copy pathmain.h
File metadata and controls
88 lines (73 loc) · 2.3 KB
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
#ifndef _MAIN_H_
#define _MAIN_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
/* MACROS */
#define UNUSED(x) (void)(x)
/**
* struct response - Struct to translate the tokens and holder
*
* @toks: Double pointer to the tokens.
*
* @hold: Pointer to a token to free later.
*/
typedef struct response
{
char **toks;
char *hold;
} response;
/**
* struct built - Struct to translate the tokens and holder
*
* @key: Pointer to a key (name of the built).
*
* @func: Pointer to a function of the built.
*/
typedef struct built
{
char *key;
int (*func)(response *r, int *err, char *av, int *exit_status);
} built;
extern char **environ;
/* Shell Functions */
char *only_the_command(char *cmd);
void free_tokens(char **tokens);
void do_the_command(response *res, int *exit_status);
int all_spaces(char *command, ssize_t size);
int total_malloc(char *command);
/* Shell Functions 2*/
response *tokenize(char *input);
int first_validations(char *command, int bytes_read, int *while_st);
void validate_last_access(response *r, char *file, int *err, int *exit_status);
int route_works(response *obj, int *while_status, int *exit_status);
void free_all(response *obj, int *while_status);
/* Shell Functions 3*/
int fail_route(response *r, char *av, int *err, int *exit_status);
char *clean_spaces(char *command);
char *which(char *command);
/* Utils */
char *validate_slash(char *cmd, char *holder);
char *find_char(char *key, char character);
void display_path(void);
char *str_concat(char *s1, char *s2);
/*Built in Functions*/
int match_built_in(response *r, int *err, char *av, int *exit_status);
int built_env(response *r, int *err, char *av, int *exit_status);
int built_exit(response *r, int *err, char *av, int *exit_status);
int built_setenv(response *r, int *err, char *av, int *exit_status);
int built_unsetenv(response *r, int *err, char *av, int *exit_status);
int built_cd(response *r, int *err, char *av, int *exit_status);
int built_help(response *r, int *err, char *av, int *exit_status);
/*Future releases*/
int built_alias(response *r, int *err, char *av, int *exit_status);
/*Built in Utils*/
void c_handler(int x);
int number_of_tokens(char **tokens);
char *find_points(char *key);
int is_number(char *str);
#endif