Module: sip-router
Branch: master
Commit: 14525efb68380b759347e64441cb90f97c1e3595
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=14525ef…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Tue Mar 26 23:45:50 2013 +0100
core: auto-define cfg directive MOD_modname for each loaded module
- example: if acc module is loaded, MOD_acc is defined in cfg
- suggestion by Olle E. Johansson
---
sr_module.c | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/sr_module.c b/sr_module.c
index 485f975..3cce9fe 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -64,6 +64,7 @@
#include "globals.h"
#include "rpc_lookup.h"
#include "sr_compat.h"
+#include "ppcfg.h"
#include <sys/stat.h>
#include <regex.h>
@@ -271,6 +272,7 @@ static int register_module(unsigned ver, union module_exports_u* e,
{
int ret, i;
struct sr_module* mod;
+ char defmod[64];
ret=-1;
@@ -366,6 +368,20 @@ static int register_module(unsigned ver, union module_exports_u* e,
/* i==0 => success */
}
+ /* add cfg define for each module: MOD_modulename */
+ if(strlen(mod->exports.name)>=60) {
+ LM_ERR("too long module name: %s\n", mod->exports.name);
+ goto error;
+ }
+ strcpy(defmod, "MOD_");
+ strcat(defmod, mod->exports.name);
+ pp_define_set_type(0);
+ if(pp_define(strlen(defmod), defmod)<0) {
+ LM_ERR("unable to set cfg define for module: %s\n",
+ mod->exports.name);
+ goto error;
+ }
+
/* link module in the list */
mod->next=modules;
modules=mod;