summaryrefslogtreecommitdiff
path: root/usr.bin/rdist/message.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rdist/message.c')
-rw-r--r--usr.bin/rdist/message.c56
1 files changed, 37 insertions, 19 deletions
diff --git a/usr.bin/rdist/message.c b/usr.bin/rdist/message.c
index 1609f240d93..270177c4251 100644
--- a/usr.bin/rdist/message.c
+++ b/usr.bin/rdist/message.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: message.c,v 1.23 2015/01/20 03:14:52 guenther Exp $ */
+/* $OpenBSD: message.c,v 1.24 2015/01/20 06:02:30 guenther Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -45,7 +45,10 @@ int nerrs = 0; /* Number of errors */
/*
* Message Types
*/
-MSGTYPE msgtypes[] = {
+struct msgtype {
+ int mt_type; /* Type (bit) */
+ char *mt_name; /* Name of message type */
+} msgtypes[] = {
{ MT_CHANGE, "change" },
{ MT_INFO, "info" },
{ MT_NOTICE, "notice" },
@@ -58,15 +61,30 @@ MSGTYPE msgtypes[] = {
{ 0 },
};
-static void msgsendstdout(MSGFACILITY *, int, int, char *);
-static void msgsendsyslog(MSGFACILITY *, int, int, char *);
-static void msgsendfile(MSGFACILITY *, int, int, char *);
-static void msgsendnotify(MSGFACILITY *, int, int, char *);
+/*
+ * Description of message facilities
+ */
+struct msgfacility {
+ /* compile time initialized data */
+ int mf_msgfac; /* One of MF_* from below */
+ char *mf_name; /* Name of this facility */
+ void (*mf_sendfunc) /* Function to send msg */
+ (struct msgfacility *, int, int, char *);
+ /* run time initialized data */
+ int mf_msgtypes; /* Bitmask of MT_* from above*/
+ char *mf_filename; /* Name of file */
+ FILE *mf_fptr; /* File pointer to output to */
+};
+
+static void msgsendstdout(struct msgfacility *, int, int, char *);
+static void msgsendsyslog(struct msgfacility *, int, int, char *);
+static void msgsendfile(struct msgfacility *, int, int, char *);
+static void msgsendnotify(struct msgfacility *, int, int, char *);
/*
* Message Facilities
*/
-MSGFACILITY msgfacility[] = {
+struct msgfacility msgfacility[] = {
{ MF_STDOUT, "stdout", msgsendstdout },
{ MF_FILE, "file", msgsendfile },
{ MF_SYSLOG, "syslog", msgsendsyslog },
@@ -74,9 +92,9 @@ MSGFACILITY msgfacility[] = {
{ 0 },
};
-static MSGFACILITY *getmsgfac(char *);
-static MSGTYPE *getmsgtype(char *);
-static char *setmsgtypes(MSGFACILITY *, char *);
+static struct msgfacility *getmsgfac(char *);
+static struct msgtype *getmsgtype(char *);
+static char *setmsgtypes(struct msgfacility *, char *);
static void _message(int, char *);
static void _debugmsg(int, char *);
static void _error(const char *);
@@ -135,7 +153,7 @@ msgprconfig(void)
/*
* Get the Message Facility entry "name"
*/
-static MSGFACILITY *
+static struct msgfacility *
getmsgfac(char *name)
{
int i;
@@ -150,7 +168,7 @@ getmsgfac(char *name)
/*
* Get the Message Type entry named "name"
*/
-static MSGTYPE *
+static struct msgtype *
getmsgtype(char *name)
{
int i;
@@ -167,12 +185,12 @@ getmsgtype(char *name)
* indicated by string "str".
*/
static char *
-setmsgtypes(MSGFACILITY *msgfac, char *str)
+setmsgtypes(struct msgfacility *msgfac, char *str)
{
static char ebuf[BUFSIZ];
char *cp;
char *strptr, *word;
- MSGTYPE *mtp;
+ struct msgtype *mtp;
/*
* MF_SYSLOG is the only supported message facility for the server
@@ -265,7 +283,7 @@ msgparseopts(char *msgstr, int doset)
static char ebuf[BUFSIZ], msgbuf[MSGBUFSIZ];
char *cp, *optstr;
char *word;
- MSGFACILITY *msgfac;
+ struct msgfacility *msgfac;
if (msgstr == NULL)
return("NULL message string");
@@ -317,7 +335,7 @@ msgparseopts(char *msgstr, int doset)
* For rdistd, this is really the rdist client.
*/
static void
-msgsendstdout(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
+msgsendstdout(struct msgfacility *msgfac, int mtype, int flags, char *msgbuf)
{
char cmd;
@@ -371,7 +389,7 @@ msgsendstdout(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
* Send a message to facility "syslog"
*/
static void
-msgsendsyslog(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
+msgsendsyslog(struct msgfacility *msgfac, int mtype, int flags, char *msgbuf)
{
int syslvl = 0;
@@ -412,7 +430,7 @@ msgsendsyslog(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
* Send a message to a "file" facility.
*/
static void
-msgsendfile(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
+msgsendfile(struct msgfacility *msgfac, int mtype, int flags, char *msgbuf)
{
if (msgfac->mf_fptr == NULL)
return;
@@ -428,7 +446,7 @@ msgsendfile(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
* Same method as msgsendfile()
*/
static void
-msgsendnotify(MSGFACILITY *msgfac, int mtype, int flags, char *msgbuf)
+msgsendnotify(struct msgfacility *msgfac, int mtype, int flags, char *msgbuf)
{
char *tempfile;