Cross-platform sprintf support with RIP related extensions. More...
Files | |
file | swcopyf.h |
Header file defining String formatting functions. | |
Functions | |
int32 | vswcopyf (uint8 *destination, const uint8 *format, va_list ap) |
Equivalent to vsprintf. More... | |
int32 | swcopyf (uint8 *destination, const uint8 *format,...) |
Equivalent to sprintf. More... | |
int32 | vswncopyf (uint8 *destination, int32 len, const uint8 *format, va_list ap) |
Equivalent to vsnprintf. More... | |
int32 | swncopyf (uint8 *destination, int32 len, const uint8 *format,...) |
Equivalent to snprintf. More... | |
int32 | swncopyduration (uint8 *destination, int32 len, int32 millisecs) |
Format a duration, expressing in hours, minutes, and seconds, and also summarised in a machine-parseable format. More... | |
Cross-platform sprintf support with RIP related extensions.
The format string supported by swcopyf() and related functions is a sequence of ordinary characters and conversion specifications, introduced by '%'. Conversion specifications have the general form:
%[flags][width][.precision][size|escape]type
Conversion specifications usually consume one or more arguments from the variable argument list supplied. The variable argument list must be supplied with the correct number and types of values to match the format.
The flags are output modifiers that change signs, justification, etc. The flags supported by swcopyf() and related functions are:
The width part of the conversion specification is a minimum field width. If the output would be shorter than this width, it is padded with spaces (or zeros, if right justified and the '0' flag is used for numerics), either to the left or right of the output, depending on the justification flag. If the output is longer than the width specified, it will continue to its normal width. The width can be specified directly using a decimal number, or indirectly by '*'. An indirect width specification consumes the next argument as an int32 to supply the width. If a negative width is provided through an indirect width, the output is left-justified.
The precision part of the conversion limits the size of the output. For strings, the precision truncates the width of the output at the precision. For integral values, the precision determines the minimum number of digits to output. For real values, the precision determines the number of significant digits (for 'g' and 'G' types), or the number of digits to appear after the decimal point (for 'e', 'E', 'f', and 'F' types). The precision can be specified directly using a period followed by a decimal number, or indirectly by '.*'. An indirect precision specification consumes the next argument as an int32 to supply the precision.
The size part of the specification determines the size of the argument taken from the variable argument list. The size specifications supported by swcopyf() and related functions are:
The size part is optional, so omitting it will interpret the argument as the size of an int, for numeric output. The size modifier does not apply to all types of conversion.
Other printf sizes (hh, ll, L, j and t) are not supported.
String conversions may use an escape modifier instead of a size (GGS extension). The escape modifier is introduced by '!', and may optionally be followed by '7' or '8'. The meanings of these modifiers are:
The type of the conversion specification is a single character:
promoted_real
as a signed value using the exponent form [-]9.9999e[+|-]999. The digit before the decimal point is non-zero if the value is non-zero. The precision determines how many digits appear between the decimal point and the exponent character. The value zero has an exponent of zero. The alternate form when using the '#' modifier always contains a decimal point, even if no digits follow it. Binary token format (machine byte order) using the '=' modifier is supported. promoted_real
as a signed value using the non-exponent form [-]9999.9999. The precision determines how many digits follow the decimal point. The alternate form when using the '#' modifier always contains a decimal point, even if no digits follow it. Binary token format (machine byte order) using the '=' modifier is supported. promoted_real
in either the 'e' or 'f' form, based on the value and precision. An exponent less than -4 or greater than the precision selects the 'e' form. Trailing zeros and the decimal point are printed only if necessary. The alternate form when using the '#' modifier always contains a decimal point, even if no digits follow it, and trailing zeros are not removed. Binary token format (machine byte order) using the '=' modifier is supported. promoted_real
in either the 'E' or 'F' form, based on the value and precision. An exponent less than -4 or greater than the precision selects the 'E' form. Trailing zeros and the decimal point are printed only if necessary. The alternate form when using the '#' modifier always contains a decimal point, even if no digits follow it, and trailing zeros are not removed. Binary token format (machine byte order) using the '=' modifier is supported. No other conversion specification characters should be used in the format string. Global Graphics may extend the conversions supported at any time, using other conversion specification characters.
The printf conversions a, A and n are not supported.
Equivalent to sprintf.
[out] | destination | A pointer to a buffer to which output will be stored. Since this function does not perform length validation, the caller must supply a buffer of sufficient length for any possible output. |
[in] | format | A sprintf-like format string, describing the fixed and variable portions of the data stored in destination. |
[in] | ... | A variable-length list of arguments, interpreted according to format. |
It is recommended that swncopyf() is used instead of this function.
Format a duration, expressing in hours, minutes, and seconds, and also summarised in a machine-parseable format.
This is used to format durations expressed in the RIP's monitor output.
[out] | destination | A pointer to a buffer to which output will be stored. |
[in] | len | The size of the buffer pointed to by destination. |
[in] | millisecs | A non-negative duration, expressed in milliseconds. |
Equivalent to snprintf.
[out] | destination | A pointer to a buffer to which output will be stored. |
[in] | len | The size of the buffer pointed to by destination. |
[in] | format | A sprintf-like format string, describing the fixed and variable portions of the data stored in destination. |
[in] | ... | A variable-length list of arguments, interpreted according to format. |
Equivalent to vsprintf.
[out] | destination | A pointer to a buffer to which output will be stored. Since this function does not perform length validation, the caller must supply a buffer of sufficient length for any possible output. |
[in] | format | A sprintf-like format string, describing the fixed and variable portions of the data stored in destination. |
[in] | ap | A handle to a variable-length list of arguments, interpreted according to format. |
It is recommended that vswncopyf() is used instead of this function.
Equivalent to vsnprintf.
[out] | destination | A pointer to a buffer to which output will be stored. |
[in] | len | The size of the buffer pointed to by destination. |
[in] | format | A sprintf-like format string, describing the fixed and variable portions of the data stored in destination. |
[in] | ap | A handle to a variable-length list of arguments, interpreted according to format. |