]> arthur.barton.de Git - netatalk.git/blob - include/atalk/dictionary.h
0d6eb677261157e1f4b3a05dd9e3ca554a066e30
[netatalk.git] / include / atalk / dictionary.h
1
2 /*-------------------------------------------------------------------------*/
3 /**
4    @file    dictionary.h
5    @author  N. Devillard
6    @date    Sep 2007
7    @version $Revision: 1.12 $
8    @brief   Implements a dictionary for string variables.
9
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).
13 */
14 /*--------------------------------------------------------------------------*/
15
16 /*
17         $Id: dictionary.h,v 1.12 2007-11-23 21:37:00 ndevilla Exp $
18         $Author: ndevilla $
19         $Date: 2007-11-23 21:37:00 $
20         $Revision: 1.12 $
21 */
22
23 #ifndef _DICTIONARY_H_
24 #define _DICTIONARY_H_
25
26 /*---------------------------------------------------------------------------
27                                                                 Includes
28  ---------------------------------------------------------------------------*/
29
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <unistd.h>
34
35 /*---------------------------------------------------------------------------
36                                                                 New types
37  ---------------------------------------------------------------------------*/
38
39
40 /*-------------------------------------------------------------------------*/
41 /**
42   @brief        Dictionary object
43
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)
47   hash function.
48  */
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 */
56 } dictionary ;
57
58
59 /*---------------------------------------------------------------------------
60                                                         Function prototypes
61  ---------------------------------------------------------------------------*/
62
63 unsigned   dictionary_hash  (char * key);
64 dictionary *dictionary_new  (int size);
65 void       dictionary_del   (dictionary * vd);
66 char       *dictionary_get  (dictionary * d, char *section, char * key, 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);
70
71 #endif