Skip to content

Commit

Permalink
mohqueue: 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 a8eaac5 commit 1475913
Show file tree
Hide file tree
Showing 9 changed files with 2,684 additions and 2,883 deletions.
51 changes: 25 additions & 26 deletions src/modules/mohqueue/mohq_common.h
Expand Up @@ -82,49 +82,48 @@
#include "../../modules/tm/tm_load.h"

/* convenience macros */
#define MOHQ_STRUCT_PTR_OFFSET( struct1, cast1, offset1 ) \
#define MOHQ_STRUCT_PTR_OFFSET(struct1, cast1, offset1) \
(cast1)(struct1) + (offset1)

#define MOHQ_STR_COPY( str1, str2 ) \
memcpy((str1)->s, (str2)->s, (str2)->len ); \
#define MOHQ_STR_COPY(str1, str2) \
memcpy((str1)->s, (str2)->s, (str2)->len); \
(str1)->len = (str2)->len;

#define MOHQ_STR_APPEND( str1, str2 ) \
#define MOHQ_STR_APPEND(str1, str2) \
memcpy((str1)->s + (str1)->len, (str2)->s, (str2)->len); \
(str1)->len += (str2)->len;

#define MOHQ_STR_APPEND_L( str1, str1_lim, s2, s2_len ) \
if ((str1)->len + (s2_len) >= (str1_lim)) { \
LM_ERR( "Failed to append to str: too long!\n" ); \
} else { \
MOHQ_STR_APPEND((str1), (s2), (s2_len)); \
(str1_lim) -= (s2_len); \
#define MOHQ_STR_APPEND_L(str1, str1_lim, s2, s2_len) \
if((str1)->len + (s2_len) >= (str1_lim)) { \
LM_ERR("Failed to append to str: too long!\n"); \
} else { \
MOHQ_STR_APPEND((str1), (s2), (s2_len)); \
(str1_lim) -= (s2_len); \
}

#define MOHQ_STR_COPY_CSTR( str1, cstr1 ) \
#define MOHQ_STR_COPY_CSTR(str1, cstr1) \
memcpy((str1)->s + (str1)->len, (cstr1), strlen((cstr1))); \
(str1)->len += strlen((cstr1));

#define MOHQ_STR_APPEND_CSTR( str1, cstr1 ) \
MOHQ_STR_COPY_CSTR((str1), (cstr1))
#define MOHQ_STR_APPEND_CSTR(str1, cstr1) MOHQ_STR_COPY_CSTR((str1), (cstr1))

#define MOHQ_STR_APPEND_CSTR_L( str1, str1_lim, cstr1 ) \
if ((str1)->len + strlen(cstr1) >= (str1_lim)) { \
LM_ERR( "Failed to append to str: too long!\n" ); \
} else { \
MOHQ_STR_APPEND_CSTR((str1), (cstr1)); \
#define MOHQ_STR_APPEND_CSTR_L(str1, str1_lim, cstr1) \
if((str1)->len + strlen(cstr1) >= (str1_lim)) { \
LM_ERR("Failed to append to str: too long!\n"); \
} else { \
MOHQ_STR_APPEND_CSTR((str1), (cstr1)); \
}

/* STR_EQ assumes we're not using str pointers, which is obnoxious */
#define MOHQ_STR_EQ( str1, str2 ) \
(((str1)->len == (str2)->len) && \
memcmp((str1)->s, (str2)->s, (str1)->len) == 0)
#define MOHQ_STR_EQ(str1, str2) \
(((str1)->len == (str2)->len) \
&& memcmp((str1)->s, (str2)->s, (str1)->len) == 0)

#define MOHQ_STR_EMPTY( str1 ) \
(((str1) != NULL && ((str1)->s == NULL || (str1)->len <= 0 )) \
|| (str1) == NULL )
#define MOHQ_STR_EMPTY(str1) \
(((str1) != NULL && ((str1)->s == NULL || (str1)->len <= 0)) \
|| (str1) == NULL)

#define MOHQ_HEADER_EMPTY( hdr1 ) \
((hdr1) == NULL || MOHQ_STR_EMPTY( &(hdr1)->body ))
#define MOHQ_HEADER_EMPTY(hdr1) \
((hdr1) == NULL || MOHQ_STR_EMPTY(&(hdr1)->body))

#endif /* MOHQ_COMMON_H */

0 comments on commit 1475913

Please sign in to comment.