w32log.c 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247
  1. /*********************************************************************
  2. *
  3. * File : $Source: /cvsroot/ijbswa/current/w32log.c,v $
  4. *
  5. * Purpose : Functions for creating and destroying the log window,
  6. * outputting strings, processing messages and so on.
  7. *
  8. * Copyright : Written by and Copyright (C) 2001-2009 members of
  9. * the Privoxy team. https://www.privoxy.org/
  10. *
  11. * Written by and Copyright (C) 1999 Adam Lock
  12. * <locka@iol.ie>
  13. *
  14. * This program is free software; you can redistribute it
  15. * and/or modify it under the terms of the GNU General
  16. * Public License as published by the Free Software
  17. * Foundation; either version 2 of the License, or (at
  18. * your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will
  21. * be useful, but WITHOUT ANY WARRANTY; without even the
  22. * implied warranty of MERCHANTABILITY or FITNESS FOR A
  23. * PARTICULAR PURPOSE. See the GNU General Public
  24. * License for more details.
  25. *
  26. * The GNU General Public License should be included with
  27. * this file. If not, you can view it at
  28. * http://www.gnu.org/copyleft/gpl.html
  29. * or write to the Free Software Foundation, Inc., 59
  30. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  31. *
  32. *********************************************************************/
  33. #include "config.h"
  34. #include <assert.h>
  35. #include <stdio.h>
  36. #ifndef STRICT
  37. #define STRICT
  38. #endif
  39. #include <winsock2.h>
  40. #include <windows.h>
  41. #include <richedit.h>
  42. #include "project.h"
  43. #include "w32log.h"
  44. #include "w32taskbar.h"
  45. #include "win32.h"
  46. #include "w32res.h"
  47. #include "jcc.h"
  48. #include "miscutil.h"
  49. #include "errlog.h"
  50. #include "loadcfg.h"
  51. #ifndef _WIN_CONSOLE /* entire file */
  52. /*
  53. * Timers and the various durations
  54. */
  55. #define TIMER_ANIM_ID 1
  56. #define TIMER_ANIM_TIME 100
  57. #define TIMER_ANIMSTOP_ID 2
  58. #define TIMER_ANIMSTOP_TIME 1000
  59. #define TIMER_CLIPBUFFER_ID 3
  60. #define TIMER_CLIPBUFFER_TIME 1000
  61. #define TIMER_CLIPBUFFER_FORCE_ID 4
  62. #define TIMER_CLIPBUFFER_FORCE_TIME 5000
  63. /*
  64. * Styles of text that can be output
  65. */
  66. #define STYLE_NONE 0
  67. #define STYLE_HIGHLIGHT 1
  68. #define STYLE_LINK 2
  69. #define STYLE_HEADER 3
  70. /*
  71. * Number of frames of animation in tray activity sequence
  72. */
  73. #define ANIM_FRAMES 8
  74. #define DEFAULT_MAX_BUFFER_LINES 200
  75. #define DEFAULT_LOG_FONT_NAME "MS Sans Serif"
  76. #define DEFAULT_LOG_FONT_SIZE 8
  77. /*
  78. * These values affect the way the log window behaves, they should be read
  79. * from a file but for the moment, they are hardcoded here. Some options are
  80. * configurable through the UI.
  81. */
  82. /* Indicates whether task bar shows activity animation */
  83. BOOL g_bShowActivityAnimation = 1;
  84. /* Indicates whether the log window is shown */
  85. BOOL g_bShowLogWindow = 1;
  86. /* Indicates if the log window appears on the task bar */
  87. BOOL g_bShowOnTaskBar = 0;
  88. /* Indicates whether closing the log window really just hides it */
  89. BOOL g_bCloseHidesWindow = 1;
  90. /* Indicates if messages are logged at all */
  91. BOOL g_bLogMessages = 1;
  92. /* Indicates whether log messages are highlighted */
  93. BOOL g_bHighlightMessages = 1;
  94. /* Indicates if buffer is limited in size */
  95. BOOL g_bLimitBufferSize = 1;
  96. /* Maximum number of lines allowed in buffer when limited */
  97. int g_nMaxBufferLines = DEFAULT_MAX_BUFFER_LINES;
  98. /* Font to use */
  99. char g_szFontFaceName[32] = DEFAULT_LOG_FONT_NAME;
  100. /* Size of font to use */
  101. int g_nFontSize = DEFAULT_LOG_FONT_SIZE;
  102. /* FIXME: this is a kludge */
  103. const char * g_default_actions_file = NULL;
  104. const char * g_user_actions_file = NULL;
  105. const char * g_default_filterfile = NULL;
  106. const char * g_user_filterfile = NULL;
  107. #ifdef FEATURE_TRUST
  108. const char * g_trustfile = NULL;
  109. #endif /* def FEATURE_TRUST */
  110. /* FIXME: end kludge */
  111. /* Regular expression for detected URLs */
  112. #define RE_URL "http:[^ \n\r]*"
  113. /*
  114. * Regular expressions that are used to perform highlight in the log window
  115. */
  116. static struct _Pattern
  117. {
  118. const char *str;
  119. int style;
  120. regex_t buffer;
  121. } patterns_to_highlight[] =
  122. {
  123. /* url headers */
  124. { RE_URL, STYLE_LINK },
  125. /* { "[a-zA-Z0-9]+\\.[a-zA-Z0-9]+\\.[a-zA-Z0-9]+\\.[^ \n\r]*", STYLE_LINK }, */
  126. /* interesting text to highlight */
  127. /* see jcc.c crunch_reason for the full list */
  128. { "Crunch: Blocked:", STYLE_HIGHLIGHT },
  129. { "Crunch: Untrusted", STYLE_HIGHLIGHT },
  130. { "Crunch: Redirected:", STYLE_HIGHLIGHT },
  131. { "Crunch: DNS failure", STYLE_HIGHLIGHT },
  132. { "Crunch: Forwarding failed", STYLE_HIGHLIGHT },
  133. { "Crunch: Connection failure", STYLE_HIGHLIGHT },
  134. { "Crunch: Out of memory", STYLE_HIGHLIGHT },
  135. { "Connect: Found reusable socket", STYLE_HIGHLIGHT },
  136. { "Connect: Reusing server socket", STYLE_HIGHLIGHT },
  137. { "Connect: Created new connection to", STYLE_HIGHLIGHT },
  138. { "hung up on us", STYLE_HIGHLIGHT },
  139. { "Info: Loading actions file:", STYLE_HIGHLIGHT },
  140. { "Info: Loading filter file:", STYLE_HIGHLIGHT },
  141. { "Info: Now toggled ", STYLE_HIGHLIGHT },
  142. { "Crunching Referer:", STYLE_HIGHLIGHT },
  143. /* what are all the possible error strings?? */
  144. { "Error:", STYLE_HIGHLIGHT },
  145. /* http headers */
  146. { "referer:", STYLE_HEADER },
  147. { "proxy-connection:", STYLE_HEADER },
  148. { "proxy-agent:", STYLE_HEADER },
  149. { "user-agent:", STYLE_HEADER },
  150. { "host:", STYLE_HEADER },
  151. { "accept:", STYLE_HEADER },
  152. { "accept-encoding:", STYLE_HEADER },
  153. { "accept-language:", STYLE_HEADER },
  154. { "accept-charset:", STYLE_HEADER },
  155. { "accept-ranges:", STYLE_HEADER },
  156. { "date:", STYLE_HEADER },
  157. { "cache-control:", STYLE_HEADER },
  158. { "cache-last-checked:", STYLE_HEADER },
  159. { "connection:", STYLE_HEADER },
  160. { "content-type", STYLE_HEADER },
  161. { "content-length", STYLE_HEADER },
  162. { "cookie", STYLE_HEADER },
  163. { "last-modified:", STYLE_HEADER },
  164. { "pragma:", STYLE_HEADER },
  165. { "server:", STYLE_HEADER },
  166. { "etag:", STYLE_HEADER },
  167. { "expires:", STYLE_HEADER },
  168. { "warning:", STYLE_HEADER },
  169. /* this is the terminator statement - do not delete! */
  170. { NULL, STYLE_NONE }
  171. };
  172. /*
  173. * Public variables
  174. */
  175. HWND g_hwndLogFrame;
  176. HICON g_hiconApp;
  177. /*
  178. * Private variables
  179. */
  180. static CRITICAL_SECTION g_criticalsection;
  181. static HWND g_hwndTray;
  182. static HWND g_hwndLogBox;
  183. static WNDPROC g_fnLogBox;
  184. static HICON g_hiconAnim[ANIM_FRAMES];
  185. static HICON g_hiconIdle;
  186. static HICON g_hiconOff;
  187. static int g_nAnimFrame;
  188. static BOOL g_bClipPending = FALSE;
  189. static int g_nRichEditVersion = 0;
  190. /*
  191. * Private functions
  192. */
  193. static HWND CreateLogWindow(HINSTANCE hInstance, int nCmdShow);
  194. static HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance);
  195. static LRESULT CALLBACK LogWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  196. static LRESULT CALLBACK LogOwnerWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  197. static LRESULT CALLBACK LogRichEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  198. static BOOL InitRichEdit(void);
  199. static void LogClipBuffer(void);
  200. static void LogCreatePatternMatchingBuffers(void);
  201. static void LogDestroyPatternMatchingBuffers(void);
  202. static int LogPutStringNoMatch(const char *pszText, int style);
  203. static void SetIdleIcon(void);
  204. /*********************************************************************
  205. *
  206. * Function : InitLogWindow
  207. *
  208. * Description : Initialise the log window.
  209. *
  210. * Parameters : None
  211. *
  212. * Returns : Always TRUE (there should be error checking on the resources).
  213. *
  214. *********************************************************************/
  215. BOOL InitLogWindow(void)
  216. {
  217. int i;
  218. /* Load the icons */
  219. g_hiconIdle = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_IDLE));
  220. g_hiconOff = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_OFF));
  221. for (i = 0; i < ANIM_FRAMES; i++)
  222. {
  223. g_hiconAnim[i] = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ANIMATED1 + i));
  224. }
  225. g_hiconApp = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_MAINICON));
  226. /* Create the user interface */
  227. g_hwndLogFrame = CreateLogWindow(g_hInstance, g_nCmdShow);
  228. g_hwndTray = CreateTrayWindow(g_hInstance);
  229. TrayAddIcon(g_hwndTray, 1, g_hiconApp, "Privoxy");
  230. /* Create pattern matching buffers (for highlighting */
  231. LogCreatePatternMatchingBuffers();
  232. /* Create a critical section to protect multi-threaded access to certain things */
  233. InitializeCriticalSection(&g_criticalsection);
  234. return TRUE;
  235. }
  236. /*********************************************************************
  237. *
  238. * Function : TermLogWindow
  239. *
  240. * Description : Cleanup the logwindow.
  241. *
  242. * Parameters : None
  243. *
  244. * Returns : N/A
  245. *
  246. *********************************************************************/
  247. void TermLogWindow(void)
  248. {
  249. int i;
  250. LogDestroyPatternMatchingBuffers();
  251. TrayDeleteIcon(g_hwndTray, 1);
  252. DeleteObject(g_hiconApp);
  253. DeleteObject(g_hiconIdle);
  254. DeleteObject(g_hiconOff);
  255. for (i = 0; i < ANIM_FRAMES; i++)
  256. {
  257. DeleteObject(g_hiconAnim[i]);
  258. }
  259. }
  260. /*********************************************************************
  261. *
  262. * Function : LogCreatePatternMatchingBuffers
  263. *
  264. * Description : Compile the pattern matching buffers.
  265. *
  266. * Parameters : None
  267. *
  268. * Returns : N/A
  269. *
  270. *********************************************************************/
  271. void LogCreatePatternMatchingBuffers(void)
  272. {
  273. int i;
  274. for (i = 0; patterns_to_highlight[i].str != NULL; i++)
  275. {
  276. regcomp(&patterns_to_highlight[i].buffer, patterns_to_highlight[i].str, REG_ICASE);
  277. }
  278. }
  279. /*********************************************************************
  280. *
  281. * Function : LogDestroyPatternMatchingBuffers
  282. *
  283. * Description : Free up the pattern matching buffers.
  284. *
  285. * Parameters : None
  286. *
  287. * Returns : N/A
  288. *
  289. *********************************************************************/
  290. void LogDestroyPatternMatchingBuffers(void)
  291. {
  292. int i;
  293. for (i = 0; patterns_to_highlight[i].str != NULL; i++)
  294. {
  295. regfree(&patterns_to_highlight[i].buffer);
  296. }
  297. }
  298. /*********************************************************************
  299. *
  300. * Function : LogPutString
  301. *
  302. * Description : Inserts text into the logging window. This is really
  303. * a regexp aware wrapper function to `LogPutStringNoMatch'.
  304. *
  305. * Parameters :
  306. * 1 : pszText = pointer to string going to the log window
  307. *
  308. * Returns : 1 => success, else the return code from `LogPutStringNoMatch'.
  309. * FIXME: this is backwards to the rest of IJB and to common
  310. * programming practice. Please use 0 => success instead.
  311. *
  312. *********************************************************************/
  313. int LogPutString(const char *pszText)
  314. {
  315. int i;
  316. int result = 0;
  317. if (!g_bLogMessages)
  318. {
  319. return 1;
  320. }
  321. if (pszText == NULL || strlen(pszText) == 0)
  322. {
  323. return 1;
  324. }
  325. /* Critical section stops multiple threads doing nasty interactions that
  326. * foul up the highlighting and output.
  327. */
  328. EnterCriticalSection(&g_criticalsection);
  329. if (g_bHighlightMessages)
  330. {
  331. regmatch_t match;
  332. /* First things first, regexp scan for various things that we would like highlighted */
  333. for (i = 0; patterns_to_highlight[i].str != NULL; i++)
  334. {
  335. if (regexec(&patterns_to_highlight[i].buffer, pszText, 1, &match, 0) == 0)
  336. {
  337. char *pszBefore = NULL;
  338. char *pszMatch = NULL;
  339. char *pszAfter = NULL;
  340. int nMatchSize;
  341. /* Split the string up into pieces representing the strings, before
  342. at and after the matching pattern
  343. */
  344. if (match.rm_so > 0)
  345. {
  346. pszBefore = (char *)malloc((match.rm_so + 1) * sizeof(char));
  347. memset(pszBefore, 0, (match.rm_so + 1) * sizeof(char));
  348. strncpy(pszBefore, pszText, match.rm_so);
  349. }
  350. if (match.rm_eo < (regoff_t)strlen(pszText))
  351. {
  352. pszAfter = strdup(&pszText[match.rm_eo]);
  353. }
  354. nMatchSize = match.rm_eo - match.rm_so;
  355. pszMatch = (char *)malloc(nMatchSize + 1);
  356. strncpy(pszMatch, &pszText[match.rm_so], nMatchSize);
  357. pszMatch[nMatchSize] = '\0';
  358. /* Recursively call LogPutString */
  359. if (pszBefore)
  360. {
  361. LogPutString(pszBefore);
  362. free(pszBefore);
  363. }
  364. if (pszMatch)
  365. {
  366. LogPutStringNoMatch(pszMatch, patterns_to_highlight[i].style);
  367. free(pszMatch);
  368. }
  369. if (pszAfter)
  370. {
  371. LogPutString(pszAfter);
  372. free(pszAfter);
  373. }
  374. result = 1;
  375. goto end;
  376. }
  377. }
  378. }
  379. result = LogPutStringNoMatch(pszText, STYLE_NONE);
  380. end:
  381. LeaveCriticalSection(&g_criticalsection);
  382. return result;
  383. }
  384. /*********************************************************************
  385. *
  386. * Function : LogPutStringNoMatch
  387. *
  388. * Description : Puts a string into the logging window.
  389. *
  390. * Parameters :
  391. * 1 : pszText = pointer to string going to the log window
  392. * 2 : style = STYLE_NONE, STYLE_HEADER, STYLE_HIGHLIGHT, or STYLE_LINK
  393. *
  394. * Returns : Always 1 => success.
  395. * FIXME: this is backwards to the rest of IJB and to common
  396. * programming practice. Please use 0 => success instead.
  397. *
  398. *********************************************************************/
  399. int LogPutStringNoMatch(const char *pszText, int style)
  400. {
  401. CHARRANGE range;
  402. CHARFORMAT format;
  403. int nTextLength;
  404. assert(g_hwndLogBox);
  405. if (g_hwndLogBox == NULL)
  406. {
  407. return 1;
  408. }
  409. /* TODO preserve existing selection */
  410. /* Go to the end of the text */
  411. nTextLength = GetWindowTextLength(g_hwndLogBox);
  412. range.cpMin = nTextLength;
  413. range.cpMax = nTextLength;
  414. SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range);
  415. /* Apply a formatting style */
  416. memset(&format, 0, sizeof(format));
  417. format.cbSize = sizeof(format);
  418. format.dwMask = CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT |
  419. CFM_ITALIC | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_CHARSET;
  420. format.bCharSet = DEFAULT_CHARSET;
  421. format.yHeight = (g_nFontSize * 1440) / 72;
  422. strlcpy(format.szFaceName, g_szFontFaceName, sizeof(format.szFaceName));
  423. if (style == STYLE_NONE)
  424. {
  425. /* DO NOTHING */
  426. format.dwEffects |= CFE_AUTOCOLOR;
  427. }
  428. else if (style == STYLE_HEADER)
  429. {
  430. format.dwEffects |= CFE_AUTOCOLOR | CFE_ITALIC;
  431. }
  432. else if (style == STYLE_HIGHLIGHT)
  433. {
  434. format.dwEffects |= CFE_AUTOCOLOR | CFE_BOLD;
  435. }
  436. else if (style == STYLE_LINK)
  437. {
  438. format.dwEffects |= CFE_UNDERLINE;
  439. format.crTextColor = RGB(0, 0, 255);
  440. }
  441. SendMessage(g_hwndLogBox, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &format);
  442. /* Append text to the end */
  443. SendMessage(g_hwndLogBox, EM_REPLACESEL, FALSE, (LPARAM) pszText);
  444. /* TODO Restore the old selection */
  445. /* Purge buffer */
  446. if (strchr(pszText, '\n') != NULL)
  447. {
  448. SetTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_ID, TIMER_CLIPBUFFER_TIME, NULL);
  449. if (!g_bClipPending)
  450. {
  451. /* Set the force clip timer going. This timer ensures clipping is done
  452. intermittently even when there is a sustained burst of logging
  453. */
  454. SetTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_FORCE_ID, TIMER_CLIPBUFFER_FORCE_TIME, NULL);
  455. }
  456. g_bClipPending = TRUE;
  457. }
  458. return 1;
  459. }
  460. /*********************************************************************
  461. *
  462. * Function : LogShowActivity
  463. *
  464. * Description : Start the spinner.
  465. *
  466. * Parameters : None
  467. *
  468. * Returns : N/A
  469. *
  470. *********************************************************************/
  471. void LogShowActivity(void)
  472. {
  473. /* Start some activity timers */
  474. if (g_bShowActivityAnimation)
  475. {
  476. SetTimer(g_hwndLogFrame, TIMER_ANIM_ID, TIMER_ANIM_TIME, NULL);
  477. SetTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID, TIMER_ANIMSTOP_TIME, NULL);
  478. }
  479. }
  480. /*********************************************************************
  481. *
  482. * Function : LogClipBuffer
  483. *
  484. * Description : Prunes old lines from the log.
  485. *
  486. * Parameters : None
  487. *
  488. * Returns : N/A
  489. *
  490. *********************************************************************/
  491. void LogClipBuffer(void)
  492. {
  493. int nLines = SendMessage(g_hwndLogBox, EM_GETLINECOUNT, 0, 0);
  494. if (g_bLimitBufferSize && nLines > g_nMaxBufferLines)
  495. {
  496. /* Compute the range representing the lines to be deleted */
  497. LONG nLastLineToDelete = nLines - g_nMaxBufferLines;
  498. LONG nLastChar = SendMessage(g_hwndLogBox, EM_LINEINDEX, nLastLineToDelete, 0);
  499. CHARRANGE range;
  500. range.cpMin = 0;
  501. range.cpMax = nLastChar;
  502. /* TODO get current selection */
  503. /* TODO adjust and clip old selection against range to be deleted */
  504. /* Select range and erase it (turning off autoscroll to prevent
  505. nasty scrolling) */
  506. SendMessage(g_hwndLogBox, EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL);
  507. SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range);
  508. SendMessage(g_hwndLogBox, EM_REPLACESEL, FALSE, (LPARAM) "");
  509. SendMessage(g_hwndLogBox, EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL);
  510. /* reposition (back to) the end of the log content */
  511. range.cpMin = SendMessage (g_hwndLogBox, WM_GETTEXTLENGTH, 0, 0);
  512. range.cpMax = -1;
  513. SendMessage(g_hwndLogBox, EM_EXSETSEL, 0, (LPARAM) &range);
  514. /* restore vertical ScrollBar stuff (messed up by AUTOVSCROLL) */
  515. SendMessage (g_hwndLogBox, EM_SCROLL, SB_LINEDOWN, 0);
  516. }
  517. }
  518. /*********************************************************************
  519. *
  520. * Function : CreateHiddenLogOwnerWindow
  521. *
  522. * Description : Creates a hidden owner window that stops the log
  523. * window appearing in the task bar.
  524. *
  525. * Parameters :
  526. * 1 : hInstance = application's instance handle
  527. *
  528. * Returns : Handle to newly created window.
  529. *
  530. *********************************************************************/
  531. HWND CreateHiddenLogOwnerWindow(HINSTANCE hInstance)
  532. {
  533. static const char *szWndName = "PrivoxyLogOwner";
  534. WNDCLASS wc;
  535. HWND hwnd;
  536. wc.style = 0;
  537. wc.lpfnWndProc = LogOwnerWindowProc;
  538. wc.cbClsExtra = 0;
  539. wc.cbWndExtra = 0;
  540. wc.hInstance = hInstance;
  541. wc.hIcon = g_hiconApp;
  542. wc.hCursor = 0;
  543. wc.hbrBackground = 0;
  544. wc.lpszMenuName = 0;
  545. wc.lpszClassName = szWndName;
  546. RegisterClass(&wc);
  547. hwnd = CreateWindow(szWndName, szWndName,
  548. WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  549. CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
  550. return hwnd;
  551. }
  552. /*********************************************************************
  553. *
  554. * Function : LogOwnerWindowProc
  555. *
  556. * Description : Dummy procedure that does nothing special.
  557. *
  558. * Parameters :
  559. * 1 : hwnd = window handle
  560. * 2 : uMsg = message number
  561. * 3 : wParam = first param for this message
  562. * 4 : lParam = next param for this message
  563. *
  564. * Returns : Same as `DefWindowProc'.
  565. *
  566. *********************************************************************/
  567. LRESULT CALLBACK LogOwnerWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  568. {
  569. return DefWindowProc(hwnd, uMsg, wParam, lParam);
  570. }
  571. /*********************************************************************
  572. *
  573. * Function : CreateLogWindow
  574. *
  575. * Description : Create the logging window.
  576. *
  577. * Parameters :
  578. * 1 : hInstance = application's instance handle
  579. * 2 : nCmdShow = window show value (MIN, MAX, NORMAL, etc...)
  580. *
  581. * Returns : Handle to newly created window.
  582. *
  583. *********************************************************************/
  584. HWND CreateLogWindow(HINSTANCE hInstance, int nCmdShow)
  585. {
  586. static const char *szWndName = "PrivoxyLogWindow";
  587. static const char *szWndTitle = "Privoxy";
  588. HWND hwnd = NULL;
  589. HWND hwndOwner = (g_bShowOnTaskBar) ? NULL : CreateHiddenLogOwnerWindow(hInstance);
  590. RECT rcClient;
  591. WNDCLASSEX wc;
  592. memset(&wc, 0, sizeof(wc));
  593. wc.cbSize = sizeof(wc);
  594. wc.style = CS_DBLCLKS;
  595. wc.lpfnWndProc = LogWindowProc;
  596. wc.cbClsExtra = 0;
  597. wc.cbWndExtra = 0;
  598. wc.hInstance = hInstance;
  599. wc.hIcon = g_hiconApp;
  600. wc.hCursor = 0;
  601. wc.hbrBackground = 0;
  602. wc.lpszMenuName = MAKEINTRESOURCE(IDR_LOGVIEW);
  603. wc.lpszClassName = szWndName;
  604. wc.hbrBackground = GetStockObject(WHITE_BRUSH);
  605. RegisterClassEx(&wc);
  606. hwnd = CreateWindowEx(WS_EX_APPWINDOW, szWndName, szWndTitle,
  607. WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
  608. CW_USEDEFAULT, hwndOwner, NULL, hInstance, NULL);
  609. /* Now create a child list box */
  610. GetClientRect(hwnd, &rcClient);
  611. /* Create a rich edit control */
  612. InitRichEdit();
  613. g_hwndLogBox = CreateWindowEx(0, (g_nRichEditVersion == 0x0100) ? "RichEdit" : RICHEDIT_CLASS, "",
  614. ES_AUTOVSCROLL | ES_MULTILINE | ES_READONLY | ES_NOHIDESEL | WS_CHILD | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
  615. rcClient.left, rcClient.top, rcClient.right, rcClient.bottom,
  616. hwnd, NULL, hInstance, NULL);
  617. /* SendMessage(g_hwndLogBox, EM_SETWORDWRAPMODE, 0, 0); */
  618. /* Subclass the control to catch certain messages */
  619. g_fnLogBox = (WNDPROC) GetWindowLongPtr(g_hwndLogBox, GWLP_WNDPROC);
  620. SetWindowLongPtr(g_hwndLogBox, GWLP_WNDPROC, (LONG_PTR) LogRichEditProc);
  621. /* Minimizing looks stupid when the log window is not on the task bar, so hide instead */
  622. if (!g_bShowOnTaskBar &&
  623. (nCmdShow == SW_SHOWMINIMIZED ||
  624. nCmdShow == SW_MINIMIZE ||
  625. nCmdShow == SW_SHOWMINNOACTIVE))
  626. {
  627. g_bShowLogWindow = FALSE;
  628. nCmdShow = SW_HIDE;
  629. }
  630. ShowWindow(hwnd, nCmdShow);
  631. UpdateWindow(hwnd);
  632. GetClientRect(g_hwndLogFrame, &rcClient);
  633. SetWindowPos(g_hwndLogBox, NULL, rcClient.left, rcClient.top, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_NOZORDER);
  634. return hwnd;
  635. }
  636. /*********************************************************************
  637. *
  638. * Function : InitRichEdit
  639. *
  640. * Description : Initialise the rich edit control library.
  641. *
  642. * Parameters : None
  643. *
  644. * Returns : TRUE => success, FALSE => failure.
  645. * FIXME: this is backwards to the rest of IJB and to common
  646. * programming practice. Please use 0 => success instead.
  647. *
  648. *********************************************************************/
  649. BOOL InitRichEdit(void)
  650. {
  651. static HINSTANCE hInstRichEdit;
  652. if (hInstRichEdit == NULL)
  653. {
  654. g_nRichEditVersion = 0;
  655. hInstRichEdit = LoadLibraryA("RICHED20.DLL");
  656. if (hInstRichEdit)
  657. {
  658. g_nRichEditVersion = _RICHEDIT_VER;
  659. }
  660. else
  661. {
  662. hInstRichEdit = LoadLibraryA("RICHED32.DLL");
  663. if (hInstRichEdit)
  664. {
  665. g_nRichEditVersion = 0x0100;
  666. }
  667. }
  668. }
  669. return (hInstRichEdit != NULL) ? TRUE : FALSE;
  670. }
  671. /*********************************************************************
  672. *
  673. * Function : ShowLogWindow
  674. *
  675. * Description : Shows or hides the log window. We will also raise the
  676. * window on a show command in case it is buried.
  677. *
  678. * Parameters :
  679. * 1 : bShow = TRUE to show, FALSE to mimize/hide
  680. *
  681. * Returns : N/A
  682. *
  683. *********************************************************************/
  684. void ShowLogWindow(BOOL bShow)
  685. {
  686. if (bShow)
  687. {
  688. SetForegroundWindow(g_hwndLogFrame);
  689. SetWindowPos(g_hwndLogFrame, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
  690. }
  691. else if (g_bShowOnTaskBar)
  692. {
  693. ShowWindow(g_hwndLogFrame, SW_MINIMIZE);
  694. }
  695. else
  696. {
  697. ShowWindow(g_hwndLogFrame, SW_HIDE);
  698. }
  699. }
  700. /*********************************************************************
  701. *
  702. * Function : EditFile
  703. *
  704. * Description : Opens the specified setting file for editing.
  705. * FIXME: What if the file has no associated application. Check for return values
  706. * from ShellExecute??
  707. *
  708. * Parameters :
  709. * 1 : filename = filename from the config (aka config.txt) file.
  710. *
  711. * Returns : N/A
  712. *
  713. *********************************************************************/
  714. void EditFile(const char *filename)
  715. {
  716. if (filename)
  717. {
  718. ShellExecute(g_hwndLogFrame, "open", filename, NULL, NULL, SW_SHOWNORMAL);
  719. }
  720. }
  721. /*--------------------------------------------------------------------------*/
  722. /* Windows message handlers */
  723. /*--------------------------------------------------------------------------*/
  724. /*********************************************************************
  725. *
  726. * Function : OnLogRButtonUp
  727. *
  728. * Description : Handler for WM_RBUTTONUP messages.
  729. *
  730. * Parameters :
  731. * 1 : nModifier = wParam from mouse message (unused)
  732. * 2 : x = x coordinate of the mouse event
  733. * 3 : y = y coordinate of the mouse event
  734. *
  735. * Returns : N/A
  736. *
  737. *********************************************************************/
  738. void OnLogRButtonUp(int nModifier, int x, int y)
  739. {
  740. HMENU hMenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_POPUP_SELECTION));
  741. if (hMenu != NULL)
  742. {
  743. HMENU hMenuPopup = GetSubMenu(hMenu, 0);
  744. /* Check if there is a selection */
  745. CHARRANGE range;
  746. SendMessage(g_hwndLogBox, EM_EXGETSEL, 0, (LPARAM) &range);
  747. if (range.cpMin == range.cpMax)
  748. {
  749. EnableMenuItem(hMenuPopup, ID_EDIT_COPY, MF_BYCOMMAND | MF_GRAYED);
  750. }
  751. else
  752. {
  753. EnableMenuItem(hMenuPopup, ID_EDIT_COPY, MF_BYCOMMAND | MF_ENABLED);
  754. }
  755. /* Display the popup */
  756. TrackPopupMenu(hMenuPopup, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON, x, y, 0, g_hwndLogFrame, NULL);
  757. DestroyMenu(hMenu);
  758. }
  759. }
  760. /*********************************************************************
  761. *
  762. * Function : OnLogCommand
  763. *
  764. * Description : Handler for WM_COMMAND messages.
  765. *
  766. * Parameters :
  767. * 1 : nCommand = the command portion of the menu selection event
  768. *
  769. * Returns : N/A
  770. *
  771. *********************************************************************/
  772. void OnLogCommand(int nCommand)
  773. {
  774. switch (nCommand)
  775. {
  776. case ID_TOGGLE_SHOWWINDOW:
  777. g_bShowLogWindow = !g_bShowLogWindow;
  778. ShowLogWindow(g_bShowLogWindow);
  779. break;
  780. case ID_FILE_EXIT:
  781. PostMessage(g_hwndLogFrame, WM_CLOSE, 0, 0);
  782. break;
  783. case ID_EDIT_COPY:
  784. SendMessage(g_hwndLogBox, WM_COPY, 0, 0);
  785. break;
  786. case ID_VIEW_CLEARLOG:
  787. SendMessage(g_hwndLogBox, WM_SETTEXT, 0, (LPARAM) "");
  788. break;
  789. case ID_VIEW_LOGMESSAGES:
  790. g_bLogMessages = !g_bLogMessages;
  791. /* SaveLogSettings(); */
  792. break;
  793. case ID_VIEW_MESSAGEHIGHLIGHTING:
  794. g_bHighlightMessages = !g_bHighlightMessages;
  795. /* SaveLogSettings(); */
  796. break;
  797. case ID_VIEW_LIMITBUFFERSIZE:
  798. g_bLimitBufferSize = !g_bLimitBufferSize;
  799. /* SaveLogSettings(); */
  800. break;
  801. case ID_VIEW_ACTIVITYANIMATION:
  802. g_bShowActivityAnimation = !g_bShowActivityAnimation;
  803. /* SaveLogSettings(); */
  804. break;
  805. #ifdef FEATURE_TOGGLE
  806. case ID_TOGGLE_ENABLED:
  807. global_toggle_state = !global_toggle_state;
  808. log_error(LOG_LEVEL_INFO,
  809. "Now toggled %s", global_toggle_state ? "ON" : "OFF");
  810. /*
  811. * Leverage TIMER_ANIMSTOP_ID to set the idle icon through the
  812. * "application queue". According to MSDN, 10 milliseconds are
  813. * the lowest value possible and seem to be close enough to
  814. * "instantly".
  815. */
  816. SetTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID, 10, NULL);
  817. break;
  818. #endif /* def FEATURE_TOGGLE */
  819. case ID_TOOLS_EDITCONFIG:
  820. EditFile(configfile);
  821. break;
  822. case ID_TOOLS_EDITDEFAULTACTIONS:
  823. EditFile(g_default_actions_file);
  824. break;
  825. case ID_TOOLS_EDITUSERACTIONS:
  826. EditFile(g_user_actions_file);
  827. break;
  828. case ID_TOOLS_EDITDEFAULTFILTERS:
  829. EditFile(g_default_filterfile);
  830. break;
  831. case ID_TOOLS_EDITUSERFILTERS:
  832. EditFile(g_user_filterfile);
  833. break;
  834. #ifdef FEATURE_TRUST
  835. case ID_TOOLS_EDITTRUST:
  836. EditFile(g_trustfile);
  837. break;
  838. #endif /* def FEATURE_TRUST */
  839. case ID_HELP_GPL:
  840. ShellExecute(g_hwndLogFrame, "open", "LICENSE.txt", NULL, NULL, SW_SHOWNORMAL);
  841. break;
  842. case ID_HELP_FAQ:
  843. ShellExecute(g_hwndLogFrame, "open", "doc\\faq\\index.html", NULL, NULL, SW_SHOWNORMAL);
  844. break;
  845. case ID_HELP_MANUAL:
  846. ShellExecute(g_hwndLogFrame, "open", "doc\\user-manual\\index.html", NULL, NULL, SW_SHOWNORMAL);
  847. break;
  848. case ID_HELP_STATUS:
  849. ShellExecute(g_hwndLogFrame, "open", CGI_PREFIX "show-status", NULL, NULL, SW_SHOWNORMAL);
  850. break;
  851. case ID_HELP_ABOUT:
  852. MessageBox(g_hwndLogFrame, win32_blurb, "About Privoxy", MB_OK);
  853. break;
  854. default:
  855. /* DO NOTHING */
  856. break;
  857. }
  858. }
  859. /*********************************************************************
  860. *
  861. * Function : OnLogInitMenu
  862. *
  863. * Description : Handler for WM_INITMENU messages. Enable, disable,
  864. * check, and/or uncheck menu options as apropos.
  865. *
  866. * Parameters :
  867. * 1 : hmenu = handle to menu to "make current"
  868. *
  869. * Returns : N/A
  870. *
  871. *********************************************************************/
  872. void OnLogInitMenu(HMENU hmenu)
  873. {
  874. /* Only enable editors if there is a file to edit */
  875. EnableMenuItem(hmenu, ID_TOOLS_EDITDEFAULTACTIONS, MF_BYCOMMAND | (g_default_actions_file ? MF_ENABLED : MF_GRAYED));
  876. EnableMenuItem(hmenu, ID_TOOLS_EDITUSERACTIONS, MF_BYCOMMAND | (g_user_actions_file ? MF_ENABLED : MF_GRAYED));
  877. EnableMenuItem(hmenu, ID_TOOLS_EDITDEFAULTFILTERS, MF_BYCOMMAND | (g_default_filterfile ? MF_ENABLED : MF_GRAYED));
  878. EnableMenuItem(hmenu, ID_TOOLS_EDITUSERFILTERS, MF_BYCOMMAND | (g_user_filterfile ? MF_ENABLED : MF_GRAYED));
  879. #ifdef FEATURE_TRUST
  880. EnableMenuItem(hmenu, ID_TOOLS_EDITTRUST, MF_BYCOMMAND | (g_trustfile ? MF_ENABLED : MF_GRAYED));
  881. #endif /* def FEATURE_TRUST */
  882. /* Check/uncheck options */
  883. CheckMenuItem(hmenu, ID_VIEW_LOGMESSAGES, MF_BYCOMMAND | (g_bLogMessages ? MF_CHECKED : MF_UNCHECKED));
  884. CheckMenuItem(hmenu, ID_VIEW_MESSAGEHIGHLIGHTING, MF_BYCOMMAND | (g_bHighlightMessages ? MF_CHECKED : MF_UNCHECKED));
  885. CheckMenuItem(hmenu, ID_VIEW_LIMITBUFFERSIZE, MF_BYCOMMAND | (g_bLimitBufferSize ? MF_CHECKED : MF_UNCHECKED));
  886. CheckMenuItem(hmenu, ID_VIEW_ACTIVITYANIMATION, MF_BYCOMMAND | (g_bShowActivityAnimation ? MF_CHECKED : MF_UNCHECKED));
  887. #ifdef FEATURE_TOGGLE
  888. /* by haroon - menu item for Enable toggle on/off */
  889. CheckMenuItem(hmenu, ID_TOGGLE_ENABLED, MF_BYCOMMAND | (global_toggle_state ? MF_CHECKED : MF_UNCHECKED));
  890. #endif /* def FEATURE_TOGGLE */
  891. CheckMenuItem(hmenu, ID_TOGGLE_SHOWWINDOW, MF_BYCOMMAND | (g_bShowLogWindow ? MF_CHECKED : MF_UNCHECKED));
  892. }
  893. /*********************************************************************
  894. *
  895. * Function : OnLogTimer
  896. *
  897. * Description : Handler for WM_TIMER messages.
  898. *
  899. * Parameters :
  900. * 1 : nTimer = timer id (animation start/stop or clip buffer)
  901. *
  902. * Returns : N/A
  903. *
  904. *********************************************************************/
  905. void OnLogTimer(int nTimer)
  906. {
  907. switch (nTimer)
  908. {
  909. case TIMER_ANIM_ID:
  910. TraySetIcon(g_hwndTray, 1, g_hiconAnim[g_nAnimFrame++ % ANIM_FRAMES]);
  911. break;
  912. case TIMER_ANIMSTOP_ID:
  913. g_nAnimFrame = 0;
  914. SetIdleIcon();
  915. KillTimer(g_hwndLogFrame, TIMER_ANIM_ID);
  916. KillTimer(g_hwndLogFrame, TIMER_ANIMSTOP_ID);
  917. break;
  918. case TIMER_CLIPBUFFER_ID:
  919. case TIMER_CLIPBUFFER_FORCE_ID:
  920. LogClipBuffer();
  921. g_bClipPending = FALSE;
  922. KillTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_ID);
  923. KillTimer(g_hwndLogFrame, TIMER_CLIPBUFFER_FORCE_ID);
  924. break;
  925. default:
  926. /* DO NOTHING */
  927. break;
  928. }
  929. }
  930. /*********************************************************************
  931. *
  932. * Function : SetIdleIcon
  933. *
  934. * Description : Sets the tray icon to either idle or off
  935. *
  936. * Parameters : none
  937. *
  938. * Returns : N/A
  939. *
  940. *********************************************************************/
  941. void SetIdleIcon()
  942. {
  943. #ifdef FEATURE_TOGGLE
  944. if (!global_toggle_state)
  945. {
  946. TraySetIcon(g_hwndTray, 1, g_hiconOff);
  947. }
  948. else
  949. #endif /* def FEATURE_TOGGLE */
  950. TraySetIcon(g_hwndTray, 1, g_hiconIdle);
  951. }
  952. /*********************************************************************
  953. *
  954. * Function : LogRichEditProc
  955. *
  956. * Description : Window subclass routine handles some events for the rich edit control.
  957. *
  958. * Parameters :
  959. * 1 : hwnd = window handle of the rich edit control
  960. * 2 : uMsg = message number
  961. * 3 : wParam = first param for this message
  962. * 4 : lParam = next param for this message
  963. *
  964. * Returns : Appropriate M$ window message handler codes.
  965. *
  966. *********************************************************************/
  967. LRESULT CALLBACK LogRichEditProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  968. {
  969. switch (uMsg)
  970. {
  971. case WM_RBUTTONUP:
  972. {
  973. POINT pt;
  974. pt.x = LOWORD(lParam);
  975. pt.y = HIWORD(lParam);
  976. ClientToScreen(hwnd, &pt);
  977. OnLogRButtonUp(wParam, pt.x, pt.y);
  978. return 0;
  979. }
  980. case WM_CHAR:
  981. {
  982. if ((GetKeyState(VK_CONTROL) != 0) && (wParam == 4)) /* ctrl+d */
  983. {
  984. OnLogCommand(ID_VIEW_CLEARLOG);
  985. return 0;
  986. }
  987. }
  988. }
  989. return CallWindowProc(g_fnLogBox, hwnd, uMsg, wParam, lParam);
  990. }
  991. /*********************************************************************
  992. *
  993. * Function : LogWindowProc
  994. *
  995. * Description : Windows call back routine handles events on the log window.
  996. *
  997. * Parameters :
  998. * 1 : hwnd = handle of the logging window
  999. * 2 : uMsg = message number
  1000. * 3 : wParam = first param for this message
  1001. * 4 : lParam = next param for this message
  1002. *
  1003. * Returns : Appropriate M$ window message handler codes.
  1004. *
  1005. *********************************************************************/
  1006. LRESULT CALLBACK LogWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  1007. {
  1008. switch (uMsg)
  1009. {
  1010. case WM_CREATE:
  1011. return 0;
  1012. case WM_CLOSE:
  1013. /* This is the end - my only friend - the end */
  1014. DestroyWindow(g_hwndLogBox);
  1015. DestroyWindow(g_hwndLogFrame);
  1016. return 0;
  1017. case WM_DESTROY:
  1018. PostQuitMessage(0);
  1019. return 0;
  1020. case WM_SHOWWINDOW:
  1021. g_bShowLogWindow = wParam;
  1022. case WM_SIZE:
  1023. /* Resize the logging window to fit the new frame */
  1024. if (g_hwndLogBox)
  1025. {
  1026. RECT rc;
  1027. GetClientRect(g_hwndLogFrame, &rc);
  1028. SetWindowPos(g_hwndLogBox, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOZORDER);
  1029. }
  1030. return 0;
  1031. case WM_INITMENU:
  1032. OnLogInitMenu((HMENU) wParam);
  1033. return 0;
  1034. case WM_TIMER:
  1035. OnLogTimer(wParam);
  1036. return 0;
  1037. case WM_COMMAND:
  1038. OnLogCommand(LOWORD(wParam));
  1039. return 0;
  1040. case WM_SYSCOMMAND:
  1041. switch (wParam)
  1042. {
  1043. case SC_CLOSE:
  1044. if (g_bCloseHidesWindow)
  1045. {
  1046. ShowLogWindow(FALSE);
  1047. return 0;
  1048. }
  1049. break;
  1050. case SC_MINIMIZE:
  1051. ShowLogWindow(FALSE);
  1052. return 0;
  1053. }
  1054. break;
  1055. case WM_CHAR:
  1056. if ((GetKeyState(VK_CONTROL) != 0) && (wParam == 4)) /* ctrl+d */
  1057. {
  1058. OnLogCommand(ID_VIEW_CLEARLOG);
  1059. return 0;
  1060. }
  1061. break;
  1062. }
  1063. return DefWindowProc(hwnd, uMsg, wParam, lParam);
  1064. }
  1065. #endif /* ndef _WIN_CONSOLE - entire file */
  1066. /*
  1067. Local Variables:
  1068. tab-width: 3
  1069. end:
  1070. */