Module: kamailio
Branch: master
Commit: f5792d1c61702526f6382d4250c16ba0deacff6f
URL:
https://github.com/kamailio/kamailio/commit/f5792d1c61702526f6382d4250c16ba…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-06-07T12:40:13+02:00
core: new rpc command - core.ppdefines_full
- print preprocess defines with their details
---
Modified: src/core/cfg.lex
Modified: src/core/core_cmd.c
Modified: src/core/ppcfg.h
---
Diff:
https://github.com/kamailio/kamailio/commit/f5792d1c61702526f6382d4250c16ba…
Patch:
https://github.com/kamailio/kamailio/commit/f5792d1c61702526f6382d4250c16ba…
---
diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index 65507e7dfb..192b488938 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -1724,6 +1724,13 @@ str* pp_get_define_name(int idx)
return &pp_defines[idx].name;
}
+ksr_ppdefine_t* pp_get_define(int idx)
+{
+ if(idx<0 || idx>=pp_num_defines)
+ return NULL;
+ return &pp_defines[idx];
+}
+
static int pp_lookup(int len, const char * text)
{
str var = {(char *)text, len};
@@ -1768,7 +1775,7 @@ int pp_define(int len, const char * text)
pp_defines[ppos].value.len = 0;
pp_defines[ppos].value.s = NULL;
}
- pp_defines[ppos].type = pp_define_type;
+ pp_defines[ppos].dtype = pp_define_type;
return 0;
} else {
LM_CRIT("already defined: %.*s\n", len, text);
@@ -1786,7 +1793,7 @@ int pp_define(int len, const char * text)
pp_defines[pp_num_defines].name.s[len] = '\0';
pp_defines[pp_num_defines].value.len = 0;
pp_defines[pp_num_defines].value.s = NULL;
- pp_defines[pp_num_defines].type = pp_define_type;
+ pp_defines[pp_num_defines].dtype = pp_define_type;
pp_define_index = pp_num_defines;
pp_num_defines++;
diff --git a/src/core/core_cmd.c b/src/core/core_cmd.c
index 4dc5554671..d1ceb88cef 100644
--- a/src/core/core_cmd.c
+++ b/src/core/core_cmd.c
@@ -998,6 +998,44 @@ static void core_ppdefines(rpc_t* rpc, void* c)
}
}
+/**
+ *
+ */
+static const char* core_ppdefines_full_doc[] = {
+ "List preprocessor defines with full details", /* Documentation string */
+ 0 /* Method signature(s) */
+};
+
+/**
+ * list listen sockets for SIP server
+ */
+static void core_ppdefines_full(rpc_t* rpc, void* c)
+{
+ ksr_ppdefine_t *ppdef;
+ void *vp;
+ int i=0;
+
+ while((ppdef=pp_get_define(i))!=NULL && ppdef->name.s!=NULL) {
+ if (rpc->add(c, "{", &vp) < 0) {
+ rpc->fault(c, 500, "Server Failure");
+ return;
+ }
+ if(ppdef->value.s!=NULL) {
+ rpc->struct_add(vp, "SdS",
+ "name", &ppdef->name,
+ "type", ppdef->dtype,
+ "value", &ppdef->value);
+ } else {
+ rpc->struct_add(vp, "Sds",
+ "name", &ppdef->name,
+ "type", ppdef->dtype,
+ "value", "none");
+ }
+
+ i++;
+ }
+}
+
/*
* RPC Methods exported by core
*/
@@ -1036,6 +1074,7 @@ static rpc_export_t core_rpc_methods[] = {
{"core.sockets_list", core_sockets_list, core_sockets_list_doc, 0},
{"core.modules", core_modules, core_modules_doc,
RET_ARRAY},
{"core.ppdefines", core_ppdefines, core_ppdefines_doc,
RET_ARRAY},
+ {"core.ppdefines_full", core_ppdefines_full, core_ppdefines_doc,
RET_ARRAY},
#ifdef USE_DNS_CACHE
{"dns.mem_info", dns_cache_mem_info, dns_cache_mem_info_doc,
0 },
diff --git a/src/core/ppcfg.h b/src/core/ppcfg.h
index c28258b71f..5524b9fd58 100644
--- a/src/core/ppcfg.h
+++ b/src/core/ppcfg.h
@@ -28,10 +28,11 @@
typedef struct ksr_ppdefine {
str name;
str value;
- int type;
+ int dtype;
} ksr_ppdefine_t;
str* pp_get_define_name(int idx);
+ksr_ppdefine_t* pp_get_define(int idx);
int pp_subst_add(char *data);
int pp_substdef_add(char *data, int mode);