Index: src/script.cpp =================================================================== RCS file: /cvsroot/xanadux/haret/haret-gnu/src/script.cpp,v retrieving revision 1.20 diff -u -r1.20 script.cpp --- src/script.cpp 9 Jul 2006 16:45:44 -0000 1.20 +++ src/script.cpp 16 Sep 2006 21:21:10 -0000 @@ -1383,6 +1383,10 @@ Output (L"PRINT [ [ ... []]]"); Output (L" Same as MESSAGE except that it outputs the text without decorations"); Output (L" directly to the network pipe."); + Output (L"LOG "); + Output (L" Log all output to specified file."); + Output (L"UNLOG"); + Output (L" Stop logging output to file."); Output (L"QUIT"); Output (L" Quit the remote session."); Output (L"SET "); @@ -1452,6 +1456,29 @@ else Output (L"No help on this topic available"); } + else if (IsToken (tok, "L|OG")) { + char *vn = strnew (get_token (&x)); + if (!vn) + { + Complain (C_ERROR ("line %d: file name expected"), line); + return true; + } + char fn[200]; + fnprepare (vn, fn, sizeof(fn)); + if (outputLogfile) + fclose(outputLogfile); + outputLogfile = fopen (fn, "a"); + if (!outputLogfile) { + Output (L"line %d: Cannot open file `%hs' for writing", line, fn); + return true; + } + delete [] vn; + } + else if (IsToken (tok, "UNL|OG")) { + if (outputLogfile) + fclose(outputLogfile); + outputLogfile = 0; + } else if (IsToken (tok, "Q|UIT")) return false; else Index: src/wince/output.cpp =================================================================== RCS file: /cvsroot/xanadux/haret/haret-gnu/src/wince/output.cpp,v retrieving revision 1.1 diff -u -r1.1 output.cpp --- src/wince/output.cpp 22 Mar 2006 21:12:54 -0000 1.1 +++ src/wince/output.cpp 16 Sep 2006 21:21:10 -0000 @@ -25,6 +25,8 @@ // message boxes elsewhere (such as to a socket) void (*output_fn) (wchar_t *msg, wchar_t *title) = NULL; +FILE *outputLogfile = NULL; + extern HINSTANCE hInst; extern HWND MainWindow; @@ -126,11 +128,16 @@ void Output (const wchar_t *format, ...) { wchar_t buffer [512]; + char buffer2[512]; va_list args; va_start (args, format); _vsnwprintf (buffer, sizeof (buffer) / sizeof (wchar_t), format, args); va_end (args); + if (outputLogfile) { + WideCharToMultiByte(CP_ACP,0,buffer,sizeof(buffer)/sizeof(wchar_t),buffer2,sizeof(buffer2),NULL,NULL); + fprintf (outputLogfile, "%s\r\n", buffer2); + } if (output_fn) output_fn (buffer, NULL); } Index: include/output.h =================================================================== RCS file: /cvsroot/xanadux/haret/haret-gnu/include/output.h,v retrieving revision 1.1 diff -u -r1.1 output.h --- include/output.h 22 Mar 2006 21:14:51 -0000 1.1 +++ include/output.h 16 Sep 2006 21:21:10 -0000 @@ -12,6 +12,10 @@ #define C_WARN(s) L"<3>" L##s #define C_ERROR(s) L"<0>" L##s +#include + +extern FILE *outputLogfile; + /* Log something to the on-screen log. */ extern void Log (const wchar_t *format, ...); /* Complain about something. You can prepend one of the C_XXX macros