Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 14/02/2002 16:29:53
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,61 @@
1
+
2
+
3
+#include "dprint.h"
4
+#include "mem/mem.h"
5
+#include "data_lump_rpl.h"
6
+
7
+
8
+struct lump_rpl* build_lump_rpl( char* text, int len )
9
+{
10
+	struct lump_rpl *lump = 0;
11
+
12
+	lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl));
13
+	if (!lump)
14
+	{
15
+		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n");
16
+		goto error;
17
+	}
18
+
19
+	lump->text.s = pkg_malloc( len );
20
+	if (!lump->text.s)
21
+	{
22
+		LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n");
23
+		goto error;
24
+	}
25
+
26
+	memcpy(lump->text.s,text,len);
27
+	lump->text.len = len;
28
+	lump->next = 0;
29
+
30
+	return lump;
31
+
32
+error:
33
+	if (lump) pkg_free(lump);
34
+	return 0;
35
+}
36
+
37
+
38
+
39
+int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump)
40
+{
41
+	struct lump_rpl *foo;
42
+
43
+	if (!msg->reply_lump)
44
+	{
45
+		msg->reply_lump = lump;
46
+	}else{
47
+		for(foo=msg->reply_lump;foo->next;foo=foo->next);
48
+		foo->next = lump;
49
+	}
50
+}
51
+
52
+
53
+
54
+int free_lump_rpl(struct lump_rpl* lump)
55
+{
56
+	if (lump && lump->text.s)  pkg_free(lump->text.s);
57
+	if (lump) pkg_free(lump);
58
+}
59
+
60
+
61
+
0 62
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ */
5
+
6
+#ifndef data_lump_rpl_h
7
+#define data_lump_rpl_h
8
+
9
+#include "msg_parser.h"
10
+
11
+
12
+struct lump_rpl
13
+{
14
+	str text;
15
+	struct lump_rpl* next;
16
+};
17
+
18
+struct lump_rpl* build_lump_rpl( char* , int );
19
+
20
+int add_lump_rpl(struct sip_msg * , struct lump_rpl* );
21
+
22
+int free_lump_rpl(struct lump_rpl* );
23
+
24
+#endif
... ...
@@ -36,6 +36,7 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
36 36
    struct to_param   *to_prm,*new_to_prm;
37 37
    struct sip_msg     *new_msg;
38 38
    struct lump          *lump_chain, *lump_tmp, **lump_anchor, **lump_anchor2;
39
+   struct lump_rpl    *rpl_lump, *new_rpl_lump, **rpl_lump_anchor;
39 40
    char                       *p,*foo;
40 41
 
41 42
 
... ...
@@ -97,8 +98,9 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
97 98
       lump_chain = lump_chain->next;
98 99
    }
99 100
 
100
-   /**/
101
-
101
+   /*length of reply lump structures*/
102
+   for(rpl_lump=org_msg->reply_lump;rpl_lump;rpl_lump=rpl_lump->next)
103
+       len+=rpl_lump->text.len;
102 104
 
103 105
    p=(char *)sh_malloc(len);foo=p;
104 106
    if (!p)
... ...
@@ -290,6 +292,21 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
290 292
       lump_anchor = &((*lump_anchor)->next);
291 293
       lump_chain = lump_chain->next;
292 294
    }
295
+
296
+   /*cloning reply lump structures*/
297
+   rpl_lump_anchor = &(new_msg->reply_lump);
298
+   for(rpl_lump=org_msg->reply_lump;rpl_lump;rpl_lump=rpl_lump->next)
299
+   {
300
+       *(rpl_lump_anchor)=(struct lump_rpl*)p;
301
+       p+=sizeof( struct lump_rpl );
302
+       (*rpl_lump_anchor)->text.len = rpl_lump->text.len;
303
+       (*rpl_lump_anchor)->text.s=p;
304
+       p+=rpl_lump->text.len;
305
+       memcpy((*rpl_lump_anchor)->text.s,rpl_lump->text.s,rpl_lump->text.len);
306
+       (*rpl_lump_anchor)->next=0;
307
+       rpl_lump_anchor = &((*rpl_lump_anchor)->next)
308
+   }
309
+
293 310
    return new_msg;
294 311
 }
295 312