diff -Naur pearpc.old/src/io/prom/fs/hfsplus/partitions.c pearpc.new/src/io/prom/fs/hfsplus/partitions.c --- pearpc.old/src/io/prom/fs/hfsplus/partitions.c 2004-11-04 23:10:30.000000000 +0000 +++ pearpc.new/src/io/prom/fs/hfsplus/partitions.c 2005-02-16 17:38:39.156250000 +0000 @@ -159,7 +159,7 @@ ApplePartition **partitions = map->partitions; int i; for (i=0; i < map->numparts; i++) { - printf("getStartBlock: %d %s\n", i, partitions[num]->pmPartType); + //printf("getStartBlock: %d %s\n", i, partitions[num]->pmPartType); } if (num >= map->numparts) return 0; if (strcmp(partitions[num]->pmPartType, type)) return 0; diff -Naur pearpc.old/src/main.cc pearpc.new/src/main.cc --- pearpc.old/src/main.cc 2004-10-15 12:55:05.000000000 +0100 +++ pearpc.new/src/main.cc 2005-02-16 17:40:44.421875000 +0000 @@ -43,6 +43,7 @@ #include "system/keyboard.h" #include "system/sys.h" #include "configparser.h" +#include "tools/snprintf.h" #include "system/gif.h" #include "system/ui/gui.h" @@ -242,6 +243,9 @@ gConfig->acceptConfigEntryStringDef("key_change_cd_1", "none"); gConfig->acceptConfigEntryStringDef("key_toggle_mouse_grab", "F12"); gConfig->acceptConfigEntryStringDef("key_toggle_full_screen", "Ctrl+Alt+Return"); + gConfig->acceptConfigEntryIntDef("ppc_logfile_enabled", 1); + gConfig->acceptConfigEntryStringDef("ppc_logfile_location", "ppc.log"); + gConfig->acceptConfigEntryStringDef("ppc_logfile_mode", "e"); prom_init_config(); io_init_config(); @@ -260,6 +264,20 @@ usage(); exit(1); } + + int logEnabled; + String logFile; + String logMode; + logEnabled = gConfig->getConfigInt("ppc_logfile_enabled"); + gConfig->getConfigString("ppc_logfile_location", logFile); + gConfig->getConfigString("ppc_logfile_mode", logMode); + int logRetVal; + logRetVal = initLogFile(logEnabled, logMode, logFile); + if (!logRetVal==0) + { + ht_printf("cannot initialize log file!"); + exit(1); + } ht_printf("This program is free software; you can redistribute it and/or modify\n" "it under the terms of the GNU General Public License version 2 as published by\n" diff -Naur pearpc.old/src/tools/snprintf.cc pearpc.new/src/tools/snprintf.cc --- pearpc.old/src/tools/snprintf.cc 2004-07-27 15:36:09.000000000 +0100 +++ pearpc.new/src/tools/snprintf.cc 2005-02-16 17:31:08.937500000 +0000 @@ -75,6 +75,8 @@ #include "system/types.h" #include "data.h" +#include "snprintf.h" +#include "../info.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -146,6 +148,10 @@ #define MAX(p,q) (((p) >= (q)) ? (p) : (q)) #endif +int amIEnabled; +const char *myLog; +const char *myMode; + static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) { char ch; @@ -963,7 +969,17 @@ int ht_vprintf(const char *fmt, va_list args) { - return ht_vfprintf(stdout, fmt, args); + if (amIEnabled==1) + { + if (!strcmp(myMode,"n")==0) + { + return ht_vfprintf(fopen(myLog, myMode), fmt, args); + } + } + else + { + return ht_vfprintf(stdout, fmt, args); + } } int ht_printf(const char *fmt, ...) @@ -978,4 +994,56 @@ return ret; } - +int initLogFile(int logEnabled, const char *logMode, const char *logFile) +{ + /* This handles the main output for PearPC. It is controlled by several + options in the config file. These specify a) how to handle output + b) log file name and c) mode for log file (erase or append) */ + + FILE * thelog; + int retval; + + if (logEnabled==1) + { + amIEnabled = logEnabled; + myLog = logFile; + /* So, the user wants to output to a log file + rather than the console. We need to sort this out */ + + /* Does the user want no output at all? */ + + if(strcmp(logMode,"n")==0) + { + myMode = "n"; + return 0; + } + + /* What mode does the user want it in? */ + if (strcmp(logMode,"e")==0) + { + /* Right, the user wants erase. Better do that now */ + thelog = fopen (logFile, "w"); + retval = ht_vfprintf(thelog, "\n\n", APPNAME" "APPVERSION" Log erasing...\n"); + if (!retval==0) + { + return 1; + } + myMode = "a"; + fclose (thelog); + return 0; + } + + if (strcmp(logMode,"a")==0) + { + /* OK, we want to append */ + thelog = fopen (logFile, "a"); + retval = ht_vfprintf(thelog, "", APPNAME" "APPVERSION" Log appending...\n"); + if (!retval==0) + { + return 1; + } + myMode = "a"; + fclose (thelog); + } + } +} diff -Naur pearpc.old/src/tools/snprintf.h pearpc.new/src/tools/snprintf.h --- pearpc.old/src/tools/snprintf.h 2004-05-05 23:48:13.000000000 +0100 +++ pearpc.new/src/tools/snprintf.h 2005-02-16 17:26:20.562500000 +0000 @@ -36,4 +36,5 @@ int ht_printf(const char *fmt, ...); int ht_vprintf(const char *fmt, va_list args); +int initLogFile(int logEnabled, const char *logMode, const char *logFile); #endif