/
builtin.h
118 lines (95 loc) · 3.11 KB
/
builtin.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/* CMPSC 311, Spring 2013, Project 7
*
* Author: Jacob Jones
* Email: jaj5333@psu.edu
*
* Author: Scott Cheloha
* Email: ssc5145@psu.edu
*/
#ifndef BUILTIN_H
#define BUILTIN_H
/* Builtin() compares Argv[0] to the builtin commands.
* If a match is found, the command is run, and builtin returns 1.
* If a match is not found, builtin returns 0.
*/
int Builtin(char *Argv[]);
/* Quit() exits the shell.
* If background processes are still running, Quit() refuses to exit,
* and instead displays the currently running background processes.
*/
void Quit(void);
/* Echo() prints the remaining command-line arguments from Argv[].
* The arguments are separated by a space each, ala bash's 'echo'
*/
void Echo(char *Argv[]);
/* Dir() prints the current working directory to the console.
* Compare to sh's 'pwd'.
*/
void Dir(void);
/* Cdir() changes the current working directory to Argv[1].
* If Argv[1] is NULL, the environment variable HOME is used instead.
* Compare to sh's 'cd' or 'chdir'.
*/
void Cdir(char *Argv[]);
/* Penv() prints the specified environment variable.
* If not variable is specified, Penv() prints all known variables.
* If the variable does not exist, Penv() prints nothing, and does not complain.
* Compare to sh's 'printenv'
*/
void Penv(char *Argv[]);
/* Senv() sets the specified variable to a given value.
* Format is
* senv name=value
*
* Senv() complains if no '=' is present in the argument string.
* Compare to csh's 'setenv' or 'set'
*/
void Senv(char *Argv[]);
/* Unsenv() removes the specified environment variable
* Format is
* unsenv name
*
* Unsenv() complains if the given variable does not exist
* Compare to sh's 'unset'
*/
void Unsenv(char *Argv[]);
/* Pjobs() Prints the current background processes, held by list */
void Pjobs(void);
/* Help() prints the various builtin commands implemented for Project 7.
* For a complete list, see requirement (1) of Project 7 spec.
* We also implement:
* limit -- prints various limit macros (mostly defined in pr7.h)
* toggle -- user can toggle verbosity, debug, and echo from interactive mode
*/
void Help(void);
/* Toggle allows the user to toggle on/off echo, verbosity, and debug output
* Format is
* toggle [e|v|d]
*/
void Toggle(char *Argv[]);
/* User-friendly wrapper for Print_Options() */
void Options(void);
/* Prints the current command line options to the console
* Note that this is not a builtin command, and is only run when
* 'options' is called from the shell.
*/
void Print_Options(void);
/* Set() allows toggling echo, exec types, verbose, and debug */
void Set(char *Argv[]);
/* Secho() toggles exec type (vp,ve,lp) */
void Sexec(char *Argv[]);
/* Secho() toggles echo on or off */
void Secho(char *Argv[]);
/* Secho() toggles verbose on or off */
void Sverbose(char *Argv[]);
/* Secho() toggles debug on or off */
void Sdebug(char *Argv[]);
/* Prints formatted list of command shell limitations.
* First optional extra credit in project 7 specs.
*/
void Limits(void);
/* forcibly kill a background process
* optional extra credit in project 7 specs.
*/
void pr7_Kill(char *Argv[]);
#endif /* BUILTIN_H */