Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/blacklist/port additions for linux



details:   https://anonhg.NetBSD.org/src/rev/d7c938727681
branches:  trunk
changeset: 335711:d7c938727681
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Jan 22 02:35:44 2015 +0000

description:
additions for linux

diffstat:

 external/bsd/blacklist/port/Makefile.am   |    3 +-
 external/bsd/blacklist/port/configure.ac  |   11 ++-
 external/bsd/blacklist/port/getprogname.c |   12 +++
 external/bsd/blacklist/port/port.h        |   31 +++++++++
 external/bsd/blacklist/port/strlcat.c     |  101 ++++++++++++++++++++++++++++++
 external/bsd/blacklist/port/strlcpy.c     |   81 ++++++++++++++++++++++++
 external/bsd/blacklist/port/strtoi.c      |    6 +-
 7 files changed, 237 insertions(+), 8 deletions(-)

diffs (truncated from 341 to 300 lines):

diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/Makefile.am
--- a/external/bsd/blacklist/port/Makefile.am   Thu Jan 22 02:27:16 2015 +0000
+++ b/external/bsd/blacklist/port/Makefile.am   Thu Jan 22 02:35:44 2015 +0000
@@ -1,4 +1,5 @@
 #
+ACLOCAL_AMFLAGS = -Im4
 lib_LTLIBRARIES = libblacklist.la
 include_HEADERS = blacklist.h
 
@@ -6,7 +7,7 @@
 
 VPATH = ../bin:../lib:../test
 
-AM_CPPFLAGS = -I../include -I../bin/include
+AM_CPPFLAGS = -I../include 
 AM_CFLAGS = @WARNINGS@
 
 libblacklist_la_SOURCES = bl.c blacklist.c
diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/configure.ac
--- a/external/bsd/blacklist/port/configure.ac  Thu Jan 22 02:27:16 2015 +0000
+++ b/external/bsd/blacklist/port/configure.ac  Thu Jan 22 02:35:44 2015 +0000
@@ -23,14 +23,17 @@
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(stdint.h fcntl.h stdint.h inttypes.h unistd.h)
 AC_CHECK_HEADERS(sys/un.h sys/socket.h limits.h)
-AC_CHECK_HEADERS(arpa/inet.h getopt.h err.h xlocale.h)
-AC_CHECK_HEADERS(sys/types.h sys/utime.h sys/time.h time.h)
+AC_CHECK_HEADERS(arpa/inet.h getopt.h err.h)
+AC_CHECK_HEADERS(sys/types.h util.h sys/time.h time.h)
+AC_CHECK_HEADERS(netatalk/at.h net/if_dl.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_SYS_LARGEFILE
+AC_CHECK_MEMBERS([struct sockaddr_in.sin_len])
+
 
 AC_TYPE_PID_T
 AC_TYPE_UINT8_T
@@ -67,10 +70,10 @@
 fi])
 
 dnl Checks for functions
-AC_CHECK_FUNCS(strerror strndup strtoul mkstemp mkostemp utimes utime wcwidth strtof newlocale uselocale freelocale setlocal)
+AC_CHECK_FUNCS(strerror)
 
 dnl Provide implementation of some required functions if necessary
-AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime)
+AC_REPLACE_FUNCS(strtoi sockaddr_snprintf popenve clock_gettime strlcpy strlcat getprogname)
 
 dnl See if we are cross-compiling
 AM_CONDITIONAL(IS_CROSS_COMPILE, test "$cross_compiling" = yes)
diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/getprogname.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/port/getprogname.c Thu Jan 22 02:35:44 2015 +0000
@@ -0,0 +1,12 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "port.h"
+
+extern char *__progname;
+
+const char *
+getprogname(void)
+{
+       return __progname;
+}
diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/port.h
--- a/external/bsd/blacklist/port/port.h        Thu Jan 22 02:27:16 2015 +0000
+++ b/external/bsd/blacklist/port/port.h        Thu Jan 22 02:35:44 2015 +0000
@@ -1,21 +1,52 @@
 #include <stdio.h>
 #include <inttypes.h>
+#include <time.h>
 
 #ifndef __unused
 #define __unused __attribute__((__unused__))
 #endif
+
+#ifndef __RCSID
+#define __RCSID(a)
+#endif
+
 #ifndef __UNCONST
 #define __UNCONST(a) ((void *)(intptr_t)(a))
 #endif
+
 #ifndef __arraycount
 #define __arraycount(a) (sizeof(a) / sizeof(a[0]))
 #endif
 
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_STRLCAT
+size_t strlcat(char *, const char *, size_t);
+#endif
+
+#ifndef HAVE_POPENVE
 FILE *popenve(const char *, char *const *, char *const *, const char *);
 int pcloseve(FILE *);
+#define pclose(a) pcloseve(a);
+#endif
+
+#ifndef HAVE_SOCKADDR_SNPRINTF
 struct sockaddr;
 int sockaddr_snprintf(char *, size_t, const char *, const struct sockaddr *);
+#endif
+
+#ifndef HAVE_STRTOI
 intmax_t strtoi(const char *, char **, int, intmax_t, intmax_t, int *);
+#endif
+#ifndef HAVE_GETPROGNAME
+const char *getprogname(void);
+
+#endif
+
+#ifndef HAVE_CLOCK_GETTIME
 struct timespec;
 int clock_gettime(int, struct timespec *);
 #define CLOCK_REALTIME 0
+#endif
diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/strlcat.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/port/strlcat.c     Thu Jan 22 02:35:44 2015 +0000
@@ -0,0 +1,101 @@
+/*     $NetBSD: strlcat.c,v 1.1 2015/01/22 02:36:15 christos Exp $     */
+/*     $OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp $    */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strlcat.c,v 1.1 2015/01/22 02:36:15 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+#include <sys/types.h>
+#include <assert.h>
+#include <string.h>
+
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcat, _strlcat)
+# endif
+#endif
+
+#else
+#include <lib/libkern/libkern.h>
+#endif /* !_KERNEL && !_STANDALONE */
+
+#if !HAVE_STRLCAT
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left).  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+#if 1
+       char *d = dst;
+       const char *s = src;
+       size_t n = siz;
+       size_t dlen;
+
+       _DIAGASSERT(dst != NULL);
+       _DIAGASSERT(src != NULL);
+
+       /* Find the end of dst and adjust bytes left but don't go past end */
+       while (n-- != 0 && *d != '\0')
+               d++;
+       dlen = d - dst;
+       n = siz - dlen;
+
+       if (n == 0)
+               return(dlen + strlen(s));
+       while (*s != '\0') {
+               if (n != 1) {
+                       *d++ = *s;
+                       n--;
+               }
+               s++;
+       }
+       *d = '\0';
+
+       return(dlen + (s - src));       /* count does not include NUL */
+#else
+       _DIAGASSERT(dst != NULL);
+       _DIAGASSERT(src != NULL);
+
+       /*
+        * Find length of string in dst (maxing out at siz).
+        */
+       size_t dlen = strnlen(dst, siz);
+
+       /*
+        * Copy src into any remaining space in dst (truncating if needed).
+        * Note strlcpy(dst, src, 0) returns strlen(src).
+        */
+       return dlen + strlcpy(dst + dlen, src, siz - dlen);
+#endif
+}
+#endif
diff -r 304b822d9e95 -r d7c938727681 external/bsd/blacklist/port/strlcpy.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/blacklist/port/strlcpy.c     Thu Jan 22 02:35:44 2015 +0000
@@ -0,0 +1,81 @@
+/*     $NetBSD: strlcpy.c,v 1.1 2015/01/22 02:36:15 christos Exp $     */
+/*     $OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp $     */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
+ * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#if !defined(_KERNEL) && !defined(_STANDALONE)
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strlcpy.c,v 1.1 2015/01/22 02:36:15 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+#include <sys/types.h>
+#include <assert.h>
+#include <string.h>
+
+#ifdef _LIBC
+# ifdef __weak_alias
+__weak_alias(strlcpy, _strlcpy)
+# endif
+#endif
+#else
+#include <lib/libkern/libkern.h>
+#endif /* !_KERNEL && !_STANDALONE */
+
+
+#if !HAVE_STRLCPY
+/*
+ * Copy src to string dst of size siz.  At most siz-1 characters
+ * will be copied.  Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+       char *d = dst;
+       const char *s = src;
+       size_t n = siz;
+
+       _DIAGASSERT(dst != NULL);
+       _DIAGASSERT(src != NULL);
+
+       /* Copy as many bytes as will fit */
+       if (n != 0 && --n != 0) {
+               do {



Home | Main Index | Thread Index | Old Index