Browse code

- 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 authored on 16/10/2006 18:36:43
Showing 2 changed files
... ...
@@ -30,6 +30,9 @@
30 30
  * 2003-09-11 : lump_rpl type added - LUMP_RPL_BODY & LUMP_RPL_HDR (bogdan)
31 31
  * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; types -> flags ;
32 32
  *              flags LUMP_RPL_NODUP and LUMP_RPL_NOFREE added (bogdan)
33
+ * 2006-10-16   add_lump_rpl2 added: same as the old add_lump_rpl, but
34
+ *               returns a lump_rpl**, making a specific lump removal much
35
+ *               more easy (andrei)
33 36
  */
34 37
 
35 38
 
... ...
@@ -40,10 +43,12 @@
40 40
 
41 41
 
42 42
 
43
-struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags)
43
+struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, 
44
+									int len, int flags)
44 45
 {
45 46
 	struct lump_rpl *lump = 0;
46 47
 	struct lump_rpl *foo;
48
+	struct lump_rpl** ret;
47 49
 
48 50
 	/* some checking */
49 51
 	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)
77 77
 	/* add the lump to the msg */
78 78
 	if (!msg->reply_lump) {
79 79
 		msg->reply_lump = lump;
80
+		ret=&msg->reply_lump;
80 81
 	}else{
81 82
 		if (!(flags&LUMP_RPL_BODY))
82 83
 			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)
92 92
 					break;
93 93
 			}
94 94
 		foo->next = lump;
95
+		ret= &(foo->next);
95 96
 	}
96 97
 
97
-	return lump;
98
+	return ret;
98 99
 error:
99 100
 	return 0;
100 101
 }
... ...
@@ -31,6 +31,9 @@
31 31
  * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; type removed;
32 32
  *              flags LUMP_RPL_BODY, LUMP_RPL_NODUP and LUMP_RPL_NOFREE
33 33
  *              added (bogdan)
34
+ * 2006-10-16   add_lump_rpl2 added: same as the old add_lump_rpl, but
35
+ *               returns a lump_rpl**, making a specific lump removal much
36
+ *               more easy (andrei)
34 37
  */
35 38
 
36 39
 
... ...
@@ -53,7 +56,19 @@ struct lump_rpl
53 53
 	struct lump_rpl* next;
54 54
 };
55 55
 
56
-struct lump_rpl* add_lump_rpl(struct sip_msg *, char *, int , int );
56
+struct lump_rpl** add_lump_rpl2(struct sip_msg *, char *, int , int );
57
+
58
+
59
+/* compatibility wrapper for the old add_lump_rpl version */
60
+inline static struct lump_rpl* add_lump_rpl(struct sip_msg* msg,
61
+												char* s, int len , int flags )
62
+{
63
+	struct lump_rpl** l;
64
+	
65
+	l=add_lump_rpl2(msg, s, len, flags);
66
+	return l?(*l):0;
67
+}
68
+
57 69
 
58 70
 void free_lump_rpl(struct lump_rpl* );
59 71