-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
executable file
·95 lines (88 loc) · 2.67 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
/*
* File: main.c
* Author: Oleksandr Tkachenko <oleksandr.tkachenko at crisp-da.de>
*
* Created on May 14, 2016, 1:14 PM
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <string.h>
#include "psi_simple_hashing.h"
#include "psi_structures.h"
int parse_argv(int argc, char** argv, PSI_SIMPLE_HASHING_CTX* ctx);
int main(int argc, char** argv) {
if (argc == 1) {
printf("PSI Simple Hashing\n");
return (EXIT_FAILURE);
}
PSI_SIMPLE_HASHING_CTX ctx[1];
ctx->reduction = FALSE;
parse_argv(argc, argv, ctx);
psi_simple_hashing(ctx);
return (EXIT_SUCCESS);
}
int parse_argv(int argc, char** argv, PSI_SIMPLE_HASHING_CTX* ctx) {
int index, c;
opterr = 0;
ctx->hash_n = 0;
while ((c = getopt(argc, argv, "1:2:3:p:b:q:s:i:t:d:f:z:r:")) != -1)
switch (c) {
case '1':
atob(optarg, ctx->seed[ctx->hash_n]);
ctx->hash_n++;
break;
case '2':
atob(optarg, ctx->seed[ctx->hash_n]);
ctx->hash_n++;
break;
case '3':
atob(optarg, ctx->seed[ctx->hash_n]);
ctx->hash_n++;
break;
case 'd':
ctx->table_size = atof(optarg);
break;
case 'i':
ctx->read_buffer_size = atoi(optarg);
break;
case 'p':
strncpy(ctx->path_source, optarg, 128);
break;
case 'b':
ctx->bucket_n = atoi(optarg);
break;
case 'q':
ctx->queue_buffer_size = atoi(optarg);
break;
case 's':
strncpy(ctx->path_buckets, optarg, 128);
break;
case 't':
ctx->threads = atoi(optarg);
break;
case 'f':
ctx->fixed_table_size = atoi(optarg);
break;
case 'z':
strncpy(ctx->path_result, optarg, 128);
break;
case 'r':
ctx->reduction = TRUE;
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 (EXIT_SUCCESS);
}