| | |
| | | reg->sub_net_count = subnetcnt; |
| | | return reg; |
| | | } |
| | | creg* make_creg_from_cproc(const cproc* proc){ |
| | | auto reg = ptrT<struct creg>(); |
| | | reg->proc = rmConst(proc); |
| | | return reg; |
| | | } |
| | | |
| | | static inline void creg_add_topic(char*** dst, size_t* dstC, const char** src, const size_t srcC){ |
| | | *dst = rmConst(src); |
| | | *dstC = srcC; |
| | | } |
| | | void creg_add_topic_reply(creg* reg, const char** topic, const size_t count){ |
| | | creg_add_topic(®->channel, ®->channel_count, topic, count); |
| | | } |
| | | |
| | | void creg_add_topic_pub(creg* reg, const char** topic, const size_t count){ |
| | | creg_add_topic(®->pub, ®->pub_count, topic, count); |
| | | } |
| | | |
| | | void creg_add_topic_sub(creg* reg, const char** topic, const size_t count){ |
| | | creg_add_topic(®->sub, ®->sub_count, topic, count); |
| | | } |
| | | |
| | | void creg_add_topic_subnet(creg* reg, const char** topic, const size_t count){ |
| | | creg_add_topic(®->sub_net, ®->sub_net_count, topic, count); |
| | | } |
| | | |
| | | const cproc* creg_proc(const creg* reg){ |
| | | if (!reg) return NULL; |
| | | return reg->proc; |
| | | } |
| | | |
| | | char** creg_rep_topic(const creg* reg, size_t* count){ |
| | | char** creg_reply_topic(const creg* reg, size_t* count){ |
| | | if (!reg) return NULL; |
| | | *count = reg->channel_count; |
| | | return reg->channel; |
| | |
| | | } |
| | | } |
| | | |
| | | template <class F> void ignoref(F&& f){} |
| | | static struct cstr make_reply_msg_json(const int success, const char* msg, const size_t msgl, |
| | | const char* data, const size_t datal) |
| | | { |
| | | ignoref(make_reply_msg_json); |
| | | |
| | | auto doc = yyjson_mut_doc_new(NULL); |
| | | auto root = yyjson_mut_obj(doc); |
| | | yyjson_mut_obj_add_bool(doc, root, "success", !!success); |