-
Notifications
You must be signed in to change notification settings - Fork 0
/
shell.h
80 lines (62 loc) · 1.89 KB
/
shell.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
#ifndef SHELL_H
#define SHELL_H
#define bool int
#define true 1
#define false 0
#define NPTRS(n) (n * sizeof(void *))
#define NCHARS(n) (n * sizeof(char))
#include "headers/include.h"
#include "headers/list.h"
#include "headers/string.h"
#include "headers/builtin.h"
#include "headers/path.h"
extern char **environ;
/* io */
void printerr(const char *message);
void printout(const char *message);
void fprinterr(char *message);
void fprintout(char *message);
void prompt(state *self);
/* quote */
int findquote(char *str, char quote);
void comment(char *string);
bool should_quote(const char *string);
char *remove_quotes(char *string);
/* line */
char *getlines(int fd);
char **split(char *string, char *delimiter,
unsigned int max, bool group_quote);
/* find */
char *findcmd(const char *command, const char *PATH);
struct dirent *findfile(DIR *dir, const char *filename);
char *joinpath(const char *base, const char *child);
/* run */
int interactive(state *self);
int non_interactive(state *self, int fd);
int execute(const char *program, char **args, char **env);
int runline(state *self, char *line);
bool runbuiltin(state *self, char **arguments);
bool runprogram(state *self, char **arguments);
bool runalias(state *self, char **command);
/*tokenizefile*/
char ***tokenizefiles(char *line);
char **tokenizefile(char *line);
void replaceline(char *av[]);
/* append */
bool appendStr(char ***arr, size_t *size, char *str, int index);
bool appendChar(char **string, size_t *size, char chr, int index);
bool appendInt(char **string, size_t *size, int num, int index);
/*atoi*/
int checkatoi(char *s);
int _atoi(char *s);
/* format */
char *format(const char *fmt, ...);
/* main */
state *init(char *prog, char **env);
void deinit(state *self);
void cleanup(state *self);
/* replacement */
char *replace(state *self, char *var);
/* realloc */
void *_realloc(void *ptr, unsigned int osize, unsigned int nsize);
#endif