[Toybox] [CLEANUP] syslogd - Pass 4
Rob Landley
rob at landley.net
Sun Aug 25 02:11:09 PDT 2013
On 08/23/2013 03:56:41 PM, Felix Janda wrote:
> # HG changeset patch
> # User Felix Janda <felix.janda at posteo.de>
> # Date 1377291029 -7200
> # Node ID 378ab7bde3df8fc8de3e3b3ec3d2bd665610ea37
> # Parent 42d4b68e3490ab722c637d6d211a18454deb450d
> syslogd: stop abusing arg_list
>
> diff -r 42d4b68e3490 -r 378ab7bde3df toys/pending/syslogd.c
> --- a/toys/pending/syslogd.c Fri Aug 23 22:19:55 2013 +0200
> +++ b/toys/pending/syslogd.c Fri Aug 23 22:50:29 2013 +0200
> @@ -37,6 +37,26 @@
> #include "toys.h"
> #include "toynet.h"
>
> +// UNIX Sockets for listening
> +struct unsocks {
> + struct unsocks *next;
> + char *path;
> + struct sockaddr_un sdu;
> + int sd;
> +};
> +
> +// Log file entry to log into.
> +struct logfile {
> + struct logfile *next;
> + char *filename;
> + char *config;
> + int isNetwork;
> + uint32_t facility[8];
> + uint8_t level[LOG_NFACILITIES];
> + int logfd;
> + struct sockaddr_in saddr;
> +};
> +
> GLOBALS(
> char *socket;
> char *config_file;
> @@ -48,32 +68,13 @@
> char *remote_log;
> long log_prio;
>
> - struct arg_list *lsocks; // list of listen sockets
> - struct arg_list *lfiles; // list of write logfiles
> + struct unsocks *lsocks; // list of listen sockets
> + struct logfile *lfiles; // list of write logfiles
That won't work if you build any command other than this one. The union
is defined in the headers of every command's c file, so the type has to
be in lib.h for you to use it in GLOBALS. And I'd rather not pollute
lib.h with a lot of command-local types...
Easy fix is just use a void * in GLOBALS and cast it to a local you
actually use. (I've considered adding a generic list type that's a
struct with just a next *, but you'd still have to typecast to use it,
so it wouldn't help much.)
(P.S: I've got your pass 3 patch saved but I'm moving laptops and
everything's in a halfway state that makes pushing changes to the
website a bit funky just now. Hope to have that cleared up by monday.)
Rob
More information about the Toybox
mailing list