-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsing.c
43 lines (38 loc) · 1.03 KB
/
parsing.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
//
// Created by 闫传麒 on 2018/12/1.
//
#include "parsing.h"
int error(char* msg) {
fprintf(stderr, "%s\n", msg);
return 0;
}
char* const short_options = "n:h:p:f:";
struct option long_options[] = {
{"number", 1, NULL, 'n'},
{"hostname", 1, NULL, 'h'},
{"port", 1, NULL, 'p' },
{"localdirectory", 1, NULL, 'f'},
{NULL, 0, NULL, 0 }
};
int analyzeparameter(int argc, char *argv[], struct parg* args) {
int c;
while ((c = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
switch (c) {
case 'n':
args->maxFlow = atoi(optarg);
break;
case 'h':
strcpy(args->hostname, optarg);
break;
case 'p':
args->portnum = atoi(optarg);
break;
case 'f':
strcpy(args->localDirectory, optarg);
break;
default:
error("invalid argument!");
exit(1);
}
}
}