summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/libuucp
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1995-10-18 08:53:40 +0000
commitd6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch)
treeece253b876159b39c620e62b6c9b1174642e070e /gnu/libexec/uucp/libuucp
initial import of NetBSD tree
Diffstat (limited to 'gnu/libexec/uucp/libuucp')
-rw-r--r--gnu/libexec/uucp/libuucp/MANIFEST28
-rw-r--r--gnu/libexec/uucp/libuucp/Makefile15
-rw-r--r--gnu/libexec/uucp/libuucp/bsrch.c54
-rw-r--r--gnu/libexec/uucp/libuucp/buffer.c127
-rw-r--r--gnu/libexec/uucp/libuucp/bzero.c15
-rw-r--r--gnu/libexec/uucp/libuucp/crc.c112
-rw-r--r--gnu/libexec/uucp/libuucp/debug.c173
-rw-r--r--gnu/libexec/uucp/libuucp/escape.c98
-rw-r--r--gnu/libexec/uucp/libuucp/getlin.c81
-rw-r--r--gnu/libexec/uucp/libuucp/getop1.c144
-rw-r--r--gnu/libexec/uucp/libuucp/getopt.c621
-rw-r--r--gnu/libexec/uucp/libuucp/memchr.c149
-rw-r--r--gnu/libexec/uucp/libuucp/memcmp.c19
-rw-r--r--gnu/libexec/uucp/libuucp/memcpy.c18
-rw-r--r--gnu/libexec/uucp/libuucp/parse.c219
-rw-r--r--gnu/libexec/uucp/libuucp/spool.c30
-rw-r--r--gnu/libexec/uucp/libuucp/status.c38
-rw-r--r--gnu/libexec/uucp/libuucp/strcas.c33
-rw-r--r--gnu/libexec/uucp/libuucp/strchr.c16
-rw-r--r--gnu/libexec/uucp/libuucp/strdup.c18
-rw-r--r--gnu/libexec/uucp/libuucp/strncs.c39
-rw-r--r--gnu/libexec/uucp/libuucp/strrch.c24
-rw-r--r--gnu/libexec/uucp/libuucp/strstr.c55
-rw-r--r--gnu/libexec/uucp/libuucp/strtol.c175
-rw-r--r--gnu/libexec/uucp/libuucp/strtou.c21
-rw-r--r--gnu/libexec/uucp/libuucp/xfree.c15
-rw-r--r--gnu/libexec/uucp/libuucp/xmall.c18
-rw-r--r--gnu/libexec/uucp/libuucp/xreall.c23
28 files changed, 2378 insertions, 0 deletions
diff --git a/gnu/libexec/uucp/libuucp/MANIFEST b/gnu/libexec/uucp/libuucp/MANIFEST
new file mode 100644
index 00000000000..4fe9c3b318e
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/MANIFEST
@@ -0,0 +1,28 @@
+Makefile.in
+MANIFEST
+bsrch.c
+buffer.c
+bzero.c
+crc.c
+debug.c
+escape.c
+getlin.c
+getopt.c
+getop1.c
+memchr.c
+memcmp.c
+memcpy.c
+parse.c
+spool.c
+status.c
+strcas.c
+strchr.c
+strdup.c
+strncs.c
+strrch.c
+strstr.c
+strtol.c
+strtou.c
+xfree.c
+xmall.c
+xreall.c
diff --git a/gnu/libexec/uucp/libuucp/Makefile b/gnu/libexec/uucp/libuucp/Makefile
new file mode 100644
index 00000000000..bef1f4925ca
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/Makefile
@@ -0,0 +1,15 @@
+# This is the Makefile for the libuucp subdirectory of Taylor UUCP
+# $Id: Makefile,v 1.1 1995/10/18 08:38:38 deraadt Exp $
+
+LIB= uucp
+SRCS= buffer.c crc.c debug.c escape.c getopt.c getop1.c parse.c \
+ spool.c status.c xfree.c xmall.c xreall.c getlin.c
+CFLAGS+= -I$(.CURDIR)/../common_sources
+
+NOMAN= noman
+NOPROFILE= noprofile
+NOPIC= nopic
+
+install:
+
+.include <bsd.lib.mk>
diff --git a/gnu/libexec/uucp/libuucp/bsrch.c b/gnu/libexec/uucp/libuucp/bsrch.c
new file mode 100644
index 00000000000..58b8710cbf6
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/bsrch.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place -
+Suite 330, Boston, MA 02111-1307, USA.
+
+This file was modified slightly by Ian Lance Taylor, May 1992, for
+Taylor UUCP. */
+
+#include "uucp.h"
+
+/* Perform a binary search for KEY in BASE which has NMEMB elements
+ of SIZE bytes each. The comparisons are done by (*COMPAR)(). */
+pointer
+bsearch (key, base, nmemb, size, compar)
+ register constpointer key;
+ register constpointer base;
+ size_t nmemb;
+ register size_t size;
+ register int (*compar) P((constpointer, constpointer));
+{
+ register size_t l, u, idx;
+ register constpointer p;
+ register int comparison;
+
+ l = 0;
+ u = nmemb;
+ while (l < u)
+ {
+ idx = (l + u) / 2;
+ p = (constpointer) (((const char *) base) + (idx * size));
+ comparison = (*compar)(key, p);
+ if (comparison < 0)
+ u = idx;
+ else if (comparison > 0)
+ l = idx + 1;
+ else
+ return (pointer) p;
+ }
+
+ return NULL;
+}
diff --git a/gnu/libexec/uucp/libuucp/buffer.c b/gnu/libexec/uucp/libuucp/buffer.c
new file mode 100644
index 00000000000..e33b282aea0
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/buffer.c
@@ -0,0 +1,127 @@
+/* buffer.c
+ Manipulate buffers used to hold strings.
+
+ Copyright (C) 1992, 1993 Ian Lance Taylor
+
+ This file is part of Taylor UUCP.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License
+ as published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The author of the program may be contacted at ian@airs.com or
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
+ */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+
+/* We keep a linked list of buffers. The union is a hack because the
+ default definition of offsetof, in uucp.h, takes the address of the
+ field, and some C compilers will not let you take the address of an
+ array. */
+
+struct sbuf
+{
+ struct sbuf *qnext;
+ size_t c;
+ union
+ {
+ char ab[4];
+ char bdummy;
+ }
+ u;
+};
+
+static struct sbuf *qBlist;
+
+/* Get a buffer of a given size. The buffer is returned with the
+ ubuffree function. */
+
+char *
+zbufalc (c)
+ size_t c;
+{
+ register struct sbuf *q;
+
+ if (qBlist == NULL)
+ {
+ q = (struct sbuf *) xmalloc (sizeof (struct sbuf) + c - 4);
+ q->c = c;
+ }
+ else
+ {
+ q = qBlist;
+ qBlist = q->qnext;
+ if (q->c < c)
+ {
+ q = (struct sbuf *) xrealloc ((pointer) q,
+ sizeof (struct sbuf) + c - 4);
+ q->c = c;
+ }
+ }
+ return q->u.ab;
+}
+
+/* Get a buffer holding a given string. */
+
+char *
+zbufcpy (z)
+ const char *z;
+{
+ size_t csize;
+ char *zret;
+
+ if (z == NULL)
+ return NULL;
+ csize = strlen (z) + 1;
+ zret = zbufalc (csize);
+ memcpy (zret, z, csize);
+ return zret;
+}
+
+/* Free up a buffer back onto the linked list. */
+
+void
+ubuffree (z)
+ char *z;
+{
+ struct sbuf *q;
+ /* The type of ioff should be size_t, but making it int avoids a bug
+ in some versions of the HP/UX compiler, and will always work. */
+ int ioff;
+
+ if (z == NULL)
+ return;
+ ioff = offsetof (struct sbuf, u);
+ q = (struct sbuf *) (pointer) (z - ioff);
+
+#ifdef DEBUG_BUFFER
+ {
+ struct sbuf *qlook;
+
+ for (qlook = qBlist; qlook != NULL; qlook = qlook->qnext)
+ {
+ if (qlook == q)
+ {
+ ulog (LOG_ERROR, "ubuffree: Attempt to free buffer twice");
+ abort ();
+ }
+ }
+ }
+#endif
+
+ q->qnext = qBlist;
+ qBlist = q;
+}
diff --git a/gnu/libexec/uucp/libuucp/bzero.c b/gnu/libexec/uucp/libuucp/bzero.c
new file mode 100644
index 00000000000..098e5515728
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/bzero.c
@@ -0,0 +1,15 @@
+/* bzero.c
+ Zero out a buffer. */
+
+#include "uucp.h"
+
+void
+bzero (parg, c)
+ pointer parg;
+ int c;
+{
+ char *p = (char *) parg;
+
+ while (c-- != 0)
+ *p++ = 0;
+}
diff --git a/gnu/libexec/uucp/libuucp/crc.c b/gnu/libexec/uucp/libuucp/crc.c
new file mode 100644
index 00000000000..fc9687b57cf
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/crc.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 1986 Gary S. Brown. You may use this program, or
+ * code or tables extracted from it, as desired without restriction.
+ */
+
+/* Modified slightly by Ian Lance Taylor, ian@airs.com, for use with
+ Taylor UUCP. */
+
+#include "uucp.h"
+#include "prot.h"
+
+/* First, the polynomial itself and its table of feedback terms. The */
+/* polynomial is */
+/* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0 */
+/* Note that we take it "backwards" and put the highest-order term in */
+/* the lowest-order bit. The X^32 term is "implied"; the LSB is the */
+/* X^31 term, etc. The X^0 term (usually shown as "+1") results in */
+/* the MSB being 1. */
+
+/* Note that the usual hardware shift register implementation, which */
+/* is what we're using (we're merely optimizing it by doing eight-bit */
+/* chunks at a time) shifts bits into the lowest-order term. In our */
+/* implementation, that means shifting towards the right. Why do we */
+/* do it this way? Because the calculated CRC must be transmitted in */
+/* order from highest-order term to lowest-order term. UARTs transmit */
+/* characters in order from LSB to MSB. By storing the CRC this way, */
+/* we hand it to the UART in the order low-byte to high-byte; the UART */
+/* sends each low-bit to hight-bit; and the result is transmission bit */
+/* by bit from highest- to lowest-order term without requiring any bit */
+/* shuffling on our part. Reception works similarly. */
+
+/* The feedback terms table consists of 256, 32-bit entries. Notes: */
+/* */
+/* The table can be generated at runtime if desired; code to do so */
+/* is shown later. It might not be obvious, but the feedback */
+/* terms simply represent the results of eight shift/xor opera- */
+/* tions for all combinations of data and CRC register values. */
+/* [this code is no longer present--ian] */
+/* */
+/* The values must be right-shifted by eight bits by the "updcrc" */
+/* logic; the shift must be unsigned (bring in zeroes). On some */
+/* hardware you could probably optimize the shift in assembler by */
+/* using byte-swap instructions. */
+
+static const unsigned long aicrc32tab[] = { /* CRC polynomial 0xedb88320 */
+0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
+0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L, 0x90bf1d91L,
+0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL, 0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L,
+0x136c9856L, 0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L, 0xfa0f3d63L, 0x8d080df5L,
+0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L, 0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
+0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L, 0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L,
+0x26d930acL, 0x51de003aL, 0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L, 0xb8bda50fL,
+0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L, 0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL,
+0x76dc4190L, 0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL, 0x9fbfe4a5L, 0xe8b8d433L,
+0x7807c9a2L, 0x0f00f934L, 0x9609a88eL, 0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
+0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL, 0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L,
+0x65b0d9c6L, 0x12b7e950L, 0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L, 0xfbd44c65L,
+0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L, 0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL,
+0x4369e96aL, 0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L, 0xaa0a4c5fL, 0xdd0d7cc9L,
+0x5005713cL, 0x270241aaL, 0xbe0b1010L, 0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
+0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L, 0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL,
+0xedb88320L, 0x9abfb3b6L, 0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L, 0x73dc1683L,
+0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L, 0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L,
+0xf00f9344L, 0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL, 0x196c3671L, 0x6e6b06e7L,
+0xfed41b76L, 0x89d32be0L, 0x10da7a5aL, 0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
+0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L, 0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL,
+0xd80d2bdaL, 0xaf0a1b4cL, 0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL, 0x4669be79L,
+0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L, 0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL,
+0xc5ba3bbeL, 0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L, 0x2cd99e8bL, 0x5bdeae1dL,
+0x9b64c2b0L, 0xec63f226L, 0x756aa39cL, 0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
+0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL, 0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L,
+0x86d3d2d4L, 0xf1d4e242L, 0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L, 0x18b74777L,
+0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL, 0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L,
+0xa00ae278L, 0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L, 0x4969474dL, 0x3e6e77dbL,
+0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L, 0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
+0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L, 0xcdd70693L, 0x54de5729L, 0x23d967bfL,
+0xb3667a2eL, 0xc4614ab8L, 0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL, 0x2d02ef8dL
+};
+
+/*
+ * IUPDC32 macro derived from article Copyright (C) 1986 Stephen Satchell.
+ * NOTE: First argument must be in range 0 to 255.
+ * Second argument is referenced twice.
+ *
+ * Programmers may incorporate any or all code into their programs,
+ * giving proper credit within the source. Publication of the
+ * source routines is permitted so long as proper credit is given
+ * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg,
+ * Omen Technology.
+ */
+
+#define IUPDC32(b, ick) \
+ (aicrc32tab[((int) (ick) ^ (b)) & 0xff] ^ (((ick) >> 8) & 0x00ffffffL))
+
+unsigned long
+icrc (z, c, ick)
+ const char *z;
+ size_t c;
+ unsigned long ick;
+{
+ while (c > 4)
+ {
+ ick = IUPDC32 (*z++, ick);
+ ick = IUPDC32 (*z++, ick);
+ ick = IUPDC32 (*z++, ick);
+ ick = IUPDC32 (*z++, ick);
+ c -= 4;
+ }
+ while (c-- != 0)
+ ick = IUPDC32 (*z++, ick);
+ return ick;
+}
diff --git a/gnu/libexec/uucp/libuucp/debug.c b/gnu/libexec/uucp/libuucp/debug.c
new file mode 100644
index 00000000000..6ae30632ad0
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/debug.c
@@ -0,0 +1,173 @@
+/* debug.c
+ UUCP debugging functions.
+
+ Copyright (C) 1991, 1992 Ian Lance Taylor
+
+ This file is part of the Taylor UUCP package.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The author of the program may be contacted at ian@airs.com or
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
+ */
+
+#include "uucp.h"
+
+#include <ctype.h>
+
+#include "uudefs.h"
+
+#if DEBUG > 1
+
+/* The debugging level. */
+int iDebug;
+
+/* Parse a debugging string. This may be a simple number, which sets
+ the given number of bits in iDebug, or it may be a series of single
+ letters. */
+
+static const char * const azDebug_names[] = DEBUG_NAMES;
+
+int
+idebug_parse (z)
+ const char *z;
+{
+ char *zend;
+ int i, iret;
+ char *zcopy, *ztok;
+
+ if (strncasecmp (z, DEBUG_NONE, sizeof DEBUG_NONE - 1) == 0)
+ return 0;
+
+ i = (int) strtol ((char *) z, &zend, 0);
+ if (*zend == '\0')
+ {
+ if (i > 15)
+ i = 15;
+ else if (i < 0)
+ i = 0;
+ return (1 << i) - 1;
+ }
+
+ zcopy = zbufcpy (z);
+
+ iret = 0;
+
+ for (ztok = strtok (zcopy, ", \t");
+ ztok != NULL;
+ ztok = strtok ((char *) NULL, ", \t"))
+ {
+ if (strcasecmp (ztok, "all") == 0)
+ {
+ iret = DEBUG_MAX;
+ break;
+ }
+ for (i = 0; azDebug_names[i] != NULL; i++)
+ {
+ if (strncasecmp (ztok, azDebug_names[i],
+ strlen (azDebug_names[i])) == 0)
+ {
+ iret |= 1 << i;
+ break;
+ }
+ }
+ if (azDebug_names[i] == NULL)
+ ulog (LOG_ERROR, "Unrecognized debugging option \"%s\"",
+ ztok);
+ }
+
+ ubuffree (zcopy);
+
+ return iret;
+}
+
+#endif /* DEBUG > 1 */
+
+/* A debugging routine used when displaying buffers. */
+
+size_t
+cdebug_char (z, ichar)
+ char *z;
+ int ichar;
+{
+ char b;
+
+ if (isprint (BUCHAR (ichar))
+ && ichar != '\"'
+ && ichar != '\\')
+ {
+ *z++ = (char) ichar;
+ *z = '\0';
+ return 1;
+ }
+
+ *z++ = '\\';
+
+ switch (ichar)
+ {
+ case '\n':
+ b = 'n';
+ break;
+ case '\r':
+ b = 'r';
+ break;
+ case '\"':
+ b = '\"';
+ break;
+ case '\\':
+ b = '\\';
+ break;
+ default:
+ sprintf (z, "%03o", (unsigned int) BUCHAR (ichar));
+ return strlen (z) + 1;
+ }
+
+ *z++ = b;
+ *z = '\0';
+ return 2;
+}
+
+#if DEBUG > 1
+
+/* Display a buffer when debugging. */
+
+void
+udebug_buffer (zhdr, zbuf, clen)
+ const char *zhdr;
+ const char *zbuf;
+ size_t clen;
+{
+ char *z, *zalc;
+ int i;
+
+ zalc = zbufalc (clen * 4 + 1);
+
+ z = zalc;
+ for (i = 0; i < clen && i < 80; i++)
+ z += cdebug_char (z, zbuf[i]);
+ if (i < clen)
+ {
+ *z++ = '.';
+ *z++ = '.';
+ *z++ = '.';
+ }
+ *z = '\0';
+
+ ulog (LOG_DEBUG, "%s %lu \"%s\"", zhdr, (unsigned long) clen, zalc);
+
+ ubuffree (zalc);
+}
+
+#endif
diff --git a/gnu/libexec/uucp/libuucp/escape.c b/gnu/libexec/uucp/libuucp/escape.c
new file mode 100644
index 00000000000..646b787d6e4
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/escape.c
@@ -0,0 +1,98 @@
+/* escape.c
+ Translate escape sequences. */
+
+#include "uucp.h"
+
+#include <ctype.h>
+
+#include "uudefs.h"
+
+size_t
+cescape (z)
+ char *z;
+{
+ char *zto, *zfrom;
+
+ zto = z;
+ zfrom = z;
+ while (*zfrom != '\0')
+ {
+ if (*zfrom != '\\')
+ {
+ *zto++ = *zfrom++;
+ continue;
+ }
+ ++zfrom;
+ switch (*zfrom)
+ {
+ case '-':
+ *zto++ = '-';
+ break;
+ case 'b':
+ *zto++ = '\b';
+ break;
+ case 'n':
+ *zto++ = '\n';
+ break;
+ case 'N':
+ *zto++ = '\0';
+ break;
+ case 'r':
+ *zto++ = '\r';
+ break;
+ case 's':
+ *zto++ = ' ';
+ break;
+ case 't':
+ *zto++ = '\t';
+ break;
+ case '\0':
+ --zfrom;
+ /* Fall through. */
+ case '\\':
+ *zto++ = '\\';
+ break;
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ {
+ int i;
+
+ i = *zfrom - '0';
+ if (zfrom[1] >= '0' && zfrom[1] <= '7')
+ i = 8 * i + *++zfrom - '0';
+ if (zfrom[1] >= '0' && zfrom[1] <= '7')
+ i = 8 * i + *++zfrom - '0';
+ *zto++ = (char) i;
+ }
+ break;
+ case 'x':
+ {
+ int i;
+
+ i = 0;
+ while (isxdigit (BUCHAR (zfrom[1])))
+ {
+ if (isdigit (BUCHAR (zfrom[1])))
+ i = 16 * i + *++zfrom - '0';
+ else if (isupper (BUCHAR (zfrom[1])))
+ i = 16 * i + *++zfrom - 'A' + 10;
+ else
+ i = 16 * i + *++zfrom - 'a' + 10;
+ }
+ *zto++ = (char) i;
+ }
+ break;
+ default:
+ ulog (LOG_ERROR, "Unrecognized escape sequence \\%c",
+ *zfrom);
+ *zto++ = *zfrom;
+ break;
+ }
+
+ ++zfrom;
+ }
+
+ *zto = '\0';
+
+ return (size_t) (zto - z);
+}
diff --git a/gnu/libexec/uucp/libuucp/getlin.c b/gnu/libexec/uucp/libuucp/getlin.c
new file mode 100644
index 00000000000..822bc1c851c
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/getlin.c
@@ -0,0 +1,81 @@
+/* getlin.c
+ Replacement for getline.
+
+ Copyright (C) 1992 Ian Lance Taylor
+
+ This file is part of Taylor UUCP.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License
+ as published by the Free Software Foundation; either version 2 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The author of the program may be contacted at ian@airs.com or
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
+ */
+
+#include "uucp.h"
+
+/* Read a line from a file, returning the number of characters read.
+ This should really return ssize_t. Returns -1 on error. */
+
+#define CGETLINE_DEFAULT (63)
+
+int
+getline (pzline, pcline, e)
+ char **pzline;
+ size_t *pcline;
+ FILE *e;
+{
+ char *zput, *zend;
+ int bchar;
+
+ if (*pzline == NULL)
+ {
+ *pzline = (char *) malloc (CGETLINE_DEFAULT);
+ if (*pzline == NULL)
+ return -1;
+ *pcline = CGETLINE_DEFAULT;
+ }
+
+ zput = *pzline;
+ zend = *pzline + *pcline - 1;
+
+ while ((bchar = getc (e)) != EOF)
+ {
+ if (zput >= zend)
+ {
+ size_t cnew;
+ char *znew;
+
+ cnew = *pcline * 2 + 1;
+ znew = (char *) realloc ((pointer) *pzline, cnew);
+ if (znew == NULL)
+ return -1;
+ zput = znew + *pcline - 1;
+ zend = znew + cnew - 1;
+ *pzline = znew;
+ *pcline = cnew;
+ }
+
+ *zput++ = bchar;
+
+ if (bchar == '\n')
+ break;
+ }
+
+ if (zput == *pzline)
+ return -1;
+
+ *zput = '\0';
+ return zput - *pzline;
+}
diff --git a/gnu/libexec/uucp/libuucp/getop1.c b/gnu/libexec/uucp/libuucp/getop1.c
new file mode 100644
index 00000000000..c7c73837776
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/getop1.c
@@ -0,0 +1,144 @@
+/* Getopt for GNU.
+ Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ This file was modified slightly by Ian Lance Taylor, June 1992, for
+ Taylor UUCP. */
+
+#include "uucp.h"
+
+#include "getopt.h"
+
+int
+getopt_long (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
+}
+
+/* Like getopt_long, but '-' as well as '--' can indicate a long option.
+ If an option that starts with '-' (not '--') doesn't match a long option,
+ but does match a short option, it is parsed as a short option
+ instead. */
+
+int
+getopt_long_only (argc, argv, options, long_options, opt_index)
+ int argc;
+ char *const *argv;
+ const char *options;
+ const struct option *long_options;
+ int *opt_index;
+{
+ return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
+}
+
+#ifdef TEST
+
+#include <stdio.h>
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] =
+ {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == EOF)
+ break;
+
+ switch (c)
+ {
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/gnu/libexec/uucp/libuucp/getopt.c b/gnu/libexec/uucp/libuucp/getopt.c
new file mode 100644
index 00000000000..eed7d8e5b8a
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/getopt.c
@@ -0,0 +1,621 @@
+/* Getopt for GNU.
+ NOTE: getopt is now part of the C library, so if you don't know what
+ "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
+ before changing it!
+
+ Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ This file was modified slightly by Ian Lance Taylor, June 1992, for
+ Taylor UUCP. */
+
+#include "uucp.h"
+#include "uudefs.h"
+
+/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a
+ long-named option. Because this is not POSIX.2 compliant, it is
+ being phased out. */
+#undef GETOPT_COMPAT
+
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+ but it behaves differently for the user, since it allows the user
+ to intersperse the options with the other arguments.
+
+ As `getopt' works, it permutes the elements of ARGV so that,
+ when it is done, all the options precede everything else. Thus
+ all application programs are extended to handle flexible argument order.
+
+ Setting the environment variable POSIXLY_CORRECT disables permutation.
+ Then the behavior is completely standard.
+
+ GNU application programs can use a third alternative mode in which
+ they can distinguish the relative order of options and other arguments. */
+
+#include "getopt.h"
+
+/* For communication from `getopt' to the caller.
+ When `getopt' finds an option that takes an argument,
+ the argument value is returned here.
+ Also, when `ordering' is RETURN_IN_ORDER,
+ each non-option ARGV-element is returned here. */
+
+char *optarg = 0;
+
+/* Index in ARGV of the next element to be scanned.
+ This is used for communication to and from the caller
+ and for communication between successive calls to `getopt'.
+
+ On entry to `getopt', zero means this is the first call; initialize.
+
+ When `getopt' returns EOF, this is the index of the first of the
+ non-option elements that the caller should itself scan.
+
+ Otherwise, `optind' communicates from one call to the next
+ how much of ARGV has been scanned so far. */
+
+int optind = 0;
+
+/* The next char to be scanned in the option-element
+ in which the last option character we returned was found.
+ This allows us to pick up the scan where we left off.
+
+ If this is zero, or a null string, it means resume the scan
+ by advancing to the next ARGV-element. */
+
+static char *nextchar;
+
+/* Callers store zero here to inhibit the error message
+ for unrecognized options. */
+
+int opterr = 1;
+
+/* Describe how to deal with options that follow non-option ARGV-elements.
+
+ If the caller did not specify anything,
+ the default is REQUIRE_ORDER if the environment variable
+ POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+ REQUIRE_ORDER means don't recognize them as options;
+ stop option processing when the first non-option is seen.
+ This is what Unix does.
+ This mode of operation is selected by either setting the environment
+ variable POSIXLY_CORRECT, or using `+' as the first character
+ of the list of option characters.
+
+ PERMUTE is the default. We permute the contents of ARGV as we scan,
+ so that eventually all the non-options are at the end. This allows options
+ to be given in any order, even with programs that were not written to
+ expect this.
+
+ RETURN_IN_ORDER is an option available to programs that were written
+ to expect options and other ARGV-elements in any order and that care about
+ the ordering of the two. We describe each non-option ARGV-element
+ as if it were the argument of an option with character code 1.
+ Using `-' as the first character of the list of option characters
+ selects this mode of operation.
+
+ The special argument `--' forces an end of option-scanning regardless
+ of the value of `ordering'. In the case of RETURN_IN_ORDER, only
+ `--' can cause `getopt' to return EOF with `optind' != ARGC. */
+
+static enum
+{
+ REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
+} ordering;
+
+#define my_index strchr
+#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n))
+
+/* Handle permutation of arguments. */
+
+/* Describe the part of ARGV that contains non-options that have
+ been skipped. `first_nonopt' is the index in ARGV of the first of them;
+ `last_nonopt' is the index after the last of them. */
+
+static int first_nonopt;
+static int last_nonopt;
+
+/* Exchange two adjacent subsequences of ARGV.
+ One subsequence is elements [first_nonopt,last_nonopt)
+ which contains all the non-options that have been skipped so far.
+ The other is elements [last_nonopt,optind), which contains all
+ the options processed since those non-options were skipped.
+
+ `first_nonopt' and `last_nonopt' are relocated so that they describe
+ the new indices of the non-options in ARGV after they are moved. */
+
+static void
+exchange (argv)
+ char **argv;
+{
+ size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *);
+ char **temp = (char **) malloc (nonopts_size);
+
+ if (temp == NULL)
+ abort ();
+
+ /* Interchange the two blocks of data in ARGV. */
+
+ my_bcopy ((char *) &argv[first_nonopt], (char *) temp, nonopts_size);
+ my_bcopy ((char *) &argv[last_nonopt], (char *) &argv[first_nonopt],
+ (optind - last_nonopt) * sizeof (char *));
+ my_bcopy ((char *) temp,
+ (char *) &argv[first_nonopt + optind - last_nonopt],
+ nonopts_size);
+
+ xfree (temp);
+
+ /* Update records for the slots the non-options now occupy. */
+
+ first_nonopt += (optind - last_nonopt);
+ last_nonopt = optind;
+}
+
+/* Scan elements of ARGV (whose length is ARGC) for option characters
+ given in OPTSTRING.
+
+ If an element of ARGV starts with '-', and is not exactly "-" or "--",
+ then it is an option element. The characters of this element
+ (aside from the initial '-') are option characters. If `getopt'
+ is called repeatedly, it returns successively each of the option characters
+ from each of the option elements.
+
+ If `getopt' finds another option character, it returns that character,
+ updating `optind' and `nextchar' so that the next call to `getopt' can
+ resume the scan with the following option character or ARGV-element.
+
+ If there are no more option characters, `getopt' returns `EOF'.
+ Then `optind' is the index in ARGV of the first ARGV-element
+ that is not an option. (The ARGV-elements have been permuted
+ so that those that are not options now come last.)
+
+ OPTSTRING is a string containing the legitimate option characters.
+ If an option character is seen that is not listed in OPTSTRING,
+ return '?' after printing an error message. If you set `opterr' to
+ zero, the error message is suppressed but we still return '?'.
+
+ If a char in OPTSTRING is followed by a colon, that means it wants an arg,
+ so the following text in the same ARGV-element, or the text of the following
+ ARGV-element, is returned in `optarg'. Two colons mean an option that
+ wants an optional arg; if there is text in the current ARGV-element,
+ it is returned in `optarg', otherwise `optarg' is set to zero.
+
+ If OPTSTRING starts with `-' or `+', it requests different methods of
+ handling the non-option ARGV-elements.
+ See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
+
+ Long-named options begin with `--' instead of `-'.
+ Their names may be abbreviated as long as the abbreviation is unique
+ or is an exact match for some defined option. If they have an
+ argument, it follows the option name in the same ARGV-element, separated
+ from the option name by a `=', or else the in next ARGV-element.
+ When `getopt' finds a long-named option, it returns 0 if that option's
+ `flag' field is nonzero, the value of the option's `val' field
+ if the `flag' field is zero.
+
+ The elements of ARGV aren't really const, because we permute them.
+ But we pretend they're const in the prototype to be compatible
+ with other systems.
+
+ LONGOPTS is a vector of `struct option' terminated by an
+ element containing a name which is zero.
+
+ LONGIND returns the index in LONGOPT of the long-named option found.
+ It is only valid when a long-named option has been found by the most
+ recent call.
+
+ If LONG_ONLY is nonzero, '-' as well as '--' can introduce
+ long-named options. */
+
+int
+_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+ const struct option *longopts;
+ int *longind;
+ int long_only;
+{
+ int option_index;
+
+ optarg = 0;
+
+ /* Initialize the internal data when the first call is made.
+ Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+ non-option ARGV-elements is empty. */
+
+ if (optind == 0)
+ {
+ first_nonopt = last_nonopt = optind = 1;
+
+ nextchar = NULL;
+
+ /* Determine how to handle the ordering of options and nonoptions. */
+
+ if (optstring[0] == '-')
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
+ else if (optstring[0] == '+')
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
+ else if (getenv ("POSIXLY_CORRECT") != NULL)
+ ordering = REQUIRE_ORDER;
+ else
+ ordering = PERMUTE;
+ }
+
+ if (nextchar == NULL || *nextchar == '\0')
+ {
+ if (ordering == PERMUTE)
+ {
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /* Now skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (optind < argc
+ && (argv[optind][0] != '-' || argv[optind][1] == '\0')
+#ifdef GETOPT_COMPAT
+ && (longopts == NULL
+ || argv[optind][0] != '+' || argv[optind][1] == '\0')
+#endif /* GETOPT_COMPAT */
+ )
+ optind++;
+ last_nonopt = optind;
+ }
+
+ /* Special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if (optind != argc && !strcmp (argv[optind], "--"))
+ {
+ optind++;
+
+ if (first_nonopt != last_nonopt && last_nonopt != optind)
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return EOF;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if ((argv[optind][0] != '-' || argv[optind][1] == '\0')
+#ifdef GETOPT_COMPAT
+ && (longopts == NULL
+ || argv[optind][0] != '+' || argv[optind][1] == '\0')
+#endif /* GETOPT_COMPAT */
+ )
+ {
+ if (ordering == REQUIRE_ORDER)
+ return EOF;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Start decoding its characters. */
+
+ nextchar = (argv[optind] + 1
+ + (longopts != NULL && argv[optind][1] == '-'));
+ }
+
+ if (longopts != NULL
+ && ((argv[optind][0] == '-'
+ && (argv[optind][1] == '-' || long_only))
+#ifdef GETOPT_COMPAT
+ || argv[optind][0] == '+'
+#endif /* GETOPT_COMPAT */
+ ))
+ {
+ const struct option *p;
+ char *s = nextchar;
+ int exact = 0;
+ int ambig = 0;
+ const struct option *pfound = NULL;
+ int indfound = 0;
+
+ while (*s && *s != '=')
+ s++;
+
+ /* Test all options for either exact match or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name;
+ p++, option_index++)
+ if (!strncmp (p->name, nextchar, (size_t) (s - nextchar)))
+ {
+ if (s - nextchar == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second nonexact match found. */
+ ambig = 1;
+ }
+
+ if (ambig && !exact)
+ {
+ if (opterr)
+ fprintf (stderr, "%s: option `%s' is ambiguous\n",
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ return '?';
+ }
+
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*s)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = s + 1;
+ else
+ {
+ if (opterr)
+ {
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ "%s: option `--%s' doesn't allow an argument\n",
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ "%s: option `%c%s' doesn't allow an argument\n",
+ argv[0], argv[optind - 1][0], pfound->name);
+ }
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr, "%s: option `%s' requires an argument\n",
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (!long_only || argv[optind][1] == '-'
+#ifdef GETOPT_COMPAT
+ || argv[optind][0] == '+'
+#endif /* GETOPT_COMPAT */
+ || my_index (optstring, *nextchar) == NULL)
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /* --option */
+ fprintf (stderr, "%s: unrecognized option `--%s'\n",
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, "%s: unrecognized option `%c%s'\n",
+ argv[0], argv[optind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ return '?';
+ }
+ }
+
+ /* Look at and handle the next option-character. */
+
+ {
+ char c = *nextchar++;
+ char *temp = my_index (optstring, c);
+
+ /* Increment `optind' when we start to process its last character. */
+ if (*nextchar == '\0')
+ ++optind;
+
+ if (temp == NULL || c == ':')
+ {
+ if (opterr)
+ {
+ if (c < 040 || c >= 0177)
+ fprintf (stderr, "%s: unrecognized option, character code 0%o\n",
+ argv[0], BUCHAR (c));
+ else
+ fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c);
+ }
+ return '?';
+ }
+ if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = 0;
+ nextchar = NULL;
+ }
+ else
+ {
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ fprintf (stderr, "%s: option `-%c' requires an argument\n",
+ argv[0], c);
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+ nextchar = NULL;
+ }
+ }
+ return c;
+ }
+}
+
+int
+getopt (argc, argv, optstring)
+ int argc;
+ char *const *argv;
+ const char *optstring;
+{
+ return _getopt_internal (argc, argv, optstring,
+ (const struct option *) 0,
+ (int *) 0,
+ 0);
+}
+
+#ifdef TEST
+
+/* Compile with -DTEST to make an executable for use in testing
+ the above definition of `getopt'. */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ int c;
+ int digit_optind = 0;
+
+ while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == EOF)
+ break;
+
+ switch (c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if (digit_optind != 0 && digit_optind != this_option_optind)
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
+ }
+ }
+
+ if (optind < argc)
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
+
+ exit (0);
+}
+
+#endif /* TEST */
diff --git a/gnu/libexec/uucp/libuucp/memchr.c b/gnu/libexec/uucp/libuucp/memchr.c
new file mode 100644
index 00000000000..c7431542142
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/memchr.c
@@ -0,0 +1,149 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+ Based on strlen implemention by Torbjorn Granlund (tege@sics.se),
+ with help from Dan Sahlin (dan@sics.se) and
+ commentary by Jim Blandy (jimb@ai.mit.edu);
+ adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu),
+ and implemented by Roland McGrath (roland@ai.mit.edu).
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place -
+Suite 330, Boston, MA 02111-1307, USA.
+
+This file was modified slightly by Ian Lance Taylor, May 1992, for
+Taylor UUCP. It assumes 32 bit longs. I'm willing to trust that any
+system which does not have 32 bit longs will have its own
+implementation of memchr. */
+
+#include "uucp.h"
+
+/* Search no more than N bytes of S for C. */
+
+pointer
+memchr (s, c, n)
+ constpointer s;
+ int c;
+ size_t n;
+{
+ const char *char_ptr;
+ const unsigned long int *longword_ptr;
+ unsigned long int longword, magic_bits, charmask;
+
+ c = BUCHAR (c);
+
+ /* Handle the first few characters by reading one character at a time.
+ Do this until CHAR_PTR is aligned on a 4-byte border. */
+ for (char_ptr = s; n > 0 && ((unsigned long int) char_ptr & 3) != 0;
+ --n, ++char_ptr)
+ if (BUCHAR (*char_ptr) == c)
+ return (pointer) char_ptr;
+
+ longword_ptr = (unsigned long int *) char_ptr;
+
+ /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
+ the "holes." Note that there is a hole just to the left of
+ each byte, with an extra at the end:
+
+ bits: 01111110 11111110 11111110 11111111
+ bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
+
+ The 1-bits make sure that carries propagate to the next 0-bit.
+ The 0-bits provide holes for carries to fall into. */
+ magic_bits = 0x7efefeff;
+
+ /* Set up a longword, each of whose bytes is C. */
+ charmask = c | (c << 8);
+ charmask |= charmask << 16;
+
+ /* Instead of the traditional loop which tests each character,
+ we will test a longword at a time. The tricky part is testing
+ if *any of the four* bytes in the longword in question are zero. */
+ while (n >= 4)
+ {
+ /* We tentatively exit the loop if adding MAGIC_BITS to
+ LONGWORD fails to change any of the hole bits of LONGWORD.
+
+ 1) Is this safe? Will it catch all the zero bytes?
+ Suppose there is a byte with all zeros. Any carry bits
+ propagating from its left will fall into the hole at its
+ least significant bit and stop. Since there will be no
+ carry from its most significant bit, the LSB of the
+ byte to the left will be unchanged, and the zero will be
+ detected.
+
+ 2) Is this worthwhile? Will it ignore everything except
+ zero bytes? Suppose every byte of LONGWORD has a bit set
+ somewhere. There will be a carry into bit 8. If bit 8
+ is set, this will carry into bit 16. If bit 8 is clear,
+ one of bits 9-15 must be set, so there will be a carry
+ into bit 16. Similarly, there will be a carry into bit
+ 24. If one of bits 24-30 is set, there will be a carry
+ into bit 31, so all of the hole bits will be changed.
+
+ The one misfire occurs when bits 24-30 are clear and bit
+ 31 is set; in this case, the hole at bit 31 is not
+ changed. If we had access to the processor carry flag,
+ we could close this loophole by putting the fourth hole
+ at bit 32!
+
+ So it ignores everything except 128's, when they're aligned
+ properly.
+
+ 3) But wait! Aren't we looking for C, not zero?
+ Good point. So what we do is XOR LONGWORD with a longword,
+ each of whose bytes is C. This turns each byte that is C
+ into a zero. */
+
+ longword = *longword_ptr++ ^ charmask;
+
+ /* Add MAGIC_BITS to LONGWORD. */
+ if ((((longword + magic_bits)
+
+ /* Set those bits that were unchanged by the addition. */
+ ^ ~longword)
+
+ /* Look at only the hole bits. If any of the hole bits
+ are unchanged, most likely one of the bytes was a
+ zero. */
+ & ~magic_bits) != 0)
+ {
+ /* Which of the bytes was C? If none of them were, it was
+ a misfire; continue the search. */
+
+ const char *cp = (const char *) (longword_ptr - 1);
+
+ if (BUCHAR (cp[0]) == c)
+ return (pointer) cp;
+ if (BUCHAR (cp[1]) == c)
+ return (pointer) &cp[1];
+ if (BUCHAR (cp[2]) == c)
+ return (pointer) &cp[2];
+ if (BUCHAR (cp[3]) == c)
+ return (pointer) &cp[3];
+ }
+
+ n -= 4;
+ }
+
+ char_ptr = (const char *) longword_ptr;
+
+ while (n-- > 0)
+ {
+ if (BUCHAR (*char_ptr) == c)
+ return (pointer) char_ptr;
+ else
+ ++char_ptr;
+ }
+
+ return NULL;
+}
diff --git a/gnu/libexec/uucp/libuucp/memcmp.c b/gnu/libexec/uucp/libuucp/memcmp.c
new file mode 100644
index 00000000000..b61578a4af1
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/memcmp.c
@@ -0,0 +1,19 @@
+/* memcmp.c
+ Compare two memory buffers. */
+
+#include "uucp.h"
+
+int
+memcmp (p1arg, p2arg, c)
+ constpointer p1arg;
+ constpointer p2arg;
+ size_t c;
+{
+ const char *p1 = (const char *) p1arg;
+ const char *p2 = (const char *) p2arg;
+
+ while (c-- != 0)
+ if (*p1++ != *p2++)
+ return BUCHAR (*--p1) - BUCHAR (*--p2);
+ return 0;
+}
diff --git a/gnu/libexec/uucp/libuucp/memcpy.c b/gnu/libexec/uucp/libuucp/memcpy.c
new file mode 100644
index 00000000000..2258123752a
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/memcpy.c
@@ -0,0 +1,18 @@
+/* memcpy.c
+ Copy one memory buffer to another. */
+
+#include "uucp.h"
+
+pointer
+memcpy (ptoarg, pfromarg, c)
+ pointer ptoarg;
+ constpointer pfromarg;
+ size_t c;
+{
+ char *pto = (char *) ptoarg;
+ const char *pfrom = (const char *) pfromarg;
+
+ while (c-- != 0)
+ *pto++ = *pfrom++;
+ return ptoarg;
+}
diff --git a/gnu/libexec/uucp/libuucp/parse.c b/gnu/libexec/uucp/libuucp/parse.c
new file mode 100644
index 00000000000..0921c5ac4a4
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/parse.c
@@ -0,0 +1,219 @@
+/* parse.c
+ Parse a UUCP command string.
+
+ Copyright (C) 1991, 1992, 1993 Ian Lance Taylor
+
+ This file is part of the Taylor UUCP package.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ The author of the program may be contacted at ian@airs.com or
+ c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
+ */
+
+#include "uucp.h"
+
+#if USE_RCS_ID
+const char parse_rcsid[] = "$Id: parse.c,v 1.1 1995/10/18 08:38:39 deraadt Exp $";
+#endif
+
+#include "uudefs.h"
+
+/* Parse a UUCP command string into an scmd structure. This is called
+ by the 'g' protocol and the UNIX command file reading routines. It
+ destroys the string it is passed, and the scmd string pointers are
+ left pointing into it. For the convenience of the Unix work file
+ routines, it will parse "P" into a simple 'P' command (representing
+ a poll file). It returns TRUE if the string is successfully
+ parsed, FALSE otherwise. */
+
+boolean
+fparse_cmd (zcmd, qcmd)
+ char *zcmd;
+ struct scmd *qcmd;
+{
+ char *z, *zend;
+
+ z = strtok (zcmd, " \t\n");
+ if (z == NULL)
+ return FALSE;
+
+ qcmd->bcmd = *z;
+ if (qcmd->bcmd != 'S'
+ && qcmd->bcmd != 'R'
+ && qcmd->bcmd != 'X'
+ && qcmd->bcmd != 'E'
+ && qcmd->bcmd != 'H'
+ && qcmd->bcmd != 'P')
+ return FALSE;
+
+ qcmd->bgrade = '\0';
+ qcmd->pseq = NULL;
+ qcmd->zfrom = NULL;
+ qcmd->zto = NULL;
+ qcmd->zuser = NULL;
+ qcmd->zoptions = NULL;
+ qcmd->ztemp = NULL;
+ qcmd->imode = 0666;
+ qcmd->znotify = NULL;
+ qcmd->cbytes = -1;
+ qcmd->zcmd = NULL;
+ qcmd->ipos = 0;
+
+ /* Handle hangup commands specially. If it's just "H", return
+ the command 'H' to indicate a hangup request. If it's "HY"
+ return 'Y' and if it's "HN" return 'N'. */
+ if (qcmd->bcmd == 'H')
+ {
+ if (z[1] != '\0')
+ {
+ if (z[1] == 'Y')
+ qcmd->bcmd = 'Y';
+ else if (z[1] == 'N')
+ qcmd->bcmd = 'N';
+ else
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+ if (qcmd->bcmd == 'P')
+ return TRUE;
+
+ if (z[1] != '\0')
+ return FALSE;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL)
+ return FALSE;
+ qcmd->zfrom = z;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL)
+ return FALSE;
+ qcmd->zto = z;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL)
+ return FALSE;
+ qcmd->zuser = z;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL || *z != '-')
+ return FALSE;
+ qcmd->zoptions = z + 1;
+
+ if (qcmd->bcmd == 'X')
+ return TRUE;
+
+ if (qcmd->bcmd == 'R')
+ {
+ z = strtok ((char *) NULL, " \t\n");
+ if (z != NULL)
+ {
+ if (strcmp (z, "dummy") != 0)
+ {
+ /* This may be the maximum number of bytes the remote
+ system wants to receive, if it using Taylor UUCP size
+ negotiation. */
+ qcmd->cbytes = strtol (z, &zend, 0);
+ if (*zend != '\0')
+ qcmd->cbytes = -1;
+ }
+ else
+ {
+ /* This is from an SVR4 system, and may include the
+ position at which to start sending the file. The
+ next fields are the mode bits, the remote owner (?),
+ the remote temporary file name, and finally the
+ restart position. */
+ if (strtok ((char *) NULL, " \t\n") != NULL
+ && strtok ((char *) NULL, " \t\n") != NULL
+ && strtok ((char *) NULL, " \t\n") != NULL)
+ {
+ z = strtok ((char *) NULL, " \t\n");
+ if (z != NULL)
+ {
+ qcmd->ipos = strtol (z, &zend, 0);
+ if (*zend != '\0')
+ qcmd->ipos = 0;
+ }
+ }
+ }
+ }
+
+ return TRUE;
+ }
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL)
+ return FALSE;
+ qcmd->ztemp = z;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (z == NULL)
+ return FALSE;
+ qcmd->imode = (int) strtol (z, &zend, 0);
+ if (*zend != '\0')
+ return FALSE;
+
+ /* As a magic special case, if the mode came out as the decimal
+ values 666 or 777, assume that they actually meant the octal
+ values. Most systems use a leading zero, but a few do not.
+ Since both 666 and 777 are greater than the largest legal mode
+ value, which is 0777 == 511, this hack does not restrict any
+ legal values. */
+ if (qcmd->imode == 666)
+ qcmd->imode = 0666;
+ else if (qcmd->imode == 777)
+ qcmd->imode = 0777;
+
+ z = strtok ((char *) NULL, " \t\n");
+ if (qcmd->bcmd == 'E' && z == NULL)
+ return FALSE;
+ qcmd->znotify = z;
+
+ /* SVR4 UUCP will send the string "dummy" after the notify string
+ but before the size. I do not know when it sends anything other
+ than "dummy". Fortunately, it doesn't really hurt to not get the
+ file size. */
+ if (z != NULL && strcmp (z, "dummy") == 0)
+ z = strtok ((char *) NULL, " \t\n");
+
+ if (z != NULL)
+ {
+ z = strtok ((char *) NULL, " \t\n");
+ if (z != NULL)
+ {
+ qcmd->cbytes = strtol (z, &zend, 0);
+ if (*zend != '\0')
+ qcmd->cbytes = -1;
+ }
+ else if (qcmd->bcmd == 'E')
+ return FALSE;
+
+ if (z != NULL)
+ {
+ z = strtok ((char *) NULL, "");
+ if (z != NULL)
+ z[strcspn (z, "\n")] = '\0';
+ if (qcmd->bcmd == 'E' && z == NULL)
+ return FALSE;
+ qcmd->zcmd = z;
+ }
+ }
+
+ return TRUE;
+}
diff --git a/gnu/libexec/uucp/libuucp/spool.c b/gnu/libexec/uucp/libuucp/spool.c
new file mode 100644
index 00000000000..52223fb585a
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/spool.c
@@ -0,0 +1,30 @@
+/* spool.c
+ See whether a filename is legal for the spool directory. */
+
+#include "uucp.h"
+
+#include <ctype.h>
+
+#include "uudefs.h"
+
+/* See whether a file is a spool file. Spool file names are specially
+ crafted to hand around to other UUCP packages. They always begin
+ with 'C', 'D' or 'X', and the second character is always a period.
+ The remaining characters may be any printable characters, since
+ they may include a grade set by another system. */
+
+boolean
+fspool_file (zfile)
+ const char *zfile;
+{
+ const char *z;
+
+ if (*zfile != 'C' && *zfile != 'D' && *zfile != 'X')
+ return FALSE;
+ if (zfile[1] != '.')
+ return FALSE;
+ for (z = zfile + 2; *z != '\0'; z++)
+ if (*z == '/' || ! isprint (BUCHAR (*z)) || isspace (BUCHAR (*z)))
+ return FALSE;
+ return TRUE;
+}
diff --git a/gnu/libexec/uucp/libuucp/status.c b/gnu/libexec/uucp/libuucp/status.c
new file mode 100644
index 00000000000..65e854ebdca
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/status.c
@@ -0,0 +1,38 @@
+/* status.c
+ Strings for status codes. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+
+/* Status strings. These must match enum tstatus_type. */
+
+#if USE_TRADITIONAL_STATUS
+
+const char *azStatus[] =
+{
+ "SUCCESSFUL",
+ "DEVICE FAILED",
+ "DIAL FAILED",
+ "LOGIN FAILED",
+ "STARTUP FAILED",
+ "CONVERSATION FAILED",
+ "TALKING",
+ "WRONG TIME TO CALL"
+};
+
+#else
+
+const char *azStatus[] =
+{
+ "Conversation complete",
+ "Port unavailable",
+ "Dial failed",
+ "Login failed",
+ "Handshake failed",
+ "Call failed",
+ "Talking",
+ "Wrong time to call"
+};
+
+#endif
diff --git a/gnu/libexec/uucp/libuucp/strcas.c b/gnu/libexec/uucp/libuucp/strcas.c
new file mode 100644
index 00000000000..4bb22511292
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strcas.c
@@ -0,0 +1,33 @@
+/* strcas.c
+ Compare two strings case insensitively. */
+
+#include "uucp.h"
+#include <ctype.h>
+
+int
+strcasecmp (z1, z2)
+ const char *z1;
+ const char *z2;
+{
+ char b1, b2;
+
+ while ((b1 = *z1++) != '\0')
+ {
+ b2 = *z2++;
+ if (b2 == '\0')
+ return 1;
+ if (b1 != b2)
+ {
+ if (isupper (BUCHAR (b1)))
+ b1 = tolower (BUCHAR (b1));
+ if (isupper (BUCHAR (b2)))
+ b2 = tolower (BUCHAR (b2));
+ if (b1 != b2)
+ return b1 - b2;
+ }
+ }
+ if (*z2 == '\0')
+ return 0;
+ else
+ return -1;
+}
diff --git a/gnu/libexec/uucp/libuucp/strchr.c b/gnu/libexec/uucp/libuucp/strchr.c
new file mode 100644
index 00000000000..ca8d8e9b1bd
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strchr.c
@@ -0,0 +1,16 @@
+/* strchr.c
+ Look for a character in a string. This works for a null byte. */
+
+#include "uucp.h"
+
+char *
+strchr (z, b)
+ const char *z;
+ int b;
+{
+ b = (char) b;
+ while (*z != b)
+ if (*z++ == '\0')
+ return NULL;
+ return (char *) z;
+}
diff --git a/gnu/libexec/uucp/libuucp/strdup.c b/gnu/libexec/uucp/libuucp/strdup.c
new file mode 100644
index 00000000000..231e35b3f61
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strdup.c
@@ -0,0 +1,18 @@
+/* strdup.c
+ Duplicate a string into memory. */
+
+#include "uucp.h"
+
+char *
+strdup (z)
+ const char *z;
+{
+ size_t csize;
+ char *zret;
+
+ csize = strlen (z) + 1;
+ zret = malloc (csize);
+ if (zret != NULL)
+ memcpy (zret, z, csize);
+ return zret;
+}
diff --git a/gnu/libexec/uucp/libuucp/strncs.c b/gnu/libexec/uucp/libuucp/strncs.c
new file mode 100644
index 00000000000..6959d625d6d
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strncs.c
@@ -0,0 +1,39 @@
+/* strncs.c
+ Compare two strings case insensitively up to a point. */
+
+#include "uucp.h"
+#include <ctype.h>
+
+int
+strncasecmp (z1, z2, c)
+ const char *z1;
+ const char *z2;
+ size_t c;
+{
+ char b1, b2;
+
+ if (c == 0)
+ return 0;
+ while ((b1 = *z1++) != '\0')
+ {
+ b2 = *z2++;
+ if (b2 == '\0')
+ return 1;
+ if (b1 != b2)
+ {
+ if (isupper (BUCHAR (b1)))
+ b1 = tolower (BUCHAR (b1));
+ if (isupper (BUCHAR (b2)))
+ b2 = tolower (BUCHAR (b2));
+ if (b1 != b2)
+ return b1 - b2;
+ }
+ --c;
+ if (c == 0)
+ return 0;
+ }
+ if (*z2 == '\0')
+ return 0;
+ else
+ return -1;
+}
diff --git a/gnu/libexec/uucp/libuucp/strrch.c b/gnu/libexec/uucp/libuucp/strrch.c
new file mode 100644
index 00000000000..a88e4b4358b
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strrch.c
@@ -0,0 +1,24 @@
+/* strrch.c
+ Look for the last occurrence of a character in a string. This is
+ supposed to work for a null byte, although we never actually call
+ it with one. */
+
+#include "uucp.h"
+
+char *
+strrchr (z, b)
+ const char *z;
+ int b;
+{
+ char *zret;
+
+ b = (char) b;
+ zret = NULL;
+ do
+ {
+ if (*z == b)
+ zret = (char *) z;
+ }
+ while (*z++ != '\0');
+ return zret;
+}
diff --git a/gnu/libexec/uucp/libuucp/strstr.c b/gnu/libexec/uucp/libuucp/strstr.c
new file mode 100644
index 00000000000..2cf1097df2d
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strstr.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place -
+Suite 330, Boston, MA 02111-1307, USA.
+
+This file was modified slightly by Ian Lance Taylor, May 1992, for
+Taylor UUCP. */
+
+#include "uucp.h"
+
+/* Return the first ocurrence of NEEDLE in HAYSTACK. */
+char *
+strstr (haystack, needle)
+ const char *const haystack;
+ const char *const needle;
+{
+ register const char *const needle_end = strchr(needle, '\0');
+ register const char *const haystack_end = strchr(haystack, '\0');
+ register const size_t needle_len = needle_end - needle;
+ register const size_t needle_last = needle_len - 1;
+ register const char *begin;
+
+ if (needle_len == 0)
+ return (char *) haystack_end;
+ if ((size_t) (haystack_end - haystack) < needle_len)
+ return NULL;
+
+ for (begin = &haystack[needle_last]; begin < haystack_end; ++begin)
+ {
+ register const char *n = &needle[needle_last];
+ register const char *h = begin;
+ do
+ if (*h != *n)
+ goto loop;
+ while (--n >= needle && --h >= haystack);
+
+ return (char *) h;
+ loop:;
+ }
+
+ return NULL;
+}
diff --git a/gnu/libexec/uucp/libuucp/strtol.c b/gnu/libexec/uucp/libuucp/strtol.c
new file mode 100644
index 00000000000..0c6b28c6cd0
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strtol.c
@@ -0,0 +1,175 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place -
+Suite 330, Boston, MA 02111-1307, USA.
+
+This file was modified slightly by Ian Lance Taylor, May 1992, for
+Taylor UUCP. */
+
+#include "uucp.h"
+
+#include <ctype.h>
+#include <errno.h>
+
+#if HAVE_LIMITS_H
+#include <limits.h>
+#else
+#define ULONG_MAX 4294967295
+#define LONG_MIN (- LONG_MAX - 1)
+#define LONG_MAX 2147483647
+#endif
+
+#ifndef UNSIGNED
+#define UNSIGNED 0
+#endif
+
+/* Convert NPTR to an `unsigned long int' or `long int' in base BASE.
+ If BASE is 0 the base is determined by the presence of a leading
+ zero, indicating octal or a leading "0x" or "0X", indicating hexadecimal.
+ If BASE is < 2 or > 36, it is reset to 10.
+ If ENDPTR is not NULL, a pointer to the character after the last
+ one converted is stored in *ENDPTR. */
+#if UNSIGNED
+unsigned long int
+#define strtol strtoul
+#else
+long int
+#endif
+strtol (nptr, endptr, base)
+ const char *nptr;
+ char **endptr;
+ int base;
+{
+ int negative;
+ register unsigned long int cutoff;
+ register unsigned int cutlim;
+ register unsigned long int i;
+ register const char *s;
+ register unsigned int c;
+ const char *save;
+ int overflow;
+
+ if (base < 0 || base == 1 || base > 36)
+ base = 10;
+
+ s = nptr;
+
+ /* Skip white space. */
+ while (isspace(BUCHAR (*s)))
+ ++s;
+ if (*s == '\0')
+ goto noconv;
+
+ /* Check for a sign. */
+ if (*s == '-')
+ {
+ negative = 1;
+ ++s;
+ }
+ else if (*s == '+')
+ {
+ negative = 0;
+ ++s;
+ }
+ else
+ negative = 0;
+
+ if (base == 16
+ && s[0] == '0'
+ && (s[1] == 'x' || s[1] == 'X'))
+ s += 2;
+
+ /* If BASE is zero, figure it out ourselves. */
+ if (base == 0)
+ if (*s == '0')
+ {
+ if (s[1] == 'x' || s[1] == 'X')
+ {
+ s += 2;
+ base = 16;
+ }
+ else
+ base = 8;
+ }
+ else
+ base = 10;
+
+ /* Save the pointer so we can check later if anything happened. */
+ save = s;
+
+ cutoff = ULONG_MAX / (unsigned long int) base;
+ cutlim = ULONG_MAX % (unsigned long int) base;
+
+ overflow = 0;
+ i = 0;
+ for (c = BUCHAR (*s); c != '\0'; c = BUCHAR (*++s))
+ {
+ if (isdigit(c))
+ c -= '0';
+ else if (islower(c))
+ c = c - 'a' + 10;
+ else if (isupper(c))
+ c = c - 'A' + 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ /* Check for overflow. */
+ if (i > cutoff || (i == cutoff && c > cutlim))
+ overflow = 1;
+ else
+ {
+ i *= (unsigned long int) base;
+ i += c;
+ }
+ }
+
+ /* Check if anything actually happened. */
+ if (s == save)
+ goto noconv;
+
+ /* Store in ENDPTR the address of one character
+ past the last character we converted. */
+ if (endptr != NULL)
+ *endptr = (char *) s;
+
+#if !UNSIGNED
+ /* Check for a value that is within the range of
+ `unsigned long int', but outside the range of `long int'. */
+ if (i > (negative ?
+ - (unsigned long int) LONG_MIN : (unsigned long int) LONG_MAX))
+ overflow = 1;
+#endif
+
+ if (overflow)
+ {
+ errno = ERANGE;
+#if UNSIGNED
+ return ULONG_MAX;
+#else
+ return negative ? LONG_MIN : LONG_MAX;
+#endif
+ }
+
+ /* Return the result of the appropriate sign. */
+ return (negative ? - i : i);
+
+ noconv:
+ /* There was no number to convert. */
+ if (endptr != NULL)
+ *endptr = (char *) nptr;
+ return 0L;
+}
diff --git a/gnu/libexec/uucp/libuucp/strtou.c b/gnu/libexec/uucp/libuucp/strtou.c
new file mode 100644
index 00000000000..d3c81890e3a
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/strtou.c
@@ -0,0 +1,21 @@
+/* Copyright (C) 1991 Free Software Foundation, Inc.
+This file is part of the GNU C Library.
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB. If
+not, write to the Free Software Foundation, Inc., 59 Temple Place -
+Suite 330, Boston, MA 02111-1307, USA. */
+
+#define UNSIGNED 1
+
+#include "lib/strtol.c"
diff --git a/gnu/libexec/uucp/libuucp/xfree.c b/gnu/libexec/uucp/libuucp/xfree.c
new file mode 100644
index 00000000000..239b015db21
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/xfree.c
@@ -0,0 +1,15 @@
+/* xfree.c
+ Some versions of free (like the one in SCO Unix 3.2.2) don't handle
+ null pointers correctly, so we go through our own routine. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+
+void
+xfree (p)
+ pointer p;
+{
+ if (p != NULL)
+ free (p);
+}
diff --git a/gnu/libexec/uucp/libuucp/xmall.c b/gnu/libexec/uucp/libuucp/xmall.c
new file mode 100644
index 00000000000..4aac23748c8
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/xmall.c
@@ -0,0 +1,18 @@
+/* xmalloc.c
+ Allocate a block of memory without fail. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+
+pointer
+xmalloc (c)
+ size_t c;
+{
+ pointer pret;
+
+ pret = malloc (c);
+ if (pret == NULL && c != 0)
+ ulog (LOG_FATAL, "Out of memory");
+ return pret;
+}
diff --git a/gnu/libexec/uucp/libuucp/xreall.c b/gnu/libexec/uucp/libuucp/xreall.c
new file mode 100644
index 00000000000..36ae313a508
--- /dev/null
+++ b/gnu/libexec/uucp/libuucp/xreall.c
@@ -0,0 +1,23 @@
+/* xreall.c
+ Realloc a block of memory without fail. Supposedly some versions of
+ realloc can't handle a NULL first argument, so we check for that
+ here. */
+
+#include "uucp.h"
+
+#include "uudefs.h"
+
+pointer
+xrealloc (p, c)
+ pointer p;
+ size_t c;
+{
+ pointer pret;
+
+ if (p == NULL)
+ return xmalloc (c);
+ pret = realloc (p, c);
+ if (pret == NULL && c != 0)
+ ulog (LOG_FATAL, "Out of memory");
+ return pret;
+}