Browse code

alias_db: clang format the code

Daniel-Constantin Mierla authored on 26/10/2020 07:15:10
Showing 5 changed files
... ...
@@ -40,6 +40,8 @@
40 40
 MODULE_VERSION
41 41
 
42 42
 
43
+/* clang-format off */
44
+
43 45
 /* Module destroy function prototype */
44 46
 static void destroy(void);
45 47
 
... ...
@@ -119,23 +121,23 @@ struct module_exports exports = {
119 121
 	child_init,	/* per-child·init·function */
120 122
 	destroy		/* destroy function */
121 123
 };
124
+/* clang-format on */
122 125
 
123 126
 
124
-static int alias_flags_fixup(void** param)
127
+static int alias_flags_fixup(void **param)
125 128
 {
126 129
 	char *c;
127 130
 	unsigned int flags;
128 131
 
129
-	c = (char*)*param;
132
+	c = (char *)*param;
130 133
 	flags = 0;
131 134
 
132 135
 	if(alias_db_use_domain) {
133 136
 		flags |= ALIAS_DOMAIN_FLAG;
134 137
 	}
135 138
 
136
-	while (*c) {
137
-		switch (*c)
138
-		{
139
+	while(*c) {
140
+		switch(*c) {
139 141
 			case 'd':
140 142
 			case 'D':
141 143
 				flags &= ~ALIAS_DOMAIN_FLAG;
... ...
@@ -149,61 +151,58 @@ static int alias_flags_fixup(void** param)
149 151
 				flags |= ALIAS_DOMAIN_FLAG;
150 152
 				break;
151 153
 			default:
152
-				LM_ERR("unsupported flag '%c'\n",*c);
154
+				LM_ERR("unsupported flag '%c'\n", *c);
153 155
 				return -1;
154 156
 		}
155 157
 		c++;
156 158
 	}
157 159
 	pkg_free(*param);
158
-	*param = (void*)(unsigned long)flags;
160
+	*param = (void *)(unsigned long)flags;
159 161
 	return 0;
160 162
 }
161 163
 
162 164
 
163
-static int lookup_fixup(void** param, int param_no)
165
+static int lookup_fixup(void **param, int param_no)
164 166
 {
165
-	if (param_no==1)
166
-	{
167
+	if(param_no == 1) {
167 168
 		/* string or pseudo-var - table name */
168 169
 		return fixup_spve_null(param, 1);
169
-	} else if (param_no==2) {
170
+	} else if(param_no == 2) {
170 171
 		/* string - flags ? */
171 172
 		return alias_flags_fixup(param);
172 173
 	} else {
173
-		LM_CRIT(" invalid number of params %d \n",param_no);
174
+		LM_CRIT(" invalid number of params %d \n", param_no);
174 175
 		return -1;
175 176
 	}
176 177
 }
177 178
 
178 179
 
179
-static int find_fixup(void** param, int param_no)
180
+static int find_fixup(void **param, int param_no)
180 181
 {
181 182
 	pv_spec_t *sp;
182 183
 
183
-	if (param_no==1)
184
-	{
184
+	if(param_no == 1) {
185 185
 		/* string or pseudo-var - table name */
186 186
 		return fixup_spve_null(param, 1);
187
-	} else if(param_no==2) {
187
+	} else if(param_no == 2) {
188 188
 		/* pseudo-var - source URI */
189 189
 		return fixup_pvar_null(param, 1);
190
-	} else if(param_no==3) {
190
+	} else if(param_no == 3) {
191 191
 		/* pvar (AVP or VAR) - destination URI */
192
-		if (fixup_pvar_null(param, 1))
192
+		if(fixup_pvar_null(param, 1))
193 193
 			return E_CFG;
194
-		sp = (pv_spec_t*)*param;
195
-		if (sp->type!=PVT_AVP && sp->type!=PVT_SCRIPTVAR)
196
-		{
194
+		sp = (pv_spec_t *)*param;
195
+		if(sp->type != PVT_AVP && sp->type != PVT_SCRIPTVAR) {
197 196
 			LM_ERR("PV type %d (param 3) cannot be written\n", sp->type);
198 197
 			pv_spec_free(sp);
199 198
 			return E_CFG;
200 199
 		}
201 200
 		return 0;
202
-	} else if (param_no==4) {
201
+	} else if(param_no == 4) {
203 202
 		/* string - flags  ? */
204 203
 		return alias_flags_fixup(param);
205 204
 	} else {
206
-		LM_CRIT(" invalid number of params %d \n",param_no);
205
+		LM_CRIT(" invalid number of params %d \n", param_no);
207 206
 		return -1;
208 207
 	}
209 208
 }
... ...
@@ -214,17 +213,15 @@ static int find_fixup(void** param, int param_no)
214 213
  */
215 214
 static int child_init(int rank)
216 215
 {
217
-	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
216
+	if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
218 217
 		return 0; /* do nothing for the main process */
219 218
 
220 219
 	db_handle = adbf.init(&db_url);
221
-	if (!db_handle)
222
-	{
220
+	if(!db_handle) {
223 221
 		LM_ERR("unable to connect database\n");
224 222
 		return -1;
225 223
 	}
226 224
 	return 0;
227
-
228 225
 }
229 226
 
230 227
 
... ...
@@ -234,15 +231,13 @@ static int child_init(int rank)
234 231
 static int mod_init(void)
235 232
 {
236 233
 	/* Find a database module */
237
-	if (db_bind_mod(&db_url, &adbf))
238
-	{
234
+	if(db_bind_mod(&db_url, &adbf)) {
239 235
 		LM_ERR("unable to bind database module\n");
240 236
 		return -1;
241 237
 	}
242
-	if (!DB_CAPABILITY(adbf, DB_CAP_QUERY))
243
-	{
238
+	if(!DB_CAPABILITY(adbf, DB_CAP_QUERY)) {
244 239
 		LM_CRIT("database modules does not "
245
-			"provide all functions needed by alias_db module\n");
240
+				"provide all functions needed by alias_db module\n");
246 241
 		return -1;
247 242
 	}
248 243
 
... ...
@@ -255,13 +250,13 @@ static int mod_init(void)
255 250
  */
256 251
 static void destroy(void)
257 252
 {
258
-	if (db_handle) {
253
+	if(db_handle) {
259 254
 		adbf.close(db_handle);
260 255
 		db_handle = 0;
261 256
 	}
262 257
 }
263 258
 
264
-static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
259
+static int w_alias_db_lookup1(struct sip_msg *_msg, char *_table, char *p2)
265 260
 {
266 261
 	str table_s;
267 262
 	unsigned long flags;
... ...
@@ -271,7 +266,8 @@ static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
271 266
 		flags |= ALIAS_DOMAIN_FLAG;
272 267
 	}
273 268
 
274
-	if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
269
+	if(_table == NULL
270
+			|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
275 271
 		LM_ERR("invalid table parameter\n");
276 272
 		return -1;
277 273
 	}
... ...
@@ -279,20 +275,21 @@ static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
279 275
 	return alias_db_lookup_ex(_msg, table_s, flags);
280 276
 }
281 277
 
282
-static int w_alias_db_lookup2(struct sip_msg* _msg, char* _table, char* flags)
278
+static int w_alias_db_lookup2(struct sip_msg *_msg, char *_table, char *flags)
283 279
 {
284 280
 	str table_s;
285 281
 
286
-	if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
282
+	if(_table == NULL
283
+			|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
287 284
 		LM_ERR("invalid table parameter\n");
288
-        return -1;
285
+		return -1;
289 286
 	}
290 287
 
291 288
 	return alias_db_lookup_ex(_msg, table_s, (unsigned long)flags);
292 289
 }
293 290
 
294
-static int w_alias_db_find3(struct sip_msg* _msg, char* _table, char* _in,
295
-		char* _out)
291
+static int w_alias_db_find3(
292
+		struct sip_msg *_msg, char *_table, char *_in, char *_out)
296 293
 {
297 294
 	str table_s;
298 295
 	unsigned long flags;
... ...
@@ -302,20 +299,22 @@ static int w_alias_db_find3(struct sip_msg* _msg, char* _table, char* _in,
302 299
 		flags |= ALIAS_DOMAIN_FLAG;
303 300
 	}
304 301
 
305
-	if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
302
+	if(_table == NULL
303
+			|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
306 304
 		LM_ERR("invalid table parameter\n");
307 305
 		return -1;
308 306
 	}
309 307
 
310
-	return alias_db_find(_msg, table_s, _in, _out, (char*)flags);
308
+	return alias_db_find(_msg, table_s, _in, _out, (char *)flags);
311 309
 }
312 310
 
313
-static int w_alias_db_find4(struct sip_msg* _msg, char* _table, char* _in,
314
-		char* _out, char* flags)
311
+static int w_alias_db_find4(
312
+		struct sip_msg *_msg, char *_table, char *_in, char *_out, char *flags)
315 313
 {
316 314
 	str table_s;
317 315
 
318
-	if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
316
+	if(_table == NULL
317
+			|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
319 318
 		LM_ERR("invalid table parameter\n");
320 319
 		return -1;
321 320
 	}
... ...
@@ -325,8 +324,9 @@ static int w_alias_db_find4(struct sip_msg* _msg, char* _table, char* _in,
325 324
 
326 325
 int bind_alias_db(struct alias_db_binds *pxb)
327 326
 {
328
-	if (pxb == NULL) {
329
-		LM_WARN("bind_alias_db: Cannot load alias_db API into a NULL pointer\n");
327
+	if(pxb == NULL) {
328
+		LM_WARN("bind_alias_db: Cannot load alias_db API into a NULL "
329
+				"pointer\n");
330 330
 		return -1;
331 331
 	}
332 332
 
... ...
@@ -339,7 +339,7 @@ int bind_alias_db(struct alias_db_binds *pxb)
339 339
 /**
340 340
  *
341 341
  */
342
-static int ki_alias_db_lookup(sip_msg_t* msg, str* stable)
342
+static int ki_alias_db_lookup(sip_msg_t *msg, str *stable)
343 343
 {
344 344
 	unsigned long flags;
345 345
 
... ...
@@ -354,7 +354,7 @@ static int ki_alias_db_lookup(sip_msg_t* msg, str* stable)
354 354
 /**
355 355
  *
356 356
  */
357
-static int ki_alias_db_lookup_ex(sip_msg_t* msg, str* stable, str* sflags)
357
+static int ki_alias_db_lookup_ex(sip_msg_t *msg, str *stable, str *sflags)
358 358
 {
359 359
 	unsigned long flags;
360 360
 	int i;
... ...
@@ -363,9 +363,8 @@ static int ki_alias_db_lookup_ex(sip_msg_t* msg, str* stable, str* sflags)
363 363
 	if(alias_db_use_domain) {
364 364
 		flags |= ALIAS_DOMAIN_FLAG;
365 365
 	}
366
-	for(i=0; i<sflags->len; i++) {
367
-		switch (sflags->s[i])
368
-		{
366
+	for(i = 0; i < sflags->len; i++) {
367
+		switch(sflags->s[i]) {
369 368
 			case 'd':
370 369
 			case 'D':
371 370
 				flags &= ~ALIAS_DOMAIN_FLAG;
... ...
@@ -31,13 +31,13 @@
31 31
 
32 32
 /* Module parameters variables */
33 33
 
34
-extern str user_column;     /* 'username' column name */
35
-extern str domain_column;   /* 'domain' column name */
36
-extern str alias_user_column;     /* 'alias_username' column name */
37
-extern str alias_domain_column;   /* 'alias_domain' column name */
34
+extern str user_column;			/* 'username' column name */
35
+extern str domain_column;		/* 'domain' column name */
36
+extern str alias_user_column;	/* 'alias_username' column name */
37
+extern str alias_domain_column; /* 'alias_domain' column name */
38 38
 extern str domain_prefix;
39
-extern int ald_append_branches;  /* append branches after an alias lookup */
39
+extern int ald_append_branches; /* append branches after an alias lookup */
40 40
 
41
-extern db1_con_t* db_handle;   /* Database connection handle */
41
+extern db1_con_t *db_handle; /* Database connection handle */
42 42
 
43 43
 #endif /* _ALIAS_DB_H_ */
... ...
@@ -36,32 +36,30 @@
36 36
 #include "alias_db.h"
37 37
 #include "alookup.h"
38 38
 
39
-#define MAX_USERURI_SIZE	256
39
+#define MAX_USERURI_SIZE 256
40 40
 
41
-extern db_func_t adbf;  /* DB functions */
41
+extern db_func_t adbf; /* DB functions */
42 42
 
43 43
 extern int alias_db_use_domain;
44 44
 
45 45
 char useruri_buf[MAX_USERURI_SIZE];
46 46
 
47
-typedef int (*set_alias_f)(struct sip_msg* _msg, str *alias, int no, void *p);
47
+typedef int (*set_alias_f)(struct sip_msg *_msg, str *alias, int no, void *p);
48 48
 
49 49
 /**
50 50
  *
51 51
  */
52
-static int alias_db_query(struct sip_msg* _msg, str table,
53
-			struct sip_uri *puri, unsigned long flags,
54
-			set_alias_f set_alias, void *param)
52
+static int alias_db_query(struct sip_msg *_msg, str table, struct sip_uri *puri,
53
+		unsigned long flags, set_alias_f set_alias, void *param)
55 54
 {
56 55
 	str user_s;
57 56
 	db_key_t db_keys[2];
58 57
 	db_val_t db_vals[2];
59 58
 	db_key_t db_cols[2];
60
-	db1_res_t* db_res = NULL;
59
+	db1_res_t *db_res = NULL;
61 60
 	int i;
62 61
 
63
-	if (flags&ALIAS_REVERSE_FLAG)
64
-	{
62
+	if(flags & ALIAS_REVERSE_FLAG) {
65 63
 		/* revert lookup: user->alias */
66 64
 		db_keys[0] = &user_column;
67 65
 		db_keys[1] = &domain_column;
... ...
@@ -80,91 +78,87 @@ static int alias_db_query(struct sip_msg* _msg, str table,
80 78
 	db_vals[0].val.str_val.s = puri->user.s;
81 79
 	db_vals[0].val.str_val.len = puri->user.len;
82 80
 
83
-	if ( flags&ALIAS_DOMAIN_FLAG ) {
81
+	if(flags & ALIAS_DOMAIN_FLAG) {
84 82
 		db_vals[1].type = DB1_STR;
85 83
 		db_vals[1].nul = 0;
86 84
 		db_vals[1].val.str_val.s = puri->host.s;
87 85
 		db_vals[1].val.str_val.len = puri->host.len;
88 86
 
89
-		if (domain_prefix.s && domain_prefix.len>0
90
-				&& domain_prefix.len<puri->host.len
91
-				&& strncasecmp(puri->host.s,domain_prefix.s,
92
-				domain_prefix.len)==0)
93
-		{
94
-			db_vals[1].val.str_val.s   += domain_prefix.len;
87
+		if(domain_prefix.s && domain_prefix.len > 0
88
+				&& domain_prefix.len < puri->host.len
89
+				&& strncasecmp(puri->host.s, domain_prefix.s, domain_prefix.len)
90
+						   == 0) {
91
+			db_vals[1].val.str_val.s += domain_prefix.len;
95 92
 			db_vals[1].val.str_val.len -= domain_prefix.len;
96 93
 		}
97 94
 	}
98 95
 
99 96
 	adbf.use_table(db_handle, &table);
100
-	if(adbf.query( db_handle, db_keys, NULL, db_vals, db_cols,
101
-			(flags&ALIAS_DOMAIN_FLAG)?2:1 /*no keys*/, 2 /*no cols*/,
102
-			NULL, &db_res)!=0 || db_res==NULL)
103
-	{
97
+	if(adbf.query(db_handle, db_keys, NULL, db_vals, db_cols,
98
+			   (flags & ALIAS_DOMAIN_FLAG) ? 2 : 1 /*no keys*/, 2 /*no cols*/,
99
+			   NULL, &db_res)
100
+					!= 0
101
+			|| db_res == NULL) {
104 102
 		LM_ERR("failed to query database\n");
105 103
 		goto err_server;
106 104
 	}
107 105
 
108
-	if (RES_ROW_N(db_res)<=0 || RES_ROWS(db_res)[0].values[0].nul != 0)
109
-	{
106
+	if(RES_ROW_N(db_res) <= 0 || RES_ROWS(db_res)[0].values[0].nul != 0) {
110 107
 		LM_DBG("no alias found for R-URI\n");
111 108
 		goto err_server;
112 109
 	}
113 110
 
114 111
 	memcpy(useruri_buf, "sip:", 4);
115
-	for(i=0; i<RES_ROW_N(db_res); i++)
116
-	{
112
+	for(i = 0; i < RES_ROW_N(db_res); i++) {
117 113
 		user_s.len = 4;
118
-		user_s.s = useruri_buf+4;
119
-		switch(RES_ROWS(db_res)[i].values[0].type)
120
-		{ 
114
+		user_s.s = useruri_buf + 4;
115
+		switch(RES_ROWS(db_res)[i].values[0].type) {
121 116
 			case DB1_STRING:
122
-				strcpy(user_s.s, 
123
-					(char*)RES_ROWS(db_res)[i].values[0].val.string_val);
117
+				strcpy(user_s.s,
118
+						(char *)RES_ROWS(db_res)[i].values[0].val.string_val);
124 119
 				user_s.len += strlen(user_s.s);
125
-			break;
120
+				break;
126 121
 			case DB1_STR:
127
-				strncpy(user_s.s, 
128
-					(char*)RES_ROWS(db_res)[i].values[0].val.str_val.s,
129
-					RES_ROWS(db_res)[i].values[0].val.str_val.len);
122
+				strncpy(user_s.s,
123
+						(char *)RES_ROWS(db_res)[i].values[0].val.str_val.s,
124
+						RES_ROWS(db_res)[i].values[0].val.str_val.len);
130 125
 				user_s.len += RES_ROWS(db_res)[i].values[0].val.str_val.len;
131
-			break;
126
+				break;
132 127
 			case DB1_BLOB:
133
-				strncpy(user_s.s, 
134
-					(char*)RES_ROWS(db_res)[i].values[0].val.blob_val.s,
135
-					RES_ROWS(db_res)[i].values[0].val.blob_val.len);
128
+				strncpy(user_s.s,
129
+						(char *)RES_ROWS(db_res)[i].values[0].val.blob_val.s,
130
+						RES_ROWS(db_res)[i].values[0].val.blob_val.len);
136 131
 				user_s.len += RES_ROWS(db_res)[i].values[0].val.blob_val.len;
137
-			break;
132
+				break;
138 133
 			default:
139 134
 				LM_ERR("unknown type of DB user column\n");
140 135
 				goto err_server;
141 136
 		}
142
-	
137
+
143 138
 		/* add the @*/
144 139
 		useruri_buf[user_s.len] = '@';
145 140
 		user_s.len++;
146
-	
141
+
147 142
 		/* add the domain */
148
-		user_s.s = useruri_buf+user_s.len;
149
-		switch(RES_ROWS(db_res)[i].values[1].type)
150
-		{ 
143
+		user_s.s = useruri_buf + user_s.len;
144
+		switch(RES_ROWS(db_res)[i].values[1].type) {
151 145
 			case DB1_STRING:
152
-				strcpy(user_s.s, 
153
-					(char*)RES_ROWS(db_res)[i].values[1].val.string_val);
146
+				strcpy(user_s.s,
147
+						(char *)RES_ROWS(db_res)[i].values[1].val.string_val);
154 148
 				user_s.len += strlen(user_s.s);
155
-			break;
149
+				break;
156 150
 			case DB1_STR:
157
-				strncpy(user_s.s, 
158
-					(char*)RES_ROWS(db_res)[i].values[1].val.str_val.s,
159
-					RES_ROWS(db_res)[i].values[1].val.str_val.len);
151
+				strncpy(user_s.s,
152
+						(char *)RES_ROWS(db_res)[i].values[1].val.str_val.s,
153
+						RES_ROWS(db_res)[i].values[1].val.str_val.len);
160 154
 				user_s.len += RES_ROWS(db_res)[i].values[1].val.str_val.len;
161
-			break;
155
+				break;
162 156
 			case DB1_BLOB:
163
-				strncpy(user_s.s, 
164
-					(char*)RES_ROWS(db_res)[i].values[1].val.blob_val.s,
165
-					RES_ROWS(db_res)[i].values[1].val.blob_val.len);
157
+				strncpy(user_s.s,
158
+						(char *)RES_ROWS(db_res)[i].values[1].val.blob_val.s,
159
+						RES_ROWS(db_res)[i].values[1].val.blob_val.len);
166 160
 				user_s.len += RES_ROWS(db_res)[i].values[1].val.blob_val.len;
167
-			break;
161
+				break;
168 162
 			default:
169 163
 				LM_ERR("unknown type of DB user column\n");
170 164
 				goto err_server;
... ...
@@ -172,8 +166,8 @@ static int alias_db_query(struct sip_msg* _msg, str table,
172 166
 		useruri_buf[user_s.len] = '\0';
173 167
 		user_s.s = useruri_buf;
174 168
 		/* set the URI */
175
-		LM_DBG("new URI [%d] is [%.*s]\n", i, user_s.len ,user_s.s );
176
-		if (set_alias(_msg, &user_s, i, param)!=0) {
169
+		LM_DBG("new URI [%d] is [%.*s]\n", i, user_s.len, user_s.s);
170
+		if(set_alias(_msg, &user_s, i, param) != 0) {
177 171
 			LM_ERR("error while setting alias\n");
178 172
 			goto err_server;
179 173
 		}
... ...
@@ -182,14 +176,14 @@ static int alias_db_query(struct sip_msg* _msg, str table,
182 176
 	/**
183 177
 	 * Free the DB result
184 178
 	 */
185
-	if (adbf.free_result(db_handle, db_res) < 0) {
179
+	if(adbf.free_result(db_handle, db_res) < 0) {
186 180
 		LM_DBG("failed to freeing result of query\n");
187 181
 	}
188 182
 
189 183
 	return 1;
190 184
 
191 185
 err_server:
192
-	if (db_res!=NULL) {
186
+	if(db_res != NULL) {
193 187
 		if(adbf.free_result(db_handle, db_res) < 0) {
194 188
 			LM_DBG("failed to freeing result of query\n");
195 189
 		}
... ...
@@ -197,19 +191,16 @@ err_server:
197 191
 	return -1;
198 192
 }
199 193
 
200
-int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
194
+int set_alias_to_ruri(struct sip_msg *_msg, str *alias, int no, void *p)
201 195
 {
202 196
 	/* set the RURI */
203
-	if(no==0)
204
-	{
205
-		if(rewrite_uri(_msg, alias)<0)
206
-		{
197
+	if(no == 0) {
198
+		if(rewrite_uri(_msg, alias) < 0) {
207 199
 			LM_ERR("cannot replace the R-URI\n");
208 200
 			return -1;
209 201
 		}
210
-	} else if (ald_append_branches) {
211
-		if (append_branch(_msg, alias, 0, 0, MIN_Q, 0, 0, 0, 0, 0, 0) == -1)
212
-		{
202
+	} else if(ald_append_branches) {
203
+		if(append_branch(_msg, alias, 0, 0, MIN_Q, 0, 0, 0, 0, 0, 0) == -1) {
213 204
 			LM_ERR("error while appending branches\n");
214 205
 			return -1;
215 206
 		}
... ...
@@ -218,26 +209,27 @@ int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
218 209
 }
219 210
 
220 211
 
221
-int alias_db_lookup_ex(struct sip_msg* _msg, str table, unsigned long flags)
212
+int alias_db_lookup_ex(struct sip_msg *_msg, str table, unsigned long flags)
222 213
 {
223
-	if (parse_sip_msg_uri(_msg) < 0)
214
+	if(parse_sip_msg_uri(_msg) < 0)
224 215
 		return -1;
225 216
 
226
-	return alias_db_query(_msg, table, &_msg->parsed_uri, flags,
227
-			set_alias_to_ruri, NULL);
217
+	return alias_db_query(
218
+			_msg, table, &_msg->parsed_uri, flags, set_alias_to_ruri, NULL);
228 219
 }
229 220
 
230
-int alias_db_lookup(struct sip_msg* _msg, str table)
221
+int alias_db_lookup(struct sip_msg *_msg, str table)
231 222
 {
232 223
 	unsigned long flags = 0;
233
-	if(alias_db_use_domain) flags = ALIAS_DOMAIN_FLAG;
224
+	if(alias_db_use_domain)
225
+		flags = ALIAS_DOMAIN_FLAG;
234 226
 	return alias_db_lookup_ex(_msg, table, flags);
235 227
 }
236 228
 
237
-int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
229
+int set_alias_to_pvar(struct sip_msg *_msg, str *alias, int no, void *p)
238 230
 {
239 231
 	pv_value_t val;
240
-	pv_spec_t *pvs=(pv_spec_t*)p;
232
+	pv_spec_t *pvs = (pv_spec_t *)p;
241 233
 
242 234
 	if(no && !ald_append_branches)
243 235
 		return 0;
... ...
@@ -247,8 +239,7 @@ int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
247 239
 	val.ri = 0;
248 240
 	val.rs = *alias;
249 241
 
250
-	if(pv_set_spec_value(_msg, pvs, (int)(no?EQ_T:ASSIGN_T), &val)<0)
251
-	{
242
+	if(pv_set_spec_value(_msg, pvs, (int)(no ? EQ_T : ASSIGN_T), &val) < 0) {
252 243
 		LM_ERR("setting PV AVP failed\n");
253 244
 		return -1;
254 245
 	}
... ...
@@ -256,30 +247,26 @@ int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
256 247
 }
257 248
 
258 249
 
259
-int alias_db_find(struct sip_msg* _msg, str table, char* _in, char* _out,
260
-	char* flags)
250
+int alias_db_find(
251
+		struct sip_msg *_msg, str table, char *_in, char *_out, char *flags)
261 252
 {
262 253
 	pv_value_t val;
263 254
 	struct sip_uri puri;
264 255
 
265 256
 	/* get the input value */
266
-	if (pv_get_spec_value(_msg, (pv_spec_t*)_in, &val)!=0)
267
-	{
257
+	if(pv_get_spec_value(_msg, (pv_spec_t *)_in, &val) != 0) {
268 258
 		LM_ERR("failed to get PV value\n");
269 259
 		return -1;
270 260
 	}
271
-	if ( (val.flags&PV_VAL_STR)==0 )
272
-	{
261
+	if((val.flags & PV_VAL_STR) == 0) {
273 262
 		LM_ERR("PV vals is not string\n");
274 263
 		return -1;
275 264
 	}
276
-	if (parse_uri(val.rs.s, val.rs.len, &puri)<0)
277
-	{
278
-		LM_ERR("failed to parse uri %.*s\n",val.rs.len,val.rs.s);
265
+	if(parse_uri(val.rs.s, val.rs.len, &puri) < 0) {
266
+		LM_ERR("failed to parse uri %.*s\n", val.rs.len, val.rs.s);
279 267
 		return -1;
280 268
 	}
281 269
 
282
-	return alias_db_query(_msg, table, &puri, (unsigned long)flags,
283
-			set_alias_to_pvar, _out);
270
+	return alias_db_query(
271
+			_msg, table, &puri, (unsigned long)flags, set_alias_to_pvar, _out);
284 272
 }
285
-
... ...
@@ -27,12 +27,12 @@
27 27
 
28 28
 #include "../../core/parser/msg_parser.h"
29 29
 
30
-#define ALIAS_REVERSE_FLAG	(1<<0)
31
-#define ALIAS_DOMAIN_FLAG	(1<<1)
30
+#define ALIAS_REVERSE_FLAG (1 << 0)
31
+#define ALIAS_DOMAIN_FLAG (1 << 1)
32 32
 
33
-int alias_db_lookup(struct sip_msg* _msg, str _table);
34
-int alias_db_lookup_ex(struct sip_msg* _msg, str _table, unsigned long flags);
35
-int alias_db_find(struct sip_msg* _msg, str _table, char* _in, char* _out,
36
-		char* flags);
33
+int alias_db_lookup(struct sip_msg *_msg, str _table);
34
+int alias_db_lookup_ex(struct sip_msg *_msg, str _table, unsigned long flags);
35
+int alias_db_find(
36
+		struct sip_msg *_msg, str _table, char *_in, char *_out, char *flags);
37 37
 
38 38
 #endif /* _ALOOKUP_H_ */
... ...
@@ -26,25 +26,29 @@
26 26
 
27 27
 #include "../../core/str.h"
28 28
 
29
-typedef int (*alias_db_lookup_t)(sip_msg_t*, str table);
30
-typedef int (*alias_db_lookup_ex_t)(sip_msg_t*, str table, unsigned long flags);
31
-typedef int (*alias_db_find_t)(sip_msg_t*, str table, char* _in, char* _out, char *flags);
29
+typedef int (*alias_db_lookup_t)(sip_msg_t *, str table);
30
+typedef int (*alias_db_lookup_ex_t)(
31
+		sip_msg_t *, str table, unsigned long flags);
32
+typedef int (*alias_db_find_t)(
33
+		sip_msg_t *, str table, char *_in, char *_out, char *flags);
32 34
 
35
+/* clang-format off */
33 36
 typedef struct alias_db_binds {
34 37
 	alias_db_lookup_t alias_db_lookup;
35 38
 	alias_db_lookup_ex_t alias_db_lookup_ex;
36 39
 	alias_db_find_t alias_db_find;
37 40
 } alias_db_api_t;
41
+/* clang-format on */
38 42
 
39
-typedef int (*bind_alias_db_f)(alias_db_api_t*);
43
+typedef int (*bind_alias_db_f)(alias_db_api_t *);
40 44
 
41
-int bind_alias_db(struct alias_db_binds*);
45
+int bind_alias_db(struct alias_db_binds *);
42 46
 
43 47
 inline static int alias_db_load_api(alias_db_api_t *pxb)
44 48
 {
45 49
 	bind_alias_db_f bind_alias_db_exports;
46
-	if (!(bind_alias_db_exports = (bind_alias_db_f)find_export("bind_alias_db", 1, 0)))
47
-	{
50
+	if(!(bind_alias_db_exports =
51
+					   (bind_alias_db_f)find_export("bind_alias_db", 1, 0))) {
48 52
 		LM_ERR("Failed to import bind_alias_db\n");
49 53
 		return -1;
50 54
 	}