[sr-dev] git:master:37f664c4: app_ruby: added missing app_ruby.api_list rpc command

Daniel-Constantin Mierla miconda at gmail.com
Mon Dec 17 09:05:18 CET 2018


Module: kamailio
Branch: master
Commit: 37f664c404c5391181fcb61e2ec2955105c47a4d
URL: https://github.com/kamailio/kamailio/commit/37f664c404c5391181fcb61e2ec2955105c47a4d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-12-17T09:04:07+01:00

app_ruby: added missing app_ruby.api_list rpc command

---

Modified: src/modules/app_ruby/app_ruby_api.c

---

Diff:  https://github.com/kamailio/kamailio/commit/37f664c404c5391181fcb61e2ec2955105c47a4d.diff
Patch: https://github.com/kamailio/kamailio/commit/37f664c404c5391181fcb61e2ec2955105c47a4d.patch

---

diff --git a/src/modules/app_ruby/app_ruby_api.c b/src/modules/app_ruby/app_ruby_api.c
index a503cddb5b..ff944ca20e 100644
--- a/src/modules/app_ruby/app_ruby_api.c
+++ b/src/modules/app_ruby/app_ruby_api.c
@@ -1282,12 +1282,65 @@ static void app_ruby_rpc_reload(rpc_t* rpc, void* ctx)
 			"new", *_sr_ruby_reload_version);
 }
 
+static const char* app_ruby_rpc_api_list_doc[2] = {
+	"List kemi exports to ruby",
+	0
+};
+
+static void app_ruby_rpc_api_list(rpc_t* rpc, void* ctx)
+{
+	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_RUBY_EXPORT_SIZE; i++) {
+		ket = sr_kemi_ruby_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_RUBY_EXPORT_SIZE; i++) {
+		ket = sr_kemi_ruby_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_ruby_rpc_cmds[] = {
 	{"app_ruby.reload", app_ruby_rpc_reload,
 		app_ruby_rpc_reload_doc, 0},
+	{"app_ruby.api_list", app_ruby_rpc_api_list,
+		app_ruby_rpc_api_list_doc, 0},
 	{0, 0, 0, 0}
 };
 




More information about the sr-dev mailing list