Skip to content

Commit

Permalink
rls: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed Nov 11, 2023
1 parent 242e627 commit 8be0d16
Show file tree
Hide file tree
Showing 13 changed files with 1,940 additions and 2,371 deletions.
16 changes: 8 additions & 8 deletions src/modules/rls/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@
#define RLS_API_H
#include "../../core/str.h"

typedef int (*rls_handle_subscribe_t)(struct sip_msg*, str, str);
typedef int (*rls_handle_subscribe0_t)(struct sip_msg*);
typedef int (*rls_handle_notify_t)(struct sip_msg*, char*, char*);
typedef int (*rls_handle_subscribe_t)(struct sip_msg *, str, str);
typedef int (*rls_handle_subscribe0_t)(struct sip_msg *);
typedef int (*rls_handle_notify_t)(struct sip_msg *, char *, char *);

typedef struct rls_binds {
typedef struct rls_binds
{
rls_handle_subscribe_t rls_handle_subscribe;
rls_handle_subscribe0_t rls_handle_subscribe0;
rls_handle_notify_t rls_handle_notify;
} rls_api_t;

typedef int (*bind_rls_f)(rls_api_t*);
typedef int (*bind_rls_f)(rls_api_t *);

int bind_rls(struct rls_binds*);
int bind_rls(struct rls_binds *);

inline static int rls_load_api(rls_api_t *pxb)
{
bind_rls_f bind_rls_exports;
if (!(bind_rls_exports = (bind_rls_f)find_export("bind_rls", 1, 0)))
{
if(!(bind_rls_exports = (bind_rls_f)find_export("bind_rls", 1, 0))) {
LM_ERR("Failed to import bind_rls\n");
return -1;
}
Expand Down
61 changes: 24 additions & 37 deletions src/modules/rls/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,50 @@ typedef struct list_entry
struct list_entry *next;
} list_entry_t;

static inline list_entry_t *list_insert(str *strng, list_entry_t *list, int *duplicate)
static inline list_entry_t *list_insert(
str *strng, list_entry_t *list, int *duplicate)
{
int cmp;
list_entry_t *p, *q;

if (duplicate != NULL)
if(duplicate != NULL)
*duplicate = 0;

if (strng == NULL || strng->s == NULL || strng->len == 0)
{
if(strng == NULL || strng->s == NULL || strng->len == 0) {
LM_ERR("bad string\n");
return list;
}

if ((p = (list_entry_t *) pkg_malloc(sizeof(list_entry_t))) == NULL)
{
if((p = (list_entry_t *)pkg_malloc(sizeof(list_entry_t))) == NULL) {
LM_ERR("out of memory\n");
return list;
}
p->strng = strng;
p->next = NULL;

if (list == NULL)
if(list == NULL)
return p;

cmp = strncmp(list->strng->s, strng->s, strng->len);

if (cmp == 0)
{
if (duplicate != NULL)
{
if(cmp == 0) {
if(duplicate != NULL) {
*duplicate = 1;
pkg_free(p);
return list;
}
}
if (cmp > 0)
{
if(cmp > 0) {
p->next = list;
return p;
}
else
{
} else {
q = list;
while (q->next != NULL && (cmp = strncmp(q->next->strng->s, strng->s, strng->len)) < 0)
while(q->next != NULL
&& (cmp = strncmp(q->next->strng->s, strng->s, strng->len)) < 0)
q = q->next;

if (cmp == 0)
{
if (duplicate != NULL)
{
if(cmp == 0) {
if(duplicate != NULL) {
*duplicate = 1;
pkg_free(p);
return list;
Expand All @@ -101,10 +94,8 @@ static inline list_entry_t *list_remove(str strng, list_entry_t *list)
int cmp = 0;
list_entry_t *p = list;

if (list != NULL)
{
if (strncmp(p->strng->s, strng.s, strng.len) == 0)
{
if(list != NULL) {
if(strncmp(p->strng->s, strng.s, strng.len) == 0) {
list = list->next;
pkg_free(p->strng->s);
pkg_free(p->strng);
Expand All @@ -113,11 +104,12 @@ static inline list_entry_t *list_remove(str strng, list_entry_t *list)
} else {
list_entry_t *q;

while (p->next != NULL && (cmp = strncmp(p->next->strng->s, strng.s, strng.len)) < 0)
while(p->next != NULL
&& (cmp = strncmp(p->next->strng->s, strng.s, strng.len))
< 0)
p = p->next;

if (cmp == 0)
{
if(cmp == 0) {
q = p->next;
p->next = q->next;
pkg_free(q->strng->s);
Expand All @@ -134,17 +126,13 @@ static inline str *list_pop(list_entry_t **list)
str *ret = NULL;
list_entry_t *tmp;

if (*list != NULL)
{
if(*list != NULL) {
ret = (*list)->strng;

if ((*list)->next == NULL)
{
if((*list)->next == NULL) {
pkg_free(*list);
*list = NULL;
}
else
{
} else {
tmp = *list;
*list = (*list)->next;
pkg_free(tmp);
Expand All @@ -158,8 +146,7 @@ static inline void list_free(list_entry_t **list)
{
str *strng;

while ((strng = list_pop(list)) != NULL)
{
while((strng = list_pop(list)) != NULL) {
pkg_free(strng->s);
pkg_free(strng);
}
Expand Down

0 comments on commit 8be0d16

Please sign in to comment.