Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/blacklist more portability.



details:   https://anonhg.NetBSD.org/src/rev/f54e4fc86d24
branches:  trunk
changeset: 805858:f54e4fc86d24
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 22 03:08:09 2015 +0000

description:
more portability.

diffstat:

 external/bsd/blacklist/bin/Makefile             |   6 +-
 external/bsd/blacklist/bin/blacklistctl.c       |   6 +-
 external/bsd/blacklist/bin/blacklistd.c         |   9 +-
 external/bsd/blacklist/bin/conf.c               |   6 +-
 external/bsd/blacklist/bin/internal.c           |   9 +-
 external/bsd/blacklist/bin/run.c                |   6 +-
 external/bsd/blacklist/bin/state.h              |   8 +-
 external/bsd/blacklist/bin/support.c            |  91 +++++++++++++++++++++++++
 external/bsd/blacklist/bin/support.h            |  39 ++++++++++
 external/bsd/blacklist/port/Makefile.am         |   2 +-
 external/bsd/blacklist/port/configure.ac        |   8 +-
 external/bsd/blacklist/port/port.h              |   4 +
 external/bsd/blacklist/port/sockaddr_snprintf.c |  13 ++-
 13 files changed, 185 insertions(+), 22 deletions(-)

diffs (truncated from 417 to 300 lines):

diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/Makefile
--- a/external/bsd/blacklist/bin/Makefile       Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/Makefile       Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.8 2015/01/21 23:26:26 christos Exp $
+# $NetBSD: Makefile,v 1.9 2015/01/22 03:08:09 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 internal.c
-SRCS.blacklistctl = blacklistctl.c conf.c state.c util.c internal.c
+SRCS.blacklistd = blacklistd.c conf.c run.c state.c support.c internal.c
+SRCS.blacklistctl = blacklistctl.c conf.c state.c support.c internal.c
 DBG=-g
 
 LDADD+=-lutil
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/blacklistctl.c
--- a/external/bsd/blacklist/bin/blacklistctl.c Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistctl.c Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistctl.c,v 1.5 2015/01/22 01:39:18 christos Exp $        */
+/*     $NetBSD: blacklistctl.c,v 1.6 2015/01/22 03:08:09 christos Exp $        */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,11 +34,13 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistctl.c,v 1.5 2015/01/22 01:39:18 christos Exp $");
+__RCSID("$NetBSD: blacklistctl.c,v 1.6 2015/01/22 03:08:09 christos Exp $");
 
 #include <stdio.h>
 #include <time.h>
+#ifdef HAVE_UTIL_H
 #include <util.h>
+#endif
 #include <fcntl.h>
 #include <db.h>
 #include <err.h>
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/blacklistd.c
--- a/external/bsd/blacklist/bin/blacklistd.c   Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/blacklistd.c   Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: blacklistd.c,v 1.12 2015/01/22 01:39:18 christos Exp $ */
+/*     $NetBSD: blacklistd.c,v 1.13 2015/01/22 03:08:09 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,13 +33,15 @@
 #include "port.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: blacklistd.c,v 1.12 2015/01/22 01:39:18 christos Exp $");
+__RCSID("$NetBSD: blacklistd.c,v 1.13 2015/01/22 03:08:09 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/queue.h>
 
+#ifdef HAVE_UTIL_H
 #include <util.h>
+#endif
 #include <string.h>
 #include <signal.h>
 #include <netdb.h>
@@ -56,7 +58,6 @@
 #include <err.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <util.h>
 #include <time.h>
 
 #include "bl.h"
@@ -64,7 +65,7 @@
 #include "conf.h"
 #include "run.h"
 #include "state.h"
-#include "util.h"
+#include "support.h"
 
 static const char *configfile = _PATH_BLCONF;
 static DB *state;
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/conf.c
--- a/external/bsd/blacklist/bin/conf.c Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/conf.c Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: conf.c,v 1.8 2015/01/22 02:42:27 christos Exp $        */
+/*     $NetBSD: conf.c,v 1.9 2015/01/22 03:08:09 christos Exp $        */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "port.h"
 #endif
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: conf.c,v 1.8 2015/01/22 02:42:27 christos Exp $");
+__RCSID("$NetBSD: conf.c,v 1.9 2015/01/22 03:08:09 christos Exp $");
 
 #include <stdio.h>
 #include <string.h>
@@ -43,7 +43,9 @@
 #include <pwd.h>
 #include <syslog.h>
 #include <errno.h>
+#ifdef HAVE_UTIL_H
 #include <util.h>
+#endif
 #include <stdlib.h>
 #include <limits.h>
 #include <arpa/inet.h>
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/internal.c
--- a/external/bsd/blacklist/bin/internal.c     Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/internal.c     Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: internal.c,v 1.1 2015/01/21 23:26:26 christos Exp $    */
+/*     $NetBSD: internal.c,v 1.2 2015/01/22 03:08:09 christos Exp $    */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -28,8 +28,13 @@
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
+
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: internal.c,v 1.1 2015/01/21 23:26:26 christos Exp $");
+__RCSID("$NetBSD: internal.c,v 1.2 2015/01/22 03:08:09 christos Exp $");
 
 #include <stdio.h>
 #include <syslog.h>
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/run.c
--- a/external/bsd/blacklist/bin/run.c  Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/run.c  Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: run.c,v 1.5 2015/01/22 01:39:18 christos Exp $ */
+/*     $NetBSD: run.c,v 1.6 2015/01/22 03:08:09 christos Exp $ */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -34,10 +34,12 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: run.c,v 1.5 2015/01/22 01:39:18 christos Exp $");
+__RCSID("$NetBSD: run.c,v 1.6 2015/01/22 03:08:09 christos Exp $");
 
 #include <stdio.h>
+#ifdef HAVE_UTIL_H
 #include <util.h>
+#endif
 #include <stdarg.h>
 #include <limits.h>
 #include <stdlib.h>
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/state.h
--- a/external/bsd/blacklist/bin/state.h        Thu Jan 22 02:48:24 2015 +0000
+++ b/external/bsd/blacklist/bin/state.h        Thu Jan 22 03:08:09 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: state.h,v 1.2 2015/01/21 16:16:00 christos Exp $       */
+/*     $NetBSD: state.h,v 1.3 2015/01/22 03:08:09 christos Exp $       */
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -31,7 +31,13 @@
 #ifndef _STATE_H
 #define _STATE_H
 
+#ifdef HAVE_DB_185_H
+#include <db_185.h>
+#elif HAVE_DB_H
 #include <db.h>
+#else
+#error "no db.h"
+#endif
 #include <time.h>
 
 struct dbinfo {
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/support.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/bin/support.c      Thu Jan 22 03:08:09 2015 +0000
@@ -0,0 +1,91 @@
+/*     $NetBSD: support.c,v 1.1 2015/01/22 03:08:09 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.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#include "port.h"
+#endif
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: support.c,v 1.1 2015/01/22 03:08:09 christos Exp $");
+
+#include <time.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include "support.h"
+
+static __attribute__((__format_arg__(3))) const char *
+expandm(char *buf, size_t len, const char *fmt) 
+{
+       char *p;
+       size_t r;
+
+       if ((p = strstr(fmt, "%m")) == NULL)
+               return fmt;
+
+       r = (size_t)(p - fmt);
+       if (r >= len)
+               return fmt;
+
+       strlcpy(buf, fmt, r + 1);
+       strlcat(buf, strerror(errno), len);
+       strlcat(buf, fmt + r + 2, len);
+
+       return buf;
+}
+
+void
+dlog(int level __unused, const char *fmt, ...)
+{
+       char buf[BUFSIZ];
+       va_list ap;
+
+       fprintf(stderr, "%s: ", getprogname());
+       va_start(ap, fmt);
+       vfprintf(stderr, expandm(buf, sizeof(buf), fmt), ap);
+       va_end(ap);
+       fprintf(stderr, "\n");
+}
+
+const char *
+fmttime(char *b, size_t l, time_t t)
+{
+       struct tm tm;
+       if (localtime_r(&t, &tm) == NULL)
+               snprintf(b, l, "*%jd*", (intmax_t)t);
+       else
+               strftime(b, l, "%Y/%m/%d %H:%M:%S", &tm);
+       return b;
+}
diff -r dc5933a36259 -r f54e4fc86d24 external/bsd/blacklist/bin/support.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/bin/support.h      Thu Jan 22 03:08:09 2015 +0000
@@ -0,0 +1,39 @@
+/*     $NetBSD: support.h,v 1.1 2015/01/22 03:08:09 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



Home | Main Index | Thread Index | Old Index