-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathholberton.h
93 lines (67 loc) · 1.86 KB
/
holberton.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
84
85
86
87
88
89
90
91
92
93
#ifndef HOLBERTON_H
#define HOLBERTON_H
#define _GNU_SOURCE
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#define SHELL_PROMPT "#cash$ "
#define CHAR_BUF_MAX 1024
/**
* struct shell - struct for holding relevant variables related to the
* functioning of the simple shell program
*
* @i_buf: input buffer for shell input
* @p_buf: parsed string array for parsed input
* @env: parsed string array for environment variables
* @name: argv[0] value for each shell call
* @rel: stores absolute path when found for relative arguments
* @exec: if executable is found
* @count: counter of number of loops shell main has initiated
* @exit: used to trigger exit conditions
*/
typedef struct shell
{
char *i_buf;
char **p_buf;
char **env;
char *name;
char *rel;
int exec;
int count;
int exit;
} shell;
/**
* struct select - struct for selecting which operation to perform
* on input string array
*
* @cmd: control string
* @fun: correlating function pointer
*/
typedef struct select
{
char *cmd;
void (*fun)();
} exec;
int _strlen(char *s);
int _strcmp(char *s1, char *s2);
char *_strcat(char *dest, char *src);
char *int_arg(int input);
void *_calloc(unsigned int nmemb, unsigned int size);
void *memeset(void *a, int c, int size);
char *_strcpy(char *dest, char *src);
int input_get(struct shell cash);
int input_parse(struct shell cash);
void (*input_exec(struct shell cash))(struct shell);
void shell_exec(struct shell cash);
void shell_exit(struct shell cash);
void shell_env(struct shell cash);
void shell_error(struct shell cash, int error);
void process_rel_path(struct shell cash);
char *_getenv(struct shell cash);
void direct_path(struct shell cash);
char *_strtok(char *str, const char *delim);
unsigned int _strspn(char *s, const char *accept);
#endif /*HOLBERTON_H*/