-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmjson.nelua
91 lines (91 loc) · 6 KB
/
mjson.nelua
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
##[[
cinclude 'mjson.h'
if not MJSON_NO_IMPL then
cinclude 'mjson.c'
end
]]
global mjson_cb_t: type <cimport,nodecl> = @function(cint, cstring, cint, cint, pointer): cint
global function mjson(buf: cstring, len: cint, cb: mjson_cb_t, ud: pointer): cint <cimport,nodecl> end
global function mjson_find(buf: cstring, len: cint, jp: cstring, tp: *cstring, tl: *cint): cint <cimport,nodecl> end
global function mjson_get_number(buf: cstring, len: cint, path: cstring, v: *float64): cint <cimport,nodecl> end
global function mjson_get_bool(buf: cstring, len: cint, path: cstring, v: *cint): cint <cimport,nodecl> end
global function mjson_get_string(buf: cstring, len: cint, path: cstring, to: cstring, n: cint): cint <cimport,nodecl> end
global function mjson_get_hex(buf: cstring, len: cint, path: cstring, to: cstring, n: cint): cint <cimport,nodecl> end
global function mjson_next(buf: cstring, len: cint, offset: cint, key_offset: *cint, key_len: *cint, val_offset: *cint, val_len: *cint, vale_type: *cint): cint <cimport,nodecl> end
global function mjson_get_base64(buf: cstring, len: cint, path: cstring, dst: cstring, dst_len: cint): cint <cimport,nodecl> end
global function mjson_base64_dec(src: cstring, src_len: cint, dst: cstring, dst_len: cint): cint <cimport,nodecl> end
global mjson_print_fn_t: type <cimport,nodecl> = @function(cstring, cint, pointer): cint
global mjson_vprint_fn_t: type <cimport,nodecl> = @function(mjson_print_fn_t, pointer, *cvalist): cint
global mjson_fixedbuf: type <cimport,nodecl,ctypedef> = @record{
ptr: cstring,
size: cint,
len: cint
}
global function mjson_printf(fn: mjson_print_fn_t, fn_data: pointer, fmt: cstring, ...: cvarargs): cint <cimport,nodecl> end
global function mjson_vprintf(fn: mjson_print_fn_t, fn_data: pointer, fmt: cstring, ap: *cvalist): cint <cimport,nodecl> end
global function mjson_print_str(fn: mjson_print_fn_t, fn_data: pointer, buf: cstring, len: cint): cint <cimport,nodecl> end
global function mjson_print_int(fn: mjson_print_fn_t, fn_data: pointer, value: cint, is_signed: cint): cint <cimport,nodecl> end
global function mjson_print_long(fn: mjson_print_fn_t, fn_data: pointer, value: clong, is_signed: cint): cint <cimport,nodecl> end
global function mjson_print_buf(fn: mjson_print_fn_t, fn_data: pointer, buf: cstring, len: cint): cint <cimport,nodecl> end
global function mjson_print_dbl(fn: mjson_print_fn_t, fn_data: pointer, d: float64, width: cint): cint <cimport,nodecl> end
global function mjson_print_null(ptr: cstring, len: cint, fn_data: pointer): cint <cimport,nodecl> end
global function mjson_print_fixed_buf(ptr: cstring, len: cint, fn_data: pointer): cint <cimport,nodecl> end
global function mjson_print_dynamic_buf(ptr: cstring, len: cint, fn_data: pointer): cint <cimport,nodecl> end
global function mjson_snprintf(buf: cstring, len: csize, fmt: cstring, ...: cvarargs): cint <cimport,nodecl> end
global function mjson_aprintf(fmt: cstring, ...: cvarargs): cstring <cimport,nodecl> end
global function mjson_pretty(s: cstring, n: cint, pad: cstring, fn: mjson_print_fn_t, fn_data: pointer): cint <cimport,nodecl> end
global function mjson_merge(s: cstring, n: cint, s2: cstring, n2: cint, fn: mjson_print_fn_t, fn_data: pointer): cint <cimport,nodecl> end
global function jsonrpc_init(response_cb: mjson_print_fn_t, fn_data: pointer): void <cimport,nodecl> end
global function mjson_globmatch(s1: cstring, n1: cint, s2: cstring, n2: cint): cint <cimport,nodecl> end
global jsonrpc_ctx: type <cimport,nodecl,forwarddecl,ctypedef> = @record{}
global jsonrpc_request: type <cimport,nodecl,ctypedef> = @record{
ctx: *jsonrpc_ctx,
frame: cstring,
frame_len: cint,
params: cstring,
params_len: cint,
id: cstring,
id_len: cint,
method: cstring,
method_len: cint,
fn: mjson_print_fn_t,
fn_data: pointer,
userdata: pointer
}
global jsonrpc_method: type <cimport,nodecl,forwarddecl,ctypedef> = @record{}
jsonrpc_method = @record{
method: cstring,
method_sz: cint,
cb: function(*jsonrpc_request): void,
next: *jsonrpc_method
}
jsonrpc_ctx = @record{
methods: *jsonrpc_method,
response_cb: mjson_print_fn_t,
response_cb_data: pointer
}
global function jsonrpc_ctx_init(ctx: *jsonrpc_ctx, response_cb: mjson_print_fn_t, response_cb_data: pointer): void <cimport,nodecl> end
global function jsonrpc_return_error(r: *jsonrpc_request, code: cint, message: cstring, data_fmt: cstring, ...: cvarargs): void <cimport,nodecl> end
global function jsonrpc_return_success(r: *jsonrpc_request, result_fmt: cstring, ...: cvarargs): void <cimport,nodecl> end
global function jsonrpc_ctx_process(ctx: *jsonrpc_ctx, req: cstring, req_sz: cint, fn: mjson_print_fn_t, fn_data: pointer, userdata: pointer): void <cimport,nodecl> end
global jsonrpc_default_context: jsonrpc_ctx <cimport,nodecl>
global function jsonrpc_list(r: *jsonrpc_request): void <cimport,nodecl> end
global MJSON_ERROR_INVALID_INPUT: cint <cimport,nodecl,const>
global MJSON_ERROR_TOO_DEEP: cint <cimport,nodecl,const>
global MJSON_TOK_INVALID: cint <cimport,nodecl,const>
global MJSON_TOK_KEY: cint <cimport,nodecl,const>
global MJSON_TOK_STRING: cint <cimport,nodecl,const>
global MJSON_TOK_NUMBER: cint <cimport,nodecl,const>
global MJSON_TOK_TRUE: cint <cimport,nodecl,const>
global MJSON_TOK_FALSE: cint <cimport,nodecl,const>
global MJSON_TOK_NULL: cint <cimport,nodecl,const>
global MJSON_TOK_ARRAY: cint <cimport,nodecl,const>
global MJSON_TOK_OBJECT: cint <cimport,nodecl,const>
global MJSON_MAX_DEPTH: cint <cimport,nodecl,const>
global JSONRPC_ERROR_INVALID: cint <cimport,nodecl,const>
global JSONRPC_ERROR_NOT_FOUND: cint <cimport,nodecl,const>
global JSONRPC_ERROR_BAD_PARAMS: cint <cimport,nodecl,const>
global JSONRPC_ERROR_INTERNAL: cint <cimport,nodecl,const>
global function jsonrpc_ctx_export(ctx: *jsonrpc_ctx, req: cstring, fn: function(*jsonrpc_request): void): void <cimport,nodecl> end
global function jsonrpc_export(req: cstring, fn: function(*jsonrpc_request): void): void <cimport,nodecl> end
global function jsonrpc_process(req: cstring, req_sz: cint, fn: mjson_print_fn_t, fndata: pointer, userdata: pointer): void <cimport,nodecl> end