Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ vpfmt(3C) — svr4 — mips UMIPS RISC/os 5.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pfmt(3C)

stdarg(5)



VPFMT(3C-SVR4)      RISC/os Reference Manual       VPFMT(3C-SVR4)



NAME
     vpfmt - display error message in standard format and pass to
          logging and monitoring services

SYNOPSIS
     #include <stdarg.h>
     #include <pfmt.h>

     int vpfmt(FILE *stream, long flags, char *format, valist ap);

DESCRIPTION
     vpfmt() is the same as lfmt() 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 va_list 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 va_list.  This argument is used with the
     <stdarg.h> header file macros va_start(), va_arg() and
     va_end() [see va_start(), va_arg(), and va_end() in
     stdarg(5)].  The EXAMPLE section below shows their use with
     vpfmt().

     The macro va_alist is used as the parameter list in a func-
     tion definition as in the function called error() in the
     example below.  The macro va_start(ap, ), where ap is of
     type va_list, must be called before any attempt to traverse
     and access unnamed arguments.  Calls to va_arg(ap, atype)
     traverse the argument list.  Each execution of va_arg()
     expands to an expression with the value and type of the next
     argument in the list ap, which is the same object initial-
     ized by va_start.  The argument atype is the type that the
     returned argument is expected to be.  The va_end(ap) macro
     must be invoked when all desired arguments have been
     accessed.  (The argument list in ap can be traversed again
     if va_start() is called again after va_end().)  In the exam-
     ple below, va_arg() 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 transmit-
     ted.  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:




                        Printed 11/19/92                   Page 1





VPFMT(3C-SVR4)      RISC/os Reference Manual       VPFMT(3C-SVR4)



          #include <pfmt.h>
          #include <stdarg.h>
          /*
           *   error should be called like
           *         error(format, arg1, ...);
           */
          void error(...)

          {
              va_list ap;
              char *format;
              va_start(ap, );
              format = va_arg(ap, char *);
              (void) vpfmt(stderr, MM_ERROR, format, ap);
              va_end(ap);
              (void) abort();
          }

SEE ALSO
     pfmt(3C), stdarg(5).



































 Page 2                 Printed 11/19/92



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026