vpfmt(3C) DG/UX 5.4R3.00 vpfmt(3C)
NAME
vpfmt - display error message in standard format and pass to monitor
and logger
SYNOPSIS
#include <stdarg.h>
#include <pfmt.h>
int vpfmt(FILE *stream, long flags, char *format, valist ap);
DESCRIPTION
Vpfmt() is the same as pfmt() except that instead of being called
with a variable number of arguments, it is called with an argument
list as defined by the <stdarg.h> header file.
The <stdarg.h> header file defines the type valist and a set of
macros for advancing through a list of arguments whose number and
types may vary. The argument ap to vpfmt() is of type valist. This
argument is used with the <stdarg.h> header file macros vastart(),
vaarg() and vaend() [see vastart(), vaarg(), and vaend() in
stdarg(5)]. The EXAMPLE section below shows their use with vpfmt().
The macro valist is used as the parameter list in a function
definition as in the function called error() in the example below.
The macro vastart(ap, ), where ap is of type valist, must be called
before any attempt to traverse and access unnamed arguments. Calls
to vaarg(ap, atype) traverse the argument list. Each execution of
vaarg() expands to an expression with the value and type of the next
argument in the list ap, which is the same object initialized by
vastart. The argument atype is the type that the returned argument
is expected to be. The vaend(ap) macro must be invoked when all
desired arguments have been accessed. (The argument list in ap can
be traversed again if vastart() is called again after vaend().) In
the example below, vaarg() is executed first to retrieve the format
string passed to error(). The remaining error() arguments, arg1,
arg2, ..., are given to vpfmt() in the argument ap.
RETURN VALUE
Upon success, vpfmt() returns the number of bytes transmitted. Upon
failure, it returns a negative value:
-1 write error to stream.
EXAMPLE
The following demonstrates how vpfmt() could be used to write an
error() routine:
#include <pfmt.h>
#include <stdarg.h>
/*
* error should be called like
* error(format, arg1, ...);
*/
void error(...)
Licensed material--property of copyright holder(s) 1
vpfmt(3C) DG/UX 5.4R3.00 vpfmt(3C)
{
valist ap;
char *format;
vastart(ap, );
format = vaarg(ap, char *);
(void) vpfmt(stderr, MMERROR, format, ap);
vaend(ap);
(void) abort();
}
SEE ALSO
pfmt(3C), stdarg(5).
Licensed material--property of copyright holder(s) 2