-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjsonrpc.h
44 lines (36 loc) · 869 Bytes
/
jsonrpc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#pragma once
#include "vector.h"
#include <json-c/json.h>
#include <stdbool.h>
typedef struct {
enum json_type type;
char *name;
union {
char *string;
int number;
double dnumber;
bool bvalue;
char *json_string; // this should really be a json_object. However since son-c 0.12 does not support deep_copy() yet, serialize / deserialize for compatibility
} value;
} parameter;
typedef struct {
char *method;
VECTOR(parameter) parameters;
} jsonrpc_notification;
typedef struct {
int id;
char *method;
VECTOR(parameter) parameters;
} jsonrpc_request;
typedef struct {
int code;
char *message;
VECTOR(parameter) parameters;
} jsonrpc_error;
typedef struct {
int id;
char *result;
jsonrpc_error *error;
} jsonrpc_response;
void jsonrpc_free_members(jsonrpc_request *req);
bool jsonrpc_parse_string(jsonrpc_request *result, const char *line);