forked from zguaidh/simple_shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
79 lines (65 loc) · 1.72 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef MAIN_H_
#define MAIN_H_
/* Header files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <errno.h>
/* MACRO */
extern char **environ;
/* Structures */
/**
* struct builtins - structure that finds the char in built
* and returns function *f
*
* @built: character to be found
* @f: function to be returned
*/
typedef struct builtins
{
char *built;
void (*f)(char *, char **, char **);
} builtins;
/* Main functions */
int _stat(char *filename);
void tokenize(char *str, char *delim);
char **copy_token(char *str, char *delim);
int num_tokens(char **str);
char *name_of_program;
char *name_of_command;
char *name_of_dst;
int count;
int exit_status;
void execute(char *filename, char **exec_arg);
void exec_from_path(char **exec_arg);
char *concat_path(char **exec_arg);
void free_contents(char **str);
char *concat_path(char **exec_arg);
char **get_path(void);
/* Builtins */
void get_cwd(char *str, size_t size, char *var);
void cd_req(char *str, char **env, char **exec_arg);
void exit_req(char *str, char **env, char **args);
void env_req(char *str, char **env, char **args);
void (*get_b(char *s, char **env, char **a))(char *s, char **env, char **a);
int _build(char **exec_arg, char *buff, char **env);
/* Helper functions */
void _print(char *str);
void _print_err(char *str);
int print_char(char c);
int _strlen(char *str);
char *_strdup(char *str);
char *_strcat(char *s1, char *s2);
int _strcmp(char *s1, char *s2);
char *_strcpy(char *s1, char *s2);
char *_strstr(char *haystack, char *needle);
int print_number(int n);
/* Error printing */
void print_error(void);
void print_error_exec(void);
void cd_err(void);
#endif