Przeglądaj źródła

xprint: clang-format for coherent indentation and coding style

Victor Seva 2 lat temu
rodzic
commit
83b092fea9
3 zmienionych plików z 319 dodań i 339 usunięć
  1. 220 238
      src/modules/xprint/xp_lib.c
  2. 19 19
      src/modules/xprint/xp_lib.h
  3. 80 82
      src/modules/xprint/xprint.c

Plik diff jest za duży
+ 220 - 238
src/modules/xprint/xp_lib.c


+ 19 - 19
src/modules/xprint/xp_lib.h

@@ -28,8 +28,8 @@
 
 #include "../../core/parser/msg_parser.h"
 
-typedef int (*item_func_t) (struct sip_msg*, str*, str*, int, int);
-typedef void (*item_free_t) (str*);
+typedef int (*item_func_t)(struct sip_msg *, str *, str *, int, int);
+typedef void (*item_free_t)(str *);
 
 typedef struct _xl_elog
 {
@@ -44,29 +44,30 @@ typedef struct _xl_elog
 
 /* callback function to parse the regular expression
  * back references */
-typedef int (*xl_parse_cb) (str *, int, xl_elog_p);
+typedef int (*xl_parse_cb)(str *, int, xl_elog_p);
 
-typedef int (xl_elog_free_all_f)(xl_elog_p log);
+typedef int(xl_elog_free_all_f)(xl_elog_p log);
 /* int xl_elog_free_all(xl_elog_p log); */
-typedef int (xl_parse_format_f)(char *s, xl_elog_p *el);
+typedef int(xl_parse_format_f)(char *s, xl_elog_p *el);
 //int xl_parse_format(char *s, xl_elog_p *el);
-typedef int (xl_parse_format2_f)(char *s, xl_elog_p *el, xl_parse_cb cb);
-typedef int (xl_print_log_f)(struct sip_msg*, xl_elog_t*, char*, int*);
+typedef int(xl_parse_format2_f)(char *s, xl_elog_p *el, xl_parse_cb cb);
+typedef int(xl_print_log_f)(struct sip_msg *, xl_elog_t *, char *, int *);
 //int xl_print_log(struct sip_msg* msg, xl_elog_p log, char *buf, int *len);
-typedef str* (xl_get_nulstr_f)(void);
+typedef str *(xl_get_nulstr_f)(void);
 
-typedef struct xl_api {
-	xl_print_log_f		*xprint;
-	xl_parse_format_f	*xparse;
-	xl_parse_format_f	*shm_xparse;
-	xl_parse_format2_f	*xparse2;
-	xl_parse_format2_f	*shm_xparse2;
-	xl_elog_free_all_f	*xfree;
-	xl_elog_free_all_f	*shm_xfree;
-	xl_get_nulstr_f		*xnulstr;
+typedef struct xl_api
+{
+	xl_print_log_f *xprint;
+	xl_parse_format_f *xparse;
+	xl_parse_format_f *shm_xparse;
+	xl_parse_format2_f *xparse2;
+	xl_parse_format2_f *shm_xparse2;
+	xl_elog_free_all_f *xfree;
+	xl_elog_free_all_f *shm_xfree;
+	xl_get_nulstr_f *xnulstr;
 } xl_api_t;
 
-typedef int (xl_bind_f)(xl_api_t *xl_api);
+typedef int(xl_bind_f)(xl_api_t *xl_api);
 
 /* bind to the xl_lib api */
 xl_bind_f xl_bind;
@@ -88,4 +89,3 @@ xl_get_nulstr_f xl_get_nulstr;
 int xl_mod_init();
 int xl_child_init(int);
 #endif
-

+ 80 - 82
src/modules/xprint/xprint.c

@@ -46,54 +46,50 @@ MODULE_VERSION
 char *log_buf = NULL;
 
 /** parameters */
-int buf_size=4096;
+int buf_size = 4096;
 
 /** module functions */
 static int mod_init(void);
 static int child_init(int);
 
-static int xplog(struct sip_msg*, char*, char*);
-static int xpdbg(struct sip_msg*, char*, char*);
+static int xplog(struct sip_msg *, char *, char *);
+static int xpdbg(struct sip_msg *, char *, char *);
 
-static int xplog_fixup(void** param, int param_no);
-static int xpdbg_fixup(void** param, int param_no);
+static int xplog_fixup(void **param, int param_no);
+static int xpdbg_fixup(void **param, int param_no);
 
 static void destroy(void);
 
-static cmd_export_t cmds[]={
-	{"xplog",  xplog,  2, xplog_fixup, 0, ANY_ROUTE},
-	{"xpdbg",  xpdbg,  1, xpdbg_fixup, 0, ANY_ROUTE},
-	{"xbind",	(cmd_function)xl_bind, NO_SCRIPT, 0, 0, 0},
-	{"xprint",	(cmd_function)xl_print_log, NO_SCRIPT, 0, 0, 0},
-	{"xparse",	(cmd_function)xl_parse_format, NO_SCRIPT, 0, 0, 0},
-	{"shm_xparse",	(cmd_function)xl_shm_parse_format, NO_SCRIPT, 0, 0, 0},
-	{"xparse2",	(cmd_function)xl_parse_format2, NO_SCRIPT, 0, 0, 0},
-	{"shm_xparse2",	(cmd_function)xl_shm_parse_format2, NO_SCRIPT, 0, 0, 0},
-	{"xfree",	(cmd_function)xl_elog_free_all, NO_SCRIPT, 0, 0, 0},
-	{"shm_xfree",	(cmd_function)xl_elog_shm_free_all, NO_SCRIPT, 0, 0, 0},
-	{"xnulstr",	(cmd_function)xl_get_nulstr, NO_SCRIPT, 0, 0, 0},
-	{0,0,0,0,0,0}
-};
+static cmd_export_t cmds[] = {{"xplog", xplog, 2, xplog_fixup, 0, ANY_ROUTE},
+		{"xpdbg", xpdbg, 1, xpdbg_fixup, 0, ANY_ROUTE},
+		{"xbind", (cmd_function)xl_bind, NO_SCRIPT, 0, 0, 0},
+		{"xprint", (cmd_function)xl_print_log, NO_SCRIPT, 0, 0, 0},
+		{"xparse", (cmd_function)xl_parse_format, NO_SCRIPT, 0, 0, 0},
+		{"shm_xparse", (cmd_function)xl_shm_parse_format, NO_SCRIPT, 0, 0, 0},
+		{"xparse2", (cmd_function)xl_parse_format2, NO_SCRIPT, 0, 0, 0},
+		{"shm_xparse2", (cmd_function)xl_shm_parse_format2, NO_SCRIPT, 0, 0, 0},
+		{"xfree", (cmd_function)xl_elog_free_all, NO_SCRIPT, 0, 0, 0},
+		{"shm_xfree", (cmd_function)xl_elog_shm_free_all, NO_SCRIPT, 0, 0, 0},
+		{"xnulstr", (cmd_function)xl_get_nulstr, NO_SCRIPT, 0, 0, 0},
+		{0, 0, 0, 0, 0, 0}};
 
 
-static param_export_t params[]={
-	{"buf_size",  PARAM_INT, &buf_size},
-	{0,0,0}
-};
+static param_export_t params[] = {
+		{"buf_size", PARAM_INT, &buf_size}, {0, 0, 0}};
 
 
 /** module exports */
-struct module_exports exports= {
-	"xprint",			/* module name */
-	DEFAULT_DLFLAGS,	/* dlopen flags */
-	cmds,				/* cmd (cfg function) exports */
-	params,				/* param exports */
-	0,					/* RPC method exports */
-	0,					/* pv exports */
-	0,					/* response handling function */
-	mod_init,			/* module init function */
-	child_init,			/* per-child init function */
-	destroy			/* module destroy function */
+struct module_exports exports = {
+		"xprint",		 /* module name */
+		DEFAULT_DLFLAGS, /* dlopen flags */
+		cmds,			 /* cmd (cfg function) exports */
+		params,			 /* param exports */
+		0,				 /* RPC method exports */
+		0,				 /* pv exports */
+		0,				 /* response handling function */
+		mod_init,		 /* module init function */
+		child_init,		 /* per-child init function */
+		destroy			 /* module destroy function */
 };
 
 /**
@@ -102,9 +98,8 @@ struct module_exports exports= {
 static int mod_init(void)
 {
 	DBG("initializing ...\n");
-	log_buf = (char*)pkg_malloc((buf_size+1)*sizeof(char));
-	if(log_buf==NULL)
-	{
+	log_buf = (char *)pkg_malloc((buf_size + 1) * sizeof(char));
+	if(log_buf == NULL) {
 		PKG_MEM_ERROR;
 		return -1;
 	}
@@ -123,22 +118,22 @@ static int child_init(int rank)
 
 /**
  */
-static int xplog(struct sip_msg* msg, char* lev, char* frm)
+static int xplog(struct sip_msg *msg, char *lev, char *frm)
 {
 	int log_len, level;
 
-	if (get_int_fparam(&level, msg, (fparam_t *)lev)) {
+	if(get_int_fparam(&level, msg, (fparam_t *)lev)) {
 		LOG(L_ERR, "xplog: cannot get log level\n");
 		return -1;
 	}
-	if (level < L_ALERT)
+	if(level < L_ALERT)
 		level = L_ALERT;
-	else if (level > L_DBG)
+	else if(level > L_DBG)
 		level = L_DBG;
 
 	log_len = buf_size;
 
-	if(xl_print_log(msg, (xl_elog_t*)frm, log_buf, &log_len)<0)
+	if(xl_print_log(msg, (xl_elog_t *)frm, log_buf, &log_len) < 0)
 		return -1;
 
 	/* log_buf[log_len] = '\0'; */
@@ -149,13 +144,13 @@ static int xplog(struct sip_msg* msg, char* lev, char* frm)
 
 /**
  */
-static int xpdbg(struct sip_msg* msg, char* frm, char* str2)
+static int xpdbg(struct sip_msg *msg, char *frm, char *str2)
 {
 	int log_len;
 
 	log_len = buf_size;
 
-	if(xl_print_log(msg, (xl_elog_t*)frm, log_buf, &log_len)<0)
+	if(xl_print_log(msg, (xl_elog_t *)frm, log_buf, &log_len) < 0)
 		return -1;
 
 	/* log_buf[log_len] = '\0'; */
@@ -174,47 +169,56 @@ static void destroy(void)
 		pkg_free(log_buf);
 }
 
-static int xplog_fixup(void** param, int param_no)
+static int xplog_fixup(void **param, int param_no)
 {
 	int level;
-	fparam_t	*p;
+	fparam_t *p;
 
-	if(param_no==1)
-	{
-		if (*param == NULL) {
+	if(param_no == 1) {
+		if(*param == NULL) {
 			LOG(L_ERR, "xplog_fixup: NULL parameter\n");
 			return -1;
 		}
 
-		if ((((char*)(*param))[0] == '$')
-			|| (((char*)(*param))[0] == '@')
-		) {
+		if((((char *)(*param))[0] == '$') || (((char *)(*param))[0] == '@')) {
 			/* avp or select parameter */
 			return fixup_var_int_1(param, 1);
 		}
 
-		if(strlen((char*)(*param))<3)
-		{
+		if(strlen((char *)(*param)) < 3) {
 			LOG(L_ERR, "xplog_fixup: wrong log level\n");
 			return E_UNSPEC;
 		}
-		switch(((char*)(*param))[2])
-		{
-		case 'A': level = L_ALERT; break;
-		case 'C': level = L_CRIT; break;
-		case 'E': level = L_ERR; break;
-		case 'W': level = L_WARN; break;
-		case 'N': level = L_NOTICE; break;
-		case 'I': level = L_INFO; break;
-		case 'D': level = L_DBG; break;
-		default:
-			LOG(L_ERR, "xplog_fixup: unknown log level\n");
-			return E_UNSPEC;
+		switch(((char *)(*param))[2]) {
+			case 'A':
+				level = L_ALERT;
+				break;
+			case 'C':
+				level = L_CRIT;
+				break;
+			case 'E':
+				level = L_ERR;
+				break;
+			case 'W':
+				level = L_WARN;
+				break;
+			case 'N':
+				level = L_NOTICE;
+				break;
+			case 'I':
+				level = L_INFO;
+				break;
+			case 'D':
+				level = L_DBG;
+				break;
+			default:
+				LOG(L_ERR, "xplog_fixup: unknown log level\n");
+				return E_UNSPEC;
 		}
 		/* constant parameter, but the fparam structure
 		 * needs to be created */
-		p = (fparam_t*)pkg_malloc(sizeof(fparam_t));
-		if (!p) {
+		p = (fparam_t *)pkg_malloc(sizeof(fparam_t));
+		if(!p) {
 			PKG_MEM_ERROR;
 			return -1;
 		}
@@ -226,37 +230,31 @@ static int xplog_fixup(void** param, int param_no)
 		return 0;
 	}
 
-	if(param_no==2)
+	if(param_no == 2)
 		return xpdbg_fixup(param, 1);
 
 	return 0;
 }
 
-static int xpdbg_fixup(void** param, int param_no)
+static int xpdbg_fixup(void **param, int param_no)
 {
 	xl_elog_t *model;
 
-	if(param_no==1)
-	{
-		if(*param)
-		{
-			if(xl_parse_format((char*)(*param), &model)<0)
-			{
+	if(param_no == 1) {
+		if(*param) {
+			if(xl_parse_format((char *)(*param), &model) < 0) {
 				LOG(L_ERR, "xpdbg_fixup: ERROR: wrong format[%s]\n",
-					(char*)(*param));
+						(char *)(*param));
 				return E_UNSPEC;
 			}
 
-			*param = (void*)model;
+			*param = (void *)model;
 			return 0;
-		}
-		else
-		{
+		} else {
 			LOG(L_ERR, "xpdbg_fixup: ERROR: null format\n");
 			return E_UNSPEC;
 		}
 	}
 
 	return 0;
-
 }

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików