Browse code

pua_bla: convert to PKG/SHM memory logging helper functions

* remove trailing spaces
* remove history notes and $Id

Victor Seva authored on 29/07/2020 11:15:25
Showing 5 changed files
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id: notify.c 1666 2007-03-02 13:40:09Z anca_vamanu $
3
- *
4 2
  * pua_bla module - pua Bridged Line Appearance
5 3
  *
6 4
  * Copyright (C) 2007 Voice Sistem S.R.L.
... ...
@@ -20,21 +18,17 @@
20 18
  * You should have received a copy of the GNU General Public License
21 19
  * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
- *
24
- * History:
25
- * --------
26
- *  2007-03-30  initial version (anca)
27 21
  */
28
-#include<stdio.h>
29
-#include<stdlib.h>
30
-#include<libxml/parser.h>
22
+#include <stdio.h>
23
+#include <stdlib.h>
24
+#include <libxml/parser.h>
31 25
 
32 26
 #include "../../core/parser/parse_content.h"
33 27
 #include "../../core/parser/contact/parse_contact.h"
34 28
 #include "../../core/parser/parse_from.h"
35 29
 #include "../../core/strutils.h"
36 30
 #include "../pua/hash.h"
37
-#include"pua_bla.h"
31
+#include "pua_bla.h"
38 32
 
39 33
 int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
40 34
 {
... ...
@@ -85,21 +79,21 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
85 79
   	}
86 80
   	publ.pres_uri= &pto->uri;
87 81
   	dialog.watcher_uri= publ.pres_uri;
88
-  
82
+
89 83
   	if (pto->tag_value.s==NULL || pto->tag_value.len==0 )
90 84
   	{
91 85
   		LM_ERR("NULL to_tag value\n");
92 86
 		goto error;
93 87
   	}
94 88
   	dialog.from_tag= pto->tag_value;
95
-  
89
+
96 90
   	if( msg->callid==NULL || msg->callid->body.s==NULL)
97 91
  	{
98 92
   		LM_ERR("cannot parse callid header\n");
99 93
   		goto error;
100 94
   	}
101 95
   	dialog.call_id = msg->callid->body;
102
-  
96
+
103 97
   	if (!msg->from || !msg->from->body.s)
104 98
   	{
105 99
   		LM_ERR("cannot find 'from' header!\n");
... ...
@@ -117,13 +111,13 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
117 111
  	}
118 112
  	pfrom = (struct to_body*)msg->from->parsed;
119 113
  	dialog.pres_uri= &pfrom->uri;
120
- 
114
+
121 115
  	if( pfrom->tag_value.s ==NULL || pfrom->tag_value.len == 0)
122 116
  	{
123 117
  		LM_ERR("no from tag value present\n");
124 118
  		goto error;
125 119
  	}
126
- 
120
+
127 121
  	dialog.to_tag= pfrom->tag_value;
128 122
  	dialog.event= BLA_EVENT;
129 123
  	dialog.flag= BLA_SUBSCRIBE;
... ...
@@ -133,7 +127,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
133 127
  		goto error;
134 128
  	}
135 129
  	LM_DBG("found a matching dialog\n");
136
- 
130
+
137 131
  	/* parse Subscription-State and extract expires if existing */
138 132
 	hdr = msg->headers;
139 133
 	while (hdr!= NULL)
... ...
@@ -183,7 +177,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
183 177
    				goto error;
184 178
    			}
185 179
    		}
186
-   
180
+
187 181
    	if ( get_content_length(msg) == 0 )
188 182
    	{
189 183
    		LM_ERR("content length= 0\n");
... ...
@@ -199,7 +193,7 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
199 193
    		}
200 194
    		body.len = get_content_length( msg );
201 195
    	}
202
-   	
196
+
203 197
 	if(msg->contact== NULL || msg->contact->body.s== NULL)
204 198
 	{
205 199
 		LM_ERR("no contact header found");
... ...
@@ -228,25 +222,25 @@ int bla_handle_notify(struct sip_msg* msg, char* s1, char* s2)
228 222
    	extra_headers.len+= contact.len;
229 223
    	memcpy(extra_headers.s+ extra_headers.len, CRLF, CRLF_LEN);
230 224
    	extra_headers.len+= CRLF_LEN;
231
-   
225
+
232 226
    	publ.body= &body;
233 227
    	publ.source_flag= BLA_PUBLISH;
234 228
    	publ.expires= expires;
235 229
    	publ.event= BLA_EVENT;
236 230
    	publ.extra_headers= &extra_headers;
237
-	
231
+
238 232
    	if(pua_send_publish(&publ)< 0)
239 233
    	{
240 234
    		LM_ERR("while sending Publish\n");
241 235
    		goto error;
242 236
    	}
243
-      
237
+
244 238
    	xmlCleanupParser();
245 239
    	xmlMemoryDump();
246 240
 
247 241
 	free_to_params(&TO);
248 242
 	return 1;
249
-   
243
+
250 244
 error:
251 245
 	free_to_params(&TO);
252 246
    	return 0;
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id: pua_bla.c 1666 2007-03-02 13:40:09Z anca_vamanu $
3
- *
4 2
  * pua_bla module - pua Bridged Line Appearance
5 3
  *
6 4
  * Copyright (C) 2007 Voice Sistem S.R.L.
... ...
@@ -17,17 +15,14 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
- *
24
- * History:
25
- * --------
26
- *  2007-03-30  initial version (anca)
27 21
  */
28 22
 
29
-#include<stdio.h>
30
-#include<stdlib.h>
23
+#include <stdio.h>
24
+#include <stdlib.h>
25
+
31 26
 #include "../../core/sr_module.h"
32 27
 #include "../../core/dprint.h"
33 28
 #include "../usrloc/usrloc.h"
... ...
@@ -56,7 +51,7 @@ str server_address= {0, 0};
56 51
 static cmd_export_t cmds[]=
57 52
 {
58 53
 	{"bla_set_flag", (cmd_function)bla_set_flag,		 0, 0, 0, REQUEST_ROUTE},
59
-	{"bla_handle_notify", (cmd_function)bla_handle_notify,   0, 0, 0, REQUEST_ROUTE}, 	
54
+	{"bla_handle_notify", (cmd_function)bla_handle_notify,   0, 0, 0, REQUEST_ROUTE},
60 55
 	{0, 0, 0, 0, 0, 0}
61 56
 };
62 57
 static param_export_t params[]=
... ...
@@ -81,7 +76,7 @@ struct module_exports exports= {
81 76
 	0,					/* per-child init function */
82 77
 	0					/* module destroy function */
83 78
 };
84
-	
79
+
85 80
 /**
86 81
  * init module function
87 82
  */
... ...
@@ -97,19 +92,19 @@ static int mod_init(void)
97 92
 	}
98 93
 
99 94
 	if(!default_domain.s || default_domain.len<=0)
100
-	{	
95
+	{
101 96
 		LM_ERR("default domain not found\n");
102 97
 		return -1;
103 98
 	}
104 99
 
105 100
 	if(!header_name.s || header_name.len<=0)
106
-	{	
101
+	{
107 102
 		LM_ERR("header_name parameter not set\n");
108 103
 		return -1;
109 104
 	}
110 105
 
111 106
 	if(!bla_outbound_proxy.s || bla_outbound_proxy.len<=0)
112
-	{	
107
+	{
113 108
 		LM_DBG("No outbound proxy set\n");
114 109
 	}
115 110
 
... ...
@@ -119,7 +114,7 @@ static int mod_init(void)
119 114
 		LM_ERR("Can't bind pua\n");
120 115
 		return -1;
121 116
 	}
122
-	
117
+
123 118
 	if (bind_pua(&pua) < 0)
124 119
 	{
125 120
 		LM_ERR("Can't bind pua\n");
... ...
@@ -145,12 +140,12 @@ static int mod_init(void)
145 140
 		return -1;
146 141
 	}
147 142
 	pua_is_dialog= pua.is_dialog;
148
-	
143
+
149 144
 	if(pua.register_puacb== NULL)
150 145
 	{
151 146
 		LM_ERR("Could not import register callback\n");
152 147
 		return -1;
153
-	}	
148
+	}
154 149
 
155 150
 	bind_usrloc = (bind_usrloc_t)find_export("ul_bind_usrloc", 1, 0);
156 151
 	if (!bind_usrloc)
... ...
@@ -176,19 +171,19 @@ static int mod_init(void)
176 171
 		return -1;
177 172
 	}
178 173
 	if(ul.register_ulcb(UL_CONTACT_EXPIRE, bla_cb, 0)< 0)
179
-	{	
174
+	{
180 175
 		LM_ERR("can not register callback for"
181 176
 				" insert\n");
182 177
 		return -1;
183 178
 	}
184 179
 	if(ul.register_ulcb(UL_CONTACT_UPDATE, bla_cb, 0)< 0)
185
-	{	
180
+	{
186 181
 		LM_ERR("can not register callback for"
187 182
 				" update\n");
188 183
 		return -1;
189 184
 	}
190 185
 	if(ul.register_ulcb(UL_CONTACT_DELETE, bla_cb, 0)< 0)
191
-	{	
186
+	{
192 187
 		LM_ERR("can not register callback for"
193 188
 				" delete\n");
194 189
 		return -1;
... ...
@@ -201,19 +196,19 @@ static int mod_init(void)
201 196
 int bla_set_flag(struct sip_msg* msg , char* s1, char* s2)
202 197
 {
203 198
 	LM_DBG("mark as bla aor\n");
204
-	
199
+
205 200
 	is_bla_aor= 1;
206
-	
201
+
207 202
 	if( parse_headers(msg,HDR_EOH_F, 0)==-1 )
208 203
 	{
209 204
 		LM_ERR("parsing headers\n");
210 205
 		return -1;
211 206
 	}
212
-	
207
+
213 208
 
214 209
 	if (msg->from->parsed == NULL)
215 210
 	{
216
-		if ( parse_from_header( msg )<0 ) 
211
+		if ( parse_from_header( msg )<0 )
217 212
 		{
218 213
 			LM_DBG("cannot parse From header\n");
219 214
 			return -1;
... ...
@@ -223,5 +218,5 @@ int bla_set_flag(struct sip_msg* msg , char* s1, char* s2)
223 218
 	reg_from_uri= ((struct to_body*)(msg->from->parsed))->uri;
224 219
 
225 220
 	return 1;
226
-}	
221
+}
227 222
 
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id: pua_bla.h 1666 2007-03-02 13:40:09Z anca_vamanu $
3
- *
4 2
  * pua_bla module - pua Bridged Line Appearance
5 3
  *
6 4
  * Copyright (C) 2007 Voice Sistem S.R.L.
... ...
@@ -17,13 +15,9 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
- *
24
- * History:
25
- * --------
26
- *  2007-03-30  initial version (anca)
27 21
  */
28 22
 
29 23
 #ifndef PUA_BLA_H
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id: registrar_cb.c 1666 2007-03-02 13:40:09Z anca_vamanu $
3
- *
4 2
  * pua_bla module - pua Bridged Line Appearance
5 3
  *
6 4
  * Copyright (C) 2007 Voice Sistem S.R.L.
... ...
@@ -17,17 +15,14 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
- *
24
- * History:
25
- * --------
26
- *  2007-03-30  initial version (anca)
27 21
  */
28 22
 
29
-#include<stdio.h>
30
-#include<stdlib.h>
23
+#include <stdio.h>
24
+#include <stdlib.h>
25
+
31 26
 #include "../../core/dprint.h"
32 27
 #include "../pua/pua.h"
33 28
 #include "registrar_cb.h"
... ...
@@ -44,7 +39,7 @@ void bla_cb(ucontact_t* c, int type, void* param)
44 39
 	{
45 40
 		LM_DBG("Not a recognized BLA AOR\n");
46 41
 		return ;
47
-	}	
42
+	}
48 43
 
49 44
 	if(type & UL_CONTACT_INSERT)
50 45
 		LM_DBG("type= UL_CONTACT_INSERT\n");
... ...
@@ -60,12 +55,14 @@ void bla_cb(ucontact_t* c, int type, void* param)
60 55
 
61 56
 	memset(&subs, 0, sizeof(subs_info_t));
62 57
 	subs.remote_target= &c->c;
63
-	
58
+
64 59
 	subs.pres_uri= &reg_from_uri;
65 60
 
66 61
 	uri.s = (char*)pkg_malloc(sizeof(char)*(c->aor->len+default_domain.len+6));
67
-	if(uri.s == NULL)
62
+	if(uri.s == NULL) {
63
+		PKG_MEM_ERROR;
68 64
 		goto error;
65
+	}
69 66
 
70 67
 	memcpy(uri.s, "sip:", 4);
71 68
 	uri.len = 4;
... ...
@@ -77,20 +74,20 @@ void bla_cb(ucontact_t* c, int type, void* param)
77 74
 	{
78 75
 		uri.s[uri.len++]= '@';
79 76
 		memcpy(uri.s+ uri.len, default_domain.s, default_domain.len);
80
-		uri.len+= default_domain.len;		
77
+		uri.len+= default_domain.len;
81 78
 	}
82
-	
79
+
83 80
 	subs.watcher_uri= &uri;
84 81
 	if(type & UL_CONTACT_DELETE || type & UL_CONTACT_EXPIRE )
85 82
 		subs.expires= 0;
86 83
 	else
87 84
 		subs.expires= c->expires - (int)time(NULL);
88
-		
85
+
89 86
 
90 87
 	subs.source_flag= BLA_SUBSCRIBE;
91 88
 	subs.event= BLA_EVENT;
92 89
 	subs.contact= &server_address;
93
-	
90
+
94 91
 	if(bla_outbound_proxy.s && bla_outbound_proxy.len)
95 92
 		subs.outbound_proxy= &bla_outbound_proxy;
96 93
 	else
... ...
@@ -105,9 +102,9 @@ void bla_cb(ucontact_t* c, int type, void* param)
105 102
 	if(pua_send_subscribe(&subs)< 0)
106 103
 	{
107 104
 		LM_ERR("while sending subscribe\n");
108
-	}	
105
+	}
109 106
 	pkg_free(uri.s);
110 107
 error:
111 108
 	is_bla_aor= 0;
112 109
 	return ;
113
-}	
110
+}
... ...
@@ -1,6 +1,4 @@
1 1
 /*
2
- * $Id: pua_bla.c 1666 2007-03-02 13:40:09Z anca_vamanu $
3
- *
4 2
  * pua_bla module - pua Bridged Line Appearance
5 3
  *
6 4
  * Copyright (C) 2007 Voice Sistem S.R.L.
... ...
@@ -17,17 +15,14 @@
17 15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 16
  * GNU General Public License for more details.
19 17
  *
20
- * You should have received a copy of the GNU General Public License 
21
- * along with this program; if not, write to the Free Software 
18
+ * You should have received a copy of the GNU General Public License
19
+ * along with this program; if not, write to the Free Software
22 20
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23
- *
24
- * History:
25
- * --------
26
- *  2007-03-30  initial version (anca)
27 21
  */
28 22
 
29
-#include<stdio.h>
30
-#include<stdlib.h>
23
+#include <stdio.h>
24
+#include <stdlib.h>
25
+
31 26
 #include "../../core/dprint.h"
32 27
 #include "../usrloc/usrloc.h"
33 28