Browse Source

secfilter: clang-format

Victor Seva 6 years ago
parent
commit
bfbbc23115

+ 2 - 1
src/modules/secfilter/secfilter.c

@@ -67,6 +67,7 @@ str secf_action_col = str_init("action");
 str secf_type_col = str_init("type");
 str secf_data_col = str_init("data");
 
+/* clang-format off */
 /* Exported commands */
 static cmd_export_t cmds[] = {
 		{"secf_check_ua", (cmd_function)w_check_ua, 0, 0, 0, ANY_ROUTE},
@@ -121,7 +122,7 @@ rpc_export_t secfilter_rpc[] = {
 		{"secfilter.add_dst", rpc_add_dst, rpc_add_dst_doc, 0},
 		{"secfilter.add_bl", rpc_add_bl, rpc_add_bl_doc, 0},
 		{"secfilter.add_wl", rpc_add_wl, rpc_add_wl_doc, 0}, {0, 0, 0, 0}};
-
+/* clang-format on */
 
 /***
 PREVENT SQL INJECTION

+ 4 - 2
src/modules/secfilter/secfilter_db.c

@@ -216,7 +216,8 @@ int append_rule(int action, int type, str *value)
 		LM_ERR("can't append new node\n");
 		return -1;
 	}
-	LM_DBG("new node[%p] str:'%.*s'[%d]\n", new, new->s.len, new->s.s, new->s.len);
+	LM_DBG("new node[%p] str:'%.*s'[%d]\n", new, new->s.len, new->s.s,
+			new->s.len);
 
 	*last_node = new;
 	if(!*ini_node) {
@@ -277,7 +278,8 @@ int load_db(void)
 		type = (int)RES_ROWS(db_res)[i].values[1].val.int_val;
 		str_data.s = (char *)RES_ROWS(db_res)[i].values[2].val.string_val;
 		str_data.len = strlen(str_data.s);
-		LM_DBG("[%d] append_rule for action:%d type:%d data:%.*s\n",i, action, type, str_data.len, str_data.s);
+		LM_DBG("[%d] append_rule for action:%d type:%d data:%.*s\n", i, action,
+				type, str_data.len, str_data.s);
 
 		if(append_rule(action, type, &str_data) < 0) {
 			LM_ERR("Can't append_rule with action:%d type:%d\n", action, type);

+ 27 - 30
src/modules/secfilter/secfilter_rpc.c

@@ -61,27 +61,25 @@ void rpc_add_dst(rpc_t *rpc, void *ctx)
 	char *text = NULL;
 
 	if(rpc->scan(ctx, "d", &number) < 1) {
-		rpc->fault(ctx, 0, "Invalid Parameters. Usage: secfilter.add_dst "
-						   "number\n     Example: secfilter.add_dst "
-						   "555123123");
+		rpc->fault(ctx, 0,
+				"Invalid Parameters. Usage: secfilter.add_dst "
+				"number\n     Example: secfilter.add_dst "
+				"555123123");
 	} else {
 		text = int2str(number, &data.len);
-		data.s = pkg_malloc(data.len*sizeof(char));
-		if(!data.s){
+		data.s = pkg_malloc(data.len * sizeof(char));
+		if(!data.s) {
 			PKG_MEM_ERROR;
-			rpc->rpl_printf(ctx,
-					"Error insert values in the blacklist");
+			rpc->rpl_printf(ctx, "Error insert values in the blacklist");
 			return;
 		}
 		memcpy(data.s, text, data.len);
 		lock_get(&secf_data->lock);
-		if (append_rule(2, 0, &data) == 0) {
+		if(append_rule(2, 0, &data) == 0) {
 			rpc->rpl_printf(ctx,
-					"Values (%s) inserted into blacklist destinations",
-					data);
+					"Values (%s) inserted into blacklist destinations", data);
 		} else {
-			rpc->rpl_printf(ctx,
-					"Error insert values in the blacklist");
+			rpc->rpl_printf(ctx, "Error insert values in the blacklist");
 		}
 		lock_release(&secf_data->lock);
 		if(data.s)
@@ -97,18 +95,18 @@ void rpc_add_bl(rpc_t *rpc, void *ctx)
 	int type;
 
 	if(rpc->scan(ctx, "ss", (char *)(&ctype), (char *)(&data.s)) < 2) {
-		rpc->fault(ctx, 0, "Invalid Parameters. Usage: secfilter.add_bl type "
-						   "value\n     Example: secfilter.add_bl user "
-						   "sipvicious");
+		rpc->fault(ctx, 0,
+				"Invalid Parameters. Usage: secfilter.add_bl type "
+				"value\n     Example: secfilter.add_bl user "
+				"sipvicious");
 	} else {
 		data.len = strlen(data.s);
 		type = get_type(ctype);
-		
+
 		lock_get(&secf_data->lock);
-		if (append_rule(0, type, &data) == 0) {
-			rpc->rpl_printf(ctx,
-					"Values (%s, %s) inserted into blacklist", ctype,
-					data);
+		if(append_rule(0, type, &data) == 0) {
+			rpc->rpl_printf(ctx, "Values (%s, %s) inserted into blacklist",
+					ctype, data);
 		} else {
 			rpc->rpl_printf(ctx, "Error insert values in the blacklist");
 		}
@@ -125,18 +123,18 @@ void rpc_add_wl(rpc_t *rpc, void *ctx)
 	int type;
 
 	if(rpc->scan(ctx, "ss", (char *)(&ctype), (char *)(&data.s)) < 2) {
-		rpc->fault(ctx, 0, "Invalid Parameters. Usage: secfilter.add_wl type "
-						   "value\n     Example: secfilter.add_wl user "
-						   "trusted_user");
+		rpc->fault(ctx, 0,
+				"Invalid Parameters. Usage: secfilter.add_wl type "
+				"value\n     Example: secfilter.add_wl user "
+				"trusted_user");
 	} else {
 		data.len = strlen(data.s);
 		type = get_type(ctype);
-		
+
 		lock_get(&secf_data->lock);
-		if (append_rule(1, type, &data) == 0) {
-			rpc->rpl_printf(ctx,
-					"Values (%s, %s) inserted into whitelist", type,
-					data);
+		if(append_rule(1, type, &data) == 0) {
+			rpc->rpl_printf(
+					ctx, "Values (%s, %s) inserted into whitelist", type, data);
 		} else {
 			rpc->rpl_printf(ctx, "Error insert values in the whitelist");
 		}
@@ -153,8 +151,7 @@ void rpc_reload(rpc_t *rpc, void *ctx)
 	if(load_db() == -1) {
 		LM_ERR("Error loading data from database\n");
 		rpc->rpl_printf(ctx, "Error loading data from database");
-	}
-	else {
+	} else {
 		rpc->rpl_printf(ctx, "Data reloaded");
 	}
 }