00030 {
00031     
BOOL Success;
00032     
DWORD OldInputMode,OldOutputMode;
00033     
DWORD NewInputMode,NewOutputMode;
00034     
CHAR buff[512];
00035     
DWORD n;
00036 
00037     
00038     
00039     
00040     
00041     
00042     
00043     
00044     
00045     
00046     
00047     
00048     
00049     
00050     
00051     
00052     
00053 
00054     NewInputMode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT;
00055     Success = 
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),
00056                              &OldInputMode
00057                             );
00058     
if (OldInputMode & NewInputMode != NewInputMode) {
00059         
DbgPrint(
"ERROR: OldInputMode is %x\n",OldInputMode);
00060         
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),NewInputMode);
00061     }
00062 
00063     NewOutputMode = ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT;
00064     Success = 
GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),
00065                              &OldOutputMode
00066                             );
00067     
if (OldOutputMode & NewOutputMode != NewOutputMode) {
00068         
DbgPrint(
"ERROR: OldOutputMode is %x\n",OldOutputMode);
00069         
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),NewOutputMode);
00070     }
00071 
00072     
00073     
00074     
00075     
00076     
00077     
00078     
00079     
00080     
DbgPrint(
"input mode is ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT\n");
00081     
DbgPrint(
"output mode is ENABLE_PROCESSED_OUTPUT\n");
00082     
DbgPrint(
"type aTabbcdBackspaceCr\n");
00083     
DbgPrint(
"a       bc should be output string\n");
00084 
00085     Success = ReadFile(GetStdHandle(STD_INPUT_HANDLE),buff,512, &n, NULL);
00086     
if (!Success) {
00087         
DbgPrint(
"ReadFile returned error %d\n",GetLastError());
00088         
return 1;
00089     }
00090     
if (
n != 
PROCESSED_LENGTH) {
00091         
DbgPrint(
"n is %d\n",n);
00092     }
00093     
if (strncmp(ProcessedString,buff,n)) {
00094         
DbgPrint(
"strncmp failed\n");
00095         
DbgPrint(
"ProcessedString contains %s\n",ProcessedString);
00096         
DbgPrint(
"buff contains %s\n",buff);
00097         DbgBreakPoint();
00098     }
00099 
00100     
00101     
00102     
00103     
00104     
00105     
00106 
00107     
DbgPrint(
"input mode is ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT\n");
00108     
DbgPrint(
"output mode is 0\n");
00109     
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_WRAP_AT_EOL_OUTPUT);
00110     
DbgPrint(
"type aTabbcdBackspaceCr\n");
00111     
DbgPrint(
"a0x90x8bc0xd0xa should be output string\n");
00112 
00113     Success = ReadFile(GetStdHandle(STD_INPUT_HANDLE),buff,512, &n, NULL);
00114     
if (!Success) {
00115         
DbgPrint(
"ReadFile returned error %d\n",GetLastError());
00116         
return 1;
00117     }
00118     
if (
n != 
PROCESSED_LENGTH) {
00119         
DbgPrint(
"n is %d\n",n);
00120     }
00121     
if (strncmp(ProcessedString,buff,n)) {
00122         
DbgPrint(
"strncmp failed\n");
00123         
DbgPrint(
"ProcessedString contains %s\n",ProcessedString);
00124         
DbgPrint(
"buff contains %s\n",buff);
00125         DbgBreakPoint();
00126     }
00127 
00128     
00129     
00130     
00131     
00132     
00133     
00134 
00135     
DbgPrint(
"input mode is ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT\n");
00136     
DbgPrint(
"output mode is ENABLE_PROCESSED_OUTPUT\n");
00137     
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT);
00138     
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT);
00139     
DbgPrint(
"type aTabbcdBackspaceCr\n");
00140     
DbgPrint(
"a       bc should be output string\n");
00141 
00142     Success = ReadFile(GetStdHandle(STD_INPUT_HANDLE),buff,512, &n, NULL);
00143     
if (!Success) {
00144         
DbgPrint(
"ReadFile returned error %d\n",GetLastError());
00145         
return 1;
00146     }
00147     
if (
n != 
UNPROCESSED_LENGTH) {
00148         
DbgPrint(
"n is %d\n",n);
00149     }
00150     
if (strncmp(UnprocessedString,buff,n)) {
00151         
DbgPrint(
"strncmp failed\n");
00152         
DbgPrint(
"UnprocessedString contains %s\n",ProcessedString);
00153         
DbgPrint(
"buff contains %s\n",buff);
00154         DbgBreakPoint();
00155     }
00156 
00157     
00158     
00159     
00160     
00161     
00162     
00163 
00164     
DbgPrint(
"input mode is ENABLE_PROCESSED_INPUT\n");
00165     
DbgPrint(
"output mode is ENABLE_PROCESSED_OUTPUT\n");
00166     
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),ENABLE_PROCESSED_INPUT);
00167     
DbgPrint(
"type aTabbcdBackspaceCr\n");
00168     
DbgPrint(
"no string should be output\n");
00169 
00170     Success = ReadFile(GetStdHandle(STD_INPUT_HANDLE),buff,512, &n, NULL);
00171     
if (!Success) {
00172         
DbgPrint(
"ReadFile returned error %d\n",GetLastError());
00173         
return 1;
00174     }
00175     { 
DWORD i=0;
00176       
DWORD j;
00177     
while (Success) {
00178         
DbgPrint(
"n is %d\n",n);
00179         
for (j=0;j<
n;j++,i++) {
00180             
if (
UnprocessedString[i] != buff[j]) {
00181                 
DbgPrint(
"strncmp failed\n");
00182                 
DbgPrint(
"UnprocessedString[i] is %c\n",UnprocessedString[i]);
00183                 
DbgPrint(
"buff[j] is %c\n",buff[j]);
00184                 DbgBreakPoint();
00185             }
00186         }
00187         Success = ReadFile(GetStdHandle(STD_INPUT_HANDLE),buff,512, &n, NULL);
00188         
if (!Success) {
00189             
DbgPrint(
"ReadFile returned error %d\n",GetLastError());
00190             
return 1;
00191         }
00192     }
00193     }
00194     
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE),OldInputMode);
00195     
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE),OldOutputMode);
00196 }