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 499
 	return dup_lump_list_r(l, LD_NEXT, &deep_error);
498 500
 }
499 501
 
502
+
503
+
500 504
 void free_duped_lump_list(struct lump* l)
501 505
 {
502 506
 	struct lump *r, *foo,*crt;
... ...
@@ -530,3 +534,56 @@ void free_duped_lump_list(struct lump* l)
530 534
 	}
531 535
 }
532 536
 
537
+
538
+
539
+void del_nonshm_lump( struct lump** lump_list )
540
+{
541
+	struct lump *r, *foo, *crt, **prev, *prev_r;
542
+
543
+	prev = lump_list;
544
+	crt = *lump_list;
545
+
546
+	while (crt) {
547
+		if (crt->flags!=LUMPFLAG_SHMEM) {
548
+			/* unlink it */
549
+			foo = crt;
550
+			crt = crt->next;
551
+			foo->next = 0;
552
+			/* update the 'next' link of the previous lump */
553
+			*prev = crt;
554
+			/* entire before/after list must be removed */
555
+			free_lump_list( foo );
556
+		} else {
557
+			/* check on before and prev list for non-shmem lumps */
558
+			r = crt->after;
559
+			prev_r = crt;
560
+			while(r){
561
+				foo=r; r=r->after;
562
+				if (foo->flags!=LUMPFLAG_SHMEM) {
563
+					prev_r->after = r;
564
+					free_lump(foo);
565
+					pkg_free(foo);
566
+				} else {
567
+					prev_r = foo;
568
+				}
569
+			}
570
+			/* before */
571
+			r = crt->before;
572
+			prev_r = crt;
573
+			while(r){
574
+				foo=r; r=r->before;
575
+				if (foo->flags!=LUMPFLAG_SHMEM) {
576
+					prev_r->before = r;
577
+					free_lump(foo);
578
+					pkg_free(foo);
579
+				} else {
580
+					prev_r = foo;
581
+				}
582
+			}
583
+			/* go to next lump */
584
+			prev = &(crt->next);
585
+			crt = crt->next;
586
+		}
587
+	}
588
+}
589
+
... ...
@@ -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
  */