Mercurial > pidgin.yaz
comparison src/upnp.c @ 13621:095fd5936962
[gaim-migrate @ 16007]
datallah committed this to CVS during the CVS -> SVN migration:
The retval of xmlnode_get_data() needs to be g_free()'d
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 11 Apr 2006 15:59:36 +0000 |
parents | 33bef17125c2 |
children | b39a92702939 |
comparison
equal
deleted
inserted
replaced
13620:78c2c6a462d7 | 13621:095fd5936962 |
---|---|
167 | 167 |
168 static gboolean | 168 static gboolean |
169 gaim_upnp_compare_device(const xmlnode* device, const gchar* deviceType) | 169 gaim_upnp_compare_device(const xmlnode* device, const gchar* deviceType) |
170 { | 170 { |
171 xmlnode* deviceTypeNode = xmlnode_get_child(device, "deviceType"); | 171 xmlnode* deviceTypeNode = xmlnode_get_child(device, "deviceType"); |
172 char *tmp; | |
173 gboolean ret; | |
174 | |
172 if(deviceTypeNode == NULL) { | 175 if(deviceTypeNode == NULL) { |
173 return FALSE; | 176 return FALSE; |
174 } | 177 } |
175 return !g_ascii_strcasecmp(xmlnode_get_data(deviceTypeNode), | 178 |
176 deviceType); | 179 tmp = xmlnode_get_data(deviceTypeNode); |
180 ret = !g_ascii_strcasecmp(tmp, deviceType); | |
181 g_free(tmp); | |
182 | |
183 return ret; | |
177 } | 184 } |
178 | 185 |
179 | 186 |
180 static gboolean | 187 static gboolean |
181 gaim_upnp_compare_service(const xmlnode* service, const gchar* serviceType) | 188 gaim_upnp_compare_service(const xmlnode* service, const gchar* serviceType) |
182 { | 189 { |
183 xmlnode* serviceTypeNode = xmlnode_get_child(service, "serviceType"); | 190 xmlnode* serviceTypeNode = xmlnode_get_child(service, "serviceType"); |
191 char *tmp; | |
192 gboolean ret; | |
193 | |
184 if(serviceTypeNode == NULL) { | 194 if(serviceTypeNode == NULL) { |
185 return FALSE; | 195 return FALSE; |
186 } | 196 } |
187 return !g_ascii_strcasecmp(xmlnode_get_data(serviceTypeNode), | 197 |
188 serviceType); | 198 tmp = xmlnode_get_data(serviceTypeNode); |
199 ret = !g_ascii_strcasecmp(tmp, serviceType); | |
200 g_free(tmp); | |
201 | |
202 return ret; | |
189 } | 203 } |
190 | 204 |
191 | 205 |
192 static gchar* | 206 static gchar* |
193 gaim_upnp_parse_description_response(const gchar* httpResponse, gsize len, | 207 gaim_upnp_parse_description_response(const gchar* httpResponse, gsize len, |
194 const gchar* httpURL, const gchar* serviceType) | 208 const gchar* httpURL, const gchar* serviceType) |
195 { | 209 { |
196 gchar* xmlRoot; | 210 gchar *xmlRoot, *baseURL, *controlURL, *service; |
197 gchar* baseURL; | 211 xmlnode *xmlRootNode, *serviceTypeNode, *controlURLNode, *baseURLNode; |
198 gchar* controlURL; | 212 char *tmp; |
199 gchar* service; | |
200 xmlnode* xmlRootNode; | |
201 xmlnode* serviceTypeNode; | |
202 xmlnode* controlURLNode; | |
203 xmlnode* baseURLNode; | |
204 | 213 |
205 /* make sure we have a valid http response */ | 214 /* make sure we have a valid http response */ |
206 if(g_strstr_len(httpResponse, len, HTTP_OK) == NULL) { | 215 if(g_strstr_len(httpResponse, len, HTTP_OK) == NULL) { |
207 gaim_debug_error("upnp", | 216 gaim_debug_error("upnp", |
208 "parse_description_response(): Failed In HTTP_OK\n\n"); | 217 "parse_description_response(): Failed In HTTP_OK\n\n"); |
224 return NULL; | 233 return NULL; |
225 } | 234 } |
226 | 235 |
227 /* get the baseURL of the device */ | 236 /* get the baseURL of the device */ |
228 if((baseURLNode = xmlnode_get_child(xmlRootNode, "URLBase")) != NULL) { | 237 if((baseURLNode = xmlnode_get_child(xmlRootNode, "URLBase")) != NULL) { |
229 baseURL = g_strdup(xmlnode_get_data(baseURLNode)); | 238 baseURL = xmlnode_get_data(baseURLNode); |
230 } else { | 239 } else { |
231 baseURL = g_strdup(httpURL); | 240 baseURL = g_strdup(httpURL); |
232 } | 241 } |
233 | 242 |
234 /* get the serviceType child that has the service type as its data */ | 243 /* get the serviceType child that has the service type as its data */ |
326 g_free(baseURL); | 335 g_free(baseURL); |
327 xmlnode_free(xmlRootNode); | 336 xmlnode_free(xmlRootNode); |
328 return NULL; | 337 return NULL; |
329 } | 338 } |
330 | 339 |
331 if(!gaim_str_has_prefix(xmlnode_get_data(controlURLNode), "http://") && | 340 tmp = xmlnode_get_data(controlURLNode); |
332 !gaim_str_has_prefix(xmlnode_get_data(controlURLNode), "HTTP://")) { | 341 if(!gaim_str_has_prefix(tmp, "http://") && |
333 controlURL = g_strdup_printf("%s%s", baseURL, | 342 !gaim_str_has_prefix(tmp, "HTTP://")) { |
334 xmlnode_get_data(controlURLNode)); | 343 controlURL = g_strdup_printf("%s%s", baseURL, tmp); |
344 g_free(tmp); | |
335 }else{ | 345 }else{ |
336 controlURL = g_strdup(xmlnode_get_data(controlURLNode)); | 346 controlURL = tmp; |
337 } | 347 } |
338 g_free(baseURL); | 348 g_free(baseURL); |
339 xmlnode_free(xmlRootNode); | 349 xmlnode_free(xmlRootNode); |
340 | 350 |
341 return controlURL; | 351 return controlURL; |