vsnprintf(3scl)vsnprintf(3scl)NAMEvsnprintf - print formatted output to a buffer
LIBRARY
SCL Miscellaneous Library (libsolmisc.so, libsolmisc.a)
SYNOPSIS
#include <stdarg.h> #include <stdio.h>
int vsnprintf(char *string,
size_t n,
const char *format,
va_list arglist);
PARAMETERS
Pointer to buffer to contain formatted output string. Size of the buf‐
fer referred to by string. Pointer to buffer containing a string spec‐
ifying the characters and format of optional parameters (specified in
arglist) to be written to string. Variable length argument list con‐
taining the items to be output
DESCRIPTION
The vsnprintf() function behaves as function snprintf(3scl) except that
parameter arglist specifies the output items through an argument list
pointer rather than a variable number of arguments.
SCL IMPLEMENTATION NOTES
The output buffer is assumed to be large enough to contain the format‐
ted output, otherwise an error is returned. This is different behaviour
to Solaris which returns the number of characters that should have been
output if the buffer was sufficiently large.
Tru64 UNIX version 5 implements the vsnprintf() function in the stan‐
dard library, but Tru64 UNIX version 4 does not, hence the function is
implemented by the SCL.
The SCL-supplied stdio.h header maps vsnprintf() to an SCL-specific
implementation function. This mapping is not required if building
applications on Tru64 UNIX version 5. Consequently, the header uses
preprocessor statements to only map the definition when building on a
version 4 system.
To ensure that the correct preprocessor symbol is defined for the con‐
ditional test within the header, use the tru64_version utility (in the
bin directory beneath the SCL root directory) with the application
build command (for example: cc -o myprog -D`tru64_version -m` myprog.c
-lsolmisc). Alternatively, remove the definitions from the SCL-sup‐
plied stdio.h on a version 5 system.
The implementation of this function calls vfprintf(3) which in turn
invokes the va_arg() macro, but not the va_end() macro, thus making the
value of arglist indeterminate after a return. Therefore, applications
should invoke the va_end() macro after a call to the vsnprintf() func‐
tion.
RETURN VALUES
The number of characters written to the buffer, excluding the terminat‐
ing null, if successful, otherwise a negative value is returned.
RELATED INFORMATION
Functions: snprintf(3scl), vfprintf(3)
Manual: Solaris Compatibility Library User's Guide
vsnprintf(3scl)