Home | History | Annotate | Download | only in hal

Lines Matching full:dictionary

3    @file    dictionary.c
5 @brief Implements a dictionary for string variables.
7 This module implements a simple dictionary object, i.e. a list
16 #include "dictionary.h"
26 /** Minimal allocated number of entries in a dictionary */
108 @brief Create a new dictionary object.
109 @param size Optional initial size of the dictionary.
110 @return 1 newly allocated dictionary objet.
112 This function allocates a new dictionary object of given size and returns
114 dictionary, give size=0.
117 dictionary * dictionary_new(int size)
119 dictionary * d ;
124 if (!(d = (dictionary *)calloc(1, sizeof(dictionary)))) {
136 @brief Delete a dictionary object
137 @param d dictionary object to deallocate.
140 Deallocate a dictionary object and all memory associated to it.
143 void dictionary_del(dictionary * d)
163 @brief Get a value from a dictionary.
164 @param d dictionary object to search.
165 @param key Key to look for in the dictionary.
169 This function locates a key in a dictionary and returns a pointer to its
171 dictionary. The returned character pointer points to data internal to the
172 dictionary object, you should not try to free it or modify it.
175 char * dictionary_get(dictionary * d, const char * key, char * def)
197 @brief Set a value in a dictionary.
198 @param d dictionary object to modify.
203 If the given key is found in the dictionary, the associated value is
205 dictionary, it is added to it.
207 It is Ok to provide a NULL value for val, but NULL values for the dictionary
215 dictionary. It is not possible (in this implementation) to have a key in
216 the dictionary without value.
221 int dictionary_set(dictionary * d, const char * key, const char * val)
230 /* Find if value is already in dictionary */
248 /* See if dictionary needs to grow */
251 /* Reached maximum size: reallocate dictionary */
256 /* Cannot grow dictionary */
279 @brief Delete a key in a dictionary
280 @param d dictionary object to modify.
284 This function deletes a key in a dictionary. Nothing is done if the
288 void dictionary_unset(dictionary * d, const char * key)
327 @brief Dump a dictionary to an opened file pointer.
328 @param d Dictionary to dump
332 Dumps a dictionary onto an opened file pointer. Key pairs are printed out
337 void dictionary_dump(dictionary * d, FILE * out)
343 fprintf(out, "empty dictionary\n");
362 dictionary * d ;
367 /* Allocate dictionary */
371 /* Set values in dictionary */