Forráskód Böngészése

lib/xcap: removed trailing spaces

Daniel-Constantin Mierla 1 éve
szülő
commit
275b9e1b87

+ 18 - 18
src/lib/xcap/common_policy.c

@@ -15,9 +15,9 @@ static void free_identity(cp_identity_t *id)
 	cp_domain_t *d, *nd;
 	cp_except_t *e, *ne;
 	cp_except_domain_t *ed, *ned;
-	
+
 	if (!id) return;
-	
+
 	i = id->ids;
 	while (i) {
 		ni = i->next;
@@ -25,7 +25,7 @@ static void free_identity(cp_identity_t *id)
 		cds_free(i);
 		i = ni;
 	}
-	
+
 	d = id->domains;
 	while (d) {
 		nd = d->next;
@@ -33,7 +33,7 @@ static void free_identity(cp_identity_t *id)
 		cds_free(d);
 		d = nd;
 	}
-	
+
 	e = id->excepts;
 	while (e) {
 		ne = e->next;
@@ -50,7 +50,7 @@ static void free_identity(cp_identity_t *id)
 			cds_free(d);
 			d = nd;
 		}
-		
+
 		ed = id->any_identity->except_domains;
 		while (ed) {
 			ned = ed->next;
@@ -59,7 +59,7 @@ static void free_identity(cp_identity_t *id)
 			ed = ned;
 		}
 	}
-	
+
 	cds_free(id);
 }
 
@@ -83,9 +83,9 @@ static void free_conditions(cp_conditions_t *c)
 static void free_transformations(cp_transformations_t *t)
 {
 	cp_unknown_t *u, *nu;
-	
+
 	if (!t) return;
-	
+
 	u = t->unknown;
 	while (u) {
 		nu = u->next;
@@ -108,7 +108,7 @@ void free_cp_rule(cp_rule_t *r, cp_free_actions_func free_actions)
 void free_common_rules(cp_ruleset_t *r, cp_free_actions_func free_actions)
 {
 	cp_rule_t *rule, *n;
-	
+
 	if (!r) return;
 	rule = r->rules;
 	while (rule) {
@@ -124,7 +124,7 @@ static void parse_uri(const str_t *uri, str_t *user, str_t *domain)
 	char *a;
 	char *d;
 	str_t s;
-	
+
 	str_clear(user);
 	str_clear(domain);
 	if (uri->len > 0) {
@@ -142,7 +142,7 @@ static void parse_uri(const str_t *uri, str_t *user, str_t *domain)
 		domain->s = s.s + user->len;
 		if (a) domain->s++;
 		domain->len = uri->len - (domain->s - uri->s);
-		
+
 /*		TRACE_LOG("parse uri \'%.*s\': user=\'%.*s\' domain=\'%.*s\'\n",
 				FMT_STR(*uri), FMT_STR(*user), FMT_STR(*domain));*/
 	}
@@ -151,7 +151,7 @@ static void parse_uri(const str_t *uri, str_t *user, str_t *domain)
 
 /* returns 1 if rule is used for uri */
 int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
-{	
+{
 	cp_identity_t *id;
 	int ok = 0;
 	str_t domain, user;
@@ -160,19 +160,19 @@ int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
 	cp_id_t *i;
 	cp_except_t *e;
 	cp_except_domain_t *ed;
-	
+
 	if (!rule) return 0;
 	if (!rule->conditions) return 1; /* FIXME: ??? */
 	id = rule->conditions->identity;
 	if (!id) return 0;
-	
+
 	parse_uri(uri, &user, &domain);
-	
+
 	i = id->ids;
 	while (i) {
 		parse_uri(&i->entity, &u_, &d_);
 /*		TRACE_LOG("comparing uris \'%.*s\' \'%.*s\' "
-				"domains \'%.*s\' \'%.*s\'\n", 
+				"domains \'%.*s\' \'%.*s\'\n",
 				FMT_STR(user), FMT_STR(u_),
 				FMT_STR(domain), FMT_STR(d_));*/
 		if (str_case_equals(&user, &u_) == 0) {
@@ -183,7 +183,7 @@ int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
 		}
 		i = i->next;
 	}
-	
+
 	d = id->domains;
 	while (d) {
 /*		TRACE_LOG("comparing domains \'%.*s\' \'%.*s\'\n",
@@ -211,7 +211,7 @@ int is_rule_for_uri(cp_rule_t *rule, const str_t *uri)
 			}
 			d = d->next;
 		}
-		
+
 		ed = id->any_identity->except_domains;
 		while (ed) {
 			if (str_nocase_equals(&domain, &d->domain) == 0) return 0;

+ 2 - 2
src/lib/xcap/common_policy.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -93,7 +93,7 @@ typedef struct {
 
 typedef struct _cp_rule_t {
 	struct _cp_rule_t *next;
-		
+
 	cp_conditions_t *conditions;
 	cp_actions_t *actions;
 	cp_transformations_t *transformations;

+ 12 - 12
src/lib/xcap/msg_rules.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -40,7 +40,7 @@ int get_msg_rules(const str_t *username, const str_t *filename,
 	int dsize = 0;
 	char *uri = NULL;
 	int res = RES_OK;
-	
+
 	uri = xcap_uri_for_users_document(xcap_doc_im_rules,
 				username, filename,
 				xcap_params);
@@ -49,7 +49,7 @@ int get_msg_rules(const str_t *username, const str_t *filename,
 		ERROR_LOG("can't build XCAP uri\n");
 		return RES_XCAP_QUERY_ERR;
 	}
-	
+
 	res = xcap_query(uri, xcap_params, &data, &dsize);
 	if (res != RES_OK) {
 		DEBUG_LOG("XCAP problems for uri \'%s\'\n", uri);
@@ -58,7 +58,7 @@ int get_msg_rules(const str_t *username, const str_t *filename,
 		return RES_XCAP_QUERY_ERR;
 	}
 	cds_free(uri);
-	
+
 	/* parse input data */
 	res = parse_msg_rules(data, dsize, dst);
 	if (res != RES_OK) {
@@ -69,22 +69,22 @@ int get_msg_rules(const str_t *username, const str_t *filename,
 	return res;
 }
 
-int get_msg_rules_action(cp_ruleset_t *r, const str_t *wuri, 
+int get_msg_rules_action(cp_ruleset_t *r, const str_t *wuri,
 		msg_handling_t *dst_action)
 {
 	int res = 1; /* rule not found */
 	cp_rule_t *rule;
 	msg_handling_t a = msg_handling_block;
 	msg_handling_t aa;
-	
+
 	if (!r) return -1;
-	
+
 	rule = r->rules;
 	while (rule) {
-		DEBUG_LOG("TRYING rule %.*s for uri %.*s\n", 
+		DEBUG_LOG("TRYING rule %.*s for uri %.*s\n",
 					FMT_STR(rule->id), FMT_STR(*wuri));
 		if (is_rule_for_uri(rule, wuri)) {
-			DEBUG_LOG("rule %.*s matches for uri %.*s\n", 
+			DEBUG_LOG("rule %.*s matches for uri %.*s\n",
 					FMT_STR(rule->id), FMT_STR(*wuri));
 
 			if (!rule->actions) continue;
@@ -96,16 +96,16 @@ int get_msg_rules_action(cp_ruleset_t *r, const str_t *wuri,
 		rule = rule->next;
 	}
 	if (dst_action && (res == 0)) *dst_action = a;
-	
+
 	return res;
 }
 
 void free_msg_actions(cp_actions_t *a)
 {
 	cp_unknown_t *u, *nu;
-	
+
 	if (!a) return;
-	
+
 	u = a->unknown;
 	while (u) {
 		nu = u->next;

+ 1 - 1
src/lib/xcap/msg_rules.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 29 - 29
src/lib/xcap/parse_common_rules.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -42,7 +42,7 @@ static int read_sphere(xmlNode *n, cp_sphere_t **dst)
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
 	(*dst)->next = NULL;
-	
+
 	str_dup_zt(&(*dst)->value, get_node_value(n));
 	return RES_OK;
 }
@@ -53,10 +53,10 @@ static int read_validity(xmlNode *n, cp_validity_t **dst)
 	*dst = (cp_validity_t*)cds_malloc(sizeof(cp_validity_t));
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
-	
+
 	from = get_node_value(find_node(n, "from", common_policy_ns));
 	to = get_node_value(find_node(n, "to", common_policy_ns));
-	
+
 	(*dst)->from = xmltime2time(from);
 	(*dst)->to = xmltime2time(to);
 	return RES_OK;
@@ -68,7 +68,7 @@ static int read_id(xmlNode *n, cp_id_t **dst)
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
 	(*dst)->next = NULL;
-	
+
 	get_str_attr(n, "entity", &(*dst)->entity);
 	if ((*dst)->entity.len == 0) {
 		/* hack - eyeBeams format differs from draft ! */
@@ -84,7 +84,7 @@ static int read_domain(xmlNode *n, cp_domain_t **dst)
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
 	(*dst)->next = NULL;
-	
+
 	get_str_attr(n, "domain", &(*dst)->domain);
 	return RES_OK;
 }
@@ -95,7 +95,7 @@ static int read_except(xmlNode *n, cp_except_t **dst)
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
 	(*dst)->next = NULL;
-	
+
 	get_str_attr(n, "entity", &(*dst)->entity);
 	return RES_OK;
 }
@@ -106,7 +106,7 @@ static int read_except_domain(xmlNode *n, cp_except_domain_t **dst)
 	if (!*dst) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
 	(*dst)->next = NULL;
-	
+
 	get_str_attr(n, "domain", &(*dst)->domain);
 	return RES_OK;
 }
@@ -117,11 +117,11 @@ static int read_any_identity(xmlNode *an, cp_any_identity_t **dst)
 	cp_except_domain_t *except, *last_except = NULL;
 	xmlNode *n;
 	int res = RES_OK;
-	
+
 	*dst = (cp_any_identity_t*)cds_malloc(sizeof(cp_any_identity_t));
 	if (!*dst) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
-	
+
 	n = an->children;
 	while (n) {
 		if (n->type == XML_ELEMENT_NODE) {
@@ -136,7 +136,7 @@ static int read_any_identity(xmlNode *an, cp_any_identity_t **dst)
 				LINKED_LIST_ADD((*dst)->except_domains, last_except, except);
 			}
 		}
-		
+
 		n = n->next;
 	}
 	return res;
@@ -149,7 +149,7 @@ static int read_identity(xmlNode *idn, cp_identity_t **dst)
 	cp_except_t *except, *last_except = NULL;
 	xmlNode *n;
 	int res = RES_OK;
-	
+
 	*dst = (cp_identity_t*)cds_malloc(sizeof(cp_identity_t));
 	if (!*dst) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(**dst));
@@ -177,10 +177,10 @@ static int read_identity(xmlNode *idn, cp_identity_t **dst)
 				if (res != 0) break;
 			}
 		}
-		
+
 		n = n->next;
 	}
-	
+
 	return res;
 }
 
@@ -190,11 +190,11 @@ static int read_conditions(xmlNode *cn, cp_conditions_t **dst)
 	int res = RES_OK;
 	cp_sphere_t *sphere, * last_sphere = NULL;
 	if ((!cn) || (!dst)) return RES_INTERNAL_ERR;
-	
+
 	*dst = (cp_conditions_t*)cds_malloc(sizeof(cp_conditions_t));
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(cp_conditions_t));
-	
+
 	n = cn->children;
 	while (n) {
 		if (n->type == XML_ELEMENT_NODE) {
@@ -217,7 +217,7 @@ static int read_conditions(xmlNode *cn, cp_conditions_t **dst)
 					}
 					/* else process other elements ? */
 				}
-				
+
 			}
 		}
 		n = n->next;
@@ -230,7 +230,7 @@ static int read_transformations(xmlNode *tn, cp_transformations_t **dst)
 {
 	int res = RES_OK;
 	if ((!tn) || (!dst)) return RES_INTERNAL_ERR;
-	
+
 	*dst = (cp_transformations_t*)cds_malloc(sizeof(cp_transformations_t));
 	if (!*dst) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(cp_transformations_t));
@@ -240,14 +240,14 @@ static int read_transformations(xmlNode *tn, cp_transformations_t **dst)
 	return res;
 }
 
-static int read_rule(xmlNode *rn, cp_rule_t **dst, 
+static int read_rule(xmlNode *rn, cp_rule_t **dst,
 		cp_read_actions_func read_actions,
 		cp_free_actions_func free_actions)
 {
 	xmlNode *n;
 	int res = RES_OK;
 	if ((!rn) || (!dst)) return RES_INTERNAL_ERR;
-	
+
 	*dst = (cp_rule_t*)cds_malloc(sizeof(cp_rule_t));
 	if (!*dst) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(cp_rule_t));
@@ -256,13 +256,13 @@ static int read_rule(xmlNode *rn, cp_rule_t **dst,
 
 	n = find_node(rn, "actions", common_policy_ns);
 	if (n && (res == 0) && read_actions) res = read_actions(n, &(*dst)->actions);
-	
+
 	n = find_node(rn, "conditions", common_policy_ns);
 	if (n && (res == 0)) res = read_conditions(n, &(*dst)->conditions);
-	
+
 	n = find_node(rn, "transformations", common_policy_ns);
 	if (n && (res == 0)) res = read_transformations(n, &(*dst)->transformations);
-	
+
 	if (res != 0) {
 		free_cp_rule(*dst, free_actions);
 		*dst = NULL;
@@ -272,18 +272,18 @@ static int read_rule(xmlNode *rn, cp_rule_t **dst,
 	return 0;
 }
 
-static int read_common_rules(xmlNode *root, cp_ruleset_t **dst, 
+static int read_common_rules(xmlNode *root, cp_ruleset_t **dst,
 		cp_read_actions_func read_actions, cp_free_actions_func free_actions)
 {
 	cp_ruleset_t *rs = NULL;
 	cp_rule_t *r, *last = NULL;
 	xmlNode *n;
 	int res = RES_OK;
-	
+
 	if (!dst) return RES_INTERNAL_ERR;
 	else *dst = NULL;
 	if (!root) return RES_INTERNAL_ERR;
-	
+
 	if (cmp_node(root, "ruleset", common_policy_ns) < 0) {
 		ERROR_LOG("document is not a ruleset \n");
 		return RES_INTERNAL_ERR;
@@ -294,7 +294,7 @@ static int read_common_rules(xmlNode *root, cp_ruleset_t **dst,
 	*dst = rs;
 	memset(rs, 0, sizeof(*rs));
 
-	
+
 	/* read rules in ruleset */
 	n = root->children;
 	while (n) {
@@ -325,8 +325,8 @@ int parse_common_rules(const char *data, int dsize, cp_ruleset_t **dst,
 		ERROR_LOG("can't parse document\n");
 		return RES_INTERNAL_ERR;
 	}
-	
-	res = read_common_rules(xmlDocGetRootElement(doc), dst, 
+
+	res = read_common_rules(xmlDocGetRootElement(doc), dst,
 			read_actions, free_actions);
 	if ((res != RES_OK) && (dst)) {
 		/* may be set => must be freed */

+ 1 - 1
src/lib/xcap/parse_common_rules.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 4 - 4
src/lib/xcap/parse_msg_rules.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -40,7 +40,7 @@ char *msg_rules_ns = NULL;
 static int str2msg_handling(const char *s, msg_handling_t *dst)
 {
 	if (!s) return RES_INTERNAL_ERR;
-	
+
 	if (strcmp(s, "allow") == 0) {
 		*dst = msg_handling_allow;
 		return 0;
@@ -67,7 +67,7 @@ static int read_msg_actions(xmlNode *an, cp_actions_t **dst)
 	const char *s;
 	int res = RES_OK;
 	if ((!an) || (!dst)) return RES_INTERNAL_ERR;
-	
+
 	*dst = (cp_actions_t*)cds_malloc(sizeof(cp_actions_t));
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(cp_actions_t));
@@ -86,7 +86,7 @@ static int read_msg_actions(xmlNode *an, cp_actions_t **dst)
 
 int parse_msg_rules(const char *data, int dsize, cp_ruleset_t **dst)
 {
-	return parse_common_rules(data, dsize, dst, 
+	return parse_common_rules(data, dsize, dst,
 			read_msg_actions, free_msg_actions);
 }
 

+ 1 - 1
src/lib/xcap/parse_msg_rules.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 3 - 3
src/lib/xcap/parse_pres_rules.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -39,7 +39,7 @@ char *pres_rules_ns = NULL;
 static int str2sub_handling(const char *s, sub_handling_t *dst)
 {
 	if (!s) return RES_INTERNAL_ERR;
-	
+
 	if (strcmp(s, "allow") == 0) {
 		*dst = sub_handling_allow;
 		return 0;
@@ -66,7 +66,7 @@ static int read_pres_actions(xmlNode *an, cp_actions_t **dst)
 	const char *s;
 	int res = RES_OK;
 	if ((!an) || (!dst)) return RES_INTERNAL_ERR;
-	
+
 	*dst = (cp_actions_t*)cds_malloc(sizeof(cp_actions_t));
 	if (!(*dst)) return RES_MEMORY_ERR;
 	memset(*dst, 0, sizeof(cp_actions_t));

+ 1 - 1
src/lib/xcap/parse_pres_rules.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 14 - 14
src/lib/xcap/pres_rules.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -33,14 +33,14 @@
 #include <cds/sstr.h>
 #include <string.h>
 
-int get_pres_rules(const str_t *username, const str_t *filename, 
+int get_pres_rules(const str_t *username, const str_t *filename,
 		xcap_query_params_t *xcap_params, cp_ruleset_t **dst)
 {
 	char *data = NULL;
 	int dsize = 0;
 	char *uri = NULL;
 	int res = RES_OK;
-	
+
 	if (dst) *dst = NULL;
 
 	uri = xcap_uri_for_users_document(xcap_doc_pres_rules,
@@ -59,12 +59,12 @@ int get_pres_rules(const str_t *username, const str_t *filename,
 		return RES_XCAP_QUERY_ERR;
 	}
 	cds_free(uri);
-	
+
 	/* parse input data */
 	res = parse_pres_rules(data, dsize, dst);
 	if (res != RES_OK) {
-		ERROR_LOG("Error occurred during parsing pres-rules for %.*s!\n", 
-				str_len(username), 
+		ERROR_LOG("Error occurred during parsing pres-rules for %.*s!\n",
+				str_len(username),
 				username ? username->s : "");
 	}
 
@@ -72,22 +72,22 @@ int get_pres_rules(const str_t *username, const str_t *filename,
 	return res;
 }
 
-int get_pres_rules_action(cp_ruleset_t *r, const str_t *wuri, 
+int get_pres_rules_action(cp_ruleset_t *r, const str_t *wuri,
 		sub_handling_t *dst_action)
 {
 	int res = 1; /* rule not found */
 	cp_rule_t *rule;
 	sub_handling_t a = sub_handling_block;
 	sub_handling_t aa;
-	
+
 	if (!r) return -1;
-	
+
 	rule = r->rules;
 	while (rule) {
-		DEBUG_LOG("TRYING rule %.*s for uri %.*s\n", 
+		DEBUG_LOG("TRYING rule %.*s for uri %.*s\n",
 					FMT_STR(rule->id), FMT_STR(*wuri));
 		if (is_rule_for_uri(rule, wuri)) {
-			DEBUG_LOG("rule %.*s matches for uri %.*s\n", 
+			DEBUG_LOG("rule %.*s matches for uri %.*s\n",
 					FMT_STR(rule->id), FMT_STR(*wuri));
 
 			if (!rule->actions) continue;
@@ -99,7 +99,7 @@ int get_pres_rules_action(cp_ruleset_t *r, const str_t *wuri,
 		rule = rule->next;
 	}
 	if (dst_action && (res == 0)) *dst_action = a;
-	
+
 	return res;
 }
 
@@ -108,9 +108,9 @@ int get_pres_rules_action(cp_ruleset_t *r, const str_t *wuri,
 void free_pres_actions(cp_actions_t *a)
 {
 	cp_unknown_t *u, *nu;
-	
+
 	if (!a) return;
-	
+
 	u = a->unknown;
 	while (u) {
 		nu = u->next;

+ 1 - 1
src/lib/xcap/pres_rules.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 64 - 64
src/lib/xcap/resource_list.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -56,7 +56,7 @@ typedef struct {
 void canonicalize_uri(const str_t *uri, str_t *dst)
 {
 	/* TODO: do the operation according to draft-ietf-simple-xcap-list-usage-05.txt */
-	
+
 	if (!dst) return;
 	if (!uri) {
 		dst->len = 0;
@@ -93,7 +93,7 @@ char *xcap_uri_for_rls_resource(const str_t *xcap_root, const str_t *uri)
 	canonicalize_uri(uri, &c_uri);
 	dstr_append_str(&s, &c_uri);
 	if (c_uri.s) cds_free(c_uri.s);
-	
+
 	dstr_append_zt(&s, "%22]");
 	l = dstr_get_data_length(&s);
 	if (l > 0) {
@@ -118,7 +118,7 @@ char *xcap_uri_for_rls_services(const str_t *xcap_root)
 	dstr_append_str(&s, xcap_root);
 	if (xcap_root->s[xcap_root->len - 1] != '/') dstr_append(&s, "/", 1);
 	dstr_append_zt(&s, "rls-services/global/index");
-	
+
 	l = dstr_get_data_length(&s);
 	if (l > 0) {
 		dst = (char *)cds_malloc(l + 1);
@@ -181,7 +181,7 @@ static char *relative2absolute_uri(const str_t *xcap_root, const char *relative)
 	if (slash_len) dst[root_len] = '/';
 	if (relative) memcpy(dst + root_len + slash_len, relative, rel_len);
 	dst[len - 1] = 0;
-	
+
 	return dst;
 }
 
@@ -202,11 +202,11 @@ int add_entry_to_flat(process_params_t *params, entry_t *entry)
 	flat_list_t *f;
 	display_name_t *d, *n, *last;
 	char *uri;
-	
+
 	if (!entry) return -1;
 	uri = entry->uri;
 	if (!uri) return -1; /* can't be added */
-	
+
 	/* try to find the uri in the flat list first */
 	f = params->flat;
 	while (f) {
@@ -219,11 +219,11 @@ int add_entry_to_flat(process_params_t *params, entry_t *entry)
 	memset(f, 0, sizeof(*f));
 	f->uri = zt_strdup(uri);
 	f->next = NULL;
-		
+
 	if (params->flat_last) params->flat_last->next = f;
 	else params->flat = f;
 	params->flat_last = f;
-		
+
 	/* add all entry's names */
 	last = NULL;
 	d = SEQUENCE_FIRST(entry->display_names);
@@ -239,7 +239,7 @@ int add_entry_to_flat(process_params_t *params, entry_t *entry)
 int add_uri_to_traversed(process_params_t *params, const char *uri)
 {
 	traversed_list_t *f;
-	
+
 	if (!uri) return -1; /* can't be added */
 
 	/* try to find the uri in the flat list first */
@@ -254,11 +254,11 @@ int add_uri_to_traversed(process_params_t *params, const char *uri)
 	if (!f) return -1;
 	f->uri = zt_strdup(uri);
 	f->next = NULL;
-		
+
 	if (params->traversed_last) params->traversed_last->next = f;
 	else params->traversed = f;
 	params->traversed_last = f;
-	
+
 	return 0;
 }
 
@@ -270,7 +270,7 @@ static int process_entry(entry_t *entry, process_params_t *params)
 {
 	if (!entry) return RES_OK;
 	if (!entry->uri) return RES_OK;
-	
+
 	/* DEBUG_LOG("processing entry with uri \'%s\'\n", STR_OK(entry->uri)); */
 
 	add_entry_to_flat(params, entry);
@@ -284,12 +284,12 @@ static int process_entry_ref(entry_ref_t *entry_ref, process_params_t *params)
 	entry_t *entry = NULL;
 	char *xcap_uri;
 	int res;
-	
+
 	/* DEBUG_LOG("processing entry-ref with ref \'%s\'\n", STR_OK(entry_ref->ref)); */
-	
+
 	if (!entry_ref) return RES_OK;
 	if (!entry_ref->ref) return RES_OK;
-	
+
 	if (add_uri_to_traversed(params, entry_ref->ref) != 0) {
 		/* It is existing yet? */
 		ERROR_LOG("Duplicate URI in traversed set\n");
@@ -328,12 +328,12 @@ static int process_external(external_t *external, process_params_t *params)
 	int dsize = 0;
 	list_t *list = NULL;
 	int res;
-	
+
 	/* DEBUG_LOG("processing external with anchor \'%s\'\n", STR_OK(external->anchor)); */
-	
+
 	if (!external) return RES_OK;
 	if (!external->anchor) return RES_OK;
-	
+
 	if (add_uri_to_traversed(params, external->anchor) != 0) {
 		/* It is existing yet? */
 		ERROR_LOG("Duplicate URI in traversed set\n");
@@ -363,17 +363,17 @@ static int process_external(external_t *external, process_params_t *params)
 	free_list(list);
 	return res;
 }
-	
+
 static int process_list(list_t *list, process_params_t *params)
 {
 	list_content_t *e;
 	int res = 0;
-	
+
 	if (!list) return RES_INTERNAL_ERR;
 	/* DEBUG_LOG("processing list \'%s\'\n", STR_OK(list->name)); */
 
 	e = SEQUENCE_FIRST(list->content);
-	
+
 	while (e) {
 		switch (e->type) {
 			case lct_list:
@@ -392,7 +392,7 @@ static int process_list(list_t *list, process_params_t *params)
 		if (res != 0) break;
 		e = SEQUENCE_NEXT(e);
 	}
-	
+
 	return res;
 }
 
@@ -411,7 +411,7 @@ static int process_resource_list(const char *rl_uri, process_params_t *params)
 		if (data) cds_free(data);
 		return RES_BAD_GATEWAY_ERR; /* -> 502 Bad GW */
 	}
-	
+
 	/* parse query result */
 	if (parse_list_xml(data, dsize, &list) != 0) {
 		if (data) cds_free(data);
@@ -421,7 +421,7 @@ static int process_resource_list(const char *rl_uri, process_params_t *params)
 		cds_free(data);
 	}
 	if (!list) return RES_INTERNAL_ERR; /* ??? */
-	
+
 	res = process_list(list, params);
 	if (list) {
 		free_list(list);
@@ -430,8 +430,8 @@ static int process_resource_list(const char *rl_uri, process_params_t *params)
 	return res;
 }
 
-static int create_flat_list(service_t *srv, 
-		xcap_query_params_t *xcap_params, 
+static int create_flat_list(service_t *srv,
+		xcap_query_params_t *xcap_params,
 		flat_list_t **dst)
 {
 	process_params_t params;
@@ -443,7 +443,7 @@ static int create_flat_list(service_t *srv,
 	params.flat_last = NULL;
 	params.traversed = NULL;
 	params.traversed_last = NULL;
-	
+
 	if (srv->content_type == stc_list) {
 		res = process_list(srv->content.list, &params);
 	}
@@ -453,7 +453,7 @@ static int create_flat_list(service_t *srv,
 	if (dst) *dst = params.flat;
 
 	free_traversed_list(params.traversed);
-	
+
 	return res;
 }
 
@@ -463,7 +463,7 @@ static int create_flat_list(service_t *srv,
 static int str_strcmp(const str_t *a, const char *b)
 {
 	int i;
-	
+
 	if (!a) {
 		if (!b) return 0;
 		else return 1;
@@ -489,7 +489,7 @@ static int verify_package(service_t *srv, const str_t *package)
 	if (!package->len) return 0;
 	if (!package->s) return 0;
 	if (!srv) return 1;
-	
+
 	if (srv->packages) {
 		e = SEQUENCE_FIRST(srv->packages->package);
 		while (e) {
@@ -505,9 +505,9 @@ static int verify_package(service_t *srv, const str_t *package)
 static service_t *find_service(rls_services_t *rls, const str_t *uri)
 {
 	service_t *srv;
-	
+
 	if (!rls) return NULL;
-	
+
 	srv = SEQUENCE_FIRST(rls->rls_services);
 	while (srv) {
 		/* TRACE_LOG("comparing %s to %.*s\n", srv->uri, FMT_STR(*uri)); */
@@ -519,7 +519,7 @@ static service_t *find_service(rls_services_t *rls, const str_t *uri)
 
 /* ------- rls examining ------- */
 
-int get_rls(const str_t *uri, xcap_query_params_t *xcap_params, 
+int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 		const str_t *package, flat_list_t **dst)
 {
 	char *data = NULL;
@@ -530,15 +530,15 @@ int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 	int res;
 
 	if (!dst) return RES_INTERNAL_ERR;
-	
+
 	/* get basic document */
-	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services, 
+	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services,
 			filename, xcap_params);
 	if (!xcap_uri) {
 		ERROR_LOG("can't get XCAP uri\n");
 		return RES_XCAP_QUERY_ERR;
 	}
-	
+
 	res = xcap_query(xcap_uri, xcap_params, &data, &dsize);
 	if (res != 0) {
 		ERROR_LOG("XCAP problems for uri \'%s\'\n", xcap_uri);
@@ -549,7 +549,7 @@ int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 		return RES_XCAP_QUERY_ERR;
 	}
 	cds_free(xcap_uri);
-	
+
 	/* parse document as a service element in rls-sources */
 	if (parse_service(data, dsize, &service) != 0) {
 		ERROR_LOG("Parsing problems!\n");
@@ -561,7 +561,7 @@ int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 	}
 /*	DEBUG_LOG("%.*s\n", dsize, data);*/
 	if (data) cds_free(data);
-	
+
 	if (!service) {
 		DEBUG_LOG("Empty service!\n");
 		return RES_XCAP_QUERY_ERR;
@@ -572,7 +572,7 @@ int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 		free_service(service);
 		return RES_BAD_EVENT_PACKAGE_ERR;
 	}
-	
+
 	/* create flat document */
 	res = create_flat_list(service, xcap_params, dst);
 	if (res != RES_OK) {
@@ -583,13 +583,13 @@ int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 		return res;
 	}
 	free_service(service);
-	
+
 	return RES_OK;
 }
 
-int get_rls_from_full_doc(const str_t *uri, 
+int get_rls_from_full_doc(const str_t *uri,
 		/* const str_t *filename,  */
-		xcap_query_params_t *xcap_params, 
+		xcap_query_params_t *xcap_params,
 		const str_t *package, flat_list_t **dst)
 {
 	char *data = NULL;
@@ -602,16 +602,16 @@ int get_rls_from_full_doc(const str_t *uri,
 	str_t *filename = NULL;
 
 	if (!dst) return RES_INTERNAL_ERR;
-	
+
 
 	/* get basic document */
-	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services, 
+	xcap_uri = xcap_uri_for_global_document(xcap_doc_rls_services,
 			filename, xcap_params);
 	if (!xcap_uri) {
 		ERROR_LOG("can't get XCAP uri\n");
 		return -1;
 	}
-	
+
 	res = xcap_query(xcap_uri, xcap_params, &data, &dsize);
 	if (res != 0) {
 		ERROR_LOG("XCAP problems for uri \'%s\'\n", xcap_uri);
@@ -622,7 +622,7 @@ int get_rls_from_full_doc(const str_t *uri,
 		return RES_XCAP_QUERY_ERR;
 	}
 	cds_free(xcap_uri);
-	
+
 	/* parse document as a service element in rls-sources */
 	if (parse_rls_services_xml(data, dsize, &rls) != 0) {
 		ERROR_LOG("Parsing problems!\n");
@@ -637,10 +637,10 @@ int get_rls_from_full_doc(const str_t *uri,
 
 	/* try to find given service according to uri */
 	canonicalize_uri(uri, &curi);
-	service = find_service(rls, &curi); 
+	service = find_service(rls, &curi);
 	if (!service) DEBUG_LOG("Service %.*s not found!\n", FMT_STR(curi));
 	str_free_content(&curi);
-	
+
 	if (!service) {
 		if (rls) free_rls_services(rls);
 		return RES_XCAP_QUERY_ERR;
@@ -651,7 +651,7 @@ int get_rls_from_full_doc(const str_t *uri,
 		free_rls_services(rls);
 		return RES_BAD_EVENT_PACKAGE_ERR;
 	}
-	
+
 	/* create flat document */
 	res = create_flat_list(service, xcap_params, dst);
 	if (res != RES_OK) {
@@ -662,14 +662,14 @@ int get_rls_from_full_doc(const str_t *uri,
 		return res;
 	}
 	free_rls_services(rls);
-	
+
 	return RES_OK;
 }
 
 static list_t *find_list(list_t *root, const char *name)
 {
 	list_content_t *c;
-	
+
 	if (!root) return root;
 	if (!name) return root;
 	if (!*name) return root; /* empty name = whole doc */
@@ -678,7 +678,7 @@ static list_t *find_list(list_t *root, const char *name)
 	while (c) {
 		if (c->type == lct_list) {
 			if (c->u.list) {
-				if (strcmp(name, c->u.list->name) == 0) 
+				if (strcmp(name, c->u.list->name) == 0)
 					return c->u.list;
 			}
 		}
@@ -686,25 +686,25 @@ static list_t *find_list(list_t *root, const char *name)
 	}
 
 	ERROR_LOG("list \'%s\' not found\n", name);
-	
+
 	return NULL;
 }
 
 /* catches and processes user's resource list as rls-services document */
-int get_resource_list_from_full_doc(const str_t *user, 
-		const str_t *filename, 
-		xcap_query_params_t *xcap_params, 
+int get_resource_list_from_full_doc(const str_t *user,
+		const str_t *filename,
+		xcap_query_params_t *xcap_params,
 		const char *list_name, flat_list_t **dst)
 {
 	char *data = NULL;
 	int dsize = 0;
-	service_t *service = NULL; 
+	service_t *service = NULL;
 	list_t *list = NULL, *right = NULL;
 	int res;
 	char *uri = NULL;
 
 	if (!dst) return RES_INTERNAL_ERR;
-	
+
 	/* get basic document */
 	uri = xcap_uri_for_users_document(xcap_doc_resource_lists,
 			user, filename, xcap_params);
@@ -723,7 +723,7 @@ int get_resource_list_from_full_doc(const str_t *user,
 		return RES_XCAP_QUERY_ERR;
 	}
 	cds_free(uri);
-	
+
 	/* parse document as a list element in resource-lists */
 	if (parse_as_list_content_xml(data, dsize, &list) != 0) {
 		ERROR_LOG("Parsing problems!\n");
@@ -737,7 +737,7 @@ int get_resource_list_from_full_doc(const str_t *user,
 	if (data) cds_free(data);
 
 	/* rs -> list */
-	
+
 	if (!list) {
 		ERROR_LOG("Empty resource list!\n");
 		*dst = NULL;
@@ -747,7 +747,7 @@ int get_resource_list_from_full_doc(const str_t *user,
 
 	/* search for right list element */
 	right = find_list(list, list_name);
-		
+
 	service = (service_t*)cds_malloc(sizeof(*service));
 	if (!service) {
 		ERROR_LOG("Can't allocate memory!\n");
@@ -763,13 +763,13 @@ int get_resource_list_from_full_doc(const str_t *user,
 
 	service->content.list = list; /* free whole document not only "right" list */
 	free_service(service);
-	
+
 	if (res != RES_OK) {
 		ERROR_LOG("Flat list creation error\n");
 		free_flat_list(*dst);
 		*dst = NULL;
 		return res;
 	}
-	
+
 	return RES_OK;
 }

+ 4 - 4
src/lib/xcap/resource_list.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -42,11 +42,11 @@ typedef struct _flat_list_t {
 
 char *xcap_uri_for_rls_resource(const str_t *xcap_root, const str_t *uri);
 void canonicalize_uri(const str_t *uri, str_t *dst);
-int get_rls(const str_t *uri, xcap_query_params_t *xcap_params, 
+int get_rls(const str_t *uri, xcap_query_params_t *xcap_params,
 		const str_t *package, flat_list_t **dst);
-int get_rls_from_full_doc(const str_t *uri, 
+int get_rls_from_full_doc(const str_t *uri,
 		/* const str_t *filename,  */
-		xcap_query_params_t *xcap_params, 
+		xcap_query_params_t *xcap_params,
 		const str_t *package, flat_list_t **dst);
 int get_resource_list_from_full_doc(const str_t *xcap_root, const str_t *user, xcap_query_params_t *xcap_params, const char *list_name, flat_list_t **dst);
 /* TODO: int get_resource_list(const str_t *xcap_root, const str_t *user, xcap_query_t *xcap_params, const str_t *list_name, flat_list_t **dst); */

+ 28 - 28
src/lib/xcap/resource_lists_parser.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -41,7 +41,7 @@ static int read_entry_ref(xmlNode *entry_node, entry_ref_t **dst)
 {
 	xmlAttr *a;
 	const char *a_val;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (entry_ref_t*)cds_malloc(sizeof(entry_ref_t));
@@ -61,7 +61,7 @@ static int read_name(xmlNode *name_node, display_name_t **dst)
 {
 	xmlAttr *a;
 	const char *a_val;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (display_name_t*)cds_malloc(sizeof(display_name_t));
@@ -86,7 +86,7 @@ static int read_names(xmlNode *entry_node, display_name_t **dst)
 	xmlNode *n;
 	display_name_t *name, *last;
 	int res = 0;
-	
+
 	last = NULL;
 	*dst = NULL;
 	n = entry_node->children;
@@ -112,7 +112,7 @@ static int read_entry(xmlNode *entry_node, entry_t **dst)
 {
 	xmlAttr *a;
 	const char *a_val;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (entry_t*)cds_malloc(sizeof(entry_t));
@@ -133,7 +133,7 @@ static int read_external(xmlNode *entry_node, external_t **dst)
 {
 	xmlAttr *a;
 	const char *a_val;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (external_t*)cds_malloc(sizeof(external_t));
@@ -156,7 +156,7 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 	const char *a_val;
 	xmlNode *n;
 	list_content_t *l, *last_l;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (list_t*)cds_malloc(sizeof(list_t));
@@ -180,7 +180,7 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 			l = (list_content_t*) cds_malloc(sizeof(list_content_t));
 			if (!l) return -1;
 			memset(l, 0, sizeof(*l));
-			
+
 			if (cmp_node(n, "list", rl_namespace) >= 0) {
 				res = read_list(n, &l->u.list, 0);
 				if (res == 0) {
@@ -192,7 +192,7 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 				}
 				else break;
 			}
-			
+
 			if (cmp_node(n, "entry", rl_namespace) >= 0) {
 				res = read_entry(n, &l->u.entry);
 				if (res == 0) {
@@ -204,7 +204,7 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 				}
 				else break;
 			}
-			
+
 			if (cmp_node(n, "entry-ref", rl_namespace) >= 0) {
 				res = read_entry_ref(n, &l->u.entry_ref);
 				if (res == 0) {
@@ -216,7 +216,7 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 				}
 				else break;
 			}
-			
+
 			if (cmp_node(n, "external", rl_namespace) >= 0) {
 				res = read_external(n, &l->u.external);
 				if (res == 0) {
@@ -228,16 +228,16 @@ int read_list(xmlNode *list_node, list_t **dst, int read_content_only)
 				}
 				else break;
 			}
-			
+
 			if (l) {
 				cds_free(l);
 				l = NULL;
 			}
-			
+
 		}
 		n = n->next;
 	}
-	
+
 	return 0;
 }
 
@@ -248,11 +248,11 @@ static int read_resource_lists(xmlNode *root, resource_lists_t **dst)
 	xmlNode *n;
 	list_t *l, *last_l;
 	int res = 0;
-	
+
 	if (!dst) return -1;
 	else *dst = NULL;
 	if (!root) return -1;
-	
+
 	if (cmp_node(root, "resource-lists", rl_namespace) < 0) {
 		ERROR_LOG("document is not a resource-lists\n");
 		return -1;
@@ -262,7 +262,7 @@ static int read_resource_lists(xmlNode *root, resource_lists_t **dst)
 	if (!rl) return -2;
 	*dst = rl;
 	rl->lists = NULL;
-	
+
 	last_l = NULL;
 	n = root->children;
 	while (n) {
@@ -292,7 +292,7 @@ int parse_resource_lists_xml(const char *data, int data_len, resource_lists_t **
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_resource_lists(xmlDocGetRootElement(doc), dst);
 
 	xmlFreeDoc(doc);
@@ -310,7 +310,7 @@ int parse_list_xml(const char *data, int data_len, list_t **dst)
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_list(xmlDocGetRootElement(doc), dst, 0);
 
 	xmlFreeDoc(doc);
@@ -328,7 +328,7 @@ int parse_as_list_content_xml(const char *data, int data_len, list_t **dst)
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_list(xmlDocGetRootElement(doc), dst, 1);
 
 	xmlFreeDoc(doc);
@@ -346,7 +346,7 @@ int parse_entry_xml(const char *data, int data_len, entry_t **dst)
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_entry(xmlDocGetRootElement(doc), dst);
 
 	xmlFreeDoc(doc);
@@ -364,25 +364,25 @@ void free_display_name(display_name_t *n)
 void free_display_names(display_name_t *sequence_first)
 {
 	display_name_t *d, *n;
-	
+
 	if (!sequence_first) return;
-	
+
 	d = SEQUENCE_FIRST(sequence_first);
 	while (d) {
 		n = SEQUENCE_NEXT(d);
 		free_display_name(d);
 		d = n;
 	}
-	
+
 }
 
 void free_entry(entry_t *e)
 {
 	if (!e) return;
-	
+
 	if (e->uri) cds_free(e->uri);
 	free_display_names(e->display_names);
-	
+
 	cds_free(e);
 }
 
@@ -405,7 +405,7 @@ void free_list(list_t *l)
 	list_content_t *e, *f;
 
 	if (!l) return;
-	
+
 	if (l->name) cds_free(l->name);
 
 	e = SEQUENCE_FIRST(l->content);
@@ -429,7 +429,7 @@ void free_resource_lists(resource_lists_t *rl)
 {
 	list_t *e, *f;
 	if (!rl) return;
-	
+
 	e = SEQUENCE_FIRST(rl->lists);
 	while (e) {
 		f = SEQUENCE_NEXT(e);

+ 7 - 7
src/lib/xcap/resource_lists_parser.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -50,7 +50,7 @@ typedef struct {
 	/* SEQUENCE(display_name_t) display_names; */
 } entry_ref_t;
 
-typedef enum { 
+typedef enum {
 	lct_list,
 	lct_entry,
 	lct_entry_ref,
@@ -61,7 +61,7 @@ struct _list_t;
 
 typedef struct _list_content_t {
 	SEQUENCE_ABLE(struct _list_content_t)
-		
+
 	list_content_type_t type;
 	union {
 		struct _list_t *list;
@@ -73,19 +73,19 @@ typedef struct _list_content_t {
 
 typedef struct _list_t {
 	SEQUENCE_ABLE(struct _list_t)
-		
+
 /*	entry_t *entries;*/
 	char *display_name;
-	
+
 	SEQUENCE(list_content_t) content;
-	
+
 	char *name;
 } list_t;
 
 typedef struct {
 	/* list_t *lists; */
 	SEQUENCE(list_t) lists;
-	
+
 } resource_lists_t;
 
 int parse_resource_lists_xml(const char *data, int data_len, resource_lists_t **dst);

+ 15 - 15
src/lib/xcap/rls_services_parser.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -41,7 +41,7 @@ static int read_entry(xmlNode *entry_node, entry_t **dst)
 {
 	xmlAttr *a;
 	const char *a_val;
-	
+
 	/ * allocate memory and prepare empty node * /
 	if (!dst) return -1;
 	*dst = (entry_t*)cds_malloc(sizeof(entry_t));
@@ -61,7 +61,7 @@ static int read_package(xmlNode *n, package_t **dst)
 {
 	const char *name;
 	if (!dst) return -1;
-	
+
 	*dst = (package_t*)cds_malloc(sizeof(package_t));
 	if (!(*dst)) return -2;
 	memset(*dst, 0, sizeof(package_t));
@@ -76,7 +76,7 @@ static int read_packages(xmlNode *list_node, packages_t **dst)
 	int res = 0;
 	xmlNode *n;
 	package_t *p, *last;
-	
+
 	/* allocate memory and prepare empty node */
 	if (!dst) return -1;
 	*dst = (packages_t*)cds_malloc(sizeof(packages_t));
@@ -97,7 +97,7 @@ static int read_packages(xmlNode *list_node, packages_t **dst)
 		}
 		n = n->next;
 	}
-	
+
 	return 0;
 }
 
@@ -158,7 +158,7 @@ int read_service(xmlNode *list_node, service_t **dst)
 		}
 		n = n->next;
 	}
-	
+
 	return 0;
 }
 
@@ -168,10 +168,10 @@ static int read_rls_services(xmlNode *root, rls_services_t **dst)
 	xmlNode *n;
 	service_t *l, *last_l;
 	int res = 0;
-	
+
 	if (!root) return -1;
 	if (!dst) return -1;
-	
+
 	if (cmp_node(root, "rls-services", rls_namespace) < 0) {
 		ERROR_LOG("document is not a rls-services\n");
 		return -1;
@@ -180,7 +180,7 @@ static int read_rls_services(xmlNode *root, rls_services_t **dst)
 	*dst = (rls_services_t*)cds_malloc(sizeof(rls_services_t));
 	if (!(*dst)) return -2;
 	(*dst)->rls_services = NULL;
-	
+
 	last_l = NULL;
 	n = root->children;
 	while (n) {
@@ -209,7 +209,7 @@ int parse_rls_services_xml(const char *data, int data_len, rls_services_t **dst)
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_rls_services(xmlDocGetRootElement(doc), dst);
 
 	xmlFreeDoc(doc);
@@ -226,7 +226,7 @@ int parse_service(const char *data, int data_len, service_t **dst)
 		ERROR_LOG("can't parse document\n");
 		return -1;
 	}
-	
+
 	res = read_service(xmlDocGetRootElement(doc), dst);
 
 	xmlFreeDoc(doc);
@@ -244,7 +244,7 @@ static void free_packages(packages_t *p)
 {
 	package_t *e, *f;
 	if (!p) return;
-	
+
 	e = SEQUENCE_FIRST(p->package);
 	while (e) {
 		f = SEQUENCE_NEXT(e);
@@ -257,14 +257,14 @@ static void free_packages(packages_t *p)
 void free_service(service_t *s)
 {
 	if (!s) return;
-	
+
 	if (s->uri) cds_free(s->uri);
 
 	switch (s->content_type) {
 		case stc_list: free_list(s->content.list); break;
 		case stc_resource_list: cds_free(s->content.resource_list); break;
 	}
-	
+
 	free_packages(s->packages);
 
 	cds_free(s);
@@ -274,7 +274,7 @@ void free_rls_services(rls_services_t *rls)
 {
 	service_t *e, *f;
 	if (!rls) return;
-	
+
 	e = SEQUENCE_FIRST(rls->rls_services);
 	while (e) {
 		f = SEQUENCE_NEXT(e);

+ 5 - 5
src/lib/xcap/rls_services_parser.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -38,22 +38,22 @@ typedef struct _packages_t {
 	SEQUENCE(package_t) package;
 } packages_t;
 
-typedef enum { 
+typedef enum {
 	stc_list,
 	stc_resource_list,
 } service_content_type_t;
 
 typedef struct _service_t {
 	SEQUENCE_ABLE(struct _service_t)
-		
+
 	packages_t *packages;
-	
+
 	service_content_type_t content_type;
 	union {
 		list_t *list;
 		char *resource_list; /* uri */
 	} content;
-	
+
 	char *uri;
 } service_t;
 

+ 33 - 33
src/lib/xcap/xcap_client.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -77,7 +77,7 @@ static int ends_with_separator(str_t *s)
 }
 
 char *xcap_uri_for_users_document(xcap_document_type_t doc_type,
-		const str_t *username, 
+		const str_t *username,
 		const str_t*filename,
 		xcap_query_params_t *params)
 {
@@ -103,7 +103,7 @@ char *xcap_uri_for_users_document(xcap_document_type_t doc_type,
 		dstr_append_str(&s, get_default_user_doc(doc_type));
 	}
 	/* res = dstr_get_str(&s, dst); */
-	
+
 	l = dstr_get_data_length(&s);
 	if (l > 0) {
 		dst = (char *)cds_malloc(l + 1);
@@ -113,14 +113,14 @@ char *xcap_uri_for_users_document(xcap_document_type_t doc_type,
 		}
 		else ERROR_LOG("can't allocate memory (%d bytes)\n", l);
 	}
-	
+
 	dstr_destroy(&s);
 	return dst;
 }
 
 
 char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
-		const str_t *filename, 
+		const str_t *filename,
 		xcap_query_params_t *params)
 {
 	dstring_t s;
@@ -145,7 +145,7 @@ char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
 		dstr_append_zt(&s, "/global/index");
 	}
 	/* res = dstr_get_str(&s, dst); */
-	
+
 	l = dstr_get_data_length(&s);
 	if (l > 0) {
 		dst = (char *)cds_malloc(l + 1);
@@ -154,7 +154,7 @@ char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
 			dst[l] = 0;
 		}
 	}
-	
+
 	dstr_destroy(&s);
 	return dst;
 }
@@ -163,7 +163,7 @@ char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
 
 #include "sr_module.h"
 
-int xcap_query(const char *uri, 
+int xcap_query(const char *uri,
 		xcap_query_params_t *params, char **buf, int *bsize)
 {
 	static xcap_query_func query = NULL;
@@ -178,7 +178,7 @@ int xcap_query(const char *uri,
 		/* no function for doing XCAP queries */
 		return -1;
 	}
-	
+
 	/* all XCAP queries are done through XCAP module */
 	return query(uri, params, buf, bsize);
 }
@@ -209,7 +209,7 @@ int xcap_query(const char *uri, xcap_query_params_t *params, char **buf, int *bs
 	char *auth = NULL;
 	int i;
 	long auth_methods;
-	
+
 	if (!uri) {
 		ERROR_LOG("BUG: no uri given\n");
 		return -1;
@@ -233,14 +233,14 @@ int xcap_query(const char *uri, xcap_query_params_t *params, char **buf, int *bs
 	}
 
 	auth_methods = CURLAUTH_BASIC | CURLAUTH_DIGEST;
-	
+
 	dstr_init(&data, 512);
-	
-	if (!handle) handle = curl_easy_init(); 
+
+	if (!handle) handle = curl_easy_init();
 	if (handle) {
 		curl_easy_setopt(handle, CURLOPT_URL, uri);
 		/* TRACE_LOG("uri: %s\n", uri ? uri : "<null>"); */
-		
+
 		/* do not store data into a file - store them in memory */
 		curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, write_data_func);
 		curl_easy_setopt(handle, CURLOPT_WRITEDATA, &data);
@@ -249,7 +249,7 @@ int xcap_query(const char *uri, xcap_query_params_t *params, char **buf, int *bs
 		/* be quiet */
 		curl_easy_setopt(handle, CURLOPT_MUTE, 1);
 #endif /* CURLOPT_MUTE */
-		
+
 		/* non-2xx => error */
 		curl_easy_setopt(handle, CURLOPT_FAILONERROR, 1);
 
@@ -265,15 +265,15 @@ int xcap_query(const char *uri, xcap_query_params_t *params, char **buf, int *bs
 				curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0);
 			}
 		}
-		
+
 		/* follow redirects (needed for apache mod_speling - case insesitive names) */
 		curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1);
-		
+
 	/*	curl_easy_setopt(handle, CURLOPT_TCP_NODELAY, 1);
 		curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, 10);*/
-		
+
 		/* Accept headers */
-		
+
 		res = curl_easy_perform(handle);
 		/* curl_easy_cleanup(handle); */ /* FIXME: experimental */
 	}
@@ -311,26 +311,26 @@ void free_xcap_params_content(xcap_query_params_t *params)
 int dup_xcap_params(xcap_query_params_t *dst, xcap_query_params_t *src)
 {
 	int res = -10;
-	
+
 	if (dst) memset(dst, 0, sizeof(*dst));
-	
+
 	if (src && dst) {
 		res = 0;
-		
+
 		res = str_dup(&dst->xcap_root, &src->xcap_root);
 		if (res == 0) res = str_dup(&dst->auth_user, &src->auth_user);
 		if (res == 0) res = str_dup(&dst->auth_pass, &src->auth_pass);
-		
+
 		if (res != 0) free_xcap_params_content(dst);
 	}
-	
+
 	return res;
 }
 
 int get_inline_xcap_buf_len(xcap_query_params_t *params)
 {
 	int len;
-	
+
 	/* counts the length for data buffer storing values of
 	 * xcap parameter members */
 	if (!params) {
@@ -348,13 +348,13 @@ int get_inline_xcap_buf_len(xcap_query_params_t *params)
 int dup_xcap_params_inline(xcap_query_params_t *dst, xcap_query_params_t *src, char *data_buffer)
 {
 	int res = -10;
-	
+
 	/* copies structure into existing buffer */
 	if (dst) {
 		memset(dst, 0, sizeof(*dst));
 		res = 0;
 	}
-	
+
 	if (src && dst) {
 		dst->xcap_root.s = data_buffer;
 		str_cpy(&dst->xcap_root, &src->xcap_root);
@@ -370,7 +370,7 @@ int dup_xcap_params_inline(xcap_query_params_t *dst, xcap_query_params_t *src, c
 int serialize_xcap_params(sstream_t *ss, xcap_query_params_t *xp)
 {
 	int res = 0;
-	
+
 	if (is_input_sstream(ss)) {
 		memset(xp, 0, sizeof(*xp));
 	}
@@ -387,14 +387,14 @@ int str2xcap_params(xcap_query_params_t *dst, const str_t *src)
 	sstream_t store;
 
 	if (!src) return -1;
-	
+
 	init_input_sstream(&store, src->s, src->len);
 	if (serialize_xcap_params(&store, dst) != 0) {
 		ERROR_LOG("can't de-serialize xcap_params\n");
 		res = -1;
-	}	
+	}
 	destroy_sstream(&store);
-	
+
 	return res;
 }
 
@@ -402,9 +402,9 @@ int xcap_params2str(str_t *dst, xcap_query_params_t *src)
 {
 	int res = 0;
 	sstream_t store;
-	
+
 	init_output_sstream(&store, 256);
-	
+
 	if (serialize_xcap_params(&store, src) != 0) {
 		ERROR_LOG("can't serialize dialog\n");
 		res = -1;

+ 7 - 7
src/lib/xcap/xcap_client.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -36,7 +36,7 @@ typedef struct {
 	str_t auth_user;
 	/** password used for authentication */
 	str_t auth_pass;
-	/** Accept unverifiable peers (ignore information 
+	/** Accept unverifiable peers (ignore information
 	 * stored in certificate and trust a certificate
 	 * without know CA). */
 	int enable_unverified_ssl_peer;
@@ -50,7 +50,7 @@ typedef enum {
 } xcap_document_type_t;
 
 char *xcap_uri_for_users_document(xcap_document_type_t doc_type,
-		const str_t *username, 
+		const str_t *username,
 		const str_t*filename,
 		xcap_query_params_t *params);
 
@@ -58,15 +58,15 @@ char *xcap_uri_for_global_document(xcap_document_type_t doc_type,
 		const str_t *filename,
 		xcap_query_params_t *params);
 
-/** Sends a XCAP query to the destination and using parameters from 
+/** Sends a XCAP query to the destination and using parameters from
  * query variable a returns received data in output variables buf
  * and bsize. */
 /* URI is absolute HTTP/HTTPS uri for the query  */
-int xcap_query(const char *uri, xcap_query_params_t *params, 
+int xcap_query(const char *uri, xcap_query_params_t *params,
 		char **buf, int *bsize);
 
-typedef int (*xcap_query_func)(const char *uri, 
-		xcap_query_params_t *params, 
+typedef int (*xcap_query_func)(const char *uri,
+		xcap_query_params_t *params,
 		char **buf, int *bsize);
 
 void free_xcap_params_content(xcap_query_params_t *params);

+ 1 - 1
src/lib/xcap/xcap_result_codes.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.

+ 5 - 5
src/lib/xcap/xml_utils.c

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.
@@ -84,7 +84,7 @@ xmlNode *find_node(xmlNode *parent, const char *name, const char *nspace)
 const char *find_value(xmlNode *first_child)
 {
 	const char *s = NULL;
-	
+
 	xmlNode *c = first_child;
 	while (c) {
 		if (c->type == XML_TEXT_NODE) {
@@ -93,7 +93,7 @@ const char *find_value(xmlNode *first_child)
 		}
 		c = c->next;
 	}
-	
+
 	return s;
 }
 
@@ -113,7 +113,7 @@ xmlAttr *find_attr(xmlAttr *first, const char *name)
 	return a;
 }
 
-const char *get_attr_value(xmlAttr *a) 
+const char *get_attr_value(xmlAttr *a)
 {
 	if (!a) return NULL;
 	return find_value(a->children);
@@ -123,7 +123,7 @@ int cmp_node(xmlNode *node, const char *name, const char *nspace)
 {
 	if (!node) return -1;
 	if (node->type != XML_ELEMENT_NODE) return -1;
-	
+
 	if (xmlstrcmp(node->name, name) != 0) return -1;
 	if (!nspace) return 0;
 	if (!node->ns) {

+ 1 - 1
src/lib/xcap/xml_utils.h

@@ -1,4 +1,4 @@
-/* 
+/*
  * Copyright (C) 2005 iptelorg GmbH
  *
  * This file is part of ser, a free SIP server.