mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'develop' of github.com:verisign/getdns into develop
This commit is contained in:
commit
5345753868
|
@ -253,7 +253,7 @@ getdns_context_create_with_extended_memory_functions(
|
||||||
mf_union mf;
|
mf_union mf;
|
||||||
|
|
||||||
if (!context || !malloc || !realloc || !free)
|
if (!context || !malloc || !realloc || !free)
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
/** default init **/
|
/** default init **/
|
||||||
mf.ext.malloc = malloc;
|
mf.ext.malloc = malloc;
|
||||||
|
|
27
src/dict.c
27
src/dict.c
|
@ -87,7 +87,7 @@ getdns_dict_get_names(const struct getdns_dict * dict,
|
||||||
struct getdns_bindata bindata;
|
struct getdns_bindata bindata;
|
||||||
|
|
||||||
if (!dict || !answer)
|
if (!dict || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
*answer = getdns_list_create_with_extended_memory_functions(
|
*answer = getdns_list_create_with_extended_memory_functions(
|
||||||
dict->mf.mf_arg, dict->mf.mf.ext.malloc,
|
dict->mf.mf_arg, dict->mf.mf.ext.malloc,
|
||||||
|
@ -132,7 +132,7 @@ getdns_dict_get_dict(const struct getdns_dict * dict, const char *name,
|
||||||
struct getdns_dict_item *item;
|
struct getdns_dict_item *item;
|
||||||
|
|
||||||
if (!dict || !name || !answer)
|
if (!dict || !name || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
item = getdns_dict_find(dict, name);
|
item = getdns_dict_find(dict, name);
|
||||||
if (!item)
|
if (!item)
|
||||||
|
@ -153,7 +153,7 @@ getdns_dict_get_list(const struct getdns_dict * dict, const char *name,
|
||||||
struct getdns_dict_item *item;
|
struct getdns_dict_item *item;
|
||||||
|
|
||||||
if (!dict || !name || !answer)
|
if (!dict || !name || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
item = getdns_dict_find(dict, name);
|
item = getdns_dict_find(dict, name);
|
||||||
if (!item)
|
if (!item)
|
||||||
|
@ -174,7 +174,7 @@ getdns_dict_get_bindata(const struct getdns_dict * dict, const char *name,
|
||||||
struct getdns_dict_item *item;
|
struct getdns_dict_item *item;
|
||||||
|
|
||||||
if (!dict || !name || !answer)
|
if (!dict || !name || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
item = getdns_dict_find(dict, name);
|
item = getdns_dict_find(dict, name);
|
||||||
if (!item)
|
if (!item)
|
||||||
|
@ -195,7 +195,7 @@ getdns_dict_get_int(const struct getdns_dict * dict, const char *name,
|
||||||
struct getdns_dict_item *item;
|
struct getdns_dict_item *item;
|
||||||
|
|
||||||
if (!dict || !name || !answer)
|
if (!dict || !name || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
item = getdns_dict_find(dict, name);
|
item = getdns_dict_find(dict, name);
|
||||||
if (!item)
|
if (!item)
|
||||||
|
@ -289,7 +289,7 @@ getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
|
|
||||||
if (!dstdict)
|
if (!dstdict)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (!srcdict) {
|
if (!srcdict) {
|
||||||
*dstdict = NULL;
|
*dstdict = NULL;
|
||||||
|
@ -301,7 +301,7 @@ getdns_dict_copy(struct getdns_dict * srcdict, struct getdns_dict ** dstdict)
|
||||||
srcdict->mf.mf.ext.realloc,
|
srcdict->mf.mf.ext.realloc,
|
||||||
srcdict->mf.mf.ext.free);
|
srcdict->mf.mf.ext.free);
|
||||||
if (!*dstdict)
|
if (!*dstdict)
|
||||||
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
|
||||||
retval = GETDNS_RETURN_GOOD;
|
retval = GETDNS_RETURN_GOOD;
|
||||||
LDNS_RBTREE_FOR(item, struct getdns_dict_item *, &(srcdict->root)) {
|
LDNS_RBTREE_FOR(item, struct getdns_dict_item *, &(srcdict->root)) {
|
||||||
|
@ -741,6 +741,19 @@ getdns_pretty_print_dict(const struct getdns_dict *dict)
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_dict_remove_name(struct getdns_dict *this_dict, char *name)
|
getdns_dict_remove_name(struct getdns_dict *this_dict, char *name)
|
||||||
{
|
{
|
||||||
|
struct getdns_dict_item *item;
|
||||||
|
|
||||||
|
if (!this_dict || !name)
|
||||||
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
item = getdns_dict_find(this_dict, name, 0);
|
||||||
|
if (!item)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_DICT_NAME;
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
ldns_rbtree_delete(&this_dict->root, name);
|
||||||
|
getdns_dict_item_free(&item->node, this_dict);
|
||||||
|
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,7 +269,7 @@ getdns_general_ub(struct ub_ctx *unbound,
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
gr = getdns_context_prepare_for_resolution(context);
|
gr = getdns_context_prepare_for_resolution(context);
|
||||||
|
@ -337,7 +337,7 @@ getdns_general(struct getdns_context *context,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ensure callback is not NULL */
|
/* ensure callback is not NULL */
|
||||||
if (!callback) {
|
if (!callback || !name) {
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
46
src/list.c
46
src/list.c
|
@ -55,12 +55,12 @@ getdns_return_t
|
||||||
getdns_list_get_data_type(const struct getdns_list * list, size_t index,
|
getdns_list_get_data_type(const struct getdns_list * list, size_t index,
|
||||||
getdns_data_type * answer)
|
getdns_data_type * answer)
|
||||||
{
|
{
|
||||||
if (!list || index >= list->numinuse)
|
if (!list || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
|
||||||
|
|
||||||
if (!answer)
|
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (index >= list->numinuse)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
*answer = list->items[index].dtype;
|
*answer = list->items[index].dtype;
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
} /* getdns_list_get_data_type */
|
} /* getdns_list_get_data_type */
|
||||||
|
@ -70,12 +70,12 @@ getdns_return_t
|
||||||
getdns_list_get_dict(const struct getdns_list * list, size_t index,
|
getdns_list_get_dict(const struct getdns_list * list, size_t index,
|
||||||
struct getdns_dict ** answer)
|
struct getdns_dict ** answer)
|
||||||
{
|
{
|
||||||
if (!list || index >= list->numinuse)
|
if (!list || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
|
||||||
|
|
||||||
if (!answer)
|
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (index >= list->numinuse)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if (list->items[index].dtype != t_dict)
|
if (list->items[index].dtype != t_dict)
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
|
||||||
|
@ -88,13 +88,12 @@ getdns_return_t
|
||||||
getdns_list_get_list(const struct getdns_list * list, size_t index,
|
getdns_list_get_list(const struct getdns_list * list, size_t index,
|
||||||
struct getdns_list ** answer)
|
struct getdns_list ** answer)
|
||||||
{
|
{
|
||||||
|
if (!list || !answer)
|
||||||
if (!list || index >= list->numinuse)
|
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
|
||||||
|
|
||||||
if (!answer)
|
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (index >= list->numinuse)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if (list->items[index].dtype != t_list)
|
if (list->items[index].dtype != t_list)
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
|
||||||
|
@ -107,12 +106,13 @@ getdns_return_t
|
||||||
getdns_list_get_bindata(const struct getdns_list * list, size_t index,
|
getdns_list_get_bindata(const struct getdns_list * list, size_t index,
|
||||||
struct getdns_bindata ** answer)
|
struct getdns_bindata ** answer)
|
||||||
{
|
{
|
||||||
if (!list || index >= list->numinuse)
|
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
|
||||||
|
|
||||||
if (!answer)
|
if (!list || !answer)
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (index >= list->numinuse)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if (list->items[index].dtype != t_bindata)
|
if (list->items[index].dtype != t_bindata)
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
|
||||||
|
@ -125,12 +125,12 @@ getdns_return_t
|
||||||
getdns_list_get_int(const struct getdns_list * list, size_t index,
|
getdns_list_get_int(const struct getdns_list * list, size_t index,
|
||||||
uint32_t * answer)
|
uint32_t * answer)
|
||||||
{
|
{
|
||||||
if (!list || index >= list->numinuse)
|
if (!list || !answer)
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
|
||||||
|
|
||||||
if (!answer)
|
|
||||||
return GETDNS_RETURN_INVALID_PARAMETER;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
if (index >= list->numinuse)
|
||||||
|
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
||||||
|
|
||||||
if (list->items[index].dtype != t_int)
|
if (list->items[index].dtype != t_int)
|
||||||
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
return GETDNS_RETURN_WRONG_TYPE_REQUESTED;
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ getdns_list_realloc(struct getdns_list *list)
|
||||||
struct getdns_list_item *newlist;
|
struct getdns_list_item *newlist;
|
||||||
|
|
||||||
if (!list)
|
if (!list)
|
||||||
return GETDNS_RETURN_GENERIC_ERROR;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
newlist = GETDNS_XREALLOC(list->mf, list->items,
|
newlist = GETDNS_XREALLOC(list->mf, list->items,
|
||||||
struct getdns_list_item,
|
struct getdns_list_item,
|
||||||
|
@ -174,7 +174,7 @@ getdns_list_copy(struct getdns_list * srclist, struct getdns_list ** dstlist)
|
||||||
getdns_return_t retval;
|
getdns_return_t retval;
|
||||||
|
|
||||||
if (!dstlist)
|
if (!dstlist)
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
|
||||||
if (!srclist) {
|
if (!srclist) {
|
||||||
*dstlist = NULL;
|
*dstlist = NULL;
|
||||||
|
@ -187,7 +187,7 @@ getdns_list_copy(struct getdns_list * srclist, struct getdns_list ** dstlist)
|
||||||
srclist->mf.mf.ext.free
|
srclist->mf.mf.ext.free
|
||||||
);
|
);
|
||||||
if (!dstlist)
|
if (!dstlist)
|
||||||
return GETDNS_RETURN_NO_SUCH_LIST_ITEM;
|
return GETDNS_RETURN_GENERIC_ERROR;
|
||||||
|
|
||||||
for (i = 0; i < srclist->numinuse; i++) {
|
for (i = 0; i < srclist->numinuse; i++) {
|
||||||
retval = getdns_list_add_item(*dstlist, &index);
|
retval = getdns_list_add_item(*dstlist, &index);
|
||||||
|
|
Loading…
Reference in New Issue