2 /*-------------------------------------------------------------------------*/
7 @brief Implements a dictionary for string variables.
9 This module implements a simple dictionary object, i.e. a list
10 of string/string associations. This object is useful to store e.g.
11 informations retrieved from a configuration file (ini files).
13 /*--------------------------------------------------------------------------*/
17 $Date: 2007-11-23 21:37:00 $
20 #ifndef _DICTIONARY_H_
21 #define _DICTIONARY_H_
23 /*---------------------------------------------------------------------------
25 ---------------------------------------------------------------------------*/
32 /*---------------------------------------------------------------------------
34 ---------------------------------------------------------------------------*/
37 /*-------------------------------------------------------------------------*/
39 @brief Dictionary object
41 This object contains a list of string/string associations. Each
42 association is identified by a unique string key. Looking up values
43 in the dictionary is speeded up by the use of a (hopefully collision-free)
46 /*-------------------------------------------------------------------------*/
47 typedef struct _dictionary_ {
48 int n ; /** Number of entries in dictionary */
49 int size ; /** Storage size */
50 char ** val ; /** List of string values */
51 char ** key ; /** List of string keys */
52 unsigned * hash ; /** List of hash values for keys */
56 /*---------------------------------------------------------------------------
58 ---------------------------------------------------------------------------*/
60 unsigned atalkdict_hash (char * key);
61 dictionary *atalkdict_new (int size);
62 void atalkdict_del (dictionary * vd);
63 const char *atalkdict_get (const dictionary * d, const char *section, const char * key, const char * def);
64 int atalkdict_set (dictionary * vd, char *section, char * key, char * val);
65 void atalkdict_unset (dictionary * d, char *section, char * key);
66 void atalkdict_dump (dictionary * d, FILE * out);