From 0c0b00ab8086c07600680d41e2f8feefe0f8f150 Mon Sep 17 00:00:00 2001 From: Guillaume Cottenceau Date: Thu, 7 Dec 2000 23:16:19 +0000 Subject: first draft can detect your cdrom drives soon will launch the stage2 --- mdk-stage1/log.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'mdk-stage1/log.c') diff --git a/mdk-stage1/log.c b/mdk-stage1/log.c index 27e77bf02..7536d0a08 100644 --- a/mdk-stage1/log.c +++ b/mdk-stage1/log.c @@ -19,26 +19,29 @@ * */ - +#include +#include #include #include #include -#include -#include +#include +#include +#include #include "log.h" static FILE * logfile = NULL; - -void do_log_message(const char * s, va_list args) +void vlog_message_nobs(const char * s, va_list args) { - if (!logfile) return; - fprintf(logfile, "* "); vfprintf(logfile, s, args); +} + +void vlog_message(const char * s, va_list args) +{ + vlog_message_nobs(s, args); fprintf(logfile, "\n"); - fflush(logfile); } @@ -46,25 +49,34 @@ void do_log_message(const char * s, va_list args) void log_message(const char * s, ...) { va_list args; - + + if (!logfile) { + fprintf(stderr, "Log is not open!\n"); + return; + } + va_start(args, s); - do_log_message(s, args); + vlog_message(s, args); va_end(args); return; } +void log_perror(char *msg) +{ + log_message("%s %s", strerror(errno), msg); +} + void open_log(int testing) { - if (!testing) - { - logfile = fopen("/dev/tty3", "w"); - if (!logfile) - logfile = fopen("/tmp/install.log", "a"); - } - else - logfile = fopen("debug.log", "w"); + if (!testing) { + logfile = fopen("/dev/tty3", "w"); + if (!logfile) + logfile = fopen("/tmp/install.log", "a"); + } + else + logfile = fopen("debug.log", "w"); } void close_log(void) -- cgit v1.2.1