HP-UX Reference (11i v1 00/12) - 5 Miscellaneous Topics, 7 Device (Special) Files, 9 General Information, Index (vol 9)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man5/!!!intro.5
________________________________________________________________
___ ___
v
varargs(5) varargs(5)
In this example, one can imagine that there are a series of other routines (such as a log_warning()
and log_message()) that also call the v_print_log() function.
#include <stdio.h>
#include <varargs.h>
#include <unistd.h>
int error_count;
/* VARARGS4 -- for lint */
int
log_errors(log_fp, func_name, err_num, msg_fmt, va_alist)
FILE *log_fp;
char *func_name;
int err_num;
char *msg_fmt;
va_dcl
{
va_list ap;
/* Print error header information */
(void) fprintf(log_fp, "\nERROR in process %d\n", getpid());
(void) fprintf(log_fp, " function \"%s\": ", func_name);
switch(err_num)
{
case ILLEGAL_OPTION:
(void) fprintf(log_fp, "illegal option\n");
break;
case CANNOT_PARSE:
(void) fprintf(log_fp, "cannot parse input file\n");
break;
...
}
/*
* Get pointer to first variable argument so that we can
* pass it on to v_print_log(). We do this so that
* v_print_log() can access the variable arguments passed
* to this routine.
*/
va_start(ap);
v_print_log(log_fp, msg_fmt, ap);
va_end(ap);
}
/* VARARGS2 -- for lint */
int
v_print_log(log_fp, fmt, ap)
FILE *log_fp;
char *fmt;
va_list ap;
{
/*
* If "%Y" is the first two characters in the format string,
* a second file pointer has been passed in to print general
* message information to. The rest of the format string is
* a standard printf(3S) format string.
*/
Section 5−−364 − 2 − HP-UX Release 11i: December 2000
___
___