1 /*
2  *  Copyright (C) 2004-2010 Christos Tsantilas
3  *
4  *  This program is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Lesser General Public
6  *  License as published by the Free Software Foundation; either
7  *  version 2.1 of the License, or (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  *  Lesser General Public License for more details.
13  *
14  *  You should have received a copy of the GNU Lesser General Public
15  *  License along with this library; if not, write to the Free Software
16  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  *  MA  02110-1301  USA.
18  */
19 
20 #ifndef __TYPES_OPS_H
21 #define __TYPES_OPS_H
22 
23 #include "c-icap.h"
24 #include "mem.h"
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 typedef struct ci_type_ops {
32     void *(*dup)(const char *, ci_mem_allocator_t *);
33     void (*free)(void *key, ci_mem_allocator_t *);
34     int (*compare)(const void *ref_key,const void *check_key);
35     size_t (*size)(const void *key);
36     int (*equal)(const void *ref_key,const void *check_key);
37 } ci_type_ops_t;
38 
39 CI_DECLARE_DATA extern const ci_type_ops_t ci_str_ops;
40 CI_DECLARE_DATA extern const ci_type_ops_t ci_str_ext_ops;
41 CI_DECLARE_DATA extern const ci_type_ops_t ci_int32_ops;
42 CI_DECLARE_DATA extern const ci_type_ops_t ci_uint64_ops;
43 CI_DECLARE_DATA extern const ci_type_ops_t ci_ip_ops;
44 CI_DECLARE_DATA extern const ci_type_ops_t ci_ip_sockaddr_ops;
45 CI_DECLARE_DATA extern const ci_type_ops_t  ci_datatype_ops;
46 #ifdef USE_REGEX
47 CI_DECLARE_DATA extern const ci_type_ops_t  ci_regex_ops;
48 #define ci_type_ops_is_string(tops) ((tops) == &ci_str_ops || (tops) == &ci_str_ext_ops || (tops) == &ci_regex_ops)
49 #else
50 #define ci_type_ops_is_string(tops) ((tops) == &ci_str_ops || (tops) == &ci_str_ext_ops)
51 #endif
52 
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif
59