From 29cc88db7d97c11b1d0e7f0504f4b84e784c9249 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Sun, 30 May 2010 12:06:38 +0000 Subject: Print --version etc via estream --- common/init.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'common/init.c') diff --git a/common/init.c b/common/init.c index aa0b6a7ca..f0ab9c98c 100644 --- a/common/init.c +++ b/common/init.c @@ -49,6 +49,23 @@ sleep_on_exit (void) #endif /*HAVE_W32CE_SYSTEM*/ +/* If STRING is not NULL write string to es_stdout or es_stderr. MODE + must be 1 or 2. If STRING is NULL flush the respective stream. */ +static int +writestring_via_estream (int mode, const char *string) +{ + if (mode == 1 || mode == 2) + { + if (string) + return es_fputs (string, mode == 1? es_stdout : es_stderr); + else + return es_fflush (mode == 1? es_stdout : es_stderr); + } + else + return -1; +} + + /* This function is to be used early at program startup to make sure that some subsystems are initialized. This is in particular important for W32 to initialize the sockets so that our socket @@ -100,6 +117,10 @@ init_common_subsystems (int *argcp, char ***argvp) (void)argcp; (void)argvp; #endif + + /* --version et al shall use estream as well. */ + argparse_register_outfnc (writestring_via_estream); + } -- cgit v1.2.3