Source-Changes-HG archive

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

[xsrc/util-linux]: xsrc/external/bsd/libuuid_ul/dist import a small portion o...



details:   https://anonhg.NetBSD.org/xsrc/rev/eaf6097e824d
branches:  util-linux
changeset: 10183:eaf6097e824d
user:      mrg <mrg%NetBSD.org@localhost>
date:      Thu Mar 07 03:09:20 2019 +0000

description:
import a small portion of util-linux's "libuuid".  this is needed for
the new fontconfig which uses these APIs internally.  we'll rename
the symbols and they aren't exported by fontconfig.so anyway.

this is necessary because libuuid's API conflicts with netbsd libc
uuid API while being not really simple to shim or provide compat for.

diffstat:

 external/bsd/libuuid_ul/dist/compare.c  |   55 ++
 external/bsd/libuuid_ul/dist/copy.c     |   45 ++
 external/bsd/libuuid_ul/dist/gen_uuid.c |  610 ++++++++++++++++++++++++++++++++
 external/bsd/libuuid_ul/dist/pack.c     |   69 +++
 external/bsd/libuuid_ul/dist/parse.c    |   79 ++++
 external/bsd/libuuid_ul/dist/unpack.c   |   63 +++
 external/bsd/libuuid_ul/dist/unparse.c  |   76 +++
 external/bsd/libuuid_ul/dist/uuid.h     |  121 ++++++
 external/bsd/libuuid_ul/dist/uuidP.h    |   61 +++
 9 files changed, 1179 insertions(+), 0 deletions(-)

diffs (truncated from 1215 to 300 lines):

diff -r b52b9fb50d7f -r eaf6097e824d external/bsd/libuuid_ul/dist/compare.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/libuuid_ul/dist/compare.c    Thu Mar 07 03:09:20 2019 +0000
@@ -0,0 +1,55 @@
+/*
+ * compare.c --- compare whether or not two UUIDs are the same
+ *
+ * Returns 0 if the two UUIDs are different, and 1 if they are the same.
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * 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, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+#include <string.h>
+
+#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
+
+int uuid_compare(const uuid_t uu1, const uuid_t uu2)
+{
+       struct uuid     uuid1, uuid2;
+
+       uuid_unpack(uu1, &uuid1);
+       uuid_unpack(uu2, &uuid2);
+
+       UUCMP(uuid1.time_low, uuid2.time_low);
+       UUCMP(uuid1.time_mid, uuid2.time_mid);
+       UUCMP(uuid1.time_hi_and_version, uuid2.time_hi_and_version);
+       UUCMP(uuid1.clock_seq, uuid2.clock_seq);
+       return memcmp(uuid1.node, uuid2.node, 6);
+}
+
diff -r b52b9fb50d7f -r eaf6097e824d external/bsd/libuuid_ul/dist/copy.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/libuuid_ul/dist/copy.c       Thu Mar 07 03:09:20 2019 +0000
@@ -0,0 +1,45 @@
+/*
+ * copy.c --- copy UUIDs
+ *
+ * Copyright (C) 1996, 1997 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * 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, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#include "uuidP.h"
+
+void uuid_copy(uuid_t dst, const uuid_t src)
+{
+       unsigned char           *cp1;
+       const unsigned char     *cp2;
+       int                     i;
+
+       for (i=0, cp1 = dst, cp2 = src; i < 16; i++)
+               *cp1++ = *cp2++;
+}
diff -r b52b9fb50d7f -r eaf6097e824d external/bsd/libuuid_ul/dist/gen_uuid.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/libuuid_ul/dist/gen_uuid.c   Thu Mar 07 03:09:20 2019 +0000
@@ -0,0 +1,610 @@
+/*
+ * gen_uuid.c --- generate a DCE-compatible uuid
+ *
+ * Copyright (C) 1996, 1997, 1998, 1999 Theodore Ts'o.
+ *
+ * %Begin-Header%
+ * 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, and the entire permission notice in its entirety,
+ *    including the disclaimer of warranties.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR 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 NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ * %End-Header%
+ */
+
+#ifdef _WIN32
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#define UUID MYUUID
+#endif
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#include <string.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <limits.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#include <sys/stat.h>
+#ifdef HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>
+#endif
+#ifdef HAVE_NET_IF_H
+#include <net/if.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_NET_IF_DL_H
+#include <net/if_dl.h>
+#endif
+#if defined(__linux__) && defined(HAVE_SYS_SYSCALL_H)
+#include <sys/syscall.h>
+#endif
+
+#include "all-io.h"
+#include "uuidP.h"
+#include "uuidd.h"
+#include "randutils.h"
+#include "strutils.h"
+#include "c.h"
+#include "md5.h"
+#include "sha1.h"
+
+#ifdef HAVE_TLS
+#define THREAD_LOCAL static __thread
+#else
+#define THREAD_LOCAL static
+#endif
+
+/* index with UUID_VARIANT_xxx and shift 5 bits */
+static unsigned char variant_bits[] = { 0x00, 0x04, 0x06, 0x07 };
+
+#ifdef _WIN32
+static void gettimeofday (struct timeval *tv, void *dummy)
+{
+       FILETIME        ftime;
+       uint64_t        n;
+
+       GetSystemTimeAsFileTime (&ftime);
+       n = (((uint64_t) ftime.dwHighDateTime << 32)
+            + (uint64_t) ftime.dwLowDateTime);
+       if (n) {
+               n /= 10;
+               n -= ((369 * 365 + 89) * (uint64_t) 86400) * 1000000;
+       }
+
+       tv->tv_sec = n / 1000000;
+       tv->tv_usec = n % 1000000;
+}
+
+static int getuid (void)
+{
+       return 1;
+}
+#endif
+
+/*
+ * Get the ethernet hardware address, if we can find it...
+ *
+ * XXX for a windows version, probably should use GetAdaptersInfo:
+ * http://www.codeguru.com/cpp/i-n/network/networkinformation/article.php/c5451
+ * commenting out get_node_id just to get gen_uuid to compile under windows
+ * is not the right way to go!
+ */
+static int get_node_id(unsigned char *node_id)
+{
+#ifdef HAVE_NET_IF_H
+       int             sd;
+       struct ifreq    ifr, *ifrp;
+       struct ifconf   ifc;
+       char buf[1024];
+       int             n, i;
+       unsigned char   *a;
+#ifdef HAVE_NET_IF_DL_H
+       struct sockaddr_dl *sdlp;
+#endif
+
+/*
+ * BSD 4.4 defines the size of an ifreq to be
+ * max(sizeof(ifreq), sizeof(ifreq.ifr_name)+ifreq.ifr_addr.sa_len
+ * However, under earlier systems, sa_len isn't present, so the size is
+ * just sizeof(struct ifreq)
+ */
+#ifdef HAVE_SA_LEN
+#define ifreq_size(i) max(sizeof(struct ifreq),\
+     sizeof((i).ifr_name)+(i).ifr_addr.sa_len)
+#else
+#define ifreq_size(i) sizeof(struct ifreq)
+#endif /* HAVE_SA_LEN */
+
+       sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
+       if (sd < 0) {
+               return -1;
+       }
+       memset(buf, 0, sizeof(buf));
+       ifc.ifc_len = sizeof(buf);
+       ifc.ifc_buf = buf;
+       if (ioctl (sd, SIOCGIFCONF, (char *)&ifc) < 0) {
+               close(sd);
+               return -1;
+       }
+       n = ifc.ifc_len;
+       for (i = 0; i < n; i+= ifreq_size(*ifrp) ) {
+               ifrp = (struct ifreq *)((char *) ifc.ifc_buf+i);
+               strncpy(ifr.ifr_name, ifrp->ifr_name, IFNAMSIZ);
+#ifdef SIOCGIFHWADDR
+               if (ioctl(sd, SIOCGIFHWADDR, &ifr) < 0)
+                       continue;
+               a = (unsigned char *) &ifr.ifr_hwaddr.sa_data;
+#else
+#ifdef SIOCGENADDR
+               if (ioctl(sd, SIOCGENADDR, &ifr) < 0)
+                       continue;
+               a = (unsigned char *) ifr.ifr_enaddr;
+#else
+#ifdef HAVE_NET_IF_DL_H
+               sdlp = (struct sockaddr_dl *) &ifrp->ifr_addr;
+               if ((sdlp->sdl_family != AF_LINK) || (sdlp->sdl_alen != 6))
+                       continue;



Home | Main Index | Thread Index | Old Index