Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tdisp.c File Reference

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>

Go to the source code of this file.

Functions

VOID ErrorExit (VOID)
VOID NotepadPrint (LPWSTR pwsz)
int _cdecl main (int argc, char *argv[])

Variables

BOOL gfNotepad = FALSE


Function Documentation

VOID ErrorExit VOID   ) 
 

Definition at line 9 of file tdisp.c.

References exit, and VOID().

Referenced by CmpAddSubKey(), CmpMarkIndexDirty(), CmpSaveKeyByFileCopy(), CmReplaceKey(), ConsoleClientConnectRoutine(), HvpBuildMap(), HvpEnlistBinInMap(), HvpReadFileImageAndBuildMap(), HvpRecoverData(), InitConsoleIME(), InitWindowsStuff(), InternalScrollDC(), main(), NTFastDOSIO(), and UserHardErrorEx().

00009 { 00010 fprintf(stderr, "Usage: \"tdisp [-n] hex1 [hex2] [width]\"\n"); 00011 fprintf(stderr, " \"tdisp hex\"\n"); 00012 fprintf(stderr, " Displays single Unicode char <hex>\n"); 00013 fprintf(stderr, " \"tdisp hex1 hex2\"\n"); 00014 fprintf(stderr, " Displays Unicode char <hex1> through <hex2>\n"); 00015 fprintf(stderr, " \"tdisp hex1 hex2 n\"\n"); 00016 fprintf(stderr, " Displays <hex1> thru <hex2> in lines of <width> chars\n"); 00017 fprintf(stderr, " -n generates a Notepad Unicode text file on stdout\n"); 00018 exit(2); 00019 }

int _cdecl main int  argc,
char *  argv[]
 

Definition at line 31 of file tdisp.c.

References DWORD, ErrorExit(), gfNotepad, L, n, NotepadPrint(), NULL, STD_OUTPUT_HANDLE, TRUE, and WriteConsoleW().

00031 { 00032 WCHAR wch1, wch2; 00033 int n = 1; 00034 int i; 00035 LPWSTR p; 00036 WCHAR awch[100]; 00037 DWORD cchWritten; 00038 00039 if (argc < 2) { 00040 ErrorExit(); 00041 } 00042 00043 if ((*argv[1] == '/') || (*argv[1] == '-')) { 00044 switch (argv[1][1]) { 00045 case 'n': 00046 gfNotepad = TRUE; 00047 /* Set "stdin" to have binary mode: */ 00048 _setmode( _fileno( stdout ), _O_BINARY ); 00049 printf("%c%c", 0xff, 0xfe); // Unicode BOM 00050 argv++; 00051 break; 00052 default: 00053 ErrorExit(); 00054 } 00055 } 00056 00057 wch1 = (WCHAR)strtol(argv[1], NULL, 16); 00058 if (argc > 2) { 00059 wch2 = (WCHAR)strtol(argv[2], NULL, 16); 00060 if (argc > 3) { 00061 n = atoi(argv[3]); 00062 } 00063 } else { 00064 wch2 = wch1; 00065 } 00066 00067 if (gfNotepad) { 00068 NotepadPrint(L"=======(begin)=======\n"); 00069 } else { 00070 printf("=======(begin)=======\n"); 00071 } 00072 00073 while (wch1 <= wch2) { 00074 i = swprintf(awch, L"0x%04x : --->", wch1); 00075 p = &awch[i]; 00076 for (i = 0; i < n; i++) { 00077 *p++ = wch1++; 00078 } 00079 *p = L'\0'; 00080 wcscat(awch, L"<---\n"); 00081 if (gfNotepad) { 00082 NotepadPrint(awch); 00083 } else { 00084 WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), awch, 00085 wcslen(awch), &cchWritten, NULL); 00086 } 00087 } 00088 00089 if (gfNotepad) { 00090 NotepadPrint(L"========(end)========\n"); 00091 } else { 00092 printf("========(end)========\n"); 00093 } 00094 00095 return 0; 00096 }

VOID NotepadPrint LPWSTR  pwsz  ) 
 

Definition at line 21 of file tdisp.c.

References HIBYTE, LOBYTE, and VOID().

Referenced by main().

00021 { 00022 while (*pwsz) { 00023 if (*pwsz == 0x000a) { 00024 printf("%c%c", 0x0d, 0x00); 00025 } 00026 printf("%c%c", LOBYTE(*pwsz), HIBYTE(*pwsz)); 00027 pwsz++; 00028 } 00029 }


Variable Documentation

BOOL gfNotepad = FALSE
 

Definition at line 7 of file tdisp.c.

Referenced by main().


Generated on Sat May 15 19:45:44 2004 for test by doxygen 1.3.7