Detailed Description
Function Documentation
◆ getdns_dict_get_names()
getdns_return_t getdns_dict_get_names | ( | const getdns_dict * | dict, |
getdns_list ** | answer | ||
) |
fetch a list of names from the dictionary, this list must be freed by the caller via a call to getdns_list_destroy
- Parameters
-
dict dictionary from which to produce the list of names **answer a pointer to the new list will be assigned to *answer
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or empty
◆ getdns_dict_get_data_type()
getdns_return_t getdns_dict_get_data_type | ( | const getdns_dict * | dict, |
const char * | name, | ||
getdns_data_type * | answer | ||
) |
fetch the data type for the data associated with the specified name
- Parameters
-
dict dictionary from which to fetch the data type name a name/key value to look up in the dictionary *answer data type will be stored at this address
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_dict_get_dict()
getdns_return_t getdns_dict_get_dict | ( | const getdns_dict * | dict, |
const char * | name, | ||
getdns_dict ** | answer | ||
) |
fetch the dictionary associated with the specified name, the dictionary should not be free()'d by the caller, it will be freed when the parent dictionary is free()'d
- Parameters
-
dict dictionary from which to fetch the dictionary name a name/key value to look up in the dictionary **answer a copy of the dictionary will be stored at this address
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_dict_get_list()
getdns_return_t getdns_dict_get_list | ( | const getdns_dict * | dict, |
const char * | name, | ||
getdns_list ** | answer | ||
) |
fetch the list associated with the specified name the list should not be free()'d by the caller, when the dictionary is destroyed the list will also be destroyed
- Parameters
-
dict dictionary from which to fetch the list name a name/key value to look up in the dictionary **answer a copy of the list will be stored at this address
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_dict_get_bindata()
getdns_return_t getdns_dict_get_bindata | ( | const getdns_dict * | dict, |
const char * | name, | ||
getdns_bindata ** | answer | ||
) |
fetch the bindata associated with the specified name, the bindata should not be free()'d by the caller
- Parameters
-
dict dictionary from which to fetch the bindata name a name/key value to look up in the dictionary **answer a copy of the bindata will be stored at this address
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_dict_get_int()
getdns_return_t getdns_dict_get_int | ( | const getdns_dict * | dict, |
const char * | name, | ||
uint32_t * | answer | ||
) |
fetch the integer value associated with the specified name
- Parameters
-
dict dictionary from which to fetch the integer name a name/key value to look up in the dictionary *answer the integer will be stored at this address
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_dict_create()
getdns_dict* getdns_dict_create | ( | ) |
create a new dictionary with no items
- Returns
- pointer to an allocated dictionary, NULL if insufficient memory
◆ getdns_dict_create_with_context()
getdns_dict* getdns_dict_create_with_context | ( | const getdns_context * | context | ) |
create a new dict with no items, creating and initializing it with the custom memory function from context. These memory functions will be used for creating, and inherited by the list members when populating the dict. The custom deallocator will be used for destroying the dict.
- Parameters
-
context The context from which the custom memory functions will be used to create and initialize the dict.
- Returns
- pointer to an allocated dict, NULL if insufficient memory
◆ getdns_dict_create_with_memory_functions()
getdns_dict* getdns_dict_create_with_memory_functions | ( | void *(*)(size_t) | malloc, |
void *(*)(void *, size_t) | realloc, | ||
void(*)(void *) | free | ||
) |
create a new dict with no items, creating and initializing it with the provided custom memory function. These memory functions will be used for creating, and inherited by the dict members when populating the dict. The custom deallocator will be used for destroying the dict.
- Parameters
-
malloc Custom allocator realloc Custom reallocator free Custom deallocator
- Returns
- pointer to an allocated dict, NULL if insufficient memory
◆ getdns_dict_create_with_extended_memory_functions()
getdns_dict* getdns_dict_create_with_extended_memory_functions | ( | void * | userarg, |
void *(*)(void *userarg, size_t) | malloc, | ||
void *(*)(void *userarg, void *, size_t) | realloc, | ||
void(*)(void *userarg, void *) | free | ||
) |
create a new dict with no items, creating and initializing it with the provided extended custom memory function. These memory functions will be used for creating, and inherited by the dict members when populating the dict. The custom deallocator will be used for destroying the dict.
- Parameters
-
userarg Will be passed as the first argument to the extended custom malloc, realloc, and free. malloc Custom allocator realloc Custom reallocator free Custom deallocator
- Returns
- pointer to an allocated dict, NULL if insufficient memory
◆ getdns_dict_destroy()
void getdns_dict_destroy | ( | getdns_dict * | dict | ) |
destroy a dictionary and all items within that dictionary be aware that if you have fetched any data from the dictionary it will no longer be available (you are likely to experience bad things if you try)
◆ getdns_dict_set_dict()
getdns_return_t getdns_dict_set_dict | ( | getdns_dict * | dict, |
const char * | name, | ||
const getdns_dict * | child_dict | ||
) |
create a new entry in the dictionary, or replace the value of an existing entry this routine makes a copy of the child_dict_
- Parameters
-
dict dictionary in which to add or change the value name key that identifies which item in the dictionary to add/change child_dict value to assign to the node identified by name
- Returns
- GETDNS_RETURN_GOOD on success
◆ getdns_dict_set_list()
getdns_return_t getdns_dict_set_list | ( | getdns_dict * | dict, |
const char * | name, | ||
const getdns_list * | child_list | ||
) |
create a new entry in the dictionary, or replace the value of an existing entry this routine makes a copy of the child_list
- Parameters
-
dict dictionary in which to add or change the value name key that identifies which item in the dictionary to add/change child_list value to assign to the node identified by name
- Returns
- GETDNS_RETURN_GOOD on success
◆ getdns_dict_set_bindata()
getdns_return_t getdns_dict_set_bindata | ( | getdns_dict * | dict, |
const char * | name, | ||
const getdns_bindata * | child_bindata | ||
) |
create a new entry in the dictionary, or replace the value of an existing entry this routine makes a copy of the child_bindata
- Parameters
-
dict dictionary in which to add or change the value name key that identifies which item in the dictionary to add/change child_bindata value to assign to the node identified by name
- Returns
- GETDNS_RETURN_GOOD on success
◆ getdns_dict_set_int()
getdns_return_t getdns_dict_set_int | ( | getdns_dict * | dict, |
const char * | name, | ||
uint32_t | child_uint32 | ||
) |
create a new entry in the dictionary, or replace the value of an existing entry
- Parameters
-
dict dictionary in which to add or change the value name key that identifies which item in the dictionary to add/change child_uint32 value to assign to the node identified by name
- Returns
- GETDNS_RETURN_GOOD on success
◆ getdns_pretty_print_dict()
char* getdns_pretty_print_dict | ( | const getdns_dict * | some_dict | ) |
creates a string that describes the dictionary in a human readable form one line per item in the dictionary
- Parameters
-
some_dict dictionary to pretty print
- Returns
- character array (caller must free this) containing pretty string
◆ getdns_dict_util_set_string()
getdns_return_t getdns_dict_util_set_string | ( | getdns_dict * | dict, |
const char * | name, | ||
const char * | value | ||
) |
Create a new entry in the dictionary, or replace the value of an existing entry, with a getdns_bindata representing a string. The string will be copied. The size of the bindata will be strlen(value), though there will be a '\0' byte directly after the size'd position even, though the size argument suggests that this would not be part of the bindata's date space.
- See also
- getdns_dict_set_bindata
- Parameters
-
dict dictionary in which to add or change the value name key that identifies which item in the dictionary to add/change value string to be copied and stored in the bindata at key
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_INVALID_PARAMETER when one of the arguments was NULL
- GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
◆ getdns_dict_util_get_string()
getdns_return_t getdns_dict_util_get_string | ( | const getdns_dict * | dict, |
const char * | name, | ||
char ** | result | ||
) |
Get the string associated with the speicifed name. The string should not be free()'d by the caller.
- See also
- getdns_dict_get_bindata
- Parameters
-
dict dictionary from which to fetch the bindata name a name/key value to look up in the dictionary result The bindata's data value
- Returns
- GETDNS_RETURN_GOOD on success
- GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
◆ getdns_pretty_snprint_dict()
int getdns_pretty_snprint_dict | ( | char * | str, |
size_t | size, | ||
const getdns_dict * | dict | ||
) |
Pretty print the getdns_dict in a given buffer snprintf style.
- Parameters
-
str pointer to the buffer to print to size size of the given buffer. No more than size bytes (including the terminating null byte) will be written to str. dict getdns_dict to print
- Returns
- The number of characters written excluding the terminating null byte or the number of characters which would have been written if enough space had been available.
◆ getdns_print_json_dict()
char* getdns_print_json_dict | ( | const getdns_dict * | some_dict, |
int | pretty | ||
) |
creates a string containing a json representation of some_dict. bindatas are converted to strings when possible, including bindatas for addresses, dnames and other printable data. All other bindatas are converted to lists of byte values.
- Parameters
-
some_dict dict to represent as json data pretty when non-zero returns formatted json
- Returns
- character array (caller must free this) containing pretty string
◆ getdns_snprint_json_dict()
int getdns_snprint_json_dict | ( | char * | str, |
size_t | size, | ||
const getdns_dict * | dict, | ||
int | pretty | ||
) |
Prints a json representation of dict in a given buffer snprintf style. bindatas are converted to strings when possible, including bindatas for addresses, dnames and other printable data. All other bindatas are converted to lists of byte values.
- Parameters
-
str pointer to the buffer to print to size size of the given buffer. No more than size bytes (including the terminating null byte) will be written to str. dict dict to represent as json data pretty when non-zero returns formatted json
- Returns
- The number of characters written excluding the terminating null byte or the number of characters which would have been written if enough space had been available.