Browse code

- fixed incorrectly set attribute name

Jan Janak authored on 01/12/2005 10:18:07
Showing 1 changed files
... ...
@@ -31,6 +31,9 @@
31 31
 #include "parser/digest/digest.h"
32 32
 #include "ut.h"
33 33
 
34
+static str uid_name = STR_STATIC_INIT(AVP_UID);
35
+static str did_name = STR_STATIC_INIT(AVP_DID);
36
+
34 37
 
35 38
 /*
36 39
  * Set From UID
... ...
@@ -38,9 +41,10 @@
38 41
 void set_from_uid(str* uid)
39 42
 {
40 43
 	struct search_state s;
41
-	int_str name, val;
44
+	int_str val, name;
42 45
 	avp_t* a;
43 46
 
47
+	name.s = uid_name;
44 48
 	a = search_first_avp(AVP_CLASS_USER | AVP_TRACK_FROM | AVP_NAME_STR, name, 0, &s);
45 49
 	while(a) {
46 50
 		destroy_avp(a);
... ...
@@ -75,10 +79,9 @@ int get_from_uid(str* uid, struct sip_msg* msg)
75 79
 	struct to_body* from;
76 80
 	struct sip_uri puri;
77 81
 	str* du;
78
-	static str name_s = STR_STATIC_INIT(AVP_UID);
79
-	int_str name, val;
82
+	int_str val, name;
80 83
 
81
-	name.s = name_s;
84
+	name.s = uid_name;
82 85
 	if (search_first_avp(AVP_CLASS_USER | AVP_TRACK_FROM | AVP_NAME_STR, name, &val, 0)) {
83 86
 		*uid = val.s;
84 87
 		return 1;
... ...
@@ -122,9 +125,10 @@ int get_from_uid(str* uid, struct sip_msg* msg)
122 125
 void set_to_uid(str* uid)
123 126
 {
124 127
 	struct search_state s;
125
-	int_str name, val;
128
+	int_str val, name;
126 129
 	avp_t* a;
127 130
 
131
+	name.s = uid_name;
128 132
 	a = search_first_avp(AVP_CLASS_USER | AVP_TRACK_TO | AVP_NAME_STR, name, 0, &s);
129 133
 	while(a) {
130 134
 		destroy_avp(a);
... ...
@@ -144,10 +148,9 @@ int get_to_uid(str* uid, struct sip_msg* msg)
144 148
 	static char buf[MAX_URI_SIZE];
145 149
 	struct to_body* to;
146 150
 	struct sip_uri puri;
147
-	static str name_s = STR_STATIC_INIT(AVP_UID);
148
-	int_str name, val;
151
+	int_str val, name;
149 152
 
150
-	name.s = name_s;
153
+	name.s = uid_name;
151 154
 	if (search_first_avp(AVP_CLASS_USER | AVP_TRACK_TO | AVP_NAME_STR, name, &val, 0)) {
152 155
 		*uid = val.s;
153 156
 		return 1;
... ...
@@ -179,11 +182,10 @@ int get_to_uid(str* uid, struct sip_msg* msg)
179 182
  */
180 183
 int get_to_did(str* did, struct sip_msg* msg)
181 184
 {
182
-	static str name_s = STR_STATIC_INIT(AVP_DID);
183
-	int_str name, val;
185
+	int_str val, name;
184 186
 
185
-	name.s = name_s;
186
-	if (search_first_avp(AVP_CLASS_USER | AVP_TRACK_TO | AVP_NAME_STR, name, &val, 0)) {
187
+	name.s = did_name;
188
+	if (search_first_avp(AVP_TRACK_TO | AVP_NAME_STR, name, &val, 0)) {
187 189
 		*did = val.s;
188 190
 		return 1;
189 191
 	} 
... ...
@@ -196,11 +198,10 @@ int get_to_did(str* did, struct sip_msg* msg)
196 198
  */
197 199
 int get_from_did(str* did, struct sip_msg* msg)
198 200
 {
199
-	static str name_s = STR_STATIC_INIT(AVP_DID);
200
-	int_str name, val;
201
+	int_str val, name;
201 202
 
202
-	name.s = name_s;
203
-	if (search_first_avp(AVP_CLASS_USER | AVP_TRACK_FROM | AVP_NAME_STR, name, &val, 0)) {
203
+	name.s = did_name;
204
+	if (search_first_avp(AVP_TRACK_FROM | AVP_NAME_STR, name, &val, 0)) {
204 205
 		*did = val.s;
205 206
 		return 1;
206 207
 	}