Ver código fonte

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

Daniel-Constantin Mierla 12 anos atrás
pai
commit
7fd5619757
2 arquivos alterados com 31 adições e 0 exclusões
  1. 29 0
      data_lump.c
  2. 2 0
      data_lump.h

+ 29 - 0
data_lump.c

@@ -712,3 +712,32 @@ unsigned int count_applied_lumps(struct lump *ll, int type)
 	return n;
 }
 
+int remove_lump(sip_msg_t *msg, struct lump *l)
+{
+	struct lump *t = NULL;
+	struct lump *prev = NULL;
+	struct lump **list = NULL;
+
+	list=&msg->add_rm;	
+	for (t=*list; t; prev=t, t=t->next) {
+		if(t==l)
+			break;
+	}
+	if(t==NULL) {
+		list=&msg->body_lumps;
+		for (t=*list; t; prev=t, t=t->next) {
+			if(t==l)
+				break;
+		}
+	}
+	if(t!=NULL) {
+		if(prev==NULL) {
+			*list = t->next;
+		} else {
+			prev->next = t->next;
+		}
+		free_lump(t);
+		return 1;
+	}
+	return 0;
+}

+ 2 - 0
data_lump.h

@@ -95,4 +95,6 @@ void free_duped_lump_list(struct lump* l);
 /*! \brief remove all non-SHMEM lumps from the list */
 void del_nonshm_lump( struct lump** lump_list );
 
+/*! \brief remove the lump from the internal lists */
+int remove_lump(sip_msg_t *msg, struct lump *l);
 #endif