Module: kamailio Branch: master Commit: 058fa9946b740c2b748ca592968aeec22c485ce6 URL: https://github.com/kamailio/kamailio/commit/058fa9946b740c2b748ca592968aeec2...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-01-08T09:33:43+01:00
app_jsdt: filled api list rpc command
---
Modified: src/modules/app_jsdt/app_jsdt_api.c
---
Diff: https://github.com/kamailio/kamailio/commit/058fa9946b740c2b748ca592968aeec2... Patch: https://github.com/kamailio/kamailio/commit/058fa9946b740c2b748ca592968aeec2...
---
diff --git a/src/modules/app_jsdt/app_jsdt_api.c b/src/modules/app_jsdt/app_jsdt_api.c index 47187ac..83404d1 100644 --- a/src/modules/app_jsdt/app_jsdt_api.c +++ b/src/modules/app_jsdt/app_jsdt_api.c @@ -1236,7 +1236,48 @@ static const char* app_jsdt_rpc_api_list_doc[2] = {
static void app_jsdt_rpc_api_list(rpc_t* rpc, void* ctx) { - rpc->fault(ctx, 500, "Not implemented"); + int i; + int n; + sr_kemi_t *ket; + void* th; + void* sh; + void* ih; + + if (rpc->add(ctx, "{", &th) < 0) { + rpc->fault(ctx, 500, "Internal error root reply"); + return; + } + n = 0; + for(i=0; i<SR_KEMI_JSDT_EXPORT_SIZE; i++) { + ket = sr_kemi_jsdt_export_get(i); + if(ket==NULL) continue; + n++; + } + + if(rpc->struct_add(th, "d[", + "msize", n, + "methods", &ih)<0) + { + rpc->fault(ctx, 500, "Internal error array structure"); + return; + } + for(i=0; i<SR_KEMI_JSDT_EXPORT_SIZE; i++) { + ket = sr_kemi_jsdt_export_get(i); + if(ket==NULL) continue; + if(rpc->struct_add(ih, "{", "func", &sh)<0) { + rpc->fault(ctx, 500, "Internal error internal structure"); + return; + } + if(rpc->struct_add(sh, "SSSS", + "ret", sr_kemi_param_map_get_name(ket->rtype), + "module", &ket->mname, + "name", &ket->fname, + "params", sr_kemi_param_map_get_params(ket->ptypes))<0) { + LM_ERR("failed to add the structure with attributes (%d)\n", i); + rpc->fault(ctx, 500, "Internal error creating dest struct"); + return; + } + } }
rpc_export_t app_jsdt_rpc_cmds[] = {