diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-14 18:56:25 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-14 18:56:25 +0100 |
commit | 745d95825a6a23ff187ad42c5843ad68d8d80afd (patch) | |
tree | 558ec4f50e3425a397590669ee90007e7ee8d210 /tests/daemon | |
parent | a00394b2149f36e0a8ca5af9e1b1888709490f08 (diff) | |
download | wolfbones-745d95825a6a23ff187ad42c5843ad68d8d80afd.tar.gz wolfbones-745d95825a6a23ff187ad42c5843ad68d8d80afd.tar.bz2 |
everything compiles and works again
Diffstat (limited to 'tests/daemon')
-rw-r--r-- | tests/daemon/testd.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/daemon/testd.c b/tests/daemon/testd.c index fdb3a8f..b523020 100644 --- a/tests/daemon/testd.c +++ b/tests/daemon/testd.c @@ -1,13 +1,24 @@ #include "port/string.h" /* for strdup, memset */ - -#include <unistd.h> /* for exit, unistd, getuid, getppid */ -#include <stdlib.h> /* for EXIT_FAILURE, EXIT_SUCCESS */ -#include <stdio.h> /* for fprntf */ +#include "port/stdio.h" /* for fprintf */ #include "errors.h" /* global error codes */ #include "log.h" /* logging facility */ #include "daemon/daemon.h" /* Unix daemonizing code */ #include "daemon/signals.h" /* signal suspension */ +#include "messages.h" /* for i18n */ + +#include <unistd.h> /* for exit, unistd, getuid, getppid */ +#include <stdlib.h> /* for EXIT_FAILURE, EXIT_SUCCESS */ + +/* local message identifiers, we use the category of the daemon in WolfBones + */ +#define WOLF_MSG_DAEMON_TESTING_CONFIGURATION WOLF_MSG_DAEMON_USER_BASE+1 +#define WOLF_MSG_DAEMON_STARTED_DAEMON WOLF_MSG_DAEMON_USER_BASE+2 +#define WOLF_MSG_DAEMON_SUSPENDING_ON_SIGNAL_ERROR WOLF_MSG_DAEMON_USER_BASE+3 +#define WOLF_MSG_DAEMON_REREADING_CONFIGURATION WOLF_MSG_DAEMON_USER_BASE+4 +#define WOLF_MSG_DAEMON_GOT_TERMINATION_SIGNAL WOLF_MSG_DAEMON_USER_BASE+5 +#define WOLF_MSG_DAEMON_UNEXPECED_SIGNAL WOLF_MSG_DAEMON_USER_BASE+6 +#define WOLF_MSG_DAEMON_STOPPED_DAEMON WOLF_MSG_DAEMON_USER_BASE+7 #ifndef MAKE_DEPENDENCIES #include "testd_cmdline.h" /* for command line and option parsing (gengetopt) */ @@ -27,7 +38,8 @@ static int parse_options_and_arguments( int argc, char *argv[], struct gengetopt } static int test_config( const char *filename ) { - WOLF_LOG( WOLF_LOG_NOTICE, "Testing configuraton read from '%s'", filename ); + wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_TESTING_CONFIGURATION, + "Testing configuraton read from '%s'", filename ); return EXIT_SUCCESS; } @@ -111,7 +123,8 @@ int main( int argc, char *argv[] ) { } } - WOLF_LOG( WOLF_LOG_NOTICE, "Started %s daemon", CMDLINE_PARSER_PACKAGE ); + wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_STARTED_DAEMON, + "Started %s daemon", CMDLINE_PARSER_PACKAGE ); while( ( sig != SIGTERM ) && ( sig != SIGINT ) && ( sig != -1 ) ) { sig = wolf_daemon_signals_suspend( 60, &error ); switch( sig ) { @@ -119,17 +132,20 @@ int main( int argc, char *argv[] ) { break; case -1: /* internal error */ - WOLF_LOG( WOLF_LOG_CRIT, "Suspending on UNIX signal resulted in an error %d!", + wolf_log( WOLF_LOG_CRIT, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_SUSPENDING_ON_SIGNAL_ERROR, + "Suspending on UNIX signal resulted in an error %d!", error ); break; case SIGHUP: - WOLF_LOG( WOLF_LOG_NOTICE, "Rereading configuration" ); + wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_REREADING_CONFIGURATION, + "Rereading configuration" ); break; case SIGTERM: case SIGINT: - WOLF_LOG( WOLF_LOG_NOTICE, "Got termination signal, shutting down the daemon" ); + wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_GOT_TERMINATION_SIGNAL, + "Got termination signal, shutting down the daemon" ); break; case SIGUSR1: @@ -139,13 +155,15 @@ int main( int argc, char *argv[] ) { break; default: - WOLF_LOG( WOLF_LOG_ERR, "Unexpected signal '%s' (%s, %d)", + wolf_log( WOLF_LOG_ERR, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_UNEXPECED_SIGNAL, + "Unexpected signal '%s' (%s, %d)", wolf_signal_get_long_name( sig ), wolf_signal_get_short_name( sig ), sig ); } } - WOLF_LOG( WOLF_LOG_NOTICE, "Stopped %s daemon", CMDLINE_PARSER_PACKAGE ); + wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_STOPPED_DAEMON, + "Stopped %s daemon", CMDLINE_PARSER_PACKAGE ); if( !args_info.foreground_given ) { cmdline_parser_free( &args_info ); |