Skip to content

Commit

Permalink
xcap_client: 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 90eea70 commit ce9cd31
Show file tree
Hide file tree
Showing 6 changed files with 383 additions and 438 deletions.
38 changes: 17 additions & 21 deletions src/modules/xcap_client/xcap_callbacks.c
Expand Up @@ -29,35 +29,32 @@
#include "xcap_callbacks.h"
#include "xcap_client.h"

void run_xcap_update_cb(int type, str xid, char* stream)
void run_xcap_update_cb(int type, str xid, char *stream)
{
xcap_callback_t* cb;
xcap_callback_t *cb;

for (cb= xcapcb_list; cb; cb=cb->next)
{
if(cb->types & type)
{
for(cb = xcapcb_list; cb; cb = cb->next) {
if(cb->types & type) {
LM_DBG("found callback\n");
cb->callback(type, xid, stream);
}
}
}

int register_xcapcb( int types, xcap_cb f)
int register_xcapcb(int types, xcap_cb f)
{
xcap_callback_t* xcb;
xcap_callback_t *xcb;

xcb= (xcap_callback_t*)shm_malloc(sizeof(xcap_callback_t));
if(xcb== NULL)
{
xcb = (xcap_callback_t *)shm_malloc(sizeof(xcap_callback_t));
if(xcb == NULL) {
ERR_MEM(SHARE_MEM);
}
memset(xcb, 0, sizeof(xcap_callback_t));

xcb->callback= f;
xcb->types= types;
xcb->next= xcapcb_list;
xcapcb_list= xcb;
xcb->callback = f;
xcb->types = types;
xcb->next = xcapcb_list;
xcapcb_list = xcb;
return 0;

error:
Expand All @@ -66,13 +63,12 @@ int register_xcapcb( int types, xcap_cb f)

void destroy_xcapcb_list(void)
{
xcap_callback_t* xcb, *prev_xcb;
xcap_callback_t *xcb, *prev_xcb;

xcb= xcapcb_list;
while(xcb)
{
prev_xcb= xcb;
xcb= xcb->next;
xcb = xcapcb_list;
while(xcb) {
prev_xcb = xcb;
xcb = xcb->next;
shm_free(prev_xcb);
}
}
35 changes: 18 additions & 17 deletions src/modules/xcap_client/xcap_callbacks.h
Expand Up @@ -26,36 +26,37 @@

#include "../../core/str.h"

#define PRES_RULES 1<<1
#define RESOURCE_LIST 1<<2
#define RLS_SERVICE 1<<3
#define PIDF_MANIPULATION 1<<4
#define XCAP_CAPS 1<<5
#define USER_PROFILE 1<<6
#define PRES_CONTENT 1<<7
#define SEARCH 1<<8
#define DIRECTORY 1<<9
#define PRES_RULES 1 << 1
#define RESOURCE_LIST 1 << 2
#define RLS_SERVICE 1 << 3
#define PIDF_MANIPULATION 1 << 4
#define XCAP_CAPS 1 << 5
#define USER_PROFILE 1 << 6
#define PRES_CONTENT 1 << 7
#define SEARCH 1 << 8
#define DIRECTORY 1 << 9

/* callback function prototype */
typedef int (xcap_cb)(int doc_type, str xid, char* doc);
typedef int(xcap_cb)(int doc_type, str xid, char *doc);

/* register callback function prototype */
typedef int (*register_xcapcb_t)(int types, xcap_cb f);


typedef struct xcap_callback {
int types; /* types of events that trigger the callback*/
xcap_cb* callback; /* callback function */
struct xcap_callback* next;
}xcap_callback_t;
typedef struct xcap_callback
{
int types; /* types of events that trigger the callback*/
xcap_cb *callback; /* callback function */
struct xcap_callback *next;
} xcap_callback_t;

/* destroy registered callback list */
void destroy_xcapcb_list(void);

/* register a callback for several types of events */
int register_xcapcb( int types, xcap_cb f);
int register_xcapcb(int types, xcap_cb f);

/* run all transaction callbacks for a composed type */
void run_xcap_update_cb(int type, str xid, char* stream);
void run_xcap_update_cb(int type, str xid, char *stream);

#endif

0 comments on commit ce9cd31

Please sign in to comment.