From 29f49063f7c496a55945d1e8dfe6cb6f97446487 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 28 Jun 2013 18:54:20 +0000 Subject: add void* application argument --- jsonrpc.c | 10 +++++----- jsonrpc.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/jsonrpc.c b/jsonrpc.c index b800895..4c54eb4 100644 --- a/jsonrpc.c +++ b/jsonrpc.c @@ -158,7 +158,7 @@ json_t *jsonrpc_validate_params(json_t *json_params, const char *params_spec) return data ? jsonrpc_error_object(JSONRPC_INVALID_PARAMS, data) : NULL; } -json_t *jsonrpc_handle_request_single(json_t *json_request, struct jsonrpc_method_entry_t method_table[]) +json_t *jsonrpc_handle_request_single(void *apparg, json_t *json_request, struct jsonrpc_method_entry_t method_table[]) { int rc; json_t *json_response; @@ -193,7 +193,7 @@ json_t *jsonrpc_handle_request_single(json_t *json_request, struct jsonrpc_metho json_response = NULL; json_result = NULL; - rc = entry->funcptr(json_params, &json_result); + rc = entry->funcptr(apparg, json_params, &json_result); if (is_notification) { json_decref(json_result); json_result = NULL; @@ -217,7 +217,7 @@ done: return json_response; } -char *jsonrpc_handler(const char *input, size_t input_len, struct jsonrpc_method_entry_t method_table[]) +char *jsonrpc_handler(void *apparg, const char *input, size_t input_len, struct jsonrpc_method_entry_t method_table[]) { json_t *json_request, *json_response; json_error_t error; @@ -237,7 +237,7 @@ char *jsonrpc_handler(const char *input, size_t input_len, struct jsonrpc_method json_response = NULL; for (k=0; k < len; k++) { json_t *req = json_array_get(json_request, k); - json_t *rep = jsonrpc_handle_request_single(req, method_table); + json_t *rep = jsonrpc_handle_request_single(apparg, req, method_table); if (rep) { if (!json_response) json_response = json_array(); @@ -246,7 +246,7 @@ char *jsonrpc_handler(const char *input, size_t input_len, struct jsonrpc_method } } } else { - json_response = jsonrpc_handle_request_single(json_request, method_table); + json_response = jsonrpc_handle_request_single(apparg, json_request, method_table); } if (json_response) diff --git a/jsonrpc.h b/jsonrpc.h index 27a458c..d4a34f8 100644 --- a/jsonrpc.h +++ b/jsonrpc.h @@ -6,13 +6,13 @@ #define JSONRPC_INVALID_PARAMS -32602 #define JSONRPC_INTERNAL_ERROR -32603 -typedef int (*jsonrpc_method_prototype)(json_t *json_params, json_t **result); +typedef int (*jsonrpc_method_prototype)(void *apparg, json_t *json_params, json_t **result); struct jsonrpc_method_entry_t { const char *name; jsonrpc_method_prototype funcptr; const char *params_spec; }; -char *jsonrpc_handler(const char *input, size_t input_len, struct jsonrpc_method_entry_t method_table[]); +char *jsonrpc_handler(void *apparg, const char *input, size_t input_len, struct jsonrpc_method_entry_t method_table[]); json_t *jsonrpc_error_object(int code, json_t *data); -- cgit v1.2.1