Browse code

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

Daniel-Constantin Mierla authored on 07/07/2018 07:08:18
Showing 3 changed files
... ...
@@ -225,4 +225,56 @@ void pp_ifdef_level_check(void)
225 225
 	}
226 226
 }
227 227
 
228
+/**
229
+ *
230
+ */
231
+void pp_define_core(void)
232
+{
233
+	char defval[64];
234
+	char *p;
235
+	int n;
236
+
237
+	strcpy(defval, NAME);
238
+	p = defval;
239
+	while(*p) {
240
+		*p = (char)toupper(*p);
241
+		p++;
242
+	}
243
+
244
+	n = snprintf(p, 64 - (int)(p-defval), "_%d", VERSIONVAL/1000000);
245
+	if(n<0 || n>=64 - (int)(p-defval)) {
246
+		LM_ERR("faild to build define token\n");
247
+		return;
248
+	}
249
+	pp_define_set_type(0);
250
+	if(pp_define(strlen(defval), defval)<0) {
251
+		LM_ERR("unable to set cfg define: %s\n", defval);
252
+		return;
253
+	}
254
+
255
+	n = snprintf(p, 64 - (int)(p-defval), "_%d_%d", VERSIONVAL/1000000,
256
+			(VERSIONVAL%1000000)/1000);
257
+	if(n<0 || n>=64 - (int)(p-defval)) {
258
+		LM_ERR("faild to build define token\n");
259
+		return;
260
+	}
261
+	pp_define_set_type(0);
262
+	if(pp_define(strlen(defval), defval)<0) {
263
+		LM_ERR("unable to set cfg define: %s\n", defval);
264
+		return;
265
+	}
266
+
267
+	n = snprintf(p, 64 - (int)(p-defval), "_%d_%d_%d", VERSIONVAL/1000000,
268
+			(VERSIONVAL%1000000)/1000, VERSIONVAL%1000);
269
+	if(n<0 || n>=64 - (int)(p-defval)) {
270
+		LM_ERR("faild to build define token\n");
271
+		return;
272
+	}
273
+	pp_define_set_type(0);
274
+	if(pp_define(strlen(defval), defval)<0) {
275
+		LM_ERR("unable to set cfg define: %s\n", defval);
276
+		return;
277
+	}
278
+}
279
+
228 280
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
... ...
@@ -45,6 +45,8 @@ int  pp_define_set_type(int type);
45 45
 void pp_ifdef_level_update(int val);
46 46
 void pp_ifdef_level_check(void);
47 47
 
48
+void pp_define_core(void);
49
+
48 50
 #endif /*_PPCFG_H_*/
49 51
 
50 52
 /* vi: set ts=4 sw=4 tw=79:ai:cindent: */
... ...
@@ -2155,6 +2155,7 @@ try_again:
2155 2155
 	}
2156 2156
 	if (debug_flag) default_core_cfg.debug = debug_save;
2157 2157
 	pp_ifdef_level_check();
2158
+	pp_define_core();
2158 2159
 	print_rls();
2159 2160
 
2160 2161
 	if(init_dst_set()<0) {