Implement printf-alike wide string formatting mechanism, currently without floating point numbers support
All checks were successful
Builds / ExectOS (amd64) (push) Successful in 29s
Builds / ExectOS (i686) (push) Successful in 30s

This commit is contained in:
Rafal Kupiec 2024-02-15 22:51:28 +01:00
parent 8a62a2b367
commit 8dd0e70dd9
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
4 changed files with 1426 additions and 3 deletions

View File

@ -12,6 +12,7 @@
#include <xtdefs.h>
#include <xtstruct.h>
#include <xttypes.h>
#include <rtltypes.h>
/* Routines used by XTLDR */
@ -122,6 +123,12 @@ RtlFillMemory(OUT PVOID Destination,
IN SIZE_T Length,
IN UCHAR Value);
XTAPI
XTSTATUS
RtlFormatWideString(IN PRTL_PRINT_CONTEXT Context,
IN PCWSTR Format,
IN VA_LIST ArgumentList);
XTAPI
VOID
RtlMoveMemory(OUT PVOID Destination,

View File

@ -17,14 +17,33 @@
#define GUID_STRING_LENGTH 38
#define PARTUUID_STRING_LENGTH 13
/* Maximum integer value string length */
#define MAX_INTEGER_STRING_SIZE 25
/* Floating point definitions */
#define DOUBLE_EXPONENT_MASK 0x7FF0000000000000ULL
#define DOUBLE_EXPONENT_SHIFT 0x34
#define DOUBLE_EXPONENT_BIAS 0x3FF
/* Runtime Library routine callbacks */
typedef VOID (*PWRITE_CHARACTER)(IN CHAR Character);
typedef VOID (*PWRITE_WIDE_CHARACTER)(IN WCHAR Character);
typedef XTSTATUS (*PWRITE_CHARACTER)(IN CHAR Character);
typedef XTSTATUS (*PWRITE_WIDE_CHARACTER)(IN WCHAR Character);
/* Variable types enumeration list */
typedef enum _RTL_VARIABLE_TYPE
{
Unknown,
AnsiString,
Boolean,
Char,
Float,
Guid,
Integer,
String,
UnicodeString,
WideChar,
WideString
} RTL_VARIABLE_TYPE, *PRTL_VARIABLE_TYPE;
/* Runtime Library print context structure definition */
typedef struct _RTL_PRINT_CONTEXT
@ -32,7 +51,29 @@ typedef struct _RTL_PRINT_CONTEXT
PWRITE_CHARACTER WriteCharacter;
PWRITE_WIDE_CHARACTER WriteWideCharacter;
ULONG CharactersWritten;
ULONG Limit;
} RTL_PRINT_CONTEXT, *PRTL_PRINT_CONTEXT;
/* Runtime Library print format properties structure definition */
typedef struct _RTL_PRINT_FORMAT_PROPERTIES
{
RTL_VARIABLE_TYPE VariableType;
ULONG Radix;
LONG FieldWidth;
LONG IntegerSize;
LONG Precision;
BOOLEAN AlwaysPrintSign;
BOOLEAN LongDouble;
BOOLEAN LongInteger;
BOOLEAN LeftJustified;
BOOLEAN PrintUpperCase;
BOOLEAN PrintLeadingZeroes;
BOOLEAN PrintRadix;
BOOLEAN SpaceForPlus;
BOOLEAN ThousandsGrouping;
BOOLEAN UnsignedValue;
BOOLEAN FloatFormat;
BOOLEAN ScientificFormat;
BOOLEAN SignificantDigitPrecision;
} RTL_PRINT_FORMAT_PROPERTIES, *PRTL_PRINT_FORMAT_PROPERTIES;
#endif /* __XTDK_RTLTYPES_H */

View File

@ -290,4 +290,46 @@ XTCDECL
VOID
RtlRemoveEntryList(IN PLIST_ENTRY Entry);
XTAPI
XTSTATUS
RtlpFormatWideStringArgumentSpecifier(IN PRTL_PRINT_CONTEXT Context,
IN PCWSTR Format,
IN PVA_LIST ArgumentList,
IN OUT PULONG Index);
XTAPI
ULONGLONG
RtlpGetWideStringArgument(IN PVA_LIST ArgumentList,
IN ULONG ArgumentNumber,
IN LONG ArgumentSize);
XTAPI
ULONGLONG
RtlpGetWideStringSpecifierValue(IN PWCHAR *Format);
XTAPI
XTSTATUS
RtlpWriteWideCharacter(IN PRTL_PRINT_CONTEXT Context,
IN WCHAR Character);
XTAPI
XTSTATUS
RtlpWriteWideStringIntegerValue(IN PRTL_PRINT_CONTEXT Context,
IN PRTL_PRINT_FORMAT_PROPERTIES FormatProperties,
IN ULONGLONG Integer);
XTAPI
XTSTATUS
RtlpWriteWideStringStringValue(PRTL_PRINT_CONTEXT Context,
PRTL_PRINT_FORMAT_PROPERTIES FormatProperties,
PCHAR String,
BOOLEAN Character);
XTAPI
XTSTATUS
RtlpWriteWideStringValue(PRTL_PRINT_CONTEXT Context,
PRTL_PRINT_FORMAT_PROPERTIES FormatProperties,
PWCHAR String,
BOOLEAN Character);
#endif /* __XTOSKRNL_RTLI_H */

File diff suppressed because it is too large Load Diff