Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/* $XConsortium: main.c /main/82 1995/11/07 19:47:02 gildea $ *//*Copyright (c) 1993, 1994 X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.22/08/99 APY MSDOS builds (using gcc),import INCLUDEconvert '\' to '/' for gmake happy output.-M switch25/08/99 APY Allow multiple -Y definitions11/02/04 APY -b, basename option16/02/04 --help, v2.128/04/04 -W[1|2], quote whitespace,- MAX_PATH cleanup (formal buffers sized by BUFSIZ)- v2.2003/11/04 - Multiple -p definitions.- MAXDIRS=25604/11/04 - Correctly handle an empty INCLUDE vararg.- More advanced cmdfile processor (see argv).- v2.21$Source: /cvsroot/device/DEVL/UTILS/MKDEPEND/main.c,v $$Revision: 1.6 $ $Date: 2004/11/04 07:11:36 $ $State: Exp $$Author: ayoung $ $Locker: $*/#define VMAJOR 2#define VMINOR 25#include "def.h"#ifdef hpux#define sigvec sigvector#endif /* hpux */#ifdef X_POSIX_C_SOURCE#define _POSIX_C_SOURCE X_POSIX_C_SOURCE#include <signal.h>#undef _POSIX_C_SOURCE#else#if defined(X_NOT_POSIX) || defined(_POSIX_SOURCE)#include <signal.h>#else#define _POSIX_SOURCE#include <signal.h>#undef _POSIX_SOURCE#endif#endif#ifdef NeedVarargsPrototypes#include <stdarg.h>#endif#ifdef DEBUGint _debugmask;#endifstatic const char *ProgramName, *ProgramPath;const char *directives[] = {"if", /* 0 */"ifdef", /* 1 */"ifndef", /* 2 */"else", /* 3 */"endif", /* 4 */"define", /* 5 */"undef", /* 6 */"include", /* 7 */"line", /* 8 */"pragma", /* 9 */"error", /* 10 */"ident", /* 11 */"sccs", /* 12 */"elif", /* 13 */"eject", /* 14 */"warning", /* 15 */NULL};#define MAKEDEPEND#include "imakedep.h" /* from config sources */#undef MAKEDEPEND#ifdef MSDOS#include <libdos.h>#endifstruct inclist inclist[ MAXFILES ] = {0};struct inclist *inclistp = inclist;struct inclist maininclist;char *filelist[ MAXFILES ] = {0};char *includedirs[ MAXDIRS+1 ] = {0};char *defincdirs[ MAXDIRS+1 ] = {0};char **systemdirs = NULL;char *notdotdot[ MAXDIRS ] = {0};char *objprefixs[ MAXPREFIXS ] = {0};char *objsuffix = OBJSUFFIX;char *startat = "# DO NOT DELETE -- make depend depends on it.";int width = 78;int mflags = 0;boolean append = FALSE;boolean printed = FALSE;boolean verbose = FALSE;boolean opt_basename = FALSE;int embeddedwhite = BS_UNKNOWN;boolean show_where_not = FALSE;boolean warn_multiple = FALSE; /* Warn on multiple includes of same file */static void usage(void);static#ifdef SIGNALRETURNSINTint#elsevoid#endifcatch (int sig){fflush (stdout);fatalerr ("got signal %d\n", sig);}#if defined(USG) || (defined(i386) && defined(SYSV)) ||\defined(WIN32) || defined(MSDOS)#define USGISH#endif#ifndef USGISH#ifndef _POSIX_SOURCE#define sigaction sigvec#define sa_handler sv_handler#define sa_mask sv_mask#define sa_flags sv_flags#endifstruct sigaction sig_act;#endif /* USGISH */#if defined(WIN32)extern intparse_cmdbuffer(const char *, const char *, char ***, int *);#endifmain(argc, argv)int argc;char **argv;{register char **fp = filelist;register char **incp = includedirs;register char **defp = defincdirs;register char **prefixp = objprefixs;register char *p;register struct inclist *ip;char *makefile = NULL;struct filepointer *filecontent;struct symtab *psymp = predefs;char *endmarker = NULL;ProgramName = strdup(argv[0]);#if defined(WIN32) || defined(DOS)if ((p = strrchr(ProgramName, '/')) != NULL ||(p = strrchr(ProgramName, '\\')) != NULL) {ProgramPath = ProgramName;*p++ = '\0';ProgramName = p;} else {ProgramPath = NULL;ProgramName = p;}if ((p = strrchr(ProgramName, '.')) != NULL && !stricmp(p, ".exe"))*p = '\0';#endifwhile (psymp->s_name){define2(psymp->s_name, psymp->s_value, &maininclist);psymp++;}#ifdef DEBUGif ((p = getenv("MKDEPENDDEBUG")) != NULL && *p) {_debugmask = strtol(p, NULL, 0);}#endifif (argc == 2 && argv[1][0] == '@') {struct stat ast;int afd;char *args;char quotechar = '\0';char **nargv;int nargc;debug(1, ("importing: %s\n", argv[1]+1));if ((afd = open(argv[1]+1, O_RDONLY)) < 0)fatalerr("cannot open \"%s\"\n", argv[1]+1);fstat(afd, &ast);args = (char *)malloc(ast.st_size + 1);if ((ast.st_size = read(afd, args, ast.st_size)) < 0)fatalerr("failed to read %s\n", argv[1]+1);args[ast.st_size] = '\0';close(afd);#if defined(WIN32)if (parse_cmdbuffer( argv[0], args, &nargv, &argc ) == -1)fatalerr( "failed to parse %s\n", argv[1]+1 );for (nargc = 1; nargv[nargc]; nargc++) {debug(1, ("arg%d: %s\n", nargc, nargv[nargc]));}argv = nargv;#elsefor (nargc = 1, p = args; *p; p++) {if (quotechar) {if (quotechar == '\\' ||(*p == quotechar && p[-1] != '\\'))quotechar = '\0';continue;}switch (*p) {case '\\':case '"':case '\'':quotechar = *p;break;case ' ':case '\n':*p = '\0';if (p > args && p[-1])nargc++;break;}}if (p[-1])nargc++;nargv = (char **)malloc(nargc * sizeof(char *));nargv[0] = argv[0];argc = 1;for (p = args; argc < nargc; p += strlen(p) + 1)if (*p) nargv[argc++] = p;argv = nargv;#endif}for(argc--, argv++; argc; argc--, argv++) {/* if looking for endmarker then check before parsing */if (endmarker && strcmp (endmarker, *argv) == 0) {endmarker = NULL;continue;}if (**argv != '-') {/* treat +thing as an option for C++ */if (endmarker && **argv == '+')continue;*fp++ = argv[0];continue;}switch(argv[0][1]) {case '-':if (strcmp("help", argv[0]+2) == 0)usage();endmarker = &argv[0][2];if (endmarker[0] == '\0') endmarker = "--";break;case 'D':if (argv[0][2] == '\0') {argv++;argc--;}for (p=argv[0] + 2; *p ; p++)if (*p == '=') {*p = ' ';break;}define(argv[0] + 2, &maininclist);debug(1, ("-D%s\n", argv[0] + 2));break;case 'I':if (incp >= includedirs + MAXDIRS)fatalerr("Too many -I flags.\n");*incp++ = argv[0]+2;if (**(incp-1) == '\0') {*(incp-1) = *(++argv);argc--;}debug(1, ("-I%s\n", *(incp-1)));break;case 'Y':if (defp >= defincdirs + MAXDIRS)fatalerr("Too many -Y flags.\n");*defp++ = argv[0]+2;if (**(defp-1) == '\0') {*(defp-1) = *(++argv);argc--;}debug(1, ("-Y%s\n", *(defp-1)));break;case 'M':for (p=argv[0]+2; *p; p++)switch (*p) {case 'M':mflags |= MFLAG_NOSYSTEM;break;case 'G':mflags |= MFLAG_GENERATED;break;default:warning("ignoring option -M%c\n", *p);break;}break;/* do not use if endmarker processing */case 'a':if (endmarker) break;append = TRUE;break;case 'w':if (endmarker) break;if (argv[0][2] == '\0') {argv++;argc--;width = atoi(argv[0]);} elsewidth = atoi(argv[0]+2);break;case 'o': /* objsuffix */if (endmarker) break;if (argv[0][2] == '\0') {argv++;argc--;objsuffix = argv[0];} elseobjsuffix = argv[0]+2;break;case 'p': /* objprefix(s) */if (endmarker) break;if (prefixp >= objprefixs + MAXPREFIXS)fatalerr("Too many -p flags.\n");*prefixp++ = argv[0]+2;if (**(prefixp-1) == '\0') {*(prefixp-1) = *(++argv);argc--;}debug(1, ("-p%s\n", *(prefixp-1)));break;case 'b': /* basename */if (endmarker) break;opt_basename = TRUE;break;case 'W': /* whitespace handling */if (endmarker) break;embeddedwhite = BS_ESCAPE;for (p=argv[0]+2; *p; p++)switch (*p) {case '0': /* method 0: nothing */case '-':embeddedwhite = BS_IGNORE;break;case '1': /* method 1: escape */case 'e':case '+':embeddedwhite = BS_ESCAPE;break;case '2': /* method 2: quote path */case 'q':embeddedwhite = BS_QUOTE;break;case '3': /* method 3: junk */case 'j':embeddedwhite = BS_JUNK;break;case '4': /* method 3: URL */case 'u':embeddedwhite = BS_URL;break;default:warning("ignoring option -W%c\n", *p);break;}break;case 'v':if (endmarker) break;verbose = TRUE;#ifdef DEBUGif (argv[0][2])_debugmask = atoi(argv[0]+2);#ifdef MSDOS__systeml_debug = 1;#endif#endifbreak;case 's':if (endmarker) break;startat = argv[0]+2;if (*startat == '\0') {startat = *(++argv);argc--;}if (*startat != '#')fatalerr("-s flag's value should start %s\n","with '#'.");break;case 'f':if (endmarker) break;makefile = argv[0]+2;if (*makefile == '\0') {makefile = *(++argv);argc--;}break;case 'm':warn_multiple = TRUE;break;/* Ignore -O, -g so we can just pass ${CFLAGS} to* makedepend*/case 'O':case 'g':break;default:if (endmarker) break;warning("ignoring option %s\n", argv[0]);}}systemdirs = incp; /* mark beginning of system directories */if (!defincdirs[0]) {#ifdef PREINCDIRif (incp >= includedirs + MAXDIRS)fatalerr("Too many -I flags.\n");*incp++ = PREINCDIR;#endif#ifdef INCLUDEDIRif (incp >= includedirs + MAXDIRS)fatalerr("Too many -I flags.\n");*incp++ = INCLUDEDIR;#endif#ifdef POSTINCDIRif (incp >= includedirs + MAXDIRS)fatalerr("Too many -I flags.\n");*incp++ = POSTINCDIR;#endif#if defined(WIN32) || defined(MSDOS){char *p, *p2;if ((p = getenv("INCLUDE")) != NULL && *p &&(p = p2 = strdup(p)) != (char *)NULL){/* split path */do {*incp = p;if ((p = strchr(p, ';')) != NULL)*p++ = '\0';debug(1, ("imported -I%s\n", *incp));incp++;} while (p && *p);}}#endif /*WIN32, MSDOS*/} else {register char **pp;for (pp = defincdirs; *pp; pp++) {if (incp >= includedirs + MAXDIRS)fatalerr("Too many -I and -Y flags.\n");*incp++ = *pp;}}#if defined(WIN32) || defined(MSDOS){register char **pp, *p;for (pp = includedirs; *pp; pp++) {p = *pp;do {if ((p = strchr(p, '\\')) != NULL)*p = '/';} while (p && *p);}}#endif /*WIN32, MSDOS*//* terminate each directory with '/', allowing* simple -MM detection.*/if (mflags & MFLAG_NOSYSTEM) {register char **pp, *p;register int len;for (pp = systemdirs; *pp; pp++) {len = strlen(*pp);if ( len == 0 )break;if ( (*pp)[ len-1 ] != '/' ) {p = malloc(len+2);(void) strcpy(p, (const char *)*pp);p[ len ] = '/', p[ len+1 ] = '\0';debug(1, ("conv -Y%s\n", p));*pp = p;}}}redirect(startat, makefile);/** catch signals.*/#ifdef USGISH/* should really reset SIGINT to SIG_IGN if it was. */#ifdef SIGHUPsignal (SIGHUP, catch);#endifsignal (SIGINT, catch);#ifdef SIGQUITsignal (SIGQUIT, catch);#endifsignal (SIGILL, catch);#ifdef SIGBUSsignal (SIGBUS, catch);#endifsignal (SIGSEGV, catch);#ifdef SIGSYSsignal (SIGSYS, catch);#endif#elsesig_act.sa_handler = catch;#ifdef _POSIX_SOURCEsigemptyset(&sig_act.sa_mask);sigaddset(&sig_act.sa_mask, SIGINT);sigaddset(&sig_act.sa_mask, SIGQUIT);#ifdef SIGBUSsigaddset(&sig_act.sa_mask, SIGBUS);#endifsigaddset(&sig_act.sa_mask, SIGILL);sigaddset(&sig_act.sa_mask, SIGSEGV);sigaddset(&sig_act.sa_mask, SIGHUP);sigaddset(&sig_act.sa_mask, SIGPIPE);#ifdef SIGSYSsigaddset(&sig_act.sa_mask, SIGSYS);#endif#elsesig_act.sa_mask = ((1<<(SIGINT -1))|(1<<(SIGQUIT-1))#ifdef SIGBUS|(1<<(SIGBUS-1))#endif|(1<<(SIGILL-1))|(1<<(SIGSEGV-1))|(1<<(SIGHUP-1))|(1<<(SIGPIPE-1))#ifdef SIGSYS|(1<<(SIGSYS-1))#endif);#endif /* _POSIX_SOURCE */sig_act.sa_flags = 0;sigaction(SIGHUP, &sig_act, (struct sigaction *)0);sigaction(SIGINT, &sig_act, (struct sigaction *)0);sigaction(SIGQUIT, &sig_act, (struct sigaction *)0);sigaction(SIGILL, &sig_act, (struct sigaction *)0);#ifdef SIGBUSsigaction(SIGBUS, &sig_act, (struct sigaction *)0);#endifsigaction(SIGSEGV, &sig_act, (struct sigaction *)0);#ifdef SIGSYSsigaction(SIGSYS, &sig_act, (struct sigaction *)0);#endif#endif /* USGISH *//** now peruse through the list of files.*/for(fp=filelist; *fp; fp++) {filecontent = getfile(*fp);ip = newinclude(*fp, (char *)NULL);find_includes(filecontent, ip, ip, 0, FALSE);freefile(filecontent);recursive_pr_include(ip, ip->i_file, base_name(*fp));inc_clean();inc_dump();}if (printed)printf("\n");exit(0);}static voidusage(void){fprintf( stderr,"Makedepend - %d.%02d\n" \"Create dependencies in makefiles\n" \"\n" \"Usage: %s [-D name[=def]] [-I includedir] [-Y includedir]\n" \" [-a] [-f makefile] [-b] [-W[1|2]] [-o objsuffix] [-p objprefix]\n" \" [-s string] [-w width] [-v] [-m] [-- otheroptions --]\n" \" sourcefile [sourcefile ...]\n\n",VMAJOR, VMINOR, ProgramName );fprintf( stderr,"Options:\n" \" -f makefile Alternate output file name\n" \" -a Append dependencies to the end of the file.\n" \" -DIname=def or -DIname Define a symbol.\n" \" -I includedir Include directory.\n" \" -Y includedir System include directory.\n" \" -b Strip any directory from object file name.\n" \" -W[0|1|2|3|4] Specify method of handling embedded whitespace.\n" \" 0 - Disable warnings.\n"\" 1 - Escape (eg /Embedded\\ Space/x.h).\n"\" 2 - Quote the entire path (eg \"/Embedded Space/x.h\").\n"\" 3 - Junk.\n"\" 4 - URL style (eg /Embedded%%20Space/x.h).\n"\" -o objsuffix Object file suffix.\n" \" -p objprefix Object file prefix.\n" \" -s string Starting string delimiter.\n" \" -w width Line width.\n" \" -v Verbose operation.\n" \" -m Warn about multiple inclusion.\n" \" -M GCC style dependency generation.\n" \" -M - Output dependencies.\n"\" -MG - Treat missing header files as generated\n" \" -MM - Output mentions only the user header\n" \"\n");exit(1);}struct filepointer *getfile(file)char *file;{register int fd;struct filepointer *content;struct stat st;content = (struct filepointer *)malloc(sizeof(struct filepointer));debug(1,( "Opening File: %s\n", file ));if ((fd = open(file, O_RDONLY)) < 0) {warning("cannot open \"%s\"\n", file);content->f_p = content->f_base = content->f_end = (char *)malloc(1);*content->f_p = '\0';return(content);}fstat(fd, &st);content->f_base = (char *)malloc(st.st_size+1);if (content->f_base == NULL)fatalerr("cannot allocate mem\n");if ((st.st_size = read(fd, content->f_base, st.st_size)) < 0)fatalerr("failed to read %s\n", file);close(fd);content->f_len = st.st_size+1;content->f_p = content->f_base;content->f_end = content->f_base + st.st_size;*content->f_end = '\0';content->f_line = 0;content->f_name = copy(file);return(content);}freefile(fp)struct filepointer *fp;{debug(1,( "EndProcessing File: %s\n", fp->f_name ));free(fp->f_base);free(fp);return (0);}char *copy(str)register char *str;{register char *p = (char *)malloc(strlen(str) + 1);strcpy(p, str);return(p);}match(str, list)register char *str;register const char **list;{register int i;for (i=0; *list; i++, list++)if (strcmp(str, *list) == 0)return(i);return(-1);}/** Get the next line. We only return lines beginning with '#' since that* is all this program is ever interested in.*/char *getline(filep)register struct filepointer *filep;{register char *p, /* walking pointer */*eof, /* end of file pointer */*bol; /* beginning of line pointer */register lineno; /* line number */p = filep->f_p;eof = filep->f_end;if (p >= eof)return((char *)NULL);lineno = filep->f_line;for(bol = p--; ++p < eof; ) {if (*p == '/' && *(p+1) == '*') { /* consume comments */*p++ = ' ', *p++ = ' ';while (*p) {if (*p == '*' && *(p+1) == '/') {*p++ = ' ', *p = ' ';break;}else if (*p == '\n')lineno++;*p++ = ' ';}continue;}#if defined(MSDOS) || defined(WIN32)else if (*p == '/' && *(p+1) == '/') { /* consume comments */*p++ = ' ', *p++ = ' ';while (*p && *p != '\n')*p++ = ' ';--p;continue;}#endifelse if (*p == '\\') {if (*(p+1) == '\n') {*p = ' ';*(p+1) = ' ';lineno++;}}else if (*p == '\n') {char *cp = bol;lineno++;/*** Allow white space before a directive. Its not ansi, but** it is used by people*/if ( *cp == ' ' || *cp == '\t' ){while ( *cp == ' ' || *cp == '\t' ){*cp++;}bol = cp;}if (*bol == '#') {register char *cp;*p++ = '\0';/* punt lines with just # (yacc generated) */for (cp = bol+1;*cp && (*cp == ' ' || *cp == '\t'); cp++);if (*cp)goto done;}bol = p+1;}}if (*bol != '#')bol = NULL;done:filep->f_p = p;filep->f_line = lineno;return(bol);}/** Strip the file name down to what we want to see in the Makefile.* It will have objprefix and objsuffix around it.*/char *base_name(file)register char *file;{register char *p;file = copy(file);for(p=file+strlen(file); p>file && *p != '.'; p--) ;if (*p == '.')*p = '\0';return(file);}#if defined(USG) && !defined(CRAY) && !defined(SVR4)intrename (from, to)char *from, *to;{(void) unlink (to);if (link (from, to) == 0) {unlink (from);return 0;} else {return -1;}}#endif /* USGISH */voidredirect(line, makefile)char *line,*makefile;{struct stat st;FILE *fdin, *fdout;char backup[ MAX_PATH+1 ],buf[ MAX_PATH+1 ];boolean found = FALSE;int len;/** if makefile is "-" then let it pour onto stdout.*/if (makefile && *makefile == '-' && *(makefile+1) == '\0') {puts(line);return;}/** use a default makefile is not specified.*/if (!makefile) {if (stat("Makefile", &st) == 0)makefile = "Makefile";else if (stat("makefile", &st) == 0)makefile = "makefile";elsefatalerr("[mM]akefile is not present\n");}elsestat(makefile, &st);if ((fdin = fopen(makefile, "r")) == NULL)fatalerr("cannot open \"%s\"\n", makefile);sprintf(backup, "%s.bak", makefile);unlink(backup);#if defined(WIN32) || defined(MSDOS)fclose(fdin);#endifif (rename(makefile, backup) < 0)fatalerr("cannot rename %s to %s\n", makefile, backup);#if defined(WIN32) || defined(MSDOS)if ((fdin = fopen(backup, "r")) == NULL)fatalerr("cannot open \"%s\"\n", backup);#endifif ((fdout = freopen(makefile, "w", stdout)) == NULL)fatalerr("cannot open \"%s\"\n", backup);len = strlen(line);while (!found && fgets(buf, MAX_PATH, fdin)) {if (*buf == '#' && strncmp(line, buf, len) == 0)found = TRUE;fputs(buf, fdout);}if (!found) {if (verbose)warning("Adding new delimiting line \"%s\" and dependencies...\n", line);puts(line); /* same as fputs(fdout); but with newline */} else if (append) {while (fgets(buf, MAX_PATH, fdin)) {fputs(buf, fdout);}}fflush(fdout);#if defined(USGISH) || defined(_SEQUENT_)chmod(makefile, st.st_mode);#elsefchmod(fileno(fdout), st.st_mode);#endif /* USGISH */}void#ifdef NeedVarargsPrototypesfatalerr(char *msg, ...)#else/*VARARGS*/fatalerr(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)char *msg;#endif{#ifdef NeedVarargsPrototypesva_list args;#endiffprintf(stderr, "%s: error: ", ProgramName);#ifdef NeedVarargsPrototypesva_start(args, msg);vfprintf(stderr, msg, args);va_end(args);#elsefprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);#endifexit (1);}void#if NeedVarargsPrototypeswarning(char *msg, ...)#else/*VARARGS0*/warning(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)char *msg;#endif{#if NeedVarargsPrototypesva_list args;#endiffprintf(stderr, "%s: warning: ", ProgramName);#if NeedVarargsPrototypesva_start(args, msg);vfprintf(stderr, msg, args);va_end(args);#elsefprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);#endif}void#if NeedVarargsPrototypeswarning1(char *msg, ...)#else/*VARARGS0*/warning1(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)char *msg;#endif{#if NeedVarargsPrototypesva_list args;va_start(args, msg);vfprintf(stderr, msg, args);va_end(args);#elsefprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);#endif}void#if NeedVarargsPrototypesinfo(char *msg, ...)#else/*VARARGS0*/info(msg,x1,x2,x3,x4,x5,x6,x7,x8,x9)char *msg;#endif{#if NeedVarargsPrototypesva_list args;#endiffprintf(stderr, "%s: info: ", ProgramName);#if NeedVarargsPrototypesva_start(args, msg);vfprintf(stderr, msg, args);va_end(args);#elsefprintf(stderr, msg,x1,x2,x3,x4,x5,x6,x7,x8,x9);#endif}