diff --git a/src/modules/lost/functions.c b/src/modules/lost/functions.c index b7a2fe08872..6545c3cfb21 100644 --- a/src/modules/lost/functions.c +++ b/src/modules/lost/functions.c @@ -349,7 +349,7 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, } /* send to service */ curl = httpapi.http_client_query_c( - _m, lisurl, &res, que.s, mtheld, ACCEPT_HDR); + _m, lisurl, &res, que.s, mtheld, ACCEPT_HDR); pkg_free(lisurl); /*clean up */ lisurl = NULL; } @@ -440,11 +440,11 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, LM_ERR("could not create POST request\n"); goto err; } - + LM_DBG("held POST request: [%.*s]\n", len, heldreq); curl = httpapi.http_client_query_c( - _m, geo.s, &pidfurl, heldreq, mtheld, ACCEPT_HDR); + _m, geo.s, &pidfurl, heldreq, mtheld, ACCEPT_HDR); pkg_free(heldreq); /* clean up */ heldreq = NULL; } @@ -466,7 +466,7 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, res.len = pidfurl.len; } } - /* error received */ + /* error received */ } else if(xmlStrcmp(root->name, (const xmlChar *)"error") == 0) { LM_DBG("HELD error response [%.*s]\n", res.len, res.s); @@ -505,8 +505,8 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, psurl = (pv_spec_t *)_url; psurl->setf(_m, &psurl->pvp, (int)EQ_T, &pvurl); lost_free_string(&geo); /* clean up */ - - /* return error code in case of response error */ + + /* return error code in case of response error */ if(err.len > 0) { res_error = 1; } @@ -524,7 +524,7 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, err: /* clean up pointer */ lost_free_string(&que); - lost_free_string(&idhdr); + lost_free_string(&idhdr); lost_free_string(&pidfurl); /* clean up xml */ if(doc != NULL) { @@ -540,7 +540,7 @@ int lost_held_function(struct sip_msg *_m, char *_con, char *_pidf, char *_url, if(err.s != NULL && err.len > 0) { lost_free_string(&err); } - + return LOST_CLIENT_ERROR; } @@ -614,7 +614,7 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf, if((ltime > 0) && (strlen(ptr) == 0)) { /* responseTime: milliseconds */ rtime = ltime; - /* or a string */ + /* or a string */ } else if((ltime == 0) && (strlen(ptr) > 0)) { if(strncasecmp(ptr, HELD_ED, strlen(HELD_ED)) == 0) { /* responseTime: emergencyDispatch */ @@ -676,7 +676,7 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf, LM_DBG("POST url: [%.*s]\n", len, lisurl); curl = httpapi.http_client_query_c( - _m, lisurl, &res, heldreq, mtheld, ACCEPT_HDR); + _m, lisurl, &res, heldreq, mtheld, ACCEPT_HDR); pkg_free(lisurl); /* clean up */ lisurl = NULL; pkg_free(heldreq); @@ -728,7 +728,7 @@ int lost_held_dereference(struct sip_msg *_m, char *_url, char *_pidf, * + 3 value and reference found: return 203 */ ret += lost_check_HeldResponse(root); - /* error received */ + /* error received */ } else if(xmlStrcmp(root->name, (const xmlChar *)"error") == 0) { LM_DBG("HELD error response [%.*s]\n", res.len, res.s); @@ -1019,7 +1019,7 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, LM_DBG("POST request: [%.*s]\n", len, heldreq); curl = httpapi.http_client_query_c( - _m, url.s, &ret, heldreq, mtheld, ACCEPT_HDR); + _m, url.s, &ret, heldreq, mtheld, ACCEPT_HDR); pkg_free(heldreq); /* clean up */ heldreq = NULL; } @@ -1066,7 +1066,7 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, } /* assemble findService request */ req.s = lost_find_service_request(loc, NULL, &req.len); - + if(req.s == NULL && req.len == 0) { LM_ERR("lost request failed\n"); goto err; @@ -1118,21 +1118,25 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, redirect = 1; while(redirect) { fsrdata = lost_parse_findServiceResponse(ret); - if (lost_verbose == 1) { + if(lost_verbose == 1) { lost_print_findServiceResponse(fsrdata); } switch(fsrdata->category) { case RESPONSE: if(fsrdata->uri != NULL) { /* get the first sips uri element ... */ - if(lost_search_response_list(&fsrdata->uri, &tmp.s, SIPS_S) > 0) { + if(lost_search_response_list(&fsrdata->uri, &tmp.s, SIPS_S) + > 0) { tmp.len = strlen(tmp.s); - /* or the first sip uri element ... */ - } else if(lost_search_response_list(&fsrdata->uri, &tmp.s, SIP_S) > 0) { + /* or the first sip uri element ... */ + } else if(lost_search_response_list( + &fsrdata->uri, &tmp.s, SIP_S) + > 0) { tmp.len = strlen(tmp.s); - /* or return error if nothing found */ + /* or return error if nothing found */ } else { - LM_ERR("sip/sips uri not found: [%.*s]\n", ret.len, ret.s); + LM_ERR("sip/sips uri not found: [%.*s]\n", ret.len, + ret.s); goto err; } /* copy uri string */ @@ -1199,17 +1203,21 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, /* add redirecting source to path list */ if((src.s = fsrdata->redirect->source) != NULL) { src.len = strlen(fsrdata->redirect->source); - if(lost_append_response_list(&fsrdata->path, src) == 0) { - LM_ERR("could not append server to path elememt\n"); - goto err; - } + if(lost_append_response_list(&fsrdata->path, src) + == 0) { + LM_ERR("could not append server to path " + "elememt\n"); + goto err; + } } /* clean up */ src.s = NULL; src.len = 0; /* check loop ... path elements */ char *via = NULL; - if(lost_search_response_list(&fsrdata->path, &via, tmp.s) > 0) { + if(lost_search_response_list( + &fsrdata->path, &via, tmp.s) + > 0) { LM_ERR("loop detected: " "[%s]<-->[%.*s]\n", via, tmp.len, tmp.s); @@ -1236,12 +1244,14 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, tmp.len = 0; /* assemble new findService request including path element */ - rereq.s = lost_find_service_request(loc, fsrdata->path, &rereq.len); + rereq.s = lost_find_service_request( + loc, fsrdata->path, &rereq.len); /* clean up */ lost_free_findServiceResponse(&fsrdata); lost_free_string(&ret); - LM_DBG("findService request: [%.*s]\n", rereq.len, rereq.s); + LM_DBG("findService request: [%.*s]\n", rereq.len, + rereq.s); /* copy url */ len = 0; @@ -1257,11 +1267,11 @@ int lost_function(struct sip_msg *_m, char *_con, char *_uri, char *_name, pkg_free(urlrep); urlrep = NULL; lost_free_string(&rereq); - + /* only HTTP 2xx responses are accepted */ if(curl >= 300 || curl < 100) { LM_ERR("POST [%.*s] failed with error: %d\n", - url.len, url.s, curl); + url.len, url.s, curl); goto err; } /* reset url string */ diff --git a/src/modules/lost/lost.c b/src/modules/lost/lost.c index 72008ee07ea..05eebec499c 100644 --- a/src/modules/lost/lost.c +++ b/src/modules/lost/lost.c @@ -212,7 +212,7 @@ static int fixup_lost_held_query(void **param, int param_no) static int fixup_free_lost_held_query(void **param, int param_no) { if(param_no == 1) { - return fixup_spve_null(param, 1); + return fixup_spve_null(param, 1); } if((param_no == 2) || (param_no == 3) || (param_no == 4)) { return fixup_free_pvar_null(param, 1); diff --git a/src/modules/lost/naptr.c b/src/modules/lost/naptr.c index 924b213a019..753e1dcbdc5 100644 --- a/src/modules/lost/naptr.c +++ b/src/modules/lost/naptr.c @@ -50,15 +50,15 @@ static inline int service_match(struct naptr_rdata *naptr, str *service) if(naptr->flags_len == 1) { return (((naptr->flags[0] == 'u') || (naptr->flags[0] == 'U')) && (naptr->services_len == service->len) - && (strncasecmp(naptr->services, service->s, - service->len) == 0)); + && (strncasecmp(naptr->services, service->s, service->len) + == 0)); } /* LIS:HELD domain */ if(naptr->flags_len == 0) { return ((naptr->services_len == service->len) - && (strncasecmp(naptr->services, service->s, - service->len) == 0)); + && (strncasecmp(naptr->services, service->s, service->len) + == 0)); } /* no matching service found */ @@ -226,7 +226,8 @@ int lost_naptr_lookup(str hostname, str *service, str *result) } if(parse_naptr_regexp(&(naptr->regexp[0]), naptr->regexp_len, &pattern, - &replacement) < 0) { + &replacement) + < 0) { free_rdata_list(head); /*clean up*/ LM_ERR("parsing of NAPTR regexp failed\n"); return 0; @@ -235,8 +236,8 @@ int lost_naptr_lookup(str hostname, str *service, str *result) pattern.s[pattern.len] = (char)0; replacement.s[replacement.len] = (char)0; /* replace hostname */ - if(reg_replace(pattern.s, replacement.s, &(hostname.s[0]), - result) < 0) { + if(reg_replace(pattern.s, replacement.s, &(hostname.s[0]), result) + < 0) { pattern.s[pattern.len] = '!'; replacement.s[replacement.len] = '!'; LM_ERR("regexp replace failed\n"); diff --git a/src/modules/lost/pidf.c b/src/modules/lost/pidf.c index 73ba530a75a..1e2f6731f3b 100644 --- a/src/modules/lost/pidf.c +++ b/src/modules/lost/pidf.c @@ -98,8 +98,11 @@ xmlNodePtr xmlNodeGetNodeByName( while(cur) { xmlNodePtr match = NULL; if(xmlStrcasecmp(cur->name, (unsigned char *)name) == 0) { - if(!ns || (cur->ns && xmlStrcasecmp(cur->ns->prefix, - (unsigned char *)ns) == 0)) + if(!ns + || (cur->ns + && xmlStrcasecmp( + cur->ns->prefix, (unsigned char *)ns) + == 0)) return cur; } match = xmlNodeGetNodeByName(cur->children, name, ns); diff --git a/src/modules/lost/response.c b/src/modules/lost/response.c index 119d80a5028..27b0a21259c 100644 --- a/src/modules/lost/response.c +++ b/src/modules/lost/response.c @@ -364,17 +364,17 @@ int lost_append_response_list(p_lost_list_t *head, str val) p_lost_list_t current = *head; new = lost_new_response_list(); - if (new != NULL) { + if(new != NULL) { new->value = lost_copy_string(val, &len); new->next = NULL; LM_DBG("### new list data [%.*s]\n", val.len, val.s); - if (current == NULL) { + if(current == NULL) { *head = new; return len; } - while (current->next != NULL) { + while(current->next != NULL) { current = current->next; } current->next = new; @@ -407,7 +407,7 @@ int lost_search_response_list(p_lost_list_t *list, char **val, const char *str) *val = cur->value; LM_DBG("###\t[%s] found\n", cur->value); - + return 1; } } @@ -662,11 +662,11 @@ p_lost_issue_t lost_get_response_issues(xmlNodePtr node) /* source property not found, clean up and return */ lost_delete_response_type(&issue); /* clean up */ break; - } + } LM_DBG("###\t[%s]\n", issue->type); - /* type and source property found ... parse text and copy */ + /* type and source property found ... parse text and copy */ if(issue->info != NULL) { issue->info->text = lost_get_property(cur, PROP_MSG, &len); issue->info->lang = lost_get_property(cur, PROP_LANG, &len); diff --git a/src/modules/lost/utilities.c b/src/modules/lost/utilities.c index 6f503295746..1103a40fd70 100644 --- a/src/modules/lost/utilities.c +++ b/src/modules/lost/utilities.c @@ -308,7 +308,6 @@ void lost_free_string(str *string) pkg_free(ptr.s); LM_DBG("### string object removed\n"); - } string->s = NULL; @@ -454,11 +453,12 @@ p_lost_geolist_t lost_get_geolocation_header(struct sip_msg *msg, int *items) if((hf->type == HDR_OTHER_T) && (hf->name.len == LOST_GEOLOC_HEADER_SIZE - 2)) { /* possible hit */ - if(strncasecmp(hf->name.s, LOST_GEOLOC_HEADER, - LOST_GEOLOC_HEADER_SIZE) == 0) { - + if(strncasecmp( + hf->name.s, LOST_GEOLOC_HEADER, LOST_GEOLOC_HEADER_SIZE) + == 0) { + hdr.s = hf->body.s; - hdr.len = hf->body.len; + hdr.len = hf->body.len; LM_DBG("found geolocation header [%.*s]\n", hdr.len, hdr.s); @@ -690,7 +690,8 @@ void lost_free_geoheader_list(p_lost_geolist_t *list) * lost_get_geoheader_value(list, type, rtype) * returns geoheader value and type (rtype) of given type */ -char *lost_get_geoheader_value(p_lost_geolist_t list, lost_geotype_t type, int *rtype) +char *lost_get_geoheader_value( + p_lost_geolist_t list, lost_geotype_t type, int *rtype) { p_lost_geolist_t head = list; char *value = NULL; @@ -802,7 +803,8 @@ int lost_new_geoheader_list(p_lost_geolist_t *list, str hdr) len++; } if((*(ptr + len) == '>') && (len > 6)) { - new = (p_lost_geolist_t)pkg_malloc(sizeof(s_lost_geolist_t)); + new = (p_lost_geolist_t)pkg_malloc( + sizeof(s_lost_geolist_t)); if(new == NULL) { PKG_MEM_ERROR; } else { @@ -844,7 +846,8 @@ int lost_new_geoheader_list(p_lost_geolist_t *list, str hdr) len++; } if((*(ptr + len) == '>') && (len > 10)) { - new = (p_lost_geolist_t)pkg_malloc(sizeof(s_lost_geolist_t)); + new = (p_lost_geolist_t)pkg_malloc( + sizeof(s_lost_geolist_t)); if(new == NULL) { PKG_MEM_ERROR; } else { @@ -859,8 +862,8 @@ int lost_new_geoheader_list(p_lost_geolist_t *list, str hdr) new->type = HTTP; } else if(((*(search + 5) == 's') - || (*(search + 5) == 'S')) - && (*(search + 6) == ':')) { + || (*(search + 5) == 'S')) + && (*(search + 6) == ':')) { LM_DBG("adding https url [%s]\n", new->value); @@ -1189,7 +1192,8 @@ int lost_xpath_location(xmlDocPtr doc, char *path, p_lost_loc_t loc) if(i == select) { /* return the current profile */ if(s_profile != NULL) { - loc->profile = (char *)pkg_malloc(strlen(s_profile) + 1); + loc->profile = + (char *)pkg_malloc(strlen(s_profile) + 1); if(loc->profile == NULL) { xmlFree(xmlbuff); /* clean up */ xmlFreeDoc(new); @@ -1497,7 +1501,7 @@ int lost_append_via_element(p_lost_list_t *head, xmlNodePtr *parent) int i; p_lost_list_t current = NULL; - if (head == NULL) { + if(head == NULL) { return 0; } @@ -1506,7 +1510,7 @@ int lost_append_via_element(p_lost_list_t *head, xmlNodePtr *parent) cnt++; /* check for more elements to add */ - while (current->next != NULL) { + while(current->next != NULL) { cnt++; current = current->next; } @@ -1515,7 +1519,7 @@ int lost_append_via_element(p_lost_list_t *head, xmlNodePtr *parent) xmlNodePtr ptrVia[cnt]; /* ad elements to element */ - for (i = 0; i < cnt; i++) { + for(i = 0; i < cnt; i++) { ptrVia[i] = xmlNewChild(*parent, NULL, BAD_CAST "via", NULL); xmlNewProp(ptrVia[i], BAD_CAST "source", BAD_CAST current->value); current = current->next; @@ -1663,14 +1667,14 @@ char *lost_find_service_request(p_lost_loc_t loc, p_lost_list_t path, int *lgth) snprintf(buf, BUFSIZE, "%s", loc->urn); xmlNewChild(ptrFindService, NULL, BAD_CAST "service", BAD_CAST buf); /* service - element */ - if (path != NULL) { + if(path != NULL) { ptrPath = xmlNewChild(ptrFindService, NULL, BAD_CAST "path", NULL); if(ptrPath == NULL) { LM_ERR("locationRequest xmlNewChild() failed\n"); xmlFreeDoc(request); return doc; } - if (lost_append_via_element(&path, &ptrPath) == 0) { + if(lost_append_via_element(&path, &ptrPath) == 0) { LM_ERR("appending elements to failed\n"); xmlFreeDoc(request); return doc;