Add new udafs and RMR support to gsprintconsole_ves
[com/gs-lite.git] / include / watchlist.h
1 #ifndef __WATCHLIST_H_DEFINED__
2 #define __WATCHLIST_H_DEFINED__
3
4
5 static inline gs_retval_t wl_csv_uint(char *p, gs_uint32_t *t)
6 {
7     *t = strtoul((const char*)p, NULL, 10);
8         return 0;
9 }
10
11 static inline gs_retval_t wl_csv_ullong(char *p, gs_uint64_t *t)
12 {
13     *t = strtoull((const char*)p, NULL, 10);
14         return 0;
15 }
16
17 static inline gs_retval_t wl_csv_ip(char *p, gs_uint32_t *t)
18 {
19         unsigned ip1,ip2,ip3,ip4;
20     sscanf((const char*) p,"%u.%u.%u.%u",&ip1,&ip2,&ip3,&ip4);
21         *t=(ip1<<24)|(ip2<<16)|(ip3<<8)|ip4;
22         return 0;
23 }
24
25 static inline gs_retval_t wl_csv_ipv6(char *p, struct ipv6_str *t)
26 {
27     gs_uint32_t v[8];
28     sscanf((const char*) p,"%x:%x:%x:%x:%x:%x:%x:%x",&v[0],&v[1],&v[2],&v[3],&v[4],&v[5],&v[6],&v[7]);
29         t->v[0]=htonl(v[0]<<16|v[1]);
30         t->v[1]=htonl(v[2]<<16|v[3]);
31         t->v[2]=htonl(v[4]<<16|v[5]);
32         t->v[3]=htonl(v[6]<<16|v[7]);
33         return 0;
34 }
35
36 static inline gs_retval_t wl_csv_string(char *p, struct gs_string * t)
37 {
38     size_t sz = strlen(p);
39         t->data=(gs_sp_t)strndup(p, sz);
40     t->length=sz;
41         t->owner=(struct FTA *)1;
42     return 0;
43 }
44
45 static inline gs_retval_t wl_csv_bool(char *p, gs_uint32_t *t)
46 {
47         *t=0;
48         if ((strlen((const char*)p)==4) &&
49                 (strncasecmp("TRUE",(const char*)p,4) ==0) ) {
50                 *t=1;
51         }
52     return 0;
53 }
54
55 static inline gs_retval_t wl_csv_int(char *p, gs_int32_t *t)
56 {
57     *t = strtol((const char*)p, NULL, 10);
58     return 0;
59 }
60
61 static inline gs_retval_t wl_csv_llong(char *p, gs_int64_t *t)
62 {
63     *t = strtoll((const char*)p, NULL, 10);
64     return 0;
65 }
66
67 static inline gs_retval_t wl_csv_float(char *p, gs_float_t *t)
68 {
69     *t = strtod((const char*)p, NULL);
70     return 0;
71 }
72
73
74
75
76 #endif