diff --git a/lib/connex.c b/lib/connex.c index b0ec444..8ae7160 100644 --- a/lib/connex.c +++ b/lib/connex.c @@ -249,6 +249,25 @@ int connections_init(conn_sys_t *ssys) return r; } +int connections_free(conn_sys_t *ssys) +{ + __destroy_rpc_list_tree(ssys->system_rpc->rpc_tree); + free(ssys->system_rpc->rpc_tree); + free(ssys->system_rpc); + free(ssys->connections); + pthread_rwlock_destroy(&(ssys->rwlock)); + + return 0; +} + +int connections_destroy(conn_sys_t *ssys) +{ + int r = connections_free(ssys); + free(ssys); + + return r; +} + conn_sys_t *connections_create(void) { int r = 0; @@ -289,3 +308,38 @@ int connections_setsslserts(conn_sys_t *ssys, const char *rootca, return r; } + +struct __scerrcode { + int code; + const char *desc; +}; + +static struct __scerrcode __lerr[] = { + {SNE_SUCCESS, "Success"}, + {SNE_FAILED, "Failed, invalid parameters given"}, + {SNE_ENOMEM, "Not enough memory"}, + {SNE_BADPROTO, "Bad protocol"}, + {SNE_ENORPC, "No such RPC exists"}, + {SNE_EPERM, "Permission denied"}, + {SNE_TOOLONG, "Message data payload too long to be sent with one message pass"}, + {SNE_EBUSY, "Index or working threads are busy"}, + {SNE_WOULDBLOCK, "Call will block operation"}, + {SNE_LINKERROR, "Connection link error"}, + {SNE_NOSUCHMSG, "No such message"}, + {SNE_NOSUCHCHAN, "No such channel"}, + {SNE_ETIMEDOUT, "Timeout exceed"}, + {SNE_IGNORED, "Function call was ignored"}, + {SNE_REPLYREQ, "Reply required to the message"}, + {SNE_RAPIDMSG, "Message is a rapid reply and dialog closed"}, + {SNE_ESSL, "SSL error occurs on connection link"}, + {SNE_NOCHANNELS, "No channels available"}, + {SNE_MCHANNELS, "Active channels limit exceed"}, + {SNE_MMESSAGES, "Active messages limit exceed"}, + {SNE_LINKBROKEN, "Connection link was broken"}, + {SNE_INVALINDEX, "Invalid index given"}, +}; + +const char *sntll_errno2cstr(int ec) +{ + return __lerr[ec - __SNTL_EPREFIX].desc; +}