smf_dict.h
Go to the documentation of this file.
1 /* spmfilter - mail filtering framework
2  * Copyright (C) 2009-2012 Axel Steiner and SpaceNet AG
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 3 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 program. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Original implementation by N.Devillard
18  */
19 
35 #ifndef _SMF_DICT_H
36 #define _SMF_DICT_H
37 
38 #include "smf_list.h"
39 
44 typedef struct {
45  int n;
46  int size;
47  char **val;
48  char **key;
49  unsigned *hash;
50 } SMFDict_T;
51 
57 SMFDict_T *smf_dict_new(void);
58 
64 void smf_dict_free(SMFDict_T *dict);
65 
77 int smf_dict_set(SMFDict_T *dict, const char * key, const char * val);
78 
86 char *smf_dict_get(SMFDict_T *dict, const char * key);
87 
102 unsigned long smf_dict_get_ulong(SMFDict_T *dict, const char * key, int *success);
103 
110 void smf_dict_remove(SMFDict_T *dict, const char * key);
111 
119 SMFList_T *smf_dict_get_keys(SMFDict_T *dict);
120 
129 void smf_dict_map(SMFDict_T *dict, void(*func)(char *key,char *value, void *args), void *args);
130 
136 #define smf_dict_count(dict) ((dict)->n)
137 
138 #endif /* _SMF_DICT_H */