summaryrefslogtreecommitdiff
path: root/libddekit/printf.c
diff options
context:
space:
mode:
authorZheng Da <zhengda1936@gmail.com>2009-12-11 13:51:22 +0100
committerZheng Da <zhengda1936@gmail.com>2009-12-11 13:51:22 +0100
commit92b35532d8707fb6aab8d450327fc8b6b64b0118 (patch)
treea57296339ca6f2af4435ecaa839fc0257fbd2c45 /libddekit/printf.c
parent9341952a7cea0d39b871ecdb6ac153fc820524c8 (diff)
allow to print information to stdout.
Diffstat (limited to 'libddekit/printf.c')
-rw-r--r--libddekit/printf.c26
1 files 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <mach.h>
#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;
}