-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_body.h
More file actions
102 lines (87 loc) · 1.82 KB
/
shell_body.h
File metadata and controls
102 lines (87 loc) · 1.82 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef __SHELL_BODY_H__
#define __SHELL_BODY_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <pwd.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#define TRUE 1
#define FALSE 0
enum command_error
{
OK
};
enum command_name
{
NONE,
EXIT,
CD,
PWD,
HISTORY
};
enum output_types
{
NO,
REWRITE,
APPEND
};
typedef struct
{
enum command_name name;
int count_arg;
char** arg;
char* input_file;
char* output_file; /* NULL - no redirection */
enum output_types output_type; /* 1 - rewrite, 2 - append */
} program;
typedef struct
{
int foreground;
pid_t group_id;
program** prog; //programs
int count_prog;
} job;
// typedef struct
// {
// char** str;
// int count_str;
// int max_num;
// int difference;
// } hist;
typedef struct type_node
{
struct type_node* next;
struct type_node* prev;
char* str;
int num;
}node;
typedef struct
{
node* head;
node* tail;
node* prevhist;
int max_num;
}main_node;
char* cmd_all[] = {"exit", "cd", "pwd", "history"};
//hist story = {NULL, 0, 100, 0};
main_node main_hist = {NULL, NULL, NULL, 100};
main_node* hist = &main_hist;
int argc_main;
char** argv_main;
char* input_str;
void delete_history();
char* delete_comments(char* str);
void shell_exit();
char* command_input(char* str);
void command_parser(char* str);
void job_controller(char* str);
void command_line();
#endif /* __SHELL_BODY_H__ */