- Fix InterlockedBitTestAndReset and InterlockedBitTestAndSet
[reactos.git] / rosapps / dflat32 / log.c
1 /* ------------ log .c ------------ */
2
3 #include "dflat.h"
4
5 #ifdef INCLUDE_LOGGING
6
7 static char *message[] = {
8 #undef DFlatMsg
9 #define DFlatMsg(m) " " #m,
10 #include "dflatmsg.h"
11 NULL
12 };
13
14 static FILE *logfile = NULL;
15 extern DF_DBOX Log;
16
17 void DfLogMessages (DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
18 {
19 if (logfile != NULL && message[msg][0] != ' ')
20 fprintf(logfile,
21 "%-20.20s %-12.12s %-20.20s, %5.5ld, %5.5ld\n",
22 wnd ? (DfGetTitle(wnd) ? DfGetTitle(wnd) : "") : "",
23 wnd ? DfClassNames[DfGetClass(wnd)] : "",
24 message[msg]+1, p1, p2);
25 }
26
27 static int LogProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
28 {
29 DFWINDOW cwnd = DfControlWindow(&Log, DF_ID_LOGLIST);
30 char **mn = message;
31 switch (msg) {
32 case DFM_INITIATE_DIALOG:
33 DfAddAttribute(cwnd, DF_MULTILINE | DF_VSCROLLBAR);
34 while (*mn) {
35 DfSendMessage(cwnd, DFM_ADDTEXT, (DF_PARAM) (*mn), 0);
36 mn++;
37 }
38 DfSendMessage(cwnd, DFM_SHOW_WINDOW, 0, 0);
39 break;
40 case DFM_COMMAND:
41 if ((int) p1 == DF_ID_OK) {
42 int item;
43 int tl = DfGetTextLines(cwnd);
44 for (item = 0; item < tl; item++)
45 if (DfItemSelected(cwnd, item))
46 mn[item][0] = DF_LISTSELECTOR;
47 }
48 break;
49 default:
50 break;
51 }
52 return DfDefaultWndProc(wnd, msg, p1, p2);
53 }
54
55 void DfMessageLog(DFWINDOW wnd)
56 {
57 if (DfDialogBox(wnd, &Log, TRUE, LogProc))
58 {
59 if (DfCheckBoxSetting(&Log, DF_ID_LOGGING))
60 {
61 logfile = fopen("DFLAT.LOG", "wt");
62 DfSetCommandToggle(&DfMainMenu, DF_ID_LOG);
63 }
64 else if (logfile != NULL)
65 {
66 fclose(logfile);
67 logfile = NULL;
68 DfClearCommandToggle(&DfMainMenu, DF_ID_LOG);
69 }
70 }
71 }
72
73 #endif
74
75 /* EOF */