Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
COMMONS: macros, headers, defines, timers, allocators,...

Macros

#define __EXTENSIONS__
 set windows if true
 
#define __n_assert(__ptr, __ret)
 macro to assert things
 
#define _nstr(__PTR)   ((__PTR && __PTR->data) ? (__PTR->data) : "NULL")
 N_STR or "NULL" string for logging purposes.
 
#define _nstrp(__PTR)   ((__PTR && __PTR->data) ? (__PTR->data) : NULL)
 N_STR or NULL pointer for testing purposes.
 
#define _str(__PTR)   ((__PTR) ? (__PTR) : "NULL")
 define true
 
#define _strp(__PTR)   ((__PTR) ? (__PTR) : NULL)
 String or NULL pointer for testing purposes.
 
#define _strw(__PTR)   ((__PTR) ? (__PTR) : " ")
 String or " " string for config purposes.
 
#define Alloca(__ptr, __size)
 Malloca Handler to get errors and set to 0.
 
#define BYTEORDER_BIG_ENDIAN   1
 Big endian macro value.
 
#define BYTEORDER_LITTLE_ENDIAN   0
 Little endian macro value.
 
#define CALL_RETRY(__retvar, __expression, __max_tries, __delay)
 TEMP_FAILURE gnu macro portable version.
 
#define checkerror()
 check for errors
 
#define CONCAT(a, b)   CONCAT_BUILDER(a, b)
 Concatenate two macro.
 
#define CONCAT_BUILDER(a, b)   a##b
 CONCAT macro helper.
 
#define DEFAULT   1000
 Default APP_STATUS Value.
 
#define endif
 close a ifwhatever block
 
#define equal_if(__a, __cond, __b)
 if( a , condition, b ) then a = b
 
#define FALL_THROUGH
 fall through macro for switch cases, avoid warning at compilation
 
#define FORCE_INLINE   static inline __attribute__((always_inline))
 FORCE_INLINE portable macro.
 
#define Free(__ptr)
 Free Handler to get errors.
 
#define FreeNoLog(__ptr)
 Free Handler without log.
 
#define GET   4321
 Flag for GET something , passing as a function parameter.
 
#define get_error()    (___error__check_flag == TRUE)
 pop up errors if any
 
#define htonll(x)   (x)
 htonl for 64 bits numbers
 
#define iffalse   if( FALSE ==
 error checker type if( toto == FALSE )

 
#define ifnull   if( !
 error checker type if( !toto )
 
#define iftrue   if( TRUE ==
 error checker type if( toto == FALSE )

 
#define ifzero   if( 0 ==
 error checker type if( 0 != toto )
 
#define init_error_check()    static int ___error__check_flag = FALSE;
 init error checking in a function
 
#define init_lock(__rwlock_mutex)
 Macro for initializing a rwlock.
 
#define Malloc(__ptr, __struct, __size)
 Malloc Handler to get errors and set to 0.
 
#define N_DAEMON_NO_CHDIR   64
 daemonize flag: do not call chdir("/")
 
#define N_DAEMON_NO_CLOSE   2
 daemonize flag: no descriptor close at all
 
#define N_DAEMON_NO_DOUBLE_FORK   8
 daemonize flag: do not double fork
 
#define N_DAEMON_NO_SETSID   16
 daemonize flag: do not call setsid
 
#define N_DAEMON_NO_SIGCHLD_HANDLER   256
 daemonize flag: do not use internal zombie SIGCHLD handler
 
#define N_DAEMON_NO_SIGCHLD_IGN   128
 daemonize flag: do not ignore SIGCHLD
 
#define N_DAEMON_NO_STD_REDIRECT   4
 daemonize flag: just do not redirect stdin/out/err to /dev/null
 
#define N_DAEMON_NO_UMASK   32
 daemonize flag: do not call umask( 0 )
 
#define next_even(__val)   ((__val) % 2 == 0) ? (__val + 1) : (__val)
 next odd helper
 
#define next_odd(__val)   ((__val) % 2 == 0) ? (__val) : (__val + 1)
 next odd helper
 
#define ntohll(x)   (x)
 ntonl for 64 bits numbers
 
#define PAUSED   1004
 Value of the state of an application who is paused.
 
#define randomize()
 Initialize the random sequence with time.
 
#define read_lock(__rwlock_mutex)
 Macro for acquiring a read lock on a rwlock mutex.
 
#define Realloc(__ptr, __struct, __size)
 Realloc Handler to get errors.
 
#define Reallocz(__ptr, __struct, __old_size, __size)
 Realloc + zero new memory zone Handler to get errors.
 
#define RUNNING   1001
 Value of the state of an application who is running.
 
#define rw_lock_destroy(__rwlock_mutex)
 Macro to destroy rwlock mutex.
 
#define RWLOCK_LOGLEVEL   LOG_NULL
 flag to tell the API to disable DEBUG log on locks
 
#define SET   1234
 Flag for SET something , passing as a function parameter.
 
#define STOPPED   1003
 Value of the state of an application who is stopped.
 
#define STOPWANTED   1002
 Value of the state of an application who want to stop his activity.
 
#define unlock(__rwlock_mutex)
 Macro for releasing read/write lock a rwlock mutex.
 
#define write_lock(__rwlock_mutex)
 Macro for acquiring a write lock on a rwlock mutex.
 

Functions

int file_exist (const char *filename)
 test if file exist and if it's readable
 
int get_computer_name (char *computer_name, size_t len)
 abort program with a text
 
char * get_prog_dir (void)
 get current program running directory
 
char * get_prog_name (void)
 get current program name
 
void log_environment (int loglevel)
 log environment variables in syslog
 
void n_abort (char const *format,...)
 abort program with a text
 
int n_daemonize (void)
 Daemonize program.
 
int n_daemonize_ex (int mode)
 Daemonize program.
 
char * n_get_file_extension (char path[])
 get extension of path+filename
 
void N_HIDE_STR (char *buf,...)
 store a hidden version of a string
 
int n_popen (char *cmd, size_t read_buf_size, void **nstr_output, int *ret)
 
void sigchld_handler (int sig)
 Handles SIGCHLD issues when forking.
 
int sigchld_handler_installer ()
 install signal SIGCHLD handler to reap zombie processes
 
pid_t system_nb (const char *command, int *infp, int *outfp)
 Non blocking system call.
 

Detailed Description

Macro Definition Documentation

◆ __EXTENSIONS__

#define __EXTENSIONS__

set windows if true

feature test macro

Definition at line 48 of file n_common.h.

◆ __n_assert

#define __n_assert (   __ptr,
  __ret 
)
Value:
if (!(__ptr)) { \
n_log(LOG_DEBUG, "if( !(%s) ) assert at line %d of %s", #__ptr, __LINE__, __FILE__); \
__ret; \
}
#define LOG_DEBUG
debug-level messages
Definition n_log.h:64

macro to assert things

Examples
ex_common.c, ex_fluid_config.c, ex_list.c, ex_network_ssl.c, and ex_threads.c.

Definition at line 258 of file n_common.h.

◆ _nstr

#define _nstr (   __PTR)    ((__PTR && __PTR->data) ? (__PTR->data) : "NULL")

N_STR or "NULL" string for logging purposes.

Examples
ex_base64.c, ex_common.c, ex_crypto.c, ex_fluid.c, ex_hash.c, ex_monolith.c, ex_network_ssl.c, and ex_nstr.c.

Definition at line 182 of file n_common.h.

◆ _nstrp

#define _nstrp (   __PTR)    ((__PTR && __PTR->data) ? (__PTR->data) : NULL)

N_STR or NULL pointer for testing purposes.

Examples
ex_common.c.

Definition at line 184 of file n_common.h.

◆ _str

#define _str (   __PTR)    ((__PTR) ? (__PTR) : "NULL")

define true

define TRUE

define false

define FALSE

returned by N_STRLIST functions to tell the caller that the list is empty

String or "NULL" string for logging purposes

Examples
ex_common.c, ex_fluid.c, ex_gui_dictionary.c, ex_hash.c, ex_network.c, and ex_network_ssl.c.

Definition at line 176 of file n_common.h.

◆ _strp

#define _strp (   __PTR)    ((__PTR) ? (__PTR) : NULL)

String or NULL pointer for testing purposes.

Definition at line 178 of file n_common.h.

◆ _strw

#define _strw (   __PTR)    ((__PTR) ? (__PTR) : " ")

String or " " string for config purposes.

Definition at line 180 of file n_common.h.

◆ Alloca

#define Alloca (   __ptr,
  __size 
)
Value:
{ \
int __n_errno = 0; \
errno = 0; \
__ptr = alloca(__size); \
__n_errno = errno; \
if (!__ptr) { \
n_log(LOG_ERR, "%s=alloca( %d ) %s at line %d of %s \n", #__ptr, __size, (__n_errno == 0) ? "alloca error" : strerror(__n_errno), __LINE__, __FILE__); \
} else { \
memset(__ptr, 0, __size); \
} \
}
#define LOG_ERR
error conditions
Definition n_log.h:56

Malloca Handler to get errors and set to 0.

Examples
ex_common.c, and ex_network_ssl.c.

Definition at line 199 of file n_common.h.

◆ BYTEORDER_BIG_ENDIAN

#define BYTEORDER_BIG_ENDIAN   1

Big endian macro value.

Definition at line 84 of file n_common.h.

◆ BYTEORDER_LITTLE_ENDIAN

#define BYTEORDER_LITTLE_ENDIAN   0

Little endian macro value.

Definition at line 82 of file n_common.h.

◆ CALL_RETRY

#define CALL_RETRY (   __retvar,
  __expression,
  __max_tries,
  __delay 
)
Value:
({ \
int __nb_retries = 0; \
do { \
__retvar = (__expression); \
__nb_retries++; \
if (__retvar == -1 && errno == EINTR && __nb_retries < __max_tries) \
usleep(__delay); \
} while (__retvar == -1 && errno == EINTR && __nb_retries < __max_tries); \
__nb_retries; \
})

TEMP_FAILURE gnu macro portable version.

Definition at line 265 of file n_common.h.

◆ checkerror

#define checkerror ( )
Value:
if (___error__check_flag == TRUE) { \
n_log(LOG_ERR, "checkerror return false at line %d of %s", __LINE__, __FILE__); \
goto error; \
}

check for errors

Examples
ex_common.c.

Definition at line 299 of file n_common.h.

◆ CONCAT

#define CONCAT (   a,
 
)    CONCAT_BUILDER(a, b)

Concatenate two macro.

Definition at line 437 of file n_common.h.

◆ CONCAT_BUILDER

#define CONCAT_BUILDER (   a,
 
)    a##b

CONCAT macro helper.

Definition at line 435 of file n_common.h.

◆ DEFAULT

#define DEFAULT   1000

Default APP_STATUS Value.

Definition at line 408 of file n_common.h.

◆ endif

#define endif
Value:
){ \
___error__check_flag = TRUE; \
n_log(LOG_ERR, "First err was at line %d of %s", __LINE__, __FILE__); \
}

close a ifwhatever block

Examples
ex_common.c.

Definition at line 306 of file n_common.h.

◆ equal_if

#define equal_if (   __a,
  __cond,
  __b 
)
Value:
if ((__a)__cond(__b)) { \
__a = __b; \
}

if( a , condition, b ) then a = b

Definition at line 316 of file n_common.h.

◆ FALL_THROUGH

#define FALL_THROUGH
Value:
/* fall through */ \
((void)0)

fall through macro for switch cases, avoid warning at compilation

Definition at line 55 of file n_common.h.

◆ FORCE_INLINE

#define FORCE_INLINE   static inline __attribute__((always_inline))

FORCE_INLINE portable macro.

Examples
ex_common.c.

Definition at line 147 of file n_common.h.

◆ Free

#define Free (   __ptr)
Value:
if (__ptr) { \
free(__ptr); \
__ptr = NULL; \
} else { \
n_log(LOG_DEBUG, "Free( %s ) already done or NULL at line %d of %s \n", #__ptr, __LINE__, __FILE__); \
}

Free Handler to get errors.

Examples
ex_common.c, ex_fluid.c, ex_hash.c, ex_log.c, ex_network_ssl.c, and ex_nstr.c.

Definition at line 242 of file n_common.h.

◆ FreeNoLog

#define FreeNoLog (   __ptr)
Value:
if (__ptr) { \
free(__ptr); \
__ptr = NULL; \
}

Free Handler without log.

Examples
ex_common.c, ex_gui_dictionary.c, and ex_network.c.

Definition at line 251 of file n_common.h.

◆ GET

#define GET   4321

Flag for GET something , passing as a function parameter.

Definition at line 406 of file n_common.h.

◆ get_error

#define get_error ( )     (___error__check_flag == TRUE)

pop up errors if any

Examples
ex_common.c.

Definition at line 312 of file n_common.h.

◆ htonll

#define htonll (   x)    (x)

htonl for 64 bits numbers

Definition at line 441 of file n_common.h.

◆ iffalse

#define iffalse   if( FALSE ==

error checker type if( toto == FALSE )

Examples
ex_common.c.

Definition at line 293 of file n_common.h.

◆ ifnull

#define ifnull   if( !

error checker type if( !toto )

Examples
ex_common.c.

Definition at line 287 of file n_common.h.

◆ iftrue

#define iftrue   if( TRUE ==

error checker type if( toto == FALSE )

Examples
ex_common.c.

Definition at line 296 of file n_common.h.

◆ ifzero

#define ifzero   if( 0 ==

error checker type if( 0 != toto )

Examples
ex_common.c.

Definition at line 290 of file n_common.h.

◆ init_error_check

#define init_error_check ( )     static int ___error__check_flag = FALSE;

init error checking in a function

Examples
ex_common.c.

Definition at line 283 of file n_common.h.

◆ init_lock

#define init_lock (   __rwlock_mutex)
Value:
({ \
pthread_rwlockattr_t __attr; \
pthread_rwlockattr_init(&__attr); \
int __ret = 0; \
do { \
n_log(RWLOCK_LOGLEVEL, "init_lock %s", #__rwlock_mutex); \
__rwlock_mutex = (pthread_rwlock_t)PTHREAD_RWLOCK_INITIALIZER; \
__ret = pthread_rwlock_init(&(__rwlock_mutex), &__attr); \
if (__ret != 0) { \
n_log(LOG_ERR, "Error %s while initializing %s at %s:%s:%d", strerror(__ret), #__rwlock_mutex, __FILE__, __func__, __LINE__); \
} \
pthread_rwlockattr_destroy(&__attr); \
} while (0); \
__ret; \
})
#define RWLOCK_LOGLEVEL
flag to tell the API to disable DEBUG log on locks
Definition n_common.h:327

Macro for initializing a rwlock.

Definition at line 331 of file n_common.h.

◆ Malloc

#define Malloc (   __ptr,
  __struct,
  __size 
)
Value:
{ \
int __n_errno = 0; \
errno = 0; \
__ptr = (__struct*)calloc(__size, sizeof(__struct)); \
__n_errno = errno; \
if (!__ptr) { \
n_log(LOG_ERR, "( %s *)calloc( %ld , sizeof( %s ) ) %s at line %d of %s \n", #__ptr, __size, #__struct, (__n_errno == 0) ? "malloc error" : strerror(__n_errno), __LINE__, __FILE__); \
} \
}

Malloc Handler to get errors and set to 0.

Examples
ex_common.c, ex_fluid.c, ex_gui_dictionary.c, ex_hash.c, and ex_network_ssl.c.

Definition at line 187 of file n_common.h.

◆ N_DAEMON_NO_CHDIR

#define N_DAEMON_NO_CHDIR   64

daemonize flag: do not call chdir("/")

Definition at line 487 of file n_common.h.

◆ N_DAEMON_NO_CLOSE

#define N_DAEMON_NO_CLOSE   2

daemonize flag: no descriptor close at all

Definition at line 477 of file n_common.h.

◆ N_DAEMON_NO_DOUBLE_FORK

#define N_DAEMON_NO_DOUBLE_FORK   8

daemonize flag: do not double fork

Definition at line 481 of file n_common.h.

◆ N_DAEMON_NO_SETSID

#define N_DAEMON_NO_SETSID   16

daemonize flag: do not call setsid

Definition at line 483 of file n_common.h.

◆ N_DAEMON_NO_SIGCHLD_HANDLER

#define N_DAEMON_NO_SIGCHLD_HANDLER   256

daemonize flag: do not use internal zombie SIGCHLD handler

Definition at line 491 of file n_common.h.

◆ N_DAEMON_NO_SIGCHLD_IGN

#define N_DAEMON_NO_SIGCHLD_IGN   128

daemonize flag: do not ignore SIGCHLD

Definition at line 489 of file n_common.h.

◆ N_DAEMON_NO_STD_REDIRECT

#define N_DAEMON_NO_STD_REDIRECT   4

daemonize flag: just do not redirect stdin/out/err to /dev/null

Definition at line 479 of file n_common.h.

◆ N_DAEMON_NO_UMASK

#define N_DAEMON_NO_UMASK   32

daemonize flag: do not call umask( 0 )

Definition at line 485 of file n_common.h.

◆ next_even

#define next_even (   __val)    ((__val) % 2 == 0) ? (__val + 1) : (__val)

next odd helper

Examples
ex_common.c.

Definition at line 280 of file n_common.h.

◆ next_odd

#define next_odd (   __val)    ((__val) % 2 == 0) ? (__val) : (__val + 1)

next odd helper

Examples
ex_common.c.

Definition at line 277 of file n_common.h.

◆ ntohll

#define ntohll (   x)    (x)

ntonl for 64 bits numbers

Definition at line 443 of file n_common.h.

◆ PAUSED

#define PAUSED   1004

Value of the state of an application who is paused.

Definition at line 416 of file n_common.h.

◆ randomize

#define randomize ( )
Value:
{ \
srand((unsigned)time(NULL)); \
rand(); \
}

Initialize the random sequence with time.

Definition at line 419 of file n_common.h.

◆ read_lock

#define read_lock (   __rwlock_mutex)
Value:
({ \
int __ret = 0; \
do { \
n_log(RWLOCK_LOGLEVEL, "read lock %s", #__rwlock_mutex); \
__ret = pthread_rwlock_rdlock(&(__rwlock_mutex)); \
if (__ret != 0) { \
n_log(LOG_ERR, "Error %s while read locking %s at %s:%s:%d", strerror(__ret), #__rwlock_mutex, __FILE__, __func__, __LINE__); \
} \
} while (0); \
__ret; \
})

Macro for acquiring a read lock on a rwlock mutex.

Definition at line 349 of file n_common.h.

◆ Realloc

#define Realloc (   __ptr,
  __struct,
  __size 
)
Value:
{ \
int __n_errno = 0; \
errno = 0; \
void* __new_ptr = (__struct*)realloc(__ptr, __size * sizeof(__struct)); \
__n_errno = errno; \
if (!__new_ptr) { \
n_log(LOG_ERR, "( %s *)realloc( %s * sizeof( %d ) ) %s at line %d of %s \n", #__ptr, #__struct, __size, (__n_errno == 0) ? "realloc error" : strerror(__n_errno), __LINE__, __FILE__); \
} else { \
__ptr = __new_ptr; \
} \
}

Realloc Handler to get errors.

Examples
ex_common.c.

Definition at line 213 of file n_common.h.

◆ Reallocz

#define Reallocz (   __ptr,
  __struct,
  __old_size,
  __size 
)
Value:
{ \
int __n_errno = 0; \
errno = 0; \
void* __new_ptr = (__struct*)realloc(__ptr, __size); \
__n_errno = errno; \
if (!__new_ptr) { \
n_log(LOG_ERR, "( %s *)realloc( %s * sizeof( %d ) ) %s at line %d of %s \n", #__ptr, #__struct, __size, (__n_errno == 0) ? "realloc error" : strerror(__n_errno), __LINE__, __FILE__); \
} else { \
__ptr = __new_ptr; \
if (__size > __old_size) memset((__ptr + __old_size), 0, __size - __old_size); \
} \
}

Realloc + zero new memory zone Handler to get errors.

Examples
ex_common.c.

Definition at line 227 of file n_common.h.

◆ RUNNING

#define RUNNING   1001

Value of the state of an application who is running.

Definition at line 410 of file n_common.h.

◆ rw_lock_destroy

#define rw_lock_destroy (   __rwlock_mutex)
Value:
({ \
int __ret = 0; \
do { \
n_log(RWLOCK_LOGLEVEL, "destroy lock %s", #__rwlock_mutex); \
__ret = pthread_rwlock_destroy(&(__rwlock_mutex)); \
if (__ret != 0) { \
n_log(LOG_ERR, "Error %s while destroying %s at %s:%s:%d", strerror(__ret), #__rwlock_mutex, __FILE__, __func__, __LINE__); \
} \
} while (0); \
__ret; \
})

Macro to destroy rwlock mutex.

Definition at line 390 of file n_common.h.

◆ RWLOCK_LOGLEVEL

#define RWLOCK_LOGLEVEL   LOG_NULL

flag to tell the API to disable DEBUG log on locks

Definition at line 327 of file n_common.h.

◆ SET

#define SET   1234

Flag for SET something , passing as a function parameter.

Definition at line 404 of file n_common.h.

◆ STOPPED

#define STOPPED   1003

Value of the state of an application who is stopped.

Definition at line 414 of file n_common.h.

◆ STOPWANTED

#define STOPWANTED   1002

Value of the state of an application who want to stop his activity.

Definition at line 412 of file n_common.h.

◆ unlock

#define unlock (   __rwlock_mutex)
Value:
({ \
int __ret = 0; \
do { \
n_log(RWLOCK_LOGLEVEL, "unlock lock %s", #__rwlock_mutex); \
__ret = pthread_rwlock_unlock(&(__rwlock_mutex)); \
if (__ret != 0) { \
n_log(LOG_ERR, "Error %s while unlocking %s at %s:%s:%d", strerror(__ret), #__rwlock_mutex, __FILE__, __func__, __LINE__); \
} \
} while (0); \
__ret; \
})

Macro for releasing read/write lock a rwlock mutex.

Definition at line 377 of file n_common.h.

◆ write_lock

#define write_lock (   __rwlock_mutex)
Value:
({ \
int __ret = 0; \
do { \
n_log(RWLOCK_LOGLEVEL, "write lock %s", #__rwlock_mutex); \
__ret = pthread_rwlock_wrlock(&(__rwlock_mutex)); \
if (__ret != 0) { \
n_log(LOG_ERR, "Error %s while write locking %s at %s:%s:%d", strerror(__ret), #__rwlock_mutex, __FILE__, __func__, __LINE__); \
} \
} while (0); \
__ret; \
})

Macro for acquiring a write lock on a rwlock mutex.

Definition at line 363 of file n_common.h.

Function Documentation

◆ file_exist()

int file_exist ( const char *  filename)

test if file exist and if it's readable

Parameters
filenamePath/name of the file
Returns
TRUE or FALSE

Definition at line 82 of file n_common.c.

◆ get_computer_name()

int get_computer_name ( char *  computer_name,
size_t  len 
)

abort program with a text

Parameters
computer_nameallocated buffer to hold the computer name
lensize of computer_name variable
Returns
TRUE or FALSE

Definition at line 55 of file n_common.c.

References LOG_ERR, and n_log.

Referenced by n_kafka_load_config().

+ Here is the caller graph for this function:

◆ get_prog_dir()

char * get_prog_dir ( void  )

get current program running directory

Returns
A copy of the current program running directory inside a string

Definition at line 95 of file n_common.c.

◆ get_prog_name()

char * get_prog_name ( void  )

get current program name

Returns
A copy of the current program name inside a string

Definition at line 127 of file n_common.c.

◆ log_environment()

void log_environment ( int  loglevel)

log environment variables in syslog

Parameters
loglevelthe loglevel used to log the environment

Definition at line 243 of file n_common.c.

References n_log.

◆ n_abort()

void n_abort ( char const *  format,
  ... 
)

abort program with a text

Parameters
formatprintf style format and args

Definition at line 38 of file n_common.c.

◆ n_daemonize()

int n_daemonize ( void  )

Daemonize program.

Returns
TRUE or FALSE

Definition at line 254 of file n_common.c.

References N_DAEMON_NO_SIGCHLD_HANDLER, N_DAEMON_NO_SIGCHLD_IGN, and n_daemonize_ex().

+ Here is the call graph for this function:

◆ n_daemonize_ex()

int n_daemonize_ex ( int  mode)

Daemonize program.

Parameters
modeflag made of a combination of N_DAEMON_NO_CLOSE, N_DAEMON_NO_STD_REDIRECT, N_DAEMON_NO_DOUBLE_FORK , N_DAEMON_NO_SETSID, N_DAEMON_NO_UMASK, N_DAEMON_NO_CHDIR, N_DAEMON_NO_SETSID, N_DAEMON_NO_SIGCHLD_IGN, N_DAEMON_NO_SIGCHLD_HANDLER or 0 for defaults
Returns
TRUE or FALSE

Definition at line 263 of file n_common.c.

References LOG_ERR, LOG_NOTICE, N_DAEMON_NO_CHDIR, N_DAEMON_NO_CLOSE, N_DAEMON_NO_DOUBLE_FORK, N_DAEMON_NO_SETSID, N_DAEMON_NO_SIGCHLD_HANDLER, N_DAEMON_NO_SIGCHLD_IGN, N_DAEMON_NO_STD_REDIRECT, N_DAEMON_NO_UMASK, n_log, and sigchld_handler_installer().

Referenced by n_daemonize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_get_file_extension()

char * n_get_file_extension ( char  path[])

get extension of path+filename

Parameters
paththe path + filename
Returns
a pointer to the first extension character or NULL

Definition at line 450 of file n_common.c.

References __n_assert.

◆ N_HIDE_STR()

void N_HIDE_STR ( char *  buf,
  ... 
)

store a hidden version of a string

Parameters
bufthe variable which will receive the string

Definition at line 429 of file n_common.c.

◆ n_popen()

int n_popen ( char *  cmd,
size_t  read_buf_size,
void **  nstr_output,
int *  ret 
)

Definition at line 162 of file n_common.c.

◆ sigchld_handler()

void sigchld_handler ( int  sig)

Handles SIGCHLD issues when forking.

Parameters
sigsignal type handle

Definition at line 212 of file n_common.c.

References LOG_DEBUG, and n_log.

Referenced by sigchld_handler_installer().

+ Here is the caller graph for this function:

◆ sigchld_handler_installer()

int sigchld_handler_installer ( )

install signal SIGCHLD handler to reap zombie processes

Returns
TRUE or FALSE

Definition at line 226 of file n_common.c.

References LOG_ERR, n_log, and sigchld_handler().

Referenced by n_daemonize_ex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ system_nb()

pid_t system_nb ( const char *  command,
int *  infp,
int *  outfp 
)

Non blocking system call.

Parameters
commandto call
infpstdin file descriptor holder or NULL
outfpstdout file descriptor holder or NULL
Returns
The system command pid or -1

Definition at line 361 of file n_common.c.

References __n_assert, LOG_ERR, and n_log.