new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / shared / tests / hash_test.c
1 #include <stdio.h>
2 #include <string.h>
3
4 #include "hash_op.h"
5
6
7 int main(int argc, char **argv)
8 {
9     int i = 0;
10     char *tmp;
11     char buf[1024];
12     OSHash *mhash;
13
14     mhash = OSHash_Create();
15
16     while (1) {
17         fgets(buf, 1024, stdin);
18         tmp = strchr(buf, '\n');
19         if (tmp) {
20             *tmp = '\0';
21         }
22
23         if (strncmp(buf, "get ", 4) == 0) {
24             printf("Getting key: '%s'\n", buf + 4);
25             printf("Found: '%s'\n", (char *)OSHash_Get(mhash, buf + 4));
26         } else {
27             printf("Adding key: '%s'\n", buf);
28             i = OSHash_Add(mhash, strdup(buf), strdup(buf));
29
30             printf("rc = %d\n", i);
31         }
32     }
33
34     return (0);
35 }
36