MIDAS
Loading...
Searching...
No Matches
JSON-RPC Functions

Classes

class  MJSO
 

Typedefs

typedef MJsonNode *() mjsonrpc_handler_t(const MJsonNode *params)
 

Functions

void mjsonrpc_init ()
 
void mjsonrpc_user_init ()
 
void mjsonrpc_add_handler (const char *method, mjsonrpc_handler_t *handler, bool needs_locking=false)
 
void mjsonrpc_exit ()
 
void mjsonrpc_set_std_mutex (void *mutex)
 
MJsonNode * mjsonrpc_get_schema ()
 
std::string mjsonrpc_schema_to_text (const MJsonNode *schema)
 
MJsonNode * mjsonrpc_make_error (int code, const char *message, const char *data)
 
MJsonNode * mjsonrpc_make_result (MJsonNode *node)
 
MJsonNode * mjsonrpc_make_result (const char *name, MJsonNode *value, const char *name2=NULL, MJsonNode *value2=NULL, const char *name3=NULL, MJsonNode *value3=NULL)
 
const MJsonNode * mjsonrpc_get_param (const MJsonNode *params, const char *name, MJsonNode **error)
 
MJsonNode * mjsonrpc_decode_post_data (const char *post_data)
 
static MJSOMJSO::MakeObjectSchema (const char *description)
 
static MJSOMJSO::MakeArraySchema (const char *description)
 
void MJSO::AddToSchema (MJsonNode *s, const char *name)
 
static MJSOMJSO::I ()
 
void MJSO::D (const char *description)
 
MJSOMJSO::Params ()
 
MJSOMJSO::Result ()
 
MJSOMJSO::PA (const char *description)
 
MJSOMJSO::RA (const char *description)
 
void MJSO::P (const char *name, int mjson_type, const char *description)
 
void MJSO::R (const char *name, int mjson_type, const char *description)
 
void MJSO::Add (const char *name, int mjson_type, const char *description)
 
MJSOMJSO::AddObject (const char *name, const char *description)
 
MJSOMJSO::AddArray (const char *name, const char *description)
 
 MJSO::MJSO ()
 

Variables

int mjsonrpc_debug
 
MJsonNode * MJSO::properties
 
MJsonNode * MJSO::required
 
MJsonNode * MJSO::items
 
MJSOMJSO::params
 
MJSOMJSO::result
 

Detailed Description


Typedef Documentation

◆ mjsonrpc_handler_t

typedef MJsonNode *() mjsonrpc_handler_t(const MJsonNode *params)

Definition at line 18 of file mjsonrpc.h.

Function Documentation

◆ MJSO()

MJSO::MJSO ( )
protected

Definition at line 403 of file mjsonrpc.cxx.

404 : MJsonNode(MJSON_OBJECT)
405{
406 properties = NULL;
407 required = NULL;
408 items = NULL;
409 params = NULL;
410 result = NULL;
411}
MJsonNode * properties
Definition mjsonrpc.h:61
MJsonNode * required
Definition mjsonrpc.h:62
MJSO * result
Definition mjsonrpc.h:66
MJsonNode * items
Definition mjsonrpc.h:63
MJSO * params
Definition mjsonrpc.h:65
Here is the caller graph for this function:

◆ Add()

void MJSO::Add ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 356 of file mjsonrpc.cxx.

357{
358 MJsonNode* p = MJsonNode::MakeObject();
359 p->AddToObject("description", MJsonNode::MakeString(description));
360 if (mjson_type == MJSON_ARRAY)
361 p->AddToObject("type", MJsonNode::MakeString("array"));
362 else if (mjson_type == MJSON_OBJECT)
363 p->AddToObject("type", MJsonNode::MakeString("object"));
364 else if (mjson_type == MJSON_STRING)
365 p->AddToObject("type", MJsonNode::MakeString("string"));
366 else if (mjson_type == MJSON_INT)
367 p->AddToObject("type", MJsonNode::MakeString("integer"));
368 else if (mjson_type == MJSON_NUMBER)
369 p->AddToObject("type", MJsonNode::MakeString("number"));
370 else if (mjson_type == MJSON_BOOL)
371 p->AddToObject("type", MJsonNode::MakeString("bool"));
372 else if (mjson_type == MJSON_NULL)
373 p->AddToObject("type", MJsonNode::MakeString("null"));
374 else if (mjson_type == MJSON_ARRAYBUFFER)
375 p->AddToObject("type", MJsonNode::MakeString("arraybuffer"));
376 else if (mjson_type == MJSON_JSON)
377 p->AddToObject("type", MJsonNode::MakeString("json"));
378 else if (mjson_type == 0)
379 ;
380 else
381 assert(!"invalid value of mjson_type");
382 this->AddToSchema(p, name);
383}
void AddToSchema(MJsonNode *s, const char *name)
Definition mjsonrpc.cxx:262
char description[1000]
Definition mana.cxx:267
#define name(x)
Definition midas_macro.h:24
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddArray()

MJSO * MJSO::AddArray ( const char *  name,
const char *  description 
)

Definition at line 394 of file mjsonrpc.cxx.

395{
397 s->AddToObject("description", MJsonNode::MakeString(description));
398 s->AddToObject("type", MJsonNode::MakeString("array"));
399 this->AddToSchema(s, name);
400 return s;
401}
static MJSO * MakeArraySchema(const char *description)
Definition mjsonrpc.cxx:243
Here is the call graph for this function:

◆ AddObject()

MJSO * MJSO::AddObject ( const char *  name,
const char *  description 
)

Definition at line 385 of file mjsonrpc.cxx.

386{
388 s->AddToObject("description", MJsonNode::MakeString(description));
389 s->AddToObject("type", MJsonNode::MakeString("object"));
390 this->AddToSchema(s, name);
391 return s;
392}
static MJSO * MakeObjectSchema(const char *description)
Definition mjsonrpc.cxx:230
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AddToSchema()

void MJSO::AddToSchema ( MJsonNode *  s,
const char *  name 
)
protected

Definition at line 262 of file mjsonrpc.cxx.

263{
264 if (!xname)
265 xname = "";
266
267 bool optional = strchr(xname, '?');
268 bool array = strchr(xname, '[');
269
270 // remove the "?" and "[]" marker characters
271 std::string name = xname;
272 name = remove(name, '?');
273 name = remove(name, '[');
274 name = remove(name, ']');
275
276 if (optional)
277 s->AddToObject("optional", MJsonNode::MakeBool(true));
278
279 if (array) { // insert an array schema
280 MJSO* ss = MakeArraySchema(s->FindObjectNode("description")->GetString().c_str());
281 s->DeleteObjectNode("description");
282 ss->AddToSchema(s, "");
283 s = ss;
284 }
285
286 if (items)
287 items->AddToArray(s);
288 else {
289 assert(properties);
290 assert(required);
291 properties->AddToObject(name.c_str(), s);
292 if (!optional) {
293 required->AddToArray(MJsonNode::MakeString(name.c_str()));
294 }
295 }
296}
static std::string remove(const std::string s, char c)
Definition mjsonrpc.cxx:253
Here is the call graph for this function:
Here is the caller graph for this function:

◆ D()

void MJSO::D ( const char *  description)

Definition at line 303 of file mjsonrpc.cxx.

304{
305 this->AddToObject("description", MJsonNode::MakeString(description));
306}

◆ I()

MJSO * MJSO::I ( )
static

Definition at line 298 of file mjsonrpc.cxx.

299{
300 return MakeObjectSchema(NULL);
301}
Here is the call graph for this function:

◆ MakeArraySchema()

MJSO * MJSO::MakeArraySchema ( const char *  description)
staticprotected

Definition at line 243 of file mjsonrpc.cxx.

244{
245 MJSO* p = new MJSO();
246 p->AddToObject("description", MJsonNode::MakeString(description));
247 p->AddToObject("type", MJsonNode::MakeString("array"));
248 p->items = MJsonNode::MakeArray();
249 p->AddToObject("items", p->items);
250 return p;
251}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ MakeObjectSchema()

MJSO * MJSO::MakeObjectSchema ( const char *  description)
staticprotected

Definition at line 230 of file mjsonrpc.cxx.

231{
232 MJSO* p = new MJSO();
233 if (description)
234 p->AddToObject("description", MJsonNode::MakeString(description));
235 p->AddToObject("type", MJsonNode::MakeString("object"));
236 p->properties = MJsonNode::MakeObject();
237 p->required = MJsonNode::MakeArray();
238 p->AddToObject("properties", p->properties);
239 p->AddToObject("required", p->required);
240 return p;
241}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_add_handler()

void mjsonrpc_add_handler ( const char *  method,
mjsonrpc_handler_t handler,
bool  needs_locking = false 
)

Definition at line 4735 of file mjsonrpc.cxx.

4736{
4738 e.fHandler = handler;
4739 e.fNeedsLocking = needs_locking;
4740 gMethodsTable[method] = e;
4741}
static MethodsTable gMethodsTable
mjsonrpc_handler_t * fHandler
static double e(void)
Definition tinyexpr.c:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_decode_post_data()

MJsonNode * mjsonrpc_decode_post_data ( const char *  post_data)

Definition at line 5360 of file mjsonrpc.cxx.

5361{
5362 //printf("mjsonrpc call, data [%s]\n", post_data);
5363 MJsonNode *request = MJsonNode::Parse(post_data);
5364
5365 assert(request != NULL); // Parse never returns NULL - either parsed data or an MJSON_ERROR node
5366
5367 if (mjsonrpc_debug) {
5368 printf("mjsonrpc: request:\n");
5369 request->Dump();
5370 printf("\n");
5371 }
5372
5373 if (mjsonrpc_sleep) {
5374 if (mjsonrpc_debug) {
5375 printf("mjsonrpc: sleep %d\n", mjsonrpc_sleep);
5376 }
5377 for (int i=0; i<mjsonrpc_sleep; i++) {
5378 sleep(1);
5379 }
5380 }
5381
5382 if (request->GetType() == MJSON_ERROR) {
5383 MJsonNode* reply = mjsonrpc_make_error(-32700, "Parse error", request->GetError().c_str());
5384 reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5385 reply->AddToObject("id", MJsonNode::MakeNull());
5386
5387 if (mjsonrpc_debug) {
5388 printf("mjsonrpc: invalid json: reply:\n");
5389 printf("%s\n", reply->Stringify().c_str());
5390 printf("\n");
5391 }
5392
5393 delete request;
5394 return reply;
5395 } else if (request->GetType() == MJSON_OBJECT) {
5396 MJsonNode* reply = mjsonrpc_handle_request(request);
5397 delete request;
5398 return reply;
5399 } else if (request->GetType() == MJSON_ARRAY) {
5400 const MJsonNodeVector* a = request->GetArray();
5401
5402 if (a->size() < 1) {
5403 MJsonNode* reply = mjsonrpc_make_error(-32600, "Invalid request", "batch request array has less than 1 element");
5404 reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5405 reply->AddToObject("id", MJsonNode::MakeNull());
5406
5407 if (mjsonrpc_debug) {
5408 printf("mjsonrpc: invalid json: reply:\n");
5409 printf("%s\n", reply->Stringify().c_str());
5410 printf("\n");
5411 }
5412
5413 delete request;
5414 return reply;
5415 }
5416
5417 MJsonNode* reply = MJsonNode::MakeArray();
5418
5419 for (unsigned i=0; i<a->size(); i++) {
5420 MJsonNode* r = mjsonrpc_handle_request(a->at(i));
5421 reply->AddToArray(r);
5422 if (r->GetType() == MJSON_ARRAYBUFFER) {
5423 delete request;
5424 delete reply;
5425 reply = mjsonrpc_make_error(-32600, "Invalid request", "MJSON_ARRAYBUFFER return is not permitted for batch requests");
5426 reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5427 reply->AddToObject("id", MJsonNode::MakeNull());
5428 return reply;
5429 }
5430 }
5431
5432 delete request;
5433 return reply;
5434 } else {
5435 MJsonNode* reply = mjsonrpc_make_error(-32600, "Invalid request", "request is not a JSON object or JSON array");
5436 reply->AddToObject("jsonrpc", MJsonNode::MakeString("2.0"));
5437 reply->AddToObject("id", MJsonNode::MakeNull());
5438
5439 if (mjsonrpc_debug) {
5440 printf("mjsonrpc: invalid json: reply:\n");
5441 printf("%s\n", reply->Stringify().c_str());
5442 printf("\n");
5443 }
5444
5445 delete request;
5446 return reply;
5447 }
5448}
MJsonNode * mjsonrpc_make_error(int code, const char *message, const char *data)
Definition mjsonrpc.cxx:123
int mjsonrpc_debug
Definition mjsonrpc.cxx:112
INT i
Definition mdump.cxx:32
char request[600000]
Definition melog.cxx:90
#define sleep(ms)
static int mjsonrpc_sleep
Definition mjsonrpc.cxx:113
static MJsonNode * mjsonrpc_handle_request(const MJsonNode *request)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_exit()

void mjsonrpc_exit ( )

Definition at line 4836 of file mjsonrpc.cxx.

4837{
4838 if (mjsonrpc_debug) {
4839 printf("mjsonrpc_exit!\n");
4840 }
4841
4842 js_hs_exit();
4844}
static void DeleteEventStash()
static void js_hs_exit()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_get_param()

const MJsonNode * mjsonrpc_get_param ( const MJsonNode *  params,
const char *  name,
MJsonNode **  error 
)

Definition at line 178 of file mjsonrpc.cxx.

179{
180 assert(gNullNode != NULL);
181
182 // NULL params is a request for documentation, return an empty object
183 if (!params) {
184 if (error)
185 *error = MJsonNode::MakeObject();
186 return gNullNode;
187 }
188
189 const MJsonNode* obj = params->FindObjectNode(name);
190 if (!obj) {
191 if (error)
192 *error = mjsonrpc_make_error(-32602, "Invalid params", (std::string("missing parameter: ") + name).c_str());
193 return gNullNode;
194 }
195
196 if (error)
197 *error = NULL;
198 return obj;
199}
static MJsonNode * gNullNode
Definition mjsonrpc.cxx:176
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_get_schema()

MJsonNode * mjsonrpc_get_schema ( )

Definition at line 4874 of file mjsonrpc.cxx.

4875{
4877}
static MJsonNode * mjsonrpc_make_schema(MethodsTable *h)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_init()

void mjsonrpc_init ( )

Definition at line 4748 of file mjsonrpc.cxx.

4749{
4750 if (mjsonrpc_debug) {
4751 printf("mjsonrpc_init!\n");
4752 }
4753
4754 if (!gNullNode)
4755 gNullNode = MJsonNode::MakeNull();
4756
4757 // test, debug and control methods for the rpc system
4758 mjsonrpc_add_handler("null", xnull);
4759 mjsonrpc_add_handler("get_debug", get_debug);
4760 mjsonrpc_add_handler("set_debug", set_debug);
4761 mjsonrpc_add_handler("get_sleep", get_sleep);
4762 mjsonrpc_add_handler("set_sleep", set_sleep);
4763 mjsonrpc_add_handler("get_time", get_time);
4764 mjsonrpc_add_handler("set_time", set_time);
4765 mjsonrpc_add_handler("get_schema", get_schema);
4766 // interface to alarm functions
4767 mjsonrpc_add_handler("al_reset_alarm", js_al_reset_alarm, true);
4768 mjsonrpc_add_handler("al_trigger_alarm", js_al_trigger_alarm, true);
4769 mjsonrpc_add_handler("al_trigger_class", js_al_trigger_class, true);
4770 // interface to midas.c functions
4771 mjsonrpc_add_handler("cm_exist", js_cm_exist, true);
4772 mjsonrpc_add_handler("cm_msg_facilities", js_cm_msg_facilities);
4773 mjsonrpc_add_handler("cm_msg_retrieve", js_cm_msg_retrieve);
4774 mjsonrpc_add_handler("cm_msg1", js_cm_msg1);
4775 mjsonrpc_add_handler("cm_shutdown", js_cm_shutdown, true);
4776 mjsonrpc_add_handler("cm_transition", js_cm_transition, true);
4777 mjsonrpc_add_handler("bm_receive_event", js_bm_receive_event, true);
4778 // interface to odb functions
4779 mjsonrpc_add_handler("db_copy", js_db_copy);
4780 mjsonrpc_add_handler("db_paste", js_db_paste);
4781 mjsonrpc_add_handler("db_get_values", js_db_get_values);
4783 mjsonrpc_add_handler("db_create", js_db_create);
4784 mjsonrpc_add_handler("db_delete", js_db_delete);
4785 mjsonrpc_add_handler("db_resize", js_db_resize);
4786 mjsonrpc_add_handler("db_resize_string", js_db_resize_string);
4787 mjsonrpc_add_handler("db_rename", js_db_rename);
4790 mjsonrpc_add_handler("db_link", js_db_link);
4791 mjsonrpc_add_handler("db_reorder", js_db_reorder);
4793 // interface to elog functions
4794 mjsonrpc_add_handler("el_retrieve", js_el_retrieve, true);
4795 mjsonrpc_add_handler("el_query", js_el_query, true);
4796 mjsonrpc_add_handler("el_delete", js_el_delete, true);
4797 // interface to midas history
4798 mjsonrpc_add_handler("hs_get_active_events", js_hs_get_active_events, true);
4799 mjsonrpc_add_handler("hs_get_channels", js_hs_get_channels, true);
4800 mjsonrpc_add_handler("hs_get_events", js_hs_get_events, true);
4801 mjsonrpc_add_handler("hs_get_tags", js_hs_get_tags, true);
4802 mjsonrpc_add_handler("hs_get_last_written", js_hs_get_last_written, true);
4803 mjsonrpc_add_handler("hs_reopen", js_hs_reopen, true);
4804 mjsonrpc_add_handler("hs_read", js_hs_read, true);
4805 mjsonrpc_add_handler("hs_read_binned", js_hs_read_binned, true);
4806 mjsonrpc_add_handler("hs_read_arraybuffer", js_hs_read_arraybuffer, true);
4807 mjsonrpc_add_handler("hs_read_binned_arraybuffer", js_hs_read_binned_arraybuffer, true);
4808 // interface to image history
4809 mjsonrpc_add_handler("hs_image_retrieve", js_hs_image_retrieve, true);
4810 // sequencer and file_picker
4811 mjsonrpc_add_handler("make_subdir", js_make_subdir, true);
4812 mjsonrpc_add_handler("ext_list_files", js_ext_list_files, true);
4813 mjsonrpc_add_handler("ext_save_file", js_ext_save_file, true);
4814 mjsonrpc_add_handler("ext_read_file", js_ext_read_file, true);
4815 // Read binary files of Uint8Arry
4816 mjsonrpc_add_handler("read_binary_file", js_read_binary_file, true);
4817 // interface to ss_system functions
4818 mjsonrpc_add_handler("ss_millitime", js_ss_millitime);
4819 // methods that perform computations or invoke actions
4820 mjsonrpc_add_handler("get_alarms", get_alarms);
4821 //mjsonrpc_add_handler("get_messages", get_messages);
4823 mjsonrpc_add_handler("jrpc_cxx", jrpc_cxx);
4824 mjsonrpc_add_handler("jrpc_old", jrpc_old);
4826 mjsonrpc_add_handler("brpc_cxx", brpc_cxx);
4827 mjsonrpc_add_handler("brpc_old", brpc_old);
4828 mjsonrpc_add_handler("start_program", start_program);
4829 mjsonrpc_add_handler("exec_script", exec_script);
4830 // timezone function
4831 mjsonrpc_add_handler("get_timezone", js_get_timezone);
4832
4834}
void mjsonrpc_user_init()
void mjsonrpc_add_handler(const char *method, mjsonrpc_handler_t *handler, bool needs_locking)
double get_time()
Definition feslow.cxx:245
static MJsonNode * js_cm_transition(const MJsonNode *params)
static MJsonNode * set_sleep(const MJsonNode *params)
static MJsonNode * js_cm_msg1(const MJsonNode *params)
static MJsonNode * get_sleep(const MJsonNode *params)
static MJsonNode * js_al_trigger_class(const MJsonNode *params)
static MJsonNode * js_el_delete(const MJsonNode *params)
static MJsonNode * js_hs_read_arraybuffer(const MJsonNode *params)
static MJsonNode * js_db_paste(const MJsonNode *params)
Definition mjsonrpc.cxx:912
static MJsonNode * js_ext_save_file(const MJsonNode *params)
static MJsonNode * js_get_timezone(const MJsonNode *params)
static MJsonNode * jrpc_old(const MJsonNode *params)
static MJsonNode * js_ext_list_files(const MJsonNode *params)
static MJsonNode * js_hs_read_binned(const MJsonNode *params)
static MJsonNode * js_ext_read_file(const MJsonNode *params)
static MJsonNode * start_program(const MJsonNode *params)
Definition mjsonrpc.cxx:483
static MJsonNode * js_hs_get_last_written(const MJsonNode *params)
static MJsonNode * jrpc_cxx(const MJsonNode *params)
static MJsonNode * js_bm_receive_event(const MJsonNode *params)
static MJsonNode * js_hs_get_active_events(const MJsonNode *params)
static MJsonNode * js_db_ls(const MJsonNode *params)
Definition mjsonrpc.cxx:802
static MJsonNode * js_db_sor(const MJsonNode *params)
static MJsonNode * js_db_copy(const MJsonNode *params)
Definition mjsonrpc.cxx:857
static MJsonNode * js_db_scl(const MJsonNode *params)
static MJsonNode * js_cm_msg_retrieve(const MJsonNode *params)
static MJsonNode * xnull(const MJsonNode *params)
Definition mjsonrpc.cxx:413
static MJsonNode * js_ss_millitime(const MJsonNode *params)
static MJsonNode * js_db_delete(const MJsonNode *params)
static MJsonNode * js_read_binary_file(const MJsonNode *params)
static MJsonNode * js_db_rename(const MJsonNode *params)
static MJsonNode * js_cm_msg_facilities(const MJsonNode *params)
static MJsonNode * js_db_key(const MJsonNode *params)
static MJsonNode * js_cm_exist(const MJsonNode *params)
Definition mjsonrpc.cxx:432
static MJsonNode * js_db_reorder(const MJsonNode *params)
static MJsonNode * js_db_resize_string(const MJsonNode *params)
static MJsonNode * js_hs_get_tags(const MJsonNode *params)
static MJsonNode * js_el_retrieve(const MJsonNode *params)
static MJsonNode * get_alarms(const MJsonNode *params)
static MJsonNode * js_el_query(const MJsonNode *params)
static MJsonNode * js_db_link(const MJsonNode *params)
static MJsonNode * exec_script(const MJsonNode *params)
Definition mjsonrpc.cxx:516
static MJsonNode * get_schema(const MJsonNode *params)
static MJsonNode * js_al_reset_alarm(const MJsonNode *params)
static MJsonNode * brpc_cxx(const MJsonNode *params)
static MJsonNode * set_time(const MJsonNode *params)
static MJsonNode * set_debug(const MJsonNode *params)
static MJsonNode * js_db_resize(const MJsonNode *params)
static MJsonNode * js_hs_get_events(const MJsonNode *params)
static MJsonNode * js_hs_read(const MJsonNode *params)
static MJsonNode * js_make_subdir(const MJsonNode *params)
static MJsonNode * js_hs_image_retrieve(const MJsonNode *params)
static MJsonNode * get_debug(const MJsonNode *params)
static MJsonNode * js_cm_shutdown(const MJsonNode *params)
Definition mjsonrpc.cxx:459
static MJsonNode * js_db_get_values(const MJsonNode *params)
Definition mjsonrpc.cxx:637
static MJsonNode * js_al_trigger_alarm(const MJsonNode *params)
static MJsonNode * js_db_create(const MJsonNode *params)
static MJsonNode * js_hs_read_binned_arraybuffer(const MJsonNode *params)
static MJsonNode * js_hs_get_channels(const MJsonNode *params)
static MJsonNode * js_hs_reopen(const MJsonNode *params)
static MJsonNode * brpc_old(const MJsonNode *params)
Here is the caller graph for this function:

◆ mjsonrpc_make_error()

MJsonNode * mjsonrpc_make_error ( int  code,
const char *  message,
const char *  data 
)

Definition at line 123 of file mjsonrpc.cxx.

124{
125 MJsonNode* errnode = MJsonNode::MakeObject();
126 errnode->AddToObject("code", MJsonNode::MakeInt(code));
127 errnode->AddToObject("message", MJsonNode::MakeString(message));
128 errnode->AddToObject("data", MJsonNode::MakeString(data));
129
130 MJsonNode* result = MJsonNode::MakeObject();
131 result->AddToObject("error", errnode);
132 return result;
133}
void * data
Definition mana.cxx:268
#define message(type, str)
Here is the caller graph for this function:

◆ mjsonrpc_make_result() [1/2]

MJsonNode * mjsonrpc_make_result ( const char *  name,
MJsonNode *  value,
const char *  name2 = NULL,
MJsonNode *  value2 = NULL,
const char *  name3 = NULL,
MJsonNode *  value3 = NULL 
)

Definition at line 142 of file mjsonrpc.cxx.

143{
144 MJsonNode* node = MJsonNode::MakeObject();
145
146 if (name)
147 node->AddToObject(name, value);
148 if (name2)
149 node->AddToObject(name2, value2);
150 if (name3)
151 node->AddToObject(name3, value3);
152
153 MJsonNode* result = MJsonNode::MakeObject();
154 result->AddToObject("result", node);
155 return result;
156}
double value[100]
Definition odbhist.cxx:42

◆ mjsonrpc_make_result() [2/2]

MJsonNode * mjsonrpc_make_result ( MJsonNode *  node)

Definition at line 135 of file mjsonrpc.cxx.

136{
137 MJsonNode* result = MJsonNode::MakeObject();
138 result->AddToObject("result", node);
139 return result;
140}

◆ mjsonrpc_schema_to_text()

std::string mjsonrpc_schema_to_text ( const MJsonNode *  schema)

Definition at line 5184 of file mjsonrpc.cxx.

5185{
5186 std::string s;
5187 NestedOutput out;
5188 out.Clear();
5189 mjsonrpc_schema_to_html_anything(schema, 0, &out);
5190 //s += "<pre>\n";
5191 //s += nested_dump();
5192 //s += "</pre>\n";
5193 s += out.Print();
5194 return s;
5195}
std::string Print()
static std::string mjsonrpc_schema_to_html_anything(const MJsonNode *schema, int nest_level, NestedOutput *o)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mjsonrpc_set_std_mutex()

void mjsonrpc_set_std_mutex ( void *  mutex)

Definition at line 4743 of file mjsonrpc.cxx.

4744{
4745 gMutex = (std::mutex*)mutex;
4746}
static std::mutex * gMutex
Here is the caller graph for this function:

◆ mjsonrpc_user_init()

void mjsonrpc_user_init ( )

Definition at line 116 of file mjsonrpc_user.cxx.

117{
118 if (mjsonrpc_debug) {
119 printf("mjsonrpc_user_init!\n");
120 }
121
122 // add user functions to the rpc list
123
124 mjsonrpc_add_handler("user_example1", user_example1);
125 mjsonrpc_add_handler("user_example2", user_example2);
126 mjsonrpc_add_handler("user_example3", user_example3);
127}
static MJsonNode * user_example3(const MJsonNode *params)
static MJsonNode * user_example1(const MJsonNode *params)
static MJsonNode * user_example2(const MJsonNode *params)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ P()

void MJSO::P ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 340 of file mjsonrpc.cxx.

341{
342 if (name == NULL)
343 this->Add("params", mjson_type, description);
344 else
345 Params()->Add(name, mjson_type, description);
346}
MJSO * Params()
Definition mjsonrpc.cxx:308
void Add(const char *name, int mjson_type, const char *description)
Definition mjsonrpc.cxx:356
Here is the call graph for this function:

◆ PA()

MJSO * MJSO::PA ( const char *  description)

Definition at line 326 of file mjsonrpc.cxx.

327{
329 this->AddToSchema(s, "params");
330 return s;
331}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Params()

MJSO * MJSO::Params ( )

Definition at line 308 of file mjsonrpc.cxx.

309{
310 if (!params) {
311 params = MakeObjectSchema(NULL);
312 this->AddToSchema(params, "params");
313 }
314 return params;
315}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ R()

void MJSO::R ( const char *  name,
int  mjson_type,
const char *  description 
)

Definition at line 348 of file mjsonrpc.cxx.

349{
350 if (name == NULL)
351 this->Add("result", mjson_type, description);
352 else
353 Result()->Add(name, mjson_type, description);
354}
MJSO * Result()
Definition mjsonrpc.cxx:317
Here is the call graph for this function:

◆ RA()

MJSO * MJSO::RA ( const char *  description)

Definition at line 333 of file mjsonrpc.cxx.

334{
336 this->AddToSchema(s, "result");
337 return s;
338}
Here is the call graph for this function:

◆ Result()

MJSO * MJSO::Result ( )

Definition at line 317 of file mjsonrpc.cxx.

318{
319 if (!result) {
320 result = MakeObjectSchema(NULL);
321 this->AddToSchema(result, "result");
322 }
323 return result;
324}
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ items

MJsonNode* MJSO::items
protected

Definition at line 63 of file mjsonrpc.h.

◆ mjsonrpc_debug

int mjsonrpc_debug
extern

Definition at line 112 of file mjsonrpc.cxx.

◆ params

MJSO* MJSO::params
protected

Definition at line 65 of file mjsonrpc.h.

◆ properties

MJsonNode* MJSO::properties
protected

Definition at line 61 of file mjsonrpc.h.

◆ required

MJsonNode* MJSO::required
protected

Definition at line 62 of file mjsonrpc.h.

◆ result

MJSO* MJSO::result
protected

Definition at line 66 of file mjsonrpc.h.