-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.h
59 lines (51 loc) · 1.65 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
#ifndef MAIN_H
#define MAIN_H
#include "unistd.h"
#include <errno.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
extern char **environ;
extern char *newvariable;
extern int envfreesignal;
extern int envargssignal;
#define MAX_PATH_LENGTH 1024
/** Print prompt**/
void print_dollar(void);
char *read_command(void);
void remove_comments(char *command);
char **seperate_input(char *command);
char *find_command_in_path(char *path, char *command);
char *_getenv(const char *name);
int runpathcmd(char *command, char **tokens);
int runpathlesscmd(char *command, char **tokens);
int _stripstr(char *command);
int execute_command(char *command, char **tokens_array);
void freecommandspath(char *command, char **tokens);
void exec_and_free(char *command, char **tokens, char *directory);
/**
* struct builtin - Represents a built-in shell command.
* @name: The name of the built-in command.
* @function: A pointer to the function that implements the comand
*/
struct builtin {
char *name;
void (*function)(char **args, int argc, char *command);
};
typedef struct builtin BuiltInCommand;
int execute_builtin(char **args, char *command);
void exit_builtin(char **args, int argc, char *command);
void env_builtin(char **args, int argc, char *command);
void clear_builtin(char **args, int argc, char *command);
void cd_builtin(char **args, int argc, char *command);
void setenv_builtin(char **args, int argc, char *command);
void _unsetenv(char **args, int argc, char *command);
int count_elements(char **array);
void call_signal(void);
char *get_input(void);
#endif