Process Hacker
format.c File Reference
#include <phbase.h>
#include <locale.h>
#include "format_i.h"

Go to the source code of this file.

Macros

#define SMALL_BUFFER_LENGTH   (PH_OBJECT_SMALL_OBJECT_SIZE - FIELD_OFFSET(PH_STRING, Data) - sizeof(WCHAR))
 
#define BUFFER_SIZE   512
 
#define PHP_FORMAT_NEGATIVE   0x1
 
#define PHP_FORMAT_POSITIVE   0x2
 
#define PHP_FORMAT_PAD   0x4
 
#define ENSURE_BUFFER(NeededLength)
 
#define OK_BUFFER   (TRUE)
 
#define ADVANCE_BUFFER(Length)   do { buffer += (Length) / sizeof(WCHAR); usedLength += (Length); } while (0)
 
#define ENSURE_BUFFER(NeededLength)
 
#define OK_BUFFER   (!overrun)
 
#define ADVANCE_BUFFER(Length)   do { buffer += (Length) / sizeof(WCHAR); usedLength += (Length); } while (0)
 

Functions

errno_t __cdecl _cfltcvt_l (double *arg, char *buffer, size_t sizeInBytes, int format, int precision, int caps, _locale_t plocinfo)
 
void __cdecl _cropzeros_l (char *_Buf, _locale_t _Locale)
 
void __cdecl _forcdecpt_l (char *_Buf, _locale_t _Locale)
 
PPH_STRING PhpResizeFormatBuffer (_In_ PPH_STRING String, _Inout_ PSIZE_T AllocatedLength, _In_ SIZE_T UsedLength, _In_ SIZE_T NeededLength)
 
PPH_STRING PhFormat (_In_reads_(Count) PPH_FORMAT Format, _In_ ULONG Count, _In_opt_ SIZE_T InitialCapacity)
 Creates a formatted string.
 
BOOLEAN PhFormatToBuffer (_In_reads_(Count) PPH_FORMAT Format, _In_ ULONG Count, _Out_writes_bytes_opt_(BufferLength) PWSTR Buffer, _In_opt_ SIZE_T BufferLength, _Out_opt_ PSIZE_T ReturnLength)
 Writes a formatted string to a buffer.
 

Variables

ULONG PhMaxSizeUnit
 

Macro Definition Documentation

#define ADVANCE_BUFFER (   Length)    do { buffer += (Length) / sizeof(WCHAR); usedLength += (Length); } while (0)
#define ADVANCE_BUFFER (   Length)    do { buffer += (Length) / sizeof(WCHAR); usedLength += (Length); } while (0)
#define BUFFER_SIZE   512

Definition at line 41 of file format.c.

#define ENSURE_BUFFER (   NeededLength)
Value:
do { \
if (allocatedLength < usedLength + (NeededLength)) \
{ \
string = PhpResizeFormatBuffer(string, &allocatedLength, usedLength, (NeededLength)); \
buffer = string->Buffer + usedLength / sizeof(WCHAR); \
} \
} while (0)
#define ENSURE_BUFFER (   NeededLength)
Value:
do { \
if (!overrun && (BufferLength < usedLength + (NeededLength))) \
overrun = TRUE; \
} while (0)
#define OK_BUFFER   (TRUE)
#define OK_BUFFER   (!overrun)
#define PHP_FORMAT_NEGATIVE   0x1

Definition at line 43 of file format.c.

#define PHP_FORMAT_PAD   0x4

Definition at line 45 of file format.c.

#define PHP_FORMAT_POSITIVE   0x2

Definition at line 44 of file format.c.

#define SMALL_BUFFER_LENGTH   (PH_OBJECT_SMALL_OBJECT_SIZE - FIELD_OFFSET(PH_STRING, Data) - sizeof(WCHAR))

Definition at line 40 of file format.c.

Function Documentation

errno_t __cdecl _cfltcvt_l ( double *  arg,
char *  buffer,
size_t  sizeInBytes,
int  format,
int  precision,
int  caps,
_locale_t  plocinfo 
)
void __cdecl _cropzeros_l ( char *  _Buf,
_locale_t  _Locale 
)
void __cdecl _forcdecpt_l ( char *  _Buf,
_locale_t  _Locale 
)
PPH_STRING PhFormat ( _In_reads_(Count) PPH_FORMAT  Format,
_In_ ULONG  Count,
_In_opt_ SIZE_T  InitialCapacity 
)

Creates a formatted string.

Parameters
FormatAn array of format structures.
CountThe number of structures supplied in Format.
InitialCapacityThe number of bytes to reserve initially for the string. If 0 is specified, a default value is used.

Definition at line 105 of file format.c.

BOOLEAN PhFormatToBuffer ( _In_reads_(Count) PPH_FORMAT  Format,
_In_ ULONG  Count,
_Out_writes_bytes_opt_(BufferLength) PWSTR  Buffer,
_In_opt_ SIZE_T  BufferLength,
_Out_opt_ PSIZE_T  ReturnLength 
)

Writes a formatted string to a buffer.

Parameters
FormatAn array of format structures.
CountThe number of structures supplied in Format.
BufferA buffer. If NULL, no data is written.
BufferLengthThe number of bytes available in Buffer, including space for the null terminator.
ReturnLengthThe number of bytes required to hold the string, including the null terminator.
Returns
TRUE if the buffer was large enough and the string was written (i.e. BufferLength >= ReturnLength), otherwise FALSE. In either case, the required number of bytes is stored in ReturnLength.
Remarks
If the function fails but BufferLength != 0, a single null byte is written to the start of Buffer.

Definition at line 175 of file format.c.

PPH_STRING PhpResizeFormatBuffer ( _In_ PPH_STRING  String,
_Inout_ PSIZE_T  AllocatedLength,
_In_ SIZE_T  UsedLength,
_In_ SIZE_T  NeededLength 
)

Definition at line 72 of file format.c.

Variable Documentation

ULONG PhMaxSizeUnit

Definition at line 52 of file support.c.