mirror of https://github.com/getdnsapi/getdns.git
Pass along a userarg with context update callbacks
This commit is contained in:
parent
18381e7753
commit
56bb9dbbdc
|
@ -24,6 +24,9 @@
|
||||||
* Better random number generation with OpenBSD's arc4random
|
* Better random number generation with OpenBSD's arc4random
|
||||||
* Let getdns_address schedule the AAAA query first. This results in AAAA
|
* Let getdns_address schedule the AAAA query first. This results in AAAA
|
||||||
being the first in the just_address_answers sections of the response dict.
|
being the first in the just_address_answers sections of the response dict.
|
||||||
|
* New context update callback function to also return a user given argument
|
||||||
|
along with the context and which item was changed.
|
||||||
|
Thanks Scott Hollenbeck.
|
||||||
|
|
||||||
* 2015-01-16: Version 0.1.6
|
* 2015-01-16: Version 0.1.6
|
||||||
* Fix: linking against libev on FreeBSD
|
* Fix: linking against libev on FreeBSD
|
||||||
|
|
|
@ -735,7 +735,9 @@ getdns_context_create_with_extended_memory_functions(
|
||||||
result->my_mf.mf.ext.realloc = realloc;
|
result->my_mf.mf.ext.realloc = realloc;
|
||||||
result->my_mf.mf.ext.free = free;
|
result->my_mf.mf.ext.free = free;
|
||||||
|
|
||||||
result->update_callback = NULL;
|
result->update_callback = NULL;
|
||||||
|
result->update_callback2 = NULL;
|
||||||
|
result->update_userarg = NULL;
|
||||||
|
|
||||||
result->mf.mf_arg = userarg;
|
result->mf.mf_arg = userarg;
|
||||||
result->mf.mf.ext.malloc = malloc;
|
result->mf.mf.ext.malloc = malloc;
|
||||||
|
@ -899,10 +901,19 @@ getdns_context_set_context_update_callback(struct getdns_context *context,
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
} /* getdns_context_set_context_update_callback */
|
} /* getdns_context_set_context_update_callback */
|
||||||
|
|
||||||
|
getdns_return_t
|
||||||
|
getdns_context_set_update_callback(getdns_context *context, void *userarg,
|
||||||
|
void (*value) (getdns_context *, getdns_context_code_t, void *))
|
||||||
|
{
|
||||||
|
if (!context) return GETDNS_RETURN_INVALID_PARAMETER;
|
||||||
|
context->update_userarg = userarg;
|
||||||
|
context->update_callback2 = value;
|
||||||
|
return GETDNS_RETURN_GOOD;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helpers to set options on the unbound ctx
|
* Helpers to set options on the unbound ctx
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_ub_string_opt(struct getdns_context *ctx, char *opt, char *value)
|
set_ub_string_opt(struct getdns_context *ctx, char *opt, char *value)
|
||||||
{
|
{
|
||||||
|
@ -1003,6 +1014,10 @@ rebuild_ub_ctx(struct getdns_context* context) {
|
||||||
static void
|
static void
|
||||||
dispatch_updated(struct getdns_context *context, uint16_t item)
|
dispatch_updated(struct getdns_context *context, uint16_t item)
|
||||||
{
|
{
|
||||||
|
if (context->update_callback2)
|
||||||
|
context->update_callback2(
|
||||||
|
context, item, context->update_userarg);
|
||||||
|
|
||||||
if (context->update_callback) {
|
if (context->update_callback) {
|
||||||
context->update_callback(context, item);
|
context->update_callback(context, item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,6 +60,9 @@ enum filechgs { GETDNS_FCHG_ERRORS = -1
|
||||||
typedef void (*getdns_update_callback) (struct getdns_context *,
|
typedef void (*getdns_update_callback) (struct getdns_context *,
|
||||||
getdns_context_code_t);
|
getdns_context_code_t);
|
||||||
|
|
||||||
|
typedef void (*getdns_update_callback2) (struct getdns_context *,
|
||||||
|
getdns_context_code_t, void *userarg);
|
||||||
|
|
||||||
/* internal use only for detecting changes to system files */
|
/* internal use only for detecting changes to system files */
|
||||||
struct filechg {
|
struct filechg {
|
||||||
char *fn;
|
char *fn;
|
||||||
|
@ -131,7 +134,9 @@ struct getdns_context {
|
||||||
uint8_t edns_do_bit;
|
uint8_t edns_do_bit;
|
||||||
int edns_maximum_udp_payload_size; /* -1 is unset */
|
int edns_maximum_udp_payload_size; /* -1 is unset */
|
||||||
|
|
||||||
getdns_update_callback update_callback;
|
getdns_update_callback update_callback;
|
||||||
|
getdns_update_callback2 update_callback2;
|
||||||
|
void *update_userarg;
|
||||||
|
|
||||||
int processing;
|
int processing;
|
||||||
int destroying;
|
int destroying;
|
||||||
|
|
|
@ -187,6 +187,7 @@ getdns_context_get_edns_version(getdns_context *context, uint8_t* value);
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value);
|
getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value);
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict);
|
getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict);
|
||||||
|
|
||||||
|
@ -210,6 +211,9 @@ int
|
||||||
getdns_snprint_json_list(
|
getdns_snprint_json_list(
|
||||||
char *str, size_t size, const getdns_list *list, int pretty);
|
char *str, size_t size, const getdns_list *list, int pretty);
|
||||||
|
|
||||||
|
getdns_return_t
|
||||||
|
getdns_context_set_update_callback(getdns_context *context, void *userarg,
|
||||||
|
void (*value) (getdns_context *, getdns_context_code_t, void *));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue