Browse code

cfg_rpc: use directly cfg_get_group_id()

Daniel-Constantin Mierla authored on 24/05/2021 14:17:52
Showing 1 changed files
... ...
@@ -44,13 +44,6 @@ static int mod_init(void)
44 44
 	return 0;
45 45
 }
46 46
 
47
-/* Set the group_id pointer based on the group string.
48
- * The string is either "group_name", or "group_name[group_id]"
49
- * *group_id is set to null in the former case.
50
- * Warning: changes the group string
51
- */
52
-#define get_group_id(group, group_id) cfg_get_group_id(group, group_id)
53
-
54 47
 static const char *rpc_set_now_doc[2] = {
55 48
 		"Set the value of a configuration variable and commit the change "
56 49
 		"immediately",
... ...
@@ -65,7 +58,7 @@ static void rpc_set_now_int(rpc_t *rpc, void *c)
65 58
 	if(rpc->scan(c, "SSd", &group, &var, &i) < 3)
66 59
 		return;
67 60
 
68
-	if(get_group_id(&group, &group_id)) {
61
+	if(cfg_get_group_id(&group, &group_id)) {
69 62
 		rpc->fault(c, 400,
70 63
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
71 64
 		return;
... ...
@@ -86,7 +79,7 @@ static void rpc_set_now_string(rpc_t *rpc, void *c)
86 79
 	if(rpc->scan(c, "SSs", &group, &var, &ch) < 3)
87 80
 		return;
88 81
 
89
-	if(get_group_id(&group, &group_id)) {
82
+	if(cfg_get_group_id(&group, &group_id)) {
90 83
 		rpc->fault(c, 400,
91 84
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
92 85
 		return;
... ...
@@ -108,7 +101,7 @@ static void rpc_set(rpc_t *rpc, void *c)
108 101
 	if(rpc->scan(c, "SS", &group, &var) < 2)
109 102
 		return;
110 103
 
111
-	if(get_group_id(&group, &group_id)) {
104
+	if(cfg_get_group_id(&group, &group_id)) {
112 105
 		rpc->fault(c, 400,
113 106
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
114 107
 		return;
... ...
@@ -140,7 +133,7 @@ static void rpc_del(rpc_t *rpc, void *c)
140 133
 	if(rpc->scan(c, "SS", &group, &var) < 2)
141 134
 		return;
142 135
 
143
-	if(get_group_id(&group, &group_id) || !group_id) {
136
+	if(cfg_get_group_id(&group, &group_id) || !group_id) {
144 137
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
145 138
 		return;
146 139
 	}
... ...
@@ -165,7 +158,7 @@ static void rpc_set_delayed_int(rpc_t *rpc, void *c)
165 158
 	if(rpc->scan(c, "SSd", &group, &var, &i) < 3)
166 159
 		return;
167 160
 
168
-	if(get_group_id(&group, &group_id)) {
161
+	if(cfg_get_group_id(&group, &group_id)) {
169 162
 		rpc->fault(c, 400,
170 163
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
171 164
 		return;
... ...
@@ -186,7 +179,7 @@ static void rpc_set_delayed_string(rpc_t *rpc, void *c)
186 179
 	if(rpc->scan(c, "SSs", &group, &var, &ch) < 3)
187 180
 		return;
188 181
 
189
-	if(get_group_id(&group, &group_id)) {
182
+	if(cfg_get_group_id(&group, &group_id)) {
190 183
 		rpc->fault(c, 400,
191 184
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
192 185
 		return;
... ...
@@ -208,7 +201,7 @@ static void rpc_set_delayed(rpc_t *rpc, void *c)
208 201
 	if(rpc->scan(c, "SS", &group, &var) < 2)
209 202
 		return;
210 203
 
211
-	if(get_group_id(&group, &group_id)) {
204
+	if(cfg_get_group_id(&group, &group_id)) {
212 205
 		rpc->fault(c, 400,
213 206
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
214 207
 		return;
... ...
@@ -240,7 +233,7 @@ static void rpc_del_delayed(rpc_t *rpc, void *c)
240 233
 	if(rpc->scan(c, "SS", &group, &var) < 2)
241 234
 		return;
242 235
 
243
-	if(get_group_id(&group, &group_id) || !group_id) {
236
+	if(cfg_get_group_id(&group, &group_id) || !group_id) {
244 237
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
245 238
 		return;
246 239
 	}
... ...
@@ -296,7 +289,7 @@ static void rpc_get(rpc_t *rpc, void *c)
296 289
 		var.s = NULL;
297 290
 		var.len = 0;
298 291
 	}
299
-	if(get_group_id(&group, &group_id)) {
292
+	if(cfg_get_group_id(&group, &group_id)) {
300 293
 		rpc->fault(c, 400,
301 294
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
302 295
 		return;
... ...
@@ -412,7 +405,7 @@ static void rpc_cfg_var_reset(rpc_t *rpc, void *c)
412 405
 	if(rpc->scan(c, "S", &group) < 1)
413 406
 		return;
414 407
 
415
-	if(get_group_id(&group, &group_id)) {
408
+	if(cfg_get_group_id(&group, &group_id)) {
416 409
 		rpc->fault(c, 400,
417 410
 				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
418 411
 		return;
... ...
@@ -579,7 +572,7 @@ static void rpc_add_group_inst(rpc_t *rpc, void *c)
579 572
 	if(rpc->scan(c, "S", &group) < 1)
580 573
 		return;
581 574
 
582
-	if(get_group_id(&group, &group_id) || !group_id) {
575
+	if(cfg_get_group_id(&group, &group_id) || !group_id) {
583 576
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
584 577
 		return;
585 578
 	}
... ...
@@ -601,7 +594,7 @@ static void rpc_del_group_inst(rpc_t *rpc, void *c)
601 594
 	if(rpc->scan(c, "S", &group) < 1)
602 595
 		return;
603 596
 
604
-	if(get_group_id(&group, &group_id) || !group_id) {
597
+	if(cfg_get_group_id(&group, &group_id) || !group_id) {
605 598
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
606 599
 		return;
607 600
 	}
Browse code

cfg_rpc: clang format

Daniel-Constantin Mierla authored on 15/05/2021 07:19:55
Showing 1 changed files
... ...
@@ -29,14 +29,14 @@
29 29
 #include "../../core/cfg/cfg_ctx.h"
30 30
 #include "../../core/rpc.h"
31 31
 
32
-static cfg_ctx_t	*ctx = NULL;
33
-
34 32
 MODULE_VERSION
35 33
 
34
+static cfg_ctx_t *ctx = NULL;
35
+
36 36
 /* module initialization function */
37 37
 static int mod_init(void)
38 38
 {
39
-	if (cfg_register_ctx(&ctx, NULL)) {
39
+	if(cfg_register_ctx(&ctx, NULL)) {
40 40
 		LOG(L_ERR, "cfg_rpc: failed to register cfg context\n");
41 41
 		return -1;
42 42
 	}
... ...
@@ -51,253 +51,254 @@ static int mod_init(void)
51 51
  */
52 52
 #define get_group_id(group, group_id) cfg_get_group_id(group, group_id)
53 53
 
54
-static const char* rpc_set_now_doc[2] = {
55
-        "Set the value of a configuration variable and commit the change immediately",
56
-        0
57
-};
54
+static const char *rpc_set_now_doc[2] = {
55
+		"Set the value of a configuration variable and commit the change "
56
+		"immediately",
57
+		0};
58 58
 
59
-static void rpc_set_now_int(rpc_t* rpc, void* c)
59
+static void rpc_set_now_int(rpc_t *rpc, void *c)
60 60
 {
61
-	str	group, var;
62
-	int	i;
63
-	unsigned int	*group_id;
61
+	str group, var;
62
+	int i;
63
+	unsigned int *group_id;
64 64
 
65
-	if (rpc->scan(c, "SSd", &group, &var, &i) < 3)
65
+	if(rpc->scan(c, "SSd", &group, &var, &i) < 3)
66 66
 		return;
67 67
 
68
-	if (get_group_id(&group, &group_id)) {
69
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
68
+	if(get_group_id(&group, &group_id)) {
69
+		rpc->fault(c, 400,
70
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
70 71
 		return;
71 72
 	}
72 73
 
73
-	if (cfg_set_now_int(ctx, &group, group_id, &var, i)) {
74
+	if(cfg_set_now_int(ctx, &group, group_id, &var, i)) {
74 75
 		rpc->fault(c, 400, "Failed to set the variable");
75 76
 		return;
76 77
 	}
77 78
 }
78 79
 
79
-static void rpc_set_now_string(rpc_t* rpc, void* c)
80
+static void rpc_set_now_string(rpc_t *rpc, void *c)
80 81
 {
81
-	str	group, var;
82
-	char	*ch;
83
-	unsigned int	*group_id;
82
+	str group, var;
83
+	char *ch;
84
+	unsigned int *group_id;
84 85
 
85
-	if (rpc->scan(c, "SSs", &group, &var, &ch) < 3)
86
+	if(rpc->scan(c, "SSs", &group, &var, &ch) < 3)
86 87
 		return;
87 88
 
88
-	if (get_group_id(&group, &group_id)) {
89
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
89
+	if(get_group_id(&group, &group_id)) {
90
+		rpc->fault(c, 400,
91
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
90 92
 		return;
91 93
 	}
92 94
 
93
-	if (cfg_set_now_string(ctx, &group, group_id, &var, ch)) {
95
+	if(cfg_set_now_string(ctx, &group, group_id, &var, ch)) {
94 96
 		rpc->fault(c, 400, "Failed to set the variable");
95 97
 		return;
96 98
 	}
97 99
 }
98 100
 
99
-static void rpc_set(rpc_t* rpc, void* c)
101
+static void rpc_set(rpc_t *rpc, void *c)
100 102
 {
101
-	str	group, var;
102
-	int	i, err;
103
-	char	*ch;
104
-	unsigned int	*group_id;
103
+	str group, var;
104
+	int i, err;
105
+	char *ch;
106
+	unsigned int *group_id;
105 107
 
106
-	if (rpc->scan(c, "SS", &group, &var) < 2)
108
+	if(rpc->scan(c, "SS", &group, &var) < 2)
107 109
 		return;
108 110
 
109
-	if (get_group_id(&group, &group_id)) {
110
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
111
+	if(get_group_id(&group, &group_id)) {
112
+		rpc->fault(c, 400,
113
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
111 114
 		return;
112 115
 	}
113 116
 
114
-	if (rpc->scan(c, "d", &i) == 1)
117
+	if(rpc->scan(c, "d", &i) == 1)
115 118
 		err = cfg_set_now_int(ctx, &group, group_id, &var, i);
116
-	else if (rpc->scan(c, "s", &ch) == 1)
119
+	else if(rpc->scan(c, "s", &ch) == 1)
117 120
 		err = cfg_set_now_string(ctx, &group, group_id, &var, ch);
118 121
 	else
119 122
 		return; /* error */
120 123
 
121
-	if (err) {
124
+	if(err) {
122 125
 		rpc->fault(c, 400, "Failed to set the variable");
123 126
 		return;
124 127
 	}
125 128
 }
126 129
 
127
-static const char* rpc_del_now_doc[2] = {
128
-        "Delete the value of a configuration variable from a group instance and commit the change immediately",
129
-        0
130
-};
130
+static const char *rpc_del_now_doc[2] = {
131
+		"Delete the value of a configuration variable from a group instance "
132
+		"and commit the change immediately",
133
+		0};
131 134
 
132
-static void rpc_del(rpc_t* rpc, void* c)
135
+static void rpc_del(rpc_t *rpc, void *c)
133 136
 {
134
-	str	group, var;
135
-	unsigned int	*group_id;
137
+	str group, var;
138
+	unsigned int *group_id;
136 139
 
137
-	if (rpc->scan(c, "SS", &group, &var) < 2)
140
+	if(rpc->scan(c, "SS", &group, &var) < 2)
138 141
 		return;
139 142
 
140
-	if (get_group_id(&group, &group_id) || !group_id) {
143
+	if(get_group_id(&group, &group_id) || !group_id) {
141 144
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
142 145
 		return;
143 146
 	}
144 147
 
145
-	if (cfg_del_now(ctx, &group, group_id, &var)) {
148
+	if(cfg_del_now(ctx, &group, group_id, &var)) {
146 149
 		rpc->fault(c, 400, "Failed to delete the value");
147 150
 		return;
148 151
 	}
149 152
 }
150 153
 
151
-static const char* rpc_set_delayed_doc[2] = {
152
-        "Prepare the change of a configuration variable, but does not commit the new value yet",
153
-        0
154
-};
154
+static const char *rpc_set_delayed_doc[2] = {
155
+		"Prepare the change of a configuration variable, but does not commit "
156
+		"the new value yet",
157
+		0};
155 158
 
156
-static void rpc_set_delayed_int(rpc_t* rpc, void* c)
159
+static void rpc_set_delayed_int(rpc_t *rpc, void *c)
157 160
 {
158
-	str	group, var;
159
-	int	i;
160
-	unsigned int	*group_id;
161
+	str group, var;
162
+	int i;
163
+	unsigned int *group_id;
161 164
 
162
-	if (rpc->scan(c, "SSd", &group, &var, &i) < 3)
165
+	if(rpc->scan(c, "SSd", &group, &var, &i) < 3)
163 166
 		return;
164 167
 
165
-	if (get_group_id(&group, &group_id)) {
166
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
168
+	if(get_group_id(&group, &group_id)) {
169
+		rpc->fault(c, 400,
170
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
167 171
 		return;
168 172
 	}
169 173
 
170
-	if (cfg_set_delayed_int(ctx, &group, group_id, &var, i)) {
174
+	if(cfg_set_delayed_int(ctx, &group, group_id, &var, i)) {
171 175
 		rpc->fault(c, 400, "Failed to set the variable");
172 176
 		return;
173 177
 	}
174 178
 }
175 179
 
176
-static void rpc_set_delayed_string(rpc_t* rpc, void* c)
180
+static void rpc_set_delayed_string(rpc_t *rpc, void *c)
177 181
 {
178
-	str	group, var;
179
-	char	*ch;
180
-	unsigned int	*group_id;
182
+	str group, var;
183
+	char *ch;
184
+	unsigned int *group_id;
181 185
 
182
-	if (rpc->scan(c, "SSs", &group, &var, &ch) < 3)
186
+	if(rpc->scan(c, "SSs", &group, &var, &ch) < 3)
183 187
 		return;
184 188
 
185
-	if (get_group_id(&group, &group_id)) {
186
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
189
+	if(get_group_id(&group, &group_id)) {
190
+		rpc->fault(c, 400,
191
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
187 192
 		return;
188 193
 	}
189 194
 
190
-	if (cfg_set_delayed_string(ctx, &group, group_id, &var, ch)) {
195
+	if(cfg_set_delayed_string(ctx, &group, group_id, &var, ch)) {
191 196
 		rpc->fault(c, 400, "Failed to set the variable");
192 197
 		return;
193 198
 	}
194 199
 }
195 200
 
196
-static void rpc_set_delayed(rpc_t* rpc, void* c)
201
+static void rpc_set_delayed(rpc_t *rpc, void *c)
197 202
 {
198
-	str	group, var;
199
-	int	i, err;
200
-	char	*ch;
201
-	unsigned int	*group_id;
203
+	str group, var;
204
+	int i, err;
205
+	char *ch;
206
+	unsigned int *group_id;
202 207
 
203
-	if (rpc->scan(c, "SS", &group, &var) < 2)
208
+	if(rpc->scan(c, "SS", &group, &var) < 2)
204 209
 		return;
205 210
 
206
-	if (get_group_id(&group, &group_id)) {
207
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
211
+	if(get_group_id(&group, &group_id)) {
212
+		rpc->fault(c, 400,
213
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
208 214
 		return;
209 215
 	}
210 216
 
211
-	if (rpc->scan(c, "d", &i) == 1)
217
+	if(rpc->scan(c, "d", &i) == 1)
212 218
 		err = cfg_set_delayed_int(ctx, &group, group_id, &var, i);
213
-	else if (rpc->scan(c, "s", &ch) == 1)
219
+	else if(rpc->scan(c, "s", &ch) == 1)
214 220
 		err = cfg_set_delayed_string(ctx, &group, group_id, &var, ch);
215 221
 	else
216 222
 		return; /* error */
217 223
 
218
-	if (err) {
224
+	if(err) {
219 225
 		rpc->fault(c, 400, "Failed to set the variable");
220 226
 		return;
221 227
 	}
222 228
 }
223 229
 
224
-static const char* rpc_del_delayed_doc[2] = {
225
-        "Prepare the deletion of the value of a configuration variable from a group instance, but does not commit the change yet",
226
-        0
227
-};
230
+static const char *rpc_del_delayed_doc[2] = {
231
+		"Prepare the deletion of the value of a configuration variable from a "
232
+		"group instance, but does not commit the change yet",
233
+		0};
228 234
 
229
-static void rpc_del_delayed(rpc_t* rpc, void* c)
235
+static void rpc_del_delayed(rpc_t *rpc, void *c)
230 236
 {
231
-	str	group, var;
232
-	unsigned int	*group_id;
237
+	str group, var;
238
+	unsigned int *group_id;
233 239
 
234
-	if (rpc->scan(c, "SS", &group, &var) < 2)
240
+	if(rpc->scan(c, "SS", &group, &var) < 2)
235 241
 		return;
236 242
 
237
-	if (get_group_id(&group, &group_id) || !group_id) {
243
+	if(get_group_id(&group, &group_id) || !group_id) {
238 244
 		rpc->fault(c, 400, "Wrong group syntax. Use \"group[id]\"");
239 245
 		return;
240 246
 	}
241 247
 
242
-	if (cfg_del_delayed(ctx, &group, group_id, &var)) {
248
+	if(cfg_del_delayed(ctx, &group, group_id, &var)) {
243 249
 		rpc->fault(c, 400, "Failed to delete the value");
244 250
 		return;
245 251
 	}
246 252
 }
247 253
 
248
-static const char* rpc_commit_doc[2] = {
249
-        "Commit the previously prepared configuration changes",
250
-        0
251
-};
254
+static const char *rpc_commit_doc[2] = {
255
+		"Commit the previously prepared configuration changes", 0};
252 256
 
253
-static void rpc_commit(rpc_t* rpc, void* c)
257
+static void rpc_commit(rpc_t *rpc, void *c)
254 258
 {
255
-	if (cfg_commit(ctx)) {
259
+	if(cfg_commit(ctx)) {
256 260
 		rpc->fault(c, 400, "Failed to commit the changes");
257 261
 		return;
258 262
 	}
259 263
 }
260 264
 
261
-static const char* rpc_rollback_doc[2] = {
262
-        "Drop the prepared configuration changes",
263
-        0
264
-};
265
+static const char *rpc_rollback_doc[2] = {
266
+		"Drop the prepared configuration changes", 0};
265 267
 
266
-static void rpc_rollback(rpc_t* rpc, void* c)
268
+static void rpc_rollback(rpc_t *rpc, void *c)
267 269
 {
268
-	if (cfg_rollback(ctx)) {
270
+	if(cfg_rollback(ctx)) {
269 271
 		rpc->fault(c, 400, "Failed to drop the changes");
270 272
 		return;
271 273
 	}
272 274
 }
273 275
 
274
-static const char* rpc_get_doc[2] = {
275
-        "Get the value of a configuration variable",
276
-        0
277
-};
276
+static const char *rpc_get_doc[2] = {
277
+		"Get the value of a configuration variable", 0};
278 278
 
279
-static void rpc_get(rpc_t* rpc, void* c)
279
+static void rpc_get(rpc_t *rpc, void *c)
280 280
 {
281
-	str     group, var;
282
-	void    *val;
283
-	unsigned int    val_type;
284
-	int     ret, n;
285
-	unsigned int    *group_id;
281
+	str group, var;
282
+	void *val;
283
+	unsigned int val_type;
284
+	int ret, n;
285
+	unsigned int *group_id;
286 286
 	void *rh = NULL;
287 287
 
288 288
 	n = rpc->scan(c, "S*S", &group, &var);
289 289
 	/*  2: both group and variable name are present
290 290
 	 * -1: only group is present, print all variables in the group */
291
-	if(n<1) {
291
+	if(n < 1) {
292 292
 		rpc->fault(c, 500, "Failed to get the parameters");
293 293
 		return;
294 294
 	}
295
-	if (n == 1) {
295
+	if(n == 1) {
296 296
 		var.s = NULL;
297 297
 		var.len = 0;
298 298
 	}
299
-	if (get_group_id(&group, &group_id)) {
300
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
299
+	if(get_group_id(&group, &group_id)) {
300
+		rpc->fault(c, 400,
301
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
301 302
 		return;
302 303
 	}
303 304
 	if(var.len != 0) {
... ...
@@ -305,16 +306,17 @@ static void rpc_get(rpc_t* rpc, void* c)
305 306
 				var.len, var.s);
306 307
 		/* print value for one variable */
307 308
 		val = NULL;
308
-		ret = cfg_get_by_name(ctx, &group, group_id, &var,
309
-				&val, &val_type);
310
-		if (ret < 0) {
309
+		ret = cfg_get_by_name(ctx, &group, group_id, &var, &val, &val_type);
310
+		if(ret < 0) {
311 311
 			rpc->fault(c, 400, "Failed to get the variable");
312 312
 			return;
313
-		} else if (ret > 0) {
314
-			rpc->fault(c, 400, "Variable exists, but it is not readable via RPC interface");
313
+		} else if(ret > 0) {
314
+			rpc->fault(c, 400,
315
+					"Variable exists, but it is not readable via RPC "
316
+					"interface");
315 317
 			return;
316 318
 		}
317
-		switch (val_type) {
319
+		switch(val_type) {
318 320
 			case CFG_VAR_INT:
319 321
 				rpc->add(c, "d", (int)(long)val);
320 322
 				break;
... ...
@@ -330,40 +332,41 @@ static void rpc_get(rpc_t* rpc, void* c)
330 332
 		}
331 333
 	} else {
332 334
 		/* print values for all variables in the group */
333
-		void            *h;
334
-		str             gname;
335
-		cfg_def_t       *def;
336
-		int             i;
335
+		void *h;
336
+		str gname;
337
+		cfg_def_t *def;
338
+		int i;
337 339
 		char pbuf[32];
338 340
 		int plen;
339 341
 		LM_DBG("getting values for group: %.*s\n", group.len, group.s);
340 342
 		rpc->add(c, "{", &rh);
341
-		if(rh==NULL) {
343
+		if(rh == NULL) {
342 344
 			LM_ERR("failed to add root structure\n");
343 345
 			rpc->fault(c, 500, "Failed to add root structure");
344 346
 			return;
345 347
 		}
346 348
 		cfg_get_group_init(&h);
347 349
 		while(cfg_get_group_next(&h, &gname, &def)) {
348
-			if (((gname.len == group.len) && (memcmp(gname.s, group.s, group.len) == 0))) {
349
-				for (i=0; def[i].name; i++) {
350
+			if(((gname.len == group.len)
351
+					   && (memcmp(gname.s, group.s, group.len) == 0))) {
352
+				for(i = 0; def[i].name; i++) {
350 353
 					var.s = def[i].name;
351 354
 					var.len = (int)strlen(def[i].name);
352
-					LM_DBG("getting value for variable: %.*s.%.*s\n",
353
-							group.len, group.s, var.len, var.s);
355
+					LM_DBG("getting value for variable: %.*s.%.*s\n", group.len,
356
+							group.s, var.len, var.s);
354 357
 					val = NULL;
355
-					ret = cfg_get_by_name(ctx, &group, group_id, &var,
356
-							&val, &val_type);
357
-					if (ret < 0) {
358
+					ret = cfg_get_by_name(
359
+							ctx, &group, group_id, &var, &val, &val_type);
360
+					if(ret < 0) {
358 361
 						rpc->fault(c, 400, "Failed to get the variable");
359 362
 						return;
360
-					} else if (ret > 0) {
363
+					} else if(ret > 0) {
361 364
 						LM_DBG("skipping dynamic (callback) value for variable:"
362
-								" %.*s.%.*s (%p/%d)\n",
365
+							   " %.*s.%.*s (%p/%d)\n",
363 366
 								group.len, group.s, var.len, var.s, val, ret);
364 367
 						continue;
365 368
 					}
366
-					switch (val_type) {
369
+					switch(val_type) {
367 370
 						case CFG_VAR_INT:
368 371
 							rpc->struct_add(rh, "d", var.s, (int)(long)val);
369 372
 							break;
... ...
@@ -375,81 +378,79 @@ static void rpc_get(rpc_t* rpc, void* c)
375 378
 							break;
376 379
 						case CFG_VAR_POINTER:
377 380
 							plen = snprintf(pbuf, 32, "%p", val);
378
-							if(plen>0 && plen<32) {
381
+							if(plen > 0 && plen < 32) {
379 382
 								rpc->struct_add(rh, "s", var.s, pbuf);
380 383
 							} else {
381
-								LM_ERR("error adding: %.*s.%s\n",
382
-										group.len, group.s, var.s);
384
+								LM_ERR("error adding: %.*s.%s\n", group.len,
385
+										group.s, var.s);
383 386
 							}
384 387
 							break;
385 388
 					}
386
-
387 389
 				}
388 390
 			}
389 391
 		}
390 392
 	}
391
-
392 393
 }
393
-static const char* rpc_cfg_var_reset_doc[2] = {
394
-       "Reset all the values of a configuration group and commit the change immediately",
395
-       0
396
-};
394
+static const char *rpc_cfg_var_reset_doc[2] = {
395
+		"Reset all the values of a configuration group and commit the change "
396
+		"immediately",
397
+		0};
397 398
 
398
-static void rpc_cfg_var_reset(rpc_t* rpc, void* c)
399
+static void rpc_cfg_var_reset(rpc_t *rpc, void *c)
399 400
 {
400
-	void	*h;
401
-	str	gname, var;
402
-	cfg_def_t	*def;
403
-	void	*val;
404
-	int	i, ret;
405
-	str	group;
406
-	char	*ch;
407
-	unsigned int	*group_id;
408
-	unsigned int	val_type;
409
-	unsigned int	input_type;
401
+	void *h;
402
+	str gname, var;
403
+	cfg_def_t *def;
404
+	void *val;
405
+	int i, ret;
406
+	str group;
407
+	char *ch;
408
+	unsigned int *group_id;
409
+	unsigned int val_type;
410
+	unsigned int input_type;
410 411
 
411
-	if (rpc->scan(c, "S", &group) < 1)
412
+	if(rpc->scan(c, "S", &group) < 1)
412 413
 		return;
413 414
 
414
-	if (get_group_id(&group, &group_id)) {
415
-		rpc->fault(c, 400, "Wrong group syntax. Use either \"group\", or \"group[id]\"");
415
+	if(get_group_id(&group, &group_id)) {
416
+		rpc->fault(c, 400,
417
+				"Wrong group syntax. Use either \"group\", or \"group[id]\"");
416 418
 		return;
417 419
 	}
418 420
 
419 421
 	cfg_get_group_init(&h);
420 422
 	while(cfg_get_group_next(&h, &gname, &def))
421
-		if (((gname.len == group.len) && (memcmp(gname.s, group.s, group.len) == 0)))
422
-		{
423
-			for (i=0; def[i].name; i++){
423
+		if(((gname.len == group.len)
424
+				   && (memcmp(gname.s, group.s, group.len) == 0))) {
425
+			for(i = 0; def[i].name; i++) {
424 426
 
425 427
 				var.s = def[i].name;
426 428
 				var.len = (int)strlen(def[i].name);
427
-				ret = cfg_get_default_value_by_name(ctx, &gname, group_id, &var,
428
-						&val, &val_type);
429
+				ret = cfg_get_default_value_by_name(
430
+						ctx, &gname, group_id, &var, &val, &val_type);
429 431
 
430
-				if (ret != 0)
432
+				if(ret != 0)
431 433
 					continue;
432 434
 
433
-				if (cfg_help(ctx, &group, &var,
434
-							&ch, &input_type)
435
-					) {
436
-					rpc->fault(c, 400, "Failed to get the variable description");
435
+				if(cfg_help(ctx, &group, &var, &ch, &input_type)) {
436
+					rpc->fault(
437
+							c, 400, "Failed to get the variable description");
437 438
 					return;
438 439
 				}
439 440
 
440
-				if (input_type == CFG_INPUT_INT) {
441
-					ret = cfg_set_now_int(ctx, &gname, group_id, &var,
442
-							(int)(long)val);
443
-				} else if (input_type == CFG_INPUT_STRING) {
441
+				if(input_type == CFG_INPUT_INT) {
442
+					ret = cfg_set_now_int(
443
+							ctx, &gname, group_id, &var, (int)(long)val);
444
+				} else if(input_type == CFG_INPUT_STRING) {
444 445
 					ret = cfg_set_now_string(ctx, &gname, group_id, &var, val);
445 446
 				} else {
446 447
 					rpc->fault(c, 500, "Unsupported input type");
447 448
 					return;
448 449
 				}
449
-				if(ret<0) {
450
+				if(ret < 0) {
450 451
 					rpc->fault(c, 500, "Reset failed");
451 452
 					return;
452
-				} else if(ret==1) {
453
+				} else if(ret == 1) {
453 454
 					LM_WARN("unexpected situation - variable not found\n");
454 455
 				}
455 456
 			}
... ...
@@ -457,215 +458,196 @@ static void rpc_cfg_var_reset(rpc_t* rpc, void* c)
457 458
 }
458 459
 
459 460
 
460
-static const char* rpc_help_doc[2] = {
461
-        "Print the description of a configuration variable",
462
-        0
463
-};
461
+static const char *rpc_help_doc[2] = {
462
+		"Print the description of a configuration variable", 0};
464 463
 
465
-static void rpc_help(rpc_t* rpc, void* c)
464
+static void rpc_help(rpc_t *rpc, void *c)
466 465
 {
467
-	str	group, var;
468
-	char	*ch;
469
-	unsigned int	input_type;
466
+	str group, var;
467
+	char *ch;
468
+	unsigned int input_type;
470 469
 
471
-	if (rpc->scan(c, "SS", &group, &var) < 2)
470
+	if(rpc->scan(c, "SS", &group, &var) < 2)
472 471
 		return;
473 472
 
474
-	if (cfg_help(ctx, &group, &var,
475
-			&ch, &input_type)
476
-	) {
473
+	if(cfg_help(ctx, &group, &var, &ch, &input_type)) {
477 474
 		rpc->fault(c, 400, "Failed to get the variable description");
478 475
 		return;
479 476
 	}
480 477
 	rpc->add(c, "s", ch);
481 478
 
482
-	switch (input_type) {
483
-	case CFG_INPUT_INT:
484
-		rpc->rpl_printf(c, "(parameter type is integer)");
485
-		break;
479
+	switch(input_type) {
480
+		case CFG_INPUT_INT:
481
+			rpc->rpl_printf(c, "(parameter type is integer)");
482
+			break;
486 483
 
487
-	case CFG_INPUT_STRING:
488
-	case CFG_INPUT_STR:
489
-		rpc->rpl_printf(c, "(parameter type is string)");
490
-		break;
491
-	}	
484
+		case CFG_INPUT_STRING:
485
+		case CFG_INPUT_STR:
486
+			rpc->rpl_printf(c, "(parameter type is string)");
487
+			break;
488
+	}
492 489
 }
493 490
 
494
-static const char* rpc_list_doc[2] = {
495
-        "List the configuration variables",
496
-        0
497
-};
491
+static const char *rpc_list_doc[2] = {"List the configuration variables", 0};
498 492
 
499
-static void rpc_list(rpc_t* rpc, void* c)
493
+static void rpc_list(rpc_t *rpc, void *c)
500 494
 {
501
-	void		*h;
502
-	str		gname;
503
-	cfg_def_t	*def;
504
-	int		i;
505
-	str		group;
495
+	void *h;
496
+	str gname;
497
+	cfg_def_t *def;
498
+	int i;
499
+	str group;
506 500
 
507
-	if (rpc->scan(c, "*S", &group) < 1) {
501
+	if(rpc->scan(c, "*S", &group) < 1) {
508 502
 		group.s = NULL;
509 503
 		group.len = 0;
510 504
 	}
511 505
 
512 506
 	cfg_get_group_init(&h);
513 507
 	while(cfg_get_group_next(&h, &gname, &def))
514
-		if (!group.len
515
-			|| ((gname.len == group.len)
516
-				&& (memcmp(gname.s, group.s, group.len) == 0))
517
-		)
518
-			for (i=0; def[i].name; i++)
508
+		if(!group.len
509
+				|| ((gname.len == group.len)
510
+						&& (memcmp(gname.s, group.s, group.len) == 0)))
511
+			for(i = 0; def[i].name; i++)
519 512
 				rpc->rpl_printf(c, "%.*s: %s", gname.len, gname.s, def[i].name);
520 513
 }
521 514
 
522
-static const char* rpc_diff_doc[2] = {
523
-        "List the pending configuration changes that have not been committed yet",
524
-        0
525
-};
515
+static const char *rpc_diff_doc[2] = {"List the pending configuration changes "
516
+									  "that have not been committed yet",
517
+		0};
526 518
 
527
-static void rpc_diff(rpc_t* rpc, void* c)
519
+static void rpc_diff(rpc_t *rpc, void *c)
528 520
 {
529
-	void		*h;
530
-	str		gname, vname;
531
-	unsigned int	*gid;
532
-	void		*old_val, *new_val;
533
-	unsigned int	val_type;
534
-	void		*rpc_handle;
535
-	int		err;
521
+	void *h;
522
+	str gname, vname;
523
+	unsigned int *gid;
524
+	void *old_val, *new_val;
525
+	unsigned int val_type;
526
+	void *rpc_handle;
527
+	int err;
536 528
 
537 529
 
538
-	if (cfg_diff_init(ctx, &h)) {
530
+	if(cfg_diff_init(ctx, &h)) {
539 531
 		rpc->fault(c, 400, "Failed to get the changes");
540 532
 		return;
541 533
 	}
542
-	while((err = cfg_diff_next(&h,
543
-			&gname, &gid, &vname,
544
-			&old_val, &new_val,
545
-			&val_type)) > 0
546
-	) {
534
+	while((err = cfg_diff_next(
535
+				   &h, &gname, &gid, &vname, &old_val, &new_val, &val_type))
536
+			> 0) {
547 537
 		rpc->add(c, "{", &rpc_handle);
548
-		if (gid)
549
-			rpc->struct_add(rpc_handle, "SdS",
550
-					"group name", &gname,
551
-					"group id", *gid,
552
-					"variable name", &vname);
538
+		if(gid)
539
+			rpc->struct_add(rpc_handle, "SdS", "group name", &gname, "group id",
540
+					*gid, "variable name", &vname);
553 541
 		else
554
-			rpc->struct_add(rpc_handle, "SS",
555
-					"group name", &gname,
542
+			rpc->struct_add(rpc_handle, "SS", "group name", &gname,
556 543
 					"variable name", &vname);
557 544
 
558
-		switch (val_type) {
559
-		case CFG_VAR_INT:
560
-			rpc->struct_add(rpc_handle, "dd",
561
-					"old value", (int)(long)old_val,
562
-					"new value", (int)(long)new_val);
563
-			break;
564
-
565
-		case CFG_VAR_STRING:
566
-			rpc->struct_add(rpc_handle, "ss",
567
-					"old value", (char *)old_val,
568
-					"new value", (char *)new_val);
569
-			break;
545
+		switch(val_type) {
546
+			case CFG_VAR_INT:
547
+				rpc->struct_add(rpc_handle, "dd", "old value",
548
+						(int)(long)old_val, "new value", (int)(long)new_val);
549
+				break;
570 550
 
571
-		case CFG_VAR_STR:
572
-			rpc->struct_add(rpc_handle, "SS",
573
-					"old value", (str *)old_val,
574
-					"new value", (str *)new_val);
575
-			break;
551
+			case CFG_VAR_STRING:
552
+				rpc->struct_add(rpc_handle, "ss", "old value", (char *)old_val,
553
+						"new value", (char *)new_val);
554
+				break;
576 555
 
577
-		case CFG_VAR_POINTER:
578
-			/* cannot print out pointer value with struct_add() */
579
-			break;
556
+			case CFG_VAR_STR:
557
+				rpc->struct_add(rpc_handle, "SS", "old value", (str *)old_val,
558
+						"new value", (str *)new_val);
559
+				break;
580 560
 
561
+			case CFG_VAR_POINTER:
562
+				/* cannot print out pointer value with struct_add() */
563
+				break;
581 564
 		}
582 565
 	}
583 566
 	cfg_diff_release(ctx);
584
-	if (err)
567
+	if(err)
585 568
 		rpc->fault(c, 400, "Failed to get the changes");
586 569
 }
587 570
 
588
-static const char* rpc_add_group_inst_doc[2] = {
589
-	"Add a new instance to an existing configuration group",
590
-	0
591
-};
571
+static const char *rpc_add_group_inst_doc[2] = {
572
+		"Add a new instance to an existing configuration group", 0};
592 573
 
593
-static void rpc_add_group_inst(rpc_t* rpc, void* c)
574
+static void rpc_add_group_inst(rpc_t *rpc, void *c)
594 575
 {