| | |
| | | |
| | | const auto& pbstr = msgRT.SerializeAsString(); |
| | | tie(msg->msg, msg->msgl) = copymemory(pbstr); |
| | | auto doc = yyjson_read(msg->msg, msg->msgl, 0); |
| | | yyjson_val* root = yyjson_doc_get_root(doc); |
| | | |
| | | auto obj = [](yyjson_val* v, const char* name){return yyjson_obj_get(v, name);}; |
| | | |
| | | auto jp = obj(root, "path"); |
| | | auto jb = obj(root, "body"); |
| | | if (jp && jb){ |
| | | tie(msg->path, msg->pathl) = copymemory(yyjson_get_str(jp), yyjson_get_len(jp)); |
| | | tie(msg->body, msg->bodyl) = copymemory(yyjson_get_str(jb), yyjson_get_len(jb)); |
| | | } |
| | | |
| | | yyjson_doc_free(doc); |
| | | |
| | | return msg; |
| | | } |
| | |
| | | if (msg){ |
| | | free(msg->procid); |
| | | free(msg->msg); |
| | | free(msg->path); |
| | | free(msg->body); |
| | | free(msg); |
| | | } |
| | | } |
| | | |
| | | static tuple<const char*, size_t> json2body(yyjson_doc* doc){ |
| | | ignoreT(json2body); |
| | | |
| | | yyjson_val* root = yyjson_doc_get_root(doc); |
| | | |
| | | auto obj = [](yyjson_val* v, const char* name){return yyjson_obj_get(v, name);}; |
| | |
| | | if (!jp) return make_tuple((const char*)NULL, 0); |
| | | auto jb = obj(root, "body"); |
| | | if (!jb) return make_tuple((const char*)NULL, 0); |
| | | return make_tuple(yyjson_get_str(jb), yyjson_get_len(jp)); |
| | | return make_tuple(yyjson_get_str(jb), yyjson_get_len(jb)); |
| | | } |
| | | |
| | | struct cstackmsgerr* get_reqmsg_stackerr(struct creqmsg* msg){ |
| | | auto doc0 = yyjson_read(msg->msg, msg->msgl, 0); |
| | | auto tpbody = json2body(doc0); |
| | | if (!get<0>(tpbody)) return NULL; |
| | | // auto doc0 = yyjson_read(msg->msg, msg->msgl, 0); |
| | | // auto tpbody = json2body(doc0); |
| | | // if (!get<0>(tpbody)) return NULL; |
| | | // auto doc = yyjson_read(get<0>(tpbody), get<1>(tpbody), 0); |
| | | |
| | | auto doc = yyjson_read(get<0>(tpbody), get<1>(tpbody), 0); |
| | | auto doc = yyjson_read(msg->body, msg->bodyl, 0); |
| | | auto root = yyjson_doc_get_root(doc); |
| | | |
| | | auto obj = [](yyjson_val* v, const char* name){return yyjson_obj_get(v, name);}; |
| | |
| | | tie(smsg->fileid, smsg->fileidl) = copymemory(yyjson_get_str(jfid), yyjson_get_len(jfid)); |
| | | yyjson_doc_free(doc); |
| | | |
| | | yyjson_doc_free(doc0); |
| | | // yyjson_doc_free(doc0); |
| | | |
| | | return smsg; |
| | | } |
| | |
| | | } |
| | | // decode success msg |
| | | struct cstackmsg* get_reqmsg_stack(struct creqmsg* msg){ |
| | | auto doc0 = yyjson_read(msg->msg, msg->msgl, 0); |
| | | auto tpbody = json2body(doc0); |
| | | if (!get<0>(tpbody)) return NULL; |
| | | // auto doc0 = yyjson_read(msg->msg, msg->msgl, 0); |
| | | // auto tpbody = json2body(doc0); |
| | | // if (!get<0>(tpbody)) return NULL; |
| | | // auto doc = yyjson_read(get<0>(tpbody), get<1>(tpbody), 0); |
| | | |
| | | auto doc = yyjson_read(get<0>(tpbody), get<1>(tpbody), 0); |
| | | auto doc = yyjson_read(msg->body, msg->bodyl, 0); |
| | | auto root = yyjson_doc_get_root(doc); |
| | | |
| | | auto obj = [](yyjson_val* v, const char* name){return yyjson_obj_get(v, name);}; |
| | |
| | | smsg->files[i] = file; |
| | | } |
| | | yyjson_doc_free(doc); |
| | | yyjson_doc_free(doc0); |
| | | // yyjson_doc_free(doc0); |
| | | |
| | | return smsg; |
| | | } |