-
Notifications
You must be signed in to change notification settings - Fork 0
/
box.c
118 lines (117 loc) · 4.22 KB
/
box.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
/* fasesiab - Ferass' Base System in a box
* Copyright (C) 2022 Ferass EL HAFIDI
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
/* START */
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#include <stdio.h>
/* END */
int test_main(int, char**);
int basename_main(int, char**);
int cat_main(int, char**);
int chmod_main(int, char**);
int chown_main(int, char**);
int date_main(int, char**);
int dirname_main(int, char**);
int echo_main(int, char**);
int false_main(int, char**);
int head_main(int, char**);
int link_main(int, char**);
int ln_main(int, char**);
int ls_main(int, char**);
int mkdir_main(int, char**);
int more_main(int, char**);
int mv_main(int, char**);
int printf_main(int, char**);
int rm_main(int, char**);
int sleep_main(int, char**);
int tail_main(int, char**);
int test_main(int, char**);
int true_main(int, char**);
int uname_main(int, char**);
int unlink_main(int, char**);
/* START */
int main(int argc, char *argv[]) {
if (!strcmp(basename(argv[0]),"box") && argc > 1) {
argc--;
argv++;
} if(0);
/* END */
else if(!strcmp(basename(argv[0]), "[")) return test_main(argc, argv);
else if(!strcmp(basename(argv[0]), "basename")) return basename_main(argc, argv);
else if(!strcmp(basename(argv[0]), "cat")) return cat_main(argc, argv);
else if(!strcmp(basename(argv[0]), "chmod")) return chmod_main(argc, argv);
else if(!strcmp(basename(argv[0]), "chown")) return chown_main(argc, argv);
else if(!strcmp(basename(argv[0]), "date")) return date_main(argc, argv);
else if(!strcmp(basename(argv[0]), "dirname")) return dirname_main(argc, argv);
else if(!strcmp(basename(argv[0]), "echo")) return echo_main(argc, argv);
else if(!strcmp(basename(argv[0]), "false")) return false_main(argc, argv);
else if(!strcmp(basename(argv[0]), "head")) return head_main(argc, argv);
else if(!strcmp(basename(argv[0]), "link")) return link_main(argc, argv);
else if(!strcmp(basename(argv[0]), "ln")) return ln_main(argc, argv);
else if(!strcmp(basename(argv[0]), "ls")) return ls_main(argc, argv);
else if(!strcmp(basename(argv[0]), "mkdir")) return mkdir_main(argc, argv);
else if(!strcmp(basename(argv[0]), "more")) return more_main(argc, argv);
else if(!strcmp(basename(argv[0]), "mv")) return mv_main(argc, argv);
else if(!strcmp(basename(argv[0]), "printf")) return printf_main(argc, argv);
else if(!strcmp(basename(argv[0]), "rm")) return rm_main(argc, argv);
else if(!strcmp(basename(argv[0]), "sleep")) return sleep_main(argc, argv);
else if(!strcmp(basename(argv[0]), "tail")) return tail_main(argc, argv);
else if(!strcmp(basename(argv[0]), "test")) return test_main(argc, argv);
else if(!strcmp(basename(argv[0]), "true")) return true_main(argc, argv);
else if(!strcmp(basename(argv[0]), "uname")) return uname_main(argc, argv);
else if(!strcmp(basename(argv[0]), "unlink")) return unlink_main(argc, argv);
/* START */
else if (!strcmp(basename(argv[0]), "box") && argc == 1) {
printf("Ferass' Base System in a box\n\n");
printf("Usage: box <COMMAND> [ARGS]\n\n");
printf("Commands available:\n");
/* END */
printf("[ ");
printf("basename ");
printf("cat ");
printf("chmod ");
printf("chown ");
printf("date ");
printf("dirname ");
printf("echo ");
printf("false ");
printf("head ");
printf("link ");
printf("ln ");
printf("ls ");
printf("mkdir ");
printf("more ");
printf("mv ");
printf("printf ");
printf("rm ");
printf("sleep ");
printf("tail ");
printf("test ");
printf("true ");
printf("uname ");
printf("unlink ");
/* START */
printf("\n");
}
else {
printf("box: %s: Not found or not implemented.\n", argv[0]);
}
return 0;
}
/* END */
/* Generated on Sun 23 Oct 19:30:23 CEST 2022 */