-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
executable file
·102 lines (95 loc) · 2.93 KB
/
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
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
/*
* File: main.c
* Author: Oleksandr Tkachenko <oleksandr.tkachenko at crisp-da.de>
*
* Created on May 5, 2016, 12:52 AM
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <string.h>
#include "psi_structures.h"
#include "psi_bucketed_intersection.h"
int parse_argv(int argc, char** argv, PSI_INTERSECTION_CTX* ctx);
/*
*
*/
int main(int argc, char** argv) {
if (argc == 1) {
printf("PSI Intersection\n");
return (EXIT_FAILURE);
}
PSI_INTERSECTION_CTX ctx[1];
ctx->result = NULL;
parse_argv(argc, argv, ctx);
psi_bucketed_intersection(ctx);
return (EXIT_SUCCESS);
}
int parse_argv(int argc, char** argv, PSI_INTERSECTION_CTX* ctx) {
int index, c;
opterr = 0;
while ((c = getopt(argc, argv, "l:p:e:n:q:m:r:s:t:a:b:c:x:")) != -1)
switch (c) {
case 'p':
strncpy(ctx->path_result, optarg, 128);
break;
case 'e':
ctx->element_size = atoi(optarg);
break;
case 'n':
ctx->bucket_n = atoi(optarg);
break;
case 'l':
ctx->lookup = TRUE;
strncpy(ctx->path_lookup, optarg, 128);
break;
case 'c':
strncpy(ctx->path_lookup_cuckoo, optarg, 128);
break;
case 'm':
strncpy(ctx->path_lookup_masks, optarg, 128);
break;
case 'x':
if (strcmp("OT", optarg) == 0)
ctx->protocol = PSI_OT;
else if (strcmp("NH", optarg) == 0)
ctx->protocol = PSI_NH;
else {
printf("Unknwon communication protocols. Resetting to Naive Hashing\n");
ctx->protocol = PSI_NH;
}
break;
case 'q':
ctx->queue_buffer_size = atoi(optarg);
break;
case 'r':
ctx->read_buffer_size = atoi(optarg);
break;
case 's':
strncpy(ctx->path_folder_buckets, optarg, 128);
break;
case 't':
ctx->threads = atoi(optarg);
break;
case 'a':
strncpy(ctx->path_a, optarg, 128);
break;
case 'b':
strncpy(ctx->path_b, optarg, 128);
break;
case '?':
if (isprint(optopt))
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
else
fprintf(stderr,
"Unknown option character `\\x%x'.\n",
optopt);
exit(EXIT_FAILURE);
default:
abort();
}
for (index = optind; index < argc; index++)
printf("Non-option argument %s\n", argv[index]);
return 0;
}