Ver Fonte

xcap_client: clang-format for coherent indentation and coding style

Victor Seva há 2 anos atrás
pai
commit
ce9cd3132b

+ 17 - 21
src/modules/xcap_client/xcap_callbacks.c

@@ -29,35 +29,32 @@
 #include "xcap_callbacks.h"
 #include "xcap_client.h"
 
-void run_xcap_update_cb(int type, str xid, char* stream)
+void run_xcap_update_cb(int type, str xid, char *stream)
 {
-	xcap_callback_t* cb;
+	xcap_callback_t *cb;
 
-	for (cb= xcapcb_list; cb; cb=cb->next)
-	{
-		if(cb->types & type)
-		{
+	for(cb = xcapcb_list; cb; cb = cb->next) {
+		if(cb->types & type) {
 			LM_DBG("found callback\n");
 			cb->callback(type, xid, stream);
 		}
 	}
 }
 
-int register_xcapcb( int types, xcap_cb f)
+int register_xcapcb(int types, xcap_cb f)
 {
-	xcap_callback_t* xcb;
+	xcap_callback_t *xcb;
 
-	xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t));
-	if(xcb== NULL)
-	{
+	xcb = (xcap_callback_t *)shm_malloc(sizeof(xcap_callback_t));
+	if(xcb == NULL) {
 		ERR_MEM(SHARE_MEM);
 	}
 	memset(xcb, 0, sizeof(xcap_callback_t));
 
-	xcb->callback= f;
-	xcb->types= types;
-	xcb->next= xcapcb_list;
-	xcapcb_list= xcb;
+	xcb->callback = f;
+	xcb->types = types;
+	xcb->next = xcapcb_list;
+	xcapcb_list = xcb;
 	return 0;
 
 error:
@@ -66,13 +63,12 @@ error:
 
 void destroy_xcapcb_list(void)
 {
-	xcap_callback_t* xcb, *prev_xcb;
+	xcap_callback_t *xcb, *prev_xcb;
 
-	xcb= xcapcb_list;
-	while(xcb)
-	{
-		prev_xcb= xcb;
-		xcb= xcb->next;
+	xcb = xcapcb_list;
+	while(xcb) {
+		prev_xcb = xcb;
+		xcb = xcb->next;
 		shm_free(prev_xcb);
 	}
 }

+ 18 - 17
src/modules/xcap_client/xcap_callbacks.h

@@ -26,36 +26,37 @@
 
 #include "../../core/str.h"
 
-#define PRES_RULES         1<<1
-#define RESOURCE_LIST      1<<2
-#define RLS_SERVICE        1<<3
-#define PIDF_MANIPULATION  1<<4
-#define XCAP_CAPS          1<<5
-#define USER_PROFILE       1<<6
-#define PRES_CONTENT       1<<7
-#define SEARCH             1<<8
-#define DIRECTORY          1<<9
+#define PRES_RULES 1 << 1
+#define RESOURCE_LIST 1 << 2
+#define RLS_SERVICE 1 << 3
+#define PIDF_MANIPULATION 1 << 4
+#define XCAP_CAPS 1 << 5
+#define USER_PROFILE 1 << 6
+#define PRES_CONTENT 1 << 7
+#define SEARCH 1 << 8
+#define DIRECTORY 1 << 9
 
 /* callback function prototype */
-typedef int (xcap_cb)(int doc_type, str xid, char* doc);
+typedef int(xcap_cb)(int doc_type, str xid, char *doc);
 
 /* register callback function prototype */
 typedef int (*register_xcapcb_t)(int types, xcap_cb f);
 
 
-typedef struct xcap_callback {
-	int types;                   /* types of events that trigger the callback*/
-	xcap_cb* callback;            /* callback function */
-	struct xcap_callback* next;
-}xcap_callback_t;
+typedef struct xcap_callback
+{
+	int types;		   /* types of events that trigger the callback*/
+	xcap_cb *callback; /* callback function */
+	struct xcap_callback *next;
+} xcap_callback_t;
 
 /* destroy registered callback list */
 void destroy_xcapcb_list(void);
 
 /* register a callback for several types of events */
-int register_xcapcb( int types, xcap_cb f);
+int register_xcapcb(int types, xcap_cb f);
 
 /* run all transaction callbacks for a composed type */
-void run_xcap_update_cb(int type, str xid, char* stream);
+void run_xcap_update_cb(int type, str xid, char *stream);
 
 #endif

+ 114 - 133
src/modules/xcap_client/xcap_client.c

@@ -47,7 +47,7 @@
 
 MODULE_VERSION
 
-#define XCAP_TABLE_VERSION   4
+#define XCAP_TABLE_VERSION 4
 
 static int xcap_client_init_rpc(void);
 
@@ -57,9 +57,9 @@ static void destroy(void);
 int get_auid_flag(str auid);
 str xcap_db_table = str_init("xcap");
 str xcap_db_url = str_init(DEFAULT_DB_URL);
-xcap_callback_t* xcapcb_list= NULL;
-int periodical_query= 1;
-unsigned int query_period= 100;
+xcap_callback_t *xcapcb_list = NULL;
+int periodical_query = 1;
+unsigned int query_period = 100;
 
 str str_source_col = str_init("source");
 str str_path_col = str_init("path");
@@ -76,35 +76,29 @@ str str_port_col = str_init("port");
 db1_con_t *xcap_db = NULL;
 db_func_t xcap_dbf;
 
-void query_xcap_update(unsigned int ticks, void* param);
+void query_xcap_update(unsigned int ticks, void *param);
 
-static param_export_t params[]={
-	{ "db_url",					PARAM_STR,         &xcap_db_url    },
-	{ "xcap_table",				PARAM_STR,         &xcap_db_table  },
-	{ "periodical_query",		INT_PARAM,         &periodical_query },
-	{ "query_period",			INT_PARAM,         &query_period     },
-	{    0,                     0,                      0            }
-};
+static param_export_t params[] = {{"db_url", PARAM_STR, &xcap_db_url},
+		{"xcap_table", PARAM_STR, &xcap_db_table},
+		{"periodical_query", INT_PARAM, &periodical_query},
+		{"query_period", INT_PARAM, &query_period}, {0, 0, 0}};
 
 
-static cmd_export_t  cmds[]=
-{
-	{"bind_xcap",  (cmd_function)bind_xcap,  1,    0, 0,            0},
-	{    0,                     0,           0,    0, 0,           0}
-};
+static cmd_export_t cmds[] = {
+		{"bind_xcap", (cmd_function)bind_xcap, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0}};
 
 /** module exports */
-struct module_exports exports= {
-	"xcap_client",   /* module name */
-	DEFAULT_DLFLAGS, /* dlopen flags */
-	cmds,            /* exported functions */
-	params,          /* exported parameters */
-	0,               /* exported rpc functions */
-	0,               /* exported pseudo-variables */
-	0,               /* response handling function */
-	mod_init,        /* module init function */
-	child_init,      /* child init function */
-	destroy          /* module destroy function */
+struct module_exports exports = {
+		"xcap_client",	 /* module name */
+		DEFAULT_DLFLAGS, /* dlopen flags */
+		cmds,			 /* exported functions */
+		params,			 /* exported parameters */
+		0,				 /* exported rpc functions */
+		0,				 /* exported pseudo-variables */
+		0,				 /* response handling function */
+		mod_init,		 /* module init function */
+		child_init,		 /* child init function */
+		destroy			 /* module destroy function */
 };
 
 /**
@@ -112,34 +106,32 @@ struct module_exports exports= {
  */
 static int mod_init(void)
 {
-	if(xcap_client_init_rpc()<0)
-	{
+	if(xcap_client_init_rpc() < 0) {
 		LM_ERR("failed to register RPC commands\n");
 		return -1;
 	}
 
 	/* binding to mysql module  */
-	if (db_bind_mod(&xcap_db_url, &xcap_dbf))
-	{
+	if(db_bind_mod(&xcap_db_url, &xcap_dbf)) {
 		LM_ERR("Database module not found\n");
 		return -1;
 	}
 
-	if (!DB_CAPABILITY(xcap_dbf, DB_CAP_ALL)) {
+	if(!DB_CAPABILITY(xcap_dbf, DB_CAP_ALL)) {
 		LM_ERR("Database module does not implement all functions"
-				" needed by the module\n");
+			   " needed by the module\n");
 		return -1;
 	}
 
 	xcap_db = xcap_dbf.init(&xcap_db_url);
-	if (!xcap_db)
-	{
+	if(!xcap_db) {
 		LM_ERR("while connecting to database\n");
 		return -1;
 	}
 
-	if(db_check_table_version(&xcap_dbf, xcap_db, &xcap_db_table,
-				XCAP_TABLE_VERSION) < 0) {
+	if(db_check_table_version(
+			   &xcap_dbf, xcap_db, &xcap_db_table, XCAP_TABLE_VERSION)
+			< 0) {
 		DB_TABLE_VERSION_ERROR(xcap_db_table);
 		xcap_dbf.close(xcap_db);
 		xcap_db = NULL;
@@ -150,8 +142,7 @@ static int mod_init(void)
 
 	curl_global_init(CURL_GLOBAL_ALL);
 
-	if(periodical_query)
-	{
+	if(periodical_query) {
 		register_timer(query_xcap_update, 0, query_period);
 	}
 	return 0;
@@ -159,11 +150,10 @@ static int mod_init(void)
 
 static int child_init(int rank)
 {
-	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
+	if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
 		return 0; /* do nothing for the main process */
 
-	if((xcap_db = xcap_dbf.init(&xcap_db_url))==NULL)
-	{
+	if((xcap_db = xcap_dbf.init(&xcap_db_url)) == NULL) {
 		LM_ERR("cannot connect to db\n");
 		return -1;
 	}
@@ -177,18 +167,18 @@ static void destroy(void)
 		xcap_dbf.close(xcap_db);
 }
 
-void query_xcap_update(unsigned int ticks, void* param)
+void query_xcap_update(unsigned int ticks, void *param)
 {
 	db_key_t query_cols[3], update_cols[3];
 	db_val_t query_vals[3], update_vals[3];
 	db_key_t result_cols[7];
-	int n_result_cols = 0, n_query_cols= 0, n_update_cols= 0;
-	db1_res_t* result= NULL;
+	int n_result_cols = 0, n_query_cols = 0, n_update_cols = 0;
+	db1_res_t *result = NULL;
 	int user_col, domain_col, doc_type_col, etag_col, doc_uri_col, port_col;
 	db_row_t *row;
 	db_val_t *row_vals;
 	unsigned int port;
-	char* etag, *path, *new_etag= NULL, *doc= NULL;
+	char *etag, *path, *new_etag = NULL, *doc = NULL;
 	int u_doc_col, u_etag_col;
 	str user, domain, uri;
 	int i;
@@ -197,104 +187,97 @@ void query_xcap_update(unsigned int ticks, void* param)
 	query_cols[n_query_cols] = &str_source_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val= XCAP_CL_MOD;
+	query_vals[n_query_cols].val.int_val = XCAP_CL_MOD;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_path_col;
 	query_vals[n_query_cols].type = DB1_STR;
 	query_vals[n_query_cols].nul = 0;
 
-	update_cols[u_doc_col=n_update_cols] = &str_doc_col;
+	update_cols[u_doc_col = n_update_cols] = &str_doc_col;
 	update_vals[n_update_cols].type = DB1_STRING;
 	update_vals[n_update_cols].nul = 0;
 	n_update_cols++;
 
-	update_cols[u_etag_col=n_update_cols] = &str_etag_col;
+	update_cols[u_etag_col = n_update_cols] = &str_etag_col;
 	update_vals[n_update_cols].type = DB1_STRING;
 	update_vals[n_update_cols].nul = 0;
 	n_update_cols++;
 
-	result_cols[user_col= n_result_cols++]     = &str_username_col;
-	result_cols[domain_col=n_result_cols++]    = &str_domain_col;
-	result_cols[doc_type_col=n_result_cols++]  = &str_doc_type_col;
-	result_cols[etag_col=n_result_cols++]      = &str_etag_col;
-	result_cols[doc_uri_col= n_result_cols++]  = &str_doc_uri_col;
-	result_cols[port_col= n_result_cols++]     = &str_port_col;
+	result_cols[user_col = n_result_cols++] = &str_username_col;
+	result_cols[domain_col = n_result_cols++] = &str_domain_col;
+	result_cols[doc_type_col = n_result_cols++] = &str_doc_type_col;
+	result_cols[etag_col = n_result_cols++] = &str_etag_col;
+	result_cols[doc_uri_col = n_result_cols++] = &str_doc_uri_col;
+	result_cols[port_col = n_result_cols++] = &str_port_col;
 
-	if (xcap_dbf.use_table(xcap_db, &xcap_db_table) < 0)
-	{
-		LM_ERR("in use_table-[table]= %.*s\n", xcap_db_table.len, xcap_db_table.s);
+	if(xcap_dbf.use_table(xcap_db, &xcap_db_table) < 0) {
+		LM_ERR("in use_table-[table]= %.*s\n", xcap_db_table.len,
+				xcap_db_table.s);
 		goto error;
 	}
 
 	if(xcap_dbf.query(xcap_db, query_cols, 0, query_vals, result_cols, 1,
-				n_result_cols, 0, &result)< 0)
-	{
+			   n_result_cols, 0, &result)
+			< 0) {
 		LM_ERR("in sql query\n");
 		goto error;
 	}
-	if(result== NULL)
-	{
+	if(result == NULL) {
 		LM_ERR("in sql query- null result\n");
 		return;
 	}
-	if(result->n<= 0)
-	{
+	if(result->n <= 0) {
 		xcap_dbf.free_result(xcap_db, result);
 		return;
 	}
 	n_query_cols++;
 
 	/* ask if updated */
-	for(i= 0; i< result->n; i++)
-	{
+	for(i = 0; i < result->n; i++) {
 		row = &result->rows[i];
 		row_vals = ROW_VALUES(row);
 
-		path= (char*)row_vals[doc_uri_col].val.string_val;
-		port= row_vals[port_col].val.int_val;
-		etag= (char*)row_vals[etag_col].val.string_val;
+		path = (char *)row_vals[doc_uri_col].val.string_val;
+		port = row_vals[port_col].val.int_val;
+		etag = (char *)row_vals[etag_col].val.string_val;
 
-		user.s= (char*)row_vals[user_col].val.string_val;
-		user.len= strlen(user.s);
+		user.s = (char *)row_vals[user_col].val.string_val;
+		user.len = strlen(user.s);
 
-		domain.s= (char*)row_vals[domain_col].val.string_val;
-		domain.len= strlen(domain.s);
+		domain.s = (char *)row_vals[domain_col].val.string_val;
+		domain.len = strlen(domain.s);
 
 		/* send HTTP request */
-		doc= send_http_get(path, port, etag, IF_NONE_MATCH, &new_etag);
-		if(doc== NULL)
-		{
+		doc = send_http_get(path, port, etag, IF_NONE_MATCH, &new_etag);
+		if(doc == NULL) {
 			LM_DBG("document not update\n");
 			continue;
 		}
-		if(new_etag== NULL)
-		{
+		if(new_etag == NULL) {
 			LM_ERR("etag not found\n");
 			pkg_free(doc);
 			goto error;
 		}
 		/* update in xcap db table */
-		update_vals[u_doc_col].val.string_val= doc;
-		update_vals[u_etag_col].val.string_val= etag;
+		update_vals[u_doc_col].val.string_val = doc;
+		update_vals[u_etag_col].val.string_val = etag;
 
 		if(xcap_dbf.update(xcap_db, query_cols, 0, query_vals, update_cols,
-					update_vals, n_query_cols, n_update_cols)< 0)
-		{
+				   update_vals, n_query_cols, n_update_cols)
+				< 0) {
 			LM_ERR("in sql update\n");
 			pkg_free(doc);
 			goto error;
 		}
 		/* call registered callbacks */
-		if(uandd_to_uri(user, domain, &uri)< 0)
-		{
+		if(uandd_to_uri(user, domain, &uri) < 0) {
 			LM_ERR("converting user and domain to uri\n");
 			pkg_free(doc);
 			goto error;
 		}
 		run_xcap_update_cb(row_vals[doc_type_col].val.int_val, uri, doc);
 		pkg_free(doc);
-
 	}
 
 	xcap_dbf.free_result(xcap_db, result);
@@ -305,128 +288,126 @@ error:
 		xcap_dbf.free_result(xcap_db, result);
 }
 
-int parse_doc_url(str doc_url, char** serv_addr, xcap_doc_sel_t* doc_sel)
+int parse_doc_url(str doc_url, char **serv_addr, xcap_doc_sel_t *doc_sel)
 {
-	char* sl, *str_type;
+	char *sl, *str_type;
 
 	memset(doc_sel, 0, sizeof(xcap_doc_sel_t));
-	sl= strchr(doc_url.s, '/');
-	if(sl==NULL) {
+	sl = strchr(doc_url.s, '/');
+	if(sl == NULL) {
 		return -1;
 	}
-	*sl= '\0';
-	*serv_addr= doc_url.s;
+	*sl = '\0';
+	*serv_addr = doc_url.s;
 
 	sl++;
-	doc_sel->auid.s= sl;
-	sl= strchr(sl, '/');
-	if(sl==NULL) {
+	doc_sel->auid.s = sl;
+	sl = strchr(sl, '/');
+	if(sl == NULL) {
 		return -1;
 	}
-	doc_sel->auid.len= sl- doc_sel->auid.s;
+	doc_sel->auid.len = sl - doc_sel->auid.s;
 
 	sl++;
-	str_type= sl;
-	sl= strchr(sl, '/');
-	if(sl==NULL) {
+	str_type = sl;
+	sl = strchr(sl, '/');
+	if(sl == NULL) {
 		return -1;
 	}
-	*sl= '\0';
+	*sl = '\0';
 
-	if(strcasecmp(str_type, "users")== 0) {
-		doc_sel->type= USERS_TYPE;
-	} else if(strcasecmp(str_type, "group")== 0) {
-		doc_sel->type= GLOBAL_TYPE;
+	if(strcasecmp(str_type, "users") == 0) {
+		doc_sel->type = USERS_TYPE;
+	} else if(strcasecmp(str_type, "group") == 0) {
+		doc_sel->type = GLOBAL_TYPE;
 	}
 
 	sl++;
 
 	return 0;
-
 }
 /*
  * rpc cmd: refreshXcapDoc
  *			<document uri>
  *			<xcap_port>
  * */
-void xcap_client_rpc_refreshXcapDoc(rpc_t* rpc, void* ctx)
+void xcap_client_rpc_refreshXcapDoc(rpc_t *rpc, void *ctx)
 {
 	str doc_url;
 	xcap_doc_sel_t doc_sel;
-	char* serv_addr;
-	char* stream= NULL;
+	char *serv_addr;
+	char *stream = NULL;
 	int type;
 	unsigned int xcap_port;
-	char* etag= NULL;
+	char *etag = NULL;
 
-	if(rpc->scan(ctx, "S", &doc_url, (int*)(&xcap_port))<1) {
+	if(rpc->scan(ctx, "S", &doc_url, (int *)(&xcap_port)) < 1) {
 		LM_WARN("not enough parameters\n");
 		rpc->fault(ctx, 500, "Not enough parameters");
 		return;
 	}
 	/* send GET HTTP request to the server */
-	stream=	send_http_get(doc_url.s, xcap_port, NULL, 0, &etag);
-	if(stream== NULL) {
+	stream = send_http_get(doc_url.s, xcap_port, NULL, 0, &etag);
+	if(stream == NULL) {
 		LM_ERR("in http get\n");
 		rpc->fault(ctx, 500, "Failed http get");
 		return;
 	}
 
 	/* call registered functions with document argument */
-	if(parse_doc_url(doc_url, &serv_addr, &doc_sel)< 0) {
+	if(parse_doc_url(doc_url, &serv_addr, &doc_sel) < 0) {
 		LM_ERR("parsing document url\n");
-		if(stream) pkg_free(stream);
+		if(stream)
+			pkg_free(stream);
 		rpc->fault(ctx, 500, "Failed parsing url");
 		return;
 	}
 
-	type= get_auid_flag(doc_sel.auid);
-	if(type<0) {
-		LM_ERR("incorrect auid: %.*s\n",
-				doc_sel.auid.len, doc_sel.auid.s);
-		if(stream) pkg_free(stream);
+	type = get_auid_flag(doc_sel.auid);
+	if(type < 0) {
+		LM_ERR("incorrect auid: %.*s\n", doc_sel.auid.len, doc_sel.auid.s);
+		if(stream)
+			pkg_free(stream);
 		rpc->fault(ctx, 500, "Invalid auid");
 		return;
 	}
 
 	run_xcap_update_cb(type, doc_sel.xid, stream);
-	if(stream) pkg_free(stream);
+	if(stream)
+		pkg_free(stream);
 }
 
-static const char* xcap_client_refreshXcapDoc_doc[2] = {
-	"Refresh XCAP document",
-	0
-};
+static const char *xcap_client_refreshXcapDoc_doc[2] = {
+		"Refresh XCAP document", 0};
 
 rpc_export_t xcap_client_rpc_cmds[] = {
-	{"xcap_client.refreshXcapDoc", xcap_client_rpc_refreshXcapDoc,
-		xcap_client_refreshXcapDoc_doc, 0},
-	{0, 0, 0, 0}
-};
+		{"xcap_client.refreshXcapDoc", xcap_client_rpc_refreshXcapDoc,
+				xcap_client_refreshXcapDoc_doc, 0},
+		{0, 0, 0, 0}};
 
 /**
  * register RPC commands
  */
 static int xcap_client_init_rpc(void)
 {
-	if (rpc_register_array(xcap_client_rpc_cmds)!=0)
-	{
+	if(rpc_register_array(xcap_client_rpc_cmds) != 0) {
 		LM_ERR("failed to register RPC commands\n");
 		return -1;
 	}
 	return 0;
 }
 
-#define STR_MATCH(s1, s2)   ((s1).len==(s2).len && memcmp((s1).s, (s2).s, (s1).len)==0)
+#define STR_MATCH(s1, s2) \
+	((s1).len == (s2).len && memcmp((s1).s, (s2).s, (s1).len) == 0)
 
 int get_auid_flag(str auid)
 {
 	static str pres_rules = str_init("pres-rules");
 	static str rls_services = str_init("rls-services");
 
-	if (STR_MATCH(auid, pres_rules))
+	if(STR_MATCH(auid, pres_rules))
 		return PRES_RULES;
-	else if (STR_MATCH(auid, rls_services))
+	else if(STR_MATCH(auid, rls_services))
 		return RESOURCE_LIST;
 
 	return -1;

+ 1 - 1
src/modules/xcap_client/xcap_client.h

@@ -27,7 +27,7 @@
 #include "../../lib/srdb1/db.h"
 #include "xcap_callbacks.h"
 
-extern xcap_callback_t* xcapcb_list;
+extern xcap_callback_t *xcapcb_list;
 extern str xcap_db_url;
 extern str xcap_db_table;
 

+ 189 - 225
src/modules/xcap_client/xcap_functions.c

@@ -37,87 +37,79 @@
 #include "../presence/hash.h"
 
 
-#define ETAG_HDR          "Etag: "
-#define ETAG_HDR_LEN      strlen("Etag: ")
+#define ETAG_HDR "Etag: "
+#define ETAG_HDR_LEN strlen("Etag: ")
 
-size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream);
-char* get_xcap_path(xcap_get_req_t req);
+size_t write_function(void *ptr, size_t size, size_t nmemb, void *stream);
+char *get_xcap_path(xcap_get_req_t req);
 
-int bind_xcap(xcap_api_t* api)
+int bind_xcap(xcap_api_t *api)
 {
-	if (!api)
-	{
+	if(!api) {
 		LM_ERR("Invalid parameter value\n");
 		return -1;
 	}
-	api->int_node_sel= xcapInitNodeSel;
-	api->add_step= xcapNodeSelAddStep;
-	api->add_terminal= xcapNodeSelAddTerminal;
-	api->free_node_sel= xcapFreeNodeSel;
-	api->register_xcb= register_xcapcb;
-	api->getNewDoc= xcapGetNewDoc;
+	api->int_node_sel = xcapInitNodeSel;
+	api->add_step = xcapNodeSelAddStep;
+	api->add_terminal = xcapNodeSelAddTerminal;
+	api->free_node_sel = xcapFreeNodeSel;
+	api->register_xcb = register_xcapcb;
+	api->getNewDoc = xcapGetNewDoc;
 
 	return 0;
 }
 
-void xcapFreeNodeSel(xcap_node_sel_t* node)
+void xcapFreeNodeSel(xcap_node_sel_t *node)
 {
-	step_t* s, *p;
-	ns_list_t* n, *m;
-
-	s= node->steps;
-	while(s)
-	{
-		p= s;
-		s= s->next;
+	step_t *s, *p;
+	ns_list_t *n, *m;
+
+	s = node->steps;
+	while(s) {
+		p = s;
+		s = s->next;
 		pkg_free(p->val.s);
 		pkg_free(p);
 	}
 
-	n= node->ns_list;
-	while(n)
-	{
-		m= n;
-		n= n->next;
+	n = node->ns_list;
+	while(n) {
+		m = n;
+		n = n->next;
 		pkg_free(m->value.s);
 		pkg_free(m);
 	}
 
 	pkg_free(node);
-
 }
 
-xcap_node_sel_t* xcapInitNodeSel(void)
+xcap_node_sel_t *xcapInitNodeSel(void)
 {
-	xcap_node_sel_t* nsel= NULL;
+	xcap_node_sel_t *nsel = NULL;
 
-	nsel= (xcap_node_sel_t*)pkg_malloc(sizeof(xcap_node_sel_t));
-	if(nsel== NULL)
-	{
+	nsel = (xcap_node_sel_t *)pkg_malloc(sizeof(xcap_node_sel_t));
+	if(nsel == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 	memset(nsel, 0, sizeof(xcap_node_sel_t));
-	nsel->steps= (step_t*)pkg_malloc(sizeof(step_t));
-	if(nsel->steps== NULL)
-	{
+	nsel->steps = (step_t *)pkg_malloc(sizeof(step_t));
+	if(nsel->steps == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 	memset(nsel->steps, 0, sizeof(step_t));
-	nsel->last_step= nsel->steps;
+	nsel->last_step = nsel->steps;
 
-	nsel->ns_list= (ns_list_t*)pkg_malloc(sizeof(ns_list_t));
-	if(nsel->ns_list== NULL)
-	{
+	nsel->ns_list = (ns_list_t *)pkg_malloc(sizeof(ns_list_t));
+	if(nsel->ns_list == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 	memset(nsel->ns_list, 0, sizeof(ns_list_t));
-	nsel->last_ns= nsel->ns_list;
+	nsel->last_ns = nsel->ns_list;
 
 	return nsel;
 
 error:
-	if(nsel)
-	{
+	if(nsel) {
 		if(nsel->steps)
 			pkg_free(nsel->steps);
 		if(nsel->ns_list)
@@ -128,104 +120,93 @@ error:
 	return NULL;
 }
 
-xcap_node_sel_t* xcapNodeSelAddStep(xcap_node_sel_t* curr_sel, str* name,
-		str* namespace, int pos, attr_test_t*  attr_test, str* extra_sel)
+xcap_node_sel_t *xcapNodeSelAddStep(xcap_node_sel_t *curr_sel, str *name,
+		str *namespace, int pos, attr_test_t *attr_test, str *extra_sel)
 {
-	int size= 0;
-	str new_step= {NULL, 0};
-	step_t* s= NULL;
-	char ns_card= 'a';
-	ns_list_t* ns= NULL;
+	int size = 0;
+	str new_step = {NULL, 0};
+	step_t *s = NULL;
+	char ns_card = 'a';
+	ns_list_t *ns = NULL;
 
 	if(name)
-		size+= name->len;
+		size += name->len;
 	else
-		size+= 1;
+		size += 1;
 
 	if(namespace)
-		size+= 2;
-	if(pos> 0)
-		size+= 7;
+		size += 2;
+	if(pos > 0)
+		size += 7;
 	if(attr_test)
-		size+= 2+ attr_test->name.len+ attr_test->value.len;
+		size += 2 + attr_test->name.len + attr_test->value.len;
 	if(extra_sel)
-		size+= 2+ extra_sel->len;
+		size += 2 + extra_sel->len;
 
-	new_step.s= (char*)pkg_malloc(size* sizeof(char));
-	if(new_step.s== NULL)
-	{
+	new_step.s = (char *)pkg_malloc(size * sizeof(char));
+	if(new_step.s == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
-	if(name)
-	{
-		if(namespace)
-		{
-			ns_card= curr_sel->ns_no+ 'a';
+	if(name) {
+		if(namespace) {
+			ns_card = curr_sel->ns_no + 'a';
 			curr_sel->ns_no++;
 
-			if(ns_card> 'z')
-			{
+			if(ns_card > 'z') {
 				LM_ERR("Insufficient name cards for namespaces\n");
 				goto error;
 			}
-			new_step.len= sprintf(new_step.s, "%c:", ns_card);
+			new_step.len = sprintf(new_step.s, "%c:", ns_card);
 		}
-		memcpy(new_step.s+new_step.len, name->s, name->len);
-		new_step.len+= name->len;
+		memcpy(new_step.s + new_step.len, name->s, name->len);
+		new_step.len += name->len;
+	} else
+		memcpy(new_step.s + new_step.len, "*", 1);
+
+	if(attr_test) {
+		new_step.len += sprintf(new_step.s + new_step.len, "[%.*s=%.*s]",
+				attr_test->name.len, attr_test->name.s, attr_test->value.len,
+				attr_test->value.s);
 	}
-	else
-		memcpy(new_step.s+new_step.len, "*", 1);
+	if(pos > 0)
+		new_step.len += sprintf(new_step.s + new_step.len, "[%d]", pos);
 
-	if(attr_test)
-	{
-		new_step.len+= sprintf(new_step.s+ new_step.len, "[%.*s=%.*s]", attr_test->name.len,
-				attr_test->name.s, attr_test->value.len, attr_test->value.s);
+	if(extra_sel) {
+		memcpy(new_step.s + new_step.len, extra_sel->s, extra_sel->len);
+		new_step.len = extra_sel->len;
 	}
-	if(pos> 0)
-		new_step.len+= sprintf(new_step.s+ new_step.len, "[%d]", pos);
 
-	if(extra_sel)
-	{
-		memcpy(new_step.s+ new_step.len, extra_sel->s, extra_sel->len);
-		new_step.len= extra_sel->len;
-	}
-
-	s= (step_t*)pkg_malloc(sizeof(step_t));
-	if(s== NULL)
-	{
+	s = (step_t *)pkg_malloc(sizeof(step_t));
+	if(s == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
-	s->val= new_step;
-	s->next= NULL;
+	s->val = new_step;
+	s->next = NULL;
 
-	curr_sel->last_step->next= s;
-	curr_sel->last_step= s;
+	curr_sel->last_step->next = s;
+	curr_sel->last_step = s;
 
 	/* add the namespace binding if present */
-	if(namespace)
-	{
-		ns= (ns_list_t*)pkg_malloc(sizeof(ns_list_t));
-		if(ns== NULL)
-		{
+	if(namespace) {
+		ns = (ns_list_t *)pkg_malloc(sizeof(ns_list_t));
+		if(ns == NULL) {
 			ERR_MEM(PKG_MEM_STR);
 		}
-		ns->name= ns_card;
-		ns->value.s= (char*)pkg_malloc(namespace->len* sizeof(char));
-		if(ns->value.s== NULL)
-		{
+		ns->name = ns_card;
+		ns->value.s = (char *)pkg_malloc(namespace->len * sizeof(char));
+		if(ns->value.s == NULL) {
 			ERR_MEM(PKG_MEM_STR);
 		}
 		memcpy(ns->value.s, namespace->s, namespace->len);
-		ns->value.len= namespace->len;
+		ns->value.len = namespace->len;
 
-		curr_sel->last_ns->next= ns;
-		curr_sel->last_ns= ns;
+		curr_sel->last_ns->next = ns;
+		curr_sel->last_ns = ns;
 	}
 
-	curr_sel->size+= 1+ new_step.len;
-	if(namespace && namespace->len)
-	{
-		curr_sel->size+= namespace->len+ 3;
+	curr_sel->size += 1 + new_step.len;
+	if(namespace && namespace->len) {
+		curr_sel->size += namespace->len + 3;
 	}
 
 	return curr_sel;
@@ -235,8 +216,7 @@ error:
 		pkg_free(new_step.s);
 	if(s)
 		pkg_free(s);
-	if(ns)
-	{
+	if(ns) {
 		if(ns->value.s)
 			pkg_free(ns->value.s);
 		pkg_free(ns);
@@ -245,51 +225,48 @@ error:
 	return NULL;
 }
 
-xcap_node_sel_t* xcapNodeSelAddTerminal(xcap_node_sel_t* curr_sel,
-		char* attr_sel, char* namespace_sel, char* extra_sel )
+xcap_node_sel_t *xcapNodeSelAddTerminal(xcap_node_sel_t *curr_sel,
+		char *attr_sel, char *namespace_sel, char *extra_sel)
 {
 
 	return NULL;
 }
 
-char* get_node_selector(xcap_node_sel_t* node_sel)
+char *get_node_selector(xcap_node_sel_t *node_sel)
 {
-	char* buf= NULL;
-	step_t* s;
-	int len= 0;
-	ns_list_t* ns_elem;
-
-	buf= (char*)pkg_malloc((node_sel->size+ 10)* sizeof(char));
-	if(buf== NULL)
-	{
+	char *buf = NULL;
+	step_t *s;
+	int len = 0;
+	ns_list_t *ns_elem;
+
+	buf = (char *)pkg_malloc((node_sel->size + 10) * sizeof(char));
+	if(buf == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 
-	s= node_sel->steps->next;
+	s = node_sel->steps->next;
 
-	while(1)
-	{
-		memcpy(buf+ len, s->val.s, s->val.len);
-		len+= s->val.len;
-		s= s->next;
+	while(1) {
+		memcpy(buf + len, s->val.s, s->val.len);
+		len += s->val.len;
+		s = s->next;
 		if(s)
-			buf[len++]= '/';
+			buf[len++] = '/';
 		else
 			break;
 	}
-	ns_elem= node_sel->ns_list;
+	ns_elem = node_sel->ns_list;
 
 	if(ns_elem)
-		buf[len++]= '?';
+		buf[len++] = '?';
 
-	while(ns_elem)
-	{
-		len+= sprintf(buf+ len, "xmlns(%c=%.*s)", ns_elem->name,
+	while(ns_elem) {
+		len += sprintf(buf + len, "xmlns(%c=%.*s)", ns_elem->name,
 				ns_elem->value.len, ns_elem->value.s);
-		ns_elem= ns_elem->next;
+		ns_elem = ns_elem->next;
 	}
 
-	buf[len]= '\0';
+	buf[len] = '\0';
 
 	return buf;
 
@@ -297,34 +274,31 @@ error:
 	return NULL;
 }
 
-char* xcapGetNewDoc(xcap_get_req_t req, str user, str domain)
+char *xcapGetNewDoc(xcap_get_req_t req, str user, str domain)
 {
-	char* etag= NULL;
-	char* doc= NULL;
+	char *etag = NULL;
+	char *doc = NULL;
 	db_key_t query_cols[9];
 	db_val_t query_vals[9];
 	int n_query_cols = 0;
-	char* path= NULL;
+	char *path = NULL;
 
-	path= get_xcap_path(req);
-	if(path== NULL)
-	{
+	path = get_xcap_path(req);
+	if(path == NULL) {
 		LM_ERR("while constructing xcap path\n");
 		return NULL;
 	}
 	/* send HTTP request */
-	doc= send_http_get(path, req.port, NULL, 0, &etag);
-	if(doc== NULL)
-	{
+	doc = send_http_get(path, req.port, NULL, 0, &etag);
+	if(doc == NULL) {
 		LM_DBG("the searched document was not found\n");
 		goto done;
 	}
 
-	if(etag== NULL)
-	{
+	if(etag == NULL) {
 		LM_ERR("no etag found\n");
 		pkg_free(doc);
-		doc= NULL;
+		doc = NULL;
 		goto done;
 	}
 	/* insert in xcap table*/
@@ -343,47 +317,46 @@ char* xcapGetNewDoc(xcap_get_req_t req, str user, str domain)
 	query_cols[n_query_cols] = &str_doc_type_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val= req.doc_sel.doc_type;
+	query_vals[n_query_cols].val.int_val = req.doc_sel.doc_type;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_doc_col;
 	query_vals[n_query_cols].type = DB1_STRING;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.string_val= doc;
+	query_vals[n_query_cols].val.string_val = doc;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_etag_col;
 	query_vals[n_query_cols].type = DB1_STRING;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.string_val= etag;
+	query_vals[n_query_cols].val.string_val = etag;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_source_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val= XCAP_CL_MOD;
+	query_vals[n_query_cols].val.int_val = XCAP_CL_MOD;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_doc_uri_col;
 	query_vals[n_query_cols].type = DB1_STRING;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.string_val= path;
+	query_vals[n_query_cols].val.string_val = path;
 	n_query_cols++;
 
 	query_cols[n_query_cols] = &str_port_col;
 	query_vals[n_query_cols].type = DB1_INT;
 	query_vals[n_query_cols].nul = 0;
-	query_vals[n_query_cols].val.int_val= req.port;
+	query_vals[n_query_cols].val.int_val = req.port;
 	n_query_cols++;
 
-	if (xcap_dbf.use_table(xcap_db, &xcap_db_table) < 0)
-	{
-		LM_ERR("in use_table-[table]= %.*s\n", xcap_db_table.len, xcap_db_table.s);
+	if(xcap_dbf.use_table(xcap_db, &xcap_db_table) < 0) {
+		LM_ERR("in use_table-[table]= %.*s\n", xcap_db_table.len,
+				xcap_db_table.s);
 		goto done;
 	}
 
-	if(xcap_dbf.insert(xcap_db, query_cols, query_vals, n_query_cols)< 0)
-	{
+	if(xcap_dbf.insert(xcap_db, query_cols, query_vals, n_query_cols) < 0) {
 		LM_ERR("in sql insert\n");
 		goto done;
 	}
@@ -393,52 +366,48 @@ done:
 	return doc;
 }
 
-char* get_xcap_path(xcap_get_req_t req)
+char *get_xcap_path(xcap_get_req_t req)
 {
-	int len= 0, size;
-	char* path= NULL;
-	char* node_selector= NULL;
+	int len = 0, size;
+	char *path = NULL;
+	char *node_selector = NULL;
 
-	len= (strlen(req.xcap_root)+ 1+ req.doc_sel.auid.len+ 5+
-			req.doc_sel.xid.len+ req.doc_sel.filename.len+ 50)* sizeof(char);
+	len = (strlen(req.xcap_root) + 1 + req.doc_sel.auid.len + 5
+				  + req.doc_sel.xid.len + req.doc_sel.filename.len + 50)
+		  * sizeof(char);
 
 	if(req.node_sel)
-		len+= req.node_sel->size;
+		len += req.node_sel->size;
 
-	path= (char*)pkg_malloc(len);
-	if(path== NULL)
-	{
+	path = (char *)pkg_malloc(len);
+	if(path == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 
-	if(req.node_sel)
-	{
-		node_selector= get_node_selector(req.node_sel);
-		if(node_selector== NULL)
-		{
+	if(req.node_sel) {
+		node_selector = get_node_selector(req.node_sel);
+		if(node_selector == NULL) {
 			LM_ERR("while constructing node selector\n");
 			goto error;
 		}
 	}
 
-	size= sprintf(path, "%s/%.*s/", req.xcap_root, req.doc_sel.auid.len,
+	size = sprintf(path, "%s/%.*s/", req.xcap_root, req.doc_sel.auid.len,
 			req.doc_sel.auid.s);
 
-	if(req.doc_sel.type==USERS_TYPE)
-		size+= sprintf(path+ size, "%s/%.*s/", "users", req.doc_sel.xid.len,
+	if(req.doc_sel.type == USERS_TYPE)
+		size += sprintf(path + size, "%s/%.*s/", "users", req.doc_sel.xid.len,
 				req.doc_sel.xid.s);
 	else
-		size+= sprintf(path+ size, "%s/", "global");
-	size+= sprintf(path+ size, "%.*s", req.doc_sel.filename.len,
+		size += sprintf(path + size, "%s/", "global");
+	size += sprintf(path + size, "%.*s", req.doc_sel.filename.len,
 			req.doc_sel.filename.s);
 
-	if(node_selector)
-	{
-		size+= sprintf(path+ size, "/~~%s", node_selector);
+	if(node_selector) {
+		size += sprintf(path + size, "/~~%s", node_selector);
 	}
 
-	if(size> len)
-	{
+	if(size > len) {
 		LM_ERR("buffer size overflow\n");
 		goto error;
 	}
@@ -454,22 +423,20 @@ error:
 	return NULL;
 }
 
-size_t get_xcap_etag( void *ptr, size_t size, size_t nmemb, void *stream)
+size_t get_xcap_etag(void *ptr, size_t size, size_t nmemb, void *stream)
 {
-	int len= 0;
-	char* etag= NULL;
-
-	if(strncasecmp(ptr, ETAG_HDR, ETAG_HDR_LEN)== 0)
-	{
-		len= size* nmemb- ETAG_HDR_LEN;
-		etag= (char*)pkg_malloc((len+ 1)* sizeof(char));
-		if(etag== NULL)
-		{
+	int len = 0;
+	char *etag = NULL;
+
+	if(strncasecmp(ptr, ETAG_HDR, ETAG_HDR_LEN) == 0) {
+		len = size * nmemb - ETAG_HDR_LEN;
+		etag = (char *)pkg_malloc((len + 1) * sizeof(char));
+		if(etag == NULL) {
 			ERR_MEM(PKG_MEM_STR);
 		}
-		memcpy(etag, ptr+ETAG_HDR_LEN, len);
-		etag[len]= '\0';
-		*((char**)stream)= etag;
+		memcpy(etag, ptr + ETAG_HDR_LEN, len);
+		etag[len] = '\0';
+		*((char **)stream) = etag;
 	}
 	return len;
 
@@ -477,29 +444,28 @@ error:
 	return -1;
 }
 
-char* send_http_get(char* path, unsigned int xcap_port, char* match_etag,
-		int match_type, char** etag)
+char *send_http_get(char *path, unsigned int xcap_port, char *match_etag,
+		int match_type, char **etag)
 {
 	int len;
-	char* stream= NULL;
+	char *stream = NULL;
 	CURLcode ret_code;
-	CURL* curl_handle= NULL;
+	CURL *curl_handle = NULL;
 	static char buf[128];
-	char* match_header= NULL;
-	*etag= NULL;
+	char *match_header = NULL;
+	*etag = NULL;
 
-	if(match_etag)
-	{
-		char* hdr_name= NULL;
+	if(match_etag) {
+		char *hdr_name = NULL;
 
-		memset(buf, 0, 128* sizeof(char));
-		match_header= buf;
+		memset(buf, 0, 128 * sizeof(char));
+		match_header = buf;
 
-		hdr_name= (match_type==IF_MATCH)?"If-Match":"If-None-Match";
+		hdr_name = (match_type == IF_MATCH) ? "If-Match" : "If-None-Match";
 
-		len=sprintf(match_header, "%s: %s\n", hdr_name, match_etag);
+		len = sprintf(match_header, "%s: %s\n", hdr_name, match_etag);
 
-		match_header[len]= '\0';
+		match_header[len] = '\0';
 	}
 
 	curl_handle = curl_easy_init();
@@ -510,15 +476,15 @@ char* send_http_get(char* path, unsigned int xcap_port, char* match_etag,
 
 	curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
 
-	curl_easy_setopt(curl_handle,  CURLOPT_STDERR, stdout);
+	curl_easy_setopt(curl_handle, CURLOPT_STDERR, stdout);
 
 	curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_function);
 
-	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void*)(&stream));
+	curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)(&stream));
 
 	curl_easy_setopt(curl_handle, CURLOPT_HEADERFUNCTION, get_xcap_etag);
 
-	curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void*)(&etag));
+	curl_easy_setopt(curl_handle, CURLOPT_WRITEHEADER, (void *)(&etag));
 
 	if(match_header)
 		curl_easy_setopt(curl_handle, CURLOPT_HEADER, (long)match_header);
@@ -526,14 +492,13 @@ char* send_http_get(char* path, unsigned int xcap_port, char* match_etag,
 	/* non-2xx => error */
 	curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1);
 
-	ret_code= curl_easy_perform(curl_handle );
+	ret_code = curl_easy_perform(curl_handle);
 
-	if( ret_code== CURLE_WRITE_ERROR)
-	{
+	if(ret_code == CURLE_WRITE_ERROR) {
 		LM_ERR("while performing curl option\n");
 		if(stream)
 			pkg_free(stream);
-		stream= NULL;
+		stream = NULL;
 		return NULL;
 	}
 
@@ -541,22 +506,21 @@ char* send_http_get(char* path, unsigned int xcap_port, char* match_etag,
 	return stream;
 }
 
-size_t write_function( void *ptr, size_t size, size_t nmemb, void *stream)
+size_t write_function(void *ptr, size_t size, size_t nmemb, void *stream)
 {
 	/* allocate memory and copy */
-	char* data;
+	char *data;
 
-	data= (char*)pkg_malloc(size* nmemb);
-	if(data== NULL)
-	{
+	data = (char *)pkg_malloc(size * nmemb);
+	if(data == NULL) {
 		ERR_MEM(PKG_MEM_STR);
 	}
 
-	memcpy(data, (char*)ptr, size* nmemb);
+	memcpy(data, (char *)ptr, size * nmemb);
 
-	*((char**) stream)= data;
+	*((char **)stream) = data;
 
-	return size* nmemb;
+	return size * nmemb;
 
 error:
 	return CURLE_WRITE_ERROR;

+ 44 - 41
src/modules/xcap_client/xcap_functions.h

@@ -26,17 +26,17 @@
 
 #include "xcap_callbacks.h"
 
-#define USERS_TYPE      1
-#define GLOBAL_TYPE     2
+#define USERS_TYPE 1
+#define GLOBAL_TYPE 2
 
-#define IF_MATCH    	1
-#define IF_NONE_MATCH    2
+#define IF_MATCH 1
+#define IF_NONE_MATCH 2
 
 /* macros for the entities responsible for handling a record inserted
  * in xcap table*/
 
-#define INTEGRATED_SERVER      0
-#define XCAP_CL_MOD            1 /* xcap_client module responsibility */
+#define INTEGRATED_SERVER 0
+#define XCAP_CL_MOD 1 /* xcap_client module responsibility */
 
 
 typedef struct xcap_doc_sel
@@ -46,85 +46,88 @@ typedef struct xcap_doc_sel
 	int type;
 	str xid;
 	str filename;
-}xcap_doc_sel_t;
+} xcap_doc_sel_t;
 
 typedef struct ns_list
 {
 	int name;
 	str value;
-	struct ns_list* next;
-}ns_list_t;
+	struct ns_list *next;
+} ns_list_t;
 
 typedef struct step
 {
 	str val;
-	struct step* next;
-}step_t;
+	struct step *next;
+} step_t;
 
 typedef struct xcap_node_sel
 {
-	step_t* steps;
-	step_t* last_step;
+	step_t *steps;
+	step_t *last_step;
 	int size;
-	ns_list_t* ns_list;
-	ns_list_t* last_ns;
+	ns_list_t *ns_list;
+	ns_list_t *last_ns;
 	int ns_no;
 
-}xcap_node_sel_t;
+} xcap_node_sel_t;
 
 typedef struct att_test
 {
 	str name;
 	str value;
-}attr_test_t;
+} attr_test_t;
 
 typedef struct xcap_get_req
 {
-	char* xcap_root;
+	char *xcap_root;
 	unsigned int port;
 	xcap_doc_sel_t doc_sel;
-	xcap_node_sel_t* node_sel;
-	char* etag;
+	xcap_node_sel_t *node_sel;
+	char *etag;
 	int match_type;
-}xcap_get_req_t;
+} xcap_get_req_t;
 
-xcap_node_sel_t* xcapInitNodeSel(void);
-typedef xcap_node_sel_t* (*xcap_nodeSel_init_t )(void);
+xcap_node_sel_t *xcapInitNodeSel(void);
+typedef xcap_node_sel_t *(*xcap_nodeSel_init_t)(void);
 
-xcap_node_sel_t* xcapNodeSelAddStep(xcap_node_sel_t* curr_sel, str* name,
-		str* namespace, int pos, attr_test_t*  attr_test, str* extra_sel);
+xcap_node_sel_t *xcapNodeSelAddStep(xcap_node_sel_t *curr_sel, str *name,
+		str *namespace, int pos, attr_test_t *attr_test, str *extra_sel);
 
-typedef xcap_node_sel_t* (*xcap_nodeSel_add_step_t)(xcap_node_sel_t* curr_sel,
-	str* name,str* namespace,int pos,attr_test_t*  attr_test,str* extra_sel);
+typedef xcap_node_sel_t *(*xcap_nodeSel_add_step_t)(xcap_node_sel_t *curr_sel,
+		str *name, str *namespace, int pos, attr_test_t *attr_test,
+		str *extra_sel);
 
-xcap_node_sel_t* xcapNodeSelAddTerminal(xcap_node_sel_t* curr_sel,
-		char* attr_sel, char* namespace_sel, char* extra_sel );
+xcap_node_sel_t *xcapNodeSelAddTerminal(xcap_node_sel_t *curr_sel,
+		char *attr_sel, char *namespace_sel, char *extra_sel);
 
-typedef xcap_node_sel_t* (*xcap_nodeSel_add_terminal_t)(xcap_node_sel_t* curr_sel,
-		char* attr_sel, char* namespace_sel, char* extra_sel );
+typedef xcap_node_sel_t *(*xcap_nodeSel_add_terminal_t)(
+		xcap_node_sel_t *curr_sel, char *attr_sel, char *namespace_sel,
+		char *extra_sel);
 
-void xcapFreeNodeSel(xcap_node_sel_t* node);
+void xcapFreeNodeSel(xcap_node_sel_t *node);
 
-typedef void (*xcap_nodeSel_free_t)(xcap_node_sel_t* node);
+typedef void (*xcap_nodeSel_free_t)(xcap_node_sel_t *node);
 
 /* specifical function to get a new document, not present in xcap table
  * to be updated and handled by the xcap_client module*/
-char* xcapGetNewDoc(xcap_get_req_t req, str user, str domain);
-typedef char* (*xcapGetNewDoc_t)(xcap_get_req_t req, str user, str domain);
+char *xcapGetNewDoc(xcap_get_req_t req, str user, str domain);
+typedef char *(*xcapGetNewDoc_t)(xcap_get_req_t req, str user, str domain);
 
-typedef struct xcap_api {
+typedef struct xcap_api
+{
 	xcap_nodeSel_init_t int_node_sel;
 	xcap_nodeSel_add_step_t add_step;
 	xcap_nodeSel_add_terminal_t add_terminal;
 	xcap_nodeSel_free_t free_node_sel;
 	xcapGetNewDoc_t getNewDoc;
 	register_xcapcb_t register_xcb;
-}xcap_api_t;
+} xcap_api_t;
 
-int bind_xcap(xcap_api_t* api);
+int bind_xcap(xcap_api_t *api);
 
-typedef int (*bind_xcap_t)(xcap_api_t* api);
+typedef int (*bind_xcap_t)(xcap_api_t *api);
 
-char* send_http_get(char* path, unsigned int xcap_port, char* match_etag,
-		int match_type, char** etag);
+char *send_http_get(char *path, unsigned int xcap_port, char *match_etag,
+		int match_type, char **etag);
 #endif