From: Nicolas Williams Date: Fri, 13 Feb 2015 21:28:30 +0000 (-0600) Subject: Reduce number of msg callback typedefs X-Git-Tag: jq-1.5rc2~148 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a83a9e0bc2c0fe4795eecf0c28dbac23887f4528;p=jq Reduce number of msg callback typedefs --- diff --git a/builtin.c b/builtin.c index 5ac35cd..40108da 100644 --- a/builtin.c +++ b/builtin.c @@ -895,11 +895,11 @@ static jv f_input(jq_state *jq, jv input) { } static jv f_debug(jq_state *jq, jv input) { - jq_debug_cb cb; + jq_msg_cb cb; void *data; jq_get_debug_cb(jq, &cb, &data); if (cb != NULL) - cb(jq, data, jv_copy(input)); + cb(data, jv_copy(input)); return input; } diff --git a/execute.c b/execute.c index b760a7d..6c6c9b1 100644 --- a/execute.c +++ b/execute.c @@ -24,7 +24,7 @@ struct jq_state { void *nomem_handler_data; struct bytecode* bc; - jq_err_cb err_cb; + jq_msg_cb err_cb; void *err_cb_data; jv error; @@ -42,7 +42,7 @@ struct jq_state { jv attrs; jq_input_cb input_cb; void *input_cb_data; - jq_debug_cb debug_cb; + jq_msg_cb debug_cb; void *debug_cb_data; }; @@ -879,7 +879,7 @@ jq_state *jq_init(void) { return jq; } -void jq_set_error_cb(jq_state *jq, jq_err_cb cb, void *data) { +void jq_set_error_cb(jq_state *jq, jq_msg_cb cb, void *data) { if (cb == NULL) { jq->err_cb = default_err_cb; jq->err_cb_data = stderr; @@ -889,7 +889,7 @@ void jq_set_error_cb(jq_state *jq, jq_err_cb cb, void *data) { } } -void jq_get_error_cb(jq_state *jq, jq_err_cb *cb, void **data) { +void jq_get_error_cb(jq_state *jq, jq_msg_cb *cb, void **data) { *cb = jq->err_cb; *data = jq->err_cb_data; } @@ -1082,12 +1082,12 @@ void jq_get_input_cb(jq_state *jq, jq_input_cb *cb, void **data) { *data = jq->input_cb_data; } -void jq_set_debug_cb(jq_state *jq, jq_debug_cb cb, void *data) { +void jq_set_debug_cb(jq_state *jq, jq_msg_cb cb, void *data) { jq->debug_cb = cb; jq->debug_cb_data = data; } -void jq_get_debug_cb(jq_state *jq, jq_debug_cb *cb, void **data) { +void jq_get_debug_cb(jq_state *jq, jq_msg_cb *cb, void **data) { *cb = jq->debug_cb; *data = jq->debug_cb_data; } diff --git a/jq.h b/jq.h index 280e827..9182cfa 100644 --- a/jq.h +++ b/jq.h @@ -7,11 +7,11 @@ enum {JQ_DEBUG_TRACE = 1}; typedef struct jq_state jq_state; -typedef void (*jq_err_cb)(void *, jv); +typedef void (*jq_msg_cb)(void *, jv); jq_state *jq_init(void); -void jq_set_error_cb(jq_state *, jq_err_cb, void *); -void jq_get_error_cb(jq_state *, jq_err_cb *, void **); +void jq_set_error_cb(jq_state *, jq_msg_cb, void *); +void jq_get_error_cb(jq_state *, jq_msg_cb *, void **); void jq_set_nomem_handler(jq_state *, void (*)(void *), void *); jv jq_format_error(jv msg); void jq_report_error(jq_state *, jv); @@ -26,9 +26,8 @@ typedef jv (*jq_input_cb)(jq_state *, void *); void jq_set_input_cb(jq_state *, jq_input_cb, void *); void jq_get_input_cb(jq_state *, jq_input_cb *, void **); -typedef void (*jq_debug_cb)(jq_state *, void *, jv); -void jq_set_debug_cb(jq_state *, jq_debug_cb, void *); -void jq_get_debug_cb(jq_state *, jq_debug_cb *, void **); +void jq_set_debug_cb(jq_state *, jq_msg_cb, void *); +void jq_get_debug_cb(jq_state *, jq_msg_cb *, void **); void jq_set_attrs(jq_state *, jv); jv jq_get_attrs(jq_state *); @@ -40,7 +39,7 @@ jv jq_get_attr(jq_state *, jv); typedef struct jq_util_input_state *jq_util_input_state; -jq_util_input_state jq_util_input_init(jq_err_cb, void *); +jq_util_input_state jq_util_input_init(jq_msg_cb, void *); void jq_util_input_set_parser(jq_util_input_state, jv_parser *, int); void jq_util_input_free(jq_util_input_state *); void jq_util_input_add_input(jq_util_input_state, jv); diff --git a/main.c b/main.c index db0472e..5627eca 100644 --- a/main.c +++ b/main.c @@ -140,7 +140,7 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) { return ret; } -static void debug_cb(jq_state *jq, void *data, jv input) { +static void debug_cb(void *data, jv input) { int dumpopts = *(int *)data; jv_dumpf(JV_ARRAY(jv_string("DEBUG:"), input), stderr, dumpopts & ~(JV_PRINT_PRETTY)); fprintf(stderr, "\n"); diff --git a/util.c b/util.c index d63fd8a..6e0ab27 100644 --- a/util.c +++ b/util.c @@ -146,7 +146,7 @@ not_this: } struct jq_util_input_state { - jq_err_cb err_cb; + jq_msg_cb err_cb; void *err_cb_data; jv_parser *parser; FILE* current_input; @@ -162,7 +162,7 @@ static void fprinter(void *data, jv fname) { } // If parser == NULL -> RAW -jq_util_input_state jq_util_input_init(jq_err_cb err_cb, void *err_cb_data) { +jq_util_input_state jq_util_input_init(jq_msg_cb err_cb, void *err_cb_data) { if (err_cb == NULL) { err_cb = fprinter; err_cb_data = stderr;