summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2008-12-21 17:09:49 +0100
committerAndreas Baumann <abaumann@yahoo.com>2008-12-21 17:09:49 +0100
commit07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976 (patch)
treed99410ede29d8f09f35351cc1beeb0866082ae57 /src
parent01e67d010b9badcf2ffc65d74b0f9285f26d45e5 (diff)
downloadwolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.gz
wolfbones-07bbb6aa8857a2fbc77d6db6b6d1e7bafb7d0976.tar.bz2
making log a little bit less leaking Unixisms
Diffstat (limited to 'src')
-rw-r--r--src/daemon/daemon.c86
-rw-r--r--src/daemon/pidfile.c44
-rw-r--r--src/daemon/signals.c24
-rw-r--r--src/log.c115
-rw-r--r--src/log.h60
-rw-r--r--src/port/limits.h2
-rw-r--r--src/port/lockf.h2
-rw-r--r--src/port/snprintf.h2
-rw-r--r--src/port/stdbool.h35
-rw-r--r--src/port/stdint.h2
-rw-r--r--src/port/stdio.h2
-rw-r--r--src/port/string.h2
-rw-r--r--src/port/sys.h119
-rw-r--r--src/port/unistd.h2
-rw-r--r--src/port/unused.h8
15 files changed, 165 insertions, 340 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index f3a9e1c..bbc554c 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -75,7 +75,7 @@ static error_t close_fd( int fd ) {
break;
default:
- LOG( LOG_EMERG, "Error while closing file descriptor %d: %s (%d)",
+ LOG( log_EMERG, "Error while closing file descriptor %d: %s (%d)",
fd, strerror( errno ), errno );
return ERR_INTERNAL;
}
@@ -102,11 +102,11 @@ static error_t daemon_close_all_fds( void ) {
nof_files = sysconf( _SC_OPEN_MAX );
if( nof_files < 0 ) {
- LOG( LOG_EMERG, "Unable to retrieve maximal number of files: %s (%d)",
+ LOG( log_EMERG, "Unable to retrieve maximal number of files: %s (%d)",
strerror( errno ), errno );
return ERR_INTERNAL;
}
- LOG( LOG_DEBUG, "Closing all filedescriptors up to %ld", nof_files );
+ LOG( log_DEBUG, "Closing all filedescriptors up to %ld", nof_files );
for( i = 0; i < nof_files; i++ ) {
if( ( i == STDIN_FILENO ) ||
@@ -131,12 +131,12 @@ static error_t open_null_fd( int must_fd, int flags ) {
fd = open( "/dev/null", flags );
if( fd < 0 ) {
- LOG( LOG_EMERG, "Unable to open fd %d as /dev/null: %s (%d)",
+ LOG( log_EMERG, "Unable to open fd %d as /dev/null: %s (%d)",
must_fd, strerror( errno ), errno );
return ERR_INTERNAL;
}
if( fd != must_fd ) {
- LOG( LOG_EMERG, "Something is wrong with the file descriptors (expecting %d,got %d)!",
+ LOG( log_EMERG, "Something is wrong with the file descriptors (expecting %d,got %d)!",
must_fd, fd );
return ERR_PROGRAMMING;
}
@@ -151,10 +151,10 @@ atomar_write_again:
res = write( fd, data, data_len );
if( res < 0 ) {
if( errno == EINTR ) goto atomar_write_again;
- LOG( LOG_EMERG, "Error in atomar write to fd %d: %s (%d)",
+ LOG( log_EMERG, "Error in atomar write to fd %d: %s (%d)",
fd, strerror( errno ), errno );
} else if( (size_t)res != data_len ) {
- LOG( LOG_EMERG, "Unexpected number of octets %zd in atomar write to fd %d (expected %zd)",
+ LOG( log_EMERG, "Unexpected number of octets %zd in atomar write to fd %d (expected %zd)",
res, fd, data_len );
}
}
@@ -166,10 +166,10 @@ atomar_read_again:
res = read( fd, data, data_len );
if( res < 0 ) {
if( errno == EINTR ) goto atomar_read_again;
- LOG( LOG_EMERG, "Error in atmoar read from fd %d: %s (%d)",
+ LOG( log_EMERG, "Error in atmoar read from fd %d: %s (%d)",
fd, strerror( errno ), errno );
} else if( (size_t)res != data_len ) {
- LOG( LOG_EMERG, "Unexpected number of octets %zd in atomar read from fd %d (expected %zd)",
+ LOG( log_EMERG, "Unexpected number of octets %zd in atomar read from fd %d (expected %zd)",
res, fd, data_len );
}
}
@@ -185,7 +185,7 @@ error_t daemon_start( daemon_p d ) {
* error..
*/
if( getppid( ) == 1 ) {
- LOG( LOG_EMERG, "Already running as daemon!" );
+ LOG( log_EMERG, "Already running as daemon!" );
return( d->error = ERR_PROGRAMMING );
}
@@ -196,7 +196,7 @@ error_t daemon_start( daemon_p d ) {
* we must be root (uid 0 by convention) for that.
*/
if( geteuid( ) != 0 ) {
- LOG( LOG_EMERG, "Unable to start daemon as not root user!" );
+ LOG( log_EMERG, "Unable to start daemon as not root user!" );
return( d->error = ERR_INVALID_STATE );
}
@@ -221,11 +221,11 @@ error_t daemon_start( daemon_p d ) {
* itself back to the grand-parent (exit codes).
*/
if( pipe( exit_code_pipe ) < 0 ) {
- LOG( LOG_EMERG, "Unable to create exit code pipe: %s (%d)",
+ LOG( log_EMERG, "Unable to create exit code pipe: %s (%d)",
strerror( errno ), errno );
return ( d->error = ERR_INTERNAL );
}
- LOG( LOG_DEBUG, "Created exit code pipe (%d,%d)", exit_code_pipe[0], exit_code_pipe[1] );
+ LOG( log_DEBUG, "Created exit code pipe (%d,%d)", exit_code_pipe[0], exit_code_pipe[1] );
/* first fork: make sure we are no longer process group leader.
* So we can get our own process group leader by calling setsid
@@ -233,12 +233,12 @@ error_t daemon_start( daemon_p d ) {
switch( ( pid = fork( ) ) ) {
case -1:
/* error */
- LOG( LOG_EMERG, "Unable to fork the first time: %s", strerror( errno ) );
+ LOG( log_EMERG, "Unable to fork the first time: %s", strerror( errno ) );
return ( d->error = ERR_INTERNAL );
case 0:
/* the child becomes the daemon */
- LOG( LOG_DEBUG, "First fork reached" );
+ LOG( log_DEBUG, "First fork reached" );
break;
default:
@@ -248,7 +248,7 @@ error_t daemon_start( daemon_p d ) {
/* TODO: wait for some time for correct exit
* code from the error pipe
*/
- LOG( LOG_DEBUG, "Parent after first fork: child is %d", pid );
+ LOG( log_DEBUG, "Parent after first fork: child is %d", pid );
return ( d->error = TERMINATE_EXIT_CODE );
}
@@ -256,11 +256,11 @@ error_t daemon_start( daemon_p d ) {
* (for termination and cleanup which can only be done as root)
*/
if( pipe( daemon_parent_pipe ) < 0 ) {
- LOG( LOG_EMERG, "Unable to create parent pipe: %s (%d)",
+ LOG( log_EMERG, "Unable to create parent pipe: %s (%d)",
strerror( errno ), errno );
return ( d->error = ERR_INTERNAL );
}
- LOG( LOG_DEBUG, "Created parent pipe (%d,%d)", daemon_parent_pipe[0], daemon_parent_pipe[1] );
+ LOG( log_DEBUG, "Created parent pipe (%d,%d)", daemon_parent_pipe[0], daemon_parent_pipe[1] );
/* Put the first child in it's own process group and finally detach it
* from its controlling terminal. This ensure we don't get funny
@@ -268,7 +268,7 @@ error_t daemon_start( daemon_p d ) {
*/
if( setsid( ) < 0 ) {
/* should actually never fail */
- LOG( LOG_EMERG, "Starting new process group session for the parent of the daemon failed: %s", strerror( errno ) );
+ LOG( log_EMERG, "Starting new process group session for the parent of the daemon failed: %s", strerror( errno ) );
return ERR_INTERNAL;
}
@@ -295,17 +295,17 @@ error_t daemon_start( daemon_p d ) {
switch( ( pid = fork( ) ) ) {
case -1:
/* error */
- LOG( LOG_EMERG, "Unable to fork the second time: %s", strerror( errno ) );
+ LOG( log_EMERG, "Unable to fork the second time: %s", strerror( errno ) );
return ( d->error = ERR_INTERNAL );
case 0:
/* the child becomes the daemon */
- LOG( LOG_DEBUG, "Second fork reached" );
+ LOG( log_DEBUG, "Second fork reached" );
break;
default:
(void)signal_install_handlers_parent( );
- LOG( LOG_DEBUG, "Parent after second fork: child (and daemon) is %d", pid );
+ LOG( log_DEBUG, "Parent after second fork: child (and daemon) is %d", pid );
return ( d->error = TERMINATE_PARENT );
}
@@ -321,7 +321,7 @@ error_t daemon_start( daemon_p d ) {
*/
if( setsid( ) < 0 ) {
/* should actually never fail */
- LOG( LOG_EMERG, "Starting new process group for daemon session failed: %s", strerror( errno ) );
+ LOG( log_EMERG, "Starting new process group for daemon session failed: %s", strerror( errno ) );
return ERR_INTERNAL;
}
@@ -334,10 +334,10 @@ error_t daemon_start( daemon_p d ) {
* directory (especially they can't write files there)
*/
if( chdir( "/" ) < 0 ) {
- LOG( LOG_EMERG, "Changing to root diretory failed: %s", strerror( errno ) );
+ LOG( log_EMERG, "Changing to root diretory failed: %s", strerror( errno ) );
return ERR_INTERNAL;
}
- LOG( LOG_DEBUG, "Changed to root directory /" );
+ LOG( log_DEBUG, "Changed to root directory /" );
/* Change the umask to 0133 temporarily so we don't have to
* chmod the logfiles, pidfiles later.
@@ -345,12 +345,12 @@ error_t daemon_start( daemon_p d ) {
* Create pid files with permissions 0644 (rw-r--r--)
*/
mode = umask( 0133 );
- LOG( LOG_DEBUG, "Switched umask from %04o to %04o", mode, 0133 );
+ LOG( log_DEBUG, "Switched umask from %04o to %04o", mode, 0133 );
/* check if another daemon is already running, if yes, bail out */
if( is_daemon_running( &d->pidfile, &pid, &error ) || ( error != OK ) ) {
if( error == OK ) {
- LOG( LOG_EMERG, "Another daemon is already running with pid '%d', can't start!", pid );
+ LOG( log_EMERG, "Another daemon is already running with pid '%d', can't start!", pid );
}
return ERR_INTERNAL;
}
@@ -386,7 +386,7 @@ error_t daemon_start( daemon_p d ) {
* New files always get the permission 640 (rw-r-----)
*/
mode = umask( 0137 );
- LOG( LOG_DEBUG, "Switched umask from %04o to %04o", mode, 0137 );
+ LOG( log_DEBUG, "Switched umask from %04o to %04o", mode, 0137 );
/* drop permissions to a non-priviledged user now */
if( ( d->params.group_name != NULL ) && ( d->params.user_name != NULL ) ) {
@@ -394,9 +394,9 @@ error_t daemon_start( daemon_p d ) {
d->groupent = getgrnam( d->params.group_name );
if( d->groupent == NULL ) {
if( errno == 0 ) {
- LOG( LOG_EMERG, "No group '%s' found", d->params.group_name );
+ LOG( log_EMERG, "No group '%s' found", d->params.group_name );
} else {
- LOG( LOG_EMERG, "Unable to retrieve group information for group '%s': %s (%d)",
+ LOG( log_EMERG, "Unable to retrieve group information for group '%s': %s (%d)",
d->params.group_name, strerror( errno ), errno );
}
return ERR_INTERNAL;
@@ -406,22 +406,22 @@ error_t daemon_start( daemon_p d ) {
d->userent = getpwnam( d->params.user_name );
if( d->userent == NULL ) {
if( errno == 0 ) {
- LOG( LOG_EMERG, "No user '%s' found", d->params.user_name );
+ LOG( log_EMERG, "No user '%s' found", d->params.user_name );
} else {
- LOG( LOG_EMERG, "Unable to retrieve user information for user '%s': %s (%d)",
+ LOG( log_EMERG, "Unable to retrieve user information for user '%s': %s (%d)",
d->params.user_name, strerror( errno ), errno );
}
return ERR_INTERNAL;
}
if( setgid( d->userent->pw_gid ) < 0 ) {
- LOG( LOG_EMERG, "Setting unprivileged group failed: %s (%d)",
+ LOG( log_EMERG, "Setting unprivileged group failed: %s (%d)",
strerror( errno ), errno );
return ERR_INTERNAL;
}
if( setuid( d->userent->pw_uid ) < 0 ) {
- LOG( LOG_EMERG, "Setting unprivileged user failed: %s (%d)",
+ LOG( log_EMERG, "Setting unprivileged user failed: %s (%d)",
strerror( errno ), errno );
return ERR_INTERNAL;
}
@@ -430,7 +430,7 @@ error_t daemon_start( daemon_p d ) {
/* TODO: also check the permissions of the home dir
* of the unpriviledged user */
- LOG( LOG_DEBUG, "Switched to user '%s' (%d) and group '%s' (%d)",
+ LOG( log_DEBUG, "Switched to user '%s' (%d) and group '%s' (%d)",
d->params.user_name, d->userent->pw_uid,
d->params.group_name, d->userent->pw_gid );
}
@@ -458,7 +458,7 @@ NORETURN void daemon_exit( daemon_p d ) {
int exit_code;
int pid_file_fd;
- LOG( LOG_DEBUG, "daemon_exit called with error %d", d->error );
+ LOG( log_DEBUG, "daemon_exit called with error %d", d->error );
switch( d->error ) {
case TERMINATE_EXIT_CODE:
@@ -466,11 +466,11 @@ NORETURN void daemon_exit( daemon_p d ) {
* so we can return the correct exit code to
* the calling script or shell
*/
- LOG( LOG_DEBUG, "Waiting on exit_code pipe for exit code" );
+ LOG( log_DEBUG, "Waiting on exit_code pipe for exit code" );
atomar_read( exit_code_pipe[0], &exit_code, sizeof( int ) );
- LOG( LOG_DEBUG, "Terminating grand-parent of daemon with code %d (PID: %lu)",
+ LOG( log_DEBUG, "Terminating grand-parent of daemon with code %d (PID: %lu)",
exit_code, getpid( ) );
signal_terminate( );
@@ -486,10 +486,10 @@ NORETURN void daemon_exit( daemon_p d ) {
*/
/* wait for termination signal */
- LOG( LOG_DEBUG, "Waiting on parent pipe for termination signal" );
+ LOG( log_DEBUG, "Waiting on parent pipe for termination signal" );
atomar_read( daemon_parent_pipe[0], &pid_file_fd, sizeof( int ) );
- LOG( LOG_DEBUG, "Parent got termination (pidfile fd: %d).. cleaning up now (PID: %lu)",
+ LOG( log_DEBUG, "Parent got termination (pidfile fd: %d).. cleaning up now (PID: %lu)",
pid_file_fd, getpid( ) );
/* we need root permissions for that! */
@@ -498,7 +498,7 @@ NORETURN void daemon_exit( daemon_p d ) {
signal_terminate( );
- LOG( LOG_DEBUG, "Terminating parent of daemon pid file fd %d (PID %lu)",
+ LOG( log_DEBUG, "Terminating parent of daemon pid file fd %d (PID %lu)",
pid_file_fd, getpid( ) );
/* exit code is irrelevant here.. */
@@ -515,7 +515,7 @@ NORETURN void daemon_exit( daemon_p d ) {
signal_terminate( );
- LOG( LOG_DEBUG, "Terminating daemon (PID: %lu)", getpid( ) );
+ LOG( log_DEBUG, "Terminating daemon (PID: %lu)", getpid( ) );
/* exit code is irrelevant here */
_exit( EXIT_SUCCESS );
@@ -539,7 +539,7 @@ NORETURN void daemon_exit( daemon_p d ) {
signal_terminate( );
- LOG( LOG_DEBUG, "Terminating daemon (PID: %lu)", getpid( ) );
+ LOG( log_DEBUG, "Terminating daemon (PID: %lu)", getpid( ) );
/* exit code is irrelevant here */
_exit( EXIT_SUCCESS );
diff --git a/src/daemon/pidfile.c b/src/daemon/pidfile.c
index 3c5f42a..53f81c9 100644
--- a/src/daemon/pidfile.c
+++ b/src/daemon/pidfile.c
@@ -53,12 +53,12 @@ bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error )
if( pidfile->fd < 0 ) {
if( errno == ENOENT ) {
/* this is good, pid file doesn't exist at all */
- LOG( LOG_DEBUG, "No pidfile '%s' found, daemon is not running", pidfile->filename );
+ LOG( log_DEBUG, "No pidfile '%s' found, daemon is not running", pidfile->filename );
(void)close( pidfile->fd );
*error = OK;
return pidfile->running;
} else {
- LOG( LOG_EMERG, "Unable to open pidfile '%s' for reading: %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to open pidfile '%s' for reading: %s", pidfile->filename, strerror( errno ) );
*error = ERR_INTERNAL;
return pidfile->running;
}
@@ -69,12 +69,12 @@ bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error )
if( res < 0 ) {
if( errno == EAGAIN ) {
/* another process locks the file already */
- LOG( LOG_DEBUG, "Another process locks the pidfile, daemon already running" );
+ LOG( log_DEBUG, "Another process locks the pidfile, daemon already running" );
*error = OK;
pidfile->locked = true;
pidfile->running = true;
} else {
- LOG( LOG_EMERG, "Unable to lock pidfile '%s': %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to lock pidfile '%s': %s", pidfile->filename, strerror( errno ) );
(void)close( pidfile->fd );
*error = ERR_INTERNAL;
pidfile->running = false;
@@ -87,7 +87,7 @@ bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error )
/* try to read the pid from the file */
bytes_read = read( pidfile->fd, buf, sizeof( buf ) - 1 );
if( bytes_read < 0 ) {
- LOG( LOG_EMERG, "Unable to read pid from pidfile '%s': %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to read pid from pidfile '%s': %s", pidfile->filename, strerror( errno ) );
(void)close( pidfile->fd );
*error = ERR_INTERNAL;
return pidfile->running;
@@ -103,12 +103,12 @@ bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error )
( end_ptr == NULL ) /* pre-condition for check for '\0'! */ ||
( end_ptr - buf < 1 ) /* too short */ ||
( *pid < 2 ) /* too small value */ ) {
- LOG( LOG_EMERG, "pidfile '%s' contains invalid data, can't read PID from it!", pidfile->filename );
+ LOG( log_EMERG, "pidfile '%s' contains invalid data, can't read PID from it!", pidfile->filename );
(void)close( pidfile->fd );
*error = ERR_INTERNAL;
return pidfile->running;
}
- LOG( LOG_DEBUG, "Found PID '%lu' in pidfile", *pid );
+ LOG( log_DEBUG, "Found PID '%lu' in pidfile", *pid );
/* the pid is valid, but is there a process with the pid actually running?
* (this handles the case of kill -9!)
@@ -117,18 +117,18 @@ bool is_daemon_running( struct pidfile_t *pidfile, pid_t *pid, error_t *error )
if( res < 0 ) {
if( errno == ESRCH ) {
/* this is fine, process doesn't exist with this PID */
- LOG( LOG_EMERG, "Found PID '%lu' in pidfile '%s', but no such process is running. Check and manually delete the pidfile!", *pid, pidfile->filename );
+ LOG( log_EMERG, "Found PID '%lu' in pidfile '%s', but no such process is running. Check and manually delete the pidfile!", *pid, pidfile->filename );
(void)close( pidfile->fd );
*error = ERR_INTERNAL;
return pidfile->running;
} else {
- LOG( LOG_EMERG, "Can't check if processor with PID '%lu' is alive: %s", *pid, strerror( errno ) );
+ LOG( log_EMERG, "Can't check if processor with PID '%lu' is alive: %s", *pid, strerror( errno ) );
(void)close( pidfile->fd );
*error = ERR_INTERNAL;
return pidfile->running;
}
}
- LOG( LOG_DEBUG, "A process with PID '%lu' is already running", *pid );
+ LOG( log_DEBUG, "A process with PID '%lu' is already running", *pid );
/* process successfuly signaled, so a process with this PID exists
* (worst case, we assume, it's the daemon)
@@ -146,7 +146,7 @@ error_t pidfile_create( struct pidfile_t *pidfile ) {
/* create or open pid file with correct permissions */
pidfile->fd = open( pidfile->filename, O_CREAT | O_WRONLY | O_EXCL, 0644 );
if( pidfile->fd < 0 ) {
- LOG( LOG_EMERG, "Unable to open pidfile '%s' for writing: %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to open pidfile '%s' for writing: %s", pidfile->filename, strerror( errno ) );
return ERR_INTERNAL;
}
@@ -157,12 +157,12 @@ error_t pidfile_create( struct pidfile_t *pidfile ) {
/* another process locks the file already, this should not happen, maybe a
* race between to daemons started in parallel?
*/
- LOG( LOG_EMERG, "Unable to lock pidfile '%s' after creation, daemon started in parallel?", pidfile->filename );
+ LOG( log_EMERG, "Unable to lock pidfile '%s' after creation, daemon started in parallel?", pidfile->filename );
(void)close( pidfile->fd );
(void)unlink( pidfile->filename );
return ERR_INVALID_STATE;
} else {
- LOG( LOG_EMERG, "Unable to lock pidfile '%s' after creation: %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to lock pidfile '%s' after creation: %s", pidfile->filename, strerror( errno ) );
(void)close( pidfile->fd );
(void)unlink( pidfile->filename );
return ERR_INTERNAL;
@@ -173,7 +173,7 @@ error_t pidfile_create( struct pidfile_t *pidfile ) {
* in the pid file
*/
if( ftruncate( pidfile->fd, (off_t)0 ) < 0 ) {
- LOG( LOG_EMERG, "Unable to truncate the pidfile '%s' before writing to it", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to truncate the pidfile '%s' before writing to it", pidfile->filename, strerror( errno ) );
(void)close( pidfile->fd );
(void)unlink( pidfile->filename );
return ERR_INTERNAL;
@@ -185,15 +185,15 @@ error_t pidfile_create( struct pidfile_t *pidfile ) {
snprintf( pid_string, 20, "%lu\n", (unsigned long)getpid( ) );
bytes_writen = write( pidfile->fd, pid_string, strlen( pid_string ) );
if( bytes_writen < 0 ) {
- LOG( LOG_EMERG, "Unable to write PID into the pidfile '%s': %s", pidfile->filename, strerror( errno ) );
+ LOG( log_EMERG, "Unable to write PID into the pidfile '%s': %s", pidfile->filename, strerror( errno ) );
(void)close( pidfile->fd );
(void)unlink( pidfile->filename );
return ERR_INTERNAL;
} else if( bytes_writen != (ssize_t)strlen( pid_string ) ) {
/* non-atomic write on files with so little data, strange, should never happen! */
- LOG( LOG_EMERG, "Non-atomic write failed when storing the PID into the pidfile '%s'", pidfile->filename );
+ LOG( log_EMERG, "Non-atomic write failed when storing the PID into the pidfile '%s'", pidfile->filename );
}
- LOG( LOG_DEBUG, "Stored '%lu' into the pidfile '%s' and locked it", (unsigned long)getpid( ), pidfile->filename );
+ LOG( log_DEBUG, "Stored '%lu' into the pidfile '%s' and locked it", (unsigned long)getpid( ), pidfile->filename );
pidfile->locked = true;
@@ -203,12 +203,12 @@ error_t pidfile_create( struct pidfile_t *pidfile ) {
error_t pidfile_release( struct pidfile_t *pidfile ) {
error_t error = OK;
- LOG( LOG_DEBUG, "Releasing (unlocking/closing) pidfile '%s' (fd: %d, locked: %d)",
+ LOG( log_DEBUG, "Releasing (unlocking/closing) pidfile '%s' (fd: %d, locked: %d)",
pidfile->filename, pidfile->fd, pidfile->locked );
if( pidfile->locked ) {
if( lockf( pidfile->fd, F_ULOCK, (off_t)0 ) < 0 ) {
- LOG( LOG_ALERT, "Unable to unlock the pidfile '%s': %s (%d)",
+ LOG( log_ALERT, "Unable to unlock the pidfile '%s': %s (%d)",
pidfile->filename, strerror( errno ), errno );
error = ERR_INTERNAL;
}
@@ -216,7 +216,7 @@ error_t pidfile_release( struct pidfile_t *pidfile ) {
if( pidfile->fd >= 0 ) {
if( close( pidfile->fd ) < 0 ) {
- LOG( LOG_ALERT, "Unable to close the pidfile '%s': %s (%d)",
+ LOG( log_ALERT, "Unable to close the pidfile '%s': %s (%d)",
pidfile->filename, strerror( errno ), errno );
error = ERR_INTERNAL;
}
@@ -229,13 +229,13 @@ error_t pidfile_release( struct pidfile_t *pidfile ) {
error_t pidfile_remove( struct pidfile_t *pidfile ) {
error_t error = OK;
- LOG( LOG_DEBUG, "Removing pidfile '%s' (fd: %d, locked: %d, running: %d)",
+ LOG( log_DEBUG, "Removing pidfile '%s' (fd: %d, locked: %d, running: %d)",
pidfile->filename, pidfile->fd, pidfile->locked, pidfile->running );
/* unconditionally remove the pidfile */
if( unlink( pidfile->filename ) < 0 ) {
- LOG( LOG_ALERT, "Unable to remove the pidfile '%s': %s (%d)",
+ LOG( log_ALERT, "Unable to remove the pidfile '%s': %s (%d)",
pidfile->filename, strerror( errno ), errno );
error = ERR_INTERNAL;
}
diff --git a/src/daemon/signals.c b/src/daemon/signals.c
index ca1024e..253c2ab 100644
--- a/src/daemon/signals.c
+++ b/src/daemon/signals.c
@@ -163,7 +163,7 @@ install_ignore_again:
if( sigaction( sig, &sa, NULL ) < 0 ) {
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_CRIT, "Can't ignore signal handler for signal '%s' (%s, %d): %s (errno: %d)",
+ LOG( log_CRIT, "Can't ignore signal handler for signal '%s' (%s, %d): %s (errno: %d)",
signal_get_long_name( sig ),
signal_get_short_name( sig ),
sig,
@@ -171,7 +171,7 @@ install_ignore_again:
errno );
return ERR_PROGRAMMING;
}
- LOG( LOG_DEBUG, "Ignoring signal handler for signal '%s' (%s)",
+ LOG( log_DEBUG, "Ignoring signal handler for signal '%s' (%s)",
signal_get_long_name( sig ),
signal_get_short_name( sig ) );
sig = va_arg( ap, int );
@@ -198,7 +198,7 @@ install_empty_again:
if( sigaction( sig, &sa, NULL ) < 0 ) {
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_CRIT, "Can't install empty signal handler for signal '%s' (%s, %d): %s (errno: %d)",
+ LOG( log_CRIT, "Can't install empty signal handler for signal '%s' (%s, %d): %s (errno: %d)",
signal_get_long_name( sig ),
signal_get_short_name( sig ),
sig,
@@ -206,7 +206,7 @@ install_empty_again:
errno );
return ERR_PROGRAMMING;
}
- LOG( LOG_DEBUG, "Installed empty signal handler for signal '%s' (%s)",
+ LOG( log_DEBUG, "Installed empty signal handler for signal '%s' (%s)",
signal_get_long_name( sig ),
signal_get_short_name( sig ) );
sig = va_arg( ap, int );
@@ -224,7 +224,7 @@ static void fatal_handler( int sig ) {
(void)sigaction( sig, &sa, NULL );
/* log what happened */
- LOG( LOG_ALERT, "Got signal '%s' (%s)",
+ LOG( log_ALERT, "Got signal '%s' (%s)",
signal_get_long_name( sig ),
signal_get_short_name( sig ) );
@@ -246,7 +246,7 @@ install_func_again:
if( sigaction( sig, &sa, NULL ) < 0 ) {
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_CRIT, "Can't install signal handler for signal '%s' (%s, %d): %s (errno: %d)",
+ LOG( log_CRIT, "Can't install signal handler for signal '%s' (%s, %d): %s (errno: %d)",
signal_get_long_name( sig ),
signal_get_short_name( sig ),
sig,
@@ -254,7 +254,7 @@ install_func_again:
errno );
return ERR_PROGRAMMING;
}
- LOG( LOG_DEBUG, "Installed signal handler for signal '%s' (%s)",
+ LOG( log_DEBUG, "Installed signal handler for signal '%s' (%s)",
signal_get_long_name( sig ),
signal_get_short_name( sig ) );
sig = va_arg( ap, int );
@@ -324,11 +324,11 @@ error_t signal_initialize( void ) {
res = pipe( daemon_signal_pipe );
if( res < 0 ) {
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_EMERG, "Unable to create signal pipe: %s (%d)",
+ LOG( log_EMERG, "Unable to create signal pipe: %s (%d)",
errbuf, errno );
return ERR_INTERNAL;
}
- LOG( LOG_DEBUG, "Created signal pipe (%d,%d)", daemon_signal_pipe[0], daemon_signal_pipe[1] );
+ LOG( log_DEBUG, "Created signal pipe (%d,%d)", daemon_signal_pipe[0], daemon_signal_pipe[1] );
return OK;
}
@@ -371,7 +371,7 @@ signal_select_again:
/* gdb no-brainer when pressing Ctrl-C (at least Linux) */
if( errno == 514 ) goto signal_select_again;
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_EMERG, "Error in select when waiting for signal from pipe: %s (%d)",
+ LOG( log_EMERG, "Error in select when waiting for signal from pipe: %s (%d)",
errbuf, errno );
*error = ERR_INTERNAL;
return -1;
@@ -384,13 +384,13 @@ signal_select_again:
case -1: /* error */
(void)strerror_r( errno, errbuf, 1024 );
- LOG( LOG_EMERG, "Error while reading a signal from the pipe: %s (%d)",
+ LOG( log_EMERG, "Error while reading a signal from the pipe: %s (%d)",
errbuf, errno );
*error = ERR_INTERNAL;
return -1;
default: /* unexpected result on atomic read */
- LOG( LOG_EMERG, "Unexpected error in read: result is %d", res );
+ LOG( log_EMERG, "Unexpected error in read: result is %d", res );
*error = ERR_PROGRAMMING;
return -1;
}
diff --git a/src/log.c b/src/log.c
index a004e79..c8d7ca2 100644
--- a/src/log.c
+++ b/src/log.c
@@ -6,6 +6,8 @@
#include <stdarg.h> /* for variable arguments */
#include <errno.h> /* for errno */
+#include <syslog.h> /* for syslog, closelog and levels */
+
const char *log_syslog_facility_to_str( int facility ) {
switch( facility ) {
case LOG_KERN: return "KERN";
@@ -24,7 +26,7 @@ const char *log_syslog_facility_to_str( int facility ) {
#if defined LOG_FTP
case LOG_FTP: return "FTP";
#endif
- default: return "<unknown";
+ default: return "<unknown>";
}
}
@@ -49,41 +51,86 @@ int log_str_to_syslog_facility( const char *facility ) {
return LOG_DAEMON;
}
-const char *log_level_to_str( int level ) {
+int log_str_to_level( const char *level ) {
+ if( strcmp( level, "EMERG" ) == 0 ) return log_EMERG;
+ if( strcmp( level, "ALERT" ) == 0 ) return log_ALERT;
+ if( strcmp( level, "CRIT" ) == 0 ) return log_CRIT;
+ if( strcmp( level, "ERR" ) == 0 ) return log_ERR;
+ if( strcmp( level, "WARNING" ) == 0 ) return log_WARNING;
+ if( strcmp( level, "NOTICE" ) == 0 ) return log_NOTICE;
+ if( strcmp( level, "INFO" ) == 0 ) return log_INFO;
+ if( strcmp( level, "DEBUG" ) == 0 ) return log_DEBUG;
+ if( strcmp( level, "DEBUG1" ) == 0 ) return log_DEBUG1;
+ if( strcmp( level, "DEBUG2" ) == 0 ) return log_DEBUG2;
+ if( strcmp( level, "DEBUG3" ) == 0 ) return log_DEBUG3;
+ if( strcmp( level, "DEBUG4" ) == 0 ) return log_DEBUG4;
+ if( strcmp( level, "DEBUG5" ) == 0 ) return log_DEBUG5;
+
+ return log_NOTICE;
+}
+
+static int map_log_to_syslog_level( int level ) {
switch( level ) {
- case LOG_EMERG: return "EMERG";
- case LOG_ALERT: return "ALERT";
- case LOG_CRIT: return "CRIT";
- case LOG_ERR: return "ERR";
- case LOG_WARNING: return "WARNING";
- case LOG_NOTICE: return "NOTICE";
- case LOG_INFO: return "INFO";
- case LOG_DEBUG: return "DEBUG";
- case LOG_DEBUG1: return "DEBUG1";
- case LOG_DEBUG2: return "DEBUG2";
- case LOG_DEBUG3: return "DEBUG3";
- case LOG_DEBUG4: return "DEBUG4";
- case LOG_DEBUG5: return "DEBUG5";
- default: return "<unknown>";
+ case log_EMERG: return LOG_EMERG;
+ case log_ALERT: return LOG_ALERT;
+ case log_CRIT: return LOG_CRIT;
+ case log_ERR: return LOG_ERR;
+ case log_WARNING: return LOG_WARNING;
+ case log_NOTICE: return LOG_NOTICE;
+ case log_INFO: return LOG_INFO;
+ case log_DEBUG:
+ case log_DEBUG1:
+ case log_DEBUG2:
+ case log_DEBUG3:
+ case log_DEBUG4:
+ case log_DEBUG5: return LOG_DEBUG;
+ default: return LOG_EMERG;
}
}
-int log_str_to_level( const char *level ) {
- if( strcmp( level, "EMERG" ) == 0 ) return LOG_EMERG;
- if( strcmp( level, "ALERT" ) == 0 ) return LOG_ALERT;
- if( strcmp( level, "CRIT" ) == 0 ) return LOG_CRIT;
- if( strcmp( level, "ERR" ) == 0 ) return LOG_ERR;
- if( strcmp( level, "WARNING" ) == 0 ) return LOG_WARNING;
- if( strcmp( level, "NOTICE" ) == 0 ) return LOG_NOTICE;
- if( strcmp( level, "INFO" ) == 0 ) return LOG_INFO;
- if( strcmp( level, "DEBUG" ) == 0 ) return LOG_DEBUG;
- if( strcmp( level, "DEBUG1" ) == 0 ) return LOG_DEBUG1;
- if( strcmp( level, "DEBUG2" ) == 0 ) return LOG_DEBUG2;
- if( strcmp( level, "DEBUG3" ) == 0 ) return LOG_DEBUG3;
- if( strcmp( level, "DEBUG4" ) == 0 ) return LOG_DEBUG4;
- if( strcmp( level, "DEBUG5" ) == 0 ) return LOG_DEBUG5;
-
- return LOG_NOTICE;
+static int map_log_facility_to_syslog_facility( int facility ) {
+ switch( facility ) {
+ case log_KERN: return LOG_KERN;
+ case log_USER: return LOG_USER;
+ case log_MAIL: return LOG_MAIL;
+ case log_DAEMON: return LOG_DAEMON;
+ case log_AUTH: return LOG_AUTH;
+ case log_SYSLOG: return LOG_SYSLOG;
+ case log_LPR: return LOG_LPR;
+ case log_NEWS: return LOG_NEWS;
+ case log_UUCP: return LOG_UUCP;
+ case log_CRON: return LOG_CRON;
+#if defined LOG_AUTHPRIV
+ case log_AUTHPRIV: return LOG_AUTHPRIV;
+#else
+ case log_AUTHPRIV: return LOG_DAEMON;
+#endif
+#if defined LOG_FTP
+ case log_FTP: return LOG_FTP;
+#else
+ case log_FTP: return LOG_DAEMON;
+#endif
+ default: return LOG_DAEMON;
+ }
+}
+
+const char *log_level_to_str( int level ) {
+ switch( level ) {
+ case log_EMERG: return "EMERG";
+ case log_ALERT: return "ALERT";
+ case log_CRIT: return "CRIT";
+ case log_ERR: return "ERR";
+ case log_WARNING: return "WARNING";
+ case log_NOTICE: return "NOTICE";
+ case log_INFO: return "INFO";
+ case log_DEBUG: return "DEBUG";
+ case log_DEBUG1: return "DEBUG1";
+ case log_DEBUG2: return "DEBUG2";
+ case log_DEBUG3: return "DEBUG3";
+ case log_DEBUG4: return "DEBUG4";
+ case log_DEBUG5: return "DEBUG5";
+ default: return "<unknown>";
+ }
}
static const char *log_logfile_filename;
@@ -104,8 +151,8 @@ void openlogtosyslog( const char *ident, int facility, int level ) {
openlog( ident, LOG_CONS | LOG_NDELAY, facility );
setlogmask( LOG_UPTO( level ) );
syslog_ident = ident;
- syslog_facility = facility;
- syslog_level = level;
+ syslog_facility = map_log_facility_to_syslog_facility( facility );
+ syslog_level = map_log_to_syslog_level( level );
}
void openlogtostderr( int level ) {
diff --git a/src/log.h b/src/log.h
deleted file mode 100644
index f6c0534..0000000
--- a/src/log.h
+++ /dev/null
@@ -1,60 +0,0 @@
-#ifndef __LOG_H
-#define __LOG_H
-
-#include "port/sys.h"
-
-#include <syslog.h> /* for syslog, closelog and levels */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if 0
-/* defined in syslog.h */
-#define LOG_EMERG 0 /* system is unusable */
-#define LOG_ALERT 1 /* action must be taken immediately */
-#define LOG_CRIT 2 /* critical conditions */
-#define LOG_ERR 3 /* error conditions */
-#define LOG_WARNING 4 /* warning conditions */
-#define LOG_NOTICE 5 /* normal but significant condition */
-#define LOG_INFO 6 /* informational */
-#define LOG_DEBUG 7 /* debug-level messages */
-#endif
-
-#define LOG_DEBUG1 ( LOG_DEBUG + 1 )
-#define LOG_DEBUG2 ( LOG_DEBUG + 2 )
-#define LOG_DEBUG3 ( LOG_DEBUG + 3 )
-#define LOG_DEBUG4 ( LOG_DEBUG + 4 )
-#define LOG_DEBUG5 ( LOG_DEBUG + 5 )
-
-const char *log_syslog_facility_to_str( int facility );
-
-int log_str_to_syslog_facility( const char *facility );
-
-const char *log_level_to_str( int level );
-
-int log_str_to_level( const char *level );
-
-void openlogtofile( const char *filename, int level );
-
-void openlogtosyslog( const char *ident, int facility, int level );
-
-void openlogtostderr( int level );
-
-void closelogtofile( void );
-
-void closelogtosyslog( void );
-
-void closelogtostderr( void );
-
-void reopenlogtofile( void );
-
-void reopenlogtosyslog( void );
-
-void LOG( int level, const char *format, ... );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/port/limits.h b/src/port/limits.h
index a9e13a7..40ae1bb 100644
--- a/src/port/limits.h
+++ b/src/port/limits.h
@@ -1,7 +1,7 @@
#ifndef __LIMITS_H
#define __LIMITS_H
-#include "sys.h"
+#include "port/sys.h"
#include <limits.h>
diff --git a/src/port/lockf.h b/src/port/lockf.h
index 5ec99b3..e060ee6 100644
--- a/src/port/lockf.h
+++ b/src/port/lockf.h
@@ -1,7 +1,7 @@
#ifndef __LOCKF_H
#define __LOCKF_H
-#include "sys.h"
+#include "port/sys.h"
#if !defined HAVE_LOCKF
diff --git a/src/port/snprintf.h b/src/port/snprintf.h
index 158e5fb..c374a15 100644
--- a/src/port/snprintf.h
+++ b/src/port/snprintf.h
@@ -1,7 +1,7 @@
#ifndef __SNPRINTF_H
#define __SNPRINTF_H
-#include "sys.h"
+#include "port/sys.h"
#define HAVE_CONFIG_H 0
#define TEST_SNPRINTF 0
diff --git a/src/port/stdbool.h b/src/port/stdbool.h
deleted file mode 100644
index 9c011e4..0000000
--- a/src/port/stdbool.h
+++ /dev/null
@@ -1,35 +0,0 @@
-#ifndef __STDBOOL_H
-#define __STDBOOL_H
-
-#include "sys.h"
-
-/* C99 Boolean types for compilers without C99 support, see
- * http://www.opengroup.org/onlinepubs/009695399/basedefs/stdbool.h.html */
-
-/* don't define bool in C++, it exists already! */
-#ifndef __cplusplus
-
-#ifdef HAVE_STDBOOL_H
-#include <stdbool.h>
-#else
-
-#if !defined HAVE_ENUM_BOOL
-typedef enum {
- _Bool_must_promote_to_int = -1,
- false = 0,
- true = 1
-} _Bool;
-#endif /* !defined HAVE_ENUM_BOOL */
-
-#define bool _Bool
-
-#define true 1
-#define false 0
-
-#define __bool_true_false_are_defined 1
-
-#endif /* ifdef HAVE_STDBOOL_H */
-
-#endif /* ifndef __cplusplus */
-
-#endif /* ifndef STDBOOL_H */
diff --git a/src/port/stdint.h b/src/port/stdint.h
index d5d830a..345ec7e 100644
--- a/src/port/stdint.h
+++ b/src/port/stdint.h
@@ -1,7 +1,7 @@
#ifndef __STDINT_H
#define __STDINT_H
-#include "sys.h"
+#include "port/sys.h"
#if defined HAVE_STDINT_H
#include <stdint.h>
diff --git a/src/port/stdio.h b/src/port/stdio.h
index 59a7d67..54b5d35 100644
--- a/src/port/stdio.h
+++ b/src/port/stdio.h
@@ -1,7 +1,7 @@
#ifndef __STDIO_H
#define __STDIO_H
-#include "sys.h"
+#include "port/sys.h"
#include <stdio.h>
diff --git a/src/port/string.h b/src/port/string.h
index 8f96466..baae59d 100644
--- a/src/port/string.h
+++ b/src/port/string.h
@@ -1,7 +1,7 @@
#ifndef __STRING_H
#define __STRING_H
-#include "sys.h"
+#include "port/sys.h"
#include <string.h>
diff --git a/src/port/sys.h b/src/port/sys.h
deleted file mode 100644
index 65b68e2..0000000
--- a/src/port/sys.h
+++ /dev/null
@@ -1,119 +0,0 @@
-#if defined LINUX
-#if OS_MAJOR_VERSION == 2
-#if OS_MINOR_VERSION == 6
-#define _XOPEN_SOURCE 600
-#define HAVE_STDBOOL_H
-#define HAVE_STDINT_H
-#define HAVE_VSNPRINTF
-#define HAVE_SNPRINTF
-#define HAVE_VASPRINTF
-#define HAVE_ASPRINTF
-#define HAVE_STRDUP
-#define HAVE_LOCKF
-#else
- #error unknown platform
-#endif /* defined OS_MINOR_VERSION == 6 */
-#else
- #error unknown platform
-#endif /* defined OS_MAJOR_VERSION == 2 */
-#endif /* defined LINUX */
-
-#if defined FREEBSD
-#if OS_MAJOR_VERSION == 7
-#if OS_MINOR_VERSION == 0
-#define _XOPEN_SOURCE 600
-#define HAVE_STDBOOL_H
-#define HAVE_STDINT_H
-#define HAVE_VSNPRINTF
-#define HAVE_SNPRINTF
-#define HAVE_VASPRINTF
-#define HAVE_ASPRINTF
-#define HAVE_STRDUP
-#define HAVE_LOCKF
-#else
- #error unknown platform
-#endif /* defined OS_MINOR_VERSION == 0 */
-#else
-#if OS_MAJOR_VERSION == 6
-#if OS_MINOR_VERSION == 2
-#define _XOPEN_SOURCE 600
-#define HAVE_STDBOOL_H
-#define HAVE_STDINT_H
-#define HAVE_VSNPRINTF
-#define HAVE_SNPRINTF
-#define HAVE_STRDUP
-#define HAVE_LOCKF
-#else
- #error unknown platform
-#endif /* defined OS_MINOR_VERSION == 2 */
-#else
- #error unknown platform
-#endif /* defined OS_MAJOR_VERSION == 6 */
-#endif /* defined OS_MAJOR_VERSION == 7 */
-#endif /* defined FREEBSD */
-
-#if defined OPENBSD
-#if OS_MAJOR_VERSION == 4
-#if OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 3
-#define _XOPEN_SOURCE 600
-#define HAVE_STDBOOL_H
-#define HAVE_STDINT_H
-#define HAVE_VSNPRINTF
-#define HAVE_SNPRINTF
-#define HAVE_VASPRINTF
-#define HAVE_ASPRINTF
-#define HAVE_STRDUP
-#define HAVE_LOCKF
-#else
- #error unknown platform
-#endif /* defined OS_MINOR_VERSION >= 2 && OS_MINOR_VERSION <= 3 */
-#else
- #error unknown platform
-#endif /* defined OS_MAJOR_VERSION == 4 */
-#endif /* defined OPENBSD */
-
-#if defined SUNOS
-#if OS_MAJOR_VERSION == 5
-#if OS_MINOR_VERSION == 8
-#if !defined __cplusplus
-#define _XOPEN_SOURCE 600
-#define __EXTENSIONS__
-#endif
-#define HAVE_SNPRINTF
-#define HAVE_VSNPRINTF
-#define HAVE_LOCKF
-#define HAVE_ENUM_BOOL
-#define HAVE_LINK_H
-#else
-#if OS_MINOR_VERSION == 10
-#if !defined __cplusplus
-#define _XOPEN_SOURCE 600
-#define __EXTENSIONS__
-#endif
-#define HAVE_SNPRINTF
-#define HAVE_VSNPRINTF
-#define HAVE_LOCKF
-#define HAVE_STDBOOL_H
-#define HAVE_STDINT_H
-#define HAVE_STRERROR_R
-#else
- #error unknown platform
-#endif /* OS_MINOR_VERSION == 10 */
-#endif /* OS_MINOR_VERSION == 8 */
-#else
- #error unknown platform
-#endif /* OS_MAJOR_VERSION == 5 */
-#endif /* defined SUNOS */
-
-#if defined CYGWIN
-#if OS_MAJOR_VERSION == 5
-#if OS_MINOR_VERSION == 0
-#define _XOPEN_SOURCE 600
-#define HAVE_ENUM_BOOL
-#else
- #error unknown platform
-#endif /* OS_MINOR_VERSION == 0 */
-#else
- #error unknown platform
-#endif /* OS_MAJOR_VERSION == 5 */
-#endif /* defined CYGWIN */
diff --git a/src/port/unistd.h b/src/port/unistd.h
index 712f851..33be786 100644
--- a/src/port/unistd.h
+++ b/src/port/unistd.h
@@ -1,7 +1,7 @@
#ifndef __UNISTD_H
#define __UNISTD_H
-#include "sys.h"
+#include "port/sys.h"
#include <unistd.h>
diff --git a/src/port/unused.h b/src/port/unused.h
deleted file mode 100644
index c7692f6..0000000
--- a/src/port/unused.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __UNUSED_H
-#define __UNUSED_H
-
-#include "port/sys.h"
-
-#define UNUSED( x ) if( 0 && (x) ) { }
-
-#endif /* ifndef __UNUSED_H */