From 5152e2790722257ca75771a000140c96b5afc981 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:37:07 +0200 Subject: [PATCH] presence_mwi: clang-format for coherent indentation and coding style --- src/modules/presence_mwi/add_events.c | 48 ++++++++++++++----------- src/modules/presence_mwi/presence_mwi.c | 39 +++++++++----------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/src/modules/presence_mwi/add_events.c b/src/modules/presence_mwi/add_events.c index 089940e0816..75f7bf06ca7 100644 --- a/src/modules/presence_mwi/add_events.c +++ b/src/modules/presence_mwi/add_events.c @@ -42,14 +42,15 @@ /*! \brief utility function that skips spaces and tabs */ static inline char *eat_sp_tab(char *at, char *over) { - while((at < over) && ((*at == ' ') || (*at == '\t'))) at++; + while((at < over) && ((*at == ' ') || (*at == '\t'))) + at++; return at; } /*! \brief utility function that skips printable ascii chars */ static inline char *eat_printable(char *at, char *over) { - while ((at < over) && ((*at == '\t') || ((*at >= 32) && (*at <= 126)))) + while((at < over) && ((*at == '\t') || ((*at >= 32) && (*at <= 126)))) at++; return at; } @@ -57,16 +58,16 @@ static inline char *eat_printable(char *at, char *over) /*! \brief * event specific publish handling - check if body format is ok */ -int mwi_publ_handl(struct sip_msg* msg) +int mwi_publ_handl(struct sip_msg *msg) { str body; char *at, *over; - if (get_content_length(msg) == 0) + if(get_content_length(msg) == 0) return 1; body.s = get_body(msg); - if (body.s == NULL) { + if(body.s == NULL) { LM_ERR("cannot extract body from msg\n"); return -1; } @@ -77,29 +78,37 @@ int mwi_publ_handl(struct sip_msg* msg) over = body.s + body.len; /* check msg-status-line */ - if (body.len <= 16) goto err; - if (strncmp(body.s, "Messages-Waiting", 16) != 0) goto err; + if(body.len <= 16) + goto err; + if(strncmp(body.s, "Messages-Waiting", 16) != 0) + goto err; at = at + 16; at = eat_sp_tab(at, over); - if ((at >= over) || (*at != ':')) goto err; + if((at >= over) || (*at != ':')) + goto err; at++; - if ((at >= over) || ((*at != ' ') && (*at != '\t'))) goto err; + if((at >= over) || ((*at != ' ') && (*at != '\t'))) + goto err; at++; at = eat_sp_tab(at, over); - if (at + 3 >= over) goto err; - if (strncmp(at, "yes", 3) == 0) at = at + 3; + if(at + 3 >= over) + goto err; + if(strncmp(at, "yes", 3) == 0) + at = at + 3; + else if(strncmp(at, "no", 2) == 0) + at = at + 2; else - if (strncmp(at, "no", 2) == 0) at = at + 2; - else - goto err; - if ((at + 1 >= over) || (*at != '\r') || (*(at + 1) != '\n')) goto err; + goto err; + if((at + 1 >= over) || (*at != '\r') || (*(at + 1) != '\n')) + goto err; at = at + 2; /* check that remaining body consists of lines that only contain * printable ascii chars */ - while (at < over) { + while(at < over) { at = eat_printable(at, over); - if ((at + 1 >= over) || (*at != '\r') || (*(at + 1) != '\n')) goto err; + if((at + 1 >= over) || (*at != '\r') || (*(at + 1) != '\n')) + goto err; at = at + 2; } @@ -109,7 +118,6 @@ int mwi_publ_handl(struct sip_msg* msg) LM_ERR("check of body <%.*s> failed at character index %d (hexa: 0x%x)\n", body.len, body.s, (int)(at - body.s + 1), (int)(*at)); return -1; - } int mwi_add_events(void) @@ -124,12 +132,12 @@ int mwi_add_events(void) event.content_type.s = "application/simple-message-summary"; event.content_type.len = 34; - event.default_expires= pres_mwi_default_expires; + event.default_expires = pres_mwi_default_expires; event.type = PUBL_TYPE; event.req_auth = 0; event.evs_publ_handl = mwi_publ_handl; - if (pres_add_event(&event) < 0) { + if(pres_add_event(&event) < 0) { LM_ERR("failed to add event \"message-summary\"\n"); return -1; } diff --git a/src/modules/presence_mwi/presence_mwi.c b/src/modules/presence_mwi/presence_mwi.c index 89f9b78da61..212714bbed8 100644 --- a/src/modules/presence_mwi/presence_mwi.c +++ b/src/modules/presence_mwi/presence_mwi.c @@ -63,29 +63,24 @@ add_event_t pres_add_event; unsigned int pres_mwi_default_expires = 3600; /* module exported commands */ -static cmd_export_t cmds[] = -{ - {0, 0, 0, 0, 0, 0} -}; +static cmd_export_t cmds[] = {{0, 0, 0, 0, 0, 0}}; /* module exported parameters */ static param_export_t params[] = { - { "default_expires", INT_PARAM, &pres_mwi_default_expires }, - {0, 0, 0} -}; + {"default_expires", INT_PARAM, &pres_mwi_default_expires}, {0, 0, 0}}; /* module exports */ -struct module_exports exports= { - "presence_mwi", /* module name */ - DEFAULT_DLFLAGS, /* dlopen flags */ - cmds, /* exported functions */ - params, /* exported parameters */ - 0, /* RPC method exports */ - 0, /* exported pseudo-variables */ - 0, /* response handling function */ - mod_init, /* module initialization function */ - 0, /* per-child init function */ - 0 /* module destroy function */ +struct module_exports exports = { + "presence_mwi", /* module name */ + DEFAULT_DLFLAGS, /* dlopen flags */ + cmds, /* exported functions */ + params, /* exported parameters */ + 0, /* RPC method exports */ + 0, /* exported pseudo-variables */ + 0, /* response handling function */ + mod_init, /* module initialization function */ + 0, /* per-child init function */ + 0 /* module destroy function */ }; /* @@ -96,18 +91,18 @@ static int mod_init(void) presence_api_t pres; bind_presence_t bind_presence; - bind_presence= (bind_presence_t)find_export("bind_presence", 1,0); - if (!bind_presence) { + bind_presence = (bind_presence_t)find_export("bind_presence", 1, 0); + if(!bind_presence) { LM_ERR("can't bind presence\n"); return -1; } - if (bind_presence(&pres) < 0) { + if(bind_presence(&pres) < 0) { LM_ERR("can't bind pua\n"); return -1; } pres_add_event = pres.add_event; - if (pres_add_event == NULL) { + if(pres_add_event == NULL) { LM_ERR("could not import add_event\n"); return -1; }