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

tmode.c File Reference

#include "precomp.h"

Go to the source code of this file.

Defines

#define UNPROCESSED_LENGTH   7
#define PROCESSED_LENGTH   6

Functions

DWORD main (VOID)

Variables

CHAR UnprocessedString [UNPROCESSED_LENGTH] = "a\tbcd\b\r"
CHAR ProcessedString [PROCESSED_LENGTH] = "a\tbc\r\n"


Define Documentation

#define PROCESSED_LENGTH   6
 

Definition at line 25 of file tmode.c.

Referenced by main().

#define UNPROCESSED_LENGTH   7
 

Definition at line 24 of file tmode.c.

Referenced by main().


Function Documentation

DWORD main VOID   ) 
 

Definition at line 29 of file tmode.c.

References BOOL, CHAR, DbgPrint, DWORD, GetConsoleMode(), n, NULL, PROCESSED_LENGTH, ProcessedString, SetConsoleMode(), STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, UNPROCESSED_LENGTH, and UnprocessedString.

00030 { 00031 BOOL Success; 00032 DWORD OldInputMode,OldOutputMode; 00033 DWORD NewInputMode,NewOutputMode; 00034 CHAR buff[512]; 00035 DWORD n; 00036 00037 // 00038 // test input and output modes 00039 // 00040 // Input Mode flags: 00041 // 00042 // ENABLE_PROCESSED_INPUT 0x0001 00043 // ENABLE_LINE_INPUT 0x0002 00044 // ENABLE_ECHO_INPUT 0x0004 00045 // ENABLE_WINDOW_INPUT 0x0008 00046 // ENABLE_MOUSE_INPUT 0x0010 00047 // 00048 // Output Mode flags: 00049 // 00050 // ENABLE_PROCESSED_OUTPUT 0x0001 00051 // ENABLE_WRAP_AT_EOL_OUTPUT 0x0002 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 // mode set: 00074 // 00075 // ENABLE_PROCESSED_INPUT - backspace, tab, cr, lf, ctrl-z 00076 // ENABLE_LINE_INPUT - wait for linefeed 00077 // ENABLE_ECHO_INPUT 00078 // ENABLE_PROCESSED_OUTPUT - backspace, tab, cr, lf, bell 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 // mode set: 00102 // 00103 // ENABLE_PROCESSED_INPUT 00104 // ENABLE_LINE_INPUT 00105 // ENABLE_ECHO_INPUT 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 // mode set: 00130 // 00131 // ENABLE_LINE_INPUT 00132 // ENABLE_ECHO_INPUT 00133 // ENABLE_PROCESSED_OUTPUT 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 // mode set: 00159 // 00160 // ENABLE_PROCESSED_INPUT 00161 // ENABLE_PROCESSED_OUTPUT 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 }


Variable Documentation

CHAR ProcessedString[PROCESSED_LENGTH] = "a\tbc\r\n"
 

Definition at line 27 of file tmode.c.

Referenced by main().

CHAR UnprocessedString[UNPROCESSED_LENGTH] = "a\tbcd\b\r"
 

Definition at line 26 of file tmode.c.

Referenced by main().


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