diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2009-03-16 20:44:05 +0100 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2009-03-16 20:44:05 +0100 |
commit | eaa9fc26151be325c8a5c838f351f80137fcce34 (patch) | |
tree | 228d4f1375c0fca9856306f8401ccc2ce1217b17 /tests/daemon | |
parent | 553e7cfb02d73f341fe4f68463e25cebac750b42 (diff) | |
download | wolfbones-eaa9fc26151be325c8a5c838f351f80137fcce34.tar.gz wolfbones-eaa9fc26151be325c8a5c838f351f80137fcce34.tar.bz2 |
testing more around getopt and locales, getopt_long on Linux has i18n, so don't use the one from gengetopt
Diffstat (limited to 'tests/daemon')
-rw-r--r-- | tests/daemon/GNUmakefile | 4 | ||||
-rw-r--r-- | tests/daemon/testd.c | 25 |
2 files changed, 20 insertions, 9 deletions
diff --git a/tests/daemon/GNUmakefile b/tests/daemon/GNUmakefile index ae3062b..d979263 100644 --- a/tests/daemon/GNUmakefile +++ b/tests/daemon/GNUmakefile @@ -18,9 +18,9 @@ TEST_OBJS = \ # ABa: currently a special rule for cmdline.c as gengetopt is not # completly fixed yet testd_cmdline.h : testd.ggo - gengetopt --file-name testd_cmdline --include-getopt --conf-parser -i $< + gengetopt --file-name testd_cmdline --conf-parser -i $< testd_cmdline.c : testd.ggo - gengetopt --file-name testd_cmdline --include-getopt --conf-parser -i $< + gengetopt --file-name testd_cmdline --conf-parser -i $< testd_cmdline.o : testd_cmdline.c testd_cmdline.h $(CC) -c -o $@ $< diff --git a/tests/daemon/testd.c b/tests/daemon/testd.c index b523020..76ac858 100644 --- a/tests/daemon/testd.c +++ b/tests/daemon/testd.c @@ -1,5 +1,6 @@ #include "port/string.h" /* for strdup, memset */ #include "port/stdio.h" /* for fprintf */ +#include "port/gettext.h" /* for i18n */ #include "errors.h" /* global error codes */ #include "log.h" /* logging facility */ @@ -39,13 +40,14 @@ static int parse_options_and_arguments( int argc, char *argv[], struct gengetopt static int test_config( const char *filename ) { wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_TESTING_CONFIGURATION, - "Testing configuraton read from '%s'", filename ); + _( "Testing configuraton read from '%s'" ), filename ); return EXIT_SUCCESS; } static int read_config( const char *filename, struct gengetopt_args_info *args_info ) { char *config_filename = strdup( filename ); if( cmdline_parser_configfile( config_filename, args_info, 1, 0, 1 ) != 0 ) { + /* TODO: gengetopt must support i18n for this */ fprintf( stderr, "\n%s\n", gengetopt_args_info_usage ); cmdline_parser_free( args_info ); free( config_filename ); @@ -56,6 +58,12 @@ static int read_config( const char *filename, struct gengetopt_args_info *args_i return EXIT_SUCCESS; } +/* FIXME: coreutils set it to automake variables, see what postgres does and maybe + * set it in platform.mk? + */ +//#define LOCALEDIR "/usr/share/locale" +#define LOCALEDIR "lcoale" + int main( int argc, char *argv[] ) { struct gengetopt_args_info args_info; wolf_error_t error; @@ -63,6 +71,9 @@ int main( int argc, char *argv[] ) { wolf_daemon_p demon = NULL; int sig = 0; + setlocale( LC_ALL, "" ); + bindtextdomain( CMDLINE_PARSER_PACKAGE, LOCALEDIR ); + if( parse_options_and_arguments( argc, argv, &args_info ) == EXIT_FAILURE ) { exit( EXIT_FAILURE ); } @@ -124,7 +135,7 @@ int main( int argc, char *argv[] ) { } wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_STARTED_DAEMON, - "Started %s daemon", CMDLINE_PARSER_PACKAGE ); + _( "Started %s daemon" ), CMDLINE_PARSER_PACKAGE ); while( ( sig != SIGTERM ) && ( sig != SIGINT ) && ( sig != -1 ) ) { sig = wolf_daemon_signals_suspend( 60, &error ); switch( sig ) { @@ -133,19 +144,19 @@ int main( int argc, char *argv[] ) { case -1: /* internal error */ wolf_log( WOLF_LOG_CRIT, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_SUSPENDING_ON_SIGNAL_ERROR, - "Suspending on UNIX signal resulted in an error %d!", + _( "Suspending on UNIX signal resulted in an error %d!" ), error ); break; case SIGHUP: wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_REREADING_CONFIGURATION, - "Rereading configuration" ); + _( "Rereading configuration" ) ); break; case SIGTERM: case SIGINT: wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_GOT_TERMINATION_SIGNAL, - "Got termination signal, shutting down the daemon" ); + _( "Got termination signal, shutting down the daemon" ) ); break; case SIGUSR1: @@ -156,14 +167,14 @@ int main( int argc, char *argv[] ) { default: wolf_log( WOLF_LOG_ERR, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_UNEXPECED_SIGNAL, - "Unexpected signal '%s' (%s, %d)", + _( "Unexpected signal '%s' (%s, %d)" ), wolf_signal_get_long_name( sig ), wolf_signal_get_short_name( sig ), sig ); } } wolf_log( WOLF_LOG_NOTICE, WOLF_CATEGORY_DAEMON, WOLF_MSG_DAEMON_STOPPED_DAEMON, - "Stopped %s daemon", CMDLINE_PARSER_PACKAGE ); + _( "Stopped %s daemon" ), CMDLINE_PARSER_PACKAGE ); if( !args_info.foreground_given ) { cmdline_parser_free( &args_info ); |