/
aash.h
61 lines (47 loc) · 1.48 KB
/
aash.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
#ifndef AASH_H
#define AASH_H
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define CRED isatty(STDOUT_FILENO) ? "\x1b[31m" : ""
#define CGREEN isatty(STDOUT_FILENO) ? "\x1b[32m" : ""
#define CYELLOW isatty(STDOUT_FILENO) ? "\x1b[33m" : ""
#define CBLUE isatty(STDOUT_FILENO) ? "\x1b[34m" : ""
#define CMAGENTA isatty(STDOUT_FILENO) ? "\x1b[35m" : ""
#define CCYAN isatty(STDOUT_FILENO) ? "\x1b[36m" : ""
#define CRESET isatty(STDOUT_FILENO) ? "\x1b[0m" : ""
#define SPACE " \t"
extern pid_t cpid;
extern int last_wstatus;
struct array {
char **items;
unsigned long numitems;
};
struct fd {
int stdin;
int stdout;
int stderr;
};
struct redir_stats {
char *filename;
char append;
};
char *get_input(void);
struct array tokenizer(char *string, const char *delim);
struct array tokenizer_whitespace(char *string);
struct array tokenizer_semicolon(char *string);
void print_prompt(void);
char execute_command(char **to_run);
void builtin_cd(const char *argument);
void builtin_exit(const char *argument);
struct redir_stats get_redir_stats(char **command, char *redirection);
int redirect_stdin(struct redir_stats r, struct fd *fds);
int redirect_stdout(struct redir_stats r, struct fd *fds);
int redirect_stderr(struct redir_stats r, struct fd *fds);
void process_redirects(char **command, struct fd *fds);
void reset_redirects(struct fd *fds);
void errno_handler(int en);
char *cwd_basename(void);
#endif /* _AASH_H */