More compiler warning message maintenance
[privoxy.git] / w32log.c
1 const char w32log_rcs[] = "$Id: w32log.c,v 1.22 2002/03/24 12:48:23 jongfoster Exp $";
2 /*********************************************************************
3  *
4  * File        :  $Source: /cvsroot/ijbswa/current/w32log.c,v $
5  *
6  * Purpose     :  Functions for creating and destroying the log window,
7  *                ouputting strings, processing messages and so on.
8  *
9  * Copyright   :  Written by and Copyright (C) 2001-2002 members of
10  *                the Privoxy team.  http://www.privoxy.org/
11  *
12  *                Written by and Copyright (C) 1999 Adam Lock
13  *                <locka@iol.ie>
14  *
15  *                This program is free software; you can redistribute it 
16  *                and/or modify it under the terms of the GNU General
17  *                Public License as published by the Free Software
18  *                Foundation; either version 2 of the License, or (at
19  *                your option) any later version.
20  *
21  *                This program is distributed in the hope that it will
22  *                be useful, but WITHOUT ANY WARRANTY; without even the
23  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
24  *                PARTICULAR PURPOSE.  See the GNU General Public
25  *                License for more details.
26  *
27  *                The GNU General Public License should be included with
28  *                this file.  If not, you can view it at
29  *                http://www.gnu.org/copyleft/gpl.html
30  *                or write to the Free Software Foundation, Inc., 59
31  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
32  *
33  * Revisions   :
34  *    $Log: w32log.c,v $
35  *    Revision 1.22  2002/03/24 12:48:23  jongfoster
36  *    Fixing doc links
37  *
38  *    Revision 1.21  2002/03/24 12:07:35  jongfoster
39  *    Consistern name for filters file
40  *
41  *    Revision 1.20  2002/03/24 12:03:47  jongfoster
42  *    Name change
43  *
44  *    Revision 1.19  2002/01/17 21:04:17  jongfoster
45  *    Replacing hard references to the URL of the config interface
46  *    with #defines from project.h
47  *
48  *    Revision 1.18  2001/11/30 23:37:24  jongfoster
49  *    Renaming the Win32 config file to config.txt - this is almost the
50  *    same as the corresponding UNIX name "config"
51  *
52  *    Revision 1.17  2001/11/16 00:46:31  jongfoster
53  *    Fixing compiler warnings
54  *
55  *    Revision 1.16  2001/08/01 19:58:12  jongfoster
56  *    Fixing documentation filenames in help menu, and making status
57  *    option work without needing the "Junkbuster Status.URL" file.
58  *
59  *    Revision 1.15  2001/07/30 22:08:36  jongfoster
60  *    Tidying up #defines:
61  *    - All feature #defines are now of the form FEATURE_xxx
62  *    - Permanently turned off WIN_GUI_EDIT
63  *    - Permanently turned on WEBDAV and SPLIT_PROXY_ARGS
64  *
65  *    Revision 1.14  2001/07/29 18:47:05  jongfoster
66  *    Adding missing #include "loadcfg.h"
67  *
68  *    Revision 1.13  2001/07/19 19:15:14  haroon
69  *    - Added a FIXME for EditFile but didn't fix :-)
70  *
71  *    Revision 1.12  2001/07/13 14:04:59  oes
72  *    Removed all #ifdef PCRS
73  *
74  *    Revision 1.11  2001/06/07 23:08:12  jongfoster
75  *    Forward and ACL edit options removed.
76  *
77  *    Revision 1.10  2001/05/31 21:37:11  jongfoster
78  *    GUI changes to rename "permissions file" to "actions file".
79  *
80  *    Revision 1.9  2001/05/31 17:33:13  oes
81  *
82  *    CRLF -> LF
83  *
84  *    Revision 1.8  2001/05/29 09:50:24  jongfoster
85  *    Unified blocklist/imagelist/permissionslist.
86  *    File format is still under discussion, but the internal changes
87  *    are (mostly) done.
88  *
89  *    Also modified interceptor behaviour:
90  *    - We now intercept all URLs beginning with one of the following
91  *      prefixes (and *only* these prefixes):
92  *        * http://i.j.b/
93  *        * http://ijbswa.sf.net/config/
94  *        * http://ijbswa.sourceforge.net/config/
95  *    - New interceptors "home page" - go to http://i.j.b/ to see it.
96  *    - Internal changes so that intercepted and fast redirect pages
97  *      are not replaced with an image.
98  *    - Interceptors now have the option to send a binary page direct
99  *      to the client. (i.e. ijb-send-banner uses this)
100  *    - Implemented show-url-info interceptor.  (Which is why I needed
101  *      the above interceptors changes - a typical URL is
102  *      "http://i.j.b/show-url-info?url=www.somesite.com/banner.gif".
103  *      The previous mechanism would not have intercepted that, and
104  *      if it had been intercepted then it then it would have replaced
105  *      it with an image.)
106  *
107  *    Revision 1.7  2001/05/26 01:26:34  jongfoster
108  *    New #define, WIN_GUI_EDIT, enables the (embryonic) Win32 GUI editor.
109  *    This #define cannot be set from ./configure - there's no point, it
110  *    doesn't work yet.  See feature request # 425722
111  *
112  *    Revision 1.6  2001/05/26 00:31:30  jongfoster
113  *    Fixing compiler warning about comparing signed/unsigned.
114  *
115  *    Revision 1.5  2001/05/26 00:28:36  jongfoster
116  *    Automatic reloading of config file.
117  *    Removed obsolete SIGHUP support (Unix) and Reload menu option (Win32).
118  *    Most of the global variables have been moved to a new
119  *    struct configuration_spec, accessed through csp->config->globalname
120  *    Most of the globals remaining are used by the Win32 GUI.
121  *
122  *    Revision 1.4  2001/05/22 18:56:28  oes
123  *    CRLF -> LF
124  *
125  *    Revision 1.3  2001/05/20 15:07:54  jongfoster
126  *    File is now ignored if _WIN_CONSOLE is defined.
127  *
128  *    Revision 1.2  2001/05/20 01:21:20  jongfoster
129  *    Version 2.9.4 checkin.
130  *    - Merged popupfile and cookiefile, and added control over PCRS
131  *      filtering, in new "permissionsfile".
132  *    - Implemented LOG_LEVEL_FATAL, so that if there is a configuration
133  *      file error you now get a message box (in the Win32 GUI) rather
134  *      than the program exiting with no explanation.
135  *    - Made killpopup use the PCRS MIME-type checking and HTTP-header
136  *      skipping.
137  *    - Removed tabs from "config"
138  *    - Moved duplicated url parsing code in "loaders.c" to a new funcition.
139  *    - Bumped up version number.
140  *
141  *    Revision 1.1.1.1  2001/05/15 13:59:07  oes
142  *    Initial import of version 2.9.3 source tree
143  *
144  *
145  *********************************************************************/
146 \f
147
148 #include "config.h"
149
150 #include <assert.h>
151 #include <stdio.h>
152
153 #include <windows.h>
154 #include <richedit.h>
155
156 #include "project.h"
157 #include "w32log.h"
158 #include "w32taskbar.h"
159 #include "win32.h"
160 #include "w32res.h"
161 #include "jcc.h"
162 #include "miscutil.h"
163 #include "errlog.h"
164 #include "loadcfg.h"
165
166 const char w32res_h_rcs[] = W32RES_H_VERSION;
167
168 #ifdef __MINGW32__
169 #include "cygwin.h"
170 const char cygwin_h_rcs[] = CYGWIN_H_VERSION;
171 #endif
172
173 const char w32log_h_rcs[] = W32LOG_H_VERSION;
174
175 #ifndef _WIN_CONSOLE /* entire file */
176
177 /*
178  * Timers and the various durations
179  */
180 #define TIMER_ANIM_ID               1
181 #define TIMER_ANIM_TIME             100
182 #define TIMER_ANIMSTOP_ID           2
183 #define TIMER_ANIMSTOP_TIME         1000
184 #define TIMER_CLIPBUFFER_ID         3
185 #define TIMER_CLIPBUFFER_TIME       1000
186 #define TIMER_CLIPBUFFER_FORCE_ID   4
187 #define TIMER_CLIPBUFFER_FORCE_TIME 5000
188
189 /*
190  * Styles of text that can be output
191  */
192 #define STYLE_NONE      0
193 #define STYLE_HIGHLIGHT 1
194 #define STYLE_LINK      2
195 #define STYLE_HEADER    3
196
197 /*
198  * Number of frames of animation in tray activity sequence
199  */
200 #define ANIM_FRAMES 8
201
202 #define DEFAULT_MAX_BUFFER_LINES    200
203 #define DEFAULT_LOG_FONT_NAME       "MS Sans Serif"
204 #define DEFAULT_LOG_FONT_SIZE       8
205
206 /*
207  * These values affect the way the log window behaves, they should be read
208  * from a file but for the moment, they are hardcoded here. Some options are
209  * configurable through the UI.
210  */
211
212 /* Indicates whether task bar shows activity animation */
213 BOOL g_bShowActivityAnimation = 1;
214
215 /* Indicates if the log window appears on the task bar */
216 BOOL g_bShowOnTaskBar = 0;
217
218 /* Indicates whether closing the log window really just hides it */
219 BOOL g_bCloseHidesWindow = 1;
220
221 /* Indicates if messages are logged at all */
222 BOOL g_bLogMessages = 1;
223
224 /* Indicates whether log messages are highlighted */
225 BOOL g_bHighlightMessages = 1;
226
227 /* Indicates if buffer is limited in size */
228 BOOL g_bLimitBufferSize = 1;
229
230 /* Maximum number of lines allowed in buffer when limited */
231 int g_nMaxBufferLines = DEFAULT_MAX_BUFFER_LINES;
232
233 /* Font to use */
234 char g_szFontFaceName[255] = DEFAULT_LOG_FONT_NAME;
235
236 /* Size of font to use */
237 int g_nFontSize = DEFAULT_LOG_FONT_SIZE;
238
239
240 /* FIXME: this is a kludge */
241
242 const char * g_actions_file = NULL;
243 const char * g_re_filterfile = NULL;
244 #ifdef FEATURE_TRUST
245 const char * g_trustfile = NULL;
246 #endif /* def FEATURE_TRUST */
247
248 /* FIXME: end kludge */
249
250
251 #ifdef REGEX
252 /* Regular expression for detected URLs */
253 #define RE_URL "http:[^ \n\r]*"
254
255 /*
256  * Regular expressions that are used to perform highlight in the log window
257  */
258 static struct _Pattern
259 {
260    const char *str;
261    int style;
262    regex_t buffer;
263 } patterns_to_highlight[] =
264 {
265    /* url headers */
266    { RE_URL,                STYLE_LINK },
267 /* { "[a-zA-Z0-9]+\\.[a-zA-Z0-9]+\\.[a-zA-Z0-9]+\\.[^ \n\r]*", STYLE_LINK }, */
268    /* interesting text to highlight */
269    { "crunch!",           STYLE_HIGHLIGHT },
270    /* http headers */
271    { "referer:",            STYLE_HEADER },
272    { "proxy-connection:",   STYLE_HEADER },
273    { "proxy-agent:",        STYLE_HEADER },
274    { "user-agent:",         STYLE_HEADER },
275    { "host:",               STYLE_HEADER },
276    { "accept:",             STYLE_HEADER },
277    { "accept-encoding:",    STYLE_HEADER },
278    { "accept-language:",    STYLE_HEADER },
279    { "accept-charset:",     STYLE_HEADER },
280    { "accept-ranges:",      STYLE_HEADER },
281    { "date:",               STYLE_HEADER },
282    { "cache-control:",      STYLE_HEADER },
283    { "cache-last-checked:", STYLE_HEADER },
284    { "connection:",         STYLE_HEADER },
285    { "content-type",        STYLE_HEADER },
286    { "content-length",      STYLE_HEADER },
287    { "cookie",              STYLE_HEADER },
288    { "last-modified:",      STYLE_HEADER },
289    { "pragma:",             STYLE_HEADER },
290    { "server:",             STYLE_HEADER },
291    { "etag:",               STYLE_HEADER },
292    { "expires:",            STYLE_HEADER },
293    { "warning:",            STYLE_HEADER },
294    /* this is the terminator statement - do not delete! */
295    { NULL,                  STYLE_NONE }
296 };
297 #endif /* def REGEX */
298
299
300 /*
301  * Public variables
302  */
303 HWND g_hwndLogFrame;
304
305 /*
306  * Private variables
307  */
308 static CRITICAL_SECTION g_criticalsection;
309 static HWND g_hwndTray;
310 static HWND g_hwndLogBox;
311 static WNDPROC g_fnLogBox;
312 static HICON g_hiconAnim[ANIM_FRAMES];
313 static HICON g_hiconIdle;
314 static HICON g_hiconApp;
315 static int g_nAnimFrame;
316 static BOOL g_bClipPending = FALSE;
317 static int g_nRichEditVersion = 0;
318
319 /*
320  * Private functions
321  */
322 static HWND CreateLogWindow(HINSTANCE hInstance, int nCmdShow);
323 static HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance);
324 static LRESULT CALLBACK LogWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
325 static LRESULT CALLBACK LogOwnerWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
326 static LRESULT CALLBACK LogRichEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
327 static BOOL InitRichEdit(void);
328 static void LogClipBuffer(void);
329 static void LogCreatePatternMatchingBuffers(void);
330 static void LogDestroyPatternMatchingBuffers(void);
331 static int LogPutStringNoMatch(const char *pszText, int style);
332
333
334 /*********************************************************************
335  *
336  * Function    :  InitLogWindow
337  *
338  * Description :  Initialise the log window.
339  *
340  * Parameters  :  None
341  *
342  * Returns     :  Always TRUE (there should be error checking on the resources).
343  *
344  *********************************************************************/
345 BOOL InitLogWindow(void)
346 {
347    int i;
348
349    /* Load the icons */
350    g_hiconIdle = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IDLE));
351    for (i = 0; i < ANIM_FRAMES; i++)
352    {
353       g_hiconAnim[i] = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ANIMATED1 + i));
354    }
355    g_hiconApp = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAINICON));
356
357    /* Create the user interface */
358    g_hwndLogFrame = CreateLogWindow(g_hInstance, g_nCmdShow);
359    g_hwndTray = CreateTrayWindow(g_hInstance);
360    TrayAddIcon(g_hwndTray, 1, g_hiconApp, "Privoxy");
361
362    /* Create pattern matching buffers (for highlighting */
363    LogCreatePatternMatchingBuffers();
364
365    /* Create a critical section to protect multi-threaded access to certain things */
366    InitializeCriticalSection(&g_criticalsection);
367
368    return TRUE;
369
370 }
371
372
373 /*********************************************************************
374  *
375  * Function    :  TermLogWindow
376  *
377  * Description :  Cleanup the logwindow.
378  *
379  * Parameters  :  None
380  *
381  * Returns     :  N/A
382  *
383  *********************************************************************/
384 void TermLogWindow(void)
385 {
386    int i;
387
388    LogDestroyPatternMatchingBuffers();
389
390    TrayDeleteIcon(g_hwndTray, 1);
391    DeleteObject(g_hiconApp);
392    DeleteObject(g_hiconIdle);
393    for (i = 0; i < ANIM_FRAMES; i++)
394    {
395       DeleteObject(g_hiconAnim[i]);
396    }
397
398 }
399
400
401 /*********************************************************************
402  *
403  * Function    :  LogCreatePatternMatchingBuffers
404  *
405  * Description :  Compile the pattern matching buffers.
406  *
407  * Parameters  :  None
408  *
409  * Returns     :  N/A
410  *
411  *********************************************************************/
412 void LogCreatePatternMatchingBuffers(void)
413 {
414 #ifdef REGEX
415    int i;
416    for (i = 0; patterns_to_highlight[i].str != NULL; i++)
417    {
418       regcomp(&patterns_to_highlight[i].buffer, patterns_to_highlight[i].str, REG_ICASE);
419    }
420 #endif
421
422 }
423
424
425 /*********************************************************************
426  *
427  * Function    :  LogDestroyPatternMatchingBuffers
428  *
429  * Description :  Free up the pattern matching buffers.
430  *
431  * Parameters  :  None
432  *
433  * Returns     :  N/A
434  *
435  *********************************************************************/
436 void LogDestroyPatternMatchingBuffers(void)
437 {
438 #ifdef REGEX
439    int i;
440    for (i = 0; patterns_to_highlight[i].str != NULL; i++)
441    {
442       regfree(&patterns_to_highlight[i].buffer);
443    }
444 #endif
445
446 }
447
448
449 /*********************************************************************
450  *
451  * Function    :  LogGetURLUnderCursor
452  *
453  * Description :  Returns the URL from under the cursor (remember to free it!).
454  *
455  * Parameters  :  None
456  *
457  * Returns     :  NULL or a pointer to an URL string.
458  *
459  *********************************************************************/
460 char *LogGetURLUnderCursor(void)
461 {
462    char *szResult = NULL;
463 #ifdef REGEX
464    regex_t re;
465    POINT ptCursor;
466    POINTL ptl;
467    DWORD nPos;
468    DWORD nWordStart = 0;
469    DWORD nWordEnd = 0;
470
471    regcomp(&re, RE_URL, REG_ICASE);
472
473    /* Get the position of the cursor over the text window */
474    GetCursorPos(&ptCursor);
475    ScreenToClient(g_hwndLogBox, &ptCursor);
476    ptl.x = ptCursor.x;
477    ptl.y = ptCursor.y;
478
479    /* Search backwards and fowards to obtain the word that is highlighted */
480    nPos = LOWORD(SendMessage(g_hwndLogBox, EM_CHARFROMPOS, 0, (LPARAM) &ptl));
481    nWordStart = SendMessage(g_hwndLogBox, EM_FINDWORDBREAK, WB_LEFT, nPos);
482    nWordEnd = SendMessage(g_hwndLogBox, EM_FINDWORDBREAK, WB_RIGHTBREAK, nPos);
483
484    /* Compare the string to the pattern */
485    if (nWordEnd > nWordStart)
486    {
487       TEXTRANGE range;
488       regmatch_t match;
489
490       range.chrg.cpMin = nWordStart;
491       range.chrg.cpMax = nWordEnd;
492       range.lpstrText = (LPSTR)zalloc(nWordEnd - nWordStart + 1);
493       SendMessage(g_hwndLogBox, EM_GETTEXTRANGE, 0, (LPARAM) &range);
494
495       if (regexec(&re, range.lpstrText, 1, &match, 0) == 0)
496       {
497          szResult = range.lpstrText;
498       }
499       else
500       {
501          free(range.lpstrText);
502       }
503
504       regfree(&re);
505    }
506 #endif
507    return szResult;
508
509 }
510
511
512 /*********************************************************************
513  *
514  * Function    :  LogPutString
515  *
516  * Description :  Inserts text into the logging window.  This is really
517  *                a REGEXP aware wrapper function to `LogPutStringNoMatch'.
518  *
519  * Parameters  :
520  *          1  :  pszText = pointer to string going to the log window
521  *
522  * Returns     :  1 => success, else the return code from `LogPutStringNoMatch'.
523  *                FIXME: this is backwards to the rest of IJB and to common
524  *                programming practice.  Please use 0 => success instead.
525  *
526  *********************************************************************/
527 int LogPutString(const char *pszText)
528 {
529 #ifdef REGEX
530    int i;
531 #endif
532    int result = 0;
533
534    if (pszText == NULL || strlen(pszText) == 0)
535    {
536       return 1;
537    }
538
539    if (!g_bLogMessages)
540    {
541       return 1;
542    }
543
544    /* Critical section stops multiple threads doing nasty interactions that
545     * foul up the highlighting and output.
546     */
547    EnterCriticalSection(&g_criticalsection);
548
549 #ifdef REGEX
550    if (g_bHighlightMessages)
551    {
552       regmatch_t match;
553
554       /* First things first, regexp scan for various things that we would like highlighted */
555       for (i = 0; patterns_to_highlight[i].str != NULL; i++)
556       {
557          if (regexec(&patterns_to_highlight[i].buffer, pszText, 1, &match, 0) == 0)
558          {
559             char *pszBefore = NULL;
560             char *pszMatch = NULL;
561             char *pszAfter = NULL;
562             int nMatchSize;
563
564             /* Split the string up into pieces representing the strings, before
565                at and after the matching pattern
566              */
567             if (match.rm_so > 0)
568             {
569                pszBefore = (char *)malloc((match.rm_so + 1) * sizeof(char));
570                memset(pszBefore, 0, (match.rm_so + 1) * sizeof(char));
571                strncpy(pszBefore, pszText, match.rm_so);
572             }
573             if (match.rm_eo < (regoff_t)strlen(pszText))
574             {
575                pszAfter = strdup(&pszText[match.rm_eo]);
576             }
577             nMatchSize = match.rm_eo - match.rm_so;
578             pszMatch = (char *)malloc(nMatchSize + 1);
579             strncpy(pszMatch, &pszText[match.rm_so], nMatchSize);
580             pszMatch[nMatchSize] = '\0';
581
582             /* Recursively call LogPutString */
583             if (pszBefore)
584             {
585                LogPutString(pszBefore);
586                free(pszBefore);
587             }
588             if (pszMatch)
589             {
590                LogPutStringNoMatch(pszMatch, patterns_to_highlight[i].style);
591                free(pszMatch);
592             }
593             if (pszAfter)
594             {
595                LogPutString(pszAfter);
596                free(pszAfter);
597             }
598
599             result = 1;
600             goto end;
601          }
602       }
603    }
604 #endif
605
606    result = LogPutStringNoMatch(pszText, STYLE_NONE);
607
608 #ifdef REGEX
609 end:
610 #endif
611    LeaveCriticalSection(&g_criticalsection);
612
613    return result;
614
615 }
616
617
618 /*********************************************************************
619  *
620  * Function    :  LogPutStringNoMatch
621  *
622  * Description :  Puts a string into the logging window.
623  *
624  * Parameters  :
625  *          1  :  pszText = pointer to string going to the log window
626  *          2  :  style = STYLE_NONE, STYLE_HEADER, STYLE_HIGHLIGHT, or STYLE_LINK
627  *
628  * Returns     :  Always 1 => success.
629  *                FIXME: this is backwards to the rest of IJB and to common
630  *                programming practice.  Please use 0 => success instead.
631  *
632  *********************************************************************/
633 int LogPutStringNoMatch(const char *pszText, int style)
634 {
635    CHARRANGE range;
636    CHARFORMAT format;
637    int nTextLength;
638
639    assert(g_hwndLogBox);
640    if (g_hwndLogBox == NULL)
641    {
642       return 1;
643    }
644
645    /* TODO preserve existing selection */
646
647    /* Go to the end of the text */
648    nTextLength = GetWindowTextLength(g_hwndLogBox);
649    range.cpMin = nTextLength;
650    range.cpMax = nTextLength;
651    SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range);
652
653    /* Apply a formatting style */
654    memset(&format, 0, sizeof(format));
655    format.cbSize = sizeof(format);
656    format.dwMask = CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT | CFM_ITALIC | CFM_COLOR | CFM_FACE | CFM_SIZE;
657    format.yHeight = (g_nFontSize * 1440) / 72;
658    strcpy(format.szFaceName, g_szFontFaceName);
659    if (style == STYLE_NONE)
660    {
661       /* DO NOTHING */
662       format.dwEffects |= CFE_AUTOCOLOR;
663    }
664    else if (style == STYLE_HEADER)
665    {
666       format.dwEffects |= CFE_AUTOCOLOR | CFE_ITALIC;
667    }
668    else if (style == STYLE_HIGHLIGHT)
669    {
670       format.dwEffects |= CFE_AUTOCOLOR | CFE_BOLD;
671    }
672    else if (style == STYLE_LINK)
673    {
674       format.dwEffects |= CFE_UNDERLINE;
675       format.crTextColor = RGB(0, 0, 255);
676    }
677    SendMessage(g_hwndLogBox, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &format);
678
679    /* Append text to the end */
680    SendMessage(g_hwndLogBox, EM_REPLACESEL, FALSE, (LPARAM) pszText);
681
682    /* TODO Restore the old selection */
683
684    /* Purge buffer */
685    if (strchr(pszText, '\n') != NULL)
686    {
687       SetTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_ID, TIMER_CLIPBUFFER_TIME, NULL);
688       if (!g_bClipPending)
689       {
690          /* Set the force clip timer going. This timer ensures clipping is done
691             intermittently even when there is a sustained burst of logging
692          */
693          SetTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_FORCE_ID, TIMER_CLIPBUFFER_FORCE_TIME, NULL);
694       }
695       g_bClipPending = TRUE;
696    }
697
698    return 1;
699
700 }
701
702
703 /*********************************************************************
704  *
705  * Function    :  LogShowActivity
706  *
707  * Description :  Start the spinner.
708  *
709  * Parameters  :  None
710  *
711  * Returns     :  N/A
712  *
713  *********************************************************************/
714 void LogShowActivity(void)
715 {
716    /* Start some activity timers */
717    if (g_bShowActivityAnimation)
718    {
719       SetTimer(g_hwndLogFrame, TIMER_ANIM_ID, TIMER_ANIM_TIME, NULL);
720       SetTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID, TIMER_ANIMSTOP_TIME, NULL);
721    }
722
723 }
724
725
726 /*********************************************************************
727  *
728  * Function    :  LogClipBuffer
729  *
730  * Description :  Prunes old lines from the log.
731  *
732  * Parameters  :  None
733  *
734  * Returns     :  N/A
735  *
736  *********************************************************************/
737 void LogClipBuffer(void)
738 {
739    int nLines = SendMessage(g_hwndLogBox, EM_GETLINECOUNT, 0, 0);
740    if (g_bLimitBufferSize && nLines > g_nMaxBufferLines)
741    {
742       /* Compute the range representing the lines to be deleted */
743       LONG nLastLineToDelete = nLines - g_nMaxBufferLines;
744       LONG nLastChar = SendMessage(g_hwndLogBox, EM_LINEINDEX, nLastLineToDelete, 0);
745       CHARRANGE range;
746       range.cpMin = 0;
747       range.cpMax = nLastChar;
748
749       /* TODO get current selection */
750
751       /* TODO adjust and clip old selection against range to be deleted */
752
753       /* Select range and erase it (turning off autoscroll to prevent
754          nasty scrolling) */
755       SendMessage(g_hwndLogBox, EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL);
756       SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range);
757       SendMessage(g_hwndLogBox, EM_REPLACESEL, FALSE, (LPARAM) "");
758       SendMessage(g_hwndLogBox, EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL);
759
760       /* Restore old selection */
761    }
762
763 }
764
765
766 /*********************************************************************
767  *
768  * Function    :  CreateHiddenLogOwnerWindow
769  *
770  * Description :  Creates a hidden owner window that stops the log
771  *                window appearing in the task bar.
772  *
773  * Parameters  :
774  *          1  :  hInstance = application's instance handle
775  *
776  * Returns     :  Handle to newly created window.
777  *
778  *********************************************************************/
779 HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance)
780 {
781    static const char *szWndName = "PrivoxyLogOwner";
782    WNDCLASS wc;
783    HWND hwnd;
784
785    wc.style          = 0;
786    wc.lpfnWndProc    = LogOwnerWindowProc;
787    wc.cbClsExtra     = 0;
788    wc.cbWndExtra     = 0;
789    wc.hInstance      = hInstance;
790    wc.hIcon          = 0;
791    wc.hCursor        = 0;
792    wc.hbrBackground  = 0;
793    wc.lpszMenuName   = 0;
794    wc.lpszClassName  = szWndName;
795
796    RegisterClass(&wc);
797
798    hwnd = CreateWindow(szWndName, szWndName,
799       WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
800       CW_USEDEFAULT, NULL, NULL, hInstance, NULL );
801
802    return hwnd;
803
804 }
805
806
807 /*********************************************************************
808  *
809  * Function    :  LogOwnerWindowProc
810  *
811  * Description :  Dummy procedure that does nothing special.
812  *
813  * Parameters  :
814  *          1  :  hwnd = window handle
815  *          2  :  uMsg = message number
816  *          3  :  wParam = first param for this message
817  *          4  :  lParam = next param for this message
818  *
819  * Returns     :  Same as `DefWindowProc'.
820  *
821  *********************************************************************/
822 LRESULT CALLBACK LogOwnerWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
823 {
824    return DefWindowProc(hwnd, uMsg, wParam, lParam);
825
826 }
827
828
829 /*********************************************************************
830  *
831  * Function    :  CreateLogWindow
832  *
833  * Description :  Create the logging window.
834  *
835  * Parameters  :
836  *          1  :  hInstance = application's instance handle
837  *          2  :  nCmdShow = window show value (MIN, MAX, NORMAL, etc...)
838  *
839  * Returns     :  Handle to newly created window.
840  *
841  *********************************************************************/
842 HWND CreateLogWindow(HINSTANCE hInstance, int nCmdShow)
843 {
844    static const char *szWndName = "PrivoxyLogWindow";
845    static const char *szWndTitle = "Privoxy";
846
847    HWND hwnd = NULL;
848    HWND hwndOwner = (g_bShowOnTaskBar) ? NULL : CreateHiddenLogOwnerWindow(hInstance);
849    RECT rcClient;
850    WNDCLASSEX wc;
851
852    memset(&wc, 0, sizeof(wc));
853    wc.cbSize         = sizeof(wc);
854    wc.style          = CS_DBLCLKS;
855    wc.lpfnWndProc    = LogWindowProc;
856    wc.cbClsExtra     = 0;
857    wc.cbWndExtra     = 0;
858    wc.hInstance      = hInstance;
859    wc.hIcon          = g_hiconApp;
860    wc.hCursor        = 0;
861    wc.hbrBackground  = 0;
862    wc.lpszMenuName   = MAKEINTRESOURCE(IDR_LOGVIEW);
863    wc.lpszClassName  = szWndName;
864    wc.hbrBackground  = GetStockObject(WHITE_BRUSH);
865    RegisterClassEx(&wc);
866
867    hwnd = CreateWindowEx(WS_EX_APPWINDOW, szWndName, szWndTitle,
868       WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
869       CW_USEDEFAULT, hwndOwner, NULL, hInstance, NULL);
870
871    /* Now create a child list box */
872    GetClientRect(hwnd, &rcClient);
873
874    /* Create a rich edit control */
875    InitRichEdit();
876    g_hwndLogBox = CreateWindowEx(0, (g_nRichEditVersion == 0x0100) ? "RichEdit" : RICHEDIT_CLASS, "",
877       ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
878       rcClient.left, rcClient.top, rcClient.right, rcClient.bottom,
879       hwnd, NULL, hInstance, NULL);
880 /* SendMessage(g_hwndLogBox, EM_SETWORDWRAPMODE, 0, 0); */
881
882    /* Subclass the control to catch certain messages */
883    g_fnLogBox = (WNDPROC) GetWindowLong(g_hwndLogBox, GWL_WNDPROC);
884    SetWindowLong(g_hwndLogBox, GWL_WNDPROC, (LONG) LogRichEditProc);
885
886    /* Minimizing looks stupid when the log window is not on the task bar, so hide instead */
887    if (!g_bShowOnTaskBar &&
888          (nCmdShow == SW_SHOWMINIMIZED ||
889           nCmdShow == SW_MINIMIZE ||
890           nCmdShow == SW_SHOWMINNOACTIVE))
891    {
892       nCmdShow = SW_HIDE;
893    }
894
895    ShowWindow(hwnd, nCmdShow);
896    UpdateWindow(hwnd);
897
898    GetClientRect(g_hwndLogFrame, &rcClient);
899    SetWindowPos(g_hwndLogBox, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_NOZORDER);
900
901    return hwnd;
902
903 }
904
905
906 /*********************************************************************
907  *
908  * Function    :  InitRichEdit
909  *
910  * Description :  Initialise the rich edit control library.
911  *
912  * Parameters  :  None
913  *
914  * Returns     :  TRUE => success, FALSE => failure.
915  *                FIXME: this is backwards to the rest of IJB and to common
916  *                programming practice.  Please use 0 => success instead.
917  *
918  *********************************************************************/
919 BOOL InitRichEdit(void)
920 {
921    static HINSTANCE hInstRichEdit;
922    if (hInstRichEdit == NULL)
923    {
924       g_nRichEditVersion = 0;
925       hInstRichEdit = LoadLibraryA("RICHED20.DLL");
926       if (hInstRichEdit)
927       {
928          g_nRichEditVersion = _RICHEDIT_VER;
929       }
930       else
931       {
932          hInstRichEdit = LoadLibraryA("RICHED32.DLL");
933          if (hInstRichEdit)
934          {
935             g_nRichEditVersion = 0x0100;
936          }
937       }
938    }
939    return (hInstRichEdit != NULL) ? TRUE : FALSE;
940
941 }
942
943
944 /*********************************************************************
945  *
946  * Function    :  ShowLogWindow
947  *
948  * Description :  Shows or hides the log window.  We will also raise the
949  *                window on a show command in case it is buried.
950  *
951  * Parameters  :
952  *          1  :  bShow = TRUE to show, FALSE to mimize/hide
953  *
954  * Returns     :  N/A
955  *
956  *********************************************************************/
957 void ShowLogWindow(BOOL bShow)
958 {
959    if (bShow)
960    {
961       SetForegroundWindow(g_hwndLogFrame);
962       SetWindowPos(g_hwndLogFrame, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
963    }
964    else if (g_bShowOnTaskBar)
965    {
966       ShowWindow(g_hwndLogFrame, SW_MINIMIZE);
967    }
968    else
969    {
970       ShowWindow(g_hwndLogFrame, SW_HIDE);
971    }
972
973 }
974
975
976 /*********************************************************************
977  *
978  * Function    :  EditFile
979  *
980  * Description :  Opens the specified setting file for editing.
981  * FIXME: What if the file has no associated application. Check for return values
982 *        from ShellExecute??
983  *
984  * Parameters  :
985  *          1  :  filename = filename from the config (aka config.txt) file.
986  *
987  * Returns     :  N/A
988  *
989  *********************************************************************/
990 void EditFile(const char *filename)
991 {
992    if (filename)
993    {
994       ShellExecute(g_hwndLogFrame, "open", filename, NULL, NULL, SW_SHOWNORMAL);
995    }
996
997 }
998
999
1000 /*--------------------------------------------------------------------------*/
1001 /* Windows message handlers                                                 */
1002 /*--------------------------------------------------------------------------*/
1003
1004
1005 /*********************************************************************
1006  *
1007  * Function    :  OnLogRButtonUp
1008  *
1009  * Description :  Handler for WM_RBUTTONUP messages.
1010  *
1011  * Parameters  :
1012  *          1  :  nModifier = wParam from mouse message (unused)
1013  *          2  :  x = x coordinate of the mouse event
1014  *          3  :  y = y coordinate of the mouse event
1015  *
1016  * Returns     :  N/A
1017  *
1018  *********************************************************************/
1019 void OnLogRButtonUp(int nModifier, int x, int y)
1020 {
1021    HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_POPUP_SELECTION));
1022    if (hMenu != NULL)
1023    {
1024       HMENU hMenuPopup = GetSubMenu(hMenu, 0);
1025
1026       /* Check if there is a selection */
1027       CHARRANGE range;
1028       SendMessage(g_hwndLogBox, EM_EXGETSEL, 0, (LPARAM) &range);
1029       if (range.cpMin == range.cpMax)
1030       {
1031          EnableMenuItem(hMenuPopup, ID_EDIT_COPY, MF_BYCOMMAND | MF_GRAYED);
1032       }
1033       else
1034       {
1035          EnableMenuItem(hMenuPopup, ID_EDIT_COPY, MF_BYCOMMAND | MF_ENABLED);
1036       }
1037
1038       /* Display the popup */
1039       TrackPopupMenu(hMenuPopup, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, x, y, 0, g_hwndLogFrame, NULL);
1040       DestroyMenu(hMenu);
1041    }
1042
1043 }
1044
1045
1046 /*********************************************************************
1047  *
1048  * Function    :  OnLogCommand
1049  *
1050  * Description :  Handler for WM_COMMAND messages.
1051  *
1052  * Parameters  :
1053  *          1  :  nCommand = the command portion of the menu selection event
1054  *
1055  * Returns     :  N/A
1056  *
1057  *********************************************************************/
1058 void OnLogCommand(int nCommand)
1059 {
1060    switch (nCommand)
1061    {
1062       case ID_SHOWWINDOW:
1063          ShowLogWindow(TRUE);
1064          break;
1065
1066       case ID_FILE_EXIT:
1067          PostMessage(g_hwndLogFrame, WM_CLOSE, 0, 0);
1068          break;
1069
1070       case ID_EDIT_COPY:
1071          SendMessage(g_hwndLogBox, WM_COPY, 0, 0);
1072          break;
1073
1074       case ID_VIEW_CLEARLOG:
1075          SendMessage(g_hwndLogBox, WM_SETTEXT, 0, (LPARAM) "");
1076          break;
1077
1078       case ID_VIEW_LOGMESSAGES:
1079          g_bLogMessages = !g_bLogMessages;
1080          /* SaveLogSettings(); */
1081          break;
1082
1083       case ID_VIEW_MESSAGEHIGHLIGHTING:
1084          g_bHighlightMessages = !g_bHighlightMessages;
1085          /* SaveLogSettings(); */
1086          break;
1087
1088       case ID_VIEW_LIMITBUFFERSIZE:
1089          g_bLimitBufferSize = !g_bLimitBufferSize;
1090          /* SaveLogSettings(); */
1091          break;
1092
1093       case ID_VIEW_ACTIVITYANIMATION:
1094          g_bShowActivityAnimation = !g_bShowActivityAnimation;
1095          /* SaveLogSettings(); */
1096          break;
1097
1098 #ifdef FEATURE_TOGGLE
1099       /* by haroon - change toggle to its opposite value */
1100       case ID_TOGGLE_ENABLED:
1101          g_bToggleIJB = !g_bToggleIJB;
1102          if (g_bToggleIJB)
1103          {
1104             log_error(LOG_LEVEL_INFO, "Now toggled ON.");
1105          }
1106          else
1107          {
1108             log_error(LOG_LEVEL_INFO, "Now toggled OFF.");
1109          }
1110          break;
1111 #endif /* def FEATURE_TOGGLE */
1112
1113       case ID_TOOLS_EDITCONFIG:
1114          EditFile(configfile);
1115          break;
1116
1117       case ID_TOOLS_EDITACTIONS:
1118          EditFile(g_actions_file);
1119          break;
1120
1121       case ID_TOOLS_EDITFILTERS:
1122          EditFile(g_re_filterfile);
1123          break;
1124
1125 #ifdef FEATURE_TRUST
1126       case ID_TOOLS_EDITTRUST:
1127          EditFile(g_trustfile);
1128          break;
1129 #endif /* def FEATURE_TRUST */
1130
1131       case ID_HELP_GPL:
1132          ShellExecute(g_hwndLogFrame, "open", "LICENSE.txt", NULL, NULL, SW_SHOWNORMAL);
1133          break;
1134
1135       case ID_HELP_FAQ:
1136          ShellExecute(g_hwndLogFrame, "open", "doc\\faq\\index.html", NULL, NULL, SW_SHOWNORMAL);
1137          break;
1138
1139       case ID_HELP_MANUAL:
1140          ShellExecute(g_hwndLogFrame, "open", "doc\\user-manual\\index.html", NULL, NULL, SW_SHOWNORMAL);
1141          break;
1142
1143       case ID_HELP_STATUS:
1144          ShellExecute(g_hwndLogFrame, "open", CGI_PREFIX "show-status", NULL, NULL, SW_SHOWNORMAL);
1145          break;
1146
1147       case ID_HELP_ABOUT:
1148          MessageBox(g_hwndLogFrame, win32_blurb, "About Privoxy", MB_OK);
1149          break;
1150
1151       default:
1152          /* DO NOTHING */
1153          break;
1154    }
1155
1156 }
1157
1158
1159 /*********************************************************************
1160  *
1161  * Function    :  OnLogInitMenu
1162  *
1163  * Description :  Handler for WM_INITMENU messages.  Enable, disable,
1164  *                check, and/or uncheck menu options as apropos.
1165  *
1166  * Parameters  :
1167  *          1  :  hmenu = handle to menu to "make current"
1168  *
1169  * Returns     :  N/A
1170  *
1171  *********************************************************************/
1172 void OnLogInitMenu(HMENU hmenu)
1173 {
1174    /* Only enable editors if there is a file to edit */
1175    EnableMenuItem(hmenu, ID_TOOLS_EDITACTIONS, MF_BYCOMMAND | (g_actions_file ? MF_ENABLED : MF_GRAYED));
1176    EnableMenuItem(hmenu, ID_TOOLS_EDITFILTERS, MF_BYCOMMAND | (g_re_filterfile ? MF_ENABLED : MF_GRAYED));
1177 #ifdef FEATURE_TRUST
1178    EnableMenuItem(hmenu, ID_TOOLS_EDITTRUST, MF_BYCOMMAND | (g_trustfile ? MF_ENABLED : MF_GRAYED));
1179 #endif /* def FEATURE_TRUST */
1180
1181    /* Check/uncheck options */
1182    CheckMenuItem(hmenu, ID_VIEW_LOGMESSAGES, MF_BYCOMMAND | (g_bLogMessages ? MF_CHECKED : MF_UNCHECKED));
1183    CheckMenuItem(hmenu, ID_VIEW_MESSAGEHIGHLIGHTING, MF_BYCOMMAND | (g_bHighlightMessages ? MF_CHECKED : MF_UNCHECKED));
1184    CheckMenuItem(hmenu, ID_VIEW_LIMITBUFFERSIZE, MF_BYCOMMAND | (g_bLimitBufferSize ? MF_CHECKED : MF_UNCHECKED));
1185    CheckMenuItem(hmenu, ID_VIEW_ACTIVITYANIMATION, MF_BYCOMMAND | (g_bShowActivityAnimation ? MF_CHECKED : MF_UNCHECKED));
1186 #ifdef FEATURE_TOGGLE
1187    /* by haroon - menu item for Enable toggle on/off */
1188    CheckMenuItem(hmenu, ID_TOGGLE_ENABLED, MF_BYCOMMAND | (g_bToggleIJB ? MF_CHECKED : MF_UNCHECKED));
1189 #endif /* def FEATURE_TOGGLE */
1190
1191 }
1192
1193
1194 /*********************************************************************
1195  *
1196  * Function    :  OnLogTimer
1197  *
1198  * Description :  Handler for WM_TIMER messages.
1199  *
1200  * Parameters  :
1201  *          1  :  nTimer = timer id (animation start/stop or clip buffer)
1202  *
1203  * Returns     :  N/A
1204  *
1205  *********************************************************************/
1206 void OnLogTimer(int nTimer)
1207 {
1208    switch (nTimer)
1209    {
1210       case TIMER_ANIM_ID:
1211          TraySetIcon(g_hwndTray, 1, g_hiconAnim[g_nAnimFrame++ % ANIM_FRAMES]);
1212          break;
1213
1214       case TIMER_ANIMSTOP_ID:
1215          g_nAnimFrame = 0;
1216          TraySetIcon(g_hwndTray, 1, g_hiconIdle);
1217          KillTimer(g_hwndLogFrame, TIMER_ANIM_ID);
1218          KillTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID);
1219          break;
1220
1221       case TIMER_CLIPBUFFER_ID:
1222       case TIMER_CLIPBUFFER_FORCE_ID:
1223          LogClipBuffer();
1224          g_bClipPending = FALSE;
1225          KillTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_ID);
1226          KillTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_FORCE_ID);
1227          break;
1228
1229       default:
1230          /* DO NOTHING */
1231          break;
1232    }
1233
1234 }
1235
1236
1237 /*********************************************************************
1238  *
1239  * Function    :  LogRichEditProc
1240  *
1241  * Description :  Window subclass routine handles some events for the rich edit control.
1242  *
1243  * Parameters  :
1244  *          1  :  hwnd = window handle of the rich edit control
1245  *          2  :  uMsg = message number
1246  *          3  :  wParam = first param for this message
1247  *          4  :  lParam = next param for this message
1248  *
1249  * Returns     :  Appropriate M$ window message handler codes.
1250  *
1251  *********************************************************************/
1252 LRESULT CALLBACK LogRichEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1253 {
1254    switch (uMsg)
1255    {
1256       case WM_RBUTTONUP:
1257       {
1258          POINT pt;
1259          pt.x = LOWORD(lParam);
1260          pt.y = HIWORD(lParam);
1261          ClientToScreen(hwnd, &pt);
1262          OnLogRButtonUp(wParam, pt.x, pt.y);
1263       }
1264       return 0;
1265    }
1266    return CallWindowProc(g_fnLogBox, hwnd, uMsg, wParam, lParam);
1267
1268 }
1269
1270
1271 /*********************************************************************
1272  *
1273  * Function    :  LogWindowProc
1274  *
1275  * Description :  Windows call back routine handles events on the log window.
1276  *
1277  * Parameters  :
1278  *          1  :  hwnd = handle of the logging window
1279  *          2  :  uMsg = message number
1280  *          3  :  wParam = first param for this message
1281  *          4  :  lParam = next param for this message
1282  *
1283  * Returns     :  Appropriate M$ window message handler codes.
1284  *
1285  *********************************************************************/
1286 LRESULT CALLBACK LogWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
1287 {
1288    switch (uMsg)
1289    {
1290       case WM_CREATE:
1291          return 0;
1292
1293       case WM_CLOSE:
1294          /* This is the end - beautiful friend - the end */
1295          DestroyWindow(g_hwndLogBox);
1296          DestroyWindow(g_hwndLogFrame);
1297          return 0;
1298
1299       case WM_DESTROY:
1300          PostQuitMessage(0);
1301          return 0;
1302
1303       case WM_SHOWWINDOW:
1304       case WM_SIZE:
1305          /* Resize the logging window to fit the new frame */
1306          if (g_hwndLogBox)
1307          {
1308             RECT rc;
1309             GetClientRect(g_hwndLogFrame, &rc);
1310             SetWindowPos(g_hwndLogBox, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER);
1311          }
1312          return 0;
1313
1314       case WM_INITMENU:
1315          OnLogInitMenu((HMENU) wParam);
1316          return 0;
1317
1318       case WM_TIMER:
1319          OnLogTimer(wParam);
1320          return 0;
1321
1322       case WM_COMMAND:
1323          OnLogCommand(LOWORD(wParam));
1324          return 0;
1325
1326       case WM_SYSCOMMAND:
1327          switch (wParam)
1328          {
1329             case SC_CLOSE:
1330                if (g_bCloseHidesWindow)
1331                {
1332                   ShowLogWindow(FALSE);
1333                   return 0;
1334                }
1335                break;
1336             case SC_MINIMIZE:
1337                ShowLogWindow(FALSE);
1338                return 0;
1339          }
1340          break;
1341    }
1342
1343    return DefWindowProc(hwnd, uMsg, wParam, lParam);
1344
1345 }
1346
1347 #endif /* ndef _WIN_CONSOLE - entire file */
1348
1349 /*
1350   Local Variables:
1351   tab-width: 3
1352   end:
1353 */