Browse code

- del_nonshm_lump(lump_list) added - removes from lump's tree all lumps that are not marked as LUMPFLAG_SHMEM.

- hdr_allocs_parse(hdr) macro added - return true if the header uses
allocated memory on parse field

Bogdan-Andrei Iancu authored on 23/02/2004 16:40:49
Showing 3 changed files
... ...
@@ -484,6 +484,8 @@ deeperror:
484 484
 	return 0;
485 485
 }
486 486
 
487
+
488
+
487 489
 /* shallow pkg copy of a lump list
488 490
  *
489 491
  * if either original list empty or error occur returns, 0
... ...
@@ -497,6 +499,8 @@ struct lump* dup_lump_list( struct lump *l )
497 497
 	return dup_lump_list_r(l, LD_NEXT, &deep_error);
498 498
 }
499 499
 
500
+
501
+
500 502
 void free_duped_lump_list(struct lump* l)
501 503
 {
502 504
 	struct lump *r, *foo,*crt;
... ...
@@ -530,3 +534,56 @@ void free_duped_lump_list(struct lump* l)
530 530
 	}
531 531
 }
532 532
 
533
+
534
+
535
+void del_nonshm_lump( struct lump** lump_list )
536
+{
537
+	struct lump *r, *foo, *crt, **prev, *prev_r;
538
+
539
+	prev = lump_list;
540
+	crt = *lump_list;
541
+
542
+	while (crt) {
543
+		if (crt->flags!=LUMPFLAG_SHMEM) {
544
+			/* unlink it */
545
+			foo = crt;
546
+			crt = crt->next;
547
+			foo->next = 0;
548
+			/* update the 'next' link of the previous lump */
549
+			*prev = crt;
550
+			/* entire before/after list must be removed */
551
+			free_lump_list( foo );
552
+		} else {
553
+			/* check on before and prev list for non-shmem lumps */
554
+			r = crt->after;
555
+			prev_r = crt;
556
+			while(r){
557
+				foo=r; r=r->after;
558
+				if (foo->flags!=LUMPFLAG_SHMEM) {
559
+					prev_r->after = r;
560
+					free_lump(foo);
561
+					pkg_free(foo);
562
+				} else {
563
+					prev_r = foo;
564
+				}
565
+			}
566
+			/* before */
567
+			r = crt->before;
568
+			prev_r = crt;
569
+			while(r){
570
+				foo=r; r=r->before;
571
+				if (foo->flags!=LUMPFLAG_SHMEM) {
572
+					prev_r->before = r;
573
+					free_lump(foo);
574
+					pkg_free(foo);
575
+				} else {
576
+					prev_r = foo;
577
+				}
578
+			}
579
+			/* go to next lump */
580
+			prev = &(crt->next);
581
+			crt = crt->next;
582
+		}
583
+	}
584
+}
585
+
... ...
@@ -77,4 +77,8 @@ struct lump* dup_lump_list( struct lump *l );
77 77
 /* frees a shallowly duplicated lump list */
78 78
 void free_duped_lump_list(struct lump* l);
79 79
 
80
+
81
+/* remove all non-SHMEM lumps from the list */
82
+void del_nonshm_lump( struct lump** lump_list );
83
+
80 84
 #endif
... ...
@@ -57,7 +57,7 @@
57 57
 #define HDR_CONTENTLENGTH      (1 << 11)  /* Content-Length header field */
58 58
 #define HDR_AUTHORIZATION      (1 << 12)  /* Authorization header field */
59 59
 #define HDR_EXPIRES            (1 << 13)  /* Expires header field */
60
-#define HDR_PROXYAUTH          (1 << 14)  /* Proxy-Authorization header field */
60
+#define HDR_PROXYAUTH          (1 << 14)  /* Proxy-Authorization hdr field */
61 61
 #define HDR_SUPPORTED          (1 << 15)  /* Supported  header field */
62 62
 #define HDR_PROXYREQUIRE       (1 << 16)  /* Proxy-Require header field */
63 63
 #define HDR_UNSUPPORTED        (1 << 17)  /* Unsupported header field */
... ...
@@ -69,13 +69,21 @@
69 69
 #define HDR_PRIORITY           (1 << 23)  /* Priority header field */
70 70
 #define HDR_SUBJECT            (1 << 24)  /* Subject header field */
71 71
 #define HDR_USERAGENT          (1 << 25)  /* User-Agent header field */
72
-#define HDR_ACCEPTDISPOSITION  (1 << 26)  /* Accept-Disposition header field */
73
-#define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition header field */
72
+#define HDR_ACCEPTDISPOSITION  (1 << 26)  /* Accept-Disposition hdr field */
73
+#define HDR_CONTENTDISPOSITION (1 << 27)  /* Content-Disposition hdr field */
74 74
 #define HDR_DIVERSION          (1 << 28)  /* Diversion header field */
75 75
 #define HDR_RPID               (1 << 29)  /* Remote-Party-ID header field */
76 76
 #define HDR_OTHER              (1 << 30)  /* Some other header field */
77 77
 
78 78
 
79
+/* returns true if the header links allocated memory on parse field */
80
+#define hdr_allocs_parse( _hdr ) \
81
+	(((_hdr)->type)&(HDR_VIA|HDR_TO|HDR_FROM|HDR_CONTACT|HDR_ROUTE|\
82
+		HDR_RECORDROUTE|HDR_AUTHORIZATION|HDR_EXPIRES|HDR_PROXYAUTH|\
83
+		HDR_EVENT|HDR_ACCEPT|HDR_CONTENTDISPOSITION|HDR_DIVERSION|HDR_RPID))
84
+
85
+
86
+
79 87
 /* 
80 88
  * Format: name':' body 
81 89
  */