From 32f71d2cab413de75b6b6f2f6c7db849610ebc25 Mon Sep 17 00:00:00 2001 From: deraadt Date: Thu, 16 Sep 2004 05:35:24 +0000 Subject: clean C for a change --- libexec/spamd-setup/spamd-setup.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'libexec/spamd-setup') diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c index cece77db761..739d4d9a53a 100644 --- a/libexec/spamd-setup/spamd-setup.c +++ b/libexec/spamd-setup/spamd-setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd-setup.c,v 1.19 2004/06/29 11:19:07 mickey Exp $ */ +/* $OpenBSD: spamd-setup.c,v 1.20 2004/09/16 05:35:24 deraadt Exp $ */ /* * Copyright (c) 2003 Bob Beck. All rights reserved. @@ -74,7 +74,7 @@ u_int32_t ptoa(char *cp); int parse_netblock(char *buf, struct bl *start, struct bl *end, int white); int open_child(char *file, char **argv); -int fetch(char *url); +int fileget(char *url); int open_file(char *method, char *file); char *fix_quoted_colons(char *buf); void do_message(FILE *sdc, char *msg); @@ -178,16 +178,6 @@ atop(u_int32_t addr) return(inet_ntoa(in)); } -u_int32_t -ptoa(char *cp) -{ - struct in_addr in; - - memset(&in, 0, sizeof(in)); - (void) inet_aton(cp, &in); - return ntohl(in.s_addr); -} - int parse_netblock(char *buf, struct bl *start, struct bl *end, int white) { @@ -258,12 +248,11 @@ parse_netblock(char *buf, struct bl *start, struct bl *end, int white) int open_child(char *file, char **argv) { - pid_t pid; int pdes[2]; if (pipe(pdes) != 0) return(-1); - switch (pid = fork()) { + switch (fork()) { case -1: close(pdes[0]); close(pdes[1]); @@ -285,9 +274,16 @@ open_child(char *file, char **argv) } int -fetch(char *url) +fileget(char *url) { - char *argv[6]= {"ftp", "-V", "-o", "-", url, NULL}; + char *argv[6]; + + argv[0] = "ftp"; + argv[1] = "-V"; + argv[2] = "-o"; + argv[3] = "-"; + argv[4] = url; + argv[5] = NULL; if (debug) fprintf(stderr, "Getting %s\n", url); @@ -309,7 +305,7 @@ open_file(char *method, char *file) asprintf(&url, "%s://%s", method, file); if (url == NULL) return(-1); - i = fetch(url); + i = fileget(url); free(url); return(i); } else if (strcmp(method, "exec") == 0) { @@ -639,12 +635,11 @@ configure_pf(struct cidr **blacklists) "-f" "-", NULL}; static FILE *pf = NULL; int pdes[2]; - pid_t pid; if (pf == NULL) { if (pipe(pdes) != 0) return(-1); - switch (pid = fork()) { + switch (fork()) { case -1: close(pdes[0]); close(pdes[1]); -- cgit v1.2.3-59-g8ed1b