Browse code

- addapted to the interface for parse_content_type_hdr function

Bogdan-Andrei Iancu authored on 05/08/2003 11:14:28
Showing 4 changed files
... ...
@@ -29,6 +29,7 @@
29 29
 /*
30 30
  * 2003-01-23 switched from t_uac to t_uac_dlg, adapted to new way of
31 31
  * parsing for Content-Type; by bogdan
32
+ * 2003-08-05 adapted to the new parse_content_type_hdr function (bogdan)
32 33
  */
33 34
 
34 35
 
... ...
@@ -149,6 +150,7 @@ int dump_request(struct sip_msg *msg, char *para1, char *para2)
149 150
 	char   *cmd;
150 151
 	int    cmd_len;
151 152
 	char   *p;
153
+	int    mime;
152 154
 
153 155
 	/* get the message's body
154 156
 	 * anyhow we have to call this function, so let's do it at the beginning
... ...
@@ -174,16 +176,16 @@ int dump_request(struct sip_msg *msg, char *para1, char *para2)
174 176
 	}
175 177
 
176 178
 	/* parse the content-type header */
177
-	if (parse_content_type_hdr(msg)==-1 ) {
179
+	if ((mime=parse_content_type_hdr(msg))<1 ) {
178 180
 		LOG(L_ERR,"ERROR:extcmd:dump_msg:cannot parse Content-Type header\n");
179 181
 		goto error;
180 182
 	}
181 183
 
182 184
 	/* check the content-type value */
183
-	if ( get_content_type(msg)!=CONTENT_TYPE_TEXT_PLAIN
184
-	&& get_content_type(msg)!=CONTENT_TYPE_MESSAGE_CPIM ) {
185
+	if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
186
+	&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {
185 187
 		LOG(L_ERR,"ERROR:extcmd:dump_msg: invalid content-type for a "
186
-			"message request! type found=%d\n",get_content_type(msg));
188
+			"message request! type found=%d\n",mime);
187 189
 		goto error;
188 190
 	}
189 191
 
... ...
@@ -38,6 +38,7 @@
38 38
  * 2003-03-16 flags export parameter added (janakj)
39 39
  * 2003-04-06 rank 0 changed to 1 in child_init (janakj)
40 40
  * 2003-06-19 fixed too many Jabber workers bug (mostly on RH9.0) (dcm)
41
+ * 2003-08-05 adapted to the new parse_content_type_hdr function (bogdan)
41 42
  */
42 43
 
43 44
 
... ...
@@ -415,6 +416,7 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
415 416
 	xj_sipmsg jsmsg;
416 417
 	int pipe, fl;
417 418
 	t_xj_jkey jkey, *p;
419
+	int mime;
418 420
 
419 421
 	// extract message body - after that whole SIP MESSAGE is parsed
420 422
 	if (type==XJ_SEND_MESSAGE)
... ...
@@ -438,7 +440,7 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
438 440
 		body.len = get_content_length(msg);
439 441
 
440 442
 		/* parse the content-type header */
441
-		if(parse_content_type_hdr(msg)==-1)
443
+		if((mime=parse_content_type_hdr(msg))<1)
442 444
 		{
443 445
 			LOG(L_ERR,"XJAB:xjab_manage_sipmsg: ERROR cannot parse"
444 446
 					" Content-Type header\n");
... ...
@@ -446,11 +448,11 @@ int xjab_manage_sipmsg(struct sip_msg *msg, int type)
446 448
 		}
447 449
 
448 450
 		/* check the content-type value */
449
-		if(get_content_type(msg)!=CONTENT_TYPE_TEXT_PLAIN
450
-			&& get_content_type(msg)!=CONTENT_TYPE_MESSAGE_CPIM)
451
+		if(mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
452
+			&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM)
451 453
 		{
452 454
 			LOG(L_ERR,"XJAB:xjab_manage_sipmsg: ERROR invalid content-type for"
453
-				" a message request! type found=%d\n", get_content_type(msg));
455
+				" a message request! type found=%d\n", mime);
454 456
 			goto error;
455 457
 		}
456 458
 	}
... ...
@@ -41,6 +41,7 @@
41 41
  *             now (janakj)
42 42
  * 2003-04-07: m_dump takes a parameter which sets the way the outgoing URI
43 43
  *             is computed (dcm)
44
+ * 2003-08-05 adapted to the new parse_content_type_hdr function (bogdan)
44 45
  */
45 46
 
46 47
 #include <stdio.h>
... ...
@@ -266,6 +267,7 @@ static int m_store(struct sip_msg* msg, char* mode, char* str2)
266 267
 	int nr_keys = 0, val, lexpire;
267 268
 	t_content_type ctype;
268 269
 	char buf[512], buf1[1024], *p;
270
+	int mime;
269 271
 
270 272
 	DBG("MSILO: m_store: ------------ start ------------\n");
271 273
 
... ...
@@ -448,16 +450,15 @@ static int m_store(struct sip_msg* msg, char* mode, char* str2)
448 450
 	lexpire = expire_time;
449 451
 	// add 'content-type'
450 452
 	/* parse the content-type header */
451
-	if (parse_content_type_hdr(msg)==-1 ) 
453
+	if ((mime=parse_content_type_hdr(msg))<1 ) 
452 454
 	{
453 455
 		LOG(L_ERR,"MSILO:m_store: ERROR cannot parse Content-Type header\n");
454 456
 		goto error;
455 457
 	}
456 458
 
457 459
 	/** check the content-type value */
458
-	if(msg->content_type && msg->content_type->body.len > 0
459
-		&& get_content_type(msg)!=CONTENT_TYPE_TEXT_PLAIN
460
-		&& get_content_type(msg)!=CONTENT_TYPE_MESSAGE_CPIM )
460
+	if( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
461
+		&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM )
461 462
 	{
462 463
 		if(m_extract_content_type(msg->content_type->body.s, 
463 464
 				msg->content_type->body.len, &ctype, CT_TYPE) != -1)
... ...
@@ -28,9 +28,10 @@
28 28
 /*
29 29
  * History:
30 30
  * --------
31
- * 2003-02-28 protocolization of t_uac_dlg completed (jiri)
32 31
  * 2003-01-23 switched from t_uac to t_uac_dlg, adapted to new way of
33 32
  * parsing for Content-Type; by bogdan
33
+ * 2003-02-28 protocolization of t_uac_dlg completed (jiri)
34
+ * 2003-08-05 adapted to the new parse_content_type_hdr function (bogdan)
34 35
  */
35 36
 
36 37
 #include <unistd.h>
... ...
@@ -158,6 +159,7 @@ int push_on_network(struct sip_msg *msg, int net)
158 159
 	struct to_body  *from;
159 160
 	char   *p;
160 161
 	int    len;
162
+	int    mime;
161 163
 
162 164
 	/* get the message's body
163 165
 	 * anyhow we have to call this function, so let's do it at the beginning
... ...
@@ -177,16 +179,16 @@ int push_on_network(struct sip_msg *msg, int net)
177 179
 	body.len = get_content_length( msg );
178 180
 
179 181
 	/* parse the content-type header */
180
-	if (parse_content_type_hdr(msg)==-1 ) {
182
+	if ( (mime=parse_content_type_hdr(msg))<1 ) {
181 183
 		LOG(L_ERR,"ERROR:extcmd:dump_msg:cannot parse Content-Type header\n");
182 184
 		goto error;
183 185
 	}
184 186
 
185 187
 	/* check the content-type value */
186
-	if ( get_content_type(msg)!=CONTENT_TYPE_TEXT_PLAIN
187
-	&& get_content_type(msg)!=CONTENT_TYPE_MESSAGE_CPIM ) {
188
+	if ( mime!=(TYPE_TEXT<<16)+SUBTYPE_PLAIN
189
+	&& mime!=(TYPE_MESSAGE<<16)+SUBTYPE_CPIM ) {
188 190
 		LOG(L_ERR,"ERROR:extcmd:dump_msg: invalid content-type for a "
189
-			"message request! type found=%d\n",get_content_type(msg));
191
+			"message request! type found=%d\n",mime);
190 192
 		goto error;
191 193
 	}
192 194