| T X T _ V C B P S N P R I N T F ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
INDEP - TXT_#?
----------------------------------------------------------------------------
NAME
txt_vcbpsnprintf() - Produces output according to the fmt.
SYNOPSIS
length = txt_vcbpsnprintf(putfunc, buffer, size, vfmt, ap);
__nifunc __interrupt LONG txt_vcbpsnprintf(void (*)(
register UBYTE * __asm("a0"),
register LONG __asm("d0")),
UBYTE *, LONG, const UBYTE *, va_list);
FUNCTION
This function does exactly what 'txt_vpsnprintf()' does,
but the output can be built/redirected through the callback
function.
INPUTS
putfunc - Callback function.
buffer - Output buffer(will be NULL terminated).
size - Output buffer size.
vfmt - Formatting string.
ap - Variable args pointer.
RETURNS
Returns length of newly formatted string or negative value
if string had to be truncated.
BASES
None.
NOTES
Please disregard direct registers in prototype. Only Amiga
makes use of them. Other platforms will follow the default
arguments passing conventions.
Argument 'buffer' can be used to carry user data, but this
will be true only on first char printout!
Beware! Using '%b' with BCPL data on stack may result in
address mess! All addresses to be BCPLed must be multiple
of 4! See 'testsuite/textfuncs-test.c' for more details.
SEE ALSO
txt_vpsnprintf(), txt_debugprintf()
EXAMPLE
...
/*
* Callback function.
*/
__saveds __interrupt void myputfunc(REGARG(UBYTE *ptr, a0),
REGARG(LONG chr, d0))
{
/*
* This will make it act as 'txt_vpsnprintf()'. Yep, ptr
* is increasing internally. You can put something else
* in here, 'RawPutChar()' maybe?
*/
*ptr = chr;
}
/*
* Main function.
*/
__interrupt LONG mysnprintf(
UBYTE *ptr, LONG, len, UBYTE *fmt, ...)
{
va_list ap;
LONG res;
va_start(ap, fmt);
res = txt_vcbpsnprintf(myputfunc, ptr, len, fmt, ap);
va_end(ap);
return res;
}
...
UBYTE buf[256];
buf[0] = '\0';
mysnprintf(buf, 256, "%s %s %ld!", "Printo", "numero", 1);
FPrintf(Output(), "%s\n", (LONG)buf);
BUGS
None known.
----------------------------------------------------------------------------
| |
| |