Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/blacklist/bin - split globals into a separate file



details:   https://anonhg.NetBSD.org/src/rev/d13ee5e68672
branches:  trunk
changeset: 335705:d13ee5e68672
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 21 23:26:26 2015 +0000

description:
- split globals into a separate file
- more config pretty-printing.

diffstat:

 external/bsd/blacklist/bin/Makefile       |   6 ++--
 external/bsd/blacklist/bin/blacklistctl.c |   1 +
 external/bsd/blacklist/bin/blacklistd.c   |  13 +-------
 external/bsd/blacklist/bin/conf.c         |  10 ++++--
 external/bsd/blacklist/bin/internal.c     |  43 +++++++++++++++++++++++++++++++
 external/bsd/blacklist/bin/internal.h     |  12 ++++----
 6 files changed, 61 insertions(+), 24 deletions(-)

diffs (183 lines):

diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/Makefile
--- a/external/bsd/blacklist/bin/Makefile       Wed Jan 21 23:09:44 2015 +0000
+++ b/external/bsd/blacklist/bin/Makefile       Wed Jan 21 23:26:26 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2015/01/21 19:27:01 christos Exp $
+# $NetBSD: Makefile,v 1.8 2015/01/21 23:26:26 christos Exp $
 
 BINDIR=/usr/sbin
 
@@ -6,8 +6,8 @@
 MAN.blacklistd=blacklistd.8
 MAN.blacklistctl=blacklistctl.8
 MLINKS=blacklistd.8 blacklistd.conf.5
-SRCS.blacklistd = blacklistd.c conf.c run.c state.c util.c
-SRCS.blacklistctl = blacklistctl.c conf.c state.c util.c
+SRCS.blacklistd = blacklistd.c conf.c run.c state.c util.c internal.c
+SRCS.blacklistctl = blacklistctl.c conf.c state.c util.c internal.c
 DBG=-g
 
 LDADD+=-lutil
diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/blacklistctl.c
--- a/external/bsd/blacklist/bin/blacklistctl.c Wed Jan 21 23:09:44 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistctl.c Wed Jan 21 23:26:26 2015 +0000
@@ -21,6 +21,7 @@
        fprintf(stderr, "Usage: %s [-d]\n", getprogname());
        exit(EXIT_FAILURE);
 }
+
 int
 main(int argc, char *argv[])
 {
diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c   Wed Jan 21 23:09:44 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c   Wed Jan 21 23:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistd.c,v 1.10 2015/01/21 23:09:44 christos Exp $ */
+/*     $NetBSD: blacklistd.c,v 1.11 2015/01/21 23:26:26 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.10 2015/01/21 23:09:44 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.11 2015/01/21 23:26:26 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -63,20 +63,11 @@
 #include "util.h"
 
 static const char *configfile = _PATH_BLCONF;
-
-int debug;
-const char *rulename = "blacklistd";
-const char *controlprog = _PATH_BLCONTROL;
-struct conf *conf;
-size_t nconf;
-
 static DB *state;
 static const char *dbfile = _PATH_BLSTATE;
 static sig_atomic_t rconf;
 static sig_atomic_t done;
 
-void (*lfun)(int, const char *, ...) = syslog;
-
 static void
 sigusr1(int n)
 {
diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/conf.c
--- a/external/bsd/blacklist/bin/conf.c Wed Jan 21 23:09:44 2015 +0000
+++ b/external/bsd/blacklist/bin/conf.c Wed Jan 21 23:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.6 2015/01/21 23:09:44 christos Exp $        */
+/*     $NetBSD: conf.c,v 1.7 2015/01/21 23:26:26 christos Exp $        */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: conf.c,v 1.6 2015/01/21 23:09:44 christos Exp $");
+__RCSID("$NetBSD: conf.c,v 1.7 2015/01/21 23:26:26 christos Exp $");
 
 #include <stdio.h>
 #include <string.h>
@@ -373,6 +373,7 @@
     const struct conf *c)
 {
        char hb[128], b[5][64];
+       int sp;
 
 #define N(n, v) conf_num(b[n], sizeof(b[n]), (v))
 
@@ -390,10 +391,11 @@
                        snprintf(hb, sizeof(hb), "%d", c->c_port);
        }
        
+       sp = *delim == '\t' ? 20 : -1;
        if (*delim)
-               snprintf(buf, len, "%s%20.20s%s%s%s" "%s%s%s%s"
+               snprintf(buf, len, "%s%*.*s%s%s%s" "%s%s%s%s"
                    "%s%s" "%s%s%s",
-                   pref, hb, delim, N(0, c->c_proto), delim,
+                   pref, sp, sp, hb, delim, N(0, c->c_proto), delim,
                    N(1, c->c_family), delim, N(2, c->c_uid), delim,
                    conf_name(c->c_name), delim,
                    N(3, c->c_nfail), delim, N(4, c->c_duration));
diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/internal.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/bin/internal.c     Wed Jan 21 23:26:26 2015 +0000
@@ -0,0 +1,43 @@
+/*     $NetBSD: internal.c,v 1.1 2015/01/21 23:26:26 christos Exp $    */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: internal.c,v 1.1 2015/01/21 23:26:26 christos Exp $");
+
+#include <stdio.h>
+#include <syslog.h>
+#include "internal.h"
+
+int debug;
+const char *rulename = "blacklistd";
+const char *controlprog = _PATH_BLCONTROL;
+struct conf *conf;
+size_t nconf;
+void (*lfun)(int, const char *, ...) = syslog;
diff -r ebf07ca0ed3c -r d13ee5e68672 external/bsd/blacklist/bin/internal.h
--- a/external/bsd/blacklist/bin/internal.h     Wed Jan 21 23:09:44 2015 +0000
+++ b/external/bsd/blacklist/bin/internal.h     Wed Jan 21 23:26:26 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: internal.h,v 1.5 2015/01/21 16:16:00 christos Exp $    */
+/*     $NetBSD: internal.h,v 1.6 2015/01/21 23:26:26 christos Exp $    */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -35,11 +35,11 @@
 #define        _PATH_BLCONTROL "/etc/blacklistd/control"
 #define        _PATH_BLSTATE   "/var/db/blacklistd.db"
 
-struct conf *conf;
-size_t nconf;
-int debug;
-const char *rulename;
-const char *controlprog;
+extern struct conf *conf;
+extern size_t nconf;
+extern int debug;
+extern const char *rulename;
+extern const char *controlprog;
 
 void (*lfun)(int, const char *, ...);
 



Home | Main Index | Thread Index | Old Index