aboutsummaryrefslogtreecommitdiffstats
path: root/common/init.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2010-05-30 12:06:38 +0000
committerWerner Koch <[email protected]>2010-05-30 12:06:38 +0000
commit29cc88db7d97c11b1d0e7f0504f4b84e784c9249 (patch)
treea383cba3be8c09969443361b595c8382df2eeb7e /common/init.c
parentUpdate tests. (diff)
downloadgnupg-29cc88db7d97c11b1d0e7f0504f4b84e784c9249.tar.gz
gnupg-29cc88db7d97c11b1d0e7f0504f4b84e784c9249.zip
Print --version etc via estream
Diffstat (limited to 'common/init.c')
-rw-r--r--common/init.c21
1 files changed, 21 insertions, 0 deletions
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);
+
}