Browse code

core: cfg vars - updated log macros

Daniel-Constantin Mierla authored on 26/08/2017 14:29:53
Showing 2 changed files
... ...
@@ -42,16 +42,16 @@ int cfg_register_ctx(cfg_ctx_t **handle, cfg_on_declare on_declare_cb)
42 42
 	str		gname;
43 43
 
44 44
 	/* allocate memory for the new context
45
-	Better to use shm mem, because 'changed' and 'lock'
46
-	must be in shm mem anyway */
45
+	 * Better to use shm mem, because 'changed' and 'lock'
46
+	 * must be in shm mem anyway */
47 47
 	ctx = (cfg_ctx_t *)shm_malloc(sizeof(cfg_ctx_t));
48 48
 	if (!ctx) {
49
-		LOG(L_ERR, "ERROR: cfg_register_ctx(): not enough shm memory\n");
49
+		LM_ERR("not enough shm memory\n");
50 50
 		return -1;
51 51
 	}
52 52
 	memset(ctx, 0, sizeof(cfg_ctx_t));
53 53
 	if (lock_init(&ctx->lock) == 0) {
54
-		LOG(L_ERR, "ERROR: cfg_register_ctx(): failed to init lock\n");
54
+		LM_ERR("failed to init lock\n");
55 55
 		shm_free(ctx);
56 56
 		return -1;
57 57
 	}
... ...
@@ -67,12 +67,12 @@ int cfg_register_ctx(cfg_ctx_t **handle, cfg_on_declare on_declare_cb)
67 67
 	if (on_declare_cb) {
68 68
 		ctx->on_declare_cb = on_declare_cb;
69 69
 
70
-		for (	group = cfg_group;
71
-			group;
72
-			group = group->next
73
-		) {
70
+		for (group = cfg_group;
71
+				group;
72
+				group = group->next
73
+				) {
74 74
 			/* dynamic groups are not ready, the callback
75
-			will be called later when the group is fixed-up */
75
+			 * will be called later when the group is fixed-up */
76 76
 			if (group->dynamic != CFG_GROUP_STATIC) continue;
77 77
 
78 78
 			gname.s = group->name;
... ...
@@ -89,10 +89,10 @@ void cfg_ctx_destroy(void)
89 89
 {
90 90
 	cfg_ctx_t	*ctx, *ctx2;
91 91
 
92
-	for (	ctx = cfg_ctx_list;
93
-		ctx;
94
-		ctx = ctx2
95
-	) {
92
+	for (ctx = cfg_ctx_list;
93
+			ctx;
94
+			ctx = ctx2
95
+			) {
96 96
 		ctx2 = ctx->next;
97 97
 		shm_free(ctx);
98 98
 	}
... ...
@@ -108,10 +108,10 @@ void cfg_notify_drivers(char *group_name, int group_name_len, cfg_def_t *def)
108 108
 	gname.s = group_name;
109 109
 	gname.len = group_name_len;
110 110
 
111
-	for (	ctx = cfg_ctx_list;
112
-		ctx;
113
-		ctx = ctx->next
114
-	)
111
+	for (ctx = cfg_ctx_list;
112
+			ctx;
113
+			ctx = ctx->next
114
+			)
115 115
 		if (ctx->on_declare_cb)
116 116
 			ctx->on_declare_cb(&gname, def);
117 117
 }
... ...
@@ -121,7 +121,7 @@ static char	*temp_string = NULL;
121 121
 
122 122
 /* convert the value to the requested type */
123 123
 int convert_val(unsigned int val_type, void *val,
124
-			unsigned int var_type, void **new_val)
124
+		unsigned int var_type, void **new_val)
125 125
 {
126 126
 	static str	s;
127 127
 	char		*end;
... ...
@@ -130,99 +130,95 @@ int convert_val(unsigned int val_type, void *val,
130 130
 
131 131
 	/* we have to convert from val_type to var_type */
132 132
 	switch (CFG_INPUT_MASK(var_type)) {
133
-	case CFG_INPUT_INT:
134
-		if (val_type == CFG_VAR_INT) {
135
-			*new_val = val;
136
-			break;
133
+		case CFG_INPUT_INT:
134
+			if (val_type == CFG_VAR_INT) {
135
+				*new_val = val;
136
+				break;
137 137
 
138
-		} else if (val_type == CFG_VAR_STRING) {
139
-			if (!val || (((char *)val)[0] == '\0')) {
140
-				LOG(L_ERR, "ERROR: convert_val(): "
141
-					"cannot convert NULL string value to integer\n");
142
-				return -1;
143
-			}
144
-			*new_val = (void *)(long)strtol((char *)val, &end, 10);
145
-			if (*end != '\0') {
146
-				LOG(L_ERR, "ERROR: convert_val(): "
147
-					"cannot convert string to integer '%s'\n",
148
-					(char *)val);
149
-				return -1;
150
-			}
151
-			break;
138
+			} else if (val_type == CFG_VAR_STRING) {
139
+				if (!val || (((char *)val)[0] == '\0')) {
140
+					LM_ERR("cannot convert NULL string value to integer\n");
141
+					return -1;
142
+				}
143
+				*new_val = (void *)(long)strtol((char *)val, &end, 10);
144
+				if (*end != '\0') {
145
+					LM_ERR("cannot convert string to integer '%s'\n",
146
+							(char *)val);
147
+					return -1;
148
+				}
149
+				break;
152 150
 
153
-		} else if (val_type == CFG_VAR_STR) {
154
-			if (!((str *)val)->len || !((str *)val)->s) {
155
-				LOG(L_ERR, "ERROR: convert_val(): "
156
-					"cannot convert NULL str value to integer\n");
157
-				return -1;
158
-			}
159
-			if (str2sint((str *)val, &i)) {
160
-				LOG(L_ERR, "ERROR: convert_val(): "
161
-					"cannot convert string to integer '%.*s'\n",
162
-					((str *)val)->len, ((str *)val)->s);
163
-				return -1;
151
+			} else if (val_type == CFG_VAR_STR) {
152
+				if (!((str *)val)->len || !((str *)val)->s) {
153
+					LM_ERR("cannot convert NULL str value to integer\n");
154
+					return -1;
155
+				}
156
+				if (str2sint((str *)val, &i)) {
157
+					LM_ERR("cannot convert string to integer '%.*s'\n",
158
+							((str *)val)->len, ((str *)val)->s);
159
+					return -1;
160
+				}
161
+				*new_val = (void *)(long)i;
162
+				break;
164 163
 			}
165
-			*new_val = (void *)(long)i;
166
-			break;
167
-		}
168
-		goto error;
164
+			goto error;
169 165
 
170
-	case CFG_INPUT_STRING:
171
-		if (val_type == CFG_VAR_INT) {
172
-			buf[snprintf(buf, sizeof(buf)-1, "%ld", (long)val)] = '\0';
173
-			*new_val = buf;
174
-			break;
166
+		case CFG_INPUT_STRING:
167
+			if (val_type == CFG_VAR_INT) {
168
+				buf[snprintf(buf, sizeof(buf)-1, "%ld", (long)val)] = '\0';
169
+				*new_val = buf;
170
+				break;
175 171
 
176
-		} else if (val_type == CFG_VAR_STRING) {
177
-			*new_val = val;
178
-			break;
172
+			} else if (val_type == CFG_VAR_STRING) {
173
+				*new_val = val;
174
+				break;
179 175
 
180
-		} else if (val_type == CFG_VAR_STR) {
181
-			if (!((str *)val)->s) {
182
-				*new_val = NULL;
176
+			} else if (val_type == CFG_VAR_STR) {
177
+				if (!((str *)val)->s) {
178
+					*new_val = NULL;
179
+					break;
180
+				}
181
+				/* the value may not be zero-terminated, thus,
182
+				 * a new variable has to be allocated with larger memory space */
183
+				if (temp_string) pkg_free(temp_string);
184
+				temp_string = (char *)pkg_malloc(sizeof(char) * (((str *)val)->len + 1));
185
+				if (!temp_string) {
186
+					LM_ERR("not enough memory\n");
187
+					return -1;
188
+				}
189
+				memcpy(temp_string, ((str *)val)->s, ((str *)val)->len);
190
+				temp_string[((str *)val)->len] = '\0';
191
+				*new_val = (void *)temp_string;
183 192
 				break;
184
-			}
185
-			/* the value may not be zero-terminated, thus,
186
-			a new variable has to be allocated with larger memory space */
187
-			if (temp_string) pkg_free(temp_string);
188
-			temp_string = (char *)pkg_malloc(sizeof(char) * (((str *)val)->len + 1));
189
-			if (!temp_string) {
190
-				LOG(L_ERR, "ERROR: convert_val(): not enough memory\n");
191
-				return -1;
192
-			}
193
-			memcpy(temp_string, ((str *)val)->s, ((str *)val)->len);
194
-			temp_string[((str *)val)->len] = '\0';
195
-			*new_val = (void *)temp_string;
196
-			break;
197 193
 
198
-		}
199
-		goto error;
194
+			}
195
+			goto error;
200 196
 
201
-	case CFG_INPUT_STR:
202
-		if (val_type == CFG_VAR_INT) {
203
-			s.len = snprintf(buf, sizeof(buf)-1, "%ld", (long)val);
204
-			buf[s.len] = '\0';
205
-			s.s = buf;
206
-			*new_val = (void *)&s;
207
-			break;
197
+		case CFG_INPUT_STR:
198
+			if (val_type == CFG_VAR_INT) {
199
+				s.len = snprintf(buf, sizeof(buf)-1, "%ld", (long)val);
200
+				buf[s.len] = '\0';
201
+				s.s = buf;
202
+				*new_val = (void *)&s;
203
+				break;
208 204
 
209
-		} else if (val_type == CFG_VAR_STRING) {
210
-			s.s = (char *)val;
211
-			s.len = (s.s) ? strlen(s.s) : 0;
212
-			*new_val = (void *)&s;
213
-			break;
205
+			} else if (val_type == CFG_VAR_STRING) {
206
+				s.s = (char *)val;
207
+				s.len = (s.s) ? strlen(s.s) : 0;
208
+				*new_val = (void *)&s;
209
+				break;
214 210
 
215
-		} else if (val_type == CFG_VAR_STR) {
216
-			*new_val = val;
217
-			break;			
218
-		}
219
-		goto error;
211
+			} else if (val_type == CFG_VAR_STR) {
212
+				*new_val = val;
213
+				break;
214
+			}
215
+			goto error;
220 216
 	}
221 217
 
222 218
 	return 0;
223 219
 
224 220
 error:
225
-	LOG(L_ERR, "ERROR: convert_val(): got a value with type %u, but expected %u\n",
221
+	LM_ERR("got a value with type %u, but expected %u\n",
226 222
 			val_type, CFG_INPUT_MASK(var_type));
227 223
 	return -1;
228 224
 }
... ...
@@ -240,22 +236,21 @@ static int cfg_var_size(cfg_mapping_t *var)
240 236
 {
241 237
 	switch (CFG_VAR_TYPE(var)) {
242 238
 
243
-	case CFG_VAR_INT:
244
-		return sizeof(int);
239
+		case CFG_VAR_INT:
240
+			return sizeof(int);
245 241
 
246
-	case CFG_VAR_STRING:
247
-		return sizeof(char *);
242
+		case CFG_VAR_STRING:
243
+			return sizeof(char *);
248 244
 
249
-	case CFG_VAR_STR:
250
-		return sizeof(str);
245
+		case CFG_VAR_STR:
246
+			return sizeof(str);
251 247
 
252
-	case CFG_VAR_POINTER:
253
-		return sizeof(void *);
248
+		case CFG_VAR_POINTER:
249
+			return sizeof(void *);
254 250
 
255
-	default:
256
-		LOG(L_CRIT, "BUG: cfg_var_size(): unknown type: %u\n",
257
-			CFG_VAR_TYPE(var));
258
-		return 0;
251
+		default:
252
+			LM_CRIT("unknown type: %u\n", CFG_VAR_TYPE(var));
253
+			return 0;
259 254
 	}
260 255
 }
261 256
 
... ...
@@ -264,8 +259,8 @@ static int cfg_var_size(cfg_mapping_t *var)
264 259
  * The array is cloned before a change if clone is set to 1.
265 260
  */
266 261
 static int cfg_update_defaults(cfg_group_meta_t	*meta,
267
-				cfg_group_t *group, cfg_mapping_t *var, char *new_val,
268
-				int clone)
262
+		cfg_group_t *group, cfg_mapping_t *var, char *new_val,
263
+		int clone)
269 264
 {
270 265
 	int	i, clone_done=0;
271 266
 	cfg_group_inst_t *array, *ginst;
... ...
@@ -274,7 +269,7 @@ static int cfg_update_defaults(cfg_group_meta_t	*meta,
274 269
 		return 0;
275 270
 	for (i = 0; i < meta->num; i++) {
276 271
 		ginst = (cfg_group_inst_t *)((char *)array
277
-			+ (sizeof(cfg_group_inst_t) + group->size - 1) * i);
272
+				+ (sizeof(cfg_group_inst_t) + group->size - 1) * i);
278 273
 
279 274
 		if (!CFG_VAR_TEST(ginst, var)) {
280 275
 			/* The variable uses the default value, it needs to be rewritten. */
... ...
@@ -283,13 +278,13 @@ static int cfg_update_defaults(cfg_group_meta_t	*meta,
283 278
 				if (!(array = cfg_clone_array(meta, group)))
284 279
 					return -1;
285 280
 				ginst = (cfg_group_inst_t *)translate_pointer((char *)array,
286
-								(char *)meta->array,
287
-								(char *)ginst);
281
+						(char *)meta->array,
282
+						(char *)ginst);
288 283
 				/* re-link the array to the meta-data */
289 284
 				meta->array = array;
290 285
 				clone_done = 1;
291 286
 			}
292
-			memcpy(ginst->vars + var->offset, new_val, cfg_var_size(var)); 
287
+			memcpy(ginst->vars + var->offset, new_val, cfg_var_size(var));
293 288
 		}
294 289
 	}
295 290
 	return 0;
... ...
@@ -303,7 +298,7 @@ static int cfg_update_defaults(cfg_group_meta_t	*meta,
303 298
  *   1: variable has not been found
304 299
  */
305 300
 int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
306
-			void *val, unsigned int val_type)
301
+		void *val, unsigned int val_type)
307 302
 {
308 303
 	int		i;
309 304
 	cfg_group_t	*group;
... ...
@@ -318,23 +313,23 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
318 313
 	unsigned char		*var_block;
319 314
 
320 315
 	/* verify the context even if we do not need it now
321
-	to make sure that a cfg driver has called the function
322
-	(very very weak security) */
316
+	 * to make sure that a cfg driver has called the function
317
+	 * (very very weak security) */
323 318
 	if (!ctx) {
324
-		LOG(L_ERR, "ERROR: cfg_set_now(): context is undefined\n");
319
+		LM_ERR("context is undefined\n");
325 320
 		return -1;
326 321
 	}
327 322
 
328 323
 	if ((val_type == CFG_VAR_UNSET) && !group_id) {
329
-		LOG(L_ERR, "ERROR: cfg_set_now(): Only group instance values can be deleted\n");
324
+		LM_ERR("Only group instance values can be deleted\n");
330 325
 		return -1;
331 326
 	}
332 327
 
333 328
 	if (group_id && !cfg_shmized) {
334
-		/* The config group has not been shmized yet,
335
-		but an additional instance of a variable needs to be added to the group.
336
-		Add this instance to the linked list of variables, they
337
-		will be fixed later. */
329
+		/* The config group has not been shmized yet, but
330
+		 * an additional instance of a variable needs to be added to the group.
331
+		 * Add this instance to the linked list of variables, they
332
+		 * will be fixed later. */
338 333
 		return new_add_var(group_name, *group_id, var_name,
339 334
 				val, val_type);
340 335
 	}
... ...
@@ -345,16 +340,15 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
345 340
 			/* The group may be dynamic which is not yet ready
346 341
 			 * before forking */
347 342
 			if ((group = cfg_lookup_group(group_name->s, group_name->len))
348
-				&& (group->dynamic == CFG_GROUP_DYNAMIC)
349
-			)
343
+					&& (group->dynamic == CFG_GROUP_DYNAMIC))
350 344
 				return cfg_set_script_var(group, var_name, val, val_type);
351 345
 		}
352 346
 		return 1;
353 347
 	}
354
-		
348
+
355 349
 	/* check whether the variable is read-only */
356 350
 	if (var->def->type & CFG_READONLY) {
357
-		LOG(L_ERR, "ERROR: cfg_set_now(): variable is read-only\n");
351
+		LM_ERR("variable is read-only\n");
358 352
 		goto error0;
359 353
 	}
360 354
 
... ...
@@ -364,59 +358,56 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
364 358
 	 * as opposed to per-process variables. Hence, it is not possible to set
365 359
 	 * the group handle temporary to another block, and then reset it back later. */
366 360
 	if (group_id
367
-		&& var->def->on_set_child_cb
368
-		&& var->def->type & CFG_CB_ONLY_ONCE
369
-	) {
370
-		LOG(L_ERR, "ERROR: cfg_set_now(): This variable does not support muliple values.\n");
361
+			&& var->def->on_set_child_cb
362
+			&& var->def->type & CFG_CB_ONLY_ONCE ) {
363
+		LM_ERR("This variable does not support muliple values.\n");
371 364
 		goto error0;
372 365
 	}
373 366
 
374 367
 	/* check whether we have to convert the type */
375 368
 	if ((val_type != CFG_VAR_UNSET)
376
-		&& convert_val(val_type, val, CFG_INPUT_TYPE(var), &v)
377
-	)
369
+			&& convert_val(val_type, val, CFG_INPUT_TYPE(var), &v))
378 370
 		goto error0;
379
-	
371
+
380 372
 	if ((val_type != CFG_VAR_UNSET)
381
-	&& (CFG_INPUT_TYPE(var) == CFG_INPUT_INT) 
382
-	&& (var->def->min || var->def->max)) {
373
+			&& (CFG_INPUT_TYPE(var) == CFG_INPUT_INT)
374
+			&& (var->def->min || var->def->max)) {
383 375
 		/* perform a simple min-max check for integers */
384 376
 		if (((int)(long)v < var->def->min)
385
-		|| ((int)(long)v > var->def->max)) {
386
-			LOG(L_ERR, "ERROR: cfg_set_now(): integer value is out of range\n");
377
+				|| ((int)(long)v > var->def->max)) {
378
+			LM_ERR("integer value is out of range\n");
387 379
 			goto error0;
388 380
 		}
389 381
 	}
390 382
 
391 383
 	if ((val_type != CFG_VAR_UNSET)
392
-		&& var->def->on_change_cb
393
-	) {
384
+			&& var->def->on_change_cb) {
394 385
 		/* Call the fixup function.
395
-		There is no need to set a temporary cfg handle,
396
-		becaue a single variable is changed */
386
+		 * There is no need to set a temporary cfg handle,
387
+		 * becaue a single variable is changed */
397 388
 		if (!group_id) {
398 389
 			var_block = *(group->handle);
399 390
 		} else {
400 391
 			if (!cfg_local) {
401
-				LOG(L_ERR, "ERROR: cfg_set_now(): Local configuration is missing\n");
392
+				LM_ERR("Local configuration is missing\n");
402 393
 				goto error0;
403 394
 			}
404 395
 			group_inst = cfg_find_group(CFG_GROUP_META(cfg_local, group),
405
-							group->size,
406
-							*group_id);
396
+					group->size,
397
+					*group_id);
407 398
 			if (!group_inst) {
408
-				LOG(L_ERR, "ERROR: cfg_set_now(): local group instance %.*s[%u] is not found\n",
409
-					group_name->len, group_name->s, *group_id);
399
+				LM_ERR("local group instance %.*s[%u] is not found\n",
400
+						group_name->len, group_name->s, *group_id);
410 401
 				goto error0;
411 402
 			}
412 403
 			var_block = group_inst->vars;
413 404
 		}
414 405
 
415 406
 		if (var->def->on_change_cb(var_block,
416
-						group_name,
417
-						var_name,
418
-						&v) < 0) {
419
-			LOG(L_ERR, "ERROR: cfg_set_now(): fixup failed\n");
407
+					group_name,
408
+					var_name,
409
+					&v) < 0) {
410
+			LM_ERR("fixup failed\n");
420 411
 			goto error0;
421 412
 		}
422 413
 
... ...
@@ -427,38 +418,38 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
427 418
 	 * switched to that instance. */
428 419
 	if (!group_id && var->def->on_set_child_cb) {
429 420
 		/* get the name of the variable from the internal struct,
430
-		because var_name may be freed before the callback needs it */
421
+		 * because var_name may be freed before the callback needs it */
431 422
 		s.s = group->name;
432 423
 		s.len = group->name_len;
433 424
 		s2.s = var->def->name;
434 425
 		s2.len = var->name_len;
435 426
 		child_cb = cfg_child_cb_new(&s, &s2,
436
-					var->def->on_set_child_cb,
437
-					var->def->type);
427
+				var->def->on_set_child_cb,
428
+				var->def->type);
438 429
 		if (!child_cb) {
439
-			LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");
430
+			LM_ERR("not enough shm memory\n");
440 431
 			goto error0;
441 432
 		}
442 433
 	}
443 434
 
444 435
 	if (cfg_shmized) {
445 436
 		/* make sure that nobody else replaces the global config
446
-		while the new one is prepared */
437
+		 * while the new one is prepared */
447 438
 		CFG_WRITER_LOCK();
448 439
 
449 440
 		if (group_id) {
450 441
 			group_inst = cfg_find_group(CFG_GROUP_META(*cfg_global, group),
451
-							group->size,
452
-							*group_id);
442
+					group->size,
443
+					*group_id);
453 444
 			if (!group_inst) {
454
-				LOG(L_ERR, "ERROR: cfg_set_now(): global group instance %.*s[%u] is not found\n",
455
-					group_name->len, group_name->s, *group_id);
445
+				LM_ERR("global group instance %.*s[%u] is not found\n",
446
+						group_name->len, group_name->s, *group_id);
456 447
 				goto error;
457 448
 			}
458 449
 			if ((val_type == CFG_VAR_UNSET) && !CFG_VAR_TEST(group_inst, var)) {
459 450
 				/* nothing to do, the variable is not set in the group instance */
460 451
 				CFG_WRITER_UNLOCK();
461
-				LOG(L_DBG, "DEBUG: cfg_set_now(): The variable is not set\n");
452
+				LM_DBG("The variable is not set\n");
462 453
 				return 0;
463 454
 			}
464 455
 			var_block = group_inst->vars;
... ...
@@ -469,7 +460,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
469 460
 
470 461
 		if (var->def->type & CFG_ATOMIC) {
471 462
 			/* atomic change is allowed, we can rewrite the value
472
-			directly in the global config */
463
+			 * directly in the global config */
473 464
 			p = var_block + var->offset;
474 465
 
475 466
 		} else {
... ...
@@ -483,8 +474,8 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
483 474
 				if (!(new_array = cfg_clone_array(CFG_GROUP_META(*cfg_global, group), group)))
484 475
 					goto error;
485 476
 				group_inst = (cfg_group_inst_t *)translate_pointer((char *)new_array,
486
-					(char *)CFG_GROUP_META(*cfg_global, group)->array,
487
-					(char *)group_inst);
477
+						(char *)CFG_GROUP_META(*cfg_global, group)->array,
478
+						(char *)group_inst);
488 479
 				var_block = group_inst->vars;
489 480
 				CFG_GROUP_META(block, group)->array = new_array;
490 481
 			} else {
... ...
@@ -500,49 +491,49 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
500 491
 		}
501 492
 	} else {
502 493
 		/* we are allowed to rewrite the value on-the-fly
503
-		The handle either points to group->vars, or to the
504
-		shared memory block (dynamic group) */
494
+		 * The handle either points to group->vars, or to the
495
+		 * shared memory block (dynamic group) */
505 496
 		p = *(group->handle) + var->offset;
506 497
 	}
507 498
 
508 499
 	if (val_type != CFG_VAR_UNSET) {
509 500
 		/* set the new value */
510 501
 		switch (CFG_VAR_TYPE(var)) {
511
-		case CFG_VAR_INT:
512
-			*(int *)p = (int)(long)v;
513
-			break;
502
+			case CFG_VAR_INT:
503
+				*(int *)p = (int)(long)v;
504
+				break;
514 505
 
515
-		case CFG_VAR_STRING:
516
-			/* clone the string to shm mem */
517
-			s.s = v;
518
-			s.len = (s.s) ? strlen(s.s) : 0;
519
-			if (cfg_clone_str(&s, &s)) goto error;
520
-			old_string = *(char **)p;
521
-			*(char **)p = s.s;
522
-			break;
506
+			case CFG_VAR_STRING:
507
+				/* clone the string to shm mem */
508
+				s.s = v;
509
+				s.len = (s.s) ? strlen(s.s) : 0;
510
+				if (cfg_clone_str(&s, &s)) goto error;
511
+				old_string = *(char **)p;
512
+				*(char **)p = s.s;
513
+				break;
523 514
 
524
-		case CFG_VAR_STR:
525
-			/* clone the string to shm mem */
526
-			s = *(str *)v;
527
-			if (cfg_clone_str(&s, &s)) goto error;
528
-			old_string = *(char **)p;
529
-			memcpy(p, &s, sizeof(str));
530
-			break;
515
+			case CFG_VAR_STR:
516
+				/* clone the string to shm mem */
517
+				s = *(str *)v;
518
+				if (cfg_clone_str(&s, &s)) goto error;
519
+				old_string = *(char **)p;
520
+				memcpy(p, &s, sizeof(str));
521
+				break;
531 522
 
532
-		case CFG_VAR_POINTER:
533
-			*(void **)p = v;
534
-			break;
523
+			case CFG_VAR_POINTER:
524
+				*(void **)p = v;
525
+				break;
535 526
 
536 527
 		}
537 528
 		if (group_inst && !CFG_VAR_TEST_AND_SET(group_inst, var))
538 529
 			old_string = NULL; /* the string is the same as the default one,
539
-						it cannot be freed */
530
+								* it cannot be freed */
540 531
 	} else {
541 532
 		/* copy the default value to the group instance */
542 533
 		if ((CFG_VAR_TYPE(var) == CFG_VAR_STRING)
543
-		|| (CFG_VAR_TYPE(var) == CFG_VAR_STR))
534
+				|| (CFG_VAR_TYPE(var) == CFG_VAR_STR))
544 535
 			old_string = *(char **)p;
545
-		memcpy(p, CFG_GROUP_DATA(*cfg_global, group) + var->offset, cfg_var_size(var)); 
536
+		memcpy(p, CFG_GROUP_DATA(*cfg_global, group) + var->offset, cfg_var_size(var));
546 537
 
547 538
 		CFG_VAR_TEST_AND_RESET(group_inst, var);
548 539
 	}
... ...
@@ -550,11 +541,11 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
550 541
 	if (cfg_shmized) {
551 542
 		if (!group_inst) {
552 543
 			/* the default value is changed, the copies of this value
553
-			need to be also updated */
544
+			 * need to be also updated */
554 545
 			if (cfg_update_defaults(CFG_GROUP_META(block ? block : *cfg_global, group),
555 546
 						group, var, p,
556 547
 						block ? 1 : 0) /* clone if needed */
557
-			)
548
+					)
558 549
 				goto error;
559 550
 			if (block && (CFG_GROUP_META(block, group)->array != CFG_GROUP_META(*cfg_global, group)->array))
560 551
 				new_array = CFG_GROUP_META(block, group)->array;
... ...
@@ -562,12 +553,12 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
562 553
 
563 554
 		if (old_string || new_array) {
564 555
 			/* prepare the array of the replaced strings,
565
-			and replaced group instances,
566
-			they will be freed when the old block is freed */
556
+			 * and replaced group instances,
557
+			 * they will be freed when the old block is freed */
567 558
 			replaced = (void **)shm_malloc(sizeof(void *)
568 559
 					* ((old_string?1:0) + (new_array?1:0) + 1));
569 560
 			if (!replaced) {
570
-				LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");
561
+				LM_ERR("not enough shm memory\n");
571 562
 				goto error;
572 563
 			}
573 564
 			i = 0;
... ...
@@ -575,7 +566,7 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
575 566
 				replaced[i] = old_string;
576 567
 				i++;
577 568
 			}
578
-			if (new_array) {	
569
+			if (new_array) {
579 570
 				replaced[i] = CFG_GROUP_META(*cfg_global, group)->array;
580 571
 				i++;
581 572
 			}
... ...
@@ -590,52 +581,46 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
590 581
 			shm_free(old_string);
591 582
 
592 583
 		/* flag the variable because there is no need
593
-		to shmize it again */
584
+		 * to shmize it again */
594 585
 		var->flag |= cfg_var_shmized;
595 586
 
596 587
 		/* the global config does not have to be replaced,
597
-		but the child callback has to be installed, otherwise the
598
-		child processes will miss the change */
588
+		 * but the child callback has to be installed, otherwise the
589
+		 * child processes will miss the change */
599 590
 		if (child_cb)
600 591
 			cfg_install_child_cb(child_cb, child_cb);
601 592
 	}
602 593
 
603 594
 	if (val_type == CFG_VAR_INT)
604
-		LOG(L_INFO, "INFO: cfg_set_now(): %.*s.%.*s "
605
-			"has been changed to %d\n",
606
-			group_name->len, group_name->s,
607
-			var_name->len, var_name->s,
608
-			(int)(long)val);
595
+		LM_INFO("%.*s.%.*s has been changed to %d\n",
596
+				group_name->len, group_name->s,
597
+				var_name->len, var_name->s,
598
+				(int)(long)val);
609 599
 
610 600
 	else if (val_type == CFG_VAR_STRING)
611
-		LOG(L_INFO, "INFO: cfg_set_now(): %.*s.%.*s "
612
-			"has been changed to \"%s\"\n",
613
-			group_name->len, group_name->s,
614
-			var_name->len, var_name->s,
615
-			(char *)val);
601
+		LM_INFO("%.*s.%.*s has been changed to \"%s\"\n",
602
+				group_name->len, group_name->s,
603
+				var_name->len, var_name->s,
604
+				(char *)val);
616 605
 
617 606
 	else if (val_type == CFG_VAR_STR)
618
-		LOG(L_INFO, "INFO: cfg_set_now(): %.*s.%.*s "
619
-			"has been changed to \"%.*s\"\n",
620
-			group_name->len, group_name->s,
621
-			var_name->len, var_name->s,
622
-			((str *)val)->len, ((str *)val)->s);
607
+		LM_INFO("%.*s.%.*s has been changed to \"%.*s\"\n",
608
+				group_name->len, group_name->s,
609
+				var_name->len, var_name->s,
610
+				((str *)val)->len, ((str *)val)->s);
623 611
 
624 612
 	else if (val_type == CFG_VAR_UNSET)
625
-		LOG(L_INFO, "INFO: cfg_set_now(): %.*s.%.*s "
626
-			"has been deleted\n",
627
-			group_name->len, group_name->s,
628
-			var_name->len, var_name->s);
613
+		LM_INFO("%.*s.%.*s has been deleted\n",
614
+				group_name->len, group_name->s,
615
+				var_name->len, var_name->s);
629 616
 
630 617
 	else
631
-		LOG(L_INFO, "INFO: cfg_set_now(): %.*s.%.*s "
632
-			"has been changed\n",
633
-			group_name->len, group_name->s,
634
-			var_name->len, var_name->s);
618
+		LM_INFO("%.*s.%.*s has been changed\n",
619
+				group_name->len, group_name->s,
620
+				var_name->len, var_name->s);
635 621
 
636 622
 	if (group_id)
637
-		LOG(L_INFO, "INFO: cfg_set_now(): group id = %u\n",
638
-			*group_id);
623
+		LM_INFO("group id = %u\n", *group_id);
639 624
 
640 625
 	convert_val_cleanup();
641 626
 	return 0;
... ...
@@ -648,7 +633,7 @@ error:
648 633
 	if (replaced) shm_free(replaced);
649 634
 
650 635
 error0:
651
-	LOG(L_ERR, "ERROR: cfg_set_now(): failed to set the variable: %.*s.%.*s\n",
636
+	LM_ERR("failed to set the variable: %.*s.%.*s\n",
652 637
 			group_name->len, group_name->s,
653 638
 			var_name->len, var_name->s);
654 639
 
... ...
@@ -658,35 +643,36 @@ error0:
658 643
 }
659 644
 
660 645
 /* wrapper function for cfg_set_now */
661
-int cfg_set_now_int(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
662
-			int val)
646
+int cfg_set_now_int(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
647
+		str *var_name, int val)
663 648
 {
664 649
 	return cfg_set_now(ctx, group_name, group_id, var_name,
665
-				(void *)(long)val, CFG_VAR_INT);
650
+			(void *)(long)val, CFG_VAR_INT);
666 651
 }
667 652
 
668 653
 /* wrapper function for cfg_set_now */
669
-int cfg_set_now_string(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
670
-			char *val)
654
+int cfg_set_now_string(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
655
+		str *var_name, char *val)
671 656
 {
672 657
 	return cfg_set_now(ctx, group_name, group_id, var_name,
673
-				(void *)val, CFG_VAR_STRING);
658
+			(void *)val, CFG_VAR_STRING);
674 659
 }
675 660
 
676 661
 /* wrapper function for cfg_set_now */
677
-int cfg_set_now_str(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
678
-			str *val)
662
+int cfg_set_now_str(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
663
+		str *var_name, str *val)
679 664
 {
680 665
 	return cfg_set_now(ctx, group_name, group_id, var_name,
681
-				(void *)val, CFG_VAR_STR);
666
+			(void *)val, CFG_VAR_STR);
682 667
 }
683 668
 
684 669
 /* Delete a variable from the group instance.
685 670
  * wrapper function for cfg_set_now */
686
-int cfg_del_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name)
671
+int cfg_del_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
672
+		str *var_name)
687 673
 {
688 674
 	return cfg_set_now(ctx, group_name, group_id, var_name,
689
-				NULL, CFG_VAR_UNSET);
675
+			NULL, CFG_VAR_UNSET);
690 676
 }
691 677
 
692 678
 /* sets the value of a variable but does not commit the change
... ...
@@ -696,8 +682,8 @@ int cfg_del_now(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *va
696 682
  *  -1: error
697 683
  *   1: variable has not been found
698 684
  */
699
-int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
700
-			void *val, unsigned int val_type)
685
+int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
686
+		str *var_name, void *val, unsigned int val_type)
701 687
 {
702 688
 	cfg_group_t	*group;
703 689
 	cfg_mapping_t	*var;
... ...
@@ -712,17 +698,17 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
712 698
 
713 699
 	if (!cfg_shmized)
714 700
 		/* the cfg has not been shmized yet, there is no
715
-		point in registering the change and committing it later */
701
+		 * point in registering the change and committing it later */
716 702
 		return cfg_set_now(ctx, group_name, group_id, var_name,
717
-					val, val_type);
703
+				val, val_type);
718 704
 
719 705
 	if (!ctx) {
720
-		LOG(L_ERR, "ERROR: cfg_set_delayed(): context is undefined\n");
706
+		LM_ERR("context is undefined\n");
721 707
 		return -1;
722 708
 	}
723 709
 
724 710
 	if ((val_type == CFG_VAR_UNSET) && !group_id) {
725
-		LOG(L_ERR, "ERROR: cfg_set_delayed(): Only group instance values can be deleted\n");
711
+		LM_ERR("Only group instance values can be deleted\n");
726 712
 		return -1;
727 713
 	}
728 714
 
... ...
@@ -732,7 +718,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
732 718
 
733 719
 	/* check whether the variable is read-only */
734 720
 	if (var->def->type & CFG_READONLY) {
735
-		LOG(L_ERR, "ERROR: cfg_set_delayed(): variable is read-only\n");
721
+		LM_ERR("variable is read-only\n");
736 722
 		goto error0;
737 723
 	}
738 724
 
... ...
@@ -742,54 +728,52 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
742 728
 	 * as opposed to per-process variables. Hence, it is not possible to set
743 729
 	 * the group handle temporary to another block, and then reset it back later. */
744 730
 	if (group_id
745
-		&& var->def->on_set_child_cb
746
-		&& var->def->type & CFG_CB_ONLY_ONCE
747
-	) {
748
-		LOG(L_ERR, "ERROR: cfg_set_delayed(): This variable does not support muliple values.\n");
731
+			&& var->def->on_set_child_cb
732
+			&& var->def->type & CFG_CB_ONLY_ONCE) {
733
+		LM_ERR("This variable does not support muliple values.\n");
749 734
 		goto error0;
750 735
 	}
751 736
 
752 737
 	/* check whether we have to convert the type */
753 738
 	if ((val_type != CFG_VAR_UNSET)
754
-		&& convert_val(val_type, val, CFG_INPUT_TYPE(var), &v)
755
-	)
739
+			&& convert_val(val_type, val, CFG_INPUT_TYPE(var), &v))
756 740
 		goto error0;
757 741
 
758 742
 	if ((val_type != CFG_VAR_UNSET)
759
-	&& (CFG_INPUT_TYPE(var) == CFG_INPUT_INT) 
760
-	&& (var->def->min || var->def->max)) {
743
+			&& (CFG_INPUT_TYPE(var) == CFG_INPUT_INT)
744
+			&& (var->def->min || var->def->max)) {
761 745
 		/* perform a simple min-max check for integers */
762 746
 		if (((int)(long)v < var->def->min)
763
-		|| ((int)(long)v > var->def->max)) {
764
-			LOG(L_ERR, "ERROR: cfg_set_delayed(): integer value is out of range\n");
747
+				|| ((int)(long)v > var->def->max)) {
748
+			LM_ERR("integer value is out of range\n");
765 749
 			goto error0;
766 750
 		}
767 751
 	}
768 752
 
769 753
 	/* the ctx must be locked while reading and writing
770
-	the list of changed variables */
754
+	 * the list of changed variables */
771 755
 	CFG_CTX_LOCK(ctx);
772 756
 
773 757
 	if ((val_type != CFG_VAR_UNSET) && var->def->on_change_cb) {
774 758
 		/* The fixup function must see also the
775
-		not yet committed values, so a temporary handle
776
-		must be prepared that points to the new config.
777
-		Only the values within the group are applied,
778
-		other modifications are not visible to the callback.
779
-		The local config is the base. */
759
+		 * not yet committed values, so a temporary handle
760
+		 * must be prepared that points to the new config.
761
+		 * Only the values within the group are applied,
762
+		 * other modifications are not visible to the callback.
763
+		 * The local config is the base. */
780 764
 		if (!group_id) {
781 765
 			var_block = *(group->handle);
782 766
 		} else {
783 767
 			if (!cfg_local) {
784
-				LOG(L_ERR, "ERROR: cfg_set_delayed(): Local configuration is missing\n");
768
+				LM_ERR("Local configuration is missing\n");
785 769
 				goto error;
786 770
 			}
787 771
 			group_inst = cfg_find_group(CFG_GROUP_META(cfg_local, group),
788
-							group->size,
789
-							*group_id);
772
+					group->size,
773
+					*group_id);
790 774
 			if (!group_inst) {
791
-				LOG(L_ERR, "ERROR: cfg_set_delayed(): local group instance %.*s[%u] is not found\n",
792
-					group_name->len, group_name->s, *group_id);
775
+				LM_ERR("local group instance %.*s[%u] is not found\n",
776
+						group_name->len, group_name->s, *group_id);
793 777
 				goto error;
794 778
 			}
795 779
 			var_block = group_inst->vars;
... ...
@@ -798,8 +782,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
798 782
 		if (ctx->changed_first) {
799 783
 			temp_handle = (unsigned char *)pkg_malloc(group->size);
800 784
 			if (!temp_handle) {
801
-				LOG(L_ERR, "ERROR: cfg_set_delayed(): "
802
-					"not enough memory\n");
785
+				LM_ERR("not enough memory\n");
803 786
 				goto error;
804 787
 			}
805 788
 			temp_handle_created = 1;
... ...
@@ -807,34 +790,34 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
807 790
 
808 791
 			/* apply the changes */
809 792
 			for (	changed = ctx->changed_first;
810
-				changed;
811
-				changed = changed->next
812
-			) {
793
+					changed;
794
+					changed = changed->next
795
+				) {
813 796
 				if (changed->group != group)
814 797
 					continue;
815 798
 				if ((!group_id && !changed->group_id_set) /* default values */
816
-					|| (group_id && !changed->group_id_set
817
-						&& !CFG_VAR_TEST(group_inst, changed->var))
818
-							/* default value is changed which affects the group_instance */
819
-					|| (group_id && changed->group_id_set
820
-						&& (*group_id == changed->group_id))
821
-							/* change within the group instance */
822
-				)
799
+						|| (group_id && !changed->group_id_set
800
+							&& !CFG_VAR_TEST(group_inst, changed->var))
801
+						/* default value is changed which affects the group_instance */
802
+						|| (group_id && changed->group_id_set
803
+							&& (*group_id == changed->group_id))
804
+						/* change within the group instance */
805
+						)
823 806
 					memcpy(	temp_handle + changed->var->offset,
824
-						changed->new_val.vraw,
825
-						cfg_var_size(changed->var));
807
+							changed->new_val.vraw,
808
+							cfg_var_size(changed->var));
826 809
 			}
827 810
 		} else {
828 811
 			/* there is not any change */
829 812
 			temp_handle = var_block;
830 813
 			temp_handle_created = 0;
831 814
 		}
832
-			
815
+
833 816
 		if (var->def->on_change_cb(temp_handle,
834
-						group_name,
835
-						var_name,
836
-						&v) < 0) {
837
-			LOG(L_ERR, "ERROR: cfg_set_delayed(): fixup failed\n");
817
+					group_name,
818
+					var_name,
819
+					&v) < 0) {
820
+			LM_ERR("fixup failed\n");
838 821
 			if (temp_handle_created) pkg_free(temp_handle);
839 822
 			goto error;
840 823
 		}
... ...
@@ -848,7 +831,7 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
848 831
 		+ ((val_type != CFG_VAR_UNSET) ? cfg_var_size(var) : 0);
849 832
 	changed = (cfg_changed_var_t *)shm_malloc(size);
850 833
 	if (!changed) {
851
-		LOG(L_ERR, "ERROR: cfg_set_delayed(): not enough shm memory\n");
834
+		LM_ERR("not enough shm memory\n");
852 835
 		goto error;
853 836
 	}
854 837
 	memset(changed, 0, size);
... ...
@@ -862,28 +845,28 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
862 845
 	if (val_type != CFG_VAR_UNSET) {
863 846
 		switch (CFG_VAR_TYPE(var)) {
864 847
 
865
-		case CFG_VAR_INT:
866
-			changed->new_val.vint = (int)(long)v;
867
-			break;
848
+			case CFG_VAR_INT:
849
+				changed->new_val.vint = (int)(long)v;
850
+				break;
868 851
 
869
-		case CFG_VAR_STRING:
870
-			/* clone the string to shm mem */
871
-			s.s = v;
872
-			s.len = (s.s) ? strlen(s.s) : 0;
873
-			if (cfg_clone_str(&s, &s)) goto error;
874
-			changed->new_val.vp = s.s;
875
-			break;
852
+			case CFG_VAR_STRING:
853
+				/* clone the string to shm mem */
854
+				s.s = v;
855
+				s.len = (s.s) ? strlen(s.s) : 0;
856
+				if (cfg_clone_str(&s, &s)) goto error;
857
+				changed->new_val.vp = s.s;
858
+				break;
876 859
 
877
-		case CFG_VAR_STR:
878
-			/* clone the string to shm mem */
879
-			s = *(str *)v;
880
-			if (cfg_clone_str(&s, &s)) goto error;
881
-			changed->new_val.vstr=s;
882
-			break;
860
+			case CFG_VAR_STR:
861
+				/* clone the string to shm mem */
862
+				s = *(str *)v;
863
+				if (cfg_clone_str(&s, &s)) goto error;
864
+				changed->new_val.vstr=s;
865
+				break;
883 866
 
884
-		case CFG_VAR_POINTER:
885
-			changed->new_val.vp=v;
886
-			break;
867
+			case CFG_VAR_POINTER:
868
+				changed->new_val.vp=v;
869
+				break;
887 870
 
888 871
 		}
889 872
 	} else {
... ...
@@ -895,19 +878,19 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
895 878
 	 * The changes can be committed faster this way, the group instances
896 879
 	 * do not have to be looked-up for each and every variable. */
897 880
 	/* Check whether there is any variable in the list which
898
-	belongs to the same group */
881
+	 * belongs to the same group */
899 882
 	for (	changed_p = &ctx->changed_first;
900
-		*changed_p && ((*changed_p)->group != changed->group);
901
-		changed_p = &(*changed_p)->next);
883
+			*changed_p && ((*changed_p)->group != changed->group);
884
+			changed_p = &(*changed_p)->next);
902 885
 	/* try to find the group instance, and move changed_p to the end of
903
-	the instance. */
886
+	 * the instance. */
904 887
 	for (	;
905
-		*changed_p
888
+			*changed_p
906 889
 			&& ((*changed_p)->group == changed->group)
907 890
 			&& (!(*changed_p)->group_id_set
908 891
 				|| ((*changed_p)->group_id_set && changed->group_id_set
909 892
 					&& ((*changed_p)->group_id <= changed->group_id)));
910
-		changed_p = &(*changed_p)->next);
893
+			changed_p = &(*changed_p)->next);
911 894
 	/* Add the new variable before *changed_p */
912 895
 	changed->next = *changed_p;
913 896
 	*changed_p = changed;
... ...
@@ -915,53 +898,47 @@ int cfg_set_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str
915 898
 	CFG_CTX_UNLOCK(ctx);
916 899
 
917 900
 	if (val_type == CFG_VAR_INT)
918
-		LOG(L_INFO, "INFO: cfg_set_delayed(): %.*s.%.*s "
919
-			"is going to be changed to %d "
920
-			"[context=%p]\n",
921
-			group_name->len, group_name->s,
922
-			var_name->len, var_name->s,
923
-			(int)(long)val,
924
-			ctx);
901
+		LM_INFO("%.*s.%.*s is going to be changed to %d "
902
+				"[context=%p]\n",
903
+				group_name->len, group_name->s,
904
+				var_name->len, var_name->s,
905
+				(int)(long)val,
906
+				ctx);
925 907
 
926 908
 	else if (val_type == CFG_VAR_STRING)
927
-		LOG(L_INFO, "INFO: cfg_set_delayed(): %.*s.%.*s "
928
-			"is going to be changed to \"%s\" "
929
-			"[context=%p]\n",
930
-			group_name->len, group_name->s,
931
-			var_name->len, var_name->s,
932
-			(char *)val,
933
-			ctx);
909
+		LM_INFO("%.*s.%.*s is going to be changed to \"%s\" "
910
+				"[context=%p]\n",
911
+				group_name->len, group_name->s,
912
+				var_name->len, var_name->s,
913
+				(char *)val,
914
+				ctx);
934 915
 
935 916
 	else if (val_type == CFG_VAR_STR)
936
-		LOG(L_INFO, "INFO: cfg_set_delayed(): %.*s.%.*s "
937
-			"is going to be changed to \"%.*s\" "
938
-			"[context=%p]\n",
939
-			group_name->len, group_name->s,
940
-			var_name->len, var_name->s,
941
-			((str *)val)->len, ((str *)val)->s,
942
-			ctx);
917
+		LM_INFO("%.*s.%.*s is going to be changed to \"%.*s\" "
918
+				"[context=%p]\n",
919
+				group_name->len, group_name->s,
920
+				var_name->len, var_name->s,
921
+				((str *)val)->len, ((str *)val)->s,
922
+				ctx);
943 923
 
944 924
 	else if (val_type == CFG_VAR_UNSET)
945
-		LOG(L_INFO, "INFO: cfg_set_delayed(): %.*s.%.*s "
946
-			"is going to be deleted "
947
-			"[context=%p]\n",
948
-			group_name->len, group_name->s,
949
-			var_name->len, var_name->s,
950
-			ctx);
925
+		LM_INFO("%.*s.%.*s is going to be deleted "
926
+				"[context=%p]\n",
927
+				group_name->len, group_name->s,
928
+				var_name->len, var_name->s,
929
+				ctx);
951 930
 
952 931
 	else
953
-		LOG(L_INFO, "INFO: cfg_set_delayed(): %.*s.%.*s "
954
-			"is going to be changed "
955
-			"[context=%p]\n",
956
-			group_name->len, group_name->s,
957
-			var_name->len, var_name->s,
958
-			ctx);
932
+		LM_INFO("%.*s.%.*s is going to be changed "
933
+				"[context=%p]\n",
934
+				group_name->len, group_name->s,
935
+				var_name->len, var_name->s,
936
+				ctx);
959 937
 
960 938
 	if (group_id)
961
-		LOG(L_INFO, "INFO: cfg_set_delayed(): group id = %u "
962
-			"[context=%p]\n",
963
-			*group_id,
964
-			ctx);
939
+		LM_INFO("group id = %u [context=%p]\n",
940
+				*group_id,
941
+				ctx);
965 942
 
966 943
 	convert_val_cleanup();
967 944
 	return 0;
... ...
@@ -970,7 +947,7 @@ error:
970 947
 	CFG_CTX_UNLOCK(ctx);
971 948
 	if (changed) shm_free(changed);
972 949
 error0:
973
-	LOG(L_ERR, "ERROR: cfg_set_delayed(): failed to set the variable: %.*s.%.*s\n",
950
+	LM_ERR("failed to set the variable: %.*s.%.*s\n",
974 951
 			group_name->len, group_name->s,
975 952
 			var_name->len, var_name->s);
976 953
 
... ...
@@ -979,35 +956,36 @@ error0:
979 956
 }
980 957
 
981 958
 /* wrapper function for cfg_set_delayed */
982
-int cfg_set_delayed_int(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
983
-				int val)
959
+int cfg_set_delayed_int(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id,
960
+		str *var_name, int val)
984 961
 {
985 962
 	return cfg_set_delayed(ctx, group_name, group_id, var_name,
986
-				(void *)(long)val, CFG_VAR_INT);
963
+			(void *)(long)val, CFG_VAR_INT);
987 964
 }
988 965
 
989 966
 /* wrapper function for cfg_set_delayed */
990
-int cfg_set_delayed_string(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
991
-				char *val)
967
+int cfg_set_delayed_string(cfg_ctx_t *ctx, str *group_name,
968
+		unsigned int *group_id, str *var_name, char *val)
992 969
 {
993 970
 	return cfg_set_delayed(ctx, group_name, group_id, var_name,
994
-				(void *)val, CFG_VAR_STRING);
971
+			(void *)val, CFG_VAR_STRING);
995 972
 }
996 973
 
997 974
 /* wrapper function for cfg_set_delayed */
998
-int cfg_set_delayed_str(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name,
999
-				str *val)
975
+int cfg_set_delayed_str(cfg_ctx_t *ctx, str *group_name,
976
+		unsigned int *group_id, str *var_name, str *val)
1000 977
 {
1001 978
 	return cfg_set_delayed(ctx, group_name, group_id, var_name,
1002
-				(void *)val, CFG_VAR_STR);
979
+			(void *)val, CFG_VAR_STR);
1003 980
 }
1004 981
 
1005 982
 /* Delete a variable from the group instance.
1006 983
  * wrapper function for cfg_set_delayed */
1007
-int cfg_del_delayed(cfg_ctx_t *ctx, str *group_name, unsigned int *group_id, str *var_name)
984
+int cfg_del_delayed(cfg_ctx_t *ctx, str *group_name,
985
+		unsigned int *group_id, str *var_name)
1008 986
 {
1009 987
 	return cfg_set_delayed(ctx, group_name, group_id, var_name,
1010
-				NULL, CFG_VAR_UNSET);
988
+			NULL, CFG_VAR_UNSET);
1011 989
 }
1012 990
 
1013 991
 /* commits the previously prepared changes within the context */
... ...
@@ -1027,23 +1005,23 @@ int cfg_commit(cfg_ctx_t *ctx)
1027 1005
 	cfg_group_inst_t	*group_inst = NULL;
1028 1006
 
1029 1007
 	if (!ctx) {
1030
-		LOG(L_ERR, "ERROR: cfg_commit(): context is undefined\n");
1008
+		LM_ERR("context is undefined\n");
1031 1009
 		return -1;
1032 1010
 	}
1033 1011
 
1034 1012
 	if (!cfg_shmized) return 0; /* nothing to do */
1035 1013
 
1036 1014
 	/* the ctx must be locked while reading and writing
1037
-	the list of changed variables */
1015
+	 * the list of changed variables */
1038 1016
 	CFG_CTX_LOCK(ctx);
1039 1017
 
1040 1018
 	/* is there any change? */
1041 1019
 	if (!ctx->changed_first) goto done;
1042 1020
 
1043 1021
 	/* Count the number of replaced strings,
1044
-	and replaced group arrays.
1045
-	Prepare the linked list of per-child process
1046
-	callbacks, that will be added to the global list. */
1022
+	 * and replaced group arrays.
1023
+	 * Prepare the linked list of per-child process
1024
+	 * callbacks, that will be added to the global list. */
1047 1025
 	for(changed = ctx->changed_first, group = NULL; changed;
1048 1026
 			changed = changed->next) {
1049 1027
 		/* Each string/str potentially causes an old string to be freed
... ...
@@ -1061,7 +1039,8 @@ int cfg_commit(cfg_ctx_t *ctx)
1061 1039
 			group = changed->group;
1062 1040
 		}
1063 1041
 
1064
-		if (changed->group && !changed->group_id_set && changed->var->def->on_set_child_cb) {
1042
+		if (changed->group && !changed->group_id_set
1043
+				&& changed->var->def->on_set_child_cb) {
1065 1044
 			s.s = changed->group->name;
1066 1045
 			s.len = changed->group->name_len;
1067 1046
 			s2.s = changed->var->def->name;
... ...
@@ -1084,7 +1063,7 @@ int cfg_commit(cfg_ctx_t *ctx)
1084 1063
 		size = sizeof(void *)*(replaced_num + 1);
1085 1064
 		replaced = (void **)shm_malloc(size);
1086 1065
 		if (!replaced) {
1087
-			LOG(L_ERR, "ERROR: cfg_commit(): not enough shm memory\n");
1066
+			LM_ERR("not enough shm memory\n");
1088 1067
 			goto error0;
1089 1068
 		}
1090 1069
 		memset(replaced, 0 , size);
... ...
@@ -1095,7 +1074,7 @@ int cfg_commit(cfg_ctx_t *ctx)
1095 1074
 	}
1096 1075
 
1097 1076
 	/* make sure that nobody else replaces the global config
1098
-	while the new one is prepared */
1077
+	 * while the new one is prepared */
1099 1078
 	CFG_WRITER_LOCK();
1100 1079
 
1101 1080
 	/* clone the memory block, and prepare the modification */
... ...
@@ -1103,11 +1082,12 @@ int cfg_commit(cfg_ctx_t *ctx)
1103 1082
 		goto error;
1104 1083
 
1105 1084
 	/* Apply the modifications to the buffer.
1106
-	Note that the cycle relies on the order of the groups and group instances, i.e.
1107
-	the order is group + group_id + order of commits. */
1085
+	 * Note that the cycle relies on the order of the groups and group
1086
+	 * instances, i.e. the order is group + group_id + order of commits. */
1108 1087
 	replaced_num = 0;
1109 1088
 	for(changed = ctx->changed_first, group = NULL; /* group points to the
1110
-										last group array that has been cloned */
1089
+													 * last group array that
1090
+													 * has been cloned */
1111 1091
 			changed; changed = changed->next) {
1112 1092
 		if (!changed->group_id_set) {
1113 1093
 			p = CFG_GROUP_DATA(block, changed->group)
... ...
@@ -1117,11 +1097,11 @@ int cfg_commit(cfg_ctx_t *ctx)
1117 1097
 			if (group != changed->group) {
1118 1098
 				/* The group array has not been cloned yet. */
1119 1099
 				group = changed->group;
1120
-				if (!(CFG_GROUP_META(block, group)->array = 
1121
-					cfg_clone_array(CFG_GROUP_META(*cfg_global, group), group))
1122
-				) {
1123
-					LOG(L_ERR, "ERROR: cfg_commit(): group array cannot be cloned for %.*s[%u]\n",
1124
-						group->name_len, group->name, changed->group_id);
1100
+				if (!(CFG_GROUP_META(block, group)->array =
1101
+							cfg_clone_array(CFG_GROUP_META(*cfg_global, group), group))
1102
+						) {
1103
+					LM_ERR("group array cannot be cloned for %.*s[%u]\n",
1104
+							group->name_len, group->name, changed->group_id);
1125 1105
 					goto error;
1126 1106
 				}
1127 1107
 
... ...
@@ -1132,53 +1112,56 @@ int cfg_commit(cfg_ctx_t *ctx)
1132 1112
 			}
1133 1113
 			if (group && (!group_inst || (group_inst->id != changed->group_id))) {
1134 1114
 				group_inst = cfg_find_group(CFG_GROUP_META(block, group),
1135
-								group->size,
1136
-								changed->group_id);
1115
+						group->size,
1116
+						changed->group_id);
1137 1117
 			}
1138 1118
 			if (group && !group_inst) {
1139
-				LOG(L_ERR, "ERROR: cfg_commit(): global group instance %.*s[%u] is not found\n",
1140
-					group->name_len, group->name, changed->group_id);
1119
+				LM_ERR("global group instance %.*s[%u] is not found\n",
1120
+						group->name_len, group->name, changed->group_id);
1141 1121
 				goto error;
1142 1122
 			}
1143 1123
 			p = group_inst->vars + changed->var->offset;
1144 1124
 		}
1145 1125
 
1146
-		if (((changed->group_id_set && !changed->del_value && CFG_VAR_TEST_AND_SET(group_inst, changed->var))
1147
-			|| (changed->group_id_set && changed->del_value && CFG_VAR_TEST_AND_RESET(group_inst, changed->var))
1148
-			|| !changed->group_id_set)
1149
-		&& ((CFG_VAR_TYPE(changed->var) == CFG_VAR_STRING)
1150
-			|| (CFG_VAR_TYPE(changed->var) == CFG_VAR_STR))
1151
-		) {
1126
+		if (((changed->group_id_set && !changed->del_value
1127
+						&& CFG_VAR_TEST_AND_SET(group_inst, changed->var))
1128
+					|| (changed->group_id_set && changed->del_value
1129
+						&& CFG_VAR_TEST_AND_RESET(group_inst, changed->var))
1130
+					|| !changed->group_id_set)
1131
+				&& ((CFG_VAR_TYPE(changed->var) == CFG_VAR_STRING)
1132
+					|| (CFG_VAR_TYPE(changed->var) == CFG_VAR_STR))
1133
+				) {
1152 1134
 			replaced[replaced_num] = *(char **)p;
1153 1135
 			if (replaced[replaced_num])
1154 1136
 				replaced_num++;
1155 1137
 			/* else do not increase replaced_num, because
1156
-			the cfg_block_free() will stop at the first
1157
-			NULL value */
1138
+			 * the cfg_block_free() will stop at the first
1139
+			 * NULL value */
1158 1140
 		}
1159 1141
 
1160 1142
 		if (!changed->del_value)
1161 1143
 			memcpy(	p,
1162
-				changed->new_val.vraw,
1163
-				cfg_var_size(changed->var));
1144
+					changed->new_val.vraw,
1145
+					cfg_var_size(changed->var));
1164 1146
 		else
1165 1147
 			memcpy(	p,
1166
-				CFG_GROUP_DATA(block, changed->group) + changed->var->offset,
1167
-				cfg_var_size(changed->var));
1148
+					CFG_GROUP_DATA(block, changed->group) + changed->var->offset,
1149
+					cfg_var_size(changed->var));
1168 1150
 
1169 1151
 
1170 1152
 		if (!changed->group_id_set) {
1171 1153
 			/* the default value is changed, the copies of this value
1172
-			need to be also updated */
1154
+			 * need to be also updated */
1173 1155
 			if (cfg_update_defaults(CFG_GROUP_META(block, changed->group),
1174 1156
 						changed->group, changed->var, p,
1175 1157
 						(group != changed->group)) /* clone if the array
1176
-									has not been cloned yet */
1177
-                        )
1178
-                                goto error;
1179
-                        if ((group != changed->group)
1180
-				&& (CFG_GROUP_META(block, changed->group)->array != CFG_GROUP_META(*cfg_global, changed->group)->array)
1181
-			) {
1158
+													* has not been cloned yet */
1159
+					)
1160
+				goto error;
1161
+			if ((group != changed->group)
1162
+					&& (CFG_GROUP_META(block, changed->group)->array
1163
+						!= CFG_GROUP_META(*cfg_global, changed->group)->array)
1164
+					) {
1182 1165
 				/* The array has been cloned */
1183 1166
 				group = changed->group;
1184 1167
 
... ...
@@ -1194,17 +1177,16 @@ int cfg_commit(cfg_ctx_t *ctx)
1194 1177
 
1195 1178
 	/* free the changed list */
1196 1179
 	for (	changed = ctx->changed_first;
1197
-		changed;
1198
-		changed = changed2
1199
-	) {
1180
+			changed;
1181
+			changed = changed2
1182
+		) {
1200 1183
 		changed2 = changed->next;
1201 1184
 		shm_free(changed);
1202 1185
 	}
1203 1186
 	ctx->changed_first = NULL;
1204 1187
 
1205 1188
 done:
1206
-	LOG(L_INFO, "INFO: cfg_commit(): config changes have been applied "
1207
-			"[context=%p]\n",
1189
+	LM_INFO("config changes have been applied [context=%p]\n",
1208 1190
 			ctx);
1209 1191
 
1210 1192
 	CFG_CTX_UNLOCK(ctx);
... ...
@@ -1213,13 +1195,14 @@ done:
1213 1195
 error:
1214 1196
 	if (block) {
1215 1197
 		/* clean the new block from the cloned arrays */
1216
-		for (	group = cfg_group;
1217
-			group;
1218
-			group = group->next
1219
-		)
1198
+		for (group = cfg_group;
1199
+				group;
1200
+				group = group->next
1201
+				)
1220 1202
 			if (CFG_GROUP_META(block, group)->array
1221
-				&& (CFG_GROUP_META(block, group)->array != CFG_GROUP_META(*cfg_global, group)->array)
1222
-			)
1203
+					&& (CFG_GROUP_META(block, group)->array
1204
+						!= CFG_GROUP_META(*cfg_global, group)->array)
1205
+					)
1223 1206
 				shm_free(CFG_GROUP_META(block, group)->array);
1224 1207
 		/* the block can be freed outside of the writer lock */
1225 1208
 	}
... ...
@@ -1242,30 +1225,29 @@ int cfg_rollback(cfg_ctx_t *ctx)
1242 1225
 	cfg_changed_var_t	*changed, *changed2;
1243 1226
 
1244 1227
 	if (!ctx) {
1245
-		LOG(L_ERR, "ERROR: cfg_rollback(): context is undefined\n");
1228
+		LM_ERR("context is undefined\n");
1246 1229
 		return -1;
1247 1230
 	}
1248 1231
 
1249 1232
 	if (!cfg_shmized) return 0; /* nothing to do */
1250 1233
 
1251
-	LOG(L_INFO, "INFO: cfg_rollback(): deleting the config changes "
1252
-			"[context=%p]\n",
1234
+	LM_INFO("deleting the config changes [context=%p]\n",
1253 1235
 			ctx);
1254 1236
 
1255 1237
 	/* the ctx must be locked while reading and writing
1256
-	the list of changed variables */
1238
+	 * the list of changed variables */
1257 1239
 	CFG_CTX_LOCK(ctx);
1258 1240
 
1259
-	for (	changed = ctx->changed_first;
1260
-		changed;
1261
-		changed = changed2
1262
-	) {
1241
+	for (changed = ctx->changed_first;
1242
+			changed;
1243