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