-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
65 lines (54 loc) · 987 Bytes
/
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
#include "big4f.h"
int main(int argc, char *argv[])
{
// Check for first arg
if (argc < 2)
{
printf_help_exit(0);
}
// Needs to be just one char
if (argv[1][1])
{
printf_help_exit(1);
}
printf("\n");
switch (argv[1][0])
{
case 'l':
// Not enough args
if(argc < 3)
{
printf_help_exit(1);
}
// Exits on failure
BIGFile_List(argv[2]);
printf("\nSuccessfully listed %s\n", argv[2]);
break;
case 'e':
case 'x':
// Not enough args
if(argc < 4)
{
printf_help_exit(1);
}
// Exits on failure
BIGFile_Extract(argv[2], argv[3]);
printf("\nSuccessfully extracted %s\n", argv[2]);
break;
case 'f':
case '4':
// Not enough args
if(argc < 4)
{
printf_help_exit(1);
}
// Exits on failure
BIGFile_Pack(argv[2], argv[3], (char)argv[1][0]);
printf("\nSuccessfully packed %s\n", argv[3]);
break;
default:
printf_help_exit(1);
break;
}
return 0;
}