summaryrefslogtreecommitdiff
path: root/jsonrpc.h
diff options
context:
space:
mode:
authorKIU Shueng Chuan <nixchuan@gmail.com>2012-11-03 13:06:42 +0800
committerKIU Shueng Chuan <nixchuan@gmail.com>2012-11-03 13:06:42 +0800
commit78902dcaa299013a488593dc916cde668981c7b8 (patch)
treed9a0e5e61abd899068cca5a0ab876d0a49874943 /jsonrpc.h
add source files
Diffstat (limited to 'jsonrpc.h')
-rw-r--r--jsonrpc.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/jsonrpc.h b/jsonrpc.h
new file mode 100644
index 0000000..27a458c
--- /dev/null
+++ b/jsonrpc.h
@@ -0,0 +1,18 @@
+#include <jansson.h>
+
+#define JSONRPC_PARSE_ERROR -32700
+#define JSONRPC_INVALID_REQUEST -32600
+#define JSONRPC_METHOD_NOT_FOUND -32601
+#define JSONRPC_INVALID_PARAMS -32602
+#define JSONRPC_INTERNAL_ERROR -32603
+
+typedef int (*jsonrpc_method_prototype)(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[]);
+
+json_t *jsonrpc_error_object(int code, json_t *data);