-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
49 lines (45 loc) · 1.09 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
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
static void print_usage(const char *progr_name)
{
fprintf(stderr, "Usage: %s [-pged ]\n"
"\t-p <upper_limit> <prime_file> generate prime numbers\n"
"\t-g <prime_file> generate keys\n"
"\t-e <message> encrypt message\n"
"\t-d <message> decrypt message\n"
,progr_name);
}
int main(int argc, char **argv)
{
char opt;
if (argc == 1)
{
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
while ((opt = getopt(argc, argv, "p:g:e:d")) != -1)
{
switch (opt)
{
case 'p':
optind--;
for(;optind < argc && *argv[optind] != '-'; optind++) {
printf("%s\n", argv[optind]);
}
break;
case 'g':
break;
case 'e':
break;
case 'd':
break;
case '?':
break;
default:
print_usage(argv[0]);
exit(EXIT_FAILURE);
}
}
return EXIT_SUCCESS;
}