-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.h
85 lines (69 loc) · 2.02 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
80
81
82
83
#ifndef MAIN_H
#define MAIN_H
#include <stdio.h>
#include <stddef.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <string.h>
#include <sys/stat.h>
/* parse.c */
int count_tokens(char *buffer, char *delim);
void handle_comments(char **tokens);
char **parse(char *buffer, char *delim);
/* search.c */
char *search(char *command);
/* exec.c */
int execute(char **tokens, char *argv[], char **env);
/* builtins.c */
int (*is_builtin(char *cmd))(char **, char **, char **);
/**
* exec_builtin - prototype to exec_builtin functon
* @func: pointer to the builtin function that will execute
* @tokens: elements of the entered command line
* @env: environment variables
* @argv: program arguments
* Return: status of executing
*/
int exec_builtin(int (*func)(char **, char **, char **),
char **tokens, char **env, char **argv);
int handle_exit_args(char **tokens, char **argv);
/**
* builtin_exit - prototype to builtin_exit function
* @tokens: the cmmmand line that is entered by user
* @env: enviroment variables
* @argv: prgram arguments
* Return: -1
*/
int builtin_exit(__attribute__((unused)) char **tokens,
__attribute__((unused)) char **env,
__attribute__((unused)) char **argv);
/**
* builtin_env - prototype to builtin_env function
* @tokens: the cmmmand line that is entered by user
* @env: enviroment variables
* @argv: prgram arguments
* Return: 0
*/
int builtin_env(__attribute__((unused)) char **tokens,
char **env,
__attribute((unused)) char **argv);
int builtin_cd(char **tokens, __attribute__((unused)) char **env, char **argv);
/**
* struct builtin_t - structure to hold
* the builtin command and their functions
* @cmd: pointer to string (command name)
* @func: command function
*/
typedef struct builtin_t
{
char *cmd;
int (*func)(char **, char**, char **);
} builtin_s;
/* utils.c */
void print_error(char *program_name, char *msg);
void free_dptr(char **dptr);
int _atoi(char *str);
int handle_program_return_value(char **tokens, char **argv, int status);
#endif