-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdksh.h
62 lines (56 loc) · 2.06 KB
/
dksh.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
#ifndef DKSH_H
#define DKSH_H
#include "dksh_common.h"
#define LINEMAX 80
#define ARGMAX 16
#define HISTMAX 500
/* prototypes for extern functions */
int gethostname(char *, size_t);
char *strdup(const char *);
/* dksh built-in functions */
int pwd(void);
int cd(char **);
int echo(int, char **, int);
int cat(int, char **);
int ls(int, char **);
int my_mkdir(int, char **);
int my_rmdir(int, char **);
int rm(int, char **);
int date(void);
int my_chmod(int, char **);
int wc(int, char **);
int my_kill(int, char **);
int history(char **);
int who(int, char **);
int help(void); /* list the commands that dksh supports */
int grep(int, char **);
int mv(int, char **);
int tee(int, char **);
int my_time(int, char **);
int more(int, char **);
int my_dcl(int, char **);
int undcl(int, char **);
int my_sleep(int, char **);
void my_exit(void);
/* prototypes for file static functions */
static void ignore_signal(void); /* ignore some signals */
static void handle_sigchld(void); /* handle SIGCHLD signal */
static void do_handle_sigchld(int); /* handle SIGCHLD signal */
static void print_promt(const char *, const char *); /* print the prompt */
static void process_ctrl_d(void); /* Ctrl-D to exit */
static int is_same_command(int); /* check if it is the same command */
static void record_history(int *); /* record the command history */
static int get_args(const char *); /* parse the input to get args */
static void free_args(void); /* free the memory of args */
static void free_hist(void); /* free the memory of hist */
static void clean_up(void); /* free the memory of args and hist */
static void run_built_in_cmd(int, char **); /* run dksh built-in commands */
static int do_run_built_in_cmd(int, char **); /* run dksh built-in commands */
static void run_system_or_user_cmd(void); /* run symtem or user's commands */
/* file static variables */
static char input[LINEMAX];
static char *args[ARGMAX];
static char *hist[HISTMAX];
static int return_value; /* echo $? */
static int background; /* run cmd in the background */
#endif /* DKSH_H */