Browse Source

- add_lump_rpl2 added: same as the old add_lump_rpl, but returns a lump_rpl**,
making a specific lump removal much more easy

Andrei Pelinescu-Onciul 19 years ago
parent
commit
9dbf5e572e
2 changed files with 25 additions and 3 deletions
  1. 9 2
      data_lump_rpl.c
  2. 16 1
      data_lump_rpl.h

+ 9 - 2
data_lump_rpl.c

@@ -30,6 +30,9 @@
  * 2003-09-11 : lump_rpl type added - LUMP_RPL_BODY & LUMP_RPL_HDR (bogdan)
  * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; types -> flags ;
  *              flags LUMP_RPL_NODUP and LUMP_RPL_NOFREE added (bogdan)
+ * 2006-10-16   add_lump_rpl2 added: same as the old add_lump_rpl, but
+ *               returns a lump_rpl**, making a specific lump removal much
+ *               more easy (andrei)
  */
 
 
@@ -40,10 +43,12 @@
 
 
 
-struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
+struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, 
+									int len, int flags)
 {
 	struct lump_rpl *lump = 0;
 	struct lump_rpl *foo;
+	struct lump_rpl** ret;
 
 	/* some checking */
 	if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY)
@@ -77,6 +82,7 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
 	/* add the lump to the msg */
 	if (!msg->reply_lump) {
 		msg->reply_lump = lump;
+		ret=&msg->reply_lump;
 	}else{
 		if (!(flags&LUMP_RPL_BODY))
 			for(foo=msg->reply_lump;foo->next;foo=foo->next);
@@ -92,9 +98,10 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
 					break;
 			}
 		foo->next = lump;
+		ret= &(foo->next);
 	}
 
-	return lump;
+	return ret;
 error:
 	return 0;
 }

+ 16 - 1
data_lump_rpl.h

@@ -31,6 +31,9 @@
  * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; type removed;
  *              flags LUMP_RPL_BODY, LUMP_RPL_NODUP and LUMP_RPL_NOFREE
  *              added (bogdan)
+ * 2006-10-16   add_lump_rpl2 added: same as the old add_lump_rpl, but
+ *               returns a lump_rpl**, making a specific lump removal much
+ *               more easy (andrei)
  */
 
 
@@ -53,7 +56,19 @@ struct lump_rpl
 	struct lump_rpl* next;
 };
 
-struct lump_rpl* add_lump_rpl(struct sip_msg *, char *, int , int );
+struct lump_rpl** add_lump_rpl2(struct sip_msg *, char *, int , int );
+
+
+/* compatibility wrapper for the old add_lump_rpl version */
+inline static struct lump_rpl* add_lump_rpl(struct sip_msg* msg,
+												char* s, int len , int flags )
+{
+	struct lump_rpl** l;
+	
+	l=add_lump_rpl2(msg, s, len, flags);
+	return l?(*l):0;
+}
+
 
 void free_lump_rpl(struct lump_rpl* );