From: guenther Date: Tue, 20 Jan 2015 06:02:30 +0000 (+0000) Subject: Move struct distoptinfo into distopt.c, killing the DISTOPTINFO typedef X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4142fec9bc6d611857dd48b3e5021f52bc3709a4;p=openbsd Move struct distoptinfo into distopt.c, killing the DISTOPTINFO typedef Move struct msgtype and msgfacility into message.c, killing the MSGTYPE and MSGFACILITY typedefs Make getdistopt() static to distopt.c --- diff --git a/usr.bin/rdist/defs.h b/usr.bin/rdist/defs.h index 73e63190002..4e1a9af36b0 100644 --- a/usr.bin/rdist/defs.h +++ b/usr.bin/rdist/defs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: defs.h,v 1.33 2015/01/20 03:14:52 guenther Exp $ */ +/* $OpenBSD: defs.h,v 1.34 2015/01/20 06:02:30 guenther Exp $ */ #ifndef __DEFS_H__ #define __DEFS_H__ @@ -324,7 +324,6 @@ char *xbasename(char *); char *searchpath(char *); /* distopt.c */ -DISTOPTINFO *getdistopt(char *, int *); int parsedistopts(char *, opt_t *, int); char *getdistoptlist(void); char *getondistoptlist(opt_t); diff --git a/usr.bin/rdist/distopt.c b/usr.bin/rdist/distopt.c index adf341f1513..64b054f8f43 100644 --- a/usr.bin/rdist/distopt.c +++ b/usr.bin/rdist/distopt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: distopt.c,v 1.11 2009/10/27 23:59:42 deraadt Exp $ */ +/* $OpenBSD: distopt.c,v 1.12 2015/01/20 06:02:30 guenther Exp $ */ /* * Copyright (c) 1983 Regents of the University of California. @@ -39,7 +39,12 @@ /* * Distfile Option Information */ -DISTOPTINFO distoptinfo[] = { +struct distoptinfo { + opt_t do_value; + char *do_name; + char *do_arg; + size_t arg_size; +} distoptinfo[] = { { DO_CHKNFS, "chknfs", NULL, 0}, { DO_CHKREADONLY, "chkreadonly", NULL, 0}, { DO_CHKSYM, "chksym", NULL, 0}, @@ -70,7 +75,7 @@ DISTOPTINFO distoptinfo[] = { /* * Get a Distfile Option entry named "name". */ -DISTOPTINFO * +static struct distoptinfo * getdistopt(char *name, int *len) { int i; @@ -92,7 +97,7 @@ int parsedistopts(char *str, opt_t *optptr, int doerrs) { char *string, *optstr; - DISTOPTINFO *distopt; + struct distoptinfo *distopt; int len; /* strtok() is destructive */ 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; diff --git a/usr.bin/rdist/types.h b/usr.bin/rdist/types.h index f11a86b2c6a..298c6396040 100644 --- a/usr.bin/rdist/types.h +++ b/usr.bin/rdist/types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: types.h,v 1.5 2003/05/14 01:34:35 millert Exp $ */ +/* $OpenBSD: types.h,v 1.6 2015/01/20 06:02:30 guenther Exp $ */ #ifndef __myTYPES_H__ #define __myTYPES_H__ @@ -37,17 +37,7 @@ #define DO_DEFOWNER 0x0800000 #define DO_SPARSE 0x1000000 /* XXX not implemented */ -/* - * Dist option information - */ typedef long opt_t; -struct _distoptinfo { - opt_t do_value; - char *do_name; - char *do_arg; - size_t arg_size; -}; -typedef struct _distoptinfo DISTOPTINFO; /* Debug Message types */ #define DM_CALL 0x01 @@ -56,15 +46,6 @@ typedef struct _distoptinfo DISTOPTINFO; #define DM_MISC 0x10 #define DM_ALL 0x17 -/* - * Description of a message type - */ -struct _msgtype { - int mt_type; /* Type (bit) */ - char *mt_name; /* Name of message type */ -}; -typedef struct _msgtype MSGTYPE; - /* * Message Type definitions */ @@ -84,23 +65,6 @@ typedef struct _msgtype MSGTYPE; MT_INFO|MT_NOTICE|\ MT_SYSLOG|MT_VERBOSE) -/* - * Description of message facilities - */ -typedef struct _msgfacility MSGFACILITY; - -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 */ - (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 */ -}; - /* * Message Facilities */