1vpfmt(3C)                Standard C Library Functions                vpfmt(3C)
2
3
4

NAME

6       vpfmt  -  display  error message in standard format and pass to logging
7       and monitoring services
8

SYNOPSIS

10       #include <pfmt.h>
11       #include <stdarg.h>
12
13       int vpfmt(FILE *stream, long flag, const char *format, va_list ap);
14
15

DESCRIPTION

17       The vpfmt() function is identical to pfmt(3C), except that it is called
18       with an argument list as defined by <stdarg.h>.
19
20
21       The  <stdarg.h> header defines the type va_list and a set of macros for
22       advancing through a list of arguments whose number and types may  vary.
23       The  ap  argument  is  of  type va_list. This argument is used with the
24       <stdarg.h> macros va_start(), va_arg(), and va_end(). See stdarg(3EXT).
25       The  example  in the EXAMPLES section below demonstrates their use with
26       vpfmt().
27

RETURN VALUES

29       Upon successful completion, vpfmt() returns the number of bytes  trans‐
30       mitted.   Otherwise,  −1  is  returned  if  there  was a write error to
31       stream.
32

EXAMPLES

34       Example 1 Use of vpfmt() to write an error routine.
35
36
37       The following example demonstrates how vpfmt() could be used  to  write
38       an  error() routine. The va_alist() macro is used as the parameter list
39       in a function definition. The va_start(ap, ...) call, where  ap  is  of
40       type va_list, must be invoked before any attempt to traverse and access
41       unnamed arguments. Calls to va_arg(ap,  atype)  traverse  the  argument
42       list.  Each  execution  of  va_arg()  expands to an expression with the
43       value and type of the next argument in the list ap, which is  the  same
44       object  initialized  by va_start(). The atype argument is the type that
45       the returned argument is expected to be. The va_end(ap) macro  must  be
46       invoked  when  all  desired  arguments have been accessed. The argument
47       list in ap can be traversed again if va_start() is called  again  after
48       va_end().  In the example below, va_arg() is executed first to retrieve
49       the format string passed to error(). The  remaining  error()  arguments
50       (arg1, arg2, ...) are passed to vpfmt() in the argument ap.
51
52
53         #include <pfmt.h>
54         #include <stdarg.h>
55         /*
56          *   error should be called like
57          *         error(format, arg1, ...);
58          */
59         void error(...)
60         {
61                 va_list ap;
62                 char *format;
63                 va_start(ap, );
64                 format = va_arg(ap, char *);
65                 (void) vpfmt(stderr, MM_ERROR, format, ap);
66                 va_end(ap);
67                 (void) abort();
68         }
69
70

USAGE

72       Since  vpfmt()  uses  gettxt(3C), it is recommended that vpfmt() not be
73       used.
74

ATTRIBUTES

76       See attributes(5) for descriptions of the following attributes:
77
78
79
80
81       ┌─────────────────────────────┬─────────────────────────────┐
82       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
83       ├─────────────────────────────┼─────────────────────────────┤
84       │MT-Level                     │MT-Safe                      │
85       └─────────────────────────────┴─────────────────────────────┘
86

SEE ALSO

88       gettxt(3C), pfmt(3C), attributes(5), stdarg(3EXT)
89
90
91
92SunOS 5.11                        29 Dec 1996                        vpfmt(3C)
Impressum