Skip to content

Commit

Permalink
lost: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent 73972a7 commit bae6239
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 60 deletions.
66 changes: 38 additions & 28 deletions src/modules/lost/functions.c
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/modules/lost/lost.c
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions src/modules/lost/naptr.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions src/modules/lost/pidf.c
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/modules/lost/response.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit bae6239

Please sign in to comment.