-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.c
60 lines (57 loc) · 1.17 KB
/
client.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
#include "client.h"
#include "read.h"
#include "write.h"
#include "retrieve.h"
#include "makedir.h"
#include "delete.h"
#include "copy.h"
int main()
{
char command[4096];
fgets(command, 4096, stdin);
char *args[MAX_TOKENS];
int arg_count = 0;
// Tokenize the command
char *token = strtok(command, " \t");
while (token != NULL)
{
args[arg_count] = token;
arg_count++;
token = strtok(NULL, " \t");
}
args[arg_count] = NULL;
int i = 0;
while (args[i] != NULL)
{
if (!strcmp("CREATE", args[i]))
{
makedirs(args);
}
else if (!strcmp("READ", args[i]))
{
reads(args);
break;
}
else if (!strcmp("WRITE", args[i]))
{
writes(args);
break;
}
else if (!strcmp("RETRIEVE", args[i]))
{
retrieves(args);
break;
}
else if (!strcmp("DELETE", args[i]))
{
deletes(args);
break;
}
else if (!strcmp("COPY", args[i]))
{
copys(args);
break;
}
i++;
}
}