[sr-dev] git:master:9a3bb8d2: core: added config defines for application version

Daniel-Constantin Mierla miconda at gmail.com
Mon Jul 9 08:55:35 CEST 2018


Module: kamailio
Branch: master
Commit: 9a3bb8d2141c67ec1147085948ea38103ca6090d
URL: https://github.com/kamailio/kamailio/commit/9a3bb8d2141c67ec1147085948ea38103ca6090d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2018-07-07T09:08:18+02:00

core: added config defines for application version

- three tokens are defined for version X.Y.Z:
    * KAMAILIO_X, KAMAILIO_X_Y, KAMAILIO_X_Y_Z

---

Modified: src/core/ppcfg.c
Modified: src/core/ppcfg.h
Modified: src/main.c

---

Diff:  https://github.com/kamailio/kamailio/commit/9a3bb8d2141c67ec1147085948ea38103ca6090d.diff
Patch: https://github.com/kamailio/kamailio/commit/9a3bb8d2141c67ec1147085948ea38103ca6090d.patch

---

diff --git a/src/core/ppcfg.c b/src/core/ppcfg.c
index f8688988aa..d15e0f899e 100644
--- a/src/core/ppcfg.c
+++ b/src/core/ppcfg.c
@@ -225,4 +225,56 @@ void pp_ifdef_level_check(void)
 	}
 }
 
+/**
+ *
+ */
+void pp_define_core(void)
+{
+	char defval[64];
+	char *p;
+	int n;
+
+	strcpy(defval, NAME);
+	p = defval;
+	while(*p) {
+		*p = (char)toupper(*p);
+		p++;
+	}
+
+	n = snprintf(p, 64 - (int)(p-defval), "_%d", VERSIONVAL/1000000);
+	if(n<0 || n>=64 - (int)(p-defval)) {
+		LM_ERR("faild to build define token\n");
+		return;
+	}
+	pp_define_set_type(0);
+	if(pp_define(strlen(defval), defval)<0) {
+		LM_ERR("unable to set cfg define: %s\n", defval);
+		return;
+	}
+
+	n = snprintf(p, 64 - (int)(p-defval), "_%d_%d", VERSIONVAL/1000000,
+			(VERSIONVAL%1000000)/1000);
+	if(n<0 || n>=64 - (int)(p-defval)) {
+		LM_ERR("faild to build define token\n");
+		return;
+	}
+	pp_define_set_type(0);
+	if(pp_define(strlen(defval), defval)<0) {
+		LM_ERR("unable to set cfg define: %s\n", defval);
+		return;
+	}
+
+	n = snprintf(p, 64 - (int)(p-defval), "_%d_%d_%d", VERSIONVAL/1000000,
+			(VERSIONVAL%1000000)/1000, VERSIONVAL%1000);
+	if(n<0 || n>=64 - (int)(p-defval)) {
+		LM_ERR("faild to build define token\n");
+		return;
+	}
+	pp_define_set_type(0);
+	if(pp_define(strlen(defval), defval)<0) {
+		LM_ERR("unable to set cfg define: %s\n", defval);
+		return;
+	}
+}
+
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/src/core/ppcfg.h b/src/core/ppcfg.h
index 5524b9fd58..432d76bcfb 100644
--- a/src/core/ppcfg.h
+++ b/src/core/ppcfg.h
@@ -45,6 +45,8 @@ int  pp_define_set_type(int type);
 void pp_ifdef_level_update(int val);
 void pp_ifdef_level_check(void);
 
+void pp_define_core(void);
+
 #endif /*_PPCFG_H_*/
 
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
diff --git a/src/main.c b/src/main.c
index 30f659c8c1..846e35970d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2155,6 +2155,7 @@ int main(int argc, char** argv)
 	}
 	if (debug_flag) default_core_cfg.debug = debug_save;
 	pp_ifdef_level_check();
+	pp_define_core();
 	print_rls();
 
 	if(init_dst_set()<0) {




More information about the sr-dev mailing list