-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.c
More file actions
64 lines (55 loc) · 1.21 KB
/
client.c
File metadata and controls
64 lines (55 loc) · 1.21 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
#include "include.h"
size_t MAX_READ_THREADS = 1;
size_t MAX_CLIENT_THREADS = 100;
int main(int argc, char** argv) {
char host[255], buf[255], proxy[255];
DIR * dp;
int p_port, s_port, trials, use_proxy = 0;
size_t count = 0;
struct list_t file_list;
struct dirent *entries;
switch (argc) {
case 7:
strcpy(proxy, argv[5]);
p_port = atoi(argv[6]);
use_proxy = 1;
case 5:
strcpy(host,argv[1]);
s_port = atoi(argv[2]);
trials = atoi(argv[3]);
MAX_CLIENT_THREADS = atoi(argv[4]);
break;
default:
fprintf(stderr, "Not enough arguments!\n");
exit(1);
break;
}
init(&file_list);
buf[0]='/';
dp = opendir(".");
if(dp) {
while( (entries = readdir(dp)) ) {
if(entries->d_name[0] == '.')
continue;
strcpy(&(buf[1]), entries->d_name);
push_back(&file_list, buf, strlen(entries->d_name)+1,
NULL, 0);
++count;
}
(void) closedir(dp);
}
else {
perror("Could not open root directory!");
}
if(!count) {
fprintf(stderr, "No files in root directory, nothing to do.\n");
exit(1);
}
if(use_proxy)
cc_start(&file_list, trials, s_port, host, proxy, p_port);
else
cc_start(&file_list, trials, s_port, host, NULL, 0);
cc_stop();
destroy(&file_list);
return 0;
}