version 1.6, 1996/07/29 17:50:09 |
version 1.7, 1998/06/26 21:21:15 |
|
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
|
#if 0 |
static char RCSid[] = |
static char RCSid[] = |
|
"$From: message.c,v 6.24 1996/07/19 17:00:35 michaelc Exp $"; |
|
#else |
|
static char RCSid[] = |
"$OpenBSD$"; |
"$OpenBSD$"; |
|
#endif |
|
|
static char sccsid[] = "@(#)common.c"; |
static char sccsid[] = "@(#)common.c"; |
|
|
|
|
if (strcasecmp(name, msgfacility[i].mf_name) == 0) |
if (strcasecmp(name, msgfacility[i].mf_name) == 0) |
return(&msgfacility[i]); |
return(&msgfacility[i]); |
|
|
return((MSGFACILITY *) NULL); |
return(NULL); |
} |
} |
|
|
/* |
/* |
|
|
if (strcasecmp(name, msgtypes[i].mt_name) == 0) |
if (strcasecmp(name, msgtypes[i].mt_name) == 0) |
return(&msgtypes[i]); |
return(&msgtypes[i]); |
|
|
return((MSGTYPE *) NULL); |
return(NULL); |
} |
} |
|
|
/* |
/* |
|
|
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); |
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, ','))) |
*cp++ = CNULL; |
*cp++ = CNULL; |
strptr = cp; |
strptr = cp; |
|
|
if (mtp = getmsgtype(word)) { |
if ((mtp = getmsgtype(word))) { |
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 |
|
|
} |
} |
} |
} |
|
|
return((char *) NULL); |
return(NULL); |
} |
} |
|
|
/* |
/* |
|
|
* Each <facility>=<types> list is seperated by ":". |
* Each <facility>=<types> list is seperated by ":". |
*/ |
*/ |
for (optstr = strtok(msgbuf, ":"); optstr; |
for (optstr = strtok(msgbuf, ":"); optstr; |
optstr = strtok((char *)NULL, ":")) { |
optstr = strtok(NULL, ":")) { |
|
|
if ((cp = strchr(optstr, '=')) == NULL) |
if ((cp = strchr(optstr, '=')) == NULL) |
return("No '=' found"); |
return("No '=' found"); |
|
|
if (doset) { |
if (doset) { |
char *mcp; |
char *mcp; |
|
|
if (mcp = setmsgtypes(msgfac, cp)) |
if ((mcp = setmsgtypes(msgfac, cp))) |
return(mcp); |
return(mcp); |
} |
} |
} |
} |
|
|
msgprconfig(); |
msgprconfig(); |
} |
} |
|
|
return((char *) NULL); |
return(NULL); |
} |
} |
|
|
/* |
/* |
|
|
|
|
if (!msgfac->mf_fptr) { |
if (!msgfac->mf_fptr) { |
register char *cp; |
register char *cp; |
char *getenv(); |
|
int fd; |
int fd; |
|
char *getenv(); |
|
|
/* |
/* |
* Create and open a new temporary file |
* Create and open a new temporary file |
*/ |
*/ |
if ((cp = getenv("TMPDIR")) == (char *) NULL) |
if ((cp = getenv("TMPDIR")) == NULL) |
cp = _PATH_TMP; |
cp = _PATH_TMP; |
tempfile = (char *) xmalloc(strlen(cp) + 1 + |
tempfile = (char *) xmalloc(strlen(cp) + 1 + |
strlen(_RDIST_TMP) + 2); |
strlen(_RDIST_TMP) + 2); |
|
|
/* |
/* |
* Ensure no stray newlines are present |
* Ensure no stray newlines are present |
*/ |
*/ |
if (cp = strchr(msgbuf, '\n')) |
if ((cp = strchr(msgbuf, '\n'))) |
*cp = CNULL; |
*cp = CNULL; |
|
|
checkhostname(); |
checkhostname(); |
|
|
* logged to the system log facility |
* logged to the system log facility |
*/ |
*/ |
if (IS_ON(flags, MT_SYSLOG)) { |
if (IS_ON(flags, MT_SYSLOG)) { |
msgsendsyslog((MSGFACILITY *)NULL, MT_SYSLOG, flags, mbuf); |
msgsendsyslog(NULL, MT_SYSLOG, flags, mbuf); |
return; |
return; |
} |
} |
|
|
|
|
* Special cases |
* Special cases |
*/ |
*/ |
if (isserver && IS_ON(flags, MT_NOTICE)) { |
if (isserver && IS_ON(flags, MT_NOTICE)) { |
msgsendstdout((MSGFACILITY *)NULL, MT_NOTICE, flags, mbuf); |
msgsendstdout(NULL, MT_NOTICE, flags, mbuf); |
return; |
return; |
} else if (isserver && IS_ON(flags, MT_REMOTE)) |
} else if (isserver && IS_ON(flags, MT_REMOTE)) |
msgsendstdout((MSGFACILITY *)NULL, MT_REMOTE, flags, mbuf); |
msgsendstdout(NULL, MT_REMOTE, flags, mbuf); |
else if (isserver && IS_ON(flags, MT_NERROR)) |
else if (isserver && IS_ON(flags, MT_NERROR)) |
msgsendstdout((MSGFACILITY *)NULL, MT_NERROR, flags, mbuf); |
msgsendstdout(NULL, MT_NERROR, flags, mbuf); |
else if (isserver && IS_ON(flags, MT_FERROR)) |
else if (isserver && IS_ON(flags, MT_FERROR)) |
msgsendstdout((MSGFACILITY *)NULL, MT_FERROR, flags, mbuf); |
msgsendstdout(NULL, MT_FERROR, flags, mbuf); |
|
|
/* |
/* |
* For each Message Facility, check each Message Type to see |
* For each Message Facility, check each Message Type to see |
|
|
return(msgfacility[i].mf_filename); |
return(msgfacility[i].mf_filename); |
} |
} |
|
|
return((char *) NULL); |
return(NULL); |
} |
} |