-
Notifications
You must be signed in to change notification settings - Fork 1
/
gacli.c
36 lines (30 loc) · 848 Bytes
/
gacli.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
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "cfgfile.h"
#include "verf.h"
#include "codegen.h"
#define USAGE "See README at https://github.com/0xleone/gacli\n"
/*-----------------------------------------------------------------*/
int main(int argc, char *argv[]) {
if (argc > 2) {
printf(USAGE);
return 1;
}
char key_from_file[17];
char *key;
int verf_code;
if(argc == 1) {
key = (load_key(get_config_filename(".gacli"), key_from_file, sizeof(key_from_file)) == 0) ? key_from_file : NULL;
}
else {
key = (load_key(argv[1], key_from_file, sizeof(key_from_file)) == 0) ? key_from_file : NULL;
}
if ((key == NULL) || (verf_key_len(key) == 1)) {
printf(USAGE);
return 1;
}
verf_code = gen_verf_code(key, time(0) / 30);
printf("%6.6d\n", verf_code);
return EXIT_SUCCESS;
}