From 92b35532d8707fb6aab8d450327fc8b6b64b0118 Mon Sep 17 00:00:00 2001 From: Zheng Da Date: Fri, 11 Dec 2009 13:51:22 +0100 Subject: allow to print information to stdout. --- libddekit/printf.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libddekit/printf.c b/libddekit/printf.c index 0d4ec52f..a35c4bc9 100644 --- a/libddekit/printf.c +++ b/libddekit/printf.c @@ -9,9 +9,11 @@ #include #include #include +#include #include "ddekit/printf.h" +extern boolean_t using_std; static FILE *output; /** @@ -71,17 +73,23 @@ int ddekit_vprintf(const char *fmt, va_list va) int log_init () { - char template[] = "/var/log/dde_log.XXXXXX"; - int ret = mkstemp (template); - if (ret < 0) { - error (0, errno, "mkstemp"); - return -1; + if (using_std) { + output = stdout; } + else { + char template[] = "/var/log/dde_log.XXXXXX"; + int ret = mkstemp (template); + if (ret < 0) { + error (0, errno, "mkstemp"); + return -1; + } - output = fopen (template, "a+"); - if (!output) { - error (0, errno, "open %s", template); - return -1; + output = fopen (template, "a+"); + if (!output) { + error (0, errno, "open %s", template); + return -1; + } } + return 0; } -- cgit v1.2.3