2 /*-------------------------------------------------------------------------*/
7 @version $Revision: 1.12 $
8 @brief Implements a dictionary for string variables.
10 This module implements a simple dictionary object, i.e. a list
11 of string/string associations. This object is useful to store e.g.
12 informations retrieved from a configuration file (ini files).
14 /*--------------------------------------------------------------------------*/
17 $Id: dictionary.h,v 1.12 2007-11-23 21:37:00 ndevilla Exp $
19 $Date: 2007-11-23 21:37:00 $
23 #ifndef _DICTIONARY_H_
24 #define _DICTIONARY_H_
26 /*---------------------------------------------------------------------------
28 ---------------------------------------------------------------------------*/
35 /*---------------------------------------------------------------------------
37 ---------------------------------------------------------------------------*/
40 /*-------------------------------------------------------------------------*/
42 @brief Dictionary object
44 This object contains a list of string/string associations. Each
45 association is identified by a unique string key. Looking up values
46 in the dictionary is speeded up by the use of a (hopefully collision-free)
49 /*-------------------------------------------------------------------------*/
50 typedef struct _dictionary_ {
51 int n ; /** Number of entries in dictionary */
52 int size ; /** Storage size */
53 char ** val ; /** List of string values */
54 char ** key ; /** List of string keys */
55 unsigned * hash ; /** List of hash values for keys */
59 /*---------------------------------------------------------------------------
61 ---------------------------------------------------------------------------*/
63 unsigned dictionary_hash (char * key);
64 dictionary *dictionary_new (int size);
65 void dictionary_del (dictionary * vd);
66 const char *dictionary_get (const dictionary * d, const char *section, const char * key, const char * def);
67 int dictionary_set (dictionary * vd, char *section, char * key, char * val);
68 void dictionary_unset (dictionary * d, char *section, char * key);
69 void dictionary_dump (dictionary * d, FILE * out);