-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.c
61 lines (49 loc) · 1.3 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
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "snowid.h"
/* Driver code to show how snowid library can be used in a program */
int main(void)
{
puts("Test program for snowid...");
snow_config_t config = {
.interface = NULL,
.timestamp_path = "./timestamp.out",
.allowable_downtime = 2592000000,
};
snow_init(&config);
snow_dump(NULL);
#if 0
snow_id_t snow_id;
#endif
unsigned char out[16] = {0};
for(int i = 1; i <= 1000; i++) {
#if 0
/* alternate way of getting a unique id but you can access
individual members of the struct.
*/
if (snow_get_id(&snow_id) == false) {
puts("unable to generate snowid");
break;
}
#endif
if (snow_get_id_as_binary(out) == false) {
puts("unable to generate snowid as binary");
break;
}
for (int8_t i = 0; i < 16; i++) {
printf("%x", out[i]);
if (i != 15) {
printf(":");
}
}
printf("\n");
if (i == 500) {
puts("sleeping for 4 sec...");
sleep(4);
}
}
snow_dump(NULL);
snow_shutdown();
return EXIT_SUCCESS;
}