Browse code

core: added function to remove an exiting lump structure from internal list

Daniel-Constantin Mierla authored on 04/01/2013 18:25:05
Showing 2 changed files
... ...
@@ -712,3 +712,32 @@ unsigned int count_applied_lumps(struct lump *ll, int type)
712 712
 	return n;
713 713
 }
714 714
 
715
+int remove_lump(sip_msg_t *msg, struct lump *l)
716
+{
717
+	struct lump *t = NULL;
718
+	struct lump *prev = NULL;
719
+	struct lump **list = NULL;
720
+
721
+	list=&msg->add_rm;	
722
+	for (t=*list; t; prev=t, t=t->next) {
723
+		if(t==l)
724
+			break;
725
+	}
726
+	if(t==NULL) {
727
+		list=&msg->body_lumps;
728
+		for (t=*list; t; prev=t, t=t->next) {
729
+			if(t==l)
730
+				break;
731
+		}
732
+	}
733
+	if(t!=NULL) {
734
+		if(prev==NULL) {
735
+			*list = t->next;
736
+		} else {
737
+			prev->next = t->next;
738
+		}
739
+		free_lump(t);
740
+		return 1;
741
+	}
742
+	return 0;
743
+}
... ...
@@ -95,4 +95,6 @@ void free_duped_lump_list(struct lump* l);
95 95
 /*! \brief remove all non-SHMEM lumps from the list */
96 96
 void del_nonshm_lump( struct lump** lump_list );
97 97
 
98
+/*! \brief remove the lump from the internal lists */
99
+int remove_lump(sip_msg_t *msg, struct lump *l);
98 100
 #endif