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

NAME

6       vlfmt  -  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 vlfmt(FILE *stream, long flag, const char *format, va_list ap);
14
15

DESCRIPTION

17       The vlfmt() function is identical to lfmt(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       vlfmt().
27

RETURN VALUES

29       Upon successful completion, vlfmt() returns the number of bytes  trans‐
30       mitted.   Otherwise,  −1  is  returned  if  there  was a write error to
31       stream, or −2 is returned if unable to log and/or display at console.
32

EXAMPLES

34       Example 1 Use of vlfmt() to write an errlog()routine.
35
36
37       The following example demonstrates how vlfmt() could be used  to  write
38       an errlog() 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 errlog(). The remaining errlog()  arguments
50       (arg1, arg2, ...) are passed to vlfmt() in the argument ap.
51
52
53         #include <pfmt.h>
54         #include <stdarg.h>
55         /*
56          *   errlog should be called like
57          *         errlog(log_info, format, arg1, ...);
58          */
59         void errlog(long log_info, ...)
60         {
61                 va_list ap;
62                 char *format;
63                 va_start(ap, );
64                 format = va_arg(ap, char *);
65                 (void) vlfmt(stderr, log_info|MM_ERROR, format, ap);
66                 va_end(ap);
67                 (void) abort();
68         }
69
70

USAGE

72       Since  vlfmt()  uses  gettxt(3C), it is recommended that vlfmt() 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), lfmt(3C), attributes(5), stdarg(3EXT)
89
90
91
92SunOS 5.11                        29 Dec 1996                        vlfmt(3C)
Impressum