]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Turn #ifdef LOG into a command-line option for debugging use
authorSimon Tatham <anakin@pobox.com>
Tue, 30 Nov 1999 11:22:30 +0000 (11:22 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 30 Nov 1999 11:22:30 +0000 (11:22 +0000)
[originally from svn r330]

putty.h
terminal.c
window.c

diff --git a/putty.h b/putty.h
index f4944aaf463b6fe621c663bea36622a535711db5..7e7eca61661bba694122005d6536f30aea5a3905 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -71,6 +71,8 @@ typedef enum {
 
 GLOBAL Unscroll_Trigger unscroll_event;
 
+GLOBAL char *logfile;
+
 #define WM_NETEVENT  (WM_USER + 1)
 
 typedef enum {
index 444f243d54974986032082502ad8df983cd83e76..01fe663c40e7d470f17d5b464c5ec67f46cc0f3c 100644 (file)
@@ -578,13 +578,15 @@ void term_out(void) {
     int c;
 
     while ( (c = inbuf_getc()) != -1) {
-#ifdef LOG
-       {
+        /*
+         * Optionally log the session traffic to a file. Useful for
+         * debugging and possibly also useful for actual logging.
+         */
+       if (logfile) {
            static FILE *fp = NULL;
-           if (!fp) fp = fopen("putty.log", "wb");
+           if (!fp) fp = fopen(logfile, "wb");
            if (fp) fputc (c, fp);
        }
-#endif
        if( termstate < DO_CTRLS && (c&0x60) == 0 ) {
            switch (c) {
              case '\005':             /* terminal type query */
index fd46be4c296fa07dc2b8f3e3ac519f95527ac046..703dec39765b86aeb7242d1ffd59746d97a5929e 100644 (file)
--- a/window.c
+++ b/window.c
@@ -129,6 +129,11 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) {
                tolower(p[2]) == 'h') {
                default_protocol = cfg.protocol = PROT_SSH;
                default_port = cfg.port = 22;
+           } else if (q == p + 3 &&
+               tolower(p[0]) == 'l' &&
+               tolower(p[1]) == 'o' &&
+               tolower(p[2]) == 'g') {
+                logfile = "putty.log";
            }
            p = q + strspn(q, " \t");
        }