-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
76 lines (59 loc) · 1.95 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
#ifndef MAIN_H
#define MAIN_H
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/wait.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/types.h>
/* global variable to access environment */
extern char **environ;
int infinite_loop(char *program_path);
/* and split arguments && execution the commands*/
void sh(char *str, char **args, char **paths, int p_cnt, char *p_path,
int *st);
/* checker helper functions*/
int check_full_path(char *argument);
char *check_small_path(char *argument, char **path);
/* string helper functions*/
int _strlen(char *str);
int _strcmp(char *str1, char *str2);
char *_strconcat(char *str1, char *str2);
char *_strcopy(char *str);
void remove_comment(char *str);
/* string helper functions 2*/
char **split(char *string, char *breaks);
int _atoi(char *s);
char *cleanStr(char *str);
ssize_t _getline(char **string, size_t *string_size);
/*string helper functions 3*/
char *_strconcat2(char *str1, char *str2);
/* environment helper functions*/
char **get_all_paths(void);
char *get_env(char *string);
/*execution functions*/
void before_exec(char **args, char **paths, int p_cnt, char *p_path, int *st);
void execution(char **arguments, int *st);
/* array helper functions*/
char **copy_array_of_strings(char **str);
void free_array_of_pointers(char **array);
void remove_idx_from_array(int idx, char **array);
/* built in checker */
int check_exit(char **args, char *str, char **paths, int *st,
char *pth, int p);
int check_builtin(char **arguments);
/* built in functions*/
int set_env_variable(char **arguments);
int unset_env_variable(char **arguments);
int _cd(char **arguments);
int print_env(char **arguments);
/*free helper functions */
void free_all(char **arguments, char *string, char **paths);
/*error functions*/
void execve_error(char *msg, char *command, int count, char *p_path);
/*number helper functions*/
void print_num(unsigned int n);
int check_positive(char *str);
#endif