Browse code

bugs fixed

Jan Janak authored on 26/03/2003 16:45:32
Showing 3 changed files
... ...
@@ -395,7 +395,7 @@ static inline void print_param(param_t* _p)
395 395
 	printf("name: \'%.*s\'\n", _p->name.len, _p->name.s);
396 396
 	printf("body: \'%.*s\'\n", _p->body.len, _p->body.s);
397 397
 	
398
-	printf("---/cparam---\n");
398
+	printf("---/param---\n");
399 399
 }
400 400
 
401 401
 
... ...
@@ -30,30 +30,32 @@
30 30
 #include <stdio.h>
31 31
 #include <string.h>
32 32
 #include "parse_rr.h"
33
-#include "../../mem/mem.h"
34
-#include "../../dprint.h"
35
-#include "../../trim.h"
33
+#include "../mem/mem.h"
34
+#include "../dprint.h"
35
+#include "../trim.h"
36 36
 
37 37
 
38 38
 /*
39 39
  * Parse Route and Record-Route header fields
40 40
  */
41
-int parse_rr(str* _s, rr_t** _r)
41
+int parse_rr(struct hdr_field* _h)
42 42
 {
43
-	rr_t* r, *res, *last;
43
+	rr_t* r, *last;
44 44
 	str s;
45 45
 	param_hooks_t hooks;
46 46
 
47
-	if (!_s || !_r) {
47
+	if (!_h) {
48 48
 		LOG(L_ERR, "parse_rr(): Invalid parameter value\n");
49 49
 		return -1;
50 50
 	}
51 51
 
52
+
52 53
 	     /* Make a temporary copy of the string */
53
-	s.s = _s->s;
54
-	s.len = _s->len;
54
+	s.s = _h->body.s;
55
+	s.len = _h->body.len;
56
+	trim_leading(&s);
55 57
 
56
-	res = last = 0;
58
+	last = 0;
57 59
 
58 60
 	while(1) {
59 61
 		     /* Allocate and clear rr stucture */
... ...
@@ -66,7 +68,7 @@ int parse_rr(str* _s, rr_t** _r)
66 66
 		memset(r, 0, sizeof(rr_t));
67 67
 		
68 68
 		     /* Parse name-addr part of the header */
69
-		if (parse_nameaddr(_s, &r->nameaddr) < 0) {
69
+		if (parse_nameaddr(&s, &r->nameaddr) < 0) {
70 70
 			LOG(L_ERR, "parse_rr(): Error while parsing name-addr\n");
71 71
 			goto error;
72 72
 		}
... ...
@@ -112,19 +114,18 @@ int parse_rr(str* _s, rr_t** _r)
112 112
 		}
113 113
 
114 114
 		     /* Append the structure as last parameter of the linked list */
115
-		if (!res) res = r;
115
+		if (!_h->parsed) (rr_t*)_h->parsed = r;
116 116
 		if (last) last->next = r;
117 117
 		last = r;
118 118
 	}
119 119
 
120 120
  error:
121 121
 	if (r) pkg_free(r);
122
-	free_rr(res); /* Free any contacts created so far */
122
+	free_rr((rr_t**)&_h->parsed); /* Free any contacts created so far */
123 123
 	return -1;
124 124
 
125 125
  ok:
126 126
 	if (last) last->next = r;
127
-	*_r = res;
128 127
 	return 0;
129 128
 }
130 129
 
... ...
@@ -133,13 +134,13 @@ int parse_rr(str* _s, rr_t** _r)
133 133
  * Free list of rrs
134 134
  * _r is head of the list
135 135
  */
136
-void free_rr(rr_t* _r)
136
+void free_rr(rr_t** _r)
137 137
 {
138 138
 	rr_t* ptr;
139 139
 
140
-	while(_r) {
141
-		ptr = _r;
142
-		_r = _r->next;
140
+	while(*_r) {
141
+		ptr = *_r;
142
+		*_r = (*_r)->next;
143 143
 		if (ptr->params) {
144 144
 			free_params(ptr->params);
145 145
 		}
... ...
@@ -31,9 +31,10 @@
31 31
 #ifndef PARSE_RR_H
32 32
 #define PARSE_RR_H
33 33
 
34
-#include "../../str.h"
35
-#include "../parse_nameaddr.h"
36
-#include "../parse_param.h"
34
+
35
+#include "parse_nameaddr.h"
36
+#include "parse_param.h"
37
+#include "hf.h"
37 38
 
38 39
 
39 40
 /*
... ...
@@ -51,14 +52,14 @@ typedef struct rr {
51 51
 /*
52 52
  * Parse Route & Record-Route header fields
53 53
  */
54
-int parse_rr(str* _s, rr_t** _r);
54
+int parse_rr(struct hdr_field* _r);
55 55
 
56 56
 
57 57
 /*
58 58
  * Free list of rr
59 59
  * _c is head of the list
60 60
  */
61
-void free_rr(rr_t* _r);
61
+void free_rr(rr_t** _r);
62 62
 
63 63
 
64 64
 /*