|
|
| version 1.3, 2003/11/14 07:37:29 | version 1.9, 2004/03/07 01:23:14 |
|---|---|
| Line 38 extern HINSTANCE hPrev; | Line 38 extern HINSTANCE hPrev; |
| enum { | enum { |
| IDM_TRACEEN = 3300, | IDM_TRACEEN = 3300, |
| IDM_TRACEFH | IDM_TRACEFH, |
| IDM_TRACECL | |
| }; | }; |
| static const char ProgTitle[] = "console"; | static const char ProgTitle[] = "console"; |
| Line 46 static const char ClassName[] = "TRACE-c | Line 47 static const char ClassName[] = "TRACE-c |
| static const char ClassEdit[] = "EDIT"; | static const char ClassEdit[] = "EDIT"; |
| static const char traceen[] = "Enable"; | static const char traceen[] = "Enable"; |
| static const char tracefh[] = "File out"; | static const char tracefh[] = "File out"; |
| static const char tracecl[] = "Clear"; | |
| static const char crlf[] = "\r\n"; | |
| static TRACEWIN tracewin; | static TRACEWIN tracewin; |
| static HWND hView = NULL; | static HWND hView = NULL; |
| Line 71 static void View_ScrollToBottom(HWND hWn | Line 74 static void View_ScrollToBottom(HWND hWn |
| PostMessage(hWnd, EM_LINESCROLL, 0, MaxPos); | PostMessage(hWnd, EM_LINESCROLL, 0, MaxPos); |
| } | } |
| static void View_ClrString(void) { | |
| szView[0] = '\0'; | |
| SetWindowText(hView, szView); | |
| } | |
| static void View_AddString(const char *lpszString) { | static void View_AddString(const char *lpszString) { |
| int len, vlen; | int len, vlen; |
| Line 92 static void View_AddString(const char *l | Line 101 static void View_AddString(const char *l |
| strcpy(szView, p); | strcpy(szView, p); |
| } | } |
| strcat(szView, lpszString); | strcat(szView, lpszString); |
| strcat(szView, str_crlf); | strcat(szView, crlf); |
| SetWindowText(hView, szView); | SetWindowText(hView, szView); |
| View_ScrollToBottom(hView); | View_ScrollToBottom(hView); |
| } | } |
| Line 109 static LRESULT CALLBACK traceproc(HWND h | Line 118 static LRESULT CALLBACK traceproc(HWND h |
| IDM_TRACEEN, traceen); | IDM_TRACEEN, traceen); |
| InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING, | InsertMenu(hmenu, 1, MF_BYPOSITION | MF_STRING, |
| IDM_TRACEFH, tracefh); | IDM_TRACEFH, tracefh); |
| InsertMenu(hmenu, 2, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | InsertMenu(hmenu, 2, MF_BYPOSITION | MF_STRING, |
| IDM_TRACECL, tracecl); | |
| InsertMenu(hmenu, 3, MF_BYPOSITION | MF_SEPARATOR, 0, NULL); | |
| CheckMenuItem(hmenu, IDM_TRACEEN, | CheckMenuItem(hmenu, IDM_TRACEEN, |
| (tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED); | (tracewin.en & 1)?MF_CHECKED:MF_UNCHECKED); |
| Line 161 static LRESULT CALLBACK traceproc(HWND h | Line 172 static LRESULT CALLBACK traceproc(HWND h |
| MF_CHECKED:MF_UNCHECKED); | MF_CHECKED:MF_UNCHECKED); |
| break; | break; |
| case IDM_TRACECL: | |
| View_ClrString(); | |
| break; | |
| default: | default: |
| return(DefWindowProc(hWnd, msg, wp, lp)); | return(DefWindowProc(hWnd, msg, wp, lp)); |
| } | } |
| Line 249 void trace_init(void) { | Line 264 void trace_init(void) { |
| } | } |
| } | } |
| tracewin.en = 1; | #if 1 |
| tracewin.en = 0; | |
| tracewin.fh = FILEH_INVALID; | tracewin.fh = FILEH_INVALID; |
| #else | |
| tracewin.en = 0; | |
| tracewin.fh = file_create_c("traces.txt"); | |
| #endif | |
| tracecfg.posx = CW_USEDEFAULT; | tracecfg.posx = CW_USEDEFAULT; |
| tracecfg.posy = CW_USEDEFAULT; | tracecfg.posy = CW_USEDEFAULT; |
| Line 291 void trace_fmt(const char *fmt, ...) { | Line 311 void trace_fmt(const char *fmt, ...) { |
| va_list ap; | va_list ap; |
| char buf[0x1000]; | char buf[0x1000]; |
| va_start(ap, fmt); | |
| vsprintf(buf, fmt, ap); | |
| va_end(ap); | |
| if (hView) { | |
| View_AddString(buf); | |
| } | |
| if (tracewin.fh != FILEH_INVALID) { | |
| file_write(tracewin.fh, buf, strlen(buf)); | |
| file_write(tracewin.fh, crlf, strlen(crlf)); | |
| } | |
| } | |
| void trace_fmt2(const char *fmt, ...) { | |
| BOOL en; | |
| va_list ap; | |
| char buf[0x1000]; | |
| en = (tracewin.en & 1) || (tracewin.fh != FILEH_INVALID); | en = (tracewin.en & 1) || (tracewin.fh != FILEH_INVALID); |
| if (en) { | if (en) { |
| va_start(ap, fmt); | va_start(ap, fmt); |
| Line 301 void trace_fmt(const char *fmt, ...) { | Line 339 void trace_fmt(const char *fmt, ...) { |
| } | } |
| if (tracewin.fh != FILEH_INVALID) { | if (tracewin.fh != FILEH_INVALID) { |
| file_write(tracewin.fh, buf, strlen(buf)); | file_write(tracewin.fh, buf, strlen(buf)); |
| file_write(tracewin.fh, str_crlf, strlen(str_crlf)); | file_write(tracewin.fh, crlf, strlen(crlf)); |
| } | } |
| } | } |
| } | } |
| void trace_fileout(const char *fname) { | |
| if (tracewin.fh != FILEH_INVALID) { | |
| file_close(tracewin.fh); | |
| tracewin.fh = FILEH_INVALID; | |
| } | |
| if (fname) { | |
| tracewin.fh = file_create_c(fname); | |
| } | |
| } | |
| #endif | #endif |