00001
00025 #ifndef _JSONRPC_H_
00026 #define _JSONRPC_H_
00027
00028 #define JSONRPC_DEFAULT_HTABLE_SIZE 500
00029 #define JSONRPC_MAX_ID 1000000
00030
00031 #define JSONRPC_INTERNAL_SERVER_ERROR -32603
00032
00033 #include <json.h>
00034 #include <event.h>
00035
00036 typedef struct jsonrpc_request jsonrpc_request_t;
00037
00038 struct jsonrpc_request {
00039 int id, timerfd;
00040 jsonrpc_request_t *next;
00041 int (*cbfunc)(json_object*, char*, int);
00042 char *cbdata;
00043 json_object *payload;
00044 struct event *timer_ev;
00045 };
00046
00047 json_object* build_jsonrpc_notification(char *method, json_object *params);
00048 jsonrpc_request_t* build_jsonrpc_request(char *method, json_object *params, char *cbdata, int (*cbfunc)(json_object*, char*, int));
00049 int handle_jsonrpc_response(json_object *response);
00050 void void_jsonrpc_request(int id);
00051 #endif
00052