ze-filter  (ze-filter-0.8.0-develop-180218)
macros.h File Reference

Go to the source code of this file.

Macros

#define ASSERT(a)   assert((a))
 
#define WAIT_NOHANG(pid, stat)   waitpid(pid, stat, WNOHANG)
 
#define WAIT_HANG(pid, stat)   waitpid(pid, stat, 0)
 
#define FREE(x)
 
#define FD_PRINTF(fdp, ...)
 
#define SD_PRINTF(fdp, ...)
 
#define STRCASEEQUAL(a, b)   ((a) != NULL && (b) != NULL ? strcasecmp((a),(b)) == 0 : ((a) == (b)))
 
#define STRNCASEEQUAL(a, b, n)   ((a) != NULL && (b) != NULL ? strncasecmp((a),(b),(n)) == 0 : ((a) == (b)))
 
#define STREQUAL(a, b)   ((a) != NULL && (b) != NULL ? strcmp((a),(b)) == 0 : ((a) == (b)))
 
#define STRNULL(x, r)   ((x) != NULL ? (x) : (r))
 
#define STREMPTY(x, r)   ((x) != NULL && strlen(x) > 0 ? (x) : (r))
 
#define ISSTRNULL(x)   ((x) == NULL)
 
#define ISSTREMPTY(x)   ((x) == NULL || strlen(x) == 0)
 
#define STRBOOL(x, t, f)   ((x) ? t : f)
 
#define SIGN(x)   ((x) < 0 ? - 1 : 1)
 
#define MUTEX_LOCK(mutex)
 
#define MUTEX_UNLOCK(mutex)
 
#define RWLOCK_RDLOCK(lock)
 
#define RWLOCK_WRLOCK(lock)
 
#define RWLOCK_UNLOCK(lock)
 
#define max(a, b)   ((a) > (b) ? (a) : (b))
 
#define min(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define SECONDS
 
#define MINUTES   * 60
 
#define HOURS   * 60 MINUTES
 
#define DAYS   * 24 HOURS
 
#define WEEKS   * 7 DAYS
 
#define MONTHS   * 30 DAYS
 
#define YEARS   * 365 DAYS
 
#define BYTES
 
#define KBYTES   * 1024
 
#define MBYTES   * 1024 KBYTES
 
#define GBYTES   * 1024 MBYTES
 
#define TRUE   1
 
#define FALSE   0
 
#define SET_BIT(p, i)   ((p) |= (1 << (i)))
 
#define CLR_BIT(p, i)   ((p) &= ~(1 << (i)))
 
#define GET_BIT(p, i)   (((p) & (1 << (i))) != 0 ? TRUE : FALSE)
 
#define SKIP_SPACES(s)
 
#define SKIP_ALPHAS(s)
 
#define SKIP_DIGITS(s)
 
#define SKIP_ALPHANUM(s)
 
#define SKIP_KEYCHARS(s)
 
#define STRIP_END_SPACES(s)
 
#define PATH_REGEX   "^(/[-a-z0-9.]+)+$"
 
#define DOMAINNAME_REGEX   "^[a-z0-9._-]+\\.[a-z]{2,6}$"
 
#define IPV4_ADDR_REGEX   "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$"
 
#define IPV6_ADDR_REGEX   "(ipv6:)?.*:"
 
#define IPV4_ADDR_REGEX_BRACKET   "[\\[][0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+[\\]]"
 
#define CRLF   "\r\n"
 
#define NULLSENDER   "<>"
 
#define POSTMASTER_OK   1
 
#define POSTMASTER_FORGED   -1
 
#define NOT_POSTMASTER   0
 
#define ADJUST_FILENAME(path, fname, cfdir, defval)
 
#define SHOW_CURSOR(zero)
 
#define __ZE_MACROS_H
 

Macro Definition Documentation

◆ __ZE_MACROS_H

#define __ZE_MACROS_H

Definition at line 261 of file macros.h.

◆ ADJUST_FILENAME

#define ADJUST_FILENAME (   path,
  fname,
  cfdir,
  defval 
)
Value:
do { \
char *name = NULL; \
name = (fname != NULL && strlen(fname) > 0) ? fname : defval; \
strcpy(path, ""); \
if (*name == '/' || *name == '.') \
strlcpy(path, name, sizeof(path)); \
else \
snprintf(path, sizeof(path), "%s/%s", cfdir, name); \
zeLog_MessageInfo(15, "Adjusted path is %s", path); \
} while (FALSE);
#define FALSE
Definition: macros.h:160

Definition at line 236 of file macros.h.

◆ ASSERT

#define ASSERT (   a)    assert((a))

Definition at line 27 of file macros.h.

◆ BYTES

#define BYTES

Definition at line 150 of file macros.h.

◆ CLR_BIT

#define CLR_BIT (   p,
 
)    ((p) &= ~(1 << (i)))

Definition at line 167 of file macros.h.

◆ CRLF

#define CRLF   "\r\n"

Definition at line 224 of file macros.h.

◆ DAYS

#define DAYS   * 24 HOURS

Definition at line 145 of file macros.h.

◆ DOMAINNAME_REGEX

#define DOMAINNAME_REGEX   "^[a-z0-9._-]+\\.[a-z]{2,6}$"

Definition at line 216 of file macros.h.

◆ FALSE

#define FALSE   0

Definition at line 160 of file macros.h.

◆ FD_PRINTF

#define FD_PRINTF (   fdp,
  ... 
)
Value:
do { \
if (fdp >= 0) { \
char fdp_str[1024]; \
(void ) snprintf(fdp_str, sizeof(fdp_str), __VA_ARGS__); \
if (write (fdp, fdp_str, strlen(fdp_str)) != strlen(fdp_str)) \
ZE_LogSysError("error on FD_PRINTF"); \
} else \
printf(__VA_ARGS__); \
} while (0)

Definition at line 45 of file macros.h.

◆ FREE

#define FREE (   x)
Value:
do { \
if (x != NULL) \
free(x); \
x = NULL; \
} while (0)

Definition at line 37 of file macros.h.

◆ GBYTES

#define GBYTES   * 1024 MBYTES

Definition at line 153 of file macros.h.

◆ GET_BIT

#define GET_BIT (   p,
 
)    (((p) & (1 << (i))) != 0 ? TRUE : FALSE)

Definition at line 168 of file macros.h.

◆ HOURS

#define HOURS   * 60 MINUTES

Definition at line 144 of file macros.h.

◆ IPV4_ADDR_REGEX

#define IPV4_ADDR_REGEX   "^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$"

Definition at line 218 of file macros.h.

◆ IPV4_ADDR_REGEX_BRACKET

#define IPV4_ADDR_REGEX_BRACKET   "[\\[][0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+[\\]]"

Definition at line 221 of file macros.h.

◆ IPV6_ADDR_REGEX

#define IPV6_ADDR_REGEX   "(ipv6:)?.*:"

Definition at line 219 of file macros.h.

◆ ISSTREMPTY

#define ISSTREMPTY (   x)    ((x) == NULL || strlen(x) == 0)

Definition at line 85 of file macros.h.

◆ ISSTRNULL

#define ISSTRNULL (   x)    ((x) == NULL)

Definition at line 84 of file macros.h.

◆ KBYTES

#define KBYTES   * 1024

Definition at line 151 of file macros.h.

◆ max

#define max (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 127 of file macros.h.

◆ MAX

#define MAX (   a,
 
)    ((a) > (b) ? (a) : (b))

Definition at line 139 of file macros.h.

◆ MBYTES

#define MBYTES   * 1024 KBYTES

Definition at line 152 of file macros.h.

◆ min

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 128 of file macros.h.

◆ MIN

#define MIN (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 140 of file macros.h.

◆ MINUTES

#define MINUTES   * 60

Definition at line 143 of file macros.h.

◆ MONTHS

#define MONTHS   * 30 DAYS

Definition at line 147 of file macros.h.

◆ MUTEX_LOCK

#define MUTEX_LOCK (   mutex)
Value:
{ \
int r = 0; \
if ((r = pthread_mutex_lock(mutex)) != 0) { \
ZE_LogSysError("pthread_mutex_lock : %s", strerror(r)); \
} \
}
pthread_mutex_t mutex
Definition: ze-connopen.c:63

Definition at line 93 of file macros.h.

◆ MUTEX_UNLOCK

#define MUTEX_UNLOCK (   mutex)
Value:
{ \
int r = 0; \
if ((r = pthread_mutex_unlock(mutex)) != 0) { \
ZE_LogSysError("pthread_mutex_unlock : %s", strerror(r)); \
} \
}
pthread_mutex_t mutex
Definition: ze-connopen.c:63

Definition at line 101 of file macros.h.

◆ NOT_POSTMASTER

#define NOT_POSTMASTER   0

Definition at line 233 of file macros.h.

◆ NULLSENDER

#define NULLSENDER   "<>"

Definition at line 229 of file macros.h.

◆ PATH_REGEX

#define PATH_REGEX   "^(/[-a-z0-9.]+)+$"

Definition at line 214 of file macros.h.

◆ POSTMASTER_FORGED

#define POSTMASTER_FORGED   -1

Definition at line 232 of file macros.h.

◆ POSTMASTER_OK

#define POSTMASTER_OK   1

Definition at line 231 of file macros.h.

◆ RWLOCK_RDLOCK

#define RWLOCK_RDLOCK (   lock)
Value:
if (pthread_rwlock_rdlock(lock) != 0) { \
ZE_LogSysError("pthread_rwlock_rdlock"); \
}

Definition at line 109 of file macros.h.

◆ RWLOCK_UNLOCK

#define RWLOCK_UNLOCK (   lock)
Value:
if (pthread_rwlock_unlock(lock) != 0) { \
ZE_LogSysError("pthread_rwlock_rdlock"); \
}

Definition at line 119 of file macros.h.

◆ RWLOCK_WRLOCK

#define RWLOCK_WRLOCK (   lock)
Value:
if (pthread_rwlock_wrlock(lock) != 0) { \
ZE_LogSysError("pthread_rwlock_rdlock"); \
}

Definition at line 114 of file macros.h.

◆ SD_PRINTF

#define SD_PRINTF (   fdp,
  ... 
)
Value:
do { \
if (fdp >= 0) { \
char fdp_str[1024]; \
(void ) snprintf(fdp_str, sizeof(fdp_str), __VA_ARGS__); \
if (sendto(fdp, fdp_str, strlen(fdp_str), 0, NULL, 0) != strlen(fdp_str)) \
ZE_LogSysError("error on SD_PRINTF"); \
} else \
printf(__VA_ARGS__); \
} while (0)

Definition at line 56 of file macros.h.

◆ SECONDS

#define SECONDS

Definition at line 142 of file macros.h.

◆ SET_BIT

#define SET_BIT (   p,
 
)    ((p) |= (1 << (i)))

Definition at line 166 of file macros.h.

◆ SHOW_CURSOR

#define SHOW_CURSOR (   zero)
Value:
do { \
static char xCURSOR[] = "|/-\\"; \
static int n = 0, i = 0; \
if (zero) \
n = 0; \
if (++n % 10 == 0) { \
char c = xCURSOR[i++ % 4]; \
fprintf (stderr, "* %c %6d\r", c, n); \
} \
} while (FALSE)
#define FALSE
Definition: macros.h:160

Definition at line 249 of file macros.h.

◆ SIGN

#define SIGN (   x)    ((x) < 0 ? - 1 : 1)

Definition at line 91 of file macros.h.

◆ SKIP_ALPHANUM

#define SKIP_ALPHANUM (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && isalnum(*s)) \
s++; \
} while (0)

Definition at line 192 of file macros.h.

◆ SKIP_ALPHAS

#define SKIP_ALPHAS (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && isalpha(*s)) \
s++; \
} while (0)

Definition at line 178 of file macros.h.

◆ SKIP_DIGITS

#define SKIP_DIGITS (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && isdigit(*s)) \
s++; \
} while (0)

Definition at line 185 of file macros.h.

◆ SKIP_KEYCHARS

#define SKIP_KEYCHARS (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && (isalnum(*s) || *s == '-')) \
s++; \
} while (0)

Definition at line 199 of file macros.h.

◆ SKIP_SPACES

#define SKIP_SPACES (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && isspace(*s)) \
s++; \
} while (0)

Definition at line 171 of file macros.h.

◆ STRBOOL

#define STRBOOL (   x,
  t,
 
)    ((x) ? t : f)

Definition at line 87 of file macros.h.

◆ STRCASEEQUAL

#define STRCASEEQUAL (   a,
 
)    ((a) != NULL && (b) != NULL ? strcasecmp((a),(b)) == 0 : ((a) == (b)))

Definition at line 72 of file macros.h.

◆ STREMPTY

#define STREMPTY (   x,
 
)    ((x) != NULL && strlen(x) > 0 ? (x) : (r))

Definition at line 82 of file macros.h.

◆ STREQUAL

#define STREQUAL (   a,
 
)    ((a) != NULL && (b) != NULL ? strcmp((a),(b)) == 0 : ((a) == (b)))

Definition at line 78 of file macros.h.

◆ STRIP_END_SPACES

#define STRIP_END_SPACES (   s)
Value:
do { \
if (s != NULL) \
while (*s != '\0' && isspace(*s)) \
s++; \
} while (0)

Definition at line 206 of file macros.h.

◆ STRNCASEEQUAL

#define STRNCASEEQUAL (   a,
  b,
 
)    ((a) != NULL && (b) != NULL ? strncasecmp((a),(b),(n)) == 0 : ((a) == (b)))

Definition at line 75 of file macros.h.

◆ STRNULL

#define STRNULL (   x,
 
)    ((x) != NULL ? (x) : (r))

Definition at line 81 of file macros.h.

◆ TRUE

#define TRUE   1

Definition at line 157 of file macros.h.

◆ WAIT_HANG

#define WAIT_HANG (   pid,
  stat 
)    waitpid(pid, stat, 0)

Definition at line 31 of file macros.h.

◆ WAIT_NOHANG

#define WAIT_NOHANG (   pid,
  stat 
)    waitpid(pid, stat, WNOHANG)

Definition at line 30 of file macros.h.

◆ WEEKS

#define WEEKS   * 7 DAYS

Definition at line 146 of file macros.h.

◆ YEARS

#define YEARS   * 365 DAYS

Definition at line 148 of file macros.h.