From b76c7610c557e1393c370154fe86589cd9adf5ac Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Mon, 20 Jul 2015 19:27:27 +0300 Subject: [PATCH] message process added; --- lib/messagesx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/messagesx.c b/lib/messagesx.c index 0a830ca..b5ab773 100644 --- a/lib/messagesx.c +++ b/lib/messagesx.c @@ -29,5 +29,31 @@ void _message_process(sxmsg_t *msg) { + chnl_t *chan = msg->pch; + sexp_t *sx, *isx; + usrtc_t *listrpc = chan->rpc_list->rpc_tree; + usrtc_node_t *node; + cx_rpc_t *rpcc; + int r; + + sx = parse_sexp(msg->payload, msg->mhead.payload_length); + if(!sx) sxmsg_return(msg, SNE_BADPROTO); + + sexp_list_car(sx, &isx); + if(!isx) { r = SNE_BADPROTO; goto __return_err; } + if(isx->ty == SEXP_LIST) { r = SNE_BADPROTO; goto __return_err; } + if(isx->aty != SEXP_BASIC) { r = SNE_BADPROTO; goto __return_err; } + + node = usrtc_lookup(listrpc, (void *)isx->val); + if(!node) { r = SNE_ENORPC; goto __return_err; } + else rpcc = (cx_rpc_t *)usrtc_node_getdata(node); + + rpcc->rpcf((void *)msg, sx); /* sx *MUST* be destroy asap */ + + return; + + __return_err: + destroy_sexp(sx); + sxmsg_return(msg, r); return; }