#include <search.h>#include <stdlib.h>#include <string.h>#include <pthread.h>#include "libdictionary.h"Functions | |
| void | dictionary_init (dictionary_t *d) |
| Must be called first, initializes the dictionary data structure. | |
| int | dictionary_add (dictionary_t *d, const char *key, const char *value) |
| Adds a (key, value) pair to the dictionary. | |
| const char * | dictionary_get (dictionary_t *d, const char *key) |
| Retrieves the value from the dictionary for a given key. | |
| int | dictionary_parse (dictionary_t *d, char *key_value) |
| Parses the key_value string and add the parsed key and value to the dictionary. | |
| int | dictionary_remove (dictionary_t *d, const char *key) |
| Removes the (key, value) entry from the dictionary. | |
| void | dictionary_destroy (dictionary_t *d) |
| Frees all internal memory associated with the dictionary. | |
| void | dictionary_destroy_all (dictionary_t *d) |
| Frees all internal memory associated with the dictionary and key/values pairs. | |
| int dictionary_add | ( | dictionary_t * | d, | |
| const char * | key, | |||
| const char * | value | |||
| ) |
Adds a (key, value) pair to the dictionary.
| void dictionary_destroy | ( | dictionary_t * | d | ) |
Frees all internal memory associated with the dictionary.
Must be called last.
| void dictionary_destroy_all | ( | dictionary_t * | d | ) |
Frees all internal memory associated with the dictionary and key/values pairs.
Must be called last.
| const char* dictionary_get | ( | dictionary_t * | d, | |
| const char * | key | |||
| ) |
Retrieves the value from the dictionary for a given key.
| void dictionary_init | ( | dictionary_t * | d | ) |
Must be called first, initializes the dictionary data structure.
Same as MP1.
| int dictionary_parse | ( | dictionary_t * | d, | |
| char * | key_value | |||
| ) |
Parses the key_value string and add the parsed key and value to the dictionary.
If successful, the key_value string will be modified in-place in order to be added to the dictionary.
This function only accepts key_value strings in the general format of "Key: Value".
| int dictionary_remove | ( | dictionary_t * | d, | |
| const char * | key | |||
| ) |
Removes the (key, value) entry from the dictionary.
1.6.1