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

misc.c File Reference

#include "stdarg.h"
#include "stdio.h"
#include "ntddk.h"
#include "fsvga.h"
#include "fsvgalog.h"

Go to the source code of this file.

Functions

int ConvertOutputToOem (IN LPWSTR Source, IN int SourceLength, OUT LPSTR Target, IN int TargetLength)
NTSTATUS TranslateOutputToOem (OUT PCHAR_IMAGE_INFO OutputBuffer, IN PCHAR_IMAGE_INFO InputBuffer, IN DWORD Length)


Function Documentation

int ConvertOutputToOem IN LPWSTR  Source,
IN int  SourceLength,
OUT LPSTR  Target,
IN int  TargetLength
 

Definition at line 31 of file w32/ntcon/fullscr/vga/misc.c.

References CHAR, FALSE, NT_SUCCESS, NTSTATUS(), RtlUnicodeStringToAnsiString(), Status, and strlen().

00045 { 00046 NTSTATUS Status; 00047 int Length; 00048 UNICODE_STRING SourceUni; 00049 ANSI_STRING TargetAns; 00050 CHAR AnsBuf[256]; 00051 00052 SourceUni.MaximumLength = 00053 SourceUni.Length = SourceLength * sizeof(WCHAR); 00054 SourceUni.Buffer = Source; 00055 00056 TargetAns.Length = 0; 00057 TargetAns.MaximumLength = sizeof(AnsBuf); 00058 TargetAns.Buffer = AnsBuf; 00059 00060 // Can do this in place 00061 Status = RtlUnicodeStringToAnsiString(&TargetAns, 00062 &SourceUni, 00063 FALSE); 00064 if (NT_SUCCESS(Status)) { 00065 Length = strlen(AnsBuf); 00066 if (Length <= TargetLength) { 00067 RtlMoveMemory(Target, AnsBuf, Length); 00068 return Length; 00069 } 00070 else { 00071 return 0; 00072 } 00073 } else { 00074 return 0; 00075 } 00076 }

NTSTATUS TranslateOutputToOem OUT PCHAR_IMAGE_INFO  OutputBuffer,
IN PCHAR_IMAGE_INFO  InputBuffer,
IN DWORD  Length
 

Definition at line 86 of file w32/ntcon/fullscr/vga/misc.c.

References CHAR, and ConvertOutputToOem().

Referenced by FsVgaWriteToFrameBuffer(), and SrvReadConsoleOutput().

00091 { 00092 CHAR AsciiDbcs[2]; 00093 ULONG NumBytes; 00094 00095 while (Length--) 00096 { 00097 if (InputBuffer->CharInfo.Attributes & COMMON_LVB_LEADING_BYTE) 00098 { 00099 if (Length >= 2) // Safe DBCS in buffer ? 00100 { 00101 Length--; 00102 NumBytes = sizeof(AsciiDbcs); 00103 NumBytes = ConvertOutputToOem(&InputBuffer->CharInfo.Char.UnicodeChar, 00104 1, 00105 &AsciiDbcs[0], 00106 NumBytes); 00107 OutputBuffer->CharInfo.Char.AsciiChar = AsciiDbcs[0]; 00108 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00109 OutputBuffer++; 00110 InputBuffer++; 00111 OutputBuffer->CharInfo.Char.AsciiChar = AsciiDbcs[1]; 00112 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00113 OutputBuffer++; 00114 InputBuffer++; 00115 } 00116 else 00117 { 00118 OutputBuffer->CharInfo.Char.AsciiChar = ' '; 00119 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes & ~COMMON_LVB_SBCSDBCS; 00120 OutputBuffer++; 00121 InputBuffer++; 00122 } 00123 } 00124 else if (! (InputBuffer->CharInfo.Attributes & COMMON_LVB_SBCSDBCS)) 00125 { 00126 ConvertOutputToOem(&InputBuffer->CharInfo.Char.UnicodeChar, 00127 1, 00128 &OutputBuffer->CharInfo.Char.AsciiChar, 00129 1); 00130 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00131 OutputBuffer++; 00132 InputBuffer++; 00133 } 00134 } 00135 00136 return STATUS_SUCCESS; 00137 }


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