-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.h
More file actions
80 lines (68 loc) · 1.89 KB
/
shell.h
File metadata and controls
80 lines (68 loc) · 1.89 KB
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_HEADER
#define SHELL_HEADER
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <wait.h>
#include <stdlib.h>
#include <fcntl.h>
#include <signal.h>
#define MAXARGS 256
#define MAXCMDS 50
#define MAXLINELEN 1024
//#define DEBUG
/* A process is a single process. */
typedef struct process
{
struct process *next; /* next process in pipeline */
int nargs;
char *argv[MAXARGS]; /* for exec */
pid_t pid; /* process ID */
char completed; /* 1 if process has completed */
char stopped; /* 1 if process has stopped */
int status; /* reported status value */
int stderrno;
} process;
/* A job is a pipeline of processes. */
typedef struct job
{
struct job *next; /* next active job */
char *command; /* command line, used for messages */
process *first_process; /* list of processes in this job */
pid_t pgid; /* process group ID */
char notified; /* true if user told about stopped job */
int stdinno, stdoutno, stderrno; /* standard i/o channels */
struct termios tmodes; /* saved terminal modes */
char foreground;
char launched;
char builtin;
} job;
/* ÇÏÌÏ×Á ÓÐÉÓËÁ ÚÁÄÁÎÉÊ */
extern job *first_job;
extern pid_t shell_pgid;
typedef enum tokenType
{
WORD,
AMPERSAND, /* '&' */
SEMICOLON, /* ';' */
LEFTARROW, /* '<' */
RIGHTARROW, /* '>' */
REALLYRIGHTARROW, /* '>>' */
PIPE, /* '|' */
ERRORRIGHTARROW /* 2> */
} tokenType;
typedef struct token
{
char *place;
tokenType type;
} token;
int parseline(char *);
int promptline(char *, char *, int);
void launch_job(job *j);
extern struct termios shell_tmodes;
#endif