Browse code

pua_bla: clang-format

* use STR_NULL

(cherry picked from commit e542b779b29bda2d0a953a4e55921edc466a3936)

Victor Seva authored on 29/07/2020 11:28:39
Showing 5 changed files
... ...
@@ -30,219 +30,188 @@
30 30
 #include "../pua/hash.h"
31 31
 #include "pua_bla.h"
32 32
 
33
-int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
33
+int bla_handle_notify(struct sip_msg *msg, char *s1, char *s2)
34 34
 {
35
- 	publ_info_t publ;
35
+	publ_info_t publ;
36 36
 	struct to_body *pto = NULL, TO = {0}, *pfrom = NULL;
37
- 	str body;
38
- 	ua_pres_t dialog;
39
- 	unsigned int expires= 0;
40
-	struct hdr_field* hdr;
37
+	str body;
38
+	ua_pres_t dialog;
39
+	unsigned int expires = 0;
40
+	struct hdr_field *hdr;
41 41
 	str subs_state;
42
-	int found= 0;
43
- 	str extra_headers= {0, 0};
44
- 	static char buf[255];
42
+	int found = 0;
43
+	str extra_headers = {0, 0};
44
+	static char buf[255];
45 45
 	str contact;
46 46
 
47 47
 	memset(&publ, 0, sizeof(publ_info_t));
48 48
 	memset(&dialog, 0, sizeof(ua_pres_t));
49 49
 
50
-  	LM_DBG("start\n");
51
-
52
-  	if ( parse_headers(msg,HDR_EOH_F, 0)==-1 )
53
-  	{
54
-  		LM_ERR("parsing headers\n");
55
-  		return -1;
56
-  	}
57
-
58
-  	if( msg->to==NULL || msg->to->body.s==NULL)
59
-  	{
60
-  		LM_ERR("cannot parse TO header\n");
61
-  		goto error;
62
-  	}
63
-  	/* examine the to header */
64
-  	if(msg->to->parsed != NULL)
65
-  	{
66
-  		pto = (struct to_body*)msg->to->parsed;
67
-  		LM_DBG("'To' header ALREADY PARSED: <%.*s>\n",
68
-  				pto->uri.len, pto->uri.s );
69
-  	}
70
- 	else
71
-  	{
72
-  		parse_to(msg->to->body.s,msg->to->body.s + msg->to->body.len + 1, &TO);
73
-  		if(TO.uri.len <= 0)
74
-  		{
75
-  			LM_DBG("'To' header NOT parsed\n");
76
-  			goto error;
77
-  		}
78
-  		pto = &TO;
79
-  	}
80
-  	publ.pres_uri= &pto->uri;
81
-  	dialog.watcher_uri= publ.pres_uri;
82
-
83
-  	if (pto->tag_value.s==NULL || pto->tag_value.len==0 )
84
-  	{
85
-  		LM_ERR("NULL to_tag value\n");
50
+	LM_DBG("start\n");
51
+
52
+	if(parse_headers(msg, HDR_EOH_F, 0) == -1) {
53
+		LM_ERR("parsing headers\n");
54
+		return -1;
55
+	}
56
+
57
+	if(msg->to == NULL || msg->to->body.s == NULL) {
58
+		LM_ERR("cannot parse TO header\n");
59
+		goto error;
60
+	}
61
+	/* examine the to header */
62
+	if(msg->to->parsed != NULL) {
63
+		pto = (struct to_body *)msg->to->parsed;
64
+		LM_DBG("'To' header ALREADY PARSED: <%.*s>\n", pto->uri.len,
65
+				pto->uri.s);
66
+	} else {
67
+		parse_to(msg->to->body.s, msg->to->body.s + msg->to->body.len + 1, &TO);
68
+		if(TO.uri.len <= 0) {
69
+			LM_DBG("'To' header NOT parsed\n");
70
+			goto error;
71
+		}
72
+		pto = &TO;
73
+	}
74
+	publ.pres_uri = &pto->uri;
75
+	dialog.watcher_uri = publ.pres_uri;
76
+
77
+	if(pto->tag_value.s == NULL || pto->tag_value.len == 0) {
78
+		LM_ERR("NULL to_tag value\n");
79
+		goto error;
80
+	}
81
+	dialog.from_tag = pto->tag_value;
82
+
83
+	if(msg->callid == NULL || msg->callid->body.s == NULL) {
84
+		LM_ERR("cannot parse callid header\n");
85
+		goto error;
86
+	}
87
+	dialog.call_id = msg->callid->body;
88
+
89
+	if(!msg->from || !msg->from->body.s) {
90
+		LM_ERR("cannot find 'from' header!\n");
91
+		goto error;
92
+	}
93
+	if(msg->from->parsed == NULL) {
94
+		LM_DBG(" 'From' header not parsed\n");
95
+		/* parsing from header */
96
+		if(parse_from_header(msg) < 0) {
97
+			LM_DBG(" ERROR cannot parse From header\n");
98
+			goto error;
99
+		}
100
+	}
101
+	pfrom = (struct to_body *)msg->from->parsed;
102
+	dialog.pres_uri = &pfrom->uri;
103
+
104
+	if(pfrom->tag_value.s == NULL || pfrom->tag_value.len == 0) {
105
+		LM_ERR("no from tag value present\n");
86 106
 		goto error;
87
-  	}
88
-  	dialog.from_tag= pto->tag_value;
89
-
90
-  	if( msg->callid==NULL || msg->callid->body.s==NULL)
91
- 	{
92
-  		LM_ERR("cannot parse callid header\n");
93
-  		goto error;
94
-  	}
95
-  	dialog.call_id = msg->callid->body;
96
-
97
-  	if (!msg->from || !msg->from->body.s)
98
-  	{
99
-  		LM_ERR("cannot find 'from' header!\n");
100
-  		goto error;
101
-  	}
102
-  	if (msg->from->parsed == NULL)
103
-  	{
104
-  		LM_DBG(" 'From' header not parsed\n");
105
-  		/* parsing from header */
106
-  		if ( parse_from_header( msg )<0 )
107
-  		{
108
-  			LM_DBG(" ERROR cannot parse From header\n");
109
-  			goto error;
110
-  		}
111
- 	}
112
- 	pfrom = (struct to_body*)msg->from->parsed;
113
- 	dialog.pres_uri= &pfrom->uri;
114
-
115
- 	if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
116
- 	{
117
- 		LM_ERR("no from tag value present\n");
118
- 		goto error;
119
- 	}
120
-
121
- 	dialog.to_tag= pfrom->tag_value;
122
- 	dialog.event= BLA_EVENT;
123
- 	dialog.flag= BLA_SUBSCRIBE;
124
- 	if(pua_is_dialog(&dialog)< 0)
125
- 	{
126
- 		LM_ERR("Notify in a non existing dialog\n");
127
- 		goto error;
128
- 	}
129
- 	LM_DBG("found a matching dialog\n");
130
-
131
- 	/* parse Subscription-State and extract expires if existing */
107
+	}
108
+
109
+	dialog.to_tag = pfrom->tag_value;
110
+	dialog.event = BLA_EVENT;
111
+	dialog.flag = BLA_SUBSCRIBE;
112
+	if(pua_is_dialog(&dialog) < 0) {
113
+		LM_ERR("Notify in a non existing dialog\n");
114
+		goto error;
115
+	}
116
+	LM_DBG("found a matching dialog\n");
117
+
118
+	/* parse Subscription-State and extract expires if existing */
132 119
 	hdr = msg->headers;
133
-	while (hdr!= NULL)
134
-	{
135
- 		if(cmp_hdrname_strzn(&hdr->name, "Subscription-State",18)==0)
136
- 		{
137
- 			found = 1;
138
- 			break;
139
- 		}
120
+	while(hdr != NULL) {
121
+		if(cmp_hdrname_strzn(&hdr->name, "Subscription-State", 18) == 0) {
122
+			found = 1;
123
+			break;
124
+		}
140 125
 		hdr = hdr->next;
141
-  	}
142
-	if(found==0 )
143
-	{
126
+	}
127
+	if(found == 0) {
144 128
 		LM_ERR("No Subscription-State header found\n");
145 129
 		goto error;
146
- 	}
147
- 	subs_state= hdr->body;
148
-	if(strncmp(subs_state.s, "terminated", 10)== 0)
149
- 		expires= 0;
150
- 	else
151
- 		if(strncmp(subs_state.s, "active", 6)== 0 ||
152
-				strncmp(subs_state.s, "pending", 7)==0 )
153
- 		{
154
-   			char* sep= NULL;
155
-   			str exp= {0, 0};
156
-  			sep= strchr(subs_state.s, ';');
157
-   			if(sep== NULL)
158
-   			{
159
-   				LM_ERR("No expires found in Notify\n");
160
-   				goto error;
161
-   			}
162
-   			if(strncmp(sep+1, "expires=", 8)!= 0)
163
-   			{
164
-   				LM_ERR("No expires found in Notify\n");
165
-   				goto error;
166
-   			}
167
-   			exp.s= sep+ 9;
168
-   			sep= exp.s;
169
-   			while((*sep)>='0' && (*sep)<='9')
170
-   			{
171
-   				sep++;
172
-   				exp.len++;
173
-   			}
174
-   			if( str2int(&exp, &expires)< 0)
175
-   			{
176
-   				LM_ERR("while parsing int\n");
177
-   				goto error;
178
-   			}
179
-   		}
180
-
181
-   	if ( get_content_length(msg) == 0 )
182
-   	{
183
-   		LM_ERR("content length= 0\n");
184
-   		goto error;
185
-   	}
186
-   	else
187
-   	{
188
-   		body.s=get_body(msg);
189
-   		if (body.s== NULL)
190
-   		{
191
-   			LM_ERR("cannot extract body from msg\n");
192
-   			goto error;
193
-   		}
194
-   		body.len = get_content_length( msg );
195
-   	}
196
-
197
-	if(msg->contact== NULL || msg->contact->body.s== NULL)
198
-	{
130
+	}
131
+	subs_state = hdr->body;
132
+	if(strncmp(subs_state.s, "terminated", 10) == 0)
133
+		expires = 0;
134
+	else if(strncmp(subs_state.s, "active", 6) == 0
135
+			|| strncmp(subs_state.s, "pending", 7) == 0) {
136
+		char *sep = NULL;
137
+		str exp = {0, 0};
138
+		sep = strchr(subs_state.s, ';');
139
+		if(sep == NULL) {
140
+			LM_ERR("No expires found in Notify\n");
141
+			goto error;
142
+		}
143
+		if(strncmp(sep + 1, "expires=", 8) != 0) {
144
+			LM_ERR("No expires found in Notify\n");
145
+			goto error;
146
+		}
147
+		exp.s = sep + 9;
148
+		sep = exp.s;
149
+		while((*sep) >= '0' && (*sep) <= '9') {
150
+			sep++;
151
+			exp.len++;
152
+		}
153
+		if(str2int(&exp, &expires) < 0) {
154
+			LM_ERR("while parsing int\n");
155
+			goto error;
156
+		}
157
+	}
158
+
159
+	if(get_content_length(msg) == 0) {
160
+		LM_ERR("content length= 0\n");
161
+		goto error;
162
+	} else {
163
+		body.s = get_body(msg);
164
+		if(body.s == NULL) {
165
+			LM_ERR("cannot extract body from msg\n");
166
+			goto error;
167
+		}
168
+		body.len = get_content_length(msg);
169
+	}
170
+
171
+	if(msg->contact == NULL || msg->contact->body.s == NULL) {
199 172
 		LM_ERR("no contact header found");
200 173
 		goto error;
201 174
 	}
202
-	if( parse_contact(msg->contact) <0 )
203
-	{
175
+	if(parse_contact(msg->contact) < 0) {
204 176
 		LM_ERR(" cannot parse contact header\n");
205 177
 		goto error;
206 178
 	}
207 179
 
208
-	if(msg->contact->parsed == NULL)
209
-	{
180
+	if(msg->contact->parsed == NULL) {
210 181
 		LM_ERR("cannot parse contact header\n");
211 182
 		goto error;
212 183
 	}
213
-	contact = ((contact_body_t* )msg->contact->parsed)->contacts->uri;
184
+	contact = ((contact_body_t *)msg->contact->parsed)->contacts->uri;
214 185
 
215 186
 	/* build extra_headers with Sender*/
216
-   	extra_headers.s= buf;
217
-   	memcpy(extra_headers.s, header_name.s, header_name.len);
218
-   	extra_headers.len= header_name.len;
219
-   	memcpy(extra_headers.s+extra_headers.len,": ",2);
220
-   	extra_headers.len+= 2;
221
-   	memcpy(extra_headers.s+ extra_headers.len, contact.s, contact.len);
222
-   	extra_headers.len+= contact.len;
223
-   	memcpy(extra_headers.s+ extra_headers.len, CRLF, CRLF_LEN);
224
-   	extra_headers.len+= CRLF_LEN;
225
-
226
-   	publ.body= &body;
227
-   	publ.source_flag= BLA_PUBLISH;
228
-   	publ.expires= expires;
229
-   	publ.event= BLA_EVENT;
230
-   	publ.extra_headers= &extra_headers;
231
-
232
-   	if(pua_send_publish(&publ)< 0)
233
-   	{
234
-   		LM_ERR("while sending Publish\n");
235
-   		goto error;
236
-   	}
237
-
238
-   	xmlCleanupParser();
239
-   	xmlMemoryDump();
187
+	extra_headers.s = buf;
188
+	memcpy(extra_headers.s, header_name.s, header_name.len);
189
+	extra_headers.len = header_name.len;
190
+	memcpy(extra_headers.s + extra_headers.len, ": ", 2);
191
+	extra_headers.len += 2;
192
+	memcpy(extra_headers.s + extra_headers.len, contact.s, contact.len);
193
+	extra_headers.len += contact.len;
194
+	memcpy(extra_headers.s + extra_headers.len, CRLF, CRLF_LEN);
195
+	extra_headers.len += CRLF_LEN;
196
+
197
+	publ.body = &body;
198
+	publ.source_flag = BLA_PUBLISH;
199
+	publ.expires = expires;
200
+	publ.event = BLA_EVENT;
201
+	publ.extra_headers = &extra_headers;
202
+
203
+	if(pua_send_publish(&publ) < 0) {
204
+		LM_ERR("while sending Publish\n");
205
+		goto error;
206
+	}
207
+
208
+	xmlCleanupParser();
209
+	xmlMemoryDump();
240 210
 
241 211
 	free_to_params(&TO);
242 212
 	return 1;
243 213
 
244 214
 error:
245 215
 	free_to_params(&TO);
246
-   	return 0;
216
+	return 0;
247 217
 }
248
-
... ...
@@ -32,50 +32,53 @@
32 32
 #include "registrar_cb.h"
33 33
 
34 34
 MODULE_VERSION
35
+
35 36
 /* Structure containing pointers to pua functions */
36 37
 pua_api_t pua;
37 38
 /* Structure containing pointers to usrloc functions */
38 39
 usrloc_api_t ul;
39
-str default_domain= {NULL, 0};
40
-str header_name= {0, 0};
41
-str bla_outbound_proxy= {0, 0};
42
-int is_bla_aor= 0;
43
-str reg_from_uri= {0, 0};
40
+str default_domain = STR_NULL;
41
+str header_name = STR_NULL;
42
+str bla_outbound_proxy = STR_NULL;
43
+int is_bla_aor = 0;
44
+str reg_from_uri = STR_NULL;
44 45
 static int mod_init(void);
45 46
 
46 47
 send_publish_t pua_send_publish;
47 48
 send_subscribe_t pua_send_subscribe;
48 49
 query_dialog_t pua_is_dialog;
49
-int bla_set_flag(struct sip_msg* , char*, char*);
50
-str server_address= {0, 0};
51
-static cmd_export_t cmds[]=
52
-{
53
-	{"bla_set_flag", (cmd_function)bla_set_flag,		 0, 0, 0, REQUEST_ROUTE},
54
-	{"bla_handle_notify", (cmd_function)bla_handle_notify,   0, 0, 0, REQUEST_ROUTE},
50
+int bla_set_flag(struct sip_msg *, char *, char *);
51
+str server_address = STR_NULL;
52
+
53
+/* clang-format off */
54
+static cmd_export_t cmds[] = {
55
+	{"bla_set_flag", (cmd_function)bla_set_flag, 0, 0, 0, REQUEST_ROUTE},
56
+	{"bla_handle_notify", (cmd_function)bla_handle_notify, 0, 0, 0, REQUEST_ROUTE},
55 57
 	{0, 0, 0, 0, 0, 0}
56 58
 };
57
-static param_export_t params[]=
58
-{
59
-	{"server_address",	 PARAM_STR, &server_address	 },
60
-	{"default_domain",	 PARAM_STR, &default_domain	 },
61
-	{"header_name",      PARAM_STR, &header_name       },
62
-	{"outbound_proxy",   PARAM_STR, &bla_outbound_proxy    },
63
-	{0,							 0,			0            }
59
+
60
+static param_export_t params[] = {
61
+	{"server_address",	PARAM_STR, &server_address},
62
+	{"default_domain",	PARAM_STR, &default_domain},
63
+	{"header_name",		PARAM_STR, &header_name},
64
+	{"outbound_proxy",	PARAM_STR, &bla_outbound_proxy},
65
+	{0, 0, 0}
64 66
 };
65 67
 
66 68
 /** module exports */
67
-struct module_exports exports= {
68
-	"pua_bla",			/* module name */
69
-	DEFAULT_DLFLAGS,	/* dlopen flags */
70
-	cmds,				/* exported functions */
71
-	params,				/* exported parameters */
72
-	0,					/* RPC method exports */
73
-	0,					/* exported pseudo-variables */
74
-	0,					/* response handling function */
75
-	mod_init,			/* module initialization function */
76
-	0,					/* per-child init function */
77
-	0					/* module destroy function */
69
+struct module_exports exports = {
70
+	"pua_bla",		 /* module name */
71
+	DEFAULT_DLFLAGS, /* dlopen flags */
72
+	cmds,			 /* exported functions */
73
+	params,			 /* exported parameters */
74
+	0,				 /* RPC method exports */
75
+	0,				 /* exported pseudo-variables */
76
+	0,				 /* response handling function */
77
+	mod_init,		 /* module initialization function */
78
+	0,				 /* per-child init function */
79
+	0				 /* module destroy function */
78 80
 };
81
+/* clang-format on */
79 82
 
80 83
 /**
81 84
  * init module function
... ...
@@ -85,107 +88,90 @@ static int mod_init(void)
85 88
 	bind_pua_t bind_pua;
86 89
 	bind_usrloc_t bind_usrloc;
87 90
 
88
-	if(!server_address.s || server_address.len<=0)
89
-	{
91
+	if(!server_address.s || server_address.len <= 0) {
90 92
 		LM_ERR("compulsory 'server_address' parameter not set!");
91 93
 		return -1;
92 94
 	}
93 95
 
94
-	if(!default_domain.s || default_domain.len<=0)
95
-	{
96
+	if(!default_domain.s || default_domain.len <= 0) {
96 97
 		LM_ERR("default domain not found\n");
97 98
 		return -1;
98 99
 	}
99 100
 
100
-	if(!header_name.s || header_name.len<=0)
101
-	{
101
+	if(!header_name.s || header_name.len <= 0) {
102 102
 		LM_ERR("header_name parameter not set\n");
103 103
 		return -1;
104 104
 	}
105 105
 
106
-	if(!bla_outbound_proxy.s || bla_outbound_proxy.len<=0)
107
-	{
106
+	if(!bla_outbound_proxy.s || bla_outbound_proxy.len <= 0) {
108 107
 		LM_DBG("No outbound proxy set\n");
109 108
 	}
110 109
 
111
-	bind_pua= (bind_pua_t)find_export("bind_pua", 1,0);
112
-	if (!bind_pua)
113
-	{
110
+	bind_pua = (bind_pua_t)find_export("bind_pua", 1, 0);
111
+	if(!bind_pua) {
114 112
 		LM_ERR("Can't bind pua\n");
115 113
 		return -1;
116 114
 	}
117 115
 
118
-	if (bind_pua(&pua) < 0)
119
-	{
116
+	if(bind_pua(&pua) < 0) {
120 117
 		LM_ERR("Can't bind pua\n");
121 118
 		return -1;
122 119
 	}
123
-	if(pua.send_publish == NULL)
124
-	{
120
+	if(pua.send_publish == NULL) {
125 121
 		LM_ERR("Could not import send_publish\n");
126 122
 		return -1;
127 123
 	}
128
-	pua_send_publish= pua.send_publish;
124
+	pua_send_publish = pua.send_publish;
129 125
 
130
-	if(pua.send_subscribe == NULL)
131
-	{
126
+	if(pua.send_subscribe == NULL) {
132 127
 		LM_ERR("Could not import send_subscribe\n");
133 128
 		return -1;
134 129
 	}
135
-	pua_send_subscribe= pua.send_subscribe;
130
+	pua_send_subscribe = pua.send_subscribe;
136 131
 
137
-	if(pua.is_dialog == NULL)
138
-	{
132
+	if(pua.is_dialog == NULL) {
139 133
 		LM_ERR("Could not import send_subscribe\n");
140 134
 		return -1;
141 135
 	}
142
-	pua_is_dialog= pua.is_dialog;
136
+	pua_is_dialog = pua.is_dialog;
143 137
 
144
-	if(pua.register_puacb== NULL)
145
-	{
138
+	if(pua.register_puacb == NULL) {
146 139
 		LM_ERR("Could not import register callback\n");
147 140
 		return -1;
148 141
 	}
149 142
 
150 143
 	bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
151
-	if (!bind_usrloc)
152
-	{
144
+	if(!bind_usrloc) {
153 145
 		LM_ERR("Can't bind usrloc\n");
154 146
 		return -1;
155 147
 	}
156
-	if (bind_usrloc(&ul) < 0)
157
-	{
148
+	if(bind_usrloc(&ul) < 0) {
158 149
 		LM_ERR("Can't bind usrloc\n");
159 150
 		return -1;
160 151
 	}
161
-	if(ul.register_ulcb == NULL)
162
-	{
152
+	if(ul.register_ulcb == NULL) {
163 153
 		LM_ERR("Could not import ul_register_ulcb\n");
164 154
 		return -1;
165 155
 	}
166 156
 
167
-	if(ul.register_ulcb(UL_CONTACT_INSERT, bla_cb , 0)< 0)
168
-	{
157
+	if(ul.register_ulcb(UL_CONTACT_INSERT, bla_cb, 0) < 0) {
169 158
 		LM_ERR("can not register callback for"
170
-				" insert\n");
159
+			   " insert\n");
171 160
 		return -1;
172 161
 	}
173
-	if(ul.register_ulcb(UL_CONTACT_EXPIRE, bla_cb, 0)< 0)
174
-	{
162
+	if(ul.register_ulcb(UL_CONTACT_EXPIRE, bla_cb, 0) < 0) {
175 163
 		LM_ERR("can not register callback for"
176
-				" insert\n");
164
+			   " insert\n");
177 165
 		return -1;
178 166
 	}
179
-	if(ul.register_ulcb(UL_CONTACT_UPDATE, bla_cb, 0)< 0)
180
-	{
167
+	if(ul.register_ulcb(UL_CONTACT_UPDATE, bla_cb, 0) < 0) {
181 168
 		LM_ERR("can not register callback for"
182
-				" update\n");
169
+			   " update\n");
183 170
 		return -1;
184 171
 	}
185
-	if(ul.register_ulcb(UL_CONTACT_DELETE, bla_cb, 0)< 0)
186
-	{
172
+	if(ul.register_ulcb(UL_CONTACT_DELETE, bla_cb, 0) < 0) {
187 173
 		LM_ERR("can not register callback for"
188
-				" delete\n");
174
+			   " delete\n");
189 175
 		return -1;
190 176
 	}
191 177
 
... ...
@@ -193,30 +179,26 @@ static int mod_init(void)
193 179
 }
194 180
 
195 181
 
196
-int bla_set_flag(struct sip_msg* msg , char* s1, char* s2)
182
+int bla_set_flag(struct sip_msg *msg, char *s1, char *s2)
197 183
 {
198 184
 	LM_DBG("mark as bla aor\n");
199 185
 
200
-	is_bla_aor= 1;
186
+	is_bla_aor = 1;
201 187
 
202
-	if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
203
-	{
188
+	if(parse_headers(msg, HDR_EOH_F, 0) == -1) {
204 189
 		LM_ERR("parsing headers\n");
205 190
 		return -1;
206 191
 	}
207 192
 
208 193
 
209
-	if (msg->from->parsed == NULL)
210
-	{
211
-		if ( parse_from_header( msg )<0 )
212
-		{
194
+	if(msg->from->parsed == NULL) {
195
+		if(parse_from_header(msg) < 0) {
213 196
 			LM_DBG("cannot parse From header\n");
214 197
 			return -1;
215 198
 		}
216 199
 	}
217 200
 
218
-	reg_from_uri= ((struct to_body*)(msg->from->parsed))->uri;
201
+	reg_from_uri = ((struct to_body *)(msg->from->parsed))->uri;
219 202
 
220 203
 	return 1;
221 204
 }
222
-
... ...
@@ -34,6 +34,6 @@ extern str reg_from_uri;
34 34
 extern send_publish_t pua_send_publish;
35 35
 extern send_subscribe_t pua_send_subscribe;
36 36
 extern query_dialog_t pua_is_dialog;
37
-extern int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2);
37
+extern int bla_handle_notify(struct sip_msg *msg, char *s1, char *s2);
38 38
 
39 39
 #endif
... ...
@@ -29,36 +29,33 @@
29 29
 #include "pua_bla.h"
30 30
 
31 31
 
32
-void bla_cb(ucontact_t* c, int type, void* param)
32
+void bla_cb(ucontact_t *c, int type, void *param)
33 33
 {
34 34
 	subs_info_t subs;
35
-	str uri={0, 0};
36
-	char* at;
35
+	str uri = STR_NULL;
36
+	char *at;
37 37
 	LM_DBG("start\n");
38
-	if(is_bla_aor== 0)
39
-	{
38
+	if(is_bla_aor == 0) {
40 39
 		LM_DBG("Not a recognized BLA AOR\n");
41
-		return ;
40
+		return;
42 41
 	}
43 42
 
44 43
 	if(type & UL_CONTACT_INSERT)
45 44
 		LM_DBG("type= UL_CONTACT_INSERT\n");
46
-	else
47
-	if(type & UL_CONTACT_UPDATE)
45
+	else if(type & UL_CONTACT_UPDATE)
48 46
 		LM_DBG("type= UL_CONTACT_UPDATE\n");
49
-	else
50
-	if(type & UL_CONTACT_EXPIRE)
47
+	else if(type & UL_CONTACT_EXPIRE)
51 48
 		LM_DBG("type= UL_CONTACT_EXPIRE\n");
52
-	else
53
-	if(type & UL_CONTACT_DELETE)
49
+	else if(type & UL_CONTACT_DELETE)
54 50
 		LM_DBG("type= UL_CONTACT_DELETE\n");
55 51
 
56 52
 	memset(&subs, 0, sizeof(subs_info_t));
57
-	subs.remote_target= &c->c;
53
+	subs.remote_target = &c->c;
58 54
 
59
-	subs.pres_uri= &reg_from_uri;
55
+	subs.pres_uri = &reg_from_uri;
60 56
 
61
-	uri.s = (char*)pkg_malloc(sizeof(char)*(c->aor->len+default_domain.len+6));
57
+	uri.s = (char *)pkg_malloc(
58
+			sizeof(char) * (c->aor->len + default_domain.len + 6));
62 59
 	if(uri.s == NULL) {
63 60
 		PKG_MEM_ERROR;
64 61
 		goto error;
... ...
@@ -67,44 +64,41 @@ void bla_cb(ucontact_t* c, int type, void* param)
67 64
 	memcpy(uri.s, "sip:", 4);
68 65
 	uri.len = 4;
69 66
 
70
-	memcpy(uri.s+ uri.len, c->aor->s, c->aor->len);
71
-	uri.len+= c->aor->len;
67
+	memcpy(uri.s + uri.len, c->aor->s, c->aor->len);
68
+	uri.len += c->aor->len;
72 69
 	at = memchr(c->aor->s, '@', c->aor->len);
73
-	if(!at)
74
-	{
75
-		uri.s[uri.len++]= '@';
76
-		memcpy(uri.s+ uri.len, default_domain.s, default_domain.len);
77
-		uri.len+= default_domain.len;
70
+	if(!at) {
71
+		uri.s[uri.len++] = '@';
72
+		memcpy(uri.s + uri.len, default_domain.s, default_domain.len);
73
+		uri.len += default_domain.len;
78 74
 	}
79 75
 
80
-	subs.watcher_uri= &uri;
81
-	if(type & UL_CONTACT_DELETE || type & UL_CONTACT_EXPIRE )
82
-		subs.expires= 0;
76
+	subs.watcher_uri = &uri;
77
+	if(type & UL_CONTACT_DELETE || type & UL_CONTACT_EXPIRE)
78
+		subs.expires = 0;
83 79
 	else
84
-		subs.expires= c->expires - (int)time(NULL);
80
+		subs.expires = c->expires - (int)time(NULL);
85 81
 
86 82
 
87
-	subs.source_flag= BLA_SUBSCRIBE;
88
-	subs.event= BLA_EVENT;
89
-	subs.contact= &server_address;
83
+	subs.source_flag = BLA_SUBSCRIBE;
84
+	subs.event = BLA_EVENT;
85
+	subs.contact = &server_address;
90 86
 
91 87
 	if(bla_outbound_proxy.s && bla_outbound_proxy.len)
92
-		subs.outbound_proxy= &bla_outbound_proxy;
93
-	else
94
-	if(c->received.s && c->received.len)
95
-		subs.outbound_proxy= &c->received;
88
+		subs.outbound_proxy = &bla_outbound_proxy;
89
+	else if(c->received.s && c->received.len)
90
+		subs.outbound_proxy = &c->received;
96 91
 
97 92
 	if(type & UL_CONTACT_INSERT)
98
-		subs.flag|= INSERT_TYPE;
93
+		subs.flag |= INSERT_TYPE;
99 94
 	else
100
-		subs.flag|= UPDATE_TYPE;
95
+		subs.flag |= UPDATE_TYPE;
101 96
 
102
-	if(pua_send_subscribe(&subs)< 0)
103
-	{
97
+	if(pua_send_subscribe(&subs) < 0) {
104 98
 		LM_ERR("while sending subscribe\n");
105 99
 	}
106 100
 	pkg_free(uri.s);
107 101
 error:
108
-	is_bla_aor= 0;
109
-	return ;
102
+	is_bla_aor = 0;
103
+	return;
110 104
 }
... ...
@@ -26,4 +26,4 @@
26 26
 #include "../../core/dprint.h"
27 27
 #include "../usrloc/usrloc.h"
28 28
 
29
-void bla_cb(ucontact_t* c, int type, void* param);
29
+void bla_cb(ucontact_t *c, int type, void *param);