version 1.13, 2003/04/19 17:22:29 |
version 1.14, 2003/05/14 01:34:35 |
|
|
* SUCH DAMAGE. |
* SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#include "defs.h" |
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$From: message.c,v 6.24 1996/07/19 17:00:35 michaelc Exp $"; |
"$From: message.c,v 1.5 1999/11/01 00:21:39 christos Exp $"; |
#else |
#else |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$OpenBSD$"; |
"$OpenBSD$"; |
#endif |
#endif |
|
|
static char sccsid[] = "@(#)common.c"; |
static char sccsid[] __attribute__((__unused__)) = |
|
"@(#)common.c"; |
|
|
static char copyright[] = |
static char copyright[] __attribute__((__unused__)) = |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
All rights reserved.\n"; |
All rights reserved.\n"; |
#endif /* !lint */ |
#endif /* !lint */ |
|
|
* Message handling functions for both rdist and rdistd. |
* Message handling functions for both rdist and rdistd. |
*/ |
*/ |
|
|
#include "defs.h" |
|
|
|
#define MSGBUFSIZ 32*1024 |
#define MSGBUFSIZ 32*1024 |
|
|
|
|
{ 0 }, |
{ 0 }, |
}; |
}; |
|
|
static void msgsendstdout(), msgsendfile(), msgsendsyslog(), |
static void msgsendstdout(MSGFACILITY *, int, int, char *); |
msgsendnotify(); |
static void msgsendsyslog(MSGFACILITY *, int, int, char *); |
|
static void msgsendfile(MSGFACILITY *, int, int, char *); |
|
static void msgsendnotify(MSGFACILITY *, int, int, char *); |
|
|
/* |
/* |
* Message Facilities |
* Message Facilities |
|
|
{ 0 }, |
{ 0 }, |
}; |
}; |
|
|
|
static MSGFACILITY *getmsgfac(char *); |
|
static MSGTYPE *getmsgtype(char *); |
|
static char *setmsgtypes(MSGFACILITY *, char *); |
|
static void _message(int, char *); |
|
static void _debugmsg(int, char *); |
|
static void _error(char *); |
|
static void _fatalerr(char *); |
|
|
/* |
/* |
* Print message logging usage message |
* Print message logging usage message |
*/ |
*/ |
extern void msgprusage() |
void |
|
msgprusage(void) |
{ |
{ |
int i, x; |
int i, x; |
|
|
|
|
/* |
/* |
* Print enabled message logging info |
* Print enabled message logging info |
*/ |
*/ |
extern void msgprconfig() |
void |
|
msgprconfig(void) |
{ |
{ |
int i, x; |
int i, x; |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
debugmsg(DM_MISC, "Current message logging config:"); |
debugmsg(DM_MISC, "Current message logging config:"); |
for (i = 0; msgfacility[i].mf_name; ++i) { |
for (i = 0; msgfacility[i].mf_name; ++i) { |
(void) snprintf(buf, sizeof(buf), |
(void) snprintf(buf, sizeof(buf), " %.*s=", |
" %s=", msgfacility[i].mf_name); |
(int)(sizeof(buf) - 7), msgfacility[i].mf_name); |
for (x = 0; msgtypes[x].mt_name; ++x) |
for (x = 0; msgtypes[x].mt_name; ++x) |
if (IS_ON(msgfacility[i].mf_msgtypes, |
if (IS_ON(msgfacility[i].mf_msgtypes, |
msgtypes[x].mt_type)) { |
msgtypes[x].mt_type)) { |
if (x > 0) |
if (x > 0) |
(void) strlcat(buf, ",", sizeof buf); |
(void) strlcat(buf, ",", sizeof(buf)); |
(void) strlcat(buf, msgtypes[x].mt_name, |
(void) strlcat(buf, msgtypes[x].mt_name, |
sizeof buf); |
sizeof(buf)); |
} |
} |
debugmsg(DM_MISC, "%s", buf); |
debugmsg(DM_MISC, "%s", buf); |
} |
} |
|
|
/* |
/* |
* Get the Message Facility entry "name" |
* Get the Message Facility entry "name" |
*/ |
*/ |
static MSGFACILITY *getmsgfac(name) |
static MSGFACILITY * |
char *name; |
getmsgfac(char *name) |
{ |
{ |
int i; |
int i; |
|
|
|
|
/* |
/* |
* Get the Message Type entry named "name" |
* Get the Message Type entry named "name" |
*/ |
*/ |
static MSGTYPE *getmsgtype(name) |
static MSGTYPE * |
char *name; |
getmsgtype(char *name) |
{ |
{ |
int i; |
int i; |
|
|
|
|
* Set Message Type information for Message Facility "msgfac" as |
* Set Message Type information for Message Facility "msgfac" as |
* indicated by string "str". |
* indicated by string "str". |
*/ |
*/ |
static char *setmsgtypes(msgfac, str) |
static char * |
MSGFACILITY *msgfac; |
setmsgtypes(MSGFACILITY *msgfac, char *str) |
char *str; |
|
{ |
{ |
static char ebuf[BUFSIZ]; |
static char ebuf[BUFSIZ]; |
char *cp; |
char *cp; |
|
|
if (isserver && (msgfac->mf_msgfac != MF_SYSLOG && |
if (isserver && (msgfac->mf_msgfac != MF_SYSLOG && |
msgfac->mf_msgfac != MF_FILE)) { |
msgfac->mf_msgfac != MF_FILE)) { |
(void) snprintf(ebuf, sizeof(ebuf), |
(void) snprintf(ebuf, sizeof(ebuf), |
"The \"%s\" message facility cannot be used by the server.", |
"The \"%.*s\" message facility cannot be used by the server.", |
msgfac->mf_name); |
100, msgfac->mf_name); |
return(ebuf); |
return(ebuf); |
} |
} |
|
|
|
|
msgfac->mf_msgtypes = 0; /* Start from scratch */ |
msgfac->mf_msgtypes = 0; /* Start from scratch */ |
while (strptr) { |
while (strptr) { |
word = strptr; |
word = strptr; |
if ((cp = strchr(strptr, ','))) |
if ((cp = strchr(strptr, ',')) != NULL) |
*cp++ = CNULL; |
*cp++ = CNULL; |
strptr = cp; |
strptr = cp; |
|
|
if ((mtp = getmsgtype(word))) { |
if ((mtp = getmsgtype(word)) != NULL) { |
msgfac->mf_msgtypes |= mtp->mt_type; |
msgfac->mf_msgtypes |= mtp->mt_type; |
/* |
/* |
* XXX This is really a kludge until we add real |
* XXX This is really a kludge until we add real |
|
|
debug = DM_ALL; |
debug = DM_ALL; |
} else { |
} else { |
(void) snprintf(ebuf, sizeof(ebuf), |
(void) snprintf(ebuf, sizeof(ebuf), |
"Message type \"%s\" is invalid.", |
"Message type \"%.*s\" is invalid.", |
word); |
100, word); |
return(ebuf); |
return(ebuf); |
} |
} |
} |
} |
|
|
/* |
/* |
* Parse a message logging option string |
* Parse a message logging option string |
*/ |
*/ |
extern char *msgparseopts(msgstr, doset) |
char * |
char *msgstr; |
msgparseopts(char *msgstr, int doset) |
int doset; |
|
{ |
{ |
static char ebuf[BUFSIZ], msgbuf[MSGBUFSIZ]; |
static char ebuf[BUFSIZ], msgbuf[MSGBUFSIZ]; |
char *cp, *optstr; |
char *cp, *optstr; |
|
|
return("NULL message string"); |
return("NULL message string"); |
|
|
/* strtok() is harmful */ |
/* strtok() is harmful */ |
(void) strlcpy(msgbuf, msgstr, sizeof msgbuf); |
(void) strlcpy(msgbuf, msgstr, sizeof(msgbuf)); |
|
|
/* |
/* |
* Each <facility>=<types> list is separated by ":". |
* Each <facility>=<types> list is separated by ":". |
|
|
|
|
if ((msgfac = getmsgfac(word)) == NULL) { |
if ((msgfac = getmsgfac(word)) == NULL) { |
(void) snprintf(ebuf, sizeof(ebuf), |
(void) snprintf(ebuf, sizeof(ebuf), |
"%s is not a valid message facility", |
"%.*s is not a valid message facility", |
word); |
100, word); |
return(ebuf); |
return(ebuf); |
} |
} |
|
|
if (doset) { |
if (doset) { |
char *mcp; |
char *mcp; |
|
|
if ((mcp = setmsgtypes(msgfac, cp))) |
if ((mcp = setmsgtypes(msgfac, cp)) != NULL) |
return(mcp); |
return(mcp); |
} |
} |
} |
} |
|
|
* Send a message to facility "stdout". |
* Send a message to facility "stdout". |
* For rdistd, this is really the rdist client. |
* For rdistd, this is really the rdist client. |
*/ |
*/ |
static void msgsendstdout(msgfac, mtype, flags, msgbuf) |
static void |
/*ARGSUSED*/ |
msgsendstdout(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf) |
MSGFACILITY *msgfac; |
|
int mtype; |
|
int flags; |
|
char *msgbuf; |
|
{ |
{ |
char cmd; |
char cmd; |
|
|
|
|
/* |
/* |
* Send a message to facility "syslog" |
* Send a message to facility "syslog" |
*/ |
*/ |
static void msgsendsyslog(msgfac, mtype, flags, msgbuf) |
static void |
/*ARGSUSED*/ |
msgsendsyslog(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf) |
MSGFACILITY *msgfac; |
|
int mtype; |
|
int flags; |
|
char *msgbuf; |
|
{ |
{ |
int syslvl = 0; |
int syslvl = 0; |
|
|
|
|
/* |
/* |
* Send a message to a "file" facility. |
* Send a message to a "file" facility. |
*/ |
*/ |
static void msgsendfile(msgfac, mtype, flags, msgbuf) |
static void |
/*ARGSUSED*/ |
msgsendfile(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf) |
MSGFACILITY *msgfac; |
|
int mtype; |
|
int flags; |
|
char *msgbuf; |
|
{ |
{ |
if (msgfac->mf_fptr == NULL) |
if (msgfac->mf_fptr == NULL) |
return; |
return; |
|
|
/* |
/* |
* Same method as msgsendfile() |
* Same method as msgsendfile() |
*/ |
*/ |
static void msgsendnotify(msgfac, mtype, flags, msgbuf) |
static void |
/*ARGSUSED*/ |
msgsendnotify(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf) |
MSGFACILITY *msgfac; |
|
int mtype; |
|
int flags; |
|
char *msgbuf; |
|
{ |
{ |
char *tempfile; |
char *tempfile; |
|
|
|
|
if (!msgfac->mf_fptr) { |
if (!msgfac->mf_fptr) { |
char *cp; |
char *cp; |
int fd; |
int fd; |
char *getenv(); |
|
size_t len; |
size_t len; |
|
|
/* |
/* |
* Create and open a new temporary file |
* Create and open a new temporary file |
*/ |
*/ |
if ((cp = getenv("TMPDIR")) == NULL) |
if ((cp = getenv("TMPDIR")) == NULL || *cp == '\0') |
cp = _PATH_TMP; |
cp = _PATH_TMP; |
len = strlen(cp) + 1 + sizeof(_RDIST_TMP); |
len = strlen(cp) + 1 + sizeof(_RDIST_TMP); |
tempfile = (char *) xmalloc(len); |
tempfile = (char *) xmalloc(len); |
(void) snprintf(tempfile, len, "%s/%s", cp, _RDIST_TMP); |
(void) snprintf(tempfile, len, "%s/%s", cp, _RDIST_TMP); |
|
|
msgfac->mf_filename = tempfile; |
msgfac->mf_filename = tempfile; |
if ((fd = mkstemp(msgfac->mf_filename)) == -1 || |
if ((fd = mkstemp(msgfac->mf_filename)) < 0 || |
(msgfac->mf_fptr = fdopen(fd, "w")) == NULL) { |
(msgfac->mf_fptr = fdopen(fd, "w")) == NULL) |
if (fd != -1) |
fatalerr("Cannot open notify file for writing: %s: %s.", |
close(fd); |
msgfac->mf_filename, SYSERR); |
fatalerr("Cannot open notify file for writing: %s: %s.", |
|
msgfac->mf_filename, SYSERR); |
|
} |
|
debugmsg(DM_MISC, "Created notify temp file '%s'", |
debugmsg(DM_MISC, "Created notify temp file '%s'", |
msgfac->mf_filename); |
msgfac->mf_filename); |
} |
} |
|
|
/* |
/* |
* Insure currenthost is set to something reasonable. |
* Insure currenthost is set to something reasonable. |
*/ |
*/ |
extern void checkhostname() |
void |
|
checkhostname(void) |
{ |
{ |
static char mbuf[MAXHOSTNAMELEN]; |
static char mbuf[MAXHOSTNAMELEN]; |
char *cp; |
char *cp; |
|
|
/* |
/* |
* Print a message contained in "msgbuf" if a level "lvl" is set. |
* Print a message contained in "msgbuf" if a level "lvl" is set. |
*/ |
*/ |
static void _message(flags, msgbuf) |
static void |
int flags; |
_message(int flags, char *msgbuf) |
char *msgbuf; |
|
{ |
{ |
int i, x; |
int i, x; |
char *cp; |
char *cp; |
|
|
/* |
/* |
* Ensure no stray newlines are present |
* Ensure no stray newlines are present |
*/ |
*/ |
if ((cp = strchr(msgbuf, '\n'))) |
if ((cp = strchr(msgbuf, '\n')) != NULL) |
*cp = CNULL; |
*cp = CNULL; |
|
|
checkhostname(); |
checkhostname(); |
if (strncmp(currenthost, msgbuf, strlen(currenthost)) == 0) |
if (strncmp(currenthost, msgbuf, strlen(currenthost)) == 0) |
(void) strlcpy(mbuf, msgbuf, sizeof mbuf); |
(void) strlcpy(mbuf, msgbuf, sizeof(mbuf)); |
else |
else |
(void) snprintf(mbuf, sizeof mbuf, |
(void) snprintf(mbuf, sizeof(mbuf), |
"%s: %s", currenthost, msgbuf); |
"%s: %s", currenthost, msgbuf); |
} else |
} else |
(void) strlcpy(mbuf, "", sizeof mbuf); |
mbuf[0] = '\0'; |
|
|
/* |
/* |
* Special case for messages that only get |
* Special case for messages that only get |
|
|
/* |
/* |
* Varargs front-end to _message() |
* Varargs front-end to _message() |
*/ |
*/ |
extern void message(va_alist) |
void |
|
message(va_alist) |
va_dcl |
va_dcl |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
fmt = (char *) va_arg(args, char *); |
fmt = (char *) va_arg(args, char *); |
va_end(args); |
va_end(args); |
|
|
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
|
|
_message(lvl, buf); |
_message(lvl, buf); |
} |
} |
|
|
/* |
/* |
* Stdarg front-end to _message() |
* Stdarg front-end to _message() |
*/ |
*/ |
extern void message(int lvl, char *fmt, ...) |
void |
|
message(int lvl, char *fmt, ...) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
va_list args; |
va_list args; |
|
|
va_start(args, fmt); |
va_start(args, fmt); |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_message(lvl, buf); |
_message(lvl, buf); |
} |
} |
#endif /* ARG_STDARG */ |
#endif /* ARG_STDARG */ |
|
|
|
|
#if !defined(ARG_TYPE) |
|
/* |
/* |
* Simple front-end to _message() |
|
*/ |
|
/*VARARGS2*/ |
|
extern void message(lvl, fmt, a1, a2, a3, a4, a5) |
|
int lvl; |
|
char *fmt; |
|
{ |
|
static char buf[MSGBUFSIZ]; |
|
|
|
(void) snprintf(buf, sizeof buf, fmt, a1, a2, a3, a4, a5); |
|
|
|
_message(lvl, buf); |
|
} |
|
#endif /* !ARG_TYPE */ |
|
|
|
/* |
|
* Display a debugging message |
* Display a debugging message |
*/ |
*/ |
static void _debugmsg(lvl, buf) |
static void |
int lvl; |
_debugmsg(int lvl, char *buf) |
char *buf; |
|
{ |
{ |
if (IS_ON(debug, lvl)) |
if (IS_ON(debug, lvl)) |
_message(MT_DEBUG, buf); |
_message(MT_DEBUG, buf); |
|
|
/* |
/* |
* Varargs front-end to _debugmsg() |
* Varargs front-end to _debugmsg() |
*/ |
*/ |
extern void debugmsg(va_alist) |
void |
|
debugmsg(va_alist) |
va_dcl |
va_dcl |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
fmt = (char *) va_arg(args, char *); |
fmt = (char *) va_arg(args, char *); |
va_end(args); |
va_end(args); |
|
|
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
|
|
_debugmsg(lvl, buf); |
_debugmsg(lvl, buf); |
} |
} |
|
|
/* |
/* |
* Stdarg front-end to _debugmsg() |
* Stdarg front-end to _debugmsg() |
*/ |
*/ |
extern void debugmsg(int lvl, char *fmt, ...) |
void |
|
debugmsg(int lvl, char *fmt, ...) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
va_list args; |
va_list args; |
|
|
va_start(args, fmt); |
va_start(args, fmt); |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_debugmsg(lvl, buf); |
_debugmsg(lvl, buf); |
} |
} |
#endif /* ARG_STDARG */ |
#endif /* ARG_STDARG */ |
|
|
#if !defined(ARG_TYPE) |
|
/* |
/* |
* Simple front-end to _debugmsg() |
|
*/ |
|
/*VARARGS2*/ |
|
extern void debugmsg(lvl, fmt, a1, a2, a3, a4, a5) |
|
int lvl; |
|
char *fmt; |
|
{ |
|
static char buf[MSGBUFSIZ]; |
|
|
|
(void) snprintf(buf, sizeof buf, fmt, a1, a2, a3, a4, a5); |
|
|
|
_debugmsg(lvl, buf); |
|
} |
|
#endif /* ARG_TYPE */ |
|
|
|
/* |
|
* Print an error message |
* Print an error message |
*/ |
*/ |
static void _error(msg) |
static void |
char *msg; |
_error(char *msg) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
|
|
|
|
if (msg) { |
if (msg) { |
if (isserver) |
if (isserver) |
(void) snprintf(buf, sizeof buf, "REMOTE ERROR: %s", msg); |
(void) snprintf(buf, sizeof(buf), |
|
"REMOTE ERROR: %s", msg); |
else |
else |
(void) snprintf(buf, sizeof buf, "LOCAL ERROR: %s", msg); |
(void) snprintf(buf, sizeof(buf), |
|
"LOCAL ERROR: %s", msg); |
} |
} |
|
|
_message(MT_NERROR, (buf[0]) ? buf : NULL); |
_message(MT_NERROR, (buf[0]) ? buf : NULL); |
|
|
/* |
/* |
* Varargs frontend to _error() |
* Varargs frontend to _error() |
*/ |
*/ |
extern void error(va_alist) |
void |
|
error(va_alist) |
va_dcl |
va_dcl |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
va_start(args); |
va_start(args); |
fmt = (char *) va_arg(args, char *); |
fmt = (char *) va_arg(args, char *); |
if (fmt) |
if (fmt) |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_error((buf[0]) ? buf : NULL); |
_error((buf[0]) ? buf : NULL); |
|
|
/* |
/* |
* Stdarg frontend to _error() |
* Stdarg frontend to _error() |
*/ |
*/ |
extern void error(char *fmt, ...) |
void |
|
error(char *fmt, ...) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
va_list args; |
va_list args; |
|
|
buf[0] = CNULL; |
buf[0] = CNULL; |
va_start(args, fmt); |
va_start(args, fmt); |
if (fmt) |
if (fmt) |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_error((buf[0]) ? buf : NULL); |
_error((buf[0]) ? buf : NULL); |
} |
} |
#endif /* ARG_STDARG */ |
#endif /* ARG_STDARG */ |
|
|
#if !defined(ARG_TYPE) |
|
/* |
/* |
* Simple frontend to _error() |
|
*/ |
|
/*VARARGS1*/ |
|
extern void error(fmt, a1, a2, a3, a4, a5, a6) |
|
char *fmt; |
|
{ |
|
static char buf[MSGBUFSIZ]; |
|
|
|
buf[0] = CNULL; |
|
if (fmt) |
|
(void) snprintf(buf, sizeof buf, fmt, a1, a2, a3, a4, a5, a6); |
|
|
|
_error((buf[0]) ? buf : NULL); |
|
} |
|
#endif /* ARG_TYPE */ |
|
|
|
/* |
|
* Display a fatal message |
* Display a fatal message |
*/ |
*/ |
static void _fatalerr(msg) |
static void |
char *msg; |
_fatalerr(char *msg) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
++nerrs; |
++nerrs; |
|
|
if (isserver) |
if (isserver) |
(void) snprintf(buf, sizeof buf, "REMOTE ERROR: %s", msg); |
(void) snprintf(buf, sizeof(buf), "REMOTE ERROR: %s", msg); |
else |
else |
(void) snprintf(buf, sizeof buf, "LOCAL ERROR: %s", msg); |
(void) snprintf(buf, sizeof(buf), "LOCAL ERROR: %s", msg); |
|
|
_message(MT_FERROR, buf); |
_message(MT_FERROR, buf); |
|
|
|
|
/* |
/* |
* Varargs front-end to _fatalerr() |
* Varargs front-end to _fatalerr() |
*/ |
*/ |
extern void fatalerr(va_alist) |
void |
|
fatalerr(va_alist) |
va_dcl |
va_dcl |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
|
|
|
|
va_start(args); |
va_start(args); |
fmt = (char *) va_arg(args, char *); |
fmt = (char *) va_arg(args, char *); |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_fatalerr(buf); |
_fatalerr(buf); |
|
|
/* |
/* |
* Stdarg front-end to _fatalerr() |
* Stdarg front-end to _fatalerr() |
*/ |
*/ |
extern void fatalerr(char *fmt, ...) |
void |
|
fatalerr(char *fmt, ...) |
{ |
{ |
static char buf[MSGBUFSIZ]; |
static char buf[MSGBUFSIZ]; |
va_list args; |
va_list args; |
|
|
va_start(args, fmt); |
va_start(args, fmt); |
(void) vsnprintf(buf, sizeof buf, fmt, args); |
(void) vsnprintf(buf, sizeof(buf), fmt, args); |
va_end(args); |
va_end(args); |
|
|
_fatalerr(buf); |
_fatalerr(buf); |
} |
} |
#endif /* ARG_STDARG */ |
#endif /* ARG_STDARG */ |
|
|
#if !defined(ARG_TYPE) |
|
/* |
/* |
* Simple front-end to _fatalerr() |
|
*/ |
|
/*VARARGS1*/ |
|
extern void fatalerr(fmt, a1, a2, a3, a4, a5) |
|
char *fmt; |
|
{ |
|
static char buf[MSGBUFSIZ]; |
|
|
|
(void) snprintf(buf, sizeof buf, fmt, a1, a2, a3, a4, a5); |
|
|
|
_fatalerr(buf); |
|
} |
|
#endif /* !ARG_TYPE */ |
|
|
|
/* |
|
* Get the name of the file used for notify. |
* Get the name of the file used for notify. |
* A side effect is that the file pointer to the file |
* A side effect is that the file pointer to the file |
* is closed. We assume this function is only called when |
* is closed. We assume this function is only called when |
* we are ready to read the file. |
* we are ready to read the file. |
*/ |
*/ |
extern char *getnotifyfile() |
char * |
|
getnotifyfile(void) |
{ |
{ |
int i; |
int i; |
|
|