VPRINTF(3s,L) AIX Technical Reference VPRINTF(3s,L) ------------------------------------------------------------------------------- vprintf, vfprintf, vsprintf, NLvprintf, NLvfprintf, NLvsprintf PURPOSE Formats a varargs parameter list for output. LIBRARY Standard I/O Library (libc.a) SYNTAX #include #include int vprintf (format, argp) int NLvprintf (format, argp) char *format; char *format; va_list argp; va_list argp; int vfprintf (stream, format, argp) int NLvfprintf (stream, format, argp) FILE *stream; FILE *stream; char *format; char *format; va_list argp; va_list argp; int vsprintf (s, format, argp) NLvsprintf (s, format, argp) char *s, *format; char *s, *format; va_list argp; va_list argp; DESCRIPTION The vprintf, vfprintf, and vsprintf subroutines format and write varargs parameter lists. They are the same as the printf, fprintf, and sprintf subroutines, respectively, except that they are not called with a variable number of parameters. Instead, they are called with a parameter list pointer as defined by "varargs." The NLvprintf, NLvfprintf, and NLvsprintf subroutines are provided for backward compatibility and behave exactly like the vprintf, vfprintf, and vsprintf subroutines respectively. EXAMPLE The following example demonstrates how the vfprintf subroutine could be used to write an error routine. Processed July 12, 1991 VPRINTF(3s,L) 1 VPRINTF(3s,L) AIX Technical Reference VPRINTF(3s,L) #include #include /* error should be called with the syntax: */ /* error(routine_name, format [, value,...]); */ /*VARARGS0*/ void error(va_alist) va_dcl /* ** Note that the function name and format arguments ** cannot be separately declared because of the ** definition of varargs. */ { va_list args; char *fmt; va_start(args); /* ** Display the name of the function that called error */ (void) fprintf(stderr, "ERROR in %s: ", va_arg(args, char *)); /* ** Display the remainder of the message */ fmt = va_arg(args, char *); (void) vfprintf(std err, fmt, args); va_end(args); (void) abort(); } ERROR CONDITIONS The vprintf subroutine fails if one or more of the following are true: EAGAIN The O_NONBLOCK flag is set for the file descriptor underlying stream and the process is delayed in the write operation. EBADF The file descriptor underlying stream is not a valid file descriptor open for writing. EFBIG An attempt was made to write to a file that exceeds the process's file size limit or the maximum file size. EINTR The write operation was terminated due to the receipt of a signal, and either no data was transferred or the implementation does not report partial transfers for this file. Processed July 12, 1991 VPRINTF(3s,L) 2 VPRINTF(3s,L) AIX Technical Reference VPRINTF(3s,L) EIO The implementation supports job control, the process is a member of a background process group attempting to write to its controlling terminal, TOSTOP is set, the process is neither ignoring nor blocking SIGTTOU and the process group of the process is orphaned. ENOSPC There was no free space remaining on the device containing the file. ENXIO A request was made of a non-existent device, or the request was outside the capabilities of the device. EPIPE An attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal will also be sent to the process. ENOMEM Insufficient storage space is available. EINVAL There are insufficient arguments. RELATED INFORMATION In this book: "printf, fprintf, sprintf, NLprintf, NLfprintf, NLsprintf, wsprintf." Processed July 12, 1991 VPRINTF(3s,L) 3