-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.c
executable file
·157 lines (137 loc) · 2.73 KB
/
main.c
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
* main.c - Main source file
* Written by Ercan Ersoy.
*/
#include "minibox.h"
#ifdef VERSION
void version(void)
{
puts(STRING_MINIBOX_VERSION);
}
#endif
int main(int argc, char *argv[])
{
if(argc >= 2)
{
#ifdef COMMAND_BEEP
if(!strcmp(argv[1], "beep"))
{
return command_beep(argc, argv);
}
#endif
#ifdef COMMAND_CAT
if(!strcmp(argv[1], "cat"))
{
return command_cat(argc, argv);
}
#endif
#ifdef COMMAND_CD
if(!strcmp(argv[1], "cd"))
{
return command_cd(argc, argv);
}
#endif
#ifdef COMMAND_CLEAR
if(!strcmp(argv[1], "clear"))
{
return command_clear(argc, argv);
}
#endif
#ifdef COMMAND_CP
if(!strcmp(argv[1], "cp"))
{
return command_cp(argc, argv);
}
#endif
#ifdef COMMAND_DATE
if(!strcmp(argv[1], "date"))
{
return command_date(argc, argv);
}
#endif
#ifdef COMMAND_ECHO
if(!strcmp(argv[1], "echo"))
{
return command_echo(argc, argv);
}
#endif
#ifdef HELP
#ifdef COMMAND_HELP
if(!strcmp(argv[1], "help"))
{
return command_help(argc, argv);
}
#endif
#endif
#ifdef COMMAND_LS
if(!strcmp(argv[1], "ls"))
{
return command_ls(argc, argv);
}
#endif
#ifdef COMMAND_MKDIR
if(!strcmp(argv[1], "mkdir"))
{
return command_mkdir(argc, argv);
}
#endif
#ifdef COMMAND_MV
if(!strcmp(argv[1], "mv"))
{
return command_mv(argc, argv);
}
#endif
#ifdef COMMAND_PWD
if(!strcmp(argv[1], "pwd"))
{
return command_pwd(argc, argv);
}
#endif
#ifdef COMMAND_RM
if(!strcmp(argv[1], "rm"))
{
return command_rm(argc, argv);
}
#endif
#ifdef COMMAND_RMDIR
if(!strcmp(argv[1], "rmdir"))
{
return command_rmdir(argc, argv);
}
#endif
#ifdef COMMAND_SH
if(!strcmp(argv[1], "sh"))
{
return command_sh(argc, argv);
}
#endif
#ifdef COMMAND_TIME
if(!strcmp(argv[1], "time"))
{
return command_time(argc, argv);
}
#endif
#ifdef HELP
if(!strcmp(argv[1], "--help"))
{
puts(STRING_MINIBOX_DESCRIPTION);
puts(STRING_MINIBOX_USAGE);
puts(" MINIBOX --help|--version");
puts(" MINIBOX ");
return EXIT_SUCCESS;
}
#endif
#ifdef VERSION
if(!strcmp(argv[1], "--version"))
{
version();
return EXIT_SUCCESS;
}
#endif
}
else
{
puts(STRING_NO_ENOUGH_ARGUMENTS);
return EXIT_SUCCESS;
}
}