Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

746 lines
22 KiB

  1. /*
  2. +-------------------------------------------------------------------------+
  3. | Logging Routines |
  4. +-------------------------------------------------------------------------+
  5. | (c) Copyright 1994 |
  6. | Microsoft Corp. |
  7. | All rights reserved |
  8. | |
  9. | Program : [NWLog.c] |
  10. | Programmer : Arthur Hanson |
  11. | Original Program Date : [Dec 01, 1993] |
  12. | Last Update : [Jun 16, 1994] |
  13. | |
  14. | Version: 1.00 |
  15. | |
  16. | Description: |
  17. | |
  18. | History: |
  19. | arth Jun 16, 1994 1.00 Original Version. |
  20. | |
  21. +-------------------------------------------------------------------------+
  22. */
  23. #include "globals.h"
  24. #include <io.h>
  25. #include <malloc.h>
  26. #include <string.h>
  27. #define VER_HI 1
  28. #define VER_LOW 1
  29. HANDLE hErr = NULL;
  30. HANDLE hLog = NULL;
  31. HANDLE hSummary = NULL;
  32. #define STD_EXT "LOG"
  33. #define ERR_FILENAME "Error."
  34. #define LOG_FILENAME "LogFile."
  35. #define SUMMARY_FILENAME "Summary."
  36. #define MAX_LOG_STR 1024
  37. #define FILENAME_LOG "LogFile.LOG"
  38. #define FILENAME_ERROR "Error.LOG"
  39. #define FILENAME_SUMMARY "Summary.LOG"
  40. static char LogFileName[MAX_PATH + 1];
  41. static char ErrorLogFileName[MAX_PATH + 1];
  42. static char SummaryLogFileName[MAX_PATH + 1];
  43. static char Spaces[] = " ";
  44. static BOOL ErrorFlag;
  45. static TCHAR ErrorContext[MAX_LOG_STR];
  46. static TCHAR ErrorCategory[MAX_LOG_STR];
  47. static TCHAR ErrorItem[MAX_LOG_STR];
  48. static TCHAR ErrorText[MAX_LOG_STR];
  49. static TCHAR tmpStr[MAX_LOG_STR];
  50. static BOOL CategoryWritten;
  51. static BOOL ContextWritten;
  52. static BOOL CategorySet;
  53. static BOOL ItemSet;
  54. static BOOL VerboseULogging = TRUE;
  55. static BOOL VerboseFLogging = TRUE;
  56. static BOOL ErrorBreak = FALSE;
  57. static BOOL LogCancel = FALSE;
  58. /*+-------------------------------------------------------------------------+
  59. | ErrorResetAll()
  60. |
  61. +-------------------------------------------------------------------------+*/
  62. void ErrorResetAll() {
  63. ErrorFlag = FALSE;
  64. CategoryWritten = FALSE;
  65. ContextWritten = FALSE;
  66. CategorySet = FALSE;
  67. ItemSet = FALSE;
  68. lstrcpy(ErrorContext, TEXT(""));
  69. lstrcpy(ErrorCategory, TEXT(""));
  70. } // ErrorResetAll
  71. /*+-------------------------------------------------------------------------+
  72. | ErrorContextSet()
  73. |
  74. | Sets the context for the error message, generally this would be
  75. | the source and destination server pair.
  76. |
  77. +-------------------------------------------------------------------------+*/
  78. void ErrorContextSet(LPTSTR szFormat, ...) {
  79. va_list marker;
  80. va_start(marker, szFormat);
  81. wvsprintf(ErrorContext, szFormat, marker);
  82. // Do category and item as well since context is higher level
  83. lstrcpy(ErrorCategory, TEXT(""));
  84. lstrcpy(ErrorItem, TEXT(""));
  85. ContextWritten = FALSE;
  86. CategoryWritten = FALSE;
  87. va_end(marker);
  88. } // ErrorContextSet
  89. /*+-------------------------------------------------------------------------+
  90. | ErrorCategorySet()
  91. |
  92. | Sets the category for the error message, generally this would tell
  93. | what type of items is being converted: "Converting Users"
  94. |
  95. +-------------------------------------------------------------------------+*/
  96. void ErrorCategorySet(LPTSTR szFormat, ...) {
  97. va_list marker;
  98. va_start(marker, szFormat);
  99. wvsprintf(ErrorCategory, szFormat, marker);
  100. CategorySet = TRUE;
  101. ItemSet = FALSE;
  102. lstrcpy(ErrorItem, TEXT(""));
  103. CategoryWritten = FALSE;
  104. va_end(marker);
  105. } // ErrorCategorySet
  106. /*+-------------------------------------------------------------------------+
  107. | ErrorItemSet()
  108. |
  109. | Defines the specific item that error'd. This is usually a user,
  110. | group or file name.
  111. |
  112. +-------------------------------------------------------------------------+*/
  113. void ErrorItemSet(LPTSTR szFormat, ...) {
  114. va_list marker;
  115. va_start(marker, szFormat);
  116. ItemSet = TRUE;
  117. wvsprintf(ErrorItem, szFormat, marker);
  118. va_end(marker);
  119. } // ErrorItemSet
  120. /*+-------------------------------------------------------------------------+
  121. | ErrorReset()
  122. |
  123. +-------------------------------------------------------------------------+*/
  124. void ErrorReset() {
  125. ErrorFlag = FALSE;
  126. lstrcpy(ErrorText, TEXT(""));
  127. } // ErrorReset
  128. /*+-------------------------------------------------------------------------+
  129. | ErrorSet()
  130. |
  131. +-------------------------------------------------------------------------+*/
  132. void ErrorSet(LPTSTR szFormat, ...) {
  133. va_list marker;
  134. va_start(marker, szFormat);
  135. wvsprintf(ErrorText, szFormat, marker);
  136. ErrorFlag = TRUE;
  137. va_end(marker);
  138. } // ErrorSet
  139. BOOL ErrorOccured() {
  140. return ErrorFlag;
  141. } // ErrorOccured
  142. /*+-------------------------------------------------------------------------+
  143. | ErrorBox()
  144. |
  145. +-------------------------------------------------------------------------+*/
  146. void ErrorBox(LPTSTR szFormat, ...) {
  147. va_list marker;
  148. va_start(marker, szFormat);
  149. wvsprintf(ErrorText, szFormat, marker);
  150. MessageBeep(MB_ICONASTERISK);
  151. MessageBox(NULL, ErrorText, (LPTSTR) Lids(IDS_E_2), MB_TASKMODAL | MB_ICONEXCLAMATION | MB_OK);
  152. va_end(marker);
  153. } // ErrorBox
  154. /*+-------------------------------------------------------------------------+
  155. | ErrorBoxRetry()
  156. |
  157. +-------------------------------------------------------------------------+*/
  158. int ErrorBoxRetry(LPTSTR szFormat, ...) {
  159. int ret;
  160. LPVOID lpMessageBuffer;
  161. va_list marker;
  162. va_start(marker, szFormat);
  163. wvsprintf(ErrorText, szFormat, marker);
  164. FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
  165. NULL, GetLastError(), 0,
  166. (LPTSTR) &lpMessageBuffer, 0, NULL );
  167. MessageBeep(MB_ICONASTERISK);
  168. ret = MessageBox(NULL, (LPTSTR) lpMessageBuffer, ErrorText,
  169. MB_TASKMODAL | MB_ICONEXCLAMATION | MB_RETRYCANCEL);
  170. LocalFree(lpMessageBuffer);
  171. va_end(marker);
  172. return ret;
  173. } // ErrorBoxRetry
  174. /*+-------------------------------------------------------------------------+
  175. | FileOpenBackup()
  176. |
  177. | Tries to open a file, if it already exists then creates a backup
  178. | with the extension in the form (.001 to .999). It tries .001 first
  179. | and if already used then tries .002, etc...
  180. |
  181. +-------------------------------------------------------------------------+*/
  182. HANDLE FileOpenBackup(CHAR *FileRoot, CHAR *FileExt) {
  183. int ret;
  184. HANDLE hFile = NULL;
  185. DWORD dwFileNumber;
  186. char FileName[MAX_PATH + 1];
  187. char buffer[MAX_PATH + 1];
  188. TCHAR FileNameW[MAX_PATH + 1];
  189. wsprintfA(FileName, "%s%s", FileRoot, FileExt);
  190. // Open, but fail if already exists.
  191. hFile = CreateFileA( FileName, GENERIC_READ | GENERIC_WRITE, 0,
  192. NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
  193. // Check if Error - file exists
  194. if(hFile == INVALID_HANDLE_VALUE) {
  195. dwFileNumber = 0;
  196. // Find next backup number...
  197. // Files are backed up as .xxx where xxx is a number in the form .001,
  198. // the first backup is stored as .001, second as .002, etc...
  199. do {
  200. dwFileNumber++;
  201. wsprintfA(FileName, "%s%03u", FileRoot, dwFileNumber);
  202. hFile = CreateFileA( FileName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
  203. FILE_ATTRIBUTE_NORMAL, NULL);
  204. if (hFile != (HANDLE) INVALID_HANDLE_VALUE)
  205. CloseHandle( hFile );
  206. } while ( (hFile != INVALID_HANDLE_VALUE) );
  207. // Rename the last log file to the first available number
  208. wsprintfA( buffer, "%s%s", FileRoot, FileExt);
  209. MoveFileA( buffer, FileName);
  210. lstrcpyA(FileName, buffer);
  211. // Create the new log file
  212. hFile = CreateFileA( FileName, GENERIC_READ | GENERIC_WRITE, 0,
  213. NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
  214. if (hFile != (HANDLE) INVALID_HANDLE_VALUE)
  215. CloseHandle( hFile );
  216. } else
  217. CloseHandle(hFile);
  218. wsprintfA(FileName, "%s%s", FileRoot, FileExt);
  219. // Now do the actual creation with error handling...
  220. do {
  221. ret = IDOK;
  222. hFile = CreateFileA( FileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
  223. FILE_ATTRIBUTE_NORMAL, NULL );
  224. if (hFile == INVALID_HANDLE_VALUE) {
  225. MultiByteToWideChar(CP_ACP, 0, FileName, -1, FileNameW, sizeof(FileNameW) );
  226. ret = ErrorBoxRetry(Lids(IDS_E_13), FileNameW);
  227. }
  228. } while(ret == IDRETRY);
  229. return(hFile);
  230. } // FileOpenBackup
  231. /*+-------------------------------------------------------------------------+
  232. | GetTime()
  233. |
  234. +-------------------------------------------------------------------------+*/
  235. void GetTime(TCHAR *str) {
  236. SYSTEMTIME st;
  237. static TCHAR *aszDay[7];
  238. aszDay[0] = Lids(IDS_SUNDAY);
  239. aszDay[1] = Lids(IDS_MONDAY);
  240. aszDay[2] = Lids(IDS_TUESDAY);
  241. aszDay[3] = Lids(IDS_WEDNESDAY);
  242. aszDay[4] = Lids(IDS_THURSDAY);
  243. aszDay[5] = Lids(IDS_FRIDAY);
  244. aszDay[6] = Lids(IDS_SATURDAY);
  245. GetLocalTime(&st);
  246. wsprintf(str, TEXT("%s, %02u/%02u/%4u (%02u:%02u:%02u)"),
  247. aszDay[st.wDayOfWeek], st.wMonth,
  248. st.wDay, st.wYear,
  249. st.wHour, st.wMinute, st.wSecond);
  250. } // GetTime
  251. /*+-------------------------------------------------------------------------+
  252. | WriteLog()
  253. |
  254. +-------------------------------------------------------------------------+*/
  255. DWORD WriteLog(HANDLE hFile, int Level, LPTSTR String) {
  256. int ret;
  257. DWORD wrote;
  258. static char tmpStr[MAX_LOG_STR];
  259. static char LogStr[MAX_LOG_STR];
  260. // If the user canceled writing to the log, then don't keep trying
  261. if (LogCancel)
  262. return 1;
  263. // Put ending NULL at correct place
  264. Spaces[Level * 3] = '\0';
  265. // Build up indented ANSI string to write out
  266. lstrcpyA(tmpStr, Spaces);
  267. WideCharToMultiByte(CP_ACP, 0, String, -1, LogStr, sizeof(LogStr), NULL, NULL);
  268. lstrcatA(tmpStr, LogStr);
  269. // reset for later writes
  270. Spaces[Level * 3] = ' ';
  271. // Now do the actual write with error handling...
  272. do {
  273. ret = IDOK;
  274. if (!WriteFile(hFile, tmpStr, strlen(tmpStr), &wrote, NULL)) {
  275. ret = ErrorBoxRetry(Lids(IDS_E_NWLOG));
  276. }
  277. } while(ret == IDRETRY);
  278. if (ret == IDCANCEL) {
  279. LogCancel = TRUE;
  280. return 1;
  281. }
  282. else
  283. return 0;
  284. } // WriteLog
  285. /*+-------------------------------------------------------------------------+
  286. | LogHeader()
  287. |
  288. +-------------------------------------------------------------------------+*/
  289. void LogHeader(HANDLE hFile, TCHAR *Title) {
  290. DWORD ret;
  291. DWORD wrote;
  292. static TCHAR time[40];
  293. static TCHAR tmpStr[MAX_LOG_STR];
  294. static TCHAR tmpStr2[MAX_LOG_STR];
  295. static TCHAR *line;
  296. ret = WriteLog(hFile, 0, Lids(IDS_LINE));
  297. wsprintf(tmpStr, Lids(IDS_BRACE), Title);
  298. if (!ret)
  299. ret = WriteLog(hFile, 0, tmpStr);
  300. if (!ret)
  301. ret = WriteLog(hFile, 0, Lids(IDS_LINE));
  302. GetTime(time);
  303. wsprintf(tmpStr, Lids(IDS_L_97), time);
  304. if (!ret)
  305. ret = WriteLog(hFile, 0, tmpStr);
  306. wrote = sizeof(tmpStr2);
  307. GetComputerName(tmpStr2, &wrote);
  308. wsprintf(tmpStr, Lids(IDS_L_98), tmpStr2);
  309. if (!ret)
  310. WriteLog(hFile, 0, tmpStr);
  311. wrote = sizeof(tmpStr);
  312. WNetGetUser(NULL, tmpStr2, &wrote);
  313. wsprintf(tmpStr, Lids(IDS_L_99), tmpStr2);
  314. if (!ret)
  315. ret = WriteLog(hFile, 0, tmpStr);
  316. wsprintf(tmpStr, Lids(IDS_L_100), VER_HI, VER_LOW);
  317. if (!ret)
  318. ret = WriteLog(hFile, 0, tmpStr);
  319. if (!ret)
  320. ret = WriteLog(hFile, 0, Lids(IDS_LINE));
  321. } // LogHeader
  322. /*+-------------------------------------------------------------------------+
  323. | LogInit()
  324. |
  325. +-------------------------------------------------------------------------+*/
  326. void LogInit() {
  327. lstrcpyA(LogFileName, FILENAME_LOG);
  328. lstrcpyA(ErrorLogFileName, FILENAME_ERROR);
  329. lstrcpyA(SummaryLogFileName, FILENAME_SUMMARY);
  330. LogCancel = FALSE;
  331. hErr = FileOpenBackup(ERR_FILENAME, STD_EXT);
  332. hLog = FileOpenBackup(LOG_FILENAME, STD_EXT);
  333. hSummary = FileOpenBackup(SUMMARY_FILENAME, STD_EXT);
  334. LogHeader(hErr, Lids(IDS_L_101));
  335. CloseHandle(hErr);
  336. LogHeader(hLog, Lids(IDS_L_102));
  337. CloseHandle(hLog);
  338. LogHeader(hSummary, Lids(IDS_L_103));
  339. CloseHandle(hSummary);
  340. } // LogInit
  341. /*+-------------------------------------------------------------------------+
  342. | LogWriteLog()
  343. |
  344. +-------------------------------------------------------------------------+*/
  345. void LogWriteLog(int Level, LPTSTR szFormat, ...) {
  346. va_list marker;
  347. va_start(marker, szFormat);
  348. wvsprintf(tmpStr, szFormat, marker);
  349. hLog = CreateFileA( LogFileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  350. SetFilePointer(hLog, 0, NULL, FILE_END);
  351. WriteLog(hLog, Level, tmpStr);
  352. CloseHandle(hLog);
  353. va_end(marker);
  354. } // LogWriteLog
  355. /*+-------------------------------------------------------------------------+
  356. | LogWritErr()
  357. |
  358. +-------------------------------------------------------------------------+*/
  359. void LogWriteErr(LPTSTR szFormat, ...) {
  360. int Indent = 3;
  361. DWORD wrote;
  362. static char LogStr[MAX_LOG_STR];
  363. va_list marker;
  364. va_start(marker, szFormat);
  365. wvsprintf(tmpStr, szFormat, marker);
  366. hErr = CreateFileA( ErrorLogFileName, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  367. SetFilePointer(hErr, 0, NULL, FILE_END);
  368. if (!ContextWritten) {
  369. ContextWritten = TRUE;
  370. WideCharToMultiByte(CP_ACP, 0, ErrorContext, -1, LogStr, sizeof(LogStr), NULL, NULL);
  371. WriteFile(hErr, LogStr, strlen(LogStr), &wrote, NULL);
  372. }
  373. if (CategorySet && !CategoryWritten) {
  374. CategoryWritten = TRUE;
  375. Spaces[3] = '\0';
  376. WriteFile(hLog, Spaces, strlen(Spaces), &wrote, NULL);
  377. WideCharToMultiByte(CP_ACP, 0, ErrorCategory, -1, LogStr, sizeof(LogStr), NULL, NULL);
  378. WriteFile(hErr, LogStr, strlen(LogStr), &wrote, NULL);
  379. Spaces[3] = ' ';
  380. }
  381. if (ItemSet) {
  382. Spaces[6] = '\0';
  383. WriteFile(hLog, Spaces, strlen(Spaces), &wrote, NULL);
  384. WideCharToMultiByte(CP_ACP, 0, ErrorItem, -1, LogStr, sizeof(LogStr), NULL, NULL);
  385. WriteFile(hErr, LogStr, strlen(LogStr), &wrote, NULL);
  386. Spaces[6] = ' ';
  387. }
  388. if (CategorySet)
  389. Indent +=3;
  390. if (ItemSet)
  391. Indent +=3;
  392. Spaces[Indent] = '\0';
  393. WriteFile(hLog, Spaces, strlen(Spaces), &wrote, NULL);
  394. WideCharToMultiByte(CP_ACP, 0, tmpStr, -1, LogStr, sizeof(LogStr), NULL, NULL);
  395. WriteFile(hErr, LogStr, strlen(LogStr), &wrote, NULL);
  396. Spaces[Indent] = ' ';
  397. CloseHandle(hErr);
  398. va_end(marker);
  399. } // LogWriteErr
  400. /*+-------------------------------------------------------------------------+
  401. | LogWriteSummary()
  402. |
  403. +-------------------------------------------------------------------------+*/
  404. void LogWriteSummary(int Level, LPTSTR szFormat, ...) {
  405. DWORD wrote;
  406. static char LogStr[MAX_LOG_STR];
  407. va_list marker;
  408. va_start(marker, szFormat);
  409. Spaces[Level * 3] = '\0';
  410. wvsprintf(tmpStr, szFormat, marker);
  411. WideCharToMultiByte(CP_ACP, 0, tmpStr, -1, LogStr, sizeof(LogStr), NULL, NULL);
  412. hSummary = CreateFileA( SummaryLogFileName, GENERIC_WRITE, 0,
  413. NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
  414. SetFilePointer(hSummary, 0, NULL, FILE_END);
  415. WriteFile(hLog, Spaces, strlen(Spaces), &wrote, NULL);
  416. WriteFile(hSummary, LogStr, strlen(LogStr), &wrote, NULL);
  417. Spaces[Level * 3] = ' ';
  418. CloseHandle(hSummary);
  419. va_end(marker);
  420. } // LogWriteSummary
  421. /*+-------------------------------------------------------------------------+
  422. | DlgLogging()
  423. |
  424. +-------------------------------------------------------------------------+*/
  425. LRESULT CALLBACK DlgLogging(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
  426. HANDLE hFile;
  427. static BOOL UserLogging, FileLogging, ErrorFlag;
  428. int wmId, wmEvent;
  429. static char CmdLine[256];
  430. HWND hCtrl;
  431. switch (message) {
  432. case WM_INITDIALOG:
  433. // Center the dialog over the application window
  434. CenterWindow (hDlg, GetWindow (hDlg, GW_OWNER));
  435. // Toggle User Logging Control
  436. UserLogging = VerboseULogging;
  437. hCtrl = GetDlgItem(hDlg, IDC_CHKUVERBOSE);
  438. if (VerboseULogging)
  439. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  440. else
  441. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  442. // Toggle File Logging Control
  443. FileLogging = VerboseFLogging;
  444. hCtrl = GetDlgItem(hDlg, IDC_CHKFVERBOSE);
  445. if (VerboseFLogging)
  446. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  447. else
  448. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  449. // Toggle Error Popup Control
  450. ErrorFlag = ErrorBreak;
  451. hCtrl = GetDlgItem(hDlg, IDC_CHKERROR);
  452. if (ErrorBreak)
  453. SendMessage(hCtrl, BM_SETCHECK, 1, 0);
  454. else
  455. SendMessage(hCtrl, BM_SETCHECK, 0, 0);
  456. hCtrl = GetDlgItem(hDlg, IDC_VIEWLOG);
  457. // check if logfile exists, if it does allow log file viewing...
  458. hFile = CreateFileA( FILENAME_LOG, GENERIC_READ, 0, NULL, OPEN_EXISTING,
  459. FILE_ATTRIBUTE_NORMAL, NULL);
  460. if (hFile != (HANDLE) INVALID_HANDLE_VALUE)
  461. CloseHandle( hFile );
  462. else
  463. EnableWindow(hCtrl, FALSE);
  464. return (TRUE);
  465. case WM_COMMAND:
  466. wmId = LOWORD(wParam);
  467. wmEvent = HIWORD(wParam);
  468. switch (wmId) {
  469. case IDOK:
  470. VerboseULogging = UserLogging;
  471. VerboseFLogging = FileLogging;
  472. ErrorBreak = ErrorFlag;
  473. EndDialog(hDlg, 0);
  474. return (TRUE);
  475. break;
  476. case IDCANCEL:
  477. EndDialog(hDlg, 0);
  478. return (TRUE);
  479. case IDHELP:
  480. WinHelp(hDlg, HELP_FILE, HELP_CONTEXT, (DWORD) IDC_HELP_LOGGING);
  481. break;
  482. case IDC_VIEWLOG:
  483. lstrcpyA(CmdLine, "LogView ");
  484. lstrcatA(CmdLine, "Error.LOG Summary.LOG LogFile.LOG");
  485. WinExec(CmdLine, SW_SHOW);
  486. return (TRUE);
  487. break;
  488. case IDC_CHKUVERBOSE:
  489. UserLogging = !UserLogging;
  490. return (TRUE);
  491. break;
  492. case IDC_CHKFVERBOSE:
  493. FileLogging = !FileLogging;
  494. return (TRUE);
  495. break;
  496. case IDC_CHKERROR:
  497. ErrorFlag = !ErrorFlag;
  498. return (TRUE);
  499. break;
  500. }
  501. break;
  502. }
  503. return (FALSE); // Didn't process the message
  504. lParam;
  505. } // DlgLogging
  506. /*+-------------------------------------------------------------------------+
  507. | LogOptionsInit()
  508. |
  509. +-------------------------------------------------------------------------+*/
  510. void LogOptionsInit() {
  511. ErrorBreak = FALSE;
  512. VerboseULogging = TRUE;
  513. VerboseFLogging = FALSE;
  514. } // LogOptionsInit
  515. /*+-------------------------------------------------------------------------+
  516. | LogOptionsSave()
  517. |
  518. +-------------------------------------------------------------------------+*/
  519. void LogOptionsSave( HANDLE hFile ) {
  520. DWORD wrote;
  521. WriteFile(hFile, &ErrorBreak, sizeof(ErrorBreak), &wrote, NULL);
  522. WriteFile(hFile, &VerboseFLogging, sizeof(VerboseFLogging), &wrote, NULL);
  523. WriteFile(hFile, &VerboseULogging, sizeof(VerboseULogging), &wrote, NULL);
  524. } // LogOptionsSave
  525. /*+-------------------------------------------------------------------------+
  526. | LogOptionsLoad()
  527. |
  528. +-------------------------------------------------------------------------+*/
  529. void LogOptionsLoad( HANDLE hFile ) {
  530. DWORD wrote;
  531. ReadFile(hFile, &ErrorBreak, sizeof(ErrorBreak), &wrote, NULL);
  532. ReadFile(hFile, &VerboseFLogging, sizeof(VerboseFLogging), &wrote, NULL);
  533. ReadFile(hFile, &VerboseULogging, sizeof(VerboseULogging), &wrote, NULL);
  534. #ifdef DEBUG
  535. dprintf(TEXT("<Log Options Load>\n"));
  536. dprintf(TEXT(" Error Break: %lx\n"), ErrorBreak);
  537. dprintf(TEXT(" Verbose File Logging: %lx\n"), VerboseFLogging);
  538. dprintf(TEXT(" Verbose User Logging: %lx\n\n"), VerboseULogging);
  539. #endif
  540. } // LogOptionsLoad
  541. /*+-------------------------------------------------------------------------+
  542. | PopupOnError()
  543. |
  544. +-------------------------------------------------------------------------+*/
  545. BOOL PopupOnError() {
  546. return ErrorBreak;
  547. } // PopupOnError
  548. /*+-------------------------------------------------------------------------+
  549. | VerboseFileLogging()
  550. |
  551. +-------------------------------------------------------------------------+*/
  552. BOOL VerboseFileLogging() {
  553. return VerboseFLogging;
  554. } // VerboseFileLogging
  555. /*+-------------------------------------------------------------------------+
  556. | VerboseUserLogging()
  557. |
  558. +-------------------------------------------------------------------------+*/
  559. BOOL VerboseUserLogging() {
  560. return VerboseULogging;
  561. } // VerboseUserLogging
  562. /*+-------------------------------------------------------------------------+
  563. | DoLoggingDlg()
  564. |
  565. +-------------------------------------------------------------------------+*/
  566. void DoLoggingDlg(HWND hDlg) {
  567. DLGPROC lpfnDlg;
  568. lpfnDlg = MakeProcInstance((DLGPROC)DlgLogging, hInst);
  569. DialogBox(hInst, TEXT("DlgLogging"), hDlg, lpfnDlg) ;
  570. FreeProcInstance(lpfnDlg);
  571. } // DoLoggingDlg