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