summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/csu/i386/gmon.c330
-rw-r--r--lib/csu/i386/gmon.h106
-rw-r--r--lib/libc/i386/gen/divsi3.S50
-rw-r--r--lib/libc/i386/gen/fixdfsi.S24
-rw-r--r--lib/libc/i386/gen/fixunsdfsi.S68
-rw-r--r--lib/libc/i386/gen/udivsi3.S50
-rw-r--r--lib/libc/locale/common_rune.h3
-rw-r--r--lib/libc/locale/common_setlocale.c64
-rw-r--r--lib/libc/locale/common_setlocale.h14
-rw-r--r--lib/libc/locale/read_runemagi.c133
-rw-r--r--lib/libc/locale/startup_setlocale.c198
-rw-r--r--lib/libforms/Makefile.orig12
-rw-r--r--lib/libforms/examples/test.c94
-rw-r--r--lib/libforms/examples/tform.c18
-rw-r--r--lib/libforms/fields.c678
-rw-r--r--lib/libforms/forms.c.orig502
-rw-r--r--lib/libforms/forms.h.orig126
-rw-r--r--lib/libforms/internal.h.orig38
-rw-r--r--lib/libforms/lex.c1606
-rw-r--r--lib/libforms/menu.c59
-rw-r--r--lib/libforms/parser.c1022
-rw-r--r--lib/libforms/y.tab.h46
-rw-r--r--lib/libforms/yacc.y149
-rw-r--r--lib/libftp/FtpAbort.c47
-rw-r--r--lib/libftp/FtpArchie.c63
-rw-r--r--lib/libftp/FtpBye.c45
-rw-r--r--lib/libftp/FtpClose.c26
-rw-r--r--lib/libftp/FtpCommand.c61
-rw-r--r--lib/libftp/FtpConnect.c72
-rw-r--r--lib/libftp/FtpCopy.c50
-rw-r--r--lib/libftp/FtpData.c92
-rw-r--r--lib/libftp/FtpDebug.c94
-rw-r--r--lib/libftp/FtpFilenameChecker.c43
-rw-r--r--lib/libftp/FtpFull.c142
-rw-r--r--lib/libftp/FtpGetHost.c44
-rw-r--r--lib/libftp/FtpGood.c55
-rw-r--r--lib/libftp/FtpIO.c174
-rw-r--r--lib/libftp/FtpInit.c41
-rw-r--r--lib/libftp/FtpLibrary.h268
-rw-r--r--lib/libftp/FtpLogin.c34
-rw-r--r--lib/libftp/FtpMessage.c130
-rw-r--r--lib/libftp/FtpMove.c25
-rw-r--r--lib/libftp/FtpNumber.c22
-rw-r--r--lib/libftp/FtpOpenDir.c27
-rw-r--r--lib/libftp/FtpPasv.c100
-rw-r--r--lib/libftp/FtpPort.c32
-rw-r--r--lib/libftp/FtpPwd.c34
-rw-r--r--lib/libftp/FtpRetr.c84
-rw-r--r--lib/libftp/FtpSize.c35
-rw-r--r--lib/libftp/FtpStor.c58
-rw-r--r--lib/libftp/FtpSyscalls.c35
-rw-r--r--lib/libftp/FtpType.c26
-rw-r--r--lib/libftp/Ftpfopen.c98
-rw-r--r--lib/libftp/Makefile20
-rw-r--r--lib/libftp/doc/example.c51
-rw-r--r--lib/libftp/utils/Makefile34
-rw-r--r--lib/libftp/utils/cdefs.h111
-rw-r--r--lib/libftp/utils/ftptry.c633
-rw-r--r--lib/libftp/utils/glob.c850
-rw-r--r--lib/libftp/utils/glob.h89
-rw-r--r--lib/libftp/utils/mirror.c92
-rw-r--r--lib/libftp/utils/readline.c961
-rw-r--r--lib/libftp/utils/uftp.c824
-rw-r--r--lib/libftp/utils/uftpcmd.c1202
-rw-r--r--lib/libncurses/TESTS/bs.c1252
-rw-r--r--lib/libncurses/TESTS/gdc.c202
-rw-r--r--lib/libncurses/lib_deleteln.c49
-rw-r--r--lib/libncurses/lib_insertln.c50
-rw-r--r--lib/libncurses/ncurses.h497
-rw-r--r--lib/libncurses/termcap.h52
-rw-r--r--lib/librpc/Makefile.inc4
-rw-r--r--lib/librpc/rpc/Makefile18
-rw-r--r--lib/libskey/authfile.c177
-rw-r--r--lib/libskey/md4.c336
-rw-r--r--lib/libskey/md4.h47
-rw-r--r--lib/libterm/Makefile15
-rw-r--r--lib/rpcsvc/Makefile31
77 files changed, 0 insertions, 15044 deletions
diff --git a/lib/csu/i386/gmon.c b/lib/csu/i386/gmon.c
deleted file mode 100644
index 4ca8333..0000000
--- a/lib/csu/i386/gmon.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/*static char sccsid[] = "from: @(#)gmon.c 5.3 (Berkeley) 5/22/91";*/
-static char rcsid[] = "$Id: gmon.c,v 1.2 1993/08/01 18:44:18 mycroft Exp $";
-#endif /* LIBC_SCCS and not lint */
-
-
-#include <unistd.h>
-
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-
-#include "gmon.h"
-
-extern mcount() asm ("mcount");
-extern char *minbrk asm ("minbrk");
-
- /*
- * froms is actually a bunch of unsigned shorts indexing tos
- */
-static int profiling = 3;
-static unsigned short *froms;
-static struct tostruct *tos = 0;
-static long tolimit = 0;
-static char *s_lowpc = 0;
-static char *s_highpc = 0;
-static unsigned long s_textsize = 0;
-
-static int ssiz;
-static char *sbuf;
-static int s_scale;
- /* see profil(2) where this is describe (incorrectly) */
-#define SCALE_1_TO_1 0x10000L
-
-#define MSG "No space for profiling buffer(s)\n"
-
-monstartup(lowpc, highpc)
- char *lowpc;
- char *highpc;
-{
- int monsize;
- char *buffer;
- register int o;
-
- /*
- * round lowpc and highpc to multiples of the density we're using
- * so the rest of the scaling (here and in gprof) stays in ints.
- */
- lowpc = (char *)
- ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
- s_lowpc = lowpc;
- highpc = (char *)
- ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
- s_highpc = highpc;
- s_textsize = highpc - lowpc;
- monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
- buffer = sbrk( monsize );
- if ( buffer == (char *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- return;
- }
- froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
- if ( froms == (unsigned short *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- froms = 0;
- return;
- }
- tolimit = s_textsize * ARCDENSITY / 100;
- if ( tolimit < MINARCS ) {
- tolimit = MINARCS;
- } else if ( tolimit > 65534 ) {
- tolimit = 65534;
- }
- tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) );
- if ( tos == (struct tostruct *) -1 ) {
- write( 2 , MSG , sizeof(MSG) );
- froms = 0;
- tos = 0;
- return;
- }
- minbrk = sbrk(0);
- tos[0].link = 0;
- sbuf = buffer;
- ssiz = monsize;
- ( (struct phdr *) buffer ) -> lpc = lowpc;
- ( (struct phdr *) buffer ) -> hpc = highpc;
- ( (struct phdr *) buffer ) -> ncnt = ssiz;
- monsize -= sizeof(struct phdr);
- if ( monsize <= 0 )
- return;
- o = highpc - lowpc;
- if( monsize < o )
-#ifndef hp300
- s_scale = ( (float) monsize / o ) * SCALE_1_TO_1;
-#else /* avoid floating point */
- {
- int quot = o / monsize;
-
- if (quot >= 0x10000)
- s_scale = 1;
- else if (quot >= 0x100)
- s_scale = 0x10000 / quot;
- else if (o >= 0x800000)
- s_scale = 0x1000000 / (o / (monsize >> 8));
- else
- s_scale = 0x1000000 / ((o << 8) / monsize);
- }
-#endif
- else
- s_scale = SCALE_1_TO_1;
- moncontrol(1);
-}
-
-_mcleanup()
-{
- int fd;
- int fromindex;
- int endfrom;
- char *frompc;
- int toindex;
- struct rawarc rawarc;
-
- moncontrol(0);
- fd = creat( "gmon.out" , 0666 );
- if ( fd < 0 ) {
- perror( "mcount: gmon.out" );
- return;
- }
-# ifdef DEBUG
- fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
-# endif DEBUG
- write( fd , sbuf , ssiz );
- endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
- for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
- if ( froms[fromindex] == 0 ) {
- continue;
- }
- frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
- for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
-# ifdef DEBUG
- fprintf( stderr ,
- "[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
- frompc , tos[toindex].selfpc , tos[toindex].count );
-# endif DEBUG
- rawarc.raw_frompc = (unsigned long) frompc;
- rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
- rawarc.raw_count = tos[toindex].count;
- write( fd , &rawarc , sizeof rawarc );
- }
- }
- close( fd );
-}
-
-mcount()
-{
- register char *selfpc;
- register unsigned short *frompcindex;
- register struct tostruct *top;
- register struct tostruct *prevtop;
- register long toindex;
-
- /*
- * find the return address for mcount,
- * and the return address for mcount's caller.
- */
- asm(".text"); /* make sure we're in text space */
- /*
- * selfpc = pc pushed by mcount call
- */
- asm("movl 4(%%ebp),%0" : "=r" (selfpc));
- /*
- * frompcindex = pc pushed by jsr into self.
- * In GCC the caller's stack frame has already been built so we
- * have to chase a6 to find caller's raddr.
- */
- asm("movl (%%ebp),%0" : "=r" (frompcindex));
- frompcindex = ((unsigned short **)frompcindex)[1];
- /*
- * check that we are profiling
- * and that we aren't recursively invoked.
- */
- if (profiling) {
- goto out;
- }
- profiling++;
- /*
- * check that frompcindex is a reasonable pc value.
- * for example: signal catchers get called from the stack,
- * not from text space. too bad.
- */
- frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc);
- if ((unsigned long)frompcindex > s_textsize) {
- goto done;
- }
- frompcindex =
- &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
- toindex = *frompcindex;
- if (toindex == 0) {
- /*
- * first time traversing this arc
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit) {
- goto overflow;
- }
- *frompcindex = toindex;
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = 0;
- goto done;
- }
- top = &tos[toindex];
- if (top->selfpc == selfpc) {
- /*
- * arc at front of chain; usual case.
- */
- top->count++;
- goto done;
- }
- /*
- * have to go looking down chain for it.
- * top points to what we are looking at,
- * prevtop points to previous top.
- * we know it is not at the head of the chain.
- */
- for (; /* goto done */; ) {
- if (top->link == 0) {
- /*
- * top is end of the chain and none of the chain
- * had top->selfpc == selfpc.
- * so we allocate a new tostruct
- * and link it to the head of the chain.
- */
- toindex = ++tos[0].link;
- if (toindex >= tolimit) {
- goto overflow;
- }
- top = &tos[toindex];
- top->selfpc = selfpc;
- top->count = 1;
- top->link = *frompcindex;
- *frompcindex = toindex;
- goto done;
- }
- /*
- * otherwise, check the next arc on the chain.
- */
- prevtop = top;
- top = &tos[top->link];
- if (top->selfpc == selfpc) {
- /*
- * there it is.
- * increment its count
- * move it to the head of the chain.
- */
- top->count++;
- toindex = prevtop->link;
- prevtop->link = top->link;
- top->link = *frompcindex;
- *frompcindex = toindex;
- goto done;
- }
-
- }
-done:
- profiling--;
- /* and fall through */
-out:
- return; /* normal return restores saved registers */
-
-overflow:
- profiling++; /* halt further profiling */
-# define TOLIMIT "mcount: tos overflow\n"
- write(2, TOLIMIT, sizeof(TOLIMIT));
- goto out;
-}
-
-/*
- * Control profiling
- * profiling is what mcount checks to see if
- * all the data structures are ready.
- */
-moncontrol(mode)
- int mode;
-{
- if (mode) {
- /* start */
- profil(sbuf + sizeof(struct phdr), ssiz - sizeof(struct phdr),
- (int)s_lowpc, s_scale);
- profiling = 0;
- } else {
- /* stop */
- profil((char *)0, 0, 0, 0);
- profiling = 3;
- }
-}
diff --git a/lib/csu/i386/gmon.h b/lib/csu/i386/gmon.h
deleted file mode 100644
index e400602..0000000
--- a/lib/csu/i386/gmon.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * from: @(#)gmon.h 5.2 (Berkeley) 5/6/91
- * $Id: gmon.h,v 1.2 1993/08/01 18:44:21 mycroft Exp $
- */
-
-struct phdr {
- char *lpc;
- char *hpc;
- int ncnt;
-};
-
- /*
- * histogram counters are unsigned shorts (according to the kernel).
- */
-#define HISTCOUNTER unsigned short
-
- /*
- * fraction of text space to allocate for histogram counters
- * here, 1/2
- */
-#define HISTFRACTION 2
-
- /*
- * Fraction of text space to allocate for from hash buckets.
- * The value of HASHFRACTION is based on the minimum number of bytes
- * of separation between two subroutine call points in the object code.
- * Given MIN_SUBR_SEPARATION bytes of separation the value of
- * HASHFRACTION is calculated as:
- *
- * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
- *
- * For the VAX, the shortest two call sequence is:
- *
- * calls $0,(r0)
- * calls $0,(r0)
- *
- * which is separated by only three bytes, thus HASHFRACTION is
- * calculated as:
- *
- * HASHFRACTION = 3 / (2 * 2 - 1) = 1
- *
- * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
- * is less than three, this algorithm will not work!
- */
-#define HASHFRACTION 1
-
- /*
- * percent of text space to allocate for tostructs
- * with a minimum.
- */
-#define ARCDENSITY 2
-#define MINARCS 50
-
-struct tostruct {
- char *selfpc;
- long count;
- unsigned short link;
-};
-
- /*
- * a raw arc,
- * with pointers to the calling site and the called site
- * and a count.
- */
-struct rawarc {
- unsigned long raw_frompc;
- unsigned long raw_selfpc;
- long raw_count;
-};
-
- /*
- * general rounding functions.
- */
-#define ROUNDDOWN(x,y) (((x)/(y))*(y))
-#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
diff --git a/lib/libc/i386/gen/divsi3.S b/lib/libc/i386/gen/divsi3.S
deleted file mode 100644
index 3b09580..0000000
--- a/lib/libc/i386/gen/divsi3.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $Id$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$Id$"
-#endif /* LIBC_RCS and not lint */
-
- .globl ___divsi3
- .type ___divsi3,@function
-___divsi3:
- movl 4(%esp),%eax
- cltd
- idivl 8(%esp)
- ret
diff --git a/lib/libc/i386/gen/fixdfsi.S b/lib/libc/i386/gen/fixdfsi.S
deleted file mode 100644
index 398506c..0000000
--- a/lib/libc/i386/gen/fixdfsi.S
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * $Id$
- */
-
- .file "__fixdfsi.s"
-.text
- .align 2
-.globl ___fixdfsi
-.type ___fixdfsi,@function
-___fixdfsi:
- pushl %ebp
- movl %esp,%ebp
- subl $12,%esp
- fstcw -4(%ebp)
- movw -4(%ebp),%ax
- orw $0x0c00,%ax
- movw %ax,-2(%ebp)
- fldcw -2(%ebp)
- fldl 8(%ebp)
- fistpl -12(%ebp)
- fldcw -4(%ebp)
- movl -12(%ebp),%eax
- leave
- ret
diff --git a/lib/libc/i386/gen/fixunsdfsi.S b/lib/libc/i386/gen/fixunsdfsi.S
deleted file mode 100644
index eb576ba..0000000
--- a/lib/libc/i386/gen/fixunsdfsi.S
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * from: @(#)fixunsdfsi.s 5.1 12/17/90
- * $Id: fixunsdfsi.S,v 1.2 1994/12/27 13:37:38 bde Exp $
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$Id: fixunsdfsi.S,v 1.2 1994/12/27 13:37:38 bde Exp $"
-#endif /* LIBC_RCS and not lint */
-
-#include "DEFS.h"
-
-ENTRY(__fixunsdfsi)
- fldl 4(%esp)
- fnstcw 4(%esp)
- movl 4(%esp),%eax
- orb $(3 << 2),%ah # change rounding mode bitfield to 3 (chop)
- movl %eax,8(%esp)
- fldcw 8(%esp)
- subl $8,%esp
- fistpq (%esp) # convert to 64 bit integer
- popl %eax
- popl %edx # discard top 32 bits
- fldcw 4(%esp)
- ret
-
-/*
- * XXX - we are sloppy about overflow, the same as gcc-2. Values too big
- * for a 64-bit (signed) integer cause an overflow trap or are silently
- * converted to 0 if the overflow trap is masked. The remaining values
- * too big for a 32-bit (unsigned) integer are silently truncated to 32
- * bits. Negative values are converted like negative ints (no overflow)
- * if they fit in 32 bits.
- */
diff --git a/lib/libc/i386/gen/udivsi3.S b/lib/libc/i386/gen/udivsi3.S
deleted file mode 100644
index 55a326b..0000000
--- a/lib/libc/i386/gen/udivsi3.S
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * $Id$
- */
-
-#if defined(LIBC_RCS) && !defined(lint)
- .text
- .asciz "$Id$"
-#endif /* LIBC_RCS and not lint */
-
- .globl ___udivsi3
- .type ___udivsi3,@function
-___udivsi3:
- movl 4(%esp),%eax
- xorl %edx,%edx
- divl 8(%esp)
- ret
diff --git a/lib/libc/locale/common_rune.h b/lib/libc/locale/common_rune.h
deleted file mode 100644
index 9dcd5f3..0000000
--- a/lib/libc/locale/common_rune.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#define PathLocale _PathLocale
-
-extern _RuneLocale *_Read_RuneMagi __P((FILE *));
diff --git a/lib/libc/locale/common_setlocale.c b/lib/libc/locale/common_setlocale.c
deleted file mode 100644
index 2dd549f..0000000
--- a/lib/libc/locale/common_setlocale.c
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <locale.h>
-#include <string.h>
-
-/*
- * Category names for getenv()
- */
-char *_categories[_LC_LAST] = {
- "LC_ALL",
- "LC_COLLATE",
- "LC_CTYPE",
- "LC_MONETARY",
- "LC_NUMERIC",
- "LC_TIME",
-};
-
-/*
- * Current locales for each category
- */
-char _current_categories[_LC_LAST][32] = {
- "C",
- "C",
- "C",
- "C",
- "C",
- "C",
-};
-
-/*
- * The locales we are going to try and load
- */
-char _new_categories[_LC_LAST][32];
-
-char _current_locale_string[_LC_LAST * 33];
-
-char *
-_currentlocale()
-{
- int i, len;
-
- (void)strcpy(_current_locale_string, _current_categories[1]);
-
- for (i = 2; i < _LC_LAST; ++i)
- if (strcmp(_current_categories[1], _current_categories[i])) {
- len = strlen(_current_categories[1]) + 1 +
- strlen(_current_categories[2]) + 1 +
- strlen(_current_categories[3]) + 1 +
- strlen(_current_categories[4]) + 1 +
- strlen(_current_categories[5]) + 1;
- if (len > sizeof(_current_locale_string))
- return NULL;
- (void) strcpy(_current_locale_string, _current_categories[1]);
- (void) strcat(_current_locale_string, "/");
- (void) strcat(_current_locale_string, _current_categories[2]);
- (void) strcat(_current_locale_string, "/");
- (void) strcat(_current_locale_string, _current_categories[3]);
- (void) strcat(_current_locale_string, "/");
- (void) strcat(_current_locale_string, _current_categories[4]);
- (void) strcat(_current_locale_string, "/");
- (void) strcat(_current_locale_string, _current_categories[5]);
- break;
- }
- return (_current_locale_string);
-}
-
diff --git a/lib/libc/locale/common_setlocale.h b/lib/libc/locale/common_setlocale.h
deleted file mode 100644
index 24b4f31..0000000
--- a/lib/libc/locale/common_setlocale.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#define categories _categories
-extern char *_categories[_LC_LAST];
-
-#define current_categories _current_categories
-extern char _current_categories[_LC_LAST][32];
-
-#define new_categories _new_categories
-extern char _new_categories[_LC_LAST][32];
-
-#define current_locale_string _current_locale_string
-extern char _current_locale_string[_LC_LAST * 33];
-
-#define currentlocale _currentlocale
-extern char *_currentlocale __P((void));
diff --git a/lib/libc/locale/read_runemagi.c b/lib/libc/locale/read_runemagi.c
deleted file mode 100644
index 2d63992..0000000
--- a/lib/libc/locale/read_runemagi.c
+++ /dev/null
@@ -1,133 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include <rune.h>
-#include <stdlib.h>
-
-_RuneLocale *
-_Read_RuneMagi(fp)
- FILE *fp;
-{
- char *data;
- void *lastp;
- _RuneLocale *rl;
- _RuneEntry *rr;
- struct stat sb;
- int x;
-
- if (fstat(fileno(fp), &sb) < 0)
- return(0);
-
- if (sb.st_size < sizeof(_RuneLocale))
- return(0);
-
- if ((data = malloc(sb.st_size)) == NULL)
- return(0);
-
- rewind(fp); /* Someone might have read the magic number once already */
-
- if (fread(data, sb.st_size, 1, fp) != 1) {
- free(data);
- return(0);
- }
-
- rl = (_RuneLocale *)data;
- lastp = data + sb.st_size;
-
- rl->variable = rl + 1;
-
- if (memcmp(rl->magic, _RUNE_MAGIC_1, sizeof(rl->magic))) {
- free(data);
- return(0);
- }
-
- rl->invalid_rune = ntohl(rl->invalid_rune);
- rl->variable_len = ntohl(rl->variable_len);
- rl->runetype_ext.nranges = ntohl(rl->runetype_ext.nranges);
- rl->maplower_ext.nranges = ntohl(rl->maplower_ext.nranges);
- rl->mapupper_ext.nranges = ntohl(rl->mapupper_ext.nranges);
-
- for (x = 0; x < _CACHED_RUNES; ++x) {
- rl->runetype[x] = ntohl(rl->runetype[x]);
- rl->maplower[x] = ntohl(rl->maplower[x]);
- rl->mapupper[x] = ntohl(rl->mapupper[x]);
- }
-
- rl->runetype_ext.ranges = (_RuneEntry *)rl->variable;
- rl->variable = rl->runetype_ext.ranges + rl->runetype_ext.nranges;
- if (rl->variable > lastp) {
- free(data);
- return(0);
- }
-
- rl->maplower_ext.ranges = (_RuneEntry *)rl->variable;
- rl->variable = rl->maplower_ext.ranges + rl->maplower_ext.nranges;
- if (rl->variable > lastp) {
- free(data);
- return(0);
- }
-
- rl->mapupper_ext.ranges = (_RuneEntry *)rl->variable;
- rl->variable = rl->mapupper_ext.ranges + rl->mapupper_ext.nranges;
- if (rl->variable > lastp) {
- free(data);
- return(0);
- }
-
- for (x = 0; x < rl->runetype_ext.nranges; ++x) {
- rr = rl->runetype_ext.ranges;
-
- rr[x].min = ntohl(rr[x].min);
- rr[x].max = ntohl(rr[x].max);
- if ((rr[x].map = ntohl(rr[x].map)) == 0) {
- int len = rr[x].max - rr[x].min + 1;
- rr[x].types = rl->variable;
- rl->variable = rr[x].types + len;
- if (rl->variable > lastp) {
- free(data);
- return(0);
- }
- while (len-- > 0)
- rr[x].types[len] = ntohl(rr[x].types[len]);
- } else
- rr[x].types = 0;
- }
-
- for (x = 0; x < rl->maplower_ext.nranges; ++x) {
- rr = rl->maplower_ext.ranges;
-
- rr[x].min = ntohl(rr[x].min);
- rr[x].max = ntohl(rr[x].max);
- rr[x].map = ntohl(rr[x].map);
- }
-
- for (x = 0; x < rl->mapupper_ext.nranges; ++x) {
- rr = rl->mapupper_ext.ranges;
-
- rr[x].min = ntohl(rr[x].min);
- rr[x].max = ntohl(rr[x].max);
- rr[x].map = ntohl(rr[x].map);
- }
- if (((char *)rl->variable) + rl->variable_len > (char *)lastp) {
- free(data);
- return(0);
- }
-
- /*
- * Go out and zero pointers that should be zero.
- */
- if (!rl->variable_len)
- rl->variable = 0;
-
- if (!rl->runetype_ext.nranges)
- rl->runetype_ext.ranges = 0;
-
- if (!rl->maplower_ext.nranges)
- rl->maplower_ext.ranges = 0;
-
- if (!rl->mapupper_ext.nranges)
- rl->mapupper_ext.ranges = 0;
-
- return(rl);
-}
-
diff --git a/lib/libc/locale/startup_setlocale.c b/lib/libc/locale/startup_setlocale.c
deleted file mode 100644
index 01a6770..0000000
--- a/lib/libc/locale/startup_setlocale.c
+++ /dev/null
@@ -1,198 +0,0 @@
-/* It is reduced version for use in crt0.c (only 8 bit locales) */
-
-#include <limits.h>
-#include <locale.h>
-#include <rune.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "common_setlocale.h"
-#include "common_rune.h"
-
-char *_PathLocale;
-
-extern int _none_init __P((_RuneLocale *));
-static char *loadlocale __P((int));
-static int startup_setrunelocale __P((char *));
-
-void
-_startup_setlocale(category, locale)
- int category;
- const char *locale;
-{
- int found, i, len;
- char *env, *r;
-
- if (!PathLocale && !(PathLocale = getenv("PATH_LOCALE")))
- PathLocale = _PATH_LOCALE;
-
- if (category < 0 || category >= _LC_LAST)
- return;
-
- if (!locale) {
- if (!category)
- (void) currentlocale();
- return;
- }
-
- /*
- * Default to the current locale for everything.
- */
- for (i = 1; i < _LC_LAST; ++i)
- (void)strcpy(new_categories[i], current_categories[i]);
-
- /*
- * Now go fill up new_categories from the locale argument
- */
- if (!*locale) {
- env = getenv(categories[category]);
-
- if (!env)
- env = getenv(categories[0]);
-
- if (!env)
- env = getenv("LANG");
-
- if (!env)
- env = "C";
-
- (void) strncpy(new_categories[category], env, 31);
- new_categories[category][31] = 0;
- if (!category) {
- for (i = 1; i < _LC_LAST; ++i) {
- if (!(env = getenv(categories[i])))
- env = new_categories[0];
- (void)strncpy(new_categories[i], env, 31);
- new_categories[i][31] = 0;
- }
- }
- } else if (category) {
- (void)strncpy(new_categories[category], locale, 31);
- new_categories[category][31] = 0;
- } else {
- if ((r = strchr(locale, '/')) == 0) {
- for (i = 1; i < _LC_LAST; ++i) {
- (void)strncpy(new_categories[i], locale, 31);
- new_categories[i][31] = 0;
- }
- } else {
- for (i = 1; r[1] == '/'; ++r);
- if (!r[1])
- return; /* Hmm, just slashes... */
- do {
- len = r - locale > 31 ? 31 : r - locale;
- (void)strncpy(new_categories[i++], locale, len);
- new_categories[i++][len] = 0;
- locale = r;
- while (*locale == '/')
- ++locale;
- while (*++r && *r != '/');
- } while (*locale);
- while (i < _LC_LAST)
- (void)strcpy(new_categories[i],
- new_categories[i-1]);
- }
- }
-
- if (category) {
- (void) loadlocale(category);
- return;
- }
-
- found = 0;
- for (i = 1; i < _LC_LAST; ++i)
- if (loadlocale(i) != NULL)
- found = 1;
- if (found)
- (void) currentlocale();
-}
-
-static char *
-loadlocale(category)
- int category;
-{
- if (strcmp(new_categories[category],
- current_categories[category]) == 0)
- return (current_categories[category]);
-
- if (category == LC_CTYPE) {
- if (startup_setrunelocale(new_categories[LC_CTYPE]))
- return (NULL);
- (void)strcpy(current_categories[LC_CTYPE],
- new_categories[LC_CTYPE]);
- return (current_categories[LC_CTYPE]);
- }
-
- if (category == LC_COLLATE) {
- if (__collate_load_tables(new_categories[LC_COLLATE]) < 0)
- return (NULL);
- (void)strcpy(current_categories[LC_COLLATE],
- new_categories[LC_COLLATE]);
- return (current_categories[LC_COLLATE]);
- }
-
- if (category == LC_TIME) {
- if (__time_load_locale(new_categories[LC_TIME]) < 0)
- return (NULL);
- (void)strcpy(current_categories[LC_TIME],
- new_categories[LC_TIME]);
- return (current_categories[LC_TIME]);
- }
-
- if (!strcmp(new_categories[category], "C") ||
- !strcmp(new_categories[category], "POSIX")) {
-
- /*
- * Some day this will need to reset the locale to the default
- * C locale. Since we have no way to change them as of yet,
- * there is no need to reset them.
- */
- (void)strcpy(current_categories[category],
- new_categories[category]);
- return (current_categories[category]);
- }
-
- return NULL;
-}
-
-static int
-startup_setrunelocale(encoding)
- char *encoding;
-{
- FILE *fp;
- char name[PATH_MAX];
- _RuneLocale *rl;
-
- if (!encoding)
- return(EFAULT);
-
- /*
- * The "C" and "POSIX" locale are always here.
- */
- if (!strcmp(encoding, "C") || !strcmp(encoding, "POSIX")) {
- _CurrentRuneLocale = &_DefaultRuneLocale;
- return(0);
- }
-
- (void) strcpy(name, PathLocale);
- (void) strcat(name, "/");
- (void) strcat(name, encoding);
- (void) strcat(name, "/LC_CTYPE");
-
- if ((fp = fopen(name, "r")) == NULL)
- return(ENOENT);
-
- if ((rl = _Read_RuneMagi(fp)) == 0) {
- fclose(fp);
- return(EFTYPE);
- }
- fclose(fp);
-
- if (!rl->encoding[0])
- return(EINVAL);
- else if (!strcmp(rl->encoding, "NONE"))
- return(_none_init(rl));
- else
- return(EINVAL);
-}
-
diff --git a/lib/libforms/Makefile.orig b/lib/libforms/Makefile.orig
deleted file mode 100644
index 7ed0abf..0000000
--- a/lib/libforms/Makefile.orig
+++ /dev/null
@@ -1,12 +0,0 @@
-LIB = forms
-
-SRCS = forms.c
-
-CFLAGS += -I. -I${.CURDIR} -Wall -g
-
-beforeinstall:
- @(cd ${.CURDIR}; cmp -s forms.h ${DESTDIR}/usr/include/forms.h || \
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 forms.h \
- ${DESTDIR}/usr/include/forms.h;)
-
-.include <bsd.lib.mk>
diff --git a/lib/libforms/examples/test.c b/lib/libforms/examples/test.c
deleted file mode 100644
index d587354..0000000
--- a/lib/libforms/examples/test.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 1995 Paul Richards.
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- */
-
-#include <stdio.h>
-#include "../forms.h"
-
-main()
-{
-
- int res;
-
- char *string0 = "A simple demo of the current forms widgets";
- char *string1 = "Hey, I can flash boldly";
- char *string2 = "This is an input field with default:";
- char *string4 = "This is a labelled input field:";
- char *string6 = "Some options to choose from: ";
-
- char *options7[] = {"Choose", "one", "of", "these"};
-
- struct text_field field0 = {string0};
- struct text_field field1 = {string1};
- struct text_field field2 = {string2};
- struct input_field field3 = {0,"Default entry",0};
- struct text_field field4 = {string4};
- struct input_field field5 = {1,"A place filler",0};
- struct text_field field6 = {string6};
- struct menu_field field7 = {sizeof &options7, 0, options7};
- struct action_field field8 = {"EXIT",&exit_form};
- struct action_field field9 = {"CANCEL",&cancel_form};
-
- struct field field[] = {
- {F_TEXT, 0, 15, 80, 80, A_BOLD,
- 0, 0, 0, 0, 0, (struct text_field *)&field0},
- {F_TEXT, 3, 23, 25, 15, A_BLINK|A_BOLD,
- 0, 0, 0, 0, 0, &field1},
- {F_TEXT, 7, 2, 40, 40, F_DEFATTR,
- 0, 0, 0, 0, 0, &field2},
- {F_INPUT, 7, 45, 15, 30, F_DEFATTR,
- 5, -1, 5, -1, -1, (struct text_field *)&field3},
- {F_TEXT, 11, 2, 40, 40, F_DEFATTR,
- 0, 0, 0, 0, 0, &field4},
- {F_INPUT, 11, 45, 15, 30, F_DEFATTR,
- 7, 3, 7, -1, -1, (struct text_field *)&field5},
- {F_TEXT, 15, 2, 40, 40, F_DEFATTR,
- 0, 0, 0, 0, 0, (struct text_field *)&field6},
- {F_MENU, 15, 45, 10, 10, F_DEFATTR,
- 8, 5, 8, -1, -1, (struct text_field *)&field7},
- {F_ACTION, 20, 20, 6, 6, (A_BOLD|A_REVERSE),
- 0, 7, -1, -1, 9, (struct text_field *)&field8},
- {F_ACTION, 20, 43, 6, 6, (A_BOLD|A_REVERSE),
- 3, 3, 3, 7, 3, (struct text_field *)&field9},
- {F_END, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
- };
-
- struct form form = {0, 3, field, 24, 80, 0, 0, 0};
- form.field = field;
-
- initscr();
-
- initfrm(&form);
- if (!form.window) {
- fprintf(stderr, "\nUnable to initialize forms library.\n");
- endwin();
- exit(1);
- }
- keypad(form.window, TRUE);
- while (!(res = update_form(&form)));
-
-
- wclear(form.window);
- wrefresh(form.window);
-
- if (res == F_DONE) {
- printf("You're entries were:\n\n");
- printf("%s\n",field[3].field.input->input);
- printf("%s\n",field[5].field.input->input);
- printf("%s\n",field[7].field.menu->options[field[7].field.menu->selected]);
- } else if (res == F_CANCEL)
- printf("You cancelled the form\n");
-
- endfrm(&form);
- endwin();
-}
diff --git a/lib/libforms/examples/tform.c b/lib/libforms/examples/tform.c
deleted file mode 100644
index 48f4d48..0000000
--- a/lib/libforms/examples/tform.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ncurses.h>
-#include <dialog.h>
-#include <forms.h>
-
-extern struct form *form;
-
-void
-main()
-{
- printf("Testing forms code\n");
-
- if (init_forms("example.frm") == -1)
- exit(1);
-
- edit_form(form);
-}
diff --git a/lib/libforms/fields.c b/lib/libforms/fields.c
deleted file mode 100644
index ce4187d..0000000
--- a/lib/libforms/fields.c
+++ /dev/null
@@ -1,678 +0,0 @@
-/*-
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <strhash.h>
-#include <ctype.h>
-#include <err.h>
-#include <ncurses.h>
-#include <forms.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "internal.h"
-
-extern hash_table *global_bindings;
-
-struct attr_cmd {
- char *name;
- int attr;
-};
-
-static struct attr_cmd attr_cmds[] = {
- { "standout", 0x00010000},
- { "underline", 0x00020000},
- { "reverse", 0x00040000},
- { "blink", 0x00080000},
- { "bold", 0x00200000 }
-};
-
-int done=0;
-
-int
-init_field(char *key, void *data, void *arg)
-{
- struct Tuple *tuple = (struct Tuple *)data;
- struct Tuple *def_tuple;
- struct Field *def, *field;
- int i;
- int len, lim;
- int strwidth;
-
- field = (struct Field *)tuple->addr;
-
- /* Field definitions are global, at least for now */
- def_tuple = form_get_tuple(global_bindings, field->defname, FT_FIELD_DEF);
- if (!def_tuple) {
- warnx("Field definition not found -- skipping field");
- return (-1);
- }
-
- def = (struct Field *)def_tuple->addr;
- field->height = def->height;
- field->width = def->width;
- field->attr = def->attr;
- field->selattr = def->selattr;
- field->type = def->type;
- switch (field->type) {
- case FF_INPUT:
- field->field.input = malloc(sizeof (struct InputField));
- if (!field->field.input) {
- warnx("Couldn't allocate memory for input field");
- return (-1);
- }
- field->field.input->limit = def->field.input->limit;
-
- /* Force height to one regardless, at least for now :-) */
- field->height = 1;
- if (!field->width && !field->field.input->limit) {
- field->width = calc_string_width(def->field.input->label);
- field->field.input->limit = field->width;
- } else if (!field->width)
- field->width = field->field.input->limit;
- else if (!field->field.input->limit)
- field->field.input->limit = field->width;
- if (field->field.input->limit < field->width)
- field->width = field->field.input->limit;
-
- strwidth = strlen(def->field.input->label);
- field->field.input->input = malloc(strwidth + 1);
- if (!field->field.input->input) {
- warnx("Couldn't allocate memory for input field text");
- return (-1);
- }
- field->field.input->label = malloc(strwidth + 1);
- if (!field->field.input->label) {
- warnx("Couldn't allocate memory for input field label");
- return (-1);
- }
- strncpy(field->field.input->label,
- def->field.input->label,
- strwidth + 1);
- field->field.input->lbl_flag = def->field.input->lbl_flag;
-
- /*
- * If it's a label then clear the input string
- * otherwise copy the default there.
- */
- if (field->field.input->lbl_flag)
- field->field.input->input[0] = '\0';
- else if (field->field.input->label) {
- strncpy(field->field.input->input,
- field->field.input->label,
- strwidth + 1);
- field->field.input->input[strwidth] = 0;
- }
- break;
- case FF_TEXT:
- field->field.text = malloc(sizeof (struct TextField));
- if (!field->field.text) {
- warnx("Couldn't allocate memory for text field");
- return (FS_ERROR);
- }
- strwidth = strlen(def->field.text->text);
- if (!field->width)
- field->width = calc_string_width(def->field.text->text);
- field->field.text->text = malloc(strwidth + 1);
- if (!field->field.text->text) {
- warnx("Couldn't allocate memory for text field text");
- return (FS_ERROR);
- } else
- strncpy(field->field.text->text,
- def->field.text->text,
- strwidth + 1);
- if (!field->height)
- calc_field_height(field, field->field.text->text);
- break;
- case FF_MENU:
- field->field.menu = malloc(sizeof (struct MenuField));
- if (!field->field.menu) {
- warnx("Couldn't allocate memory for menu field");
- return (FS_ERROR);
- }
- field->field.menu->no_options = 0;
- field->height = 1;
- lim = 0;
- for (i=0; i < def->field.menu->no_options; i++) {
- field->field.menu->no_options =
- add_menu_option(field->field.menu,
- def->field.menu->options[i]);
- if (!field->field.menu->no_options) {
- warnx("Couldn't add menu option");
- return (FS_ERROR);
- }
- len = calc_string_width(def->field.menu->options[i]);
- if (len > lim)
- lim = len;
- }
- if (!field->width)
- field->width = lim;
- break;
- case FF_ACTION:
- field->field.action = malloc(sizeof (struct ActionField));
- if (!field->field.action) {
- warnx("Couldn't allocate memory for action field");
- return (FS_ERROR);
- }
- if (!field->width)
- field->width = calc_string_width(def->field.action->text);
- strwidth = strlen(def->field.action->text);
- field->field.action->text = malloc(strwidth + 1);
- if (!field->field.action->text) {
- warnx("Couldn't allocate memory for text field text");
- return (FS_ERROR);
- } else
- strncpy(field->field.action->text,
- def->field.action->text,
- strwidth + 1);
- if (!field->height)
- calc_field_height(field, field->field.action->text);
- field->field.action->fn = def->field.action->fn;
- break;
- default:
- break;
- }
- return (1);
-}
-
-void
-display_field(WINDOW *window, struct Field *field)
-{
- wattrset(window, field->attr);
- wmove(window, field->y, field->x);
- switch (field->type) {
- case FF_TEXT:
- display_text(window, field);
- break;
- case FF_MENU:
- display_menu(window, field);
- break;
- case FF_INPUT:
- display_input(window, field);
- break;
- case FF_ACTION:
- display_action(window, field);
- break;
- case FF_UNKNOWN:
- default:
- break;
- }
- wattrset(window, 0);
- wrefresh(window);
-}
-
-void
-display_text(WINDOW *window, struct Field *field)
-{
-
- if (print_string(window, field->y, field->x, field->height,
- field->width, field->field.text->text) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-void
-display_input(WINDOW *window, struct Field *field)
-{
- if (field->field.input->lbl_flag) {
- if (print_string(window, field->y, field->x, field->height,
- field->width, field->field.input->label) == ERR)
- print_status("Illegal scroll in print_string");
- } else
- if (print_string(window, field->y, field->x, field->height,
- field->width, field->field.input->input) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-void
-display_menu(WINDOW *window, struct Field *field)
-{
- if (print_string(window, field->y, field->x,
- field->height, field->width,
- field->field.menu->options[field->field.menu->selected]) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-void
-display_action(WINDOW *window, struct Field *field)
-{
- if (print_string(window, field->y, field->x, field->height,
- field->width,
- field->field.action->text) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-int
-do_action(struct Form *form)
-{
- struct Field *field = form->current_field;
- struct Tuple *tuple;
- int ch;
- void (* fn)();
-
- display_action(form->window, field);
- wmove(form->window, field->y, field->x);
-
- for (;;) {
-
- ch = wgetch(form->window);
-
- if (ch == FK_ACCEPT) {
- tuple = form_get_tuple(form->bindings, field->field.action->fn, FT_FUNC);
- if (!tuple) {
- print_status("No function bound to action");
- beep();
- continue;
- } else {
- fn = tuple->addr;
- (*fn)(form);
- return (FS_OK);
- }
- } else
- ch = do_key_bind(form, ch);
-
- if (ch == FS_OK)
- return (FS_OK);
- else if (ch == FS_ERROR)
- continue;
- }
-}
-
-int
-do_menu(struct Form *form)
-{
- struct Field *field = form->current_field;
- int ch;
-
-
- for (;;) {
-
- display_menu(form->window, field);
- wmove(form->window, field->y, field->x);
-
- ch = wgetch(form->window);
-
- switch (ch) {
- case ' ':
- print_status("");
- field->field.menu->selected++;
- if (field->field.menu->selected >= field->field.menu->no_options)
- field->field.menu->selected = 0;
- ch = FS_OK;
- break;
- default:
- ch = do_key_bind(form, ch);
- break;
- }
-
- if (ch == FS_OK)
- return (FS_OK);
- else if (ch == FS_ERROR) {
- beep();
- continue;
- } else {
- print_status("Hit the space bar to toggle through options");
- beep();
- continue;
- }
- }
-}
-
-int
-do_field(struct Form *form)
-{
- struct Tuple *tuple;
- struct Field *field = form->current_field;
- void (* fn)();
- int status;
-
- /* Do field entry tasks */
- if (field->enter) {
- tuple = form_get_tuple(form->bindings, field->enter, FT_FUNC);
-
- if (tuple) {
- fn = tuple->addr;
- (*fn)(form);
- }
- }
-
- switch (field->type) {
- case FF_TEXT:
- status = FS_OK;
- display_text(form->window, field);
- break;
- case FF_INPUT:
- status = do_input(form);
- break;
- case FF_MENU:
- status = do_menu(form);
- break;
- case FF_ACTION:
- status = do_action(form);
- break;
- default:
- status = FF_UNKNOWN;
- beep();
- print_status("Unknown field type");
- form->current_field = form->prev_field;
- break;
- }
-
- /* Do field leave tasks */
- if (field->leave) {
- tuple = form_get_tuple(form->bindings, field->leave, FT_FUNC);
-
- if (tuple) {
- fn = tuple->addr;
- (*fn)(form);
- }
- }
-
- return (status);
-}
-
-int
-parse_attr(WINDOW *window, char *string)
-{
- int inc = 0;
- struct attr_cmd *attr;
-
- if (*(string) == '\\')
- return (1);
-
- while (!isspace(*(string + inc))) {
- inc++;
- }
-
- for (attr = attr_cmds; attr->name; attr++) {
- if (strncmp(attr->name, string, inc))
- continue;
- else {
- wattron(window, attr->attr);
- break;
- }
- }
-
- /* Skip trailing space after the attribute string */
- while (isspace(*(string + inc)))
- inc++;
-
- return (inc);
-}
-
-int
-print_string(WINDOW *window, int y, int x,
- int height, int fwidth, char *string)
-{
- int len, skip;
- int width;
-
- if (!string)
- len = -1;
-
- len = strlen(string);
-
- if (wmove(window, y, x) == ERR)
- return (ERR);
- while (height--) {
- width = fwidth;
- while (width--) {
- if (len-- > 0) {
- if (*string == '\\') {
- string++;
- len--;
- skip = parse_attr(window, string);
- len -= skip;
- string += skip;
- }
- if (waddch(window, *string++) == ERR)
- return (ERR);
- } else if (waddch(window, ' ') == ERR)
- return (ERR);
- }
- if (wmove(window, ++y, x) == ERR)
- return (ERR);
- }
- return (OK);
-}
-
-void
-print_status(char *msg)
-{
- if (wmove(stdscr, LINES-1, 0) == ERR) {
- endwin();
- exit(1);
- }
-
- wclrtoeol(stdscr);
-
- wstandout(stdscr);
- if (wprintw(stdscr, "%s",
- msg) == ERR) {
- endwin();
- exit(1);
- }
- wstandend(stdscr);
- wrefresh(stdscr);
-}
-
-
-int
-do_input(struct Form *form)
-{
- struct Field *field = form->current_field;
- int len;
- int disp_off=0, abspos=0, cursor = 0;
- unsigned int ch;
-
-#define DISPOFF ((len < field->width) ? 0 : len - field->width)
-#define CURSPOS ((len < field->width) ? len : field->width)
-
- len = strlen(field->field.input->input);
- display_input(form->window, field);
-
- cursor = CURSPOS;
- abspos = cursor;
-
- for (;;) {
-
- wmove(form->window, field->y, field->x+cursor);
- wrefresh(form->window);
-
- ch = wgetch(form->window);
- ch = do_key_bind(form, ch);
-
- /*
- * If there was a valid motion command then we've
- * moved to a new field so just return. If the motion
- * command was invalid then just go around and get another
- * keystroke. Otherwise, it was not a motion command.
- */
-
- if (ch == FS_OK)
- return (FS_OK);
- else if (ch == FS_ERROR)
- continue;
-
- print_status("");
-
- if (field->field.input->lbl_flag) {
- field->field.input->lbl_flag = 0;
- }
- if ((ch == FK_CHOME) || (ch == '')) {
- disp_off = 0;
- cursor = 0;
- abspos = 0;
- } else if ((ch == FK_CEND) || (ch == '')) {
- disp_off = DISPOFF;
- abspos = len;
- cursor = CURSPOS;
- } else if (ch == FK_CDEL) {
- if (!(len-abspos))
- beep();
- else {
- bcopy(field->field.input->input+abspos+1,
- field->field.input->input+abspos,
- len - abspos);
- --len;
- }
- } else if ((ch == FK_CLEFT) || (ch == FK_CBS) || (ch == '')) {
- if (!abspos)
- beep();
- else {
- if (ch == FK_CBS) {
- bcopy(field->field.input->input+abspos,
- field->field.input->input+abspos-1,
- len-abspos+1);
- --len;
- }
- --abspos;
- --cursor;
- if ((disp_off) && (cursor < 0)) {
- --disp_off;
- ++cursor;
- }
- }
- } else if ((ch == FK_CRIGHT) || (ch == '')) {
- if (abspos == len)
- beep();
- else {
- ++abspos;
- if (++cursor >= field->width) {
- ++disp_off;
- --cursor;
- }
- }
- } else if ((isprint(ch)) && (len < field->field.input->limit)){
- bcopy(field->field.input->input+abspos,
- field->field.input->input+abspos+1, len-abspos+1);
- field->field.input->input[abspos++] = ch;
- len++;
- if (++cursor > field->width) {
- ++disp_off;
- --cursor;
- }
- } else
- beep();
- print_string(form->window, field->y, field->x, field->height,
- field->width, field->field.input->input+disp_off);
- }
-}
-
-/*
- * Calculate length of printable part of the string,
- * stripping out the attribute modifiers.
- */
-
-int
-calc_string_width(char *string)
-{
- int len, width=0;
-
- if (!string)
- return (0);
-
- len = strlen(string);
-
- while (len) {
- if (*string != '\\') {
- width++;
- len--;
- string++;
- continue;
- } else {
- string++;
- len--;
- if (*string == '\\') {
- string++;
- width++;
- len--;
- continue;
- } else {
- while (!isspace(*string)) {
- string++;
- len--;
- }
- while (isspace(*string)) {
- string ++;
- len--;
- }
- }
- }
- }
-
- return (width);
-}
-
-/* Calculate a default height for a field */
-
-void
-calc_field_height(struct Field *field, char *string)
-{
-
- int len;
-
- len = calc_string_width(string);
-
- if (!field->width) {
- /*
- * This is a failsafe, this routine shouldn't be called
- * with a width of 0, the width should be determined
- * first.
- */
- field->height = 1;
- return;
- }
-
- if (len < field->width) {
- field->height = 1;
- return;
- } else
- field->height = len / field->width;
-
- if ((field->height*field->width) < len)
- field->height++;
-
- return;
-}
-
-void
-exit_form(struct Form *form)
-{
- form->status = FS_EXIT;
-}
-
-void
-cancel_form(struct Form *form)
-{
- form->status = FS_CANCEL;
-}
diff --git a/lib/libforms/forms.c.orig b/lib/libforms/forms.c.orig
deleted file mode 100644
index 6787d8e..0000000
--- a/lib/libforms/forms.c.orig
+++ /dev/null
@@ -1,502 +0,0 @@
-/*-
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <forms.h>
-#include <ncurses.h>
-
-#include "internal.h"
-
-unsigned int f_keymap[] = {
- KEY_UP, /* F_UP */
- KEY_DOWN, /* F_DOWN */
- 9, /* F_RIGHT */
- 8, /* F_LEFT */
- 10, /* F_NEXT */
- KEY_LEFT, /* F_CLEFT */
- KEY_RIGHT, /* F_CRIGHT */
- KEY_HOME, /* F_CHOME */
- KEY_END, /* F_CEND */
- 263, /* F_CBS */
- 330, /* F_CDEL */
- 10 /* F_ACCEPT */
-};
-
-int done=0;
-
-int
-initfrm(struct form *form)
-{
-
- struct field *field = &form->field[0];
- int i;
-
- if (has_colors()) {
- start_color();
- if (form->color_table)
- for (i=0; form->color_table[i].f != -1; i++) {
- init_pair(i+1, form->color_table[i].f, form->color_table[i].b);
- }
- }
- cbreak();
- noecho();
-
- if (!form->height)
- form->height = LINES;
- if (!form->width)
- form->width = COLS;
-
- form->window = newwin(form->height, form->width, form->y, form->x);
- if (!form->window) {
- print_status("Couldn't open window, closing form");
- return (ERR);
- }
- form->no_fields = 0;
-
- keypad(form->window, TRUE);
-
-
- while (field->type != F_END) {
- if (field->type == F_INPUT) {
- field->field.input->input = malloc(field->field.input->limit);
- if (!field->field.input->input){
- print_status("Couldn't allocate memory, closing form");
- endfrm(form);
- return (ERR);
- }
- /*
- * If it's a label then clear the input string
- * otherwise copy the default string to the input string.
- */
- if (field->field.input->lbl_flag)
- field->field.input->input[0] = '\0';
- else if (field->field.input->label) {
- strncpy(field->field.input->input,
- field->field.input->label,
- field->field.input->limit);
- field->field.input->input[field->field.input->limit] = 0;
- }
- } else if ((field->type != F_TEXT) && (field->type != F_MENU) &&
- (field->type != F_ACTION)) {
- print_status("Unknown field type, closing form");
- endfrm(form);
- return (ERR);
- }
- form->no_fields++;
- field = &form->field[form->no_fields];
- }
- form->current_field = form->start_field;
- show_form(form);
- return (OK);
-}
-
-void
-endfrm(struct form *form)
-{
-
- struct field *field = &form->field[0];
- int i;
-
- delwin(form->window);
-
- for (i=0; i < form->no_fields; i++) {
- if (field->type == F_INPUT)
- free(field->field.input->input);
- field = &form->field[i];
- }
-}
-
-int
-update_form(struct form *form)
-{
- show_form(form);
-
- if (form->current_field == -1)
- return (F_CANCEL);
-
- wattrset(form->window, form->field[form->current_field].selattr);
- switch (form->field[form->current_field].type) {
- case F_MENU:
- field_menu(form);
- break;
- case F_INPUT:
- field_input(form);
- break;
- case F_ACTION:
- field_action(form);
- break;
- case F_TEXT:
- default:
- print_status("Error, current field is invalid");
- return (F_CANCEL);
- }
- wattrset(form->window, 0);
-
- return (done);
-}
-
-static void
-show_form(struct form *form)
-{
- int i;
- int y, x;
-
- wattrset(form->window, form->attr);
- for (y = 0; y < form->height; y++)
- for (x = 0; x < form->width; x++)
- mvwaddch(form->window, y, x, ' ');
-
- for (i=0; i < form->no_fields; i++) {
- wattrset(form->window, form->field[i].attr);
- wmove(form->window, form->field[i].y, form->field[i].x);
- switch (form->field[i].type) {
- case F_TEXT:
- disp_text(form, i);
- break;
- case F_MENU:
- disp_menu(form, i);
- break;
- case F_INPUT:
- disp_input(form,i);
- break;
- case F_ACTION:
- disp_action(form,i);
- break;
- case F_END:
- default:
- break;
- }
- }
- wattrset(form->window, 0);
- wrefresh(form->window);
-}
-
-static void
-disp_text(struct form *form, int index)
-{
-
- struct field *field = &form->field[index];
-
- if (print_string(form->window, field->y, field->x, field->height,
- field->width, field->field.text->text) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-static void
-disp_input(struct form *form, int index)
-{
-
- struct field *field = &form->field[index];
-
- if (field->field.input->lbl_flag) {
- if (print_string(form->window, field->y, field->x, field->height,
- field->width, field->field.input->label) == ERR)
- print_status("Illegal scroll in print_string");
- } else
- if (print_string(form->window, field->y, field->x, field->height,
- field->width, field->field.input->input) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-static void
-disp_menu(struct form *form, int index)
-{
- struct field *field = &form->field[index];
-
- if (print_string(form->window, field->y, field->x, field->height,
- field->width,
- field->field.menu->options[field->field.menu->selected]) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-static void
-disp_action(struct form *form, int index)
-{
- struct field *field = &form->field[index];
-
- if (print_string(form->window, field->y, field->x, field->height,
- field->width,
- field->field.action->text) == ERR)
- print_status("Illegal scroll in print_string");
-}
-
-static void
-field_action(struct form *form)
-{
-
- struct field *field = &form->field[form->current_field];
- int ch;
-
- for (;;) {
- disp_action(form, form->current_field);
- wmove(form->window, field->y, field->x);
- ch = wgetch(form->window);
- if (ch == F_ACCEPT) {
- (*field->field.action->fn)();
- return;
- } else if (!next_field(form, ch))
- beep();
- else
- return;
- }
-}
-
-static void
-field_menu(struct form *form)
-{
- struct field *field = &form->field[form->current_field];
- int ch;
-
- for (;;) {
- disp_menu(form, form->current_field);
- wmove(form->window, field->y, field->x);
- switch (ch = wgetch(form->window)) {
- case ' ':
- print_status("");
- field->field.menu->selected++;
- if (field->field.menu->selected >= field->field.menu->no_options)
- field->field.menu->selected = 0;
- break;
- default:
- if (!next_field(form, ch)) {
- print_status("Hit the space bar to toggle through options");
- beep();
- } else
- return;
- }
- }
-}
-
-static int
-next_field(struct form *form, int ch)
-{
-
- struct field *field = &form->field[form->current_field];
-
- if (ch == F_UP) {
- if (field->up == -1) {
- print_status("Can't go up from here");
- return (0);
- } else
- form->current_field = field->up;
- } else if (ch == F_DOWN) {
- if (field->down == -1) {
- print_status("Can't go down from here");
- return (0);
- } else
- form->current_field = field->down;
- } else if (ch == F_NEXT) {
- if (field->next == -1) {
- print_status("Can't go to next from here");
- return (0);
- } else
- form->current_field = field->next;
- } else if (ch == F_RIGHT) {
- if (field->right == -1) {
- print_status("Can't go right from here");
- return (0);
- } else
- form->current_field = field->right;
- } else if (ch == F_LEFT) {
- if (field->left == -1) {
- print_status("Can't go left from here");
- return (0);
- } else
- form->current_field = field->left;
- } else
- return (0);
-
- print_status("");
- return (1);
-}
-
-static int
-print_string(WINDOW *window, int y, int x,
- int height, int fwidth, char *string)
-{
- int len;
- int width;
-
- if (!string)
- len = -1;
-
- len = strlen(string);
-
- if (wmove(window, y, x) == ERR)
- return (ERR);
- while (height--) {
- width = fwidth;
- while (width--) {
- if (len-- > 0) {
- if (waddch(window, *string++) == ERR)
- return (ERR);
- } else
- if (waddch(window, ' ') == ERR)
- return (ERR);
- }
- if (wmove(window, ++y, x) == ERR)
- return (ERR);
-
- }
- return (OK);
-}
-
-void
-print_status(char *msg)
-{
- if (wmove(stdscr, LINES-1, 0) == ERR) {
- endwin();
- exit(1);
- }
-
- wclrtoeol(stdscr);
-
- wstandout(stdscr);
- if (wprintw(stdscr, "%s",
- msg) == ERR) {
- endwin();
- exit(1);
- }
- wstandend(stdscr);
- wrefresh(stdscr);
-}
-
-
-void
-field_input(struct form *form)
-{
- struct field *field = &form->field[form->current_field];
- int len;
- int ch;
- int disp_off=0, abspos=0, cursor = 0;
-
-#define DISPOFF ((len < field->width) ? 0 : len - field->width)
-#define CURSPOS ((len < field->width) ? len : field->width)
-
- len = strlen(field->field.input->input);
- disp_input(form, form->current_field);
-
- cursor = CURSPOS;
- abspos = cursor;
-
- for(;;) {
-
- wmove(form->window, field->y, field->x+cursor);
- wrefresh(form->window);
-
- ch = wgetch(form->window);
- if (next_field(form, ch)) {
- print_string(form->window, field->y, field->x,
- field->height, field->width,
- field->field.input->input+DISPOFF);
- return;
- }
- if (field->field.input->lbl_flag) {
- field->field.input->lbl_flag = 0;
- }
- if ((ch == F_CHOME) || (ch == '')) {
- disp_off = 0;
- cursor = 0;
- abspos = 0;
- } else if ((ch == F_CEND) || (ch == '')) {
- disp_off = DISPOFF;
- abspos = len;
- cursor = CURSPOS;
- } else if (ch == F_CDEL) {
- if (!(len-abspos))
- beep();
- else {
- bcopy(field->field.input->input+abspos+1,
- field->field.input->input+abspos,
- len - abspos);
- --len;
- }
- } else if ((ch == F_CLEFT) || (ch == F_CBS) || (ch == '')) {
- if (!abspos)
- beep();
- else {
- if (ch == F_CBS) {
- bcopy(field->field.input->input+abspos,
- field->field.input->input+abspos-1,
- len-abspos+1);
- --len;
- }
- --abspos;
- --cursor;
- if ((disp_off) && (cursor < 0)) {
- --disp_off;
- ++cursor;
- }
- }
- } else if ((ch == F_CRIGHT) || (ch == '')) {
- if (abspos == len)
- beep();
- else {
- ++abspos;
- if (++cursor == field->width) {
- ++disp_off;
- --cursor;
- }
- }
- } else if ((isprint(ch)) && (len < field->field.input->limit)){
- bcopy(field->field.input->input+abspos,
- field->field.input->input+abspos+1, len-abspos+1);
- field->field.input->input[abspos++] = ch;
- len++;
- if (++cursor > field->width) {
- ++disp_off;
- --cursor;
- }
- } else {
- beep();
- }
- print_string(form->window, field->y, field->x, field->height,
- field->width, field->field.input->input+disp_off);
- }
- /* Not Reached */
-}
-
-void
-exit_form(void)
-{
- done = F_DONE;
-}
-
-void
-cancel_form(void)
-{
- done = F_CANCEL;
-}
diff --git a/lib/libforms/forms.h.orig b/lib/libforms/forms.h.orig
deleted file mode 100644
index 36031be..0000000
--- a/lib/libforms/forms.h.orig
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <ncurses.h>
-
-#define F_END 0
-#define F_TEXT 1
-#define F_ACTION 2
-#define F_INPUT 3
-#define F_MENU 4
-
-#define F_DEFATTR 0
-#define F_SELATTR A_REVERSE
-
-#define F_DONE 1
-#define F_CANCEL -1
-
-struct col_pair {
- int f;
- int b;
-};
-
-struct form {
- int no_fields;
- int start_field;
- int current_field;
- struct field *field;
- int height;
- int width;
- int y;
- int x;
- int attr;
- struct col_pair *color_table;
- WINDOW *window;
-};
-
-struct text_field {
- char *text;
-};
-
-struct action_field {
- char *text;
- void (* fn)();
-};
-
-struct input_field {
- int lbl_flag;
- char *label;
- char *input;
- int limit;
-};
-
-struct menu_field {
- int no_options;
- int selected;
- char **options;
-};
-
-struct help_link {
-};
-
-struct field {
- int type;
- int y;
- int x;
- int height;
- int width;
- int attr;
- int selattr;
- int next;
- int up;
- int down;
- int left;
- int right;
- union {
- struct text_field *text;
- struct action_field *action;
- struct input_field *input;
- struct menu_field *menu;
- }field;
- /*
- struct help_link help;
- */
-};
-
-/* Externally visible keymap table for user-definable keymaps */
-extern unsigned int keymap[];
-
-/* Externally visible function declarations */
-int update_form(struct form *);
-int initfrm(struct form *);
-void endfrm(struct form *);
-void exit_form(void);
-void cancel_form(void);
-void print_status(char *);
diff --git a/lib/libforms/internal.h.orig b/lib/libforms/internal.h.orig
deleted file mode 100644
index 6895de2..0000000
--- a/lib/libforms/internal.h.orig
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 1995 Paul Richards.
- *
- * All rights reserved.
- *
- * This software may be used, modified, copied, distributed, and
- * sold, in both source and binary form provided that the above
- * copyright and these terms are retained, verbatim, as the first
- * lines of this file. Under no circumstances is the author
- * responsible for the proper functioning of this software, nor does
- * the author assume any responsibility for damages incurred with
- * its use.
- */
-
-#define F_UP f_keymap[0]
-#define F_DOWN f_keymap[1]
-#define F_RIGHT f_keymap[2]
-#define F_LEFT f_keymap[3]
-#define F_NEXT f_keymap[4]
-#define F_CLEFT f_keymap[5]
-#define F_CRIGHT f_keymap[6]
-#define F_CHOME f_keymap[7]
-#define F_CEND f_keymap[8]
-#define F_CBS f_keymap[9]
-#define F_CDEL f_keymap[10]
-#define F_ACCEPT f_keymap[11]
-
-/* Private function declarations */
-static void show_form(struct form *);
-static void disp_text(struct form *, int);
-static void disp_menu(struct form *, int);
-static void disp_action(struct form *, int);
-static void disp_input(struct form *, int);
-static void field_menu(struct form *);
-static void field_input(struct form *);
-static void field_action(struct form *);
-static int print_string(WINDOW *, int, int, int, int, char *);
-static int next_field(struct form *form, int);
diff --git a/lib/libforms/lex.c b/lib/libforms/lex.c
deleted file mode 100644
index 0ce735f..0000000
--- a/lib/libforms/lex.c
+++ /dev/null
@@ -1,1606 +0,0 @@
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header: /home/ncvs/src/usr.bin/lex/skel.c,v 1.1.1.1 1994/08/24 13:10:31 csgr Exp $
- */
-
-#define FLEX_SCANNER
-
-#include <stdio.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#ifdef __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-
-#ifdef __TURBOC__
-#define YY_USE_CONST
-#endif
-
-
-#ifndef YY_USE_CONST
-#ifndef const
-#define const
-#endif
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state.
- */
-#define YY_START ((yy_start - 1) / 2)
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". Now included
- * only for backward compatibility with previous versions of flex.
- */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- extern int yywrap YY_PROTO(( void ));
-#ifdef __cplusplus
- }
-#endif
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- int yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-void yyrestart YY_PROTO(( FILE *input_file ));
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-static void yy_push_state YY_PROTO(( int new_state ));
-static void yy_pop_state YY_PROTO(( void ));
-static int yy_top_state YY_PROTO(( void ));
-
-static void *yy_flex_alloc YY_PROTO(( unsigned int ));
-static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define INITIAL 0
-typedef unsigned char YY_CHAR;
-typedef int yy_state_type;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-extern char *yytext;
-#define yytext_ptr yytext
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, const char *, int ));
-#endif
-
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( const char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yytext_ptr -= yy_more_len; \
- yyleng = yy_cp - yytext_ptr; \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_END_OF_BUFFER 46
-static const short int yy_accept[188] =
- { 0,
- 44, 44, 46, 45, 44, 42, 41, 43, 36, 39,
- 18, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 37, 38, 44, 41, 43, 39, 40, 40,
- 40, 40, 16, 15, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 31, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 6, 40, 40, 40, 40, 40, 40, 40, 40, 14,
-
- 40, 40, 40, 9, 40, 11, 40, 32, 40, 40,
- 40, 40, 40, 33, 40, 40, 35, 40, 13, 40,
- 40, 40, 21, 40, 40, 40, 40, 40, 40, 40,
- 5, 40, 40, 40, 40, 7, 40, 40, 24, 26,
- 40, 40, 34, 40, 20, 12, 19, 40, 3, 40,
- 29, 40, 40, 40, 40, 40, 17, 40, 40, 40,
- 40, 8, 4, 40, 40, 40, 25, 40, 40, 10,
- 28, 40, 40, 40, 40, 30, 40, 27, 40, 40,
- 40, 23, 22, 1, 40, 2, 0
- } ;
-
-static const int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 4, 5, 1, 1, 6, 1, 6,
- 6, 1, 1, 7, 1, 1, 1, 8, 8, 8,
- 8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
- 9, 1, 1, 1, 10, 10, 11, 10, 10, 12,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 1, 1, 1, 1, 10, 1, 13, 14, 15, 16,
-
- 17, 18, 19, 20, 21, 10, 22, 23, 24, 25,
- 26, 27, 10, 28, 29, 30, 31, 10, 32, 33,
- 34, 10, 35, 6, 36, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static const int yy_meta[37] =
- { 0,
- 1, 1, 2, 3, 1, 4, 1, 4, 1, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 1, 1
- } ;
-
-static const short int yy_base[191] =
- { 0,
- 0, 0, 195, 196, 192, 196, 0, 0, 196, 185,
- 196, 0, 166, 165, 22, 167, 12, 22, 158, 160,
- 23, 28, 174, 169, 158, 171, 26, 25, 166, 155,
- 33, 164, 196, 196, 178, 0, 0, 171, 0, 155,
- 149, 146, 0, 145, 37, 151, 160, 154, 139, 145,
- 152, 147, 148, 152, 147, 140, 144, 129, 131, 139,
- 143, 139, 134, 143, 122, 0, 133, 137, 129, 125,
- 126, 128, 120, 132, 129, 119, 119, 130, 117, 126,
- 123, 120, 118, 120, 106, 114, 117, 103, 111, 103,
- 0, 110, 112, 100, 97, 96, 95, 101, 28, 0,
-
- 97, 101, 99, 0, 29, 0, 89, 0, 89, 93,
- 97, 93, 92, 0, 84, 88, 0, 86, 0, 81,
- 95, 79, 0, 91, 87, 80, 76, 76, 78, 88,
- 0, 71, 72, 76, 77, 0, 67, 75, 0, 0,
- 65, 69, 0, 63, 0, 0, 0, 60, 0, 62,
- 0, 59, 76, 58, 57, 60, 0, 66, 71, 54,
- 65, 0, 0, 51, 66, 66, 0, 53, 57, 0,
- 0, 58, 54, 44, 52, 0, 35, 0, 35, 46,
- 39, 0, 0, 0, 44, 0, 196, 68, 72, 54
- } ;
-
-static const short int yy_def[191] =
- { 0,
- 187, 1, 187, 187, 187, 187, 188, 189, 187, 187,
- 187, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 187, 187, 187, 188, 189, 187, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
-
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 190, 190, 190, 190,
- 190, 190, 190, 190, 190, 190, 0, 187, 187, 187
- } ;
-
-static const short int yy_nxt[233] =
- { 0,
- 4, 5, 6, 7, 8, 4, 9, 10, 11, 12,
- 13, 14, 15, 16, 17, 18, 12, 19, 20, 21,
- 12, 12, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 12, 32, 33, 34, 42, 46, 48, 52,
- 54, 63, 61, 53, 55, 47, 62, 49, 56, 74,
- 43, 44, 67, 68, 64, 127, 132, 39, 128, 133,
- 186, 185, 184, 183, 182, 181, 180, 75, 36, 36,
- 179, 36, 37, 178, 37, 37, 177, 176, 175, 174,
- 173, 172, 171, 170, 169, 168, 167, 166, 165, 164,
- 163, 162, 161, 160, 159, 158, 157, 156, 155, 154,
-
- 153, 152, 151, 150, 149, 148, 147, 146, 145, 144,
- 143, 142, 141, 140, 139, 138, 137, 136, 135, 134,
- 131, 130, 129, 126, 125, 124, 123, 122, 121, 120,
- 119, 118, 117, 116, 115, 114, 113, 112, 111, 110,
- 109, 108, 107, 106, 105, 104, 103, 102, 101, 100,
- 99, 98, 97, 96, 95, 94, 93, 92, 91, 90,
- 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
- 79, 78, 77, 76, 73, 72, 71, 70, 38, 35,
- 69, 66, 65, 60, 59, 58, 57, 51, 50, 45,
- 41, 40, 38, 35, 187, 3, 187, 187, 187, 187,
-
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187
- } ;
-
-static const short int yy_chk[233] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 15, 17, 18, 21,
- 22, 28, 27, 21, 22, 17, 27, 18, 22, 45,
- 15, 15, 31, 31, 28, 99, 105, 190, 99, 105,
- 185, 181, 180, 179, 177, 175, 174, 45, 188, 188,
- 173, 188, 189, 172, 189, 189, 169, 168, 166, 165,
- 164, 161, 160, 159, 158, 156, 155, 154, 153, 152,
- 150, 148, 144, 142, 141, 138, 137, 135, 134, 133,
-
- 132, 130, 129, 128, 127, 126, 125, 124, 122, 121,
- 120, 118, 116, 115, 113, 112, 111, 110, 109, 107,
- 103, 102, 101, 98, 97, 96, 95, 94, 93, 92,
- 90, 89, 88, 87, 86, 85, 84, 83, 82, 81,
- 80, 79, 78, 77, 76, 75, 74, 73, 72, 71,
- 70, 69, 68, 67, 65, 64, 63, 62, 61, 60,
- 59, 58, 57, 56, 55, 54, 53, 52, 51, 50,
- 49, 48, 47, 46, 44, 42, 41, 40, 38, 35,
- 32, 30, 29, 26, 25, 24, 23, 20, 19, 16,
- 14, 13, 10, 5, 3, 187, 187, 187, 187, 187,
-
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
- 187, 187
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-static int yy_more_flag = 0;
-static int yy_more_len = 0;
-#define yymore() (yy_more_flag = 1)
-#define YY_MORE_ADJ yy_more_len
-char *yytext;
-# line 1 "lex.l"
-# line 2 "lex.l"
-/*-
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-#include <unistd.h>
-
-#include "y.tab.h"
-extern int lineno;
-extern int charno;
-extern int off;
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = getc( yyin ); \
- result = c == EOF ? 0 : 1; \
- buf[0] = (char) c; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-# line 43 "lex.l"
-
-
- if ( yy_init )
- {
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( yy_current_buffer )
- yy_init_buffer( yy_current_buffer, yyin );
- else
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
-
- yy_init = 0;
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_more_len = 0;
- if ( yy_more_flag )
- {
- yy_more_len = yyleng;
- yy_more_flag = 0;
- }
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 188 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 196 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_USER_ACTION
-# line 44 "lex.l"
-{ return COLORTABLE; }
- YY_BREAK
-case 2:
-YY_USER_ACTION
-# line 45 "lex.l"
-{ return COLORTABLE; }
- YY_BREAK
-case 3:
-YY_USER_ACTION
-# line 46 "lex.l"
-{ return COLOR; }
- YY_BREAK
-case 4:
-YY_USER_ACTION
-# line 47 "lex.l"
-{ return COLOR; }
- YY_BREAK
-case 5:
-YY_USER_ACTION
-# line 48 "lex.l"
-{ return BLACK; }
- YY_BREAK
-case 6:
-YY_USER_ACTION
-# line 49 "lex.l"
-{ return RED; }
- YY_BREAK
-case 7:
-YY_USER_ACTION
-# line 50 "lex.l"
-{ return GREEN; }
- YY_BREAK
-case 8:
-YY_USER_ACTION
-# line 51 "lex.l"
-{ return YELLOW; }
- YY_BREAK
-case 9:
-YY_USER_ACTION
-# line 52 "lex.l"
-{ return BLUE; }
- YY_BREAK
-case 10:
-YY_USER_ACTION
-# line 53 "lex.l"
-{ return MAGENTA; }
- YY_BREAK
-case 11:
-YY_USER_ACTION
-# line 54 "lex.l"
-{ return CYAN; }
- YY_BREAK
-case 12:
-YY_USER_ACTION
-# line 55 "lex.l"
-{ return WHITE; }
- YY_BREAK
-case 13:
-YY_USER_ACTION
-# line 56 "lex.l"
-{ return PAIR; }
- YY_BREAK
-case 14:
-YY_USER_ACTION
-# line 57 "lex.l"
-{ return FORM; }
- YY_BREAK
-case 15:
-YY_USER_ACTION
-# line 58 "lex.l"
-{ return AT; }
- YY_BREAK
-case 16:
-YY_USER_ACTION
-# line 59 "lex.l"
-{ return AS; }
- YY_BREAK
-case 17:
-YY_USER_ACTION
-# line 60 "lex.l"
-{ return HEIGHT; }
- YY_BREAK
-case 18:
-YY_USER_ACTION
-# line 61 "lex.l"
-{ return EQUALS; }
- YY_BREAK
-case 19:
-YY_USER_ACTION
-# line 62 "lex.l"
-{ return WIDTH; }
- YY_BREAK
-case 20:
-YY_USER_ACTION
-# line 63 "lex.l"
-{ return STARTFIELD; }
- YY_BREAK
-case 21:
-YY_USER_ACTION
-# line 64 "lex.l"
-{ return TEXT; }
- YY_BREAK
-case 22:
-YY_USER_ACTION
-# line 65 "lex.l"
-{ return ATTR; }
- YY_BREAK
-case 23:
-YY_USER_ACTION
-# line 66 "lex.l"
-{ return SELATTR; }
- YY_BREAK
-case 24:
-YY_USER_ACTION
-# line 67 "lex.l"
-{ return LABEL; }
- YY_BREAK
-case 25:
-YY_USER_ACTION
-# line 68 "lex.l"
-{ return DEFAULT; }
- YY_BREAK
-case 26:
-YY_USER_ACTION
-# line 69 "lex.l"
-{ return LIMIT; }
- YY_BREAK
-case 27:
-YY_USER_ACTION
-# line 70 "lex.l"
-{ return SELECTED; }
- YY_BREAK
-case 28:
-YY_USER_ACTION
-# line 71 "lex.l"
-{ return OPTIONS; }
- YY_BREAK
-case 29:
-YY_USER_ACTION
-# line 72 "lex.l"
-{ return ACTION; }
- YY_BREAK
-case 30:
-YY_USER_ACTION
-# line 73 "lex.l"
-{ return FUNC; }
- YY_BREAK
-case 31:
-YY_USER_ACTION
-# line 74 "lex.l"
-{ return UP; }
- YY_BREAK
-case 32:
-YY_USER_ACTION
-# line 75 "lex.l"
-{ return DOWN; }
- YY_BREAK
-case 33:
-YY_USER_ACTION
-# line 76 "lex.l"
-{ return LEFT; }
- YY_BREAK
-case 34:
-YY_USER_ACTION
-# line 77 "lex.l"
-{ return RIGHT; }
- YY_BREAK
-case 35:
-YY_USER_ACTION
-# line 78 "lex.l"
-{ return NEXT; }
- YY_BREAK
-case 36:
-YY_USER_ACTION
-# line 79 "lex.l"
-{ return COMMA; }
- YY_BREAK
-case 37:
-YY_USER_ACTION
-# line 80 "lex.l"
-{ return LBRACE; }
- YY_BREAK
-case 38:
-YY_USER_ACTION
-# line 81 "lex.l"
-{ return RBRACE; }
- YY_BREAK
-case 39:
-YY_USER_ACTION
-# line 82 "lex.l"
-{ yylval.ival = atoi(yytext); return NUMBER; }
- YY_BREAK
-case 40:
-YY_USER_ACTION
-# line 83 "lex.l"
-{ yylval.sval = yytext; return NAME; }
- YY_BREAK
-case 41:
-YY_USER_ACTION
-# line 84 "lex.l"
-{
- if (yytext[yyleng-1] == '\\') {
- yymore();
- } else {
- input();
- yylval.sval = yytext+1;
- return STRING;
- }
- }
- YY_BREAK
-case 42:
-YY_USER_ACTION
-# line 93 "lex.l"
-{ lineno++; }
- YY_BREAK
-case 43:
-YY_USER_ACTION
-# line 94 "lex.l"
-{ /* Ignored (comment) */; }
- YY_BREAK
-case 44:
-YY_USER_ACTION
-# line 95 "lex.l"
-{ /* Ignored (white space) */; }
- YY_BREAK
-case 45:
-YY_USER_ACTION
-# line 96 "lex.l"
-ECHO;
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = yy_cp - yytext_ptr - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr - 1; /* copy prev. char, too */
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a singled characater, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = yy_c_buf_p - yytext_ptr;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset = yy_c_buf_p - b->yy_ch_buf;
-
- b->yy_buf_size *= 2;
- b->yy_ch_buf = (char *)
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size );
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move - YY_MORE_ADJ == 1 )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- /* yytext begins at the second character in yy_ch_buf; the first
- * character is the one which preceded it before reading in the latest
- * buffer; it needs to be kept around in case it's a newline, so
- * yy_get_previous_state() will have with '^' rules active.
- */
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[1];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 188 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 188 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 187);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
- register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += dest - source;
- yy_bp += dest - source;
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
- yy_cp[-2] = '\n';
-
- *--yy_cp = (char) c;
-
-
- /* Note: the formal parameter *must* be called "yy_bp" for this
- * macro to now work correctly.
- */
- YY_DO_BEFORE_ACTION; /* set up yytext again */
- }
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- yytext_ptr = yy_c_buf_p;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- {
- yy_c_buf_p =
- yytext_ptr + YY_MORE_ADJ;
- return EOF;
- }
-
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
- break;
-
- case EOB_ACT_LAST_MATCH:
-#ifdef __cplusplus
- YY_FATAL_ERROR(
- "unexpected last match in yyinput()" );
-#else
- YY_FATAL_ERROR(
- "unexpected last match in input()" );
-#endif
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
- return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
-
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- yy_flex_free( (void *) b->yy_ch_buf );
- yy_flex_free( (void *) b );
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
- {
- b->yy_input_file = file;
-
- /* We put in the '\n' and start reading from [1] so that an
- * initial match-at-newline will be true.
- */
-
- b->yy_ch_buf[0] = '\n';
- b->yy_n_chars = 1;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[1];
-
- b->yy_is_interactive = file ? isatty( fileno(file) ) : 0;
-
- b->yy_fill_buffer = 1;
-
- b->yy_buffer_status = YY_BUFFER_NEW;
- }
-
-
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- int new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-
-
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-
-
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( const char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( 1 );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, const char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-const char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( unsigned int size )
-#else
-static void *yy_flex_alloc( size )
-unsigned int size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, unsigned int size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-unsigned int size;
-#endif
- {
- return (void *) realloc( ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-# line 96 "lex.l"
diff --git a/lib/libforms/menu.c b/lib/libforms/menu.c
deleted file mode 100644
index b234549..0000000
--- a/lib/libforms/menu.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-
-#include <strhash.h>
-#include <forms.h>
-#include <stdlib.h>
-#include <string.h>
-
-int
-add_menu_option(struct MenuField *menu, char *option)
-{
- char **tmp;
- int len;
-
- tmp = (char **)realloc(menu->options, (menu->no_options + 1) * sizeof(char**));
- if (!tmp)
- return (0);
- else
- menu->options = tmp;
-
- len = strlen(option) + 1;
- menu->options[menu->no_options] = (char *)malloc(len);
- if (!menu->options[menu->no_options])
- return (0);
- strncpy(menu->options[menu->no_options], option, len);
-
- return (++menu->no_options);
-}
diff --git a/lib/libforms/parser.c b/lib/libforms/parser.c
deleted file mode 100644
index c5ca0aa..0000000
--- a/lib/libforms/parser.c
+++ /dev/null
@@ -1,1022 +0,0 @@
-#ifndef lint
-static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
-#endif
-#define YYBYACC 1
-#define YYMAJOR 1
-#define YYMINOR 9
-#define yyclearin (yychar=(-1))
-#define yyerrok (yyerrflag=0)
-#define YYRECOVERING (yyerrflag!=0)
-#define YYPREFIX "yy"
-#line 2 "parser.y"
-/*-
- * Copyright (c) 1995
- * Paul Richards. All rights reserved.
- *
- * 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,
- * verbatim and that no modifications are made prior to this
- * point in the file.
- * 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. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Paul Richards.
- * 4. The name Paul Richards may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY PAUL RICHARDS ``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 PAUL RICHARDS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- */
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <forms.h>
-#include <err.h>
-
-#include "internal.h"
-
-char *cpstr(char *);
-
-extern int yyleng;
-int lineno = 1;
-int charno = 1;
-int off;
-
-char *fieldname;
-char *defname;
-char *formname;
-char *startname;
-char *colortable;
-int formattr;
-char *text;
-char *label;
-char *function;
-char *up, *down, *left, *right, *next;
-int height, width;
-int y, x;
-int width;
-int limit;
-int attr;
-int selattr;
-int type;
-int lbl_flag;
-int selected, no_options=0;
-
-extern FILE *outf;
-
-struct MenuList {
- char *option;
- struct MenuList *next;
-};
-
-struct MenuList *cur_menu;
-struct MenuList *menu_list;
-struct MenuList *menu;
-
-struct pair_node {
- char *foreground;
- char *background;
- struct pair_node *next;
-};
-struct pair_node *pair_list;
-struct pair_node *cur_pair;
-struct pair_node *pair;
-
-struct color_table {
- char *tablename;
- struct pair_node *pairs;
- struct color_table *next;
-};
-
-struct color_table *color_table;
-struct color_table *cur_table;
-struct color_table *color_tables;
-
-struct Form *form;
-struct Field *field_inst_list;
-struct Field *field;
-struct Field *cur_field;
-#line 106 "parser.y"
-typedef union {
- int ival;
- char *sval;
-} YYSTYPE;
-#line 120 "y.tab.c"
-#define FORM 257
-#define COLORTABLE 258
-#define COLOR 259
-#define BLACK 260
-#define RED 261
-#define GREEN 262
-#define YELLOW 263
-#define BLUE 264
-#define MAGENTA 265
-#define CYAN 266
-#define WHITE 267
-#define PAIR 268
-#define NAME 269
-#define STRING 270
-#define AT 271
-#define AS 272
-#define HEIGHT 273
-#define EQUALS 274
-#define NUMBER 275
-#define WIDTH 276
-#define STARTFIELD 277
-#define COMMA 278
-#define LBRACE 279
-#define RBRACE 280
-#define TEXT 281
-#define ATTR 282
-#define SELATTR 283
-#define DEFAULT 284
-#define LABEL 285
-#define LIMIT 286
-#define SELECTED 287
-#define OPTIONS 288
-#define ACTION 289
-#define FUNC 290
-#define LINK 291
-#define UP 292
-#define DOWN 293
-#define LEFT 294
-#define RIGHT 295
-#define NEXT 296
-#define DEF 297
-#define YYERRCODE 256
-short yylhs[] = { -1,
- 0, 0, 0, 0, 5, 4, 6, 6, 8, 7,
- 1, 1, 1, 1, 1, 1, 1, 1, 9, 11,
- 3, 12, 15, 15, 16, 16, 17, 17, 18, 18,
- 21, 23, 19, 25, 2, 20, 26, 20, 20, 24,
- 22, 22, 30, 30, 30, 30, 30, 29, 29, 29,
- 29, 31, 32, 35, 35, 36, 36, 33, 37, 37,
- 38, 34, 13, 13, 14, 14, 27, 27, 28, 28,
- 10,
-};
-short yylen[] = { 2,
- 0, 2, 2, 2, 0, 6, 0, 2, 0, 6,
- 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
- 9, 6, 0, 3, 0, 3, 0, 3, 0, 2,
- 0, 0, 7, 0, 3, 0, 0, 4, 1, 7,
- 0, 3, 3, 3, 3, 3, 3, 1, 1, 1,
- 1, 3, 1, 4, 4, 0, 3, 6, 1, 3,
- 1, 6, 0, 3, 0, 3, 0, 3, 0, 3,
- 3,
-};
-short yydefred[] = { 1,
- 0, 0, 0, 34, 2, 3, 4, 19, 5, 0,
- 0, 0, 0, 35, 0, 7, 0, 0, 0, 20,
- 0, 0, 0, 0, 0, 0, 0, 6, 8, 64,
- 0, 0, 0, 71, 0, 0, 66, 0, 0, 0,
- 0, 0, 11, 12, 13, 14, 15, 16, 17, 18,
- 9, 68, 0, 0, 0, 0, 0, 0, 0, 48,
- 49, 50, 51, 53, 21, 0, 0, 70, 0, 0,
- 0, 0, 0, 40, 0, 0, 0, 52, 0, 0,
- 0, 0, 0, 0, 0, 10, 0, 55, 54, 0,
- 0, 24, 0, 0, 29, 0, 0, 0, 26, 0,
- 0, 57, 61, 0, 59, 62, 28, 31, 30, 0,
- 0, 60, 0, 0, 39, 37, 0, 0, 32, 38,
- 41, 0, 0, 0, 0, 0, 0, 0, 42, 0,
- 0, 0, 0, 0, 43, 44, 45, 46, 47,
-};
-short yydgoto[] = { 1,
- 51, 5, 6, 7, 12, 21, 29, 67, 11, 20,
- 26, 41, 18, 24, 76, 85, 95, 101, 109, 114,
- 111, 122, 121, 14, 10, 118, 33, 40, 59, 129,
- 60, 61, 62, 63, 64, 88, 104, 105,
-};
-short yysindex[] = { 0,
- -252, -261, -240, 0, 0, 0, 0, 0, 0, -248,
- -234, -237, -225, 0, -236, 0, -219, -214, -212, 0,
- -259, -216, -205, -196, -204, -192, -186, 0, 0, 0,
- -185, -183, -194, 0, -225, -187, 0, -182, -180, -224,
- -188, -214, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -179, -177, -176, -175, -174, -173, -178, 0,
- 0, 0, 0, 0, 0, -172, -171, 0, -167, -166,
- -164, -165, -162, 0, -163, -149, -187, 0, -191, -191,
- -170, -169, -157, -161, -168, 0, -159, 0, 0, -158,
- -155, 0, -152, -154, 0, -153, -147, -145, 0, -150,
- -143, 0, 0, -151, 0, 0, 0, 0, 0, -147,
- -148, 0, -263, -142, 0, 0, -236, -146, 0, 0,
- 0, -141, -211, -144, -139, -138, -136, -135, 0, -137,
- -129, -128, -127, -126, 0, 0, 0, 0, 0,
-};
-short yyrindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -249, 0, 0, 0, 0, -238, 0, 0,
- 0, 0, 0, -231, 0, 0, 0, 0, 0, 0,
- 0, 0, -217, 0, -258, 0, 0, 0, 0, 0,
- 0, -257, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -254, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -266, 0, 0, -134, -134,
- 0, 0, 0, 0, -267, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -133, 0, 0, -132, 0, 0, 0, 0, 0, 0,
- -122, 0, -249, 0, 0, 0, 0, 0, 0, 0,
- 0, -239, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-short yygindex[] = { 0,
- 51, 0, 0, 0, 0, 0, 0, 0, 0, 16,
- 0, 0, 109, 103, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 39, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 71, 0, 42,
-};
-#define YYTABLESIZE 152
-short yytable[] = { 63,
- 65, 27, 25, 23, 2, 116, 3, 8, 27, 17,
- 63, 65, 27, 25, 23, 25, 4, 63, 63, 65,
- 28, 63, 65, 63, 65, 23, 63, 23, 9, 33,
- 13, 63, 63, 63, 63, 63, 15, 63, 19, 63,
- 33, 16, 65, 65, 65, 65, 65, 17, 65, 67,
- 65, 67, 67, 67, 22, 67, 54, 67, 30, 55,
- 56, 23, 57, 69, 58, 25, 69, 69, 31, 69,
- 34, 69, 43, 44, 45, 46, 47, 48, 49, 50,
- 124, 125, 126, 127, 128, 32, 35, 36, 39, 37,
- 38, 65, 52, 53, 87, 68, 69, 70, 71, 72,
- 73, 74, 78, 79, 75, 80, 77, 82, 84, 81,
- 83, 92, 93, 94, 96, 97, 99, 90, 98, 100,
- 91, 102, 103, 106, 107, 108, 110, 86, 117, 130,
- 113, 135, 119, 120, 131, 132, 123, 133, 134, 136,
- 137, 138, 139, 42, 66, 56, 22, 58, 36, 115,
- 89, 112,
-};
-short yycheck[] = { 258,
- 258, 269, 269, 258, 257, 269, 259, 269, 268, 273,
- 269, 269, 280, 280, 269, 282, 269, 276, 277, 277,
- 280, 280, 280, 282, 282, 280, 276, 282, 269, 269,
- 279, 281, 282, 283, 284, 285, 271, 287, 275, 289,
- 280, 279, 281, 282, 283, 284, 285, 273, 287, 281,
- 289, 283, 284, 285, 274, 287, 281, 289, 275, 284,
- 285, 276, 287, 281, 289, 278, 284, 285, 274, 287,
- 275, 289, 260, 261, 262, 263, 264, 265, 266, 267,
- 292, 293, 294, 295, 296, 282, 279, 274, 283, 275,
- 274, 280, 275, 274, 286, 275, 274, 274, 274, 274,
- 274, 280, 270, 270, 277, 270, 278, 270, 258, 275,
- 274, 269, 274, 282, 274, 274, 269, 288, 274, 274,
- 290, 275, 270, 269, 275, 269, 278, 77, 271, 274,
- 279, 269, 117, 280, 274, 274, 278, 274, 274, 269,
- 269, 269, 269, 35, 42, 280, 280, 280, 271, 111,
- 80, 110,
-};
-#define YYFINAL 1
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 297
-#if YYDEBUG
-char *yyname[] = {
-"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"FORM","COLORTABLE","COLOR",
-"BLACK","RED","GREEN","YELLOW","BLUE","MAGENTA","CYAN","WHITE","PAIR","NAME",
-"STRING","AT","AS","HEIGHT","EQUALS","NUMBER","WIDTH","STARTFIELD","COMMA",
-"LBRACE","RBRACE","TEXT","ATTR","SELATTR","DEFAULT","LABEL","LIMIT","SELECTED",
-"OPTIONS","ACTION","FUNC","LINK","UP","DOWN","LEFT","RIGHT","NEXT","DEF",
-};
-char *yyrule[] = {
-"$accept : spec",
-"spec :",
-"spec : spec fields",
-"spec : spec forms",
-"spec : spec colours",
-"$$1 :",
-"colours : COLOR NAME $$1 LBRACE color_pairs RBRACE",
-"color_pairs :",
-"color_pairs : color_pairs pair",
-"$$2 :",
-"pair : PAIR EQUALS a_color $$2 COMMA a_color",
-"a_color : BLACK",
-"a_color : RED",
-"a_color : GREEN",
-"a_color : YELLOW",
-"a_color : BLUE",
-"a_color : MAGENTA",
-"a_color : CYAN",
-"a_color : WHITE",
-"$$3 :",
-"$$4 :",
-"forms : FORM NAME $$3 AT coord $$4 LBRACE formspec RBRACE",
-"formspec : height width startfield colortable formattr fieldlocs",
-"startfield :",
-"startfield : STARTFIELD EQUALS NAME",
-"colortable :",
-"colortable : COLORTABLE EQUALS NAME",
-"formattr :",
-"formattr : ATTR EQUALS NUMBER",
-"fieldlocs :",
-"fieldlocs : fieldlocs field_at",
-"$$5 :",
-"$$6 :",
-"field_at : NAME $$5 field_def AT coord $$6 links",
-"$$7 :",
-"fields : NAME $$7 field_spec",
-"field_def :",
-"$$8 :",
-"field_def : LBRACE NAME $$8 RBRACE",
-"field_def : field_spec",
-"field_spec : LBRACE height width attr selattr type RBRACE",
-"links :",
-"links : links COMMA conns",
-"conns : UP EQUALS NAME",
-"conns : DOWN EQUALS NAME",
-"conns : LEFT EQUALS NAME",
-"conns : RIGHT EQUALS NAME",
-"conns : NEXT EQUALS NAME",
-"type : textfield",
-"type : inputfield",
-"type : menufield",
-"type : actionfield",
-"textfield : TEXT EQUALS STRING",
-"inputfield : inputspec",
-"inputspec : LABEL EQUALS STRING limit",
-"inputspec : DEFAULT EQUALS STRING limit",
-"limit :",
-"limit : LIMIT EQUALS NUMBER",
-"menufield : SELECTED EQUALS NUMBER OPTIONS EQUALS menuoptions",
-"menuoptions : menuoption",
-"menuoptions : menuoptions COMMA menuoption",
-"menuoption : STRING",
-"actionfield : ACTION EQUALS STRING FUNC EQUALS NAME",
-"height :",
-"height : HEIGHT EQUALS NUMBER",
-"width :",
-"width : WIDTH EQUALS NUMBER",
-"attr :",
-"attr : ATTR EQUALS NUMBER",
-"selattr :",
-"selattr : SELATTR EQUALS NUMBER",
-"coord : NUMBER COMMA NUMBER",
-};
-#endif
-#ifdef YYSTACKSIZE
-#undef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
-#else
-#ifdef YYMAXDEPTH
-#define YYSTACKSIZE YYMAXDEPTH
-#else
-#define YYSTACKSIZE 500
-#define YYMAXDEPTH 500
-#endif
-#endif
-int yydebug;
-int yynerrs;
-int yyerrflag;
-int yychar;
-short *yyssp;
-YYSTYPE *yyvsp;
-YYSTYPE yyval;
-YYSTYPE yylval;
-short yyss[YYSTACKSIZE];
-YYSTYPE yyvs[YYSTACKSIZE];
-#define yystacksize YYSTACKSIZE
-#line 434 "parser.y"
-
-void
-yyerror (char *error)
-{
- fprintf(stderr, "%s at line %d\n",error, lineno);
- exit(1);
-}
-
-char *
-cpstr(char *ostr)
-{
- char *nstr;
-
- nstr = malloc(strlen(ostr)+1);
- if (!nstr) {
- fprintf(stderr, "Couldn't allocate memory for string\n");
- exit(1);
- }
- strcpy(nstr, ostr);
- return (nstr);
-}
-
-/* Calculate a default height for a field */
-
-void
-calc_field_height(struct Field *field, char *string)
-{
-
- int len;
-
- len = strlen(string);
-
- if (!field->width) {
- /*
- * This is a failsafe, this routine shouldn't be called
- * with a width of 0, the width should be determined
- * first.
- */
- field->height = 1;
- return;
- }
-
- if (len < field->width) {
- field->height = 1;
- return;
- } else
- field->height = len / field->width;
-
- if ((field->height*field->width) < len)
- field->height++;
-
- return;
-}
-
-void
-define_field(char *defname)
-{
- struct Field *field;
- struct MenuList *menu_options;
- int no_options;
-
- field = malloc(sizeof (struct Field));
- if (!field) {
- fprintf(stderr,"Failed to allocate memory for form field\n");
- exit(1);
- }
- field->defname = defname;
- field->type = type;
- field->height = height;
- field->width = width;
- field->attr = attr;
- field->selattr = selattr;
- switch (type) {
- case FF_TEXT:
- field->field.text = malloc(sizeof (struct TextField));
- if (!field->field.text) {
- fprintf(stderr,
- "Failed to allocate memory for text field\n");
- exit (1);
- }
- field->field.text->text = text;
- break;
- case FF_INPUT:
- field->field.input = malloc(sizeof (struct InputField));
- if (!field->field.input) {
- fprintf(stderr,
- "Failed to allocate memory for input field\n");
- exit (1);
- }
- field->field.input->lbl_flag = lbl_flag;
- field->field.input->label = label;
- field->field.input->limit = limit;
- break;
- case FF_MENU:
- printf("field type %s = %d\n", defname,field->type);
- field->field.menu = malloc(sizeof (struct MenuField));
- if (!field->field.menu) {
- fprintf(stderr,
- "Failed to allocate memory for menu field\n");
- exit (1);
- }
- field->field.menu->selected = selected;
- menu_options = menu_list;
- field->field.menu->no_options = 0;
- field->field.menu->options = 0;
- for (; menu_options; menu_options = menu_options->next) {
- no_options = add_menu_option(field->field.menu,
- menu_options->option);
- if (!no_options)
- err(1, "Couldn't add menu option");
- }
- field->field.menu->no_options = no_options;
- cur_menu = 0;
- break;
- case FF_ACTION:
- field->field.action = malloc(sizeof (struct ActionField));
- if (!field->field.action) {
- fprintf(stderr,
- "Failed to allocate memory for action field\n");
- exit (1);
- }
- field->field.action->text = text;
- field->field.action->fn = (void *) function;
- break;
- default:
- break;
- }
- form_bind_tuple(defname, FT_FIELD_DEF, field);
- width=0;
- height = 0;
- attr=0;
- selattr=0;
- limit=0;
-}
-#line 531 "y.tab.c"
-#define YYABORT goto yyabort
-#define YYREJECT goto yyabort
-#define YYACCEPT goto yyaccept
-#define YYERROR goto yyerrlab
-int
-yyparse()
-{
- register int yym, yyn, yystate;
-#if YYDEBUG
- register char *yys;
- extern char *getenv();
-
- if (yys = getenv("YYDEBUG"))
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
-#endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = (-1);
-
- yyssp = yyss;
- yyvsp = yyvs;
- *yyssp = yystate = 0;
-
-yyloop:
- if (yyn = yydefred[yystate]) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, shifting to state %d\n",
- YYPREFIX, yystate, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- yychar = (-1);
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
-#ifdef lint
- goto yynewerror;
-#endif
-yynewerror:
- yyerror("syntax error");
-#ifdef lint
- goto yyerrlab;
-#endif
-yyerrlab:
- ++yynerrs;
-yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, error recovery shifting\
- to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate = yytable[yyn];
- *++yyvsp = yylval;
- goto yyloop;
- }
- else
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: error recovery discarding state %d\n",
- YYPREFIX, *yyssp);
-#endif
- if (yyssp <= yyss) goto yyabort;
- --yyssp;
- --yyvsp;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- yychar = (-1);
- goto yyloop;
- }
-yyreduce:
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, reducing by rule %d (%s)\n",
- YYPREFIX, yystate, yyn, yyrule[yyn]);
-#endif
- yym = yylen[yyn];
- yyval = yyvsp[1-yym];
- switch (yyn)
- {
-case 5:
-#line 166 "parser.y"
-{
- color_table = malloc(sizeof (struct color_table));
- if (!color_table) {
- fprintf(stderr, "Couldn't allocate memory for a color table\n");
- exit (1);
- }
- color_table->tablename = cpstr(yyvsp[0].sval);
- }
-break;
-case 6:
-#line 175 "parser.y"
-{
- color_table->pairs = pair_list;
- cur_pair = 0;
- form_bind_tuple(color_table->tablename, FT_COLTAB, color_table);
- }
-break;
-case 9:
-#line 187 "parser.y"
-{
- pair = malloc(sizeof (struct pair_node));
- if (!pair) {
- fprintf(stderr, "Couldn't allocate memory for a color pair\n");
- exit(1);
- }
- pair->foreground = cpstr(yyvsp[0].sval);
- }
-break;
-case 10:
-#line 196 "parser.y"
-{
- pair->background = cpstr(yyvsp[0].sval);
- if (!cur_pair) {
- pair_list = pair;
- cur_pair = pair;
- } else {
- cur_pair->next = pair;
- cur_pair = pair;
- }
- }
-break;
-case 11:
-#line 209 "parser.y"
-{ yyval.sval = "COLOR_BLACK"; }
-break;
-case 12:
-#line 211 "parser.y"
-{ yyval.sval = "COLOR_RED"; }
-break;
-case 13:
-#line 213 "parser.y"
-{ yyval.sval = "COLOR_GREEN"; }
-break;
-case 14:
-#line 215 "parser.y"
-{ yyval.sval = "COLOR_YELLOW"; }
-break;
-case 15:
-#line 217 "parser.y"
-{ yyval.sval = "COLOR_BLUE"; }
-break;
-case 16:
-#line 219 "parser.y"
-{ yyval.sval = "COLOR_MAGENTA"; }
-break;
-case 17:
-#line 221 "parser.y"
-{ yyval.sval = "COLOR_CYAN"; }
-break;
-case 18:
-#line 223 "parser.y"
-{ yyval.sval = "COLOR_WHITE"; }
-break;
-case 19:
-#line 227 "parser.y"
-{ formname = cpstr(yyvsp[0].sval); }
-break;
-case 20:
-#line 229 "parser.y"
-{
- form = malloc(sizeof (struct Form));
- if (!form) {
- fprintf(stderr,"Failed to allocate memory for form\n");
- exit(1);
- }
- form->y = y;
- form->x = x;
- }
-break;
-case 21:
-#line 239 "parser.y"
-{
- form->startfield = startname;
- form->colortable = colortable;
- form->height = height;
- form->width = width;
- form->attr = formattr;
- form->fieldlist = field_inst_list;
- field_inst_list = 0;
- form_bind_tuple(formname, FT_FORM, form);
- }
-break;
-case 23:
-#line 255 "parser.y"
-{ startname = 0;
- printf("Warning: No start field specified for form %s\n", formname);
- }
-break;
-case 24:
-#line 259 "parser.y"
-{ startname = cpstr(yyvsp[0].sval); }
-break;
-case 25:
-#line 263 "parser.y"
-{ colortable = 0; }
-break;
-case 26:
-#line 265 "parser.y"
-{ colortable = cpstr(yyvsp[0].sval); }
-break;
-case 27:
-#line 269 "parser.y"
-{ formattr = 0; }
-break;
-case 28:
-#line 271 "parser.y"
-{ formattr = yyvsp[0].ival; }
-break;
-case 31:
-#line 279 "parser.y"
-{ fieldname = cpstr(yyvsp[0].sval); }
-break;
-case 32:
-#line 281 "parser.y"
-{
- field = malloc(sizeof (struct Field));
- if (!field) {
- fprintf(stderr,"Failed to allocate memory for form field\n");
- exit(1);
- }
- if (!defname)
- field->defname = fieldname;
- else
- field->defname = defname;
- field->y = y;
- field->x = x;
- }
-break;
-case 33:
-#line 295 "parser.y"
-{
- field->fup = up;
- field->fdown = down;
- field->fleft = left;
- field->fright = right;
- field->fnext = next;
- if (!field_inst_list)
- field_inst_list = field;
- up = 0;
- down = 0;
- left = 0;
- right = 0;
- next = 0;
- if (!cur_field)
- cur_field = field;
- else {
- cur_field->next = field;
- cur_field = field;
- }
- form_bind_tuple(fieldname, FT_FIELD_INST, field);
- }
-break;
-case 34:
-#line 319 "parser.y"
-{ defname = cpstr(yyvsp[0].sval); }
-break;
-case 35:
-#line 321 "parser.y"
-{ define_field(defname); }
-break;
-case 36:
-#line 325 "parser.y"
-{ defname = 0; }
-break;
-case 37:
-#line 327 "parser.y"
-{ defname = cpstr(yyvsp[0].sval); }
-break;
-case 39:
-#line 330 "parser.y"
-{ defname = fieldname; define_field(defname); }
-break;
-case 43:
-#line 341 "parser.y"
-{ up = cpstr(yyvsp[0].sval); }
-break;
-case 44:
-#line 343 "parser.y"
-{ down = cpstr(yyvsp[0].sval); }
-break;
-case 45:
-#line 345 "parser.y"
-{ left = cpstr(yyvsp[0].sval); }
-break;
-case 46:
-#line 347 "parser.y"
-{ right = cpstr(yyvsp[0].sval); }
-break;
-case 47:
-#line 349 "parser.y"
-{ next = cpstr(yyvsp[0].sval); }
-break;
-case 52:
-#line 359 "parser.y"
-{ type = FF_TEXT; text = cpstr(yyvsp[0].sval); }
-break;
-case 53:
-#line 363 "parser.y"
-{ type = FF_INPUT; }
-break;
-case 54:
-#line 367 "parser.y"
-{ lbl_flag = 1; label = cpstr(yyvsp[-1].sval); }
-break;
-case 55:
-#line 369 "parser.y"
-{ lbl_flag = 0; label = cpstr(yyvsp[-1].sval); }
-break;
-case 57:
-#line 374 "parser.y"
-{ limit = yyvsp[0].ival; }
-break;
-case 58:
-#line 377 "parser.y"
-{ type = FF_MENU; selected = yyvsp[-3].ival; }
-break;
-case 61:
-#line 385 "parser.y"
-{
- menu = malloc(sizeof(struct MenuList));
- if (!menu) {
- err(1, "Couldn't allocate memory for menu option\n");
- }
- menu->option = cpstr(yyvsp[0].sval);
- if (!cur_menu) {
- menu_list = menu;
- cur_menu = menu;
- } else {
- cur_menu->next = menu;
- cur_menu = menu;
- }
- }
-break;
-case 62:
-#line 402 "parser.y"
-{ type = FF_ACTION; text = cpstr(yyvsp[-3].sval); function = cpstr(yyvsp[0].sval); }
-break;
-case 63:
-#line 406 "parser.y"
-{ height = 0; }
-break;
-case 64:
-#line 408 "parser.y"
-{ height = yyvsp[0].ival; }
-break;
-case 65:
-#line 412 "parser.y"
-{ width = 0; }
-break;
-case 66:
-#line 414 "parser.y"
-{ width = yyvsp[0].ival; }
-break;
-case 67:
-#line 418 "parser.y"
-{ attr = 0; }
-break;
-case 68:
-#line 420 "parser.y"
-{ attr = yyvsp[0].ival; }
-break;
-case 69:
-#line 424 "parser.y"
-{ selattr = 0; }
-break;
-case 70:
-#line 426 "parser.y"
-{ selattr = yyvsp[0].ival; }
-break;
-case 71:
-#line 430 "parser.y"
-{ y = yyvsp[-2].ival; x = yyvsp[0].ival; }
-break;
-#line 967 "y.tab.c"
- }
- yyssp -= yym;
- yystate = *yyssp;
- yyvsp -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state 0 to\
- state %d\n", YYPREFIX, YYFINAL);
-#endif
- yystate = YYFINAL;
- *++yyssp = YYFINAL;
- *++yyvsp = yyval;
- if (yychar < 0)
- {
- if ((yychar = yylex()) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, YYFINAL, yychar, yys);
- }
-#endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state %d \
-to state %d\n", YYPREFIX, *yyssp, yystate);
-#endif
- if (yyssp >= yyss + yystacksize - 1)
- {
- goto yyoverflow;
- }
- *++yyssp = yystate;
- *++yyvsp = yyval;
- goto yyloop;
-yyoverflow:
- yyerror("yacc stack overflow");
-yyabort:
- return (1);
-yyaccept:
- return (0);
-}
diff --git a/lib/libforms/y.tab.h b/lib/libforms/y.tab.h
deleted file mode 100644
index f3d9afa..0000000
--- a/lib/libforms/y.tab.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#define FORM 257
-#define COLORTABLE 258
-#define COLOR 259
-#define BLACK 260
-#define RED 261
-#define GREEN 262
-#define YELLOW 263
-#define BLUE 264
-#define MAGENTA 265
-#define CYAN 266
-#define WHITE 267
-#define PAIR 268
-#define NAME 269
-#define STRING 270
-#define AT 271
-#define AS 272
-#define HEIGHT 273
-#define EQUALS 274
-#define NUMBER 275
-#define WIDTH 276
-#define STARTFIELD 277
-#define COMMA 278
-#define LBRACE 279
-#define RBRACE 280
-#define TEXT 281
-#define ATTR 282
-#define SELATTR 283
-#define DEFAULT 284
-#define LABEL 285
-#define LIMIT 286
-#define SELECTED 287
-#define OPTIONS 288
-#define ACTION 289
-#define FUNC 290
-#define LINK 291
-#define UP 292
-#define DOWN 293
-#define LEFT 294
-#define RIGHT 295
-#define NEXT 296
-#define DEF 297
-typedef union {
- int ival;
- char *sval;
-} YYSTYPE;
-extern YYSTYPE yylval;
diff --git a/lib/libforms/yacc.y b/lib/libforms/yacc.y
deleted file mode 100644
index 2bc953e..0000000
--- a/lib/libforms/yacc.y
+++ /dev/null
@@ -1,149 +0,0 @@
-%{
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ncurses.h>
-#include <forms.h>
-
-extern struct form *form;
-
-struct field *cur_field;
-int id,next, up, down, left, right;
-%}
-
-%start file
-
-%union {
- int ival;
- char *sval;
-}
-
-%token <sval> STRING
-%token <ival> NUMBER
-%token <ival> INPUT
-%token <ival> TEXT
-%token <ival> FORM
-
-%type <sval> String
-
-%%
-
-file : /* Empty */
- | file form
- | file fields
- | error
- ;
-
-form : FORM NUMBER NUMBER NUMBER NUMBER
- {
- form = (struct form *) malloc(sizeof(struct form));
- if (!form)
- return(-1);
- form->x = $2;
- form->y = $3;
- form->height = $4;
- form->width = $5;
- form->fields = 0;
- }
- ;
-
-fields : input
- | text
- ;
-
-input : INPUT NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER String NUMBER NUMBER NUMBER NUMBER String
- {
- if (alloc_field() == -1)
- return(-1);
- cur_field->field_id = $2;
- /*
- * These will hold addresses but store
- * the field id's in them temporarily
- */
- cur_field->next = (struct field *) $3;
- cur_field->up = (struct field *) $4;
- cur_field->down = (struct field *) $5;
- cur_field->left = (struct field *) $6;
- cur_field->right = (struct field *) $7;
- cur_field->type = FORM_FTYPE_INPUT;
- cur_field->entry.input.y_prompt = $8;
- cur_field->entry.input.x_prompt = $9;
- cur_field->entry.input.prompt_width = $10;
- cur_field->entry.input.prompt_attr = FORM_DEFAULT_ATTR;
- cur_field->entry.input.prompt = (char *) malloc($10+1);
- if (!cur_field->entry.input.prompt)
- return(-1);
- strncpy(cur_field->entry.input.prompt, $11, $10);
- cur_field->entry.input.prompt[$10] = 0;
- cur_field->entry.input.y_field = $12;
- cur_field->entry.input.x_field = $13;
- cur_field->entry.input.field_width = $14;
- cur_field->entry.input.max_field_width = $15;
- cur_field->entry.input.field = (char *) malloc(strlen($16));
- cur_field->entry.input.field_attr = FORM_DEFAULT_ATTR;
- if (!cur_field->entry.input.field)
- return(-1);
- strcpy(cur_field->entry.input.field, $16);
- }
- ;
-
-text : TEXT NUMBER NUMBER String
- {
- if (alloc_field() == -1)
- return(-1);
- cur_field->field_id = 0;
- cur_field->type = FORM_FTYPE_TEXT;
- cur_field->entry.text.y = $2;
- cur_field->entry.text.x = $3;
- cur_field->entry.text.attr = FORM_DEFAULT_ATTR;
- cur_field->entry.text.text = (char *) malloc(strlen($4));
- if (!cur_field->entry.text.text)
- return (-1);
- strcpy(cur_field->entry.text.text, $4);
- }
- ;
-
-String : STRING
- {
- char *t, *old, *new;
-
- t = strdup($1);
- free($1);
- /*
- * Deal with any escaped characters,
- * only works for " and \ really.
- */
- for (old=t, new=t; *old; old++, new++) {
- if (*old == '\\')
- old++;
- *new = *old;
- }
- *new = '\0';
- $$ = t;
- }
-
-%%
-void
-yyerror(char *s)
-{
- printf("%s\n", s);
- exit(1);
-}
-
-int
-alloc_field()
-{
- if (!form->fields) {
- form->fields = (struct field *) malloc(sizeof(struct field));
- if (!form->fields)
- return(-1);
- cur_field = form->fields;
- } else {
- cur_field->link = (struct field *) malloc(sizeof(struct field));
- if (!cur_field->link)
- return(-1);
- cur_field = cur_field->link;
- }
-
- return(0);
-}
diff --git a/lib/libftp/FtpAbort.c b/lib/libftp/FtpAbort.c
deleted file mode 100644
index 80943e5..0000000
--- a/lib/libftp/FtpAbort.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-int
-FtpAbort(FTP *ftp)
-{
- fd_set fds;
- char msgc=IAC;
- String msg;
-
- FD_ZERO(&fds);
- FD_SET(fileno(FTPCMD(ftp)),&fds);
-
- FtpPutc(ftp, FTPCMD(ftp), IAC);
- FtpPutc(ftp, FTPCMD(ftp), IP);
-
- if ( send ( fileno(FTPCMD(ftp)), &msgc , 1 ,MSG_OOB) != 1 )
- return EXIT(ftp,QUIT);
-
- FtpPutc(ftp, FTPCMD(ftp), DM);
-
- FtpSendMessage(ftp,"ABOR");
-
- while (select ( getdtablesize(), &fds, 0,0, &(ftp->timeout) )>0)
- {
- FtpGetMessage(ftp,msg);
- if (FtpGood(FtpNumber(msg),225,226,EOF)) break;
- }
- return 0;
-}
-
-
-
diff --git a/lib/libftp/FtpArchie.c b/lib/libftp/FtpArchie.c
deleted file mode 100644
index 22a05e1..0000000
--- a/lib/libftp/FtpArchie.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-#define C2I(n) ((int)((n)-'0'))
-
-int FtpArchie ( char *what, ARCHIE *result, int len)
-{
- FILE *archie;
- String cmd,tmp;
- int i;
-
- bzero(result,sizeof(result[0])*len);
-
- sprintf(cmd,"archie -l -m %d %s",len,what);
-
- if ((archie = popen(cmd,"r"))==NULL)
- return 0;
-
- for(i=0;i<len;i++)
- {
- char *p, *pp;
-
- if (fgets(tmp,sizeof (tmp), archie)==NULL)
- break;
-
-
- result[i].createtime.tm_year = C2I (tmp[2 ])*10 - 70 + C2I(tmp[3]);
- result[i].createtime.tm_mday = C2I (tmp[4 ])*10 + C2I(tmp[5]);
- result[i].createtime.tm_hour = C2I (tmp[6 ])*10 + C2I(tmp[7]);
- result[i].createtime.tm_min = C2I (tmp[8 ])*10 + C2I(tmp[9]);
- result[i].createtime.tm_sec = C2I (tmp[10])*10 + C2I(tmp[11]);
-
- for(p=tmp; *p!=' '; p++);
- for(; *p==' '; p++);
-
- result[i].size = atoi(p);
-
- for(; *p!=' '; p++);
- for(; *p==' '; p++);
-
- for (pp=result[i].host;*p!=' ';p++,pp++) *pp=*p;
- *pp=0;
- for(; *p==' '; p++);
- for (pp=result[i].file;*p!='\n';p++,pp++) *pp=*p;
- *pp=0;
-
- }
-
- return i;
-}
diff --git a/lib/libftp/FtpBye.c b/lib/libftp/FtpBye.c
deleted file mode 100644
index 7094843..0000000
--- a/lib/libftp/FtpBye.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <signal.h>
-
-STATUS FtpBye(FTP *ftp)
-{
- FtpAssert(ftp,FtpCommand(ftp,"QUIT",221,EOF));
-
- fclose(FTPCMD(ftp));
- free(ftp);
- return 0;
-}
-
-STATUS FtpQuickBye(FTP *ftp)
-{
- if (ftp == NULL) return 0;
-
- if (FTPDATA(ftp)!=NULL)
- {
- shutdown(fileno(FTPDATA(ftp)),2);
- fclose(FTPDATA(ftp));
- }
-
- if (FTPCMD(ftp)!=NULL)
- {
- shutdown(fileno(FTPCMD(ftp)),2);
- fclose(FTPCMD(ftp));
- }
- free(ftp);
- return 0;
-}
-
diff --git a/lib/libftp/FtpClose.c b/lib/libftp/FtpClose.c
deleted file mode 100644
index a14658e..0000000
--- a/lib/libftp/FtpClose.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpClose(FTP *ftp)
-{
- int i;
- String S1;
-
- fflush(FTPDATA(ftp));
- shutdown(fileno(FTPDATA(ftp)),2);
- fclose(FTPDATA(ftp));
-
- FtpAssert(ftp,i=FtpGetMessage(ftp,S1));
- if ( i != 226 )
- return EXIT(ftp,-i);
- return EXIT(ftp,i);
-}
diff --git a/lib/libftp/FtpCommand.c b/lib/libftp/FtpCommand.c
deleted file mode 100644
index 25fd460..0000000
--- a/lib/libftp/FtpCommand.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <varargs.h>
-
-STATUS FtpCommand(va_alist)
- va_dcl
-{
- FTP *con;
- char *command, *param;
- int Answer[MAX_ANSWERS];
- va_list args;
- String S1;
- int i,counter=0;
-
- va_start(args);
-
- con = va_arg(args,FTP *);
- command = va_arg(args,char *);
- param = va_arg(args, char *);
-
- while ( 1 )
- {
- if (counter == MAX_ANSWERS)
- return EXIT(con,QUIT);
- Answer[counter] = va_arg(args,int);
- if (Answer[counter] == EOF ) break;
- counter++;
- }
-
- va_end(args);
-
-
- sprintf(S1,command,param);
-
- if ( FtpSendMessage(con,S1) == QUIT )
- return EXIT(con,QUIT);
-
- if ( (i=FtpGetMessage(con,S1)) == QUIT )
- return EXIT(con,QUIT);
-
- if ( ! FtpGood1 ( i , Answer ))
- return EXIT(con,-i);
-
- return EXIT(con,i);
-}
-
-
-
diff --git a/lib/libftp/FtpConnect.c b/lib/libftp/FtpConnect.c
deleted file mode 100644
index 4de95ab..0000000
--- a/lib/libftp/FtpConnect.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-STATUS FtpConnect(FTP **con,char * hostname)
-{
- struct sockaddr_in unit;
- register struct hostent *host;
- register int new_socket;
- String S1;
- STATUS x;
-
- *con = FtpCreateObject();
-
- if ((host=FtpGetHost(hostname))==NULL)
- return EXIT((*con),QUIT);
-
- strcpy((*con) -> title,host -> h_name); /* Default title for FtpLog */
-
- unit.sin_family = host -> h_addrtype; /* AF_INET */
-
- bcopy(host-> h_addr_list[0],(char *)&unit.sin_addr,host->h_length);
- if ( ( new_socket = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)
- return EXIT((*con),QUIT);
-
- unit.sin_port = htons((*con)->port);
-
- while ( connect ( new_socket , (struct sockaddr *)&unit , sizeof unit ) < 0 )
- {
- host -> h_addr_list ++;
- if (host -> h_addr_list[0]==NULL) {
- close(new_socket);
- return EXIT((*con),QUIT);
- }
- bcopy(host -> h_addr_list[0],(char *)&unit,host->h_length);
- close(new_socket);
- if ( ( new_socket = socket ( unit.sin_family , SOCK_STREAM , 0)) < 0)
- {
- close(new_socket);
- return EXIT((*con),QUIT);
- }
- }
-
- FTPCMD(*con) = fdopen(new_socket,"r+");
-
- if ( (x=FtpGetMessage(*con,S1)) == QUIT )
- return EXIT((*con),QUIT);
- if ( ! FtpGood(x,120,220,EOF))
- {
- close(new_socket);
- return EXIT((*con),-x);
- }
- if ( (*con)->mode != 'A' ) FtpType(*con,(*con)->mode);
-
- return EXIT((*con),x);
-}
-
-
-
diff --git a/lib/libftp/FtpCopy.c b/lib/libftp/FtpCopy.c
deleted file mode 100644
index db582d2..0000000
--- a/lib/libftp/FtpCopy.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpCopy (FTP * ftp1 , FTP * ftp2 ,char *in , char * out)
-{
- int size;
- char buffer[FTPBUFSIZ];
-
- if (!*out) out=in;
-
- if ( FtpTestFlag(ftp1,FTP_REST) && FtpTestFlag(ftp2,FTP_REST)
- && (size=FtpSize(ftp1,in))>0
- && FtpCommand(ftp1,"REST 0",0,0,EOF)==350 && FtpCommand(ftp2,"REST 0",0,0,EOF)==350 )
- ftp1->seek=ftp2->seek=size;
- else
- ftp1->seek=ftp2->seek=0;
-
- FtpAssert(ftp1,FtpData(ftp1,"RETR %s",in,"r"));
- FtpAssert(ftp2,FtpData(ftp2,"STOR %s",out,"w"));
-
- while ((size=FtpReadBlock(ftp1,buffer,FTPBUFSIZ))>0)
- {
- if (FtpWriteBlock(ftp2,buffer,size)!=size)
- return EXIT(ftp2,QUIT);
- }
-
- FtpAssert(ftp1,FtpClose(ftp1));
- FtpAssert(ftp2,FtpClose(ftp2));
- return 0;
-}
-
-
-
-
-
-
-
diff --git a/lib/libftp/FtpData.c b/lib/libftp/FtpData.c
deleted file mode 100644
index 066671f..0000000
--- a/lib/libftp/FtpData.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-STATUS FtpData(FTP * con,char * command , char * file ,char * mode)
-{
- struct sockaddr_in data,from;
- register struct hostent *host;
- String hostname;
- int NewSocket,Accepted_Socket,len=sizeof(data),one=1,fromlen=sizeof(from),
- i = 0;
- char *a,*b;
-
- FREE(data);
- FREE(from);
-
- if ( gethostname( hostname , sizeof hostname ) == -1 )
- return EXIT(con,QUIT);
-
- if ((host=(struct hostent *)gethostbyname(hostname))==0)
- return EXIT(con,QUIT);
-
- data.sin_family = host -> h_addrtype;
-
- bcopy(host-> h_addr_list[0],(char *)&data.sin_addr,host->h_length);
-
- if ((NewSocket = socket ( AF_INET , SOCK_STREAM , 0 ))<0)
- return EXIT(con,QUIT);
-
- if ( setsockopt ( NewSocket , SOL_SOCKET , SO_REUSEADDR ,
- (char *)&one , sizeof(one) ) < 0 )
- {
- close(NewSocket);
- return EXIT ( con,QUIT );
- }
-
- data.sin_port = 0 ;
-
- if ( bind ( NewSocket , (struct sockaddr *)&data , sizeof data ) < 0 )
- return EXIT(con,QUIT);
-
- if ( getsockname ( NewSocket , (struct sockaddr *)&data , &len ) < 0 )
- return EXIT(con,QUIT);
-
- if ( listen ( NewSocket , 1 ) < 0 )
- return EXIT(con,QUIT);
-
- a = ( char * ) & data.sin_addr;
- b = ( char * ) & data.sin_port;
-
- FtpAssert(con,FtpPort(con,CUT(a[0]),CUT(a[1]),CUT(a[2]),
- CUT(a[3]),CUT(b[0]),CUT(b[1])));
-
- if ( con -> seek != 0)
- {
- if ((i = FtpCommand ( con, "REST %d" , con -> seek , 0, EOF)) != 350 )
- return -i;
- }
-
- FtpAssert(con, FtpCommand ( con , command , file ,
- 200, 120 , 150 , 125 , 250 , EOF ));
-
- if (( Accepted_Socket = accept (NewSocket , (struct sockaddr *)&from , &fromlen )) < 0)
- {
- close(NewSocket);
- return EXIT(con,QUIT);
- }
-
- close(NewSocket);
-
- FTPDATA(con) = fdopen(Accepted_Socket, "r+");
-
- return i;
-}
-
-
-
-
-
diff --git a/lib/libftp/FtpDebug.c b/lib/libftp/FtpDebug.c
deleted file mode 100644
index d2b5af9..0000000
--- a/lib/libftp/FtpDebug.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-void FtpDebug(FTP *ftp)
-{
- STATUS FtpDebugDebug(),
- FtpDebugError(),
- FtpDebugIO();
-
- FtpSetDebugHandler(ftp,FtpDebugDebug);
- FtpSetErrorHandler(ftp,FtpDebugError);
- FtpSetIOHandler(ftp,FtpDebugIO);
-}
-
-STATUS FtpDebugDebug(FTP *ftp,int n, char * Message)
-{
- String tmp;
-
-
- strcpy(tmp,Message);
-
- if (strncmp(tmp,"PASS ",5)==0)
- {
- char *p=tmp+5;
- while ( *p != '\0') *p++='*';
- };
-
- FtpLog(ftp->title,tmp);
- return 1;
-}
-
-STATUS FtpDebugError(FTP *ftp,int n, char * Message)
-{
-
- FtpLog("FtpDebugError","");
- FtpLog(ftp->title,Message);
- if ( ! FtpTestFlag(ftp,FTP_NOEXIT))
- exit(1);
- return 0;
-}
-
-STATUS FtpDebugIO(FTP *ftp,int n, char * Message)
-{
- FtpLog("FtpDebugIO","");
- FtpLog(ftp->title,Message);
- if ( ! FtpTestFlag(ftp,FTP_NOEXIT))
- exit(1);
- return 0;
-}
-
-STATUS FtpLog(char *name,char *str)
-{
- time_t t=time((time_t *)0);
- struct tm *lt=localtime(&t);
- fprintf(stderr,"%02d:%02d:%02d %s %s\n",lt->tm_hour,
- lt->tm_min,lt->tm_sec,name,str);
- fflush(stderr);
- return 0;
-}
-
-int
-FtpHash(FTP *ftp, unsigned long chars)
-{
-
- if (chars==0) return ftp->counter=0;
- ftp->counter+=chars;
- fprintf(stdout,"%10u bytes transfered\r",(unsigned int)ftp->counter);
- fflush(stdout);
- return ftp->counter;
-}
-
-
-STATUS FtpBadReply550(char *s)
-{
- if(
- (strstr(s,"unreachable")!=NULL) ||
- (strstr(s,"Broken pipe")!=NULL)
- )
- return 0;
- return 1;
-}
diff --git a/lib/libftp/FtpFilenameChecker.c b/lib/libftp/FtpFilenameChecker.c
deleted file mode 100644
index 99946eb..0000000
--- a/lib/libftp/FtpFilenameChecker.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-*/
-
-#include "FtpLibrary.h"
-
-static char * simplename(char *s)
-{
- char *p;
-
- if ( (p=(char *)strrchr(s,'/')) == NULL )
- return s;
- return p+1;
-}
-
-
-
-
-STATUS FtpFilenameChecker(char ** in, char ** out)
-{
- struct stat st;
-
- if ( (stat(*out,&st) == 0) && S_ISDIR(st.st_mode))
- {
- char * sfn = simplename(*in);
- char * new = (char *) malloc ( strlen(*out)+ strlen(sfn) + 2 );
-
- strcpy(new,*out);
- strcat(new,"/");
- strcat(new,sfn);
- *out=new;
- return 0;
- };
- return 0;
-}
-
-
diff --git a/lib/libftp/FtpFull.c b/lib/libftp/FtpFull.c
deleted file mode 100644
index 51c87dc..0000000
--- a/lib/libftp/FtpFull.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-#include <pwd.h>
-
-static FTP *ftp_table[256];
-
-FILE * FtpFullOpen(char * file , char * mode )
-{
- FTP *ftp;
- FILE *tmp;
- String Host,User,Passwd,RemoteFile;
- STATUS i;
-
- if ( ! FtpFullSyntax (file,Host,User,Passwd,RemoteFile))
- {
- tmp=fopen(file,mode);
- if (tmp==NULL) return tmp;
- ftp_table[(int)fileno(tmp)] = NULL;
- return tmp;
- }
- if ( FtpError(i=FtpLogin(&ftp,Host,User,Passwd,NULL)))
- return NULL;
-
- if (mode[1]=='b') FtpBinary(ftp);
-
- switch(mode[0])
- {
- case 'r':
- if (FtpError(FtpOpenRead(ftp,RemoteFile)))
- return NULL;
- ftp_table[fileno(FTPDATA(ftp))] = ftp;
- return FTPDATA(ftp);
- case 'w':
- if (FtpError(FtpOpenWrite(ftp,RemoteFile)))
- return NULL;
- ftp_table[fileno(FTPDATA(ftp))] = ftp;
- return FTPDATA(ftp);
- case 'a':
- if (FtpError(FtpOpenAppend(ftp,RemoteFile)))
- return NULL;
- ftp_table[fileno(FTPDATA(ftp))] = ftp;
- return FTPDATA(ftp);
- }
- /* Error Mode */
- return NULL;
-}
-
-STATUS FtpFullClose(FILE *f)
-{
- FTP *ftp=ftp_table[(int)fileno(f)];
- if (ftp == NULL)
- return fclose(f);
- FtpClose(ftp);
- return FtpQuickBye(ftp);
-}
-
-
-/* Format of ftp's file [user[/passord]@]hostname:filename_with_path */
-
-STATUS FtpFullSyntax ( String source ,
- String host ,
- String user ,
- String passwd ,
- String file)
-
-{
- char *in,*out;
- String tmp;
-
- host[0] = user[0] = passwd[0] = file[0] = '\0';
-
- for ( in=source, out = user;
- *in !='\0' && *in != '/' && *in!='@' && *in!=':' ;
- *out++ = *in++);
- *out = '\0';
-
- if ( *in == '\0' ) return 0;
-
- if ( *in == ':' )
- {
- strcpy(host,user);
- strcpy(user,"anonymous");
- gethostname(tmp, sizeof tmp);
- sprintf(passwd,"%s@%s",
- getpwuid(getuid())->pw_name,gethostbyname(tmp)->h_name);
- goto file;
- }
-
- if ( *in == '/' )
- {
- for ( in++, out = passwd;
- *in !='\0' && *in!='@' ;
- *out++ = *in++);
- *out = '\0';
- if ( *in == '\0' ) return 0;
- }
- else
- {
- gethostname(tmp, sizeof tmp);
- sprintf(passwd,"%s@%s",
- getpwuid(getuid())->pw_name,gethostbyname(tmp)->h_name);
- }
-
-
- for ( in++, out = host;
- *in !='\0' && *in!=':' ;
- *out++ = *in++);
- *out = '\0';
-
- if ( *in == '\0' ) return 0;
-
-file:
-
- for ( in++, out = file;
- *in !='\0';
- *out++ = *in++);
- *out = '\0';
-
- return 1;
-}
-
-
-
-
-
-
-
-
diff --git a/lib/libftp/FtpGetHost.c b/lib/libftp/FtpGetHost.c
deleted file mode 100644
index 7171ba3..0000000
--- a/lib/libftp/FtpGetHost.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <arpa/inet.h>
-
-
-struct hostent *FtpGetHost(char *host)
-{
-
- static struct in_addr addr;
- static struct hostent _host;
- static char *point[2];
- static char *alias[1];
-
- bzero(&_host,sizeof _host);
- if ( (addr.s_addr=inet_addr(host)) != -1 )
- {
- _host.h_addr_list = point;
- _host.h_addr_list[0] = (char *) &addr;
- _host.h_addr_list[1] = (char *) 0;
- alias[0]=NULL;
- _host.h_aliases=alias;
- _host.h_name=host;
- _host.h_length=sizeof(unsigned long);
- _host.h_addrtype=AF_INET;
- return &_host;
- }
-
- return gethostbyname(host);
-}
-
-
diff --git a/lib/libftp/FtpGood.c b/lib/libftp/FtpGood.c
deleted file mode 100644
index 20af4e0..0000000
--- a/lib/libftp/FtpGood.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <varargs.h>
-
-STATUS FtpGood(va_alist)
- va_dcl
-{
- va_list args;
- int Number;
- int Answer[MAX_ANSWERS];
- int counter=0;
-
- va_start(args);
-
- Number = va_arg(args,int);
-
- while ( 1 )
- {
- if (counter == MAX_ANSWERS)
- return 0;
- Answer[counter] = va_arg(args,int);
- if (Answer[counter] == EOF ) break;
- counter++;
- }
-
- va_end(args);
-
- return FtpGood1(Number,Answer);
-}
-
-
-STATUS FtpGood1(int Number , int *Answer)
-{
- while (1)
- {
- if ( *Answer == Number) return 1;
- if ( *Answer == 0) return 1;
- if ( *Answer == EOF ) return 0;
- Answer++;
- }
-}
-
diff --git a/lib/libftp/FtpIO.c b/lib/libftp/FtpIO.c
deleted file mode 100644
index b7f6af5..0000000
--- a/lib/libftp/FtpIO.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/* Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the exist
-ing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-int FtpRead(FTP *con)
-{
- int c;
-
- if ( con -> mode == 'I' )
- return FtpGetc(con,FTPDATA(con));
-
- if ( con->ch != EOF )
- {
- c=con->ch;
- con->ch=EOF;
- return c;
- }
-
- c=FtpGetc(con,FTPDATA(con));
-
- if ( c == Ctrl('M') )
- {
- c = FtpGetc(con,FTPDATA(con));
-
- if ( c == Ctrl('J') )
- return '\n';
- con->ch = c;
- return Ctrl('M');
- }
- return c;
-}
-
-int FtpWrite(FTP *ftp,char c)
-{
-
- if ( ftp -> mode == 'I' || c != '\n' )
- return FtpPutc(ftp,FTPDATA(ftp),c);
-
- FtpPutc(ftp,FTPDATA(ftp),Ctrl('M'));
- return FtpPutc(ftp,FTPDATA(ftp),Ctrl('J'));
-}
-
-
-int FtpGetc(FTP *ftp,FILE *fp)
-{
- fd_set fds;
- char c;
-
- FD_ZERO(&fds);
- FD_SET(fileno(fp),&fds);
-
- if (select(getdtablesize(), &fds, 0, 0, &(ftp->timeout))<1)
- return EXIT(ftp,QUIT);
-
- if (read(fileno(fp),&c,1)<1)
- return EOF;
-
- if (ftp->hash!=NULL) (*ftp->hash)(ftp,1);
-
- return (int)c;
-}
-
-
-STATUS FtpPutc(FTP *ftp,FILE *fp,char c)
-{
- fd_set fds;
-
- FD_ZERO(&fds);
- FD_SET(fileno(fp),&fds);
-
- if (select(getdtablesize(), 0, &fds, 0, &(ftp->timeout))<1)
- return EXIT(ftp,QUIT);
-
- if (write(fileno(fp),&c,1)!=1)
- return EXIT(ftp,QUIT);
-
- if (ftp->hash!=NULL) (*ftp->hash)(ftp,1);
- return 0;
-}
-
-
-STATUS FtpReadBlock(FTP *ftp, char *buffer, int size)
-{
- fd_set fds;
- register int rsize;
-
- FD_ZERO(&fds);
- FD_SET(fileno(FTPDATA(ftp)),&fds);
-
- if (select(getdtablesize(), &fds,0, 0, &(ftp->timeout))<1)
- return EXIT(ftp,QUIT);
-
-
- if ((rsize=read(fileno(FTPDATA(ftp)),buffer,size))<0)
- return EXIT(ftp,QUIT);
-
- if (ftp->hash!=NULL && rsize!=0) (*ftp->hash)(ftp,rsize);
-
- if (ftp->mode == 'A')
- {
- char buffer2[size];
- register int i,ii;
-
- for (i=0,ii=0;i<rsize;i++,ii++)
- if (buffer[i]==Ctrl('M')&&buffer[i+1]==Ctrl('J'))
- buffer2[ii]='\n',i++;
- else
- buffer2[ii]=buffer[i];
-
- rsize=ii;
- bcopy(buffer2,buffer,rsize);
- }
- return rsize;
-}
-
-
-STATUS FtpWriteBlock(FTP *ftp, char *buffer, int size)
-{
- fd_set fds;
- register int wsize;
- char buffer2[size*2];
-
- FD_ZERO(&fds);
- FD_SET(fileno(FTPDATA(ftp)),&fds);
-
- if (select(getdtablesize(), 0, &fds, 0, &(ftp->timeout))<1)
- return EXIT(ftp,QUIT);
-
-
- if (ftp->mode=='A')
- {
- register int i,ii;
-
- for(i=0,ii=0;i<size;i++,ii++)
- if (buffer[i]=='\n')
- buffer2[ii++]=Ctrl('M'),buffer2[ii]=Ctrl('J');
- else
- buffer2[ii]=buffer[i];
- buffer=buffer2;
- size=ii;
- }
-
- if ((wsize=write(fileno(FTPDATA(ftp)),buffer,size))!=size)
- return EXIT(ftp,QUIT);
-
- if ( ftp->hash!=NULL && wsize!=0 ) (*ftp->hash)(ftp,wsize);
-
- return wsize;
-}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/libftp/FtpInit.c b/lib/libftp/FtpInit.c
deleted file mode 100644
index 4e43c8c..0000000
--- a/lib/libftp/FtpInit.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-FTP FtpInit = {
- NULL, /*sock*/
- NULL, /*data*/
- 'A', /*mode*/
- 0, /*errno*/
- 0, /*ch*/
- NULL,NULL,NULL, NULL, /*funcs*/
- 0, /*seek*/
- 0, /*flags*/
- {120,0}, /*timeout 2 min*/
- 21, /*Port*/
- "johndoe", /* Title */
- 0, /*Counter*/
-};
-
-FTP *FtpCreateObject()
-{
- FTP *new = (FTP *) malloc (sizeof(FTP));
-
- bcopy(&FtpInit,new,sizeof(FTP));
-
- return new;
-}
-
-
diff --git a/lib/libftp/FtpLibrary.h b/lib/libftp/FtpLibrary.h
deleted file mode 100644
index 754e5a1..0000000
--- a/lib/libftp/FtpLibrary.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-*/
-
-
-#ifndef __FTPLIBRARY_H
-#define __FTPLIBRARY_H
-
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/timeb.h>
-#include <sys/socket.h>
-#include <arpa/ftp.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <arpa/telnet.h>
-#include <sys/stat.h>
-
-
-#ifndef __FreeBSD__
-extern char *sys_errlist[];
-extern int errno;
-#else
-#include <errno.h>
-#endif
-
-
- /* Standard Macros & Definitions */
-
-
-
-#define EXIT(con,e) \
- ( con -> errno = e, \
- ((e==QUIT||e==LQUIT)&&(con->IO != NULL))?(*(con->IO))(con,e,sys_errlist[errno]):0,\
- ((con->error != NULL) && (e < 0) )?(*(con->error))(con,e,FtpMessage(e)):0,\
- e)
-
-
-#define MAX_ANSWERS 10 /* Number of known goodest answers for reqest */
-#define NFDS 64
-#define FTPBUFSIZ BUFSIZ
-#define LQUIT (-6)
-#define QUIT (-5) /* Few time ago QUIT character been
- equivalence to zero, changed for clear
- conflicts with reading functions */
-#define Ctrl(x) ((x) - '@')
-#define FREE(x) memset ( &(x) , '\0' , sizeof (x) )
-#define CUT(x) ((x)&0xff)
-#define FtpError(x) ((x)<0)
-#define FtpAssert(ftp,x) if (FtpError(x)) return EXIT((ftp),(ftp)->errno);
-
-typedef int STATUS;
-typedef char String[256];
-
-#ifdef __GNUC__
-#define INLINE inline
-#else
-#define INLINE
-#endif
-
-
-
- /* Common Information Structure */
-
-typedef struct/* All structure initialize from edited struct FtpInit */
-{
- FILE *sock; /* Command stream to server */
-
-#define FTPDATA(x) ((x)->data)
-#define FTPCMD(x) ((x)->sock)
-
-
- FILE *data; /* Data stream to server */
- char mode; /* Binary, Ascii, ......... */
- int errno; /* Last error code */
- int ch; /* Help character for ascii streams */
-
- STATUS (*error)();
- STATUS (*debug)();
- STATUS (*IO)();
- STATUS (*hash)(); /* Call with reading/writing next "int" characters
- from stream */
- int seek; /*
- Warning! If server not supported REST-command,
- then seek variable automaticaly turn to zero
- */
- int flags; /* FTP_REST,
- FTP_NOEXIT */
- struct timeval timeout;
- /* How long must be waiting next character
- from server */
- int port;
- String title; /* Using for FtpLog, FtpConnect lets hostname */
- unsigned long counter;
- /* Using by FtpHash */
-} FTP;
-
-typedef struct
-{
- struct tm createtime;
- unsigned long size;
- String host;
- String file;
-} ARCHIE;
-
-
-enum {FTP_REST=1,FTP_NOEXIT=2};
-enum {no,yes};
-enum {off,on};
-enum {false,true};
-
-extern FTP FtpInit;
-
-/* Options defines */
-
-#define FtpSetFlag(ftp,flag) ((ftp)->flags|=(flag))
-#define FtpClearFlag(ftp,flag) ((ftp)->flags &= (~(flag)) )
-#define FtpTestFlag(ftp,flag) ((ftp)->flags&(flag)==flag)
-#define FtpSetTimeout(ftp,tim) \
- ((ftp)->timeout.tv_sec=tim,(ftp)->timeout.tv_usec=0)
-#define FtpSetPort(ftp,prt) ((ftp)->port=(prt))
-
-/* Connect & disconnect */
-
-STATUS FtpConnect(FTP **con,char *hostname);
-#define FtpUser(ftp,user) FtpCommand(ftp,"USER %s",user,230,331,332,EOF)
-#define FtpPassword(ftp,pas) FtpCommand(ftp,"PASS %s",pas,230,332,EOF)
-#define FtpAccount(ftp,acc) FtpCommand(ftp,"ACCT %s",acc,230,EOF)
-STATUS FtpLogin(FTP **con,char *host ,char *user,char *pass,char *acct);
-STATUS FtpBye (FTP * con);
-STATUS FtpQuickBye (FTP * con);
-STATUS FtpAbort(FTP *ftp);
-
-/* Set type of transfer */
-
-STATUS FtpType(FTP *ftp,char type);
-#define FtpAscii(ftp) FtpType(ftp,'A')
-#define FtpBinary(ftp) FtpType(ftp,'I')
-
-
-/* Send/Receive and handling Procedure(s) */
-
-STATUS FtpCopy(FTP *ftp1, FTP *ftp2, char *in, char *out);
-STATUS FtpPassiveTransfer(FTP *ftp1, FTP *ftp2, char *in, char *out);
-
-STATUS FtpRetr(FTP *con, char *command,char *inp,char *out);
-#define FtpGet(ftp,in,out) FtpRetr(ftp,"RETR %s",in,out)
-#define FtpDirectory(ftp,pat,out) FtpRetr(ftp,"LIST %s",pat,out)
-#define FtpDir(ftp,out) FtpRetr(ftp,"LIST","",out)
-
-STATUS FtpStor(FTP *con ,char*command ,char *inp,char *out);
-#define FtpPut(ftp,in,out) FtpStor(ftp,"STOR %s",in,out)
-
-STATUS FtpData( FTP * con , char * command , char * param , char *mode);
-STATUS FtpPort ( FTP *con ,int ,int ,int ,int ,int ,int );
-#define FtpOpenRead(ftp,file) FtpData(ftp,"RETR %s",file,"r")
-#define FtpOpenWrite(ftp,file) FtpData(ftp,"STOR %s",file,"w")
-#define FtpOpenAppend(ftp,file) FtpData(ftp,"APPE %s",file,"r")
-STATUS FtpOpenDir( FTP * con , char * files );
-STATUS FtpClose ( FTP *);
-
-STATUS FtpReadBlock(FTP *ftp, char *buffer, int size);
-STATUS FtpWriteBlock(FTP *ftp, char *buffer, int size);
-
-/* Command for hand transfer */
-
-STATUS FtpRead ( FTP * con);
-STATUS FtpWrite ( FTP * con , char c);
-int FtpGetc ( FTP * ftp, FILE *fp );
-STATUS FtpPutc (FTP *ftp, FILE *fp, char c);
-
-/* Manipulation commands for remote server */
-
-STATUS FtpCommand ();
-#define FtpChdir(ftp,dir) FtpCommand(ftp,"CWD %s",dir,200,250,EOF)
-#define FtpMkdir(ftp,dir) FtpCommand(ftp,"MKD %s",dir,200,257,EOF)
-#define FtpRm(ftp,dir) FtpCommand(ftp,"DELE %s",dir,200,250,EOF)
-char *FtpPwd(FTP *con);
-int FtpSize(FTP *con,char *filename);
-STATUS FtpMove ( FTP *con,char * old,char *new);
-
-/* Procedures for dialog with remote server */
-
-STATUS FtpInitMessageList();
-STATUS FtpSendMessage( FTP * con , char * Message );
-int FtpGetMessage( FTP * con , char * Message);
-char *FtpMessage(int Number);
-int FtpNumber ( char * Message );
-
-
-/* Debug */
-
-#define FtpSetErrorHandler(con,f) (con)->error = f
-#define FtpSetDebugHandler(con,f) (con)->debug = f
-#define FtpSetIOHandler(con,f) (con)->IO =f
-#define FtpSetHashHandler(con,f) (con)->hash =f
-#define FtplibDebug(t) FtpDebug(&FtpInit)
-
-STATUS FtpDebugDebug ( FTP *con, int errno, char * Message);
-STATUS FtpDebugError ( FTP *con, int errno, char * Message);
-STATUS FtpDebugIO ( FTP *con, int errno, char * Message);
-STATUS FtpLog(char *progtitle, char *msg);
-STATUS FtpHash ( FTP *con, unsigned long number_of_bytes );
-void FtpDebug ( FTP * con );
-STATUS FtpBadReply550 (char *message);
-
-
-/* Other Procedures */
-
-FTP *FtpCreateObject();
-FILE *FtpFullOpen(char * file,char * mode );
-STATUS FtpFullSyntax(String,String,String,String,String);
-FILE *Ftpfopen(char *filename,char *mode);
-STATUS Ftpfclose(FILE *);
-STATUS FtpFullClose(FILE *);
-STATUS FtpGood ();
-STATUS FtpGood1 (int, int *);
-struct hostent *FtpGetHost(char *host);
-STATUS FtpFilenameChecher(char *input, char *output);
-STATUS FtpLink(FTP *,FTP *);
-int FtpArchie(char *what, ARCHIE *, int number);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/* Additional definitions */
-
-#ifdef _AIX
-int accept (int, struct sockaddr_in*, int*);
-char *bcopy (char*, char*, size_t);
-int bind (int, const void*, int);
-int connect (int, struct sockaddr_in*, int);
-int gethostname (char*, size_t);
-int getsockname (int, struct sockaddr_in*, int*);
-int getpeername (int, struct sockaddr_in*, int*);
-int getsockopt (int, int, int, void*, int*);
-int listen(int, int);
-int setsockopt (int, int, int, void*, int);
-int socket (int, int, int);
-void free (void*);
-void *malloc (size_t);
-#endif
-
-
-
-
-#endif /* __FTPLIBRARYH_ */
-
-
-
diff --git a/lib/libftp/FtpLogin.c b/lib/libftp/FtpLogin.c
deleted file mode 100644
index e066d55..0000000
--- a/lib/libftp/FtpLogin.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpLogin ( FTP ** con, char * host , char * user ,
- char * password , char * account)
-{
-
- FtpAssert((*con),FtpConnect(con,host));
- FtpAssert((*con),FtpUser((*con),user));
- if (((*con)->errno)==230 )
- return ((*con)->errno);
- if (((*con)->errno)==332)
- {
- if ( account == NULL )
- return EXIT(((*con)),(*con)->errno);
- FtpAssert((*con),FtpAccount( (*con) , account ));
- if ( ((*con)->errno)==230 )
- return (*con)->errno;
- }
- return FtpPassword((*con),password);
-}
diff --git a/lib/libftp/FtpMessage.c b/lib/libftp/FtpMessage.c
deleted file mode 100644
index 8009d05..0000000
--- a/lib/libftp/FtpMessage.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <ctype.h>
-
-static char * FtpMessageList[1000];
-
-INLINE static char *___gets(char *s, int maxchars, FTP *ftp)
-{
- char *p=s;
- int c;
-
- while (1)
- {
- if ((c = FtpGetc(ftp,FTPCMD(ftp))) == EOF)
- return NULL;
-
- if ( c == '\n' && *(p-1) == '\r' )
- {
- p--;
- *p='\0';
- return s;
- }
-
- if ( (p-s) > maxchars ) return NULL;
-
- *p++=(char)c;
- }
-}
-
-
-
-
-int FtpGetMessage(FTP *con , char * Message )
-{
- int n;
- char tmp[1024];
-
- while(1)
- {
- if (___gets(tmp,sizeof tmp,con)==NULL)
- return EXIT(con,QUIT);
- if (isdigit(tmp[0]) &&
- isdigit(tmp[1]) &&
- isdigit(tmp[2]) &&
- tmp[3]!='-') break;
- if ( con -> debug != NULL )
- (*con->debug)(con,0,tmp);
- }
-
- strcpy(Message,tmp);
- FtpInitMessageList();
- FtpMessageList[n=FtpNumber(Message)] =
- ( char * ) malloc ( strlen(Message) + 1);
- strcpy(FtpMessageList[n] , Message );
- if ( con -> debug != NULL )
- (*con->debug)(con,n,Message);
-
- return n;
-}
-
-STATUS FtpSendMessage(FTP *ftp,char * Message )
-{
- char *msg=Message;
-
- while (*Message)
- FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),*Message++));
-
- FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),'\015'));
- FtpAssert(ftp,FtpPutc(ftp,FTPCMD(ftp),'\012'));
-
- if ( ftp -> debug != NULL )
- (*ftp->debug)(ftp,0,msg);
- return 1;
-}
-
-char *FtpMessage(int number)
-{
- extern int sys_nerr,errno;
-#ifndef __FreeBSD__
- extern char *sys_errlist[];
-#endif
-
- FtpInitMessageList();
- if ( number == 0 )
- return (char *)sys_errlist[errno];
- return (FtpMessageList[abs(number)]==NULL)?
- "":FtpMessageList[abs(number)];
-}
-
-
-STATUS FtpInitMessageList()
-{
- int i;
- static u = 0;
-
- if ( u )
- return 1;
-
- u = 1;
-
- for (i=0;i<1000;i++)
- FtpMessageList[i]=NULL;
-
- return 1;
-}
-
-int FtpNumber(char *Message)
-{
- return (Message[0] - '0') * 100 +
- (Message[1] - '0') * 10 +
- (Message[2] - '0') ;
-}
-
-
-
-
-
diff --git a/lib/libftp/FtpMove.c b/lib/libftp/FtpMove.c
deleted file mode 100644
index 8037b6b..0000000
--- a/lib/libftp/FtpMove.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpMove(FTP *con,char * oldname , char * newname )
-{
- STATUS i;
-
- if ((i=FtpCommand(con,"RNFR %s",oldname,200,350,EOF)) > 1 )
- return FtpCommand(con,"RNTO %s",newname,200,250,EOF);
- else
- return i;
-}
diff --git a/lib/libftp/FtpNumber.c b/lib/libftp/FtpNumber.c
deleted file mode 100644
index a6d7114..0000000
--- a/lib/libftp/FtpNumber.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-int FtpNumber(char *Message)
-{
- return (Message[0] - '0') * 100 +
- (Message[1] - '0') * 10 +
- (Message[2] - '0') ;
-}
diff --git a/lib/libftp/FtpOpenDir.c b/lib/libftp/FtpOpenDir.c
deleted file mode 100644
index 3f2bcf1..0000000
--- a/lib/libftp/FtpOpenDir.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpOpenDir(FTP * con,char * file)
-{
- String command;
-
- if ( file == NULL || *file == '\0' )
- strcpy(command,"NLST");
- else
- sprintf(command,"NLST %s",file);
-
- return FtpCommand(con,command,"",120,150,200,EOF);
-}
diff --git a/lib/libftp/FtpPasv.c b/lib/libftp/FtpPasv.c
deleted file mode 100644
index 3dd52fe..0000000
--- a/lib/libftp/FtpPasv.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the exist
-ing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-#include <ctype.h>
-
-char * FtpPasv (FTP *ftp)
-{
- char *msg;
- static String PORT;
- char *p=PORT;
-
- if FtpError(FtpCommand(ftp,"PASV","",227,EOF))
- return "";
-
- msg = FtpMessage (227);
-
- msg+=3;
-
- while (!isdigit(*msg++));
- msg--;
-
- while (isdigit(*msg)||*msg==',') *p++=*msg++;
- *p=0;
-
- return PORT;
-}
-
-
-STATUS FtpLink(FTP *ftp1, FTP *ftp2)
-{
-
- String PORT;
-
- strcpy(PORT,FtpPasv(ftp1));
-
- FtpCommand(ftp2,"PORT %s",PORT,200,EOF);
- return 0;
-}
-
-STATUS FtpPassiveTransfer(FTP *ftp1, FTP *ftp2, char *f1, char *f2)
-{
- String tmp;
- fd_set fds;
-
- FtpAssert(ftp1,FtpLink(ftp1,ftp2));
-
-
- if (!*f2) f2=f1;
-
- FtpAssert(ftp2,FtpCommand(ftp2,"STOR %s",f2, 200, 120 , 150 , 125 , 250 , EOF ));
- FtpAssert(ftp1,FtpCommand(ftp1,"RETR %s",f1, 200, 120 , 150 , 125 , 250 , EOF ));
-
- FD_ZERO(&fds);
-
- FD_SET(fileno(FTPCMD(ftp1)),&fds);
- FD_SET(fileno(FTPCMD(ftp2)),&fds);
-
- if (select(getdtablesize(),&fds,0,0,0)<0)
- {
- if (ftp1->error!=NULL)
- return (*(ftp1->error))(ftp1,QUIT,sys_errlist[errno]);
- if (ftp2->error!=NULL)
- return (*(ftp2->error))(ftp1,QUIT,sys_errlist[errno]);
- return QUIT;
- }
-
- if (FD_ISSET(fileno(FTPCMD(ftp1)),&fds))
- {
- FtpGetMessage(ftp1,tmp);
- FtpLog(ftp1->title,tmp);
- FtpGetMessage(ftp2,tmp);
- FtpLog(ftp2->title,tmp);
- }
- else
- {
- FtpGetMessage(ftp2,tmp);
- FtpLog(ftp2->title,tmp);
- FtpGetMessage(ftp1,tmp);
- FtpLog(ftp1->title,tmp);
- }
- return 0;
-}
-
-
-
-
-
diff --git a/lib/libftp/FtpPort.c b/lib/libftp/FtpPort.c
deleted file mode 100644
index eb15ac0..0000000
--- a/lib/libftp/FtpPort.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpPort(FTP *con,int a,int b,int c,int d,int e,int f)
-{
- String cmd;
- int i;
-
- sprintf(cmd,"PORT %d,%d,%d,%d,%d,%d",a,b,c,d,e,f);
- if ( FtpSendMessage(con,cmd) == QUIT)
- return QUIT;
- if ( (i=FtpGetMessage(con,cmd)) == QUIT)
- return QUIT;
-
- if ( ! FtpGood ( i , 200 , EOF ))
- return EXIT(con,-i);
-
- return EXIT(con,i);
-}
diff --git a/lib/libftp/FtpPwd.c b/lib/libftp/FtpPwd.c
deleted file mode 100644
index 59c792d..0000000
--- a/lib/libftp/FtpPwd.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-char * FtpPwd(FTP * con)
-{
- String tmp;
- static String tmp1;
- int i;
-
- if ( FtpSendMessage(con,"PWD") == QUIT )
- return (char *) EXIT(con,QUIT);
- if ( (i=FtpGetMessage(con,tmp)) == QUIT )
- return (char *) EXIT(con,QUIT);
-
- if ( i != 257 )
- return (char *) EXIT(con,-i);
-
- sscanf(tmp,"%*[^\"]%*c%[^\"]%*s",tmp1);
- con -> errno = i;
- return tmp1;
-}
diff --git a/lib/libftp/FtpRetr.c b/lib/libftp/FtpRetr.c
deleted file mode 100644
index ced19b8..0000000
--- a/lib/libftp/FtpRetr.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-extern STATUS FtpFilenameChecker(char ** in, char ** out);
-
-STATUS FtpRetr (FTP * con , char * command ,
- char *in , char * out)
-{
- FILE *o;
- struct stat st;
- char buffer[FTPBUFSIZ];
- register int size;
-
- FtpFilenameChecker(&in,&out);
-
- if ( FtpTestFlag(con,FTP_REST) && stat(out,&st)==0)
- {
- con -> seek = st.st_size;
- if ((o=Ftpfopen(out,"a+"))==NULL)
- return EXIT(con,LQUIT);
- }
- else
- {
- con -> seek = 0;
- if ((o=Ftpfopen(out,"w+"))==NULL)
- return EXIT(con,LQUIT);
- }
-
-
- if ( FtpError(FtpData(con,command,in,"r")))
- {
-
- if (con->seek==0) return EXIT(con,con->errno);
-
- con -> seek = 0;
- fclose(o);
-
- if ( FtpError(FtpData(con,command,in,"r")) )
- {
- return EXIT(con,con->errno);
- }
-
- if ((o=Ftpfopen(out,"w+"))==NULL)
- return EXIT(con,LQUIT);
- }
-
-
- fseek(o,con->seek,0);
-
- while((size=FtpReadBlock(con,buffer,FTPBUFSIZ))>0)
- {
- if (write(fileno(o),buffer,size)!=size)
- return EXIT(con,LQUIT);
- }
-
- Ftpfclose(o);
- return FtpClose(con);
-}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/lib/libftp/FtpSize.c b/lib/libftp/FtpSize.c
deleted file mode 100644
index 581e186..0000000
--- a/lib/libftp/FtpSize.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-int FtpSize(FTP * con, char *filename)
-{
- String tmp;
- int i,size;
-
- strcpy(tmp,"SIZE ");
- strcat(tmp,filename);
-
- if ( FtpSendMessage(con,tmp) == QUIT )
- return EXIT(con,QUIT);
- if ( (i=FtpGetMessage(con,tmp)) == QUIT )
- return EXIT(con,QUIT);
-
- if ( i != 213 )
- return con -> errno = (-i);
-
- sscanf(tmp,"%*d %d",&size);
- return size;
-}
diff --git a/lib/libftp/FtpStor.c b/lib/libftp/FtpStor.c
deleted file mode 100644
index 9cd0e4e..0000000
--- a/lib/libftp/FtpStor.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-
-STATUS FtpStor (FTP * con , char * command ,
- char *in , char * out)
-{
- FILE *i;
- char buffer[FTPBUFSIZ];
- int size;
-
- con->seek=0;
-
- if ( (i=Ftpfopen(in,"rb")) == NULL )
- return EXIT(con,LQUIT);
-
- if ( FtpTestFlag(con,FTP_REST) &&
- (con->seek=FtpSize(con,out))<0 )
- con->seek=0;
-
-
- if ( FtpError(FtpData(con,command,out,"w")))
- {
- if (con->seek==0) return EXIT(con,con->errno);
-
- con -> seek =0;
- if ( FtpError(FtpData(con,command,out,"w")) )
- return EXIT(con,con->errno);
- }
-
- if (con->seek) fseek(i,con->seek,0);
-
- while ( (size=read ( fileno(i) , buffer, FTPBUFSIZ ))>0)
- FtpWriteBlock(con,buffer,size);
-
- Ftpfclose(i);
- return FtpClose(con);
-}
-
-
-
-
-
-
-
diff --git a/lib/libftp/FtpSyscalls.c b/lib/libftp/FtpSyscalls.c
deleted file mode 100644
index 67fa4ca..0000000
--- a/lib/libftp/FtpSyscalls.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-#include <unistd.h>
-#include <errno.h>
-
-#define DEF(syscal,name) int name(void *a, void *b, void *c) \
-{\
- register int status;\
- while (((status=syscal(a,b,c))==-1) && (errno==EINTR));\
- return status;\
-}
-
-DEF(open,nointr_open)
-DEF(close,nointr_close)
-DEF(select,nointr_select)
-DEF(read,nointr_read)
-DEF(write,nointr_write)
-DEF(dup,nointr_dup)
-DEF(wait,nointr_wait)
-DEF(connect,nointr_connect)
-DEF(listen,nointr_listen)
-DEF(accept,nointr_accept)
diff --git a/lib/libftp/FtpType.c b/lib/libftp/FtpType.c
deleted file mode 100644
index ae0d0ea..0000000
--- a/lib/libftp/FtpType.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include "FtpLibrary.h"
-
-STATUS FtpType(FTP *ftp, char type)
-{
- STATUS p;
-
- if ((p=FtpCommand(ftp,"TYPE %c",type,200,EOF))>0)
- ftp->mode=(int)type;
- return p;
-}
-
-
diff --git a/lib/libftp/Ftpfopen.c b/lib/libftp/Ftpfopen.c
deleted file mode 100644
index 9b89bb3..0000000
--- a/lib/libftp/Ftpfopen.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-#include <FtpLibrary.h>
-
-#define NFSD 256
-
-static int fds_types[NFDS];
-static int init=0;
-
-enum {T_EMPTY=0,T_FILE,T_STREAM,T_PIPE,T_FULL};
-
-FILE *Ftpfopen(char *filename,char *mode)
-{
- FILE *fp;
-
- if (!init)
- {
- bzero(fds_types,NFDS*sizeof(fds_types[0]));
- init=1;
- }
-
- if (!strcmp(filename,"*STDIN*") || (!strcmp(filename,"-") && (mode[0]=='r')) )
- {
- fds_types[fileno(stdin)]=T_STREAM;
- return stdin;
- }
-
- if (!strcmp(filename,"*STDOUT*") || (!strcmp(filename,"-") && (mode[0]=='w')))
- {
- fds_types[fileno(stdout)]=T_STREAM;
- return stdout;
- }
-
- if (strcmp(filename,"*STDERR*")==0)
- {
- fds_types[fileno(stderr)]=T_STREAM;
- return stderr;
- }
-
-
-
- if (*filename=='|')
- {
- fp=popen(filename+1,mode);
- if (fp==NULL) return fp;
- fds_types[fileno(fp)]=T_PIPE;
- return fp;
- }
-
- fp=FtpFullOpen(filename,mode);
- if (fp==NULL) return fp;
- fds_types[fileno(fp)]=T_FILE;
- return fp;
-
-}
-
-int Ftpfclose(FILE *fp)
-{
-
- if (!init)
- {
- bzero(fds_types,NFDS*sizeof(fds_types[0]));
- init=1;
- }
-
- switch (fds_types[fileno(fp)])
- {
-
- case T_FILE:
-
- return FtpFullClose(fp);
-
- case T_STREAM:
-
- return fflush(fp);
-
- case T_PIPE:
-
- return pclose(fp);
-
- default:
-
- return -1;
- }
-
-}
diff --git a/lib/libftp/Makefile b/lib/libftp/Makefile
deleted file mode 100644
index ebb6b5b..0000000
--- a/lib/libftp/Makefile
+++ /dev/null
@@ -1,20 +0,0 @@
-LIB= ftp
-CFLAGS+= -I${.CURDIR} -Wall
-
-SRCS= FtpAbort.c FtpFull.c FtpPasv.c \
- FtpArchie.c FtpGetHost.c FtpPort.c \
- FtpBye.c FtpGood.c FtpPwd.c \
- FtpClose.c FtpIO.c FtpRetr.c \
- FtpCommand.c FtpInit.c FtpSize.c \
- FtpConnect.c FtpLogin.c FtpStor.c \
- FtpCopy.c FtpMessage.c \
- FtpData.c FtpMove.c FtpType.c \
- FtpDebug.c Ftpfopen.c \
- FtpFilenameChecker.c FtpOpenDir.c
-
-beforeinstall:
- -cd ${.CURDIR}; cmp -s FtpLibrary.h ${DESTDIR}/usr/include/FtpLibrary.h || \
- install -c -o ${BINOWN} -g ${BINGRP} -m 444 FtpLibrary.h \
- ${DESTDIR}/usr/include
-
-.include <bsd.lib.mk>
diff --git a/lib/libftp/doc/example.c b/lib/libftp/doc/example.c
deleted file mode 100644
index 0606592..0000000
--- a/lib/libftp/doc/example.c
+++ /dev/null
@@ -1,51 +0,0 @@
-
-/* Include standard libftp's header */
-
-#include <FtpLibrary.h>
-
-
-
-main(int argc, char *argv[])
-{
-
- FILE *input,*output;
- int c;
-
-
- if (argc<3)
- exit(fprintf(stderr,"Usage: %s input-file output-file\n",argv[0]));
-
- FtplibDebug(yes);
-
- if ((input=Ftpfopen(argv[1],"r"))==NULL)
- {
- perror(argv[1]);
- exit(1);
- }
-
- if ((output=Ftpfopen(argv[2],"w"))==NULL)
- {
- perror(argv[2]);
- exit(1);
- }
-
- while ( (c=getc(input)) != EOF && (putc(c,output)!=EOF) );
-
- if (ferror(input))
- {
- perror(argv[1]);
- exit(1);
- }
-
- if (ferror(output))
- {
- perror(argv[1]);
- exit(1);
- }
-
- Ftpfclose(input);
- Ftpfclose(output);
-
- exit(0);
-
-}
diff --git a/lib/libftp/utils/Makefile b/lib/libftp/utils/Makefile
deleted file mode 100644
index bae516b..0000000
--- a/lib/libftp/utils/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# A rather bogus Makefile, but one intended to be used by hand anyway..
-#
-
-CFLAGS = -I${.CURDIR} -I${.CURDIR}/.. -DREADLINE
-LDADD+= -L${.CURDIR}
-DPADD+= libetc.a
-
-.if exists(${.CURDIR}/../obj)
-LDADD+= -L${.CURDIR}/../obj
-DPADD+= ${.CURDIR}/../obj/libftp.a
-.else
-LDADD+= -L${.CURDIR}/..
-DPADD+= ${.CURDIR}/../libftp.a
-.endif
-
-all: ftptry mirror uftp
-
-ftptry: ftptry.o
- $(CC) $(CFLAGS) -o ftptry ftptry.o ${LDADD} -lftp
-
-uftp: uftp.o uftpcmd.o libetc.a
- $(CC) $(CFLAGS) -o uftp uftp.o uftpcmd.o ${LDADD} -lftp -letc
-
-mirror: mirror.o
- $(CC) $(CFLAGS) -o mirror mirror.o ${LDADD} -lftp
-
-clean:
- rm -f ftptry mirror uftp *~ *.o *.a
-
-LIBOBJS= readline.o glob.o
-libetc.a: $(LIBOBJS)
- ar qc libetc.a $(LIBOBJS)
- ranlib libetc.a
diff --git a/lib/libftp/utils/cdefs.h b/lib/libftp/utils/cdefs.h
deleted file mode 100644
index aede2ec..0000000
--- a/lib/libftp/utils/cdefs.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)cdefs.h 8.7 (Berkeley) 1/21/94
- */
-
-#ifndef _CDEFS_H_
-#define _CDEFS_H_
-
-#if defined(__cplusplus)
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS };
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-
-#if (defined(__STDC__) || defined(__cplusplus))
-#define __const const /* define reserved names to standard */
-#define __signed signed
-#define __volatile volatile
-#if defined(__cplusplus)
-#define __inline inline /* convert to C++ keyword */
-#else
-#ifndef __GNUC__
-#define __inline /* delete GCC keyword */
-#endif /* !__GNUC__ */
-#endif /* !__cplusplus */
-
-#else /* !(__STDC__ || __cplusplus) */
-#define __P(protos) () /* traditional C preprocessor */
-#define __CONCAT(x,y) x/**/y
-#define __STRING(x) "x"
-
-#ifndef __GNUC__
-#define __const /* delete pseudo-ANSI C keywords */
-#define __inline
-#define __signed
-#define __volatile
-/*
- * In non-ANSI C environments, new programs will want ANSI-only C keywords
- * deleted from the program and old programs will want them left alone.
- * When using a compiler other than gcc, programs using the ANSI C keywords
- * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
- * When using "gcc -traditional", we assume that this is the intent; if
- * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
- */
-#ifndef NO_ANSI_KEYWORDS
-#define const /* delete ANSI C keywords */
-#define inline
-#define signed
-#define volatile
-#endif
-#endif /* !__GNUC__ */
-#endif /* !(__STDC__ || __cplusplus) */
-
-/*
- * GCC1 and some versions of GCC2 declare dead (non-returning) and
- * pure (no side effects) functions using "volatile" and "const";
- * unfortunately, these then cause warnings under "-ansi -pedantic".
- * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
- * these work for GNU C++ (modulo a slight glitch in the C++ grammar
- * in the distribution version of 2.5.5).
- */
-#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5
-#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define __dead __volatile
-#define __pure __const
-#endif
-#endif
-
-/* Delete pseudo-keywords wherever they are not available or needed. */
-#ifndef __dead
-#define __dead
-#define __pure
-#endif
-
-#endif /* !_CDEFS_H_ */
diff --git a/lib/libftp/utils/ftptry.c b/lib/libftp/utils/ftptry.c
deleted file mode 100644
index 7dfb130..0000000
--- a/lib/libftp/utils/ftptry.c
+++ /dev/null
@@ -1,633 +0,0 @@
-/*
-Library for ftpd clients.(libftp)
- Copyright by Oleg Orel
- All rights reserved.
-
-This library is desined for free, non-commercial software creation.
-It is changeable and can be improved. The author would greatly appreciate
-any advises, new components and patches of the existing programs.
-Commercial usage is also possible with participation of it's author.
-
-
-
-*/
-
-char intro[]="\
- Ftptry - try transfer via FTP.\n\
- Copyright by Oleg Orel is Reserved.\n\
-\n\
-This program is writen using \"libftp\".The main orientation for this\n\
-program is FTPing via bad-working network. Many network links are\n\
-down-up switched and networks are broaken, so the problem of\n\
-transfering large files exists. The main method, used by this\n\
-software is repetition until successfull transfer. There are some\n\
-keys for setting repetition and timeout intervals, modes of transfer\n\
-(binary and ascii), types of transfer (get,put,directory). All options\n\
-will be described in usage, if the program is started without them.\n\
-\n\
- The libftp you may transfer from host lpuds.oea.ihep.su via ftp-anonymous.\n\
- All question are sent to author via e-mail (orel@oea.ihep.su)\n\
- ";
-
-#include <FtpLibrary.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <signal.h>
-#include <setjmp.h>
-#include <string.h>
-
-#ifdef __GNUC__
-#define INLINE inline
-#else
-#define inline
-#endif
-
-#define FTPTRY "FTPTRY" /* The name of enviroment
- variable with default options*/
-#define log(x) FtpLog("ftptry",x)
-#define DEBUG(x) (debug?log(x):0)
-#define USERNAME (getenv("USER")==NULL?getenv("LOGNAME"):getenv("USER"))
-#define DEFAULT_TIMEOUT 600
-
-
-enum __type__ {ascii=1,binary};
-enum __mode__ {get=1,put,dir,multiget};
-enum __logmode__ {lm_tty,lm_file,lm_mail};
-enum __rcode__ {OK_, BREAK_, CANCEL_};
-
-char *gethost();
-char *date();
-int my_abort();
-int my_IO();
-int my_debug();
-void done(),leave(),sighup();
-
-char
- *machine ="localhost",
- *user="anonymous",
- *password,
- *localfile=NULL,
- *progname="ftptry";
-
-jmp_buf stack,trap;
-int counter=0;
-String tmp;
-FTP *ftp;
-int type=ascii;
-int sleeptime=600;
-int debug=false;
-int mode=get;
-int logmode=lm_tty;
-char *logfile=NULL;
-FILE *LIST=NULL;
-extern int errno;
-extern char *optarg;
-extern int optind, opterr;
-String PASSWORD;
-
-
-/* Setup enviroment */
-
-main(int argc,char **argv)
-{
- FILE *out,*in;
- int i;
-
- if (setjmp(trap)!=0)
- exit(1);
-
- signal(SIGHUP,sighup);
- signal(SIGTRAP,done);
- signal(SIGINT,done);
- signal(SIGQUIT,done);
-
- sprintf(password=PASSWORD,"%s@%s",
- USERNAME,
- gethost());
-
- progname=argv[0];
-
- FtpDebug(&FtpInit);
- FtpSetErrorHandler(&FtpInit,my_abort);
- FtpSetIOHandler(&FtpInit,my_IO);
- FtpSetFlag(&FtpInit,FTP_REST);
- FtpSetTimeout(&FtpInit,DEFAULT_TIMEOUT);
-
- setoptions();
- optind=1;
- options(argc,argv);
- if ( argc<2 ) usage();
-
- switch(logmode)
- {
-
- case lm_file:
-
- if (fork()) quit("Deattaching.....");
- close(0);close(1);close(2);
-
- if (logfile==NULL)
- {
- sprintf(tmp,"/tmp/ftptry-%s.XXXXXX",USERNAME);
- mktemp(tmp);
- }
- else
- strcpy(tmp,logfile);
-
- open(tmp,O_TRUNC|O_CREAT|O_WRONLY,0600);
- dup(0);
- dup(0);
- break;
-
- case lm_mail:
-
-
-
- if (fork()) quit("Deattaching.....");
-
- close(0);close(1);close(2);
- if (popen("/usr/lib/sendmail -t","w")==NULL)
- perror("sendmail"),
- quit("");
-
- dup(0);
- dup(0);
-
- printf("From: %s@%s\n",USERNAME,gethost());
- printf("To: %s@%s\n",USERNAME,gethost());
- printf("Subject: ftptry session log\n\n");
-
- fflush(stdout);
-
- break;
- }
-
-
- signal(SIGHUP,sighup);
- if (isatty(fileno(stdout))) FtpSetHashHandler(&FtpInit,FtpHash);
- loop(argc,argv,optind);
- exit(0);
-}
-
-
-
-INLINE noargs(int argc, char **argv, int optind)
-{
- int i;
-
- for (i=optind;i<argc;i++)
- if (argv[i]!=NULL) return 0;
- return 1;
-}
-
-
-
-/* Main loop */
-
-loop(int argc, char **argv, int optind /* First args as filename */ )
-{
- int i,rcode;
- String tmp;
- String machine;
- String filename;
- String localfilename;
- char *p1;
-
- for(i=optind;;(i==argc-1)?i=optind,
- sprintf(tmp,"Sleeping %d secs",sleeptime),log(tmp),sleep(sleeptime):
- i++)
- {
- if (noargs(argc,argv,optind))
- quit("Nothing doing");
-
- if (strchr(argv[i],':')==NULL)
- {
- if (find_archie(argv[i],machine,filename,localfilename)==0)
- argv[i]=NULL;
- }
- else
- {
- sscanf(argv[i],"%[^:]:%s",machine,filename);
- if ((p1=strrchr(filename,'/'))!=NULL)
- strcpy(localfilename,p1+1);
- else
- strcpy(localfilename,filename);
- }
- if (localfile == NULL ) localfile=localfilename;
- if ((rcode=transfer(machine, filename, localfile))==OK_)
- DEBUG("Transfer complete"),
- exit(0);
- if (rcode==CANCEL_ && strchr(argv[i],':')!=NULL)
- argv[i]=NULL;
- }
-}
-
-transfer(char *machine, char *file, char *localfile)
-{
- int r;
- String tmp;
-
- if ((r=setjmp(stack))!=0)
- return r;
-
- sprintf(tmp,"Start transfer, machine is %s, remote file is %s, local file is %s",
- machine, file, localfile);
- DEBUG(tmp);
-
- FtpLogin(&ftp,machine,user,password,NULL);
-
- if (type==binary)
- FtpBinary(ftp);
-
- switch (mode)
- {
-
- case get:
-
- FtpRetr(ftp,"RETR %s",file,localfile);
- break;
-
- case put:
-
- FtpStor(ftp,"STOR %s",localfile,file);
- break;
-
- case dir:
-
- FtpRetr(ftp,"LIST %s",file,localfile);
- break;
-
- case multiget:
- domultiget(file);
- break;
-
- }
-
- FtpBye(ftp);
-
- DEBUG("Transfer complete");
- return OK_;
-}
-
-
-void leave(int code)
-{
- FtpQuickBye(ftp);
- DEBUG("Leaving transfering");
- longjmp(stack,code);
-}
-
-void sighup()
-{
- leave(BREAK_);
-}
-
-
-quit(char *s)
-{
- log(s);
- longjmp(trap,1);
-}
-
-
-my_IO(FTP *ftp, int n, char *s )
-{
-
- DEBUG(s);
- leave(BREAK_);
-}
-
-my_abort(FTP *ftp, int n, char *s )
-{
-
- log(s);
- /* No access or not found, exclude network or host unreachable */;
- if (abs(n) == 550 && FtpBadReply550(s))
- leave(CANCEL_);
- leave(BREAK_);
-}
-
-
-domultiget(char *file)
-{
- String list,localname,tmp_name;
- char *p1;
-
- sprintf(list,"/tmp/ftptry-%s-multiget.XXXXXX",USERNAME);
- mktemp(list);
-
- FtpRetr(ftp,"NLST %s",file,list);
-
- if ((LIST=fopen(list,"r"))==NULL) quit((char *)sys_errlist[errno]);
-
- while ( fgets (tmp, sizeof tmp, LIST) != NULL )
- {
- tmp[strlen(tmp)-1]=0;
- if ((p1=strrchr(tmp,'/'))!=NULL)
- strcpy(localname,p1+1);
- else
- strcpy(localname,tmp);
-
- DEBUG(localname);
- FtpGet(ftp,tmp,localname);
- }
-
- fclose(LIST);
- LIST=NULL;
- return;
-}
-
-usage()
-{
- fprintf(stderr,"\
-Usage: %s [optins] [host:file]\n\
- (default host \"localhost\",\n\
- default file \"README\" or \".\" in directory mode)\n\
-\n\
-Valid options:\n\
-\n\
- -u user default anonymous\n\
- -p password default %s\n\
- -P inquire password from your terminal\n\
- -l local_file use only if remote and local file differ\n\
- -c direct output to stdout(like cat)\n\
- -r reverse mode, i.e. send file to remote host\n\
- -d directory mode, remote file is patern or \"ls\" options\n\
- default output is stdout.\n\
- -G multiget mode, file is patern for \"ls\" command\n\
- again at next try.\n\
- -b binary transfer mode\n\
- -s seconds Retry interval, default 10 minutes\n\
- -t seconds Timeout, default 10 minutes\n\
- -D Turn on debugging mode\n\
- -B Run in background and direct output to\n\
- /tmp/ftptry-%s.XXXXXX\n\
- -o file Run in background and direct output\n\
- to file\n\
- -m Send output to orel via e-mail\n\
- -I Print short introduction\n\
-\n\
-Example:\n\
- %s -Dbs 300 garbo.uwasa.fi:ls-lR.Z\n\
- Retrive file ls-lR.Z from garbo.uwasa.fi in binary mode\n\
- trying to reestablish connection every 5 minutes\n\
- on failure. Print debugging information.\n\
-\n\
- You can set default options to %s enviroment variable\n\
-",progname,password,USERNAME,progname,FTPTRY);
- exit(-1);
-}
-
-
-char *gethost()
-{
- static String tmp;
- String tmp2;
-
- gethostname(tmp2,sizeof tmp2);
-
- strcpy(tmp,FtpGetHost(tmp2)->h_name);
- return tmp;
-}
-
-
-void done(sig)
-{
- String x;
-
- signal(sig,done);
- sprintf(x,"interputed by signal %d",sig);
- log(x);
- longjmp(trap,1);
-}
-
-
-options(int argc,char **argv)
-{
- char c;
-
- while((c=getopt(argc,argv,"GOIBDru:p:Pdbs:o:l:t:cm"))!=EOF)
- {
- switch(c)
- {
-
- case 'G':
- mode=multiget;
- break;
-
- case 'c':
-
- if (localfile==NULL) localfile="*STDOUT*";
- break;
-
- case 'I':
- fprintf(stderr,intro);
- exit(0);
-
- case 'r':
-
- mode=put;
- break;
-
- case 'd':
-
- mode=dir;
- if (localfile==NULL) localfile="*STDOUT*";
- break;
-
- case 't':
-
- FtpSetTimeout(&FtpInit,atoi(optarg));
- break;
-
- case 'l':
-
- localfile=optarg;
- break;
-
- case 'D':
-
- debug=true;
- break;
-
- case 'u':
-
- user=optarg;
- break;
-
- case 'p':
-
- password=optarg;
- break;
-
- case 'P':
-
- password=(char *)getpass("Password:");
- break;
-
- case 'b':
-
- type=binary;
- break;
-
- case 's':
-
- sleeptime=atoi(optarg);
- break;
-
- case 'o':
-
- logmode=lm_file;
- logfile=optarg;
- break;
-
- case 'm':
-
- logmode=lm_mail;
- break;
-
- case 'B':
-
- logmode=lm_file;
- logfile=NULL;
- break;
-
- default:
-
- usage();
-
- }
- }
-}
-
-
-setoptions()
-{
- String x;
- char *p,*sp;
- int argc;
- char *argv[100];
-
-
-
-
- if ((p=(char *)getenv(FTPTRY))!=NULL && *p!=0)
- strcpy(x,p);
- else
- return;
-
-
-
- for (argv[0]="",p=x,sp=x,argc=1; *p!=0 ; p++)
- {
- if (*p==' ')
- {
- *p=0;
- argv[argc++] = sp;
- sp = p+1;
- }
- }
-
- argv[argc++]=sp;
-
- options(argc,argv);
-}
-
-
-INLINE unsigned long maxsize(String *result, int hops)
-{
- unsigned long maxsiz=0,cursiz=0;
- int i;
-
- for (i=0;i<hops;i++)
- {
- sscanf(result[i],"%*[^ ] %u %*s",&cursiz);
- if (cursiz>maxsiz)maxsiz=cursiz;
- }
- return maxsiz;
-}
-
-
-find_archie(char *what,char *machine, char *filename, char *localfilename)
-{
-
-#define MAXHOPS 15
-
- static String result[MAXHOPS];
- static int last=0;
- static int size=0;
- static int first=0;
- int rnd;
- static int init=0;
- static String oldwhat={'\0'};
- char *p1;
- int i;
-
- if (!init || strcmp(oldwhat,what)!=0 || last==0)
- {
- String cmd;
- FILE *archie;
-
- for (i=0;i<MAXHOPS;i++) result[i][0]=0;
- sprintf(cmd,"archie -l -m %d %s",MAXHOPS,what);
- DEBUG(cmd);
-
- if ((archie = popen(cmd,"r"))==NULL)
- quit("Archie can't execute");
-
- for(i=0;i<MAXHOPS;i++)
- {
- if (fgets(result[i],sizeof (result[i]), archie)==NULL)
- break;
- result[i][strlen(result[i])-1]=0;
- DEBUG(result[i]);
- }
-
-
- last=i;
-
- if ( last==0 )
- {
- DEBUG("archie not found need file");
- return(0);
- }
-
-
- init=1;
- first=0;
- strcpy(oldwhat,what);
- size=maxsize(result,MAXHOPS);
- }
-
- if (first >= last-1) first=0;
- for ( i=first; i<last; i++)
- if ( atoi ( strchr(result[i],' ') + 1 ) == size)
- {
- first=i+1;
- break;
- }
-
- DEBUG("Archie select is ... (see next line)");
- DEBUG(result[i]);
-
- if (sscanf ( result[i] , "%*[^ ] %*[^ ] %[^ ] %s", machine, filename )!=2)
- {
- DEBUG("Bad archie output format");
- last=0;
- return(0);
- }
-
-
- if ( (p1=strrchr(filename,'/'))!= NULL)
- strcpy(localfilename,p1+1);
- else
- strcpy(localfilename,filename);
-
- return(1);
-}
-
-
-
-
-
-
diff --git a/lib/libftp/utils/glob.c b/lib/libftp/utils/glob.c
deleted file mode 100644
index efaeaa6..0000000
--- a/lib/libftp/utils/glob.c
+++ /dev/null
@@ -1,850 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * glob(3) -- a superset of the one defined in POSIX 1003.2.
- *
- * The [!...] convention to negate a range is supported (SysV, Posix, ksh).
- *
- * Optional extra services, controlled by flags not defined by POSIX:
- *
- * GLOB_QUOTE:
- * Escaping convention: \ inhibits any special meaning the following
- * character might have (except \ at end of string is retained).
- * GLOB_MAGCHAR:
- * Set in gl_flags if pattern contained a globbing character.
- * GLOB_NOMAGIC:
- * Same as GLOB_NOCHECK, but it will only append pattern if it did
- * not contain any magic characters. [Used in csh style globbing]
- * GLOB_ALTDIRFUNC:
- * Use alternately specified directory access functions.
- * GLOB_TILDE:
- * expand ~user/foo to the /home/dir/of/user/foo
- * GLOB_BRACE:
- * expand {1,2}{a,b} to 1a 1b 2a 2b
- * gl_matchc:
- * Number of matches in the current invocation of glob.
- */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-
-#include <ctype.h>
-#include <dirent.h>
-#include <errno.h>
-#include <glob.h>
-#include <pwd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define DOLLAR '$'
-#define DOT '.'
-#define EOS '\0'
-#define LBRACKET '['
-#define NOT '!'
-#define QUESTION '?'
-#define QUOTE '\\'
-#define RANGE '-'
-#define RBRACKET ']'
-#define SEP '/'
-#define STAR '*'
-#define TILDE '~'
-#define UNDERSCORE '_'
-#define LBRACE '{'
-#define RBRACE '}'
-#define SLASH '/'
-#define COMMA ','
-
-#ifndef DEBUG
-
-#define M_QUOTE 0x8000
-#define M_PROTECT 0x4000
-#define M_MASK 0xffff
-#define M_ASCII 0x00ff
-
-typedef u_short Char;
-
-#else
-
-#define M_QUOTE 0x80
-#define M_PROTECT 0x40
-#define M_MASK 0xff
-#define M_ASCII 0x7f
-
-typedef char Char;
-
-#endif
-
-
-#define CHAR(c) ((Char)((c)&M_ASCII))
-#define META(c) ((Char)((c)|M_QUOTE))
-#define M_ALL META('*')
-#define M_END META(']')
-#define M_NOT META('!')
-#define M_ONE META('?')
-#define M_RNG META('-')
-#define M_SET META('[')
-#define ismeta(c) (((c)&M_QUOTE) != 0)
-
-
-static int compare __P((const void *, const void *));
-static void g_Ctoc __P((const Char *, char *));
-static int g_lstat __P((Char *, struct stat *, glob_t *));
-static DIR *g_opendir __P((Char *, glob_t *));
-static Char *g_strchr __P((Char *, int));
-#ifdef notdef
-static Char *g_strcat __P((Char *, const Char *));
-#endif
-static int g_stat __P((Char *, struct stat *, glob_t *));
-static int glob0 __P((const Char *, glob_t *));
-static int glob1 __P((Char *, glob_t *));
-static int glob2 __P((Char *, Char *, Char *, glob_t *));
-static int glob3 __P((Char *, Char *, Char *, Char *, glob_t *));
-static int globextend __P((const Char *, glob_t *));
-static const Char * globtilde __P((const Char *, Char *, glob_t *));
-static int globexp1 __P((const Char *, glob_t *));
-static int globexp2 __P((const Char *, const Char *, glob_t *, int *));
-static int match __P((Char *, Char *, Char *));
-#ifdef DEBUG
-static void qprintf __P((const char *, Char *));
-#endif
-
-int
-glob(pattern, flags, errfunc, pglob)
- const char *pattern;
- int flags, (*errfunc) __P((const char *, int));
- glob_t *pglob;
-{
- const u_char *patnext;
- int c;
- Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
-
- patnext = (u_char *) pattern;
- if (!(flags & GLOB_APPEND)) {
- pglob->gl_pathc = 0;
- pglob->gl_pathv = NULL;
- if (!(flags & GLOB_DOOFFS))
- pglob->gl_offs = 0;
- }
- pglob->gl_flags = flags & ~GLOB_MAGCHAR;
- pglob->gl_errfunc = errfunc;
- pglob->gl_matchc = 0;
-
- bufnext = patbuf;
- bufend = bufnext + MAXPATHLEN;
- if (flags & GLOB_QUOTE) {
- /* Protect the quoted characters. */
- while (bufnext < bufend && (c = *patnext++) != EOS)
- if (c == QUOTE) {
- if ((c = *patnext++) == EOS) {
- c = QUOTE;
- --patnext;
- }
- *bufnext++ = c | M_PROTECT;
- }
- else
- *bufnext++ = c;
- }
- else
- while (bufnext < bufend && (c = *patnext++) != EOS)
- *bufnext++ = c;
- *bufnext = EOS;
-
- if (flags & GLOB_BRACE)
- return globexp1(patbuf, pglob);
- else
- return glob0(patbuf, pglob);
-}
-
-/*
- * Expand recursively a glob {} pattern. When there is no more expansion
- * invoke the standard globbing routine to glob the rest of the magic
- * characters
- */
-static int globexp1(pattern, pglob)
- const Char *pattern;
- glob_t *pglob;
-{
- const Char* ptr = pattern;
- int rv;
-
- /* Protect a single {}, for find(1), like csh */
- if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS)
- return glob0(pattern, pglob);
-
- while ((ptr = (const Char *) g_strchr((Char *) ptr, LBRACE)) != NULL)
- if (!globexp2(ptr, pattern, pglob, &rv))
- return rv;
-
- return glob0(pattern, pglob);
-}
-
-
-/*
- * Recursive brace globbing helper. Tries to expand a single brace.
- * If it succeeds then it invokes globexp1 with the new pattern.
- * If it fails then it tries to glob the rest of the pattern and returns.
- */
-static int globexp2(ptr, pattern, pglob, rv)
- const Char *ptr, *pattern;
- glob_t *pglob;
- int *rv;
-{
- int i;
- Char *lm, *ls;
- const Char *pe, *pm, *pl;
- Char patbuf[MAXPATHLEN + 1];
-
- /* copy part up to the brace */
- for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++)
- continue;
- ls = lm;
-
- /* Find the balanced brace */
- for (i = 0, pe = ++ptr; *pe; pe++)
- if (*pe == LBRACKET) {
- /* Ignore everything between [] */
- for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++)
- continue;
- if (*pe == EOS) {
- /*
- * We could not find a matching RBRACKET.
- * Ignore and just look for RBRACE
- */
- pe = pm;
- }
- }
- else if (*pe == LBRACE)
- i++;
- else if (*pe == RBRACE) {
- if (i == 0)
- break;
- i--;
- }
-
- /* Non matching braces; just glob the pattern */
- if (i != 0 || *pe == EOS) {
- *rv = glob0(patbuf, pglob);
- return 0;
- }
-
- for (i = 0, pl = pm = ptr; pm <= pe; pm++)
- switch (*pm) {
- case LBRACKET:
- /* Ignore everything between [] */
- for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++)
- continue;
- if (*pm == EOS) {
- /*
- * We could not find a matching RBRACKET.
- * Ignore and just look for RBRACE
- */
- pm = pl;
- }
- break;
-
- case LBRACE:
- i++;
- break;
-
- case RBRACE:
- if (i) {
- i--;
- break;
- }
- /* FALLTHROUGH */
- case COMMA:
- if (i && *pm == COMMA)
- break;
- else {
- /* Append the current string */
- for (lm = ls; (pl < pm); *lm++ = *pl++)
- continue;
- /*
- * Append the rest of the pattern after the
- * closing brace
- */
- for (pl = pe + 1; (*lm++ = *pl++) != EOS;)
- continue;
-
- /* Expand the current pattern */
-#ifdef DEBUG
- qprintf("globexp2:", patbuf);
-#endif
- *rv = globexp1(patbuf, pglob);
-
- /* move after the comma, to the next string */
- pl = pm + 1;
- }
- break;
-
- default:
- break;
- }
- *rv = 0;
- return 0;
-}
-
-
-
-/*
- * expand tilde from the passwd file.
- */
-static const Char *
-globtilde(pattern, patbuf, pglob)
- const Char *pattern;
- Char *patbuf;
- glob_t *pglob;
-{
- struct passwd *pwd;
- char *h;
- const Char *p;
- Char *b;
-
- if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
- return pattern;
-
- /* Copy up to the end of the string or / */
- for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH;
- *h++ = *p++)
- continue;
-
- *h = EOS;
-
- if (((char *) patbuf)[0] == EOS) {
- /*
- * handle a plain ~ or ~/ by expanding $HOME
- * first and then trying the password file
- */
- if ((h = getenv("HOME")) == NULL) {
- if ((pwd = getpwuid(getuid())) == NULL)
- return pattern;
- else
- h = pwd->pw_dir;
- }
- }
- else {
- /*
- * Expand a ~user
- */
- if ((pwd = getpwnam((char*) patbuf)) == NULL)
- return pattern;
- else
- h = pwd->pw_dir;
- }
-
- /* Copy the home directory */
- for (b = patbuf; *h; *b++ = *h++)
- continue;
-
- /* Append the rest of the pattern */
- while ((*b++ = *p++) != EOS)
- continue;
-
- return patbuf;
-}
-
-
-/*
- * The main glob() routine: compiles the pattern (optionally processing
- * quotes), calls glob1() to do the real pattern matching, and finally
- * sorts the list (unless unsorted operation is requested). Returns 0
- * if things went well, nonzero if errors occurred. It is not an error
- * to find no matches.
- */
-static int
-glob0(pattern, pglob)
- const Char *pattern;
- glob_t *pglob;
-{
- const Char *qpatnext;
- int c, err, oldpathc;
- Char *bufnext, patbuf[MAXPATHLEN+1];
-
- qpatnext = globtilde(pattern, patbuf, pglob);
- oldpathc = pglob->gl_pathc;
- bufnext = patbuf;
-
- /* We don't need to check for buffer overflow any more. */
- while ((c = *qpatnext++) != EOS) {
- switch (c) {
- case LBRACKET:
- c = *qpatnext;
- if (c == NOT)
- ++qpatnext;
- if (*qpatnext == EOS ||
- g_strchr((Char *) qpatnext+1, RBRACKET) == NULL) {
- *bufnext++ = LBRACKET;
- if (c == NOT)
- --qpatnext;
- break;
- }
- *bufnext++ = M_SET;
- if (c == NOT)
- *bufnext++ = M_NOT;
- c = *qpatnext++;
- do {
- *bufnext++ = CHAR(c);
- if (*qpatnext == RANGE &&
- (c = qpatnext[1]) != RBRACKET) {
- *bufnext++ = M_RNG;
- *bufnext++ = CHAR(c);
- qpatnext += 2;
- }
- } while ((c = *qpatnext++) != RBRACKET);
- pglob->gl_flags |= GLOB_MAGCHAR;
- *bufnext++ = M_END;
- break;
- case QUESTION:
- pglob->gl_flags |= GLOB_MAGCHAR;
- *bufnext++ = M_ONE;
- break;
- case STAR:
- pglob->gl_flags |= GLOB_MAGCHAR;
- /* collapse adjacent stars to one,
- * to avoid exponential behavior
- */
- if (bufnext == patbuf || bufnext[-1] != M_ALL)
- *bufnext++ = M_ALL;
- break;
- default:
- *bufnext++ = CHAR(c);
- break;
- }
- }
- *bufnext = EOS;
-#ifdef DEBUG
- qprintf("glob0:", patbuf);
-#endif
-
- if ((err = glob1(patbuf, pglob)) != 0)
- return(err);
-
- /*
- * If there was no match we are going to append the pattern
- * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
- * and the pattern did not contain any magic characters
- * GLOB_NOMAGIC is there just for compatibility with csh.
- */
- if (pglob->gl_pathc == oldpathc &&
- ((pglob->gl_flags & GLOB_NOCHECK) ||
- ((pglob->gl_flags & GLOB_NOMAGIC) &&
- !(pglob->gl_flags & GLOB_MAGCHAR))))
- return(globextend(pattern, pglob));
- else if (!(pglob->gl_flags & GLOB_NOSORT))
- qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
- pglob->gl_pathc - oldpathc, sizeof(char *), compare);
- return(0);
-}
-
-static int
-compare(p, q)
- const void *p, *q;
-{
- return(strcmp(*(char **)p, *(char **)q));
-}
-
-static int
-glob1(pattern, pglob)
- Char *pattern;
- glob_t *pglob;
-{
- Char pathbuf[MAXPATHLEN+1];
-
- /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
- if (*pattern == EOS)
- return(0);
- return(glob2(pathbuf, pathbuf, pattern, pglob));
-}
-
-/*
- * The functions glob2 and glob3 are mutually recursive; there is one level
- * of recursion for each segment in the pattern that contains one or more
- * meta characters.
- */
-static int
-glob2(pathbuf, pathend, pattern, pglob)
- Char *pathbuf, *pathend, *pattern;
- glob_t *pglob;
-{
- struct stat sb;
- Char *p, *q;
- int anymeta;
-
- /*
- * Loop over pattern segments until end of pattern or until
- * segment with meta character found.
- */
- for (anymeta = 0;;) {
- if (*pattern == EOS) { /* End of pattern? */
- *pathend = EOS;
- if (g_lstat(pathbuf, &sb, pglob))
- return(0);
-
- if (((pglob->gl_flags & GLOB_MARK) &&
- pathend[-1] != SEP) && (S_ISDIR(sb.st_mode)
-#ifdef S_ISLNK
- || (S_ISLNK(sb.st_mode) &&
-#else
- || ( (sb.st_mode&S_IFLNK) &&
-#endif
- (g_stat(pathbuf, &sb, pglob) == 0) &&
- S_ISDIR(sb.st_mode)))) {
- *pathend++ = SEP;
- *pathend = EOS;
- }
- ++pglob->gl_matchc;
- return(globextend(pathbuf, pglob));
- }
-
- /* Find end of next segment, copy tentatively to pathend. */
- q = pathend;
- p = pattern;
- while (*p != EOS && *p != SEP) {
- if (ismeta(*p))
- anymeta = 1;
- *q++ = *p++;
- }
-
- if (!anymeta) { /* No expansion, do next segment. */
- pathend = q;
- pattern = p;
- while (*pattern == SEP)
- *pathend++ = *pattern++;
- } else /* Need expansion, recurse. */
- return(glob3(pathbuf, pathend, pattern, p, pglob));
- }
- /* NOTREACHED */
-}
-
-static int
-glob3(pathbuf, pathend, pattern, restpattern, pglob)
- Char *pathbuf, *pathend, *pattern, *restpattern;
- glob_t *pglob;
-{
- register struct dirent *dp;
- DIR *dirp;
- int err;
- char buf[MAXPATHLEN];
-
- /*
- * The readdirfunc declaration can't be prototyped, because it is
- * assigned, below, to two functions which are prototyped in glob.h
- * and dirent.h as taking pointers to differently typed opaque
- * structures.
- */
- struct dirent *(*readdirfunc)();
-
- *pathend = EOS;
- errno = 0;
-
- if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
- /* TODO: don't call for ENOENT or ENOTDIR? */
- if (pglob->gl_errfunc) {
- g_Ctoc(pathbuf, buf);
- if (pglob->gl_errfunc(buf, errno) ||
- pglob->gl_flags & GLOB_ERR)
- return (GLOB_ABEND);
- }
- return(0);
- }
-
- err = 0;
-
- /* Search directory for matching names. */
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- readdirfunc = pglob->gl_readdir;
- else
- readdirfunc = readdir;
- while ((dp = (*readdirfunc)(dirp))) {
- register u_char *sc;
- register Char *dc;
-
- /* Initial DOT must be matched literally. */
- if (dp->d_name[0] == DOT && *pattern != DOT)
- continue;
- for (sc = (u_char *) dp->d_name, dc = pathend;
- (*dc++ = *sc++) != EOS;)
- continue;
- if (!match(pathend, pattern, restpattern)) {
- *pathend = EOS;
- continue;
- }
- err = glob2(pathbuf, --dc, restpattern, pglob);
- if (err)
- break;
- }
-
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- (*pglob->gl_closedir)(dirp);
- else
- closedir(dirp);
- return(err);
-}
-
-
-/*
- * Extend the gl_pathv member of a glob_t structure to accomodate a new item,
- * add the new item, and update gl_pathc.
- *
- * This assumes the BSD realloc, which only copies the block when its size
- * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic
- * behavior.
- *
- * Return 0 if new item added, error code if memory couldn't be allocated.
- *
- * Invariant of the glob_t structure:
- * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and
- * gl_pathv points to (gl_offs + gl_pathc + 1) items.
- */
-static int
-globextend(path, pglob)
- const Char *path;
- glob_t *pglob;
-{
- register char **pathv;
- register int i;
- u_int newsize;
- char *copy;
- const Char *p;
-
- newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
- pathv = pglob->gl_pathv ?
- realloc((char *)pglob->gl_pathv, newsize) :
- malloc(newsize);
- if (pathv == NULL)
- return(GLOB_NOSPACE);
-
- if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
- /* first time around -- clear initial gl_offs items */
- pathv += pglob->gl_offs;
- for (i = pglob->gl_offs; --i >= 0; )
- *--pathv = NULL;
- }
- pglob->gl_pathv = pathv;
-
- for (p = path; *p++;)
- continue;
- if ((copy = malloc(p - path)) != NULL) {
- g_Ctoc(path, copy);
- pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
- }
- pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
- return(copy == NULL ? GLOB_NOSPACE : 0);
-}
-
-
-/*
- * pattern matching function for filenames. Each occurrence of the *
- * pattern causes a recursion level.
- */
-static int
-match(name, pat, patend)
- register Char *name, *pat, *patend;
-{
- int ok, negate_range;
- Char c, k;
-
- while (pat < patend) {
- c = *pat++;
- switch (c & M_MASK) {
- case M_ALL:
- if (pat == patend)
- return(1);
- do
- if (match(name, pat, patend))
- return(1);
- while (*name++ != EOS);
- return(0);
- case M_ONE:
- if (*name++ == EOS)
- return(0);
- break;
- case M_SET:
- ok = 0;
- if ((k = *name++) == EOS)
- return(0);
- if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
- ++pat;
- while (((c = *pat++) & M_MASK) != M_END)
- if ((*pat & M_MASK) == M_RNG) {
- if (c <= k && k <= pat[1])
- ok = 1;
- pat += 2;
- } else if (c == k)
- ok = 1;
- if (ok == negate_range)
- return(0);
- break;
- default:
- if (*name++ != c)
- return(0);
- break;
- }
- }
- return(*name == EOS);
-}
-
-/* Free allocated data belonging to a glob_t structure. */
-void
-globfree(pglob)
- glob_t *pglob;
-{
- register int i;
- register char **pp;
-
- if (pglob->gl_pathv != NULL) {
- pp = pglob->gl_pathv + pglob->gl_offs;
- for (i = pglob->gl_pathc; i--; ++pp)
- if (*pp)
- free(*pp);
- free(pglob->gl_pathv);
- }
-}
-
-static DIR *
-g_opendir(str, pglob)
- register Char *str;
- glob_t *pglob;
-{
- char buf[MAXPATHLEN];
-
- if (!*str)
- strcpy(buf, ".");
- else
- g_Ctoc(str, buf);
-
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_opendir)(buf));
-
- return(opendir(buf));
-}
-
-static int
-g_lstat(fn, sb, pglob)
- register Char *fn;
- struct stat *sb;
- glob_t *pglob;
-{
- char buf[MAXPATHLEN];
-
- g_Ctoc(fn, buf);
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_lstat)(buf, sb));
- return(lstat(buf, sb));
-}
-
-static int
-g_stat(fn, sb, pglob)
- register Char *fn;
- struct stat *sb;
- glob_t *pglob;
-{
- char buf[MAXPATHLEN];
-
- g_Ctoc(fn, buf);
- if (pglob->gl_flags & GLOB_ALTDIRFUNC)
- return((*pglob->gl_stat)(buf, sb));
- return(stat(buf, sb));
-}
-
-static Char *
-g_strchr(str, ch)
- Char *str;
- int ch;
-{
- do {
- if (*str == ch)
- return (str);
- } while (*str++);
- return (NULL);
-}
-
-#ifdef notdef
-static Char *
-g_strcat(dst, src)
- Char *dst;
- const Char* src;
-{
- Char *sdst = dst;
-
- while (*dst++)
- continue;
- --dst;
- while((*dst++ = *src++) != EOS)
- continue;
-
- return (sdst);
-}
-#endif
-
-static void
-g_Ctoc(str, buf)
- register const Char *str;
- char *buf;
-{
- register char *dc;
-
- for (dc = buf; (*dc++ = *str++) != EOS;)
- continue;
-}
-
-#ifdef DEBUG
-static void
-qprintf(str, s)
- const char *str;
- register Char *s;
-{
- register Char *p;
-
- (void)printf("%s:\n", str);
- for (p = s; *p; p++)
- (void)printf("%c", CHAR(*p));
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", *p & M_PROTECT ? '"' : ' ');
- (void)printf("\n");
- for (p = s; *p; p++)
- (void)printf("%c", ismeta(*p) ? '_' : ' ');
- (void)printf("\n");
-}
-#endif
diff --git a/lib/libftp/utils/glob.h b/lib/libftp/utils/glob.h
deleted file mode 100644
index b0432b7..0000000
--- a/lib/libftp/utils/glob.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Guido van Rossum.
- *
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- *
- * @(#)glob.h 8.1 (Berkeley) 6/2/93
- */
-
-#ifndef _GLOB_H_
-#define _GLOB_H_
-
-
-#include <cdefs.h>
-
-struct stat;
-typedef struct {
- int gl_pathc; /* Count of total paths so far. */
- int gl_matchc; /* Count of paths matching pattern. */
- int gl_offs; /* Reserved at beginning of gl_pathv. */
- int gl_flags; /* Copy of flags parameter to glob. */
- char **gl_pathv; /* List of paths matching pattern. */
- /* Copy of errfunc parameter to glob. */
- int (*gl_errfunc) __P((const char *, int));
-
- /*
- * Alternate filesystem access methods for glob; replacement
- * versions of closedir(3), readdir(3), opendir(3), stat(2)
- * and lstat(2).
- */
- void (*gl_closedir) __P((void *));
- struct dirent *(*gl_readdir) __P((void *));
- void *(*gl_opendir) __P((const char *));
- int (*gl_lstat) __P((const char *, struct stat *));
- int (*gl_stat) __P((const char *, struct stat *));
-} glob_t;
-
-#define GLOB_APPEND 0x0001 /* Append to output from previous call. */
-#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */
-#define GLOB_ERR 0x0004 /* Return on error. */
-#define GLOB_MARK 0x0008 /* Append / to matching directories. */
-#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */
-#define GLOB_NOSORT 0x0020 /* Don't sort. */
-
-#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */
-#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */
-#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */
-#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
-#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
-#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
-
-#define GLOB_NOSPACE (-1) /* Malloc call failed. */
-#define GLOB_ABEND (-2) /* Unignored error. */
-
-__BEGIN_DECLS
-int glob __P((const char *, int, int (*)(const char *, int), glob_t *));
-void globfree __P((glob_t *));
-__END_DECLS
-
-#endif /* !_GLOB_H_ */
diff --git a/lib/libftp/utils/mirror.c b/lib/libftp/utils/mirror.c
deleted file mode 100644
index a0d329c..0000000
--- a/lib/libftp/utils/mirror.c
+++ /dev/null
@@ -1,92 +0,0 @@
-
-/* Mirror directrory structure to another host */
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/dir.h>
-#include <sys/stat.h>
-#include <syslog.h>
-#include <FtpLibrary.h>
-
-/* Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir> */
-FTP *ftp;
-
-main(int a,char **b)
-{
-
-#define LOCAL_DIR b[1]
-#define HOST b[2]
-#define USER b[3]
-#define PASSWD b[4]
-#define REMOTE_DIR b[5]
-
- if ( a < 5 )
- quit("Usage: mirror <local_dir> <host> <user> <passwd> <remote_dir>");
-
-
- FtplibDebug(yes);
- FtpLogin(&ftp,HOST,USER,PASSWD,NULL);
- FtpChdir(ftp,REMOTE_DIR);
- FtpBinary(ftp);
- doit(LOCAL_DIR);
- exit(0);
-}
-
-doit(char *dirname)
-{
- DIR *dp;
- struct direct *de;
- char n[256],fn[256];
- struct stat st;
-
-
- if ( (dp=opendir(dirname)) == NULL )
- {
- log(dirname);
- return;
- }
-
- while ( (de = readdir(dp)) != NULL )
- {
- if ( de -> d_name[0] == '.' )
- continue;
-
- sprintf(fn,"%s/%s",dirname,de->d_name);
-
- if ( stat(fn,&st) != 0 ) {
- log(fn);
- continue;
- }
-
- if ( S_ISDIR (st.st_mode) )
- {
- FtpCommand(ftp,"MKD %s",fn,0,EOF); /* Ignore errors (0,EOF) */
- doit(fn);
- continue;
- }
-
- if ( st.st_size != FtpSize(ftp,fn))
-
- FtpPut(ftp,fn,fn);
- }
-
- closedir(dp);
-
-}
-
-
-
-quit(char *s)
-{
- log(s);
- exit(1);
-}
-
-log(char *s)
-{
- perror(s);
-}
-
-
-
diff --git a/lib/libftp/utils/readline.c b/lib/libftp/utils/readline.c
deleted file mode 100644
index e019bc1..0000000
--- a/lib/libftp/utils/readline.c
+++ /dev/null
@@ -1,961 +0,0 @@
-#ifndef lint
-static char *RCSid = "$Id: readline.c,v 1.1.1.1 1995/04/25 15:05:09 jkh Exp $";
-#endif
-
-
-/* GNUPLOT - readline.c */
-/*
- * Copyright (C) 1986 - 1993 Thomas Williams, Colin Kelley
- *
- * Permission to use, copy, and distribute this software and its
- * documentation for any purpose with or without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.
- *
- * Permission to modify the software is granted, but not the right to
- * distribute the modified code. Modifications are to be distributed
- * as patches to released version.
- *
- * This software is provided "as is" without express or implied warranty.
- *
- *
- * AUTHORS
- *
- * Original Software:
- * Tom Tkacik
- *
- * Msdos port and some enhancements:
- * Gershon Elber and many others.
- *
- * There is a mailing list for gnuplot users. Note, however, that the
- * newsgroup
- * comp.graphics.gnuplot
- * is identical to the mailing list (they
- * both carry the same set of messages). We prefer that you read the
- * messages through that newsgroup, to subscribing to the mailing list.
- * (If you can read that newsgroup, and are already on the mailing list,
- * please send a message info-gnuplot-request@dartmouth.edu, asking to be
- * removed from the mailing list.)
- *
- * The address for mailing to list members is
- * info-gnuplot@dartmouth.edu
- * and for mailing administrative requests is
- * info-gnuplot-request@dartmouth.edu
- * The mailing list for bug reports is
- * bug-gnuplot@dartmouth.edu
- * The list of those interested in beta-test versions is
- * info-gnuplot-beta@dartmouth.edu
- */
-
-#ifdef READLINE
-#ifdef ATARI
-#include "plot.h"
-#endif
-#ifdef _WINDOWS
-#define _Windows
-#endif
-
-/* a small portable version of GNU's readline */
-/* this is not the BASH or GNU EMACS version of READLINE due to Copyleft
- restrictions */
-/* do not need any terminal capabilities except backspace, */
-/* and space overwrites a character */
-
-/* NANO-EMACS line editing facility */
-/* printable characters print as themselves (insert not overwrite) */
-/* ^A moves to the beginning of the line */
-/* ^B moves back a single character */
-/* ^E moves to the end of the line */
-/* ^F moves forward a single character */
-/* ^K kills from current position to the end of line */
-/* ^P moves back through history */
-/* ^N moves forward through history */
-/* ^H and DEL delete the previous character */
-/* ^D deletes the current character, or EOF if line is empty */
-/* ^L/^R redraw line in case it gets trashed */
-/* ^U kills the entire line */
-/* ^W kills last word */
-/* LF and CR return the entire line regardless of the cursor postition */
-/* EOF with an empty line returns (char *)NULL */
-
-/* all other characters are ignored */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <signal.h>
-
-#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386)
-
-/*
- * Set up structures using the proper include file
- */
-#if defined(_IBMR2) || defined(alliant)
-#define SGTTY
-#endif
-
-/* submitted by Francois.Dagorn@cicb.fr */
-#ifdef SGTTY
-#include <sgtty.h>
-static struct sgttyb orig_termio, rl_termio;
-/* define terminal control characters */
-static struct tchars s_tchars;
-#define VERASE 0
-#define VEOF 1
-#define VKILL 2
-#ifdef TIOCGLTC /* available only with the 'new' line discipline */
-static struct ltchars s_ltchars;
-#define VWERASE 3
-#define VREPRINT 4
-#define VSUSP 5
-#endif /* TIOCGLTC */
-#define NCCS 6
-
-#else /* SGTTY */
-
-/* SIGTSTP defines job control */
-/* if there is job control then we need termios.h instead of termio.h */
-/* (Are there any systems with job control that use termio.h? I hope not.) */
-#ifdef SIGTSTP
-#define TERMIOS
-#include <termios.h>
-/* Added by Robert Eckardt, RobertE@beta.TP2.Ruhr-Uni-Bochum.de */
-#ifdef ISC22
-#ifndef ONOCR /* taken from sys/termio.h */
-#define ONOCR 0000020 /* true at least for ISC 2.2 */
-#endif
-#ifndef IUCLC
-#define IUCLC 0001000
-#endif
-#endif /* ISC22 */
-
-static struct termios orig_termio, rl_termio;
-#else
-#include <termio.h>
-static struct termio orig_termio, rl_termio;
-/* termio defines NCC instead of NCCS */
-#define NCCS NCC
-#endif /* SIGTSTP */
-#endif /* SGTTY */
-
-/* ULTRIX defines VRPRNT instead of VREPRINT */
-#ifdef VRPRNT
-#define VREPRINT VRPRNT
-#endif
-
-/* define characters to use with our input character handler */
-static char term_chars[NCCS];
-
-static int term_set = 0; /* =1 if rl_termio set */
-
-#define special_getc() ansi_getc()
-static char ansi_getc();
-
-#else /* !MSDOS && !ATARI && !_Windows */
-
-#ifdef _Windows
-#include <windows.h>
-#include "win/wtext.h"
-#include "win/wgnuplib.h"
-extern TW textwin;
-#define TEXTUSER 0xf1
-#define TEXTGNUPLOT 0xf0
-#define special_getc() msdos_getch()
-static char msdos_getch();
-#endif
-
-#if defined(MSDOS) || defined(DOS386)
-/* MSDOS specific stuff */
-#ifdef DJGPP
-#include <pc.h>
-#endif
-#ifdef __EMX__
-#include <conio.h>
-#endif
-#define special_getc() msdos_getch()
-static char msdos_getch();
-#endif /* MSDOS */
-
-#ifdef ATARI
-#include <stdlib.h>
-#ifdef __PUREC__
-#include <tos.h>
-#else
-#include <osbind.h>
-#endif
-#define special_getc() tos_getch()
-static char tos_getch();
-#endif
-
-#endif /* !MSDOS && !ATARI && !_Windows */
-
-#if !defined(ATARI)
-/* is it <string.h> or <strings.h>? just declare what we need */
-extern int strlen();
-extern char *strcpy();
-#endif
-#define alloc malloc
-extern char *alloc(); /* we'll use the safe malloc from misc.c */
-
-#define MAXBUF 1024
-#define BACKSPACE 0x08 /* ^H */
-#define SPACE ' '
-
-struct hist {
- char *line;
- struct hist *prev;
- struct hist *next;
-};
-
-static struct hist *history = NULL; /* no history yet */
-static struct hist *cur_entry = NULL;
-
-static char cur_line[MAXBUF]; /* current contents of the line */
-static int cur_pos = 0; /* current position of the cursor */
-static int max_pos = 0; /* maximum character position */
-
-
-void add_history();
-static void fix_line();
-static void redraw_line();
-static void clear_line();
-static void clear_eoline();
-static void copy_line();
-static void set_termio();
-void reset_termio();
-
-/* user_putc and user_puts should be used in the place of
- * fputc(ch,stderr) and fputs(str,stderr) for all output
- * of user typed characters. This allows MS-Windows to
- * display user input in a different color. */
-int
-user_putc(ch)
-int ch;
-{
- int rv;
-#ifdef _Windows
- TextAttr(&textwin,TEXTUSER);
-#endif
- rv = fputc(ch, stderr);
-#ifdef _Windows
- TextAttr(&textwin,TEXTGNUPLOT);
-#endif
- return rv;
-}
-
-int
-user_puts(str)
-char *str;
-{
- int rv;
-#ifdef _Windows
- TextAttr(&textwin,TEXTUSER);
-#endif
- rv = fputs(str, stderr);
-#ifdef _Windows
- TextAttr(&textwin,TEXTGNUPLOT);
-#endif
- return rv;
-}
-
-/* This function provides a centralized non-destructive backspace capability */
-/* M. Castro */
-
-backspace()
-{
- user_putc(BACKSPACE);
-}
-
-char *
-readline(prompt)
-char *prompt;
-{
-
- unsigned char cur_char;
- char *new_line;
- /* unsigned char *new_line; */
-
- /* set the termio so we can do our own input processing */
- set_termio();
-
- /* print the prompt */
- fputs(prompt, stderr);
- cur_line[0] = '\0';
- cur_pos = 0;
- max_pos = 0;
- cur_entry = NULL;
-
- /* get characters */
- for(;;) {
- cur_char = special_getc();
-#ifdef OS2
- /* for emx: remap scan codes for cursor keys */
- if( cur_char == 0 ) {
- cur_char = getc(stdin);
- switch( cur_char){
- case 75: /* left, map to ^B */
- cur_char=2;
- break ;
- case 77: /* right, map to ^F */
- cur_char=6;
- break ;
- case 115: /* ctrl left */
- case 71: /* home, map to ^A */
- cur_char=1;
- break ;
- case 116: /* ctrl right */
- case 79: /* end, map to ^E */
- cur_char=5;
- break ;
- case 72: /* up, map to ^P */
- cur_char=16;
- break ;
- case 80: /* down, map to ^N */
- cur_char=14;
- break ;
- case 83: /* delete, map to ^D */
- cur_char=4;
- break ;
- default: /* ignore */
- cur_char=0;
- continue ;
- }
- }
-#endif /*OS2*/
- if((isprint(cur_char)
-#if defined(ATARI) || defined(_Windows) || defined(MSDOS) || defined(DOS386)
- /* this should be used for all 8bit ASCII machines, I guess */
- || ((unsigned char)cur_char > 0x7f)
-#endif
- )&& max_pos<MAXBUF-1) {
- int i;
- for(i=max_pos; i>cur_pos; i--) {
- cur_line[i] = cur_line[i-1];
- }
- user_putc(cur_char);
- cur_line[cur_pos] = cur_char;
- cur_pos += 1;
- max_pos += 1;
- if (cur_pos < max_pos)
- fix_line();
- cur_line[max_pos] = '\0';
-
- /* else interpret unix terminal driver characters */
-#ifdef VERASE
- } else if(cur_char == term_chars[VERASE] ){ /* DEL? */
- if(cur_pos > 0) {
- int i;
- cur_pos -= 1;
- backspace();
- for(i=cur_pos; i<max_pos; i++)
- cur_line[i] = cur_line[i+1];
- max_pos -= 1;
- fix_line();
- }
-#endif /* VERASE */
-#ifdef VEOF
- } else if(cur_char == term_chars[VEOF] ){ /* ^D? */
- if(max_pos == 0) {
- reset_termio();
- return((char *)NULL);
- }
- if((cur_pos < max_pos)&&(cur_char == 004)) { /* ^D */
- int i;
- for(i=cur_pos; i<max_pos; i++)
- cur_line[i] = cur_line[i+1];
- max_pos -= 1;
- fix_line();
- }
-#endif /* VEOF */
-#ifdef VKILL
- } else if(cur_char == term_chars[VKILL] ){ /* ^U? */
- clear_line(prompt);
-#endif /* VKILL */
-#ifdef VWERASE
- } else if(cur_char == term_chars[VWERASE] ){ /* ^W? */
- while((cur_pos > 0) &&
- (cur_line[cur_pos-1] == SPACE)) {
- cur_pos -= 1;
- backspace();
- }
- while((cur_pos > 0) &&
- (cur_line[cur_pos-1] != SPACE)) {
- cur_pos -= 1;
- backspace();
- }
- clear_eoline();
- max_pos = cur_pos;
-#endif /* VWERASE */
-#ifdef VREPRINT
- } else if(cur_char == term_chars[VREPRINT] ){ /* ^R? */
- putc('\n',stderr); /* go to a fresh line */
- redraw_line(prompt);
-#endif /* VREPRINT */
-#ifdef VSUSP
- } else if(cur_char == term_chars[VSUSP]) {
- reset_termio();
- kill(0, SIGTSTP);
-
- /* process stops here */
-
- set_termio();
- /* print the prompt */
- redraw_line(prompt);
-#endif /* VSUSP */
- } else {
- /* do normal editing commands */
- /* some of these are also done above */
- int i;
- switch(cur_char) {
- case EOF:
- reset_termio();
- return((char *)NULL);
- case 001: /* ^A */
- while(cur_pos > 0) {
- cur_pos -= 1;
- backspace();
- }
- break;
- case 002: /* ^B */
- if(cur_pos > 0) {
- cur_pos -= 1;
- backspace();
- }
- break;
- case 005: /* ^E */
- while(cur_pos < max_pos) {
- user_putc(cur_line[cur_pos]);
- cur_pos += 1;
- }
- break;
- case 006: /* ^F */
- if(cur_pos < max_pos) {
- user_putc(cur_line[cur_pos]);
- cur_pos += 1;
- }
- break;
- case 013: /* ^K */
- clear_eoline();
- max_pos = cur_pos;
- break;
- case 020: /* ^P */
- if(history != NULL) {
- if(cur_entry == NULL) {
- cur_entry = history;
- clear_line(prompt);
- copy_line(cur_entry->line);
- } else if(cur_entry->prev != NULL) {
- cur_entry = cur_entry->prev;
- clear_line(prompt);
- copy_line(cur_entry->line);
- }
- }
- break;
- case 016: /* ^N */
- if(cur_entry != NULL) {
- cur_entry = cur_entry->next;
- clear_line(prompt);
- if(cur_entry != NULL)
- copy_line(cur_entry->line);
- else
- cur_pos = max_pos = 0;
- }
- break;
- case 014: /* ^L */
- case 022: /* ^R */
- putc('\n',stderr); /* go to a fresh line */
- redraw_line(prompt);
- break;
- case 0177: /* DEL */
- case 010: /* ^H */
- if(cur_pos > 0) {
- cur_pos -= 1;
- backspace();
- for(i=cur_pos; i<max_pos; i++)
- cur_line[i] = cur_line[i+1];
- max_pos -= 1;
- fix_line();
- }
- break;
- case 004: /* ^D */
- if(max_pos == 0) {
- reset_termio();
- return((char *)NULL);
- }
- if(cur_pos < max_pos) {
- for(i=cur_pos; i<max_pos; i++)
- cur_line[i] = cur_line[i+1];
- max_pos -= 1;
- fix_line();
- }
- break;
- case 025: /* ^U */
- clear_line(prompt);
- break;
- case 027: /* ^W */
- while((cur_pos > 0) &&
- (cur_line[cur_pos-1] == SPACE)) {
- cur_pos -= 1;
- backspace();
- }
- while((cur_pos > 0) &&
- (cur_line[cur_pos-1] != SPACE)) {
- cur_pos -= 1;
- backspace();
- }
- clear_eoline();
- max_pos = cur_pos;
- break;
- case '\n': /* ^J */
- case '\r': /* ^M */
- cur_line[max_pos+1] = '\0';
- putc('\n', stderr);
- new_line = (char *)alloc((unsigned long) (strlen(cur_line)+1), "history");
- strcpy(new_line,cur_line);
- reset_termio();
- return(new_line);
- default:
- break;
- }
- }
- }
-}
-
-/* fix up the line from cur_pos to max_pos */
-/* do not need any terminal capabilities except backspace, */
-/* and space overwrites a character */
-static void
-fix_line()
-{
- int i;
-
- /* write tail of string */
- for(i=cur_pos; i<max_pos; i++)
- user_putc(cur_line[i]);
-
- /* write a space at the end of the line in case we deleted one */
- user_putc(SPACE);
-
- /* backup to original position */
- for(i=max_pos+1; i>cur_pos; i--)
- backspace();
-
-}
-
-/* redraw the entire line, putting the cursor where it belongs */
-static void
-redraw_line(prompt)
-char *prompt;
-{
- int i;
-
- fputs(prompt, stderr);
- user_puts(cur_line);
-
- /* put the cursor where it belongs */
- for(i=max_pos; i>cur_pos; i--)
- backspace();
-}
-
-/* clear cur_line and the screen line */
-static void
-clear_line(prompt)
-char *prompt;
-{
- int i;
- for(i=0; i<max_pos; i++)
- cur_line[i] = '\0';
-
- for(i=cur_pos; i>0; i--)
- backspace();
-
- for(i=0; i<max_pos; i++)
- putc(SPACE, stderr);
-
- putc('\r', stderr);
- fputs(prompt, stderr);
-
- cur_pos = 0;
- max_pos = 0;
-}
-
-/* clear to end of line and the screen end of line */
-static void
-clear_eoline(prompt)
-char *prompt;
-{
- int i;
- for(i=cur_pos; i<max_pos; i++)
- cur_line[i] = '\0';
-
- for(i=cur_pos; i<max_pos; i++)
- putc(SPACE, stderr);
- for(i=cur_pos; i<max_pos; i++)
- backspace();
-}
-
-/* copy line to cur_line, draw it and set cur_pos and max_pos */
-static void
-copy_line(line)
-char *line;
-{
- strcpy(cur_line, line);
- user_puts(cur_line);
- cur_pos = max_pos = strlen(cur_line);
-}
-
-/* add line to the history */
-void
-add_history(line)
-char *line;
-{
- struct hist *entry;
- entry = (struct hist *)alloc((unsigned long)sizeof(struct hist),"history");
- entry->line = alloc((unsigned long)(strlen(line)+1),"history");
- strcpy(entry->line, line);
-
- entry->prev = history;
- entry->next = NULL;
- if(history != NULL) {
- history->next = entry;
- }
- history = entry;
-}
-
-
-/* Convert ANSI arrow keys to control characters */
-static char
-ansi_getc()
-{
- char c = getc(stdin);
- if (c == 033) {
- c = getc(stdin); /* check for CSI */
- if (c == '[') {
- c = getc(stdin); /* get command character */
- switch (c) {
- case 'D': /* left arrow key */
- c = 002;
- break;
- case 'C': /* right arrow key */
- c = 006;
- break;
- case 'A': /* up arrow key */
- c = 020;
- break;
- case 'B': /* down arrow key */
- c = 016;
- break;
- }
- }
- }
- return c;
-}
-
-#if defined(MSDOS) || defined(_Windows) || defined(DOS386)
-
-/* Convert Arrow keystrokes to Control characters: */
-static char
-msdos_getch()
-{
-#ifdef DJGPP
- char c;
- int ch = getkey();
- c = (ch & 0xff00) ? 0 : ch & 0xff;
-#else
- char c = getch();
-#endif
-
- if (c == 0) {
-#ifdef DJGPP
- c = ch & 0xff;
-#else
- c = getch(); /* Get the extended code. */
-#endif
- switch (c) {
- case 75: /* Left Arrow. */
- c = 002;
- break;
- case 77: /* Right Arrow. */
- c = 006;
- break;
- case 72: /* Up Arrow. */
- c = 020;
- break;
- case 80: /* Down Arrow. */
- c = 016;
- break;
- case 115: /* Ctl Left Arrow. */
- case 71: /* Home */
- c = 001;
- break;
- case 116: /* Ctl Right Arrow. */
- case 79: /* End */
- c = 005;
- break;
- case 83: /* Delete */
- c = 004;
- break;
- default:
- c = 0;
- break;
- }
- }
- else if (c == 033) { /* ESC */
- c = 025;
- }
-
-
- return c;
-}
-
-#endif /* MSDOS */
-
-#ifdef ATARI
-
-/* Convert Arrow keystrokes to Control characters: TOS version */
-
-/* the volatile could be necessary to keep gcc from reordering
- the two Super calls
-*/
-#define CONTERM ((/*volatile*/ char *)0x484L)
-
-static void
-remove_conterm()
-{
- void *ssp=(void*)Super(0L);
- *CONTERM &= ~0x8;
- Super(ssp);
-}
-
-static char
-tos_getch()
-{
- long rawkey;
- char c;
- int scan_code;
- void *ssp;
- static int init = 1;
- static int in_help = 0;
-
- if (in_help) {
- switch(in_help) {
- case 1:
- case 5: in_help++; return 'e';
- case 2:
- case 6: in_help++; return 'l';
- case 3:
- case 7: in_help++; return 'p';
- case 4: in_help = 0; return 0x0d;
- case 8: in_help = 0; return ' ';
- }
- }
-
- if (init) {
- ssp = (void*)Super(0L);
- if( !(*CONTERM & 0x8) ) {
- *CONTERM |= 0x8;
- } else {
- init=0;
- }
- (void)Super(ssp);
- if( init ) {
- atexit(remove_conterm);
- init = 0;
- }
- }
-
- (void)Cursconf(1, 0); /* cursor on */
- rawkey = Cnecin();
- c = (char)rawkey;
- scan_code= ((int)(rawkey>>16)) & 0xff; /* get the scancode */
- if( rawkey&0x07000000 ) scan_code |= 0x80; /* shift or control */
-
- switch (scan_code) {
- case 0x62: /* HELP */
- if (max_pos==0) {
- in_help = 1;
- return 'h';
- } else {
- return 0;
- }
- case 0xe2: /* shift HELP */
- if (max_pos==0) {
- in_help = 5;
- return 'h';
- } else {
- return 0;
- }
- case 0x48: /* Up Arrow */
- return 0x10; /* ^P */
- case 0x50: /* Down Arrow */
- return 0x0e; /* ^N */
- case 0x4b: /* Left Arrow */
- return 0x02; /* ^B */
- case 0x4d: /* Right Arrow */
- return 0x06; /* ^F */
- case 0xcb: /* Shift Left Arrow */
- case 0xf3: /* Ctrl Left Arrow (TOS-bug ?) */
- case 0x47: /* Home */
- return 0x01; /* ^A */
- case 0xcd: /* Shift Right Arrow */
- case 0xf4: /* Ctrl Right Arrow (TOS-bug ?) */
- case 0xc7: /* Shift Home */
- case 0xf7: /* Crtl Home */
- return 0x05; /* ^E */
- case 0x61: /* Undo - redraw line */
- return 0x0c; /* ^L */
- default:
- if (c == 0x1b) return 0x15; /* ESC becomes ^U */
- if (c == 0x7f) return 0x04; /* Del becomes ^D */
- break;
- }
-
- return c;
-}
-
-#endif /* ATARI */
-
- /* set termio so we can do our own input processing */
-static void
-set_termio()
-{
-#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386)
-/* set termio so we can do our own input processing */
-/* and save the old terminal modes so we can reset them later */
- if(term_set == 0) {
- /*
- * Get terminal modes.
- */
-#ifdef SGTTY
- ioctl(0, TIOCGETP, &orig_termio);
-#else /* SGTTY */
-#ifdef TERMIOS
-#ifdef TCGETS
- ioctl(0, TCGETS, &orig_termio);
-#else
- tcgetattr(0, &orig_termio);
-#endif /* TCGETS */
-#else
- ioctl(0, TCGETA, &orig_termio);
-#endif /* TERMIOS */
-#endif /* SGTTY */
-
- /*
- * Save terminal modes
- */
- rl_termio = orig_termio;
-
- /*
- * Set the modes to the way we want them
- * and save our input special characters
- */
-#ifdef SGTTY
- rl_termio.sg_flags |= CBREAK;
- rl_termio.sg_flags &= ~(ECHO|XTABS);
- ioctl(0, TIOCSETN, &rl_termio);
-
- ioctl(0, TIOCGETC, &s_tchars);
- term_chars[VERASE] = orig_termio.sg_erase;
- term_chars[VEOF] = s_tchars.t_eofc;
- term_chars[VKILL] = orig_termio.sg_kill;
-#ifdef TIOCGLTC
- ioctl(0, TIOCGLTC, &s_ltchars);
- term_chars[VWERASE] = s_ltchars.t_werasc;
- term_chars[VREPRINT] = s_ltchars.t_rprntc;
- term_chars[VSUSP] = s_ltchars.t_suspc;
-
- /* disable suspending process on ^Z */
- s_ltchars.t_suspc = 0;
- ioctl(0, TIOCSLTC, &s_ltchars);
-#endif /* TIOCGLTC */
-#else /* SGTTY */
-#ifdef IUCLC
- rl_termio.c_iflag &= ~(BRKINT|PARMRK|INPCK|IUCLC|IXON|IXOFF);
-#else
- rl_termio.c_iflag &= ~(BRKINT|PARMRK|INPCK|IXON|IXOFF);
-#endif
- rl_termio.c_iflag |= (IGNBRK|IGNPAR);
-
- /* rl_termio.c_oflag &= ~(ONOCR); Costas Sphocleous Irvine,CA */
-
- rl_termio.c_lflag &= ~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|NOFLSH);
-#ifdef OS2
- /* for emx: remove default terminal processing */
- rl_termio.c_lflag &= ~(IDEFAULT);
-#endif /* OS2 */
- rl_termio.c_lflag |= (ISIG);
- rl_termio.c_cc[VMIN] = 1;
- rl_termio.c_cc[VTIME] = 0;
-
-#ifndef VWERASE
-#define VWERASE 3
-#endif
- term_chars[VERASE] = orig_termio.c_cc[VERASE];
- term_chars[VEOF] = orig_termio.c_cc[VEOF];
- term_chars[VKILL] = orig_termio.c_cc[VKILL];
-#ifdef TERMIOS
- term_chars[VWERASE] = orig_termio.c_cc[VWERASE];
-#ifdef VREPRINT
- term_chars[VREPRINT] = orig_termio.c_cc[VREPRINT];
-#else
-#ifdef VRPRNT
- term_chars[VRPRNT] = orig_termio.c_cc[VRPRNT];
-#endif
-#endif
- term_chars[VSUSP] = orig_termio.c_cc[VSUSP];
-
- /* disable suspending process on ^Z */
- rl_termio.c_cc[VSUSP] = 0;
-#endif /* TERMIOS */
-#endif /* SGTTY */
-
- /*
- * Set the new terminal modes.
- */
-#ifdef SGTTY
- ioctl(0, TIOCSLTC, &s_ltchars);
-#else
-#ifdef TERMIOS
-#ifdef TCSETSW
- ioctl(0, TCSETSW, &rl_termio);
-#else
- tcsetattr(0, TCSADRAIN, &rl_termio);
-#endif /* TCSETSW */
-#else
- ioctl(0, TCSETAW, &rl_termio);
-#endif /* TERMIOS */
-#endif /* SGTTY */
- term_set = 1;
- }
-#endif /* !MSDOS && !ATARI && !defined(_Windows) */
-}
-
-void
-reset_termio()
-{
-#if !defined(MSDOS) && !defined(ATARI) && !defined(_Windows) && !defined(DOS386)
-/* reset saved terminal modes */
- if(term_set == 1) {
-#ifdef SGTTY
- ioctl(0, TIOCSETN, &orig_termio);
-#ifdef TIOCGLTC
- /* enable suspending process on ^Z */
- s_ltchars.t_suspc = term_chars[VSUSP];
- ioctl(0, TIOCSLTC, &s_ltchars);
-#endif /* TIOCGLTC */
-#else /* SGTTY */
-#ifdef TERMIOS
-#ifdef TCSETSW
- ioctl(0, TCSETSW, &orig_termio);
-#else
- tcsetattr(0, TCSADRAIN, &orig_termio);
-#endif /* TCSETSW */
-#else
- ioctl(0, TCSETAW, &orig_termio);
-#endif /* TERMIOS */
-#endif /* SGTTY */
- term_set = 0;
- }
-#endif /* !MSDOS && !ATARI && !_Windows */
-}
-#endif /* READLINE */
diff --git a/lib/libftp/utils/uftp.c b/lib/libftp/utils/uftp.c
deleted file mode 100644
index 4c8961f..0000000
--- a/lib/libftp/utils/uftp.c
+++ /dev/null
@@ -1,824 +0,0 @@
-/* File Transfer Protocol Toolkit based on libftp */
-
-#include "uftp.h"
-#include <varargs.h>
-
-
-FTP *ftp[NFRAMES];
-LINKINFO iftp[NFRAMES];
-int frame=0;
-
-
-int status;
-jmp_buf start;
-int lastcmd=0;
-int glassmode=0;
-int trymode=1;
-int restmode=1;
-int hashmode=0;
-int sleeptime=30;
-time_t noopinterval=0;
-time_t nooptimeout=1;
-time_t prevtime=0;
-
-String cmd;
-String prompt="%T %u@%H:%d> ";
-String defaultuser;
-
-ALIAS *firstalias=NULL;
-
-/* if main have any arguments, interprets each it as command with args */
-
-
-main(int argc, char **argv)
-
-{
- register int i;
- register char *p1;
- FILE *fp;
- String tmp;
-
- if (setjmp(start)!=0)
- goto main_loop;
-
- setsignals();
-
-
-
- FtpSetErrorHandler(&FtpInit,my_error);
- FtpSetIOHandler(&FtpInit,my_error);
-
- strcpy(defaultuser,getpwuid(getuid())->pw_name);
-
-
- memset(ftp,0,sizeof(FTP*)*NFRAMES);
- memset(iftp,0,sizeof(LINKINFO)*NFRAMES);
-
-
-
- batch(SYSTEMRC);
-
- if (access(getrcname(),F_OK))
- {
- FILE *out=fdopen(open(getrcname(),O_WRONLY|O_CREAT|O_TRUNC,0700),"w");
-
- printf("Create default rc-file \"%s\"\n",getrcname());
-
- if (out==NULL)
- perror(getrcname());
-
- else
- {
-
- fprintf(out,"set timeout 120\nset hash\nset debug\nset bin\n");
- fprintf(out,"set prompt \"%%T %%u@%%h:%%d\\> \"\n");
- fprintf(out,"alias a alias\na ed ! emacs\nalias tn ! telnet\n");
-
- fclose(out);
- }
- }
-
-
- batch(getrcname());
- batch(getaliasrcname());
-
-
- for (i=1, tmp[0]=0; i< argc; i++)
- {
- strcat(tmp,argv[i]);
- if (i+1!=argc) strcat(tmp," ");
- }
-
- if (tmp[0]!=0)
- {
- String new;
-
-/*
- if (!strcmp(defaultuser,"ftp") || !strcmp(defaultuser,"anonymous"))
- strcpy(new,"ftp ");
- else
-*/
- strcpy(new,"open ");
-
- if (ifalias(tmp))
- execute (tmp);
- else
- strcat(new,tmp),
- execute(new);
- }
-
-
-main_loop:
-
- setsignals();
-
- while (1)
- {
-
- setjmp(start);
- if (lastcmd) exit(0);
-
-
- if (isatty(fileno(stdin)))
- p1=readline(getprompt());
- else
- p1=gets(cmd);
-
- if (p1==NULL)
- {
- putchar('\n');
- exit(0);
- }
-
- strcpy(cmd,p1);
-
- if (cmd[0]) add_history(cmd);
- execute(cmd);
- }
-}
-
-INLINE char *findspace(char *str)
-{
- while ( !isspace(*str) && *str != '\0' ) str++;
- return str;
-}
-
-
-
-char *word(char *str, int n)
-{
- String new;
- register char *p1, *p2;
- register int i;
-
- strcpy(new,str);
-
- p1=new;
-
- while (isspace(*p1)) p1++;
-
- if (n>1 )
- for (i=0;i<n-1;i++) /* Skip n-1 words */
- {
- if ((*p1=='"')||(*p1=='\''))
- {
- p1=strchr(p1+1,*p1);
- if (p1==NULL) return "";
- p1++;
- while ( isspace(*p1) ) p1++;
- continue;
- }
- p1=findspace(p1);
- if ( *p1=='\0' ) return "";
- p1++;
- while ( isspace(*p1) ) p1++;
- }
-
- if ((*p1=='"')|(*p1=='\''))
- {
- p2=strchr(p1+1,*p1);
- if (p2==NULL) return p1+1;
- *p2=0;
- return p1+1;
- }
-
- if ((p2=findspace(p1)) != NULL )
- {
- *p2=0;
- return p1;
- }
- return "";
-}
-
-
-/* Exacute few command separated by ';' . The character ' must use for mark complex
- works*/
-
-execute (char *cmd)
-{
- String w1,w2,w3,w4,w5,w6;
- String newcmd;
- char *p;
-
- if (!*cmd || *cmd=='#' ) return;
-
- for ( p=newcmd ; *cmd; cmd++)
- {
- if ( *cmd == '\'' )
- {
- *p++=*cmd++;
- while ( *cmd != '\'' && *cmd != 0 ) *p++=*cmd++;
- if ( *cmd == 0 )
- return puts("Unbalanced \', please corrected!\n");
- *p++=*cmd;
- continue;
- }
-
- if ( *cmd == ';' )
- {
- *p=0;
- execute(newcmd);
- p=newcmd;
- continue;
- }
- *p++=*cmd;
- }
-
-
- *p=0;
- cmd=newcmd;
-
- if ( *cmd=='\\' )
- cmd++;
- else
- {
- String new;
- strcpy(new,"\\");
- strcat(new,expandalias(cmd));
- return execute(new);
- }
-
- if ( *cmd == '!' )
- {
- int pid,_pid;
- int status;
-
- if (!(pid=fork()))
- {
- execlp((getenv("SHELL")==NULL)?"/bin/sh":(char *)getenv("SHELL"),
- "shell","-c",cmd+1,NULL);
- }
-
- while(1)
- {
- _pid=wait(&status);
- if (_pid==pid)
- return;
- }
- }
-
-
- redir(cmd);
-
- if (cmd[strlen(cmd)-1]=='&')
- {
- String tmp;
-
- cmd[strlen(cmd)-1]=0;
-
- strcpy(tmp,"bg ");
- strcat(tmp,cmd);
-
- strcpy(cmd,tmp);
- }
-
- strcpy(w1,word(cmd,1));
- strcpy(w2,word(cmd,2));
- strcpy(w3,word(cmd,3));
- strcpy(w4,word(cmd,4));
- strcpy(w5,word(cmd,5));
- strcpy(w6,word(cmd,6));
-
- return executev(w1,w2,w3,w4,w5,w6);
-}
-
-executev(ARGS)
-{
- CMDS *xcmd=&cmds[0];
- String tmp;
-
- if (isdigit(*w1))
- return
- atoi(w1)<NFRAMES?frame=atoi(w1):0,
- executev(w2,w3,w4,w5,w6,"");
-
- while ( xcmd -> cmd != NULL )
- {
- if ( !strcmp(xcmd->cmd,w1) && (xcmd -> func != NULL) )
- {
- int status;
-
- if ( xcmd -> need && LINK == NULL)
- return puts("Need connection to server");
- iftp[frame].lock=1; unsetsignals();
- status = (*xcmd->func)(w1,w2,w3,w4,w5,w6);
- iftp[frame].lock=0; setsignals();
- redirback();
- return status;
- }
- xcmd++;
- }
-
-
- if (LINK!=NULL && glassmode)
- return FtpCommand(LINK,cmd,"",0,EOF);
-
- printf("%s: unknown command\n",w1);
- fflush(stdout);
- return -1;
-}
-
-
-void intr(int sig)
-{
- printf("Interupted by signal %d\n",sig);
- if (LINK!=NULL) FtpSetHashHandler(LINK,NULL);
- setsignals();
- reset_termio(); /* From readline */
- prevtime = time((time_t *)0);
- longjmp(start,1);
-}
-
-newframe(int connecteble)
-{
- register int i;
-
- if (connecteble)
- for (i=0; i<NFRAMES; i++) if (ftp[i]!=NULL) return frame=i;
- for (i=0; i<NFRAMES; i++) if (ftp[i]==NULL) return frame=i;
- return -1;
-}
-
-STATUS my_error(FTP *ftp, int code, char *msg)
-{
-
- if (code==LQUIT||(ftp==NULL)) log(msg);
- else
- FtpLog(ftp->title,msg);
-
- if ( abs(code) == 530 && (strstr(msg,"anonymous")!=NULL))
- {
- Ftp_reopen();
- longjmp(start,1);
- }
- longjmp(start,1);
-}
-
-char *getrcname()
-{
- static String rcpath;
- struct passwd *pwd=getpwuid(getuid());
-
- sprintf(rcpath,"%s/.uftprc",pwd->pw_dir);
- return rcpath;
-}
-
-char *getaliasrcname()
-{
- static String rcpath;
- struct passwd *pwd=getpwuid(getuid());
-
- sprintf(rcpath,"%s/.uftp_aliases",pwd->pw_dir);
- return rcpath;
-}
-
-char *makestr(va_alist)
- va_dcl
-{
- char *p1;
- va_list args;
- String new={0};
-
- va_start(args);
-
- while(1)
- {
- p1=va_arg(args,char *);
- if (p1==NULL) break;
- if (*p1!=0)
- {
- if (new[0]!=0) strcat(new," ");
- strcat(new,p1);
- }
- }
- va_end(args);
- return new;
-}
-
-
-#define ADD(str,chr) (*str++=chr,*str=0)
-
-INLINE ADDSTR(char **str, char *str1)
-{
- while (*str1) *(*str)++=*str1++;
-}
-
-char *expandalias(char *str)
-{
- ALIAS *a=firstalias;
- String new={0},w1={0};
- char *p,*p1=new,*args;
- int dollar=0;
-
- strcpy(w1,word(str,1));
-
- if ( (p=strchr(str,' '))!=NULL )
- args=p+1;
- else
- args="";
-
- while (a)
- {
- if (!strcmp(a->name,w1))
- break;
- a=a->next;
- }
-
- if (!a)
- return str;
-
- for ( p=a->str; *p; p++)
- {
- if ( *p != '$' )
- {
- ADD(p1,*p);
- continue;
- }
-
- dollar=1;
- p++;
-
- if (isdigit(*p))
- {
- ADDSTR(&p1,word(str,(*p)-'0'+1));
- continue;
- }
-
- switch (*p)
- {
-
- case '\0':
- case '$': ADD(p1,'$');continue;
- case '*': ADDSTR(&p1,args);continue;
- default: ADD(p1,'$');ADD(p1,*p);continue;
- }
- }
-
- if (!dollar)
- {
- ADD(p1,' ');
- ADDSTR(&p1,args);
- }
-
- *p=0;
-
- return new;
-}
-
-ifalias(char *cmd)
-{
- String what;
- ALIAS *a=firstalias;
-
-
- strcpy(what,word(cmd,1));
-
- while ( a!=NULL)
- {
- if (!strcmp(a->name,what))
- return 1;
- a=a->next;
- }
- return 0;
-}
-
-
-
-char *getprompt()
-{
-
- static String _prompt;
- String tmp;
- char *s;
-
- _prompt[0]=0;
-
- for(s=prompt;*s;s++)
- switch (*s)
- {
- case '%':
- switch (*++s)
- {
-
- case 'H':
- strcat(_prompt,iftp[frame].host);
- break;
-
- case 'h':
- strcpy(tmp,iftp[frame].host);
- if (strchr(tmp,'.')!=NULL) *(char *)strchr(tmp,'.')=0;
- strcat(_prompt,tmp);
- break;
-
- case 'M':
- gethostname(tmp, sizeof tmp);
- strcat(_prompt,gethostbyname(tmp)->h_name);
- break;
-
- case 'm':
- gethostname(tmp, sizeof tmp);
- strcpy(tmp,gethostbyname(tmp)->h_name);
- if (strchr(tmp,'.')!=NULL) *(char *)strchr(tmp,'.')=0;
- strcat(_prompt,tmp);
- break;
-
- case 'u':
- strcat(_prompt,iftp[frame].user);
- break;
-
- case 'd':
- strcat(_prompt,iftp[frame].pwd);
- break;
-
- case 'D':
- strcat(_prompt,(char *)getcwd(tmp,sizeof(tmp)));
- break;
-
- case 'f':
- sprintf(tmp,"%d",frame);
- strcat(_prompt,tmp);
- break;
-
- case 'p':
- sprintf(tmp,"%d",(LINK==NULL)?0:LINK->port);
- strcat(_prompt,tmp);
- break;
-
- case 't':
-
- sprintf(tmp,"%d",(LINK==NULL)?0:LINK->timeout.tv_sec);
- strcat(_prompt,tmp);
- break;
-
-
- case 'T':
-
- {
- time_t t=time((time_t *)0);
- struct tm *lt=localtime(&t);
- sprintf(tmp,"%02d:%02d:%02d",lt->tm_hour,
- lt->tm_min,lt->tm_sec);
- strcat(_prompt,tmp);
- }
- break;
-
- case 'P':
-
- sprintf(tmp,"%d",getpid());
- strcat(_prompt,tmp);
- break;
-
- default:
- sprintf(tmp,"%%%c",*s);
- strcat(_prompt,tmp);
- break;
- }
- break;
-
- case '^':
-
- ++s;
- if (isalpha(*s))
- {
- sprintf(tmp,"%c",toupper(*s)-'A'+1);
- strcat(_prompt,tmp);
- }
- break;
-
- default:
-
- sprintf(tmp,"%c",*s);
- strcat(_prompt,tmp);
- break;
- }
- return _prompt;
-}
-
-
-void noop()
-{
- int i;
- time_t curtime,save;
- STATUS (*func1)(),(*func2)(),(*func3)();
-
-
- if (noopinterval==0) return;
-
- curtime = time((time_t *)0);
-
- signal(SIGALRM,noop);
-
- if (prevtime==0)
- {
- prevtime=curtime;
- alarm(noopinterval);
- return;
- }
-
- if (curtime-prevtime < noopinterval)
- {
- alarm(prevtime+noopinterval-curtime);
- return;
- }
-
- printf("Waiting...");fflush(stdout);
-
- for (i=0;i<NFRAMES;i++)
- {
- if ( ftp[i]==NULL || FTPCMD(ftp[i]) == NULL || iftp[i].lock )
- continue;
-
- func1=ftp[i]->debug; ftp[i]->debug=NULL;
- func2=ftp[i]->error; ftp[i]->error=NULL;
- func3=ftp[i]->IO; ftp[i]->IO=NULL;
- save = ftp[i]->timeout.tv_sec;
- ftp[i]->timeout.tv_sec = nooptimeout;
-
- FtpCommand(ftp[i],"NOOP","",0,EOF);
-
- ftp[i]->timeout.tv_sec = save;
- ftp[i]->debug=func1;
- ftp[i]->error=func1;
- ftp[i]->IO=func1;
-
- }
-
- alarm(noopinterval);
- prevtime=curtime;
-
- for (i=0;i<10;i++) putchar(8),putchar(' '),putchar(8);
- fflush(stdout);
-}
-
-
-setsignals()
-{
- signal(SIGINT,intr);
- signal(SIGQUIT,intr);
- noop();
-}
-
-unsetsignals()
-{
- signal(SIGALRM,SIG_IGN);
- alarm(0);
-}
-
-
-int myhash(FTP *ftp,unsigned int chars)
-{
-
- if (hashmode)
- {
- if (chars==0) return ftp -> counter=0;
- ftp -> counter += chars;
- fprintf(stdout,"%10u bytes transfered\r",ftp -> counter);
- fflush(stdout);
- }
-
- if (!lastcmd)
- {
- noop();
- alarm(0);
- }
-}
-
-
-
-char *makefilename(char *f1, char *f2)
-{
- char *p;
-
- if (*f2!=0)
- return f2;
-
- if ( (p=strrchr(f1,'/'))!=NULL)
- return p+1;
- return f1;
-}
-
-redir(char *cmdline)
-{
- char *p=cmdline;
- String result;
- char *r=result;
-
- for ( ; *p ; p++ , r++ )
- {
- if ( *p == '\\' )
- {
- *r = * ++ p ;
- continue;
- }
-
- if ( *p == '>' || *p == '<' )
- {
- String filename;
- char *q=filename;
- char c=*p;
-
- for (p++;isspace(*p)&&*p!=0;p++);
- if (*p=='"')
- {
- for (p++; *p!='"' && *p!=0 ; p++,q++) *q=*p;
- if (*p!='"') p++;
- }
- else
- for (; !isspace(*p) && *p!=0 ; p++,q++) *q=*p;
-
- *q=0;
-
- if ( c == '>' )
- output(filename);
- else
- input(filename);
- }
- *r=*p;
- }
- *r=0;
- strcpy(cmdline,result);
-}
-
-int itty=-1,otty=-1;
-FILE *is=NULL,*os=NULL;
-
-
-input(char *filename)
-{
-
- if ((is=Ftpfopen(filename,"r"))==NULL)
- {
- perror(filename);
- return;
- }
-
- fflush(stdin);
- itty=dup(0);
- close(0);
- dup2(fileno(is),0);
-
-}
-
-output(char *filename)
-{
-
- if ((os=Ftpfopen(filename,"w"))==NULL)
- {
- perror(filename);
- return;
- }
-
- fflush(stdout);
- otty=dup(1);
- close(1);
- dup2(fileno(os),1);
-}
-
-redirback()
-{
-
- if (itty!=-1)
- {
- fflush(stdin);
- close(0);
- Ftpfclose(is);
- dup2(itty,0);
- is=NULL;
- itty=-1;
- }
-
- if (otty!=-1)
- {
- fflush(stdout);
- close(1);
- Ftpfclose(os);
- dup2(otty,1);
- os=NULL;
- otty=-1;
- }
-}
-
-
-batch(char *filename)
-{
- FILE *fp;
- String tmp;
-
- if ((fp=fopen(filename,"r"))!=NULL)
- {
-
- while ( fgets(tmp, sizeof tmp, fp) != NULL)
- {
- tmp[strlen(tmp)-1]=0;
- execute(tmp);
- if (tmp[0]) add_history(tmp);
- }
- fclose(fp);
- }
-}
-
-
-
-
-
-
diff --git a/lib/libftp/utils/uftpcmd.c b/lib/libftp/utils/uftpcmd.c
deleted file mode 100644
index 2eb3cb2..0000000
--- a/lib/libftp/utils/uftpcmd.c
+++ /dev/null
@@ -1,1202 +0,0 @@
-#include "uftp.h"
-
-String tmp;
-
-jmp_buf connectstack;
-
-
-
-Ftp_connect_hook(FTP *ftp,int code, char *msg)
-{
- FtpLog(ftp->title,msg);
- longjmp(connectstack,1);
-
-}
-
-
-Ftp_connect(ARGS)
-{
- STATUS (*func1)(),(*func2)();
-
- if (*w2==0) w2=readline("Host:");
-
- if (FtpGetHost(w2)==NULL && FtpInit.IO != NULL)
- {
- char *msg;
- extern int h_errno;
-
- switch(h_errno)
- {
- case HOST_NOT_FOUND: msg = "Host unknown"; break;
- case TRY_AGAIN: msg = "Hostname lookup failure";break;
- default: msg = "gethostbyname failure";
- }
- return (*FtpInit.IO)(LINK,QUIT,msg);
- }
-
- newframe(0);
-
- func1 = FtpInit.error;
- func2 = FtpInit.IO;
-
- if (trymode)
- {
- FtpSetErrorHandler(&FtpInit,Ftp_connect_hook);
- FtpSetIOHandler(&FtpInit,Ftp_connect_hook);
- setjmp(connectstack);
- }
-
- FtpConnect(&LINK,w2);
- strcpy(iftp[frame].host,FtpGetHost(w2)->h_name);
-
- FtpSetErrorHandler(LINK,func1);
- FtpSetErrorHandler(&FtpInit,func1);
- FtpSetIOHandler(LINK,func2);
- FtpSetIOHandler(&FtpInit,func2);
-
- return;
-}
-
-Ftp_user(ARGS)
-{
-
- if (*w2==0)
- {
- sprintf(tmp,"login (default %s):",defaultuser);
- w2=readline(tmp);
- if (*w2==0)
- w2=defaultuser;
- }
- strcpy(iftp[frame].user,w2);
- strcpy(iftp[frame].pass,w3);
- if (FtpUser(LINK,w2)==331) Ftp_pass("",w3,"","","","");
-}
-
-Ftp_pass(ARGS)
-{
- if (*w2==0)
- {
- String pass;
- String host;
-
- gethostname(host, sizeof host);
- strcpy(host,FtpGetHost(host)->h_name);
- sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host);
- sprintf(tmp,"Password (default %s):",pass);
- w2=getpass(tmp);
- if (*w2==0) w2=pass;
- }
-
- strcpy(iftp[frame].pass,w2);
- FtpPassword(LINK,w2);
- strcpy(iftp[frame].pwd,FtpPwd(LINK));
-}
-
-Ftp_open(ARGS)
-{
- register char *p1;
- STATUS (*err)();
-
- Ftp_connect("",w2,"","","","");
- Ftp_user("",w3,w4,"","","" );
- if (ifalias("autologin")) execute("autologin");
- if (*w5)
- Ftp_cd("cd",w5,"","","","");
-}
-
-Ftp_reopen(ARGS)
-{
- String host,user,pass,pwd;
-
- strcpy(host,iftp[frame].host);
- strcpy(user,iftp[frame].user);
- strcpy(pass,iftp[frame].pass);
- strcpy(pwd,iftp[frame].pwd);
-
- Ftp_close("","","","","","");
- Ftp_open("",host,user,pass,pwd,"");
-}
-
-Ftp_ftp(ARGS)
-{
- String pass;
- String host;
-
- gethostname(host, sizeof host);
- strcpy(host,FtpGetHost(host)->h_name);
- sprintf(pass,"%s@%s",getpwuid(getuid())->pw_name,host);
-
- Ftp_open("",w2,"anonymous",pass,w3,"");
- return;
-}
-
-Ftp_quit(ARGS)
-{
- exit(0);
-}
-
-Ftp_mput_handler()
-{
- log("File(s) or directory not found");
- longjmp(start,1);
-}
-
-
-Ftp_lcd(ARGS)
-{
- glob_t gl;
-
- bzero(&gl,sizeof gl);
-
- glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE,
- Ftp_mput_handler, &gl);
-
-
- if (gl.gl_matchc<1 || chdir(*gl.gl_pathv))
- perror(w2);
-
- printf("Local directory is \"%s\"\n",getwd(tmp));
-}
-
-Ftp_dir(ARGS)
-{
- char *cmd1;
- String cmd;
- char mode=LINK->mode;
-
- if ( !strcmp(w1,"dir") )
- cmd1="LIST";
- else
- cmd1="NLST";
-
- strcpy(cmd,makestr(cmd1,w2,w3,w4,w5,w6,NULL));
-
- if ( LINK->mode != 'A' ) FtpAscii(LINK);
- FtpRetr(LINK,cmd,"","-");
- if ( LINK->mode != mode ) FtpType(LINK,mode);
-
-}
-
-Ftp_close(ARGS)
-{
- register int i;
-
- if (isdigit(*w2))
- {
- i=atoi(w2);
- }
- else
- {
- i=frame;
- }
-
- FtpQuickBye(ftp[i]);
-
- iftp[i].host[0]=0;
- iftp[i].pwd[0]=0;
- ftp[i]=NULL;
- newframe(1);
-}
-
-
-INLINE SetLogicalVar(char arg, int * var, char *msg)
-{
- switch(arg)
- {
-
- case 'y':
-
- *var=1;
- break;
-
- case 'n':
-
- *var=0;
- break;
-
- default:
-
- (*var)?(*var=0):(*var=1);
- break;
- }
- return printf("%s %s\n",msg,(*var)?"enable":"disable");
-}
-
-
-Ftp_set(ARGS)
-{
- if (!strcmp("frame",w2))
- return atoi(w3)<NFRAMES?frame=atoi(w3):0;
-
- if (!strcmp("timeout",w2))
- {
- FtpSetTimeout(&FtpInit,atoi(w3));
- if (LINK!=0)
- FtpSetTimeout(LINK,atoi(w3));
- return;
- }
-
- if (!strcmp("sleep",w2))
- {
- sleeptime=atoi(w3);
- return;
- }
-
- if (!strcmp("debug",w2))
- {
- if ( *w3=='y' || *w3==0)
- {
- if (LINK!=NULL) FtpSetDebugHandler(LINK,FtpDebugDebug);
- FtpSetDebugHandler(&FtpInit,FtpDebugDebug);
- return puts("Debuging on for current and next session");
- }
- if ( *w3 == 'n')
- {
- if (LINK!=NULL) FtpSetDebugHandler(LINK,NULL);
- FtpSetDebugHandler(&FtpInit,NULL);
- return puts("Debuging off for current and next session");
- }
- }
-
- if (!strcmp("bin",w2))
- {
- if ( *w3=='y' || *w3==0)
- {
- FtpInit.mode='I';
- return puts("Binary mode enable");
- }
- if ( *w3 == 'n')
- {
- FtpInit.mode='A';
- return puts("Binary mode disable");
- }
- }
-
- if (!strcmp("try",w2))
- return SetLogicalVar(*w3,&trymode,"Try mode");
- if (!strcmp("hash",w2))
- return SetLogicalVar(*w3,&hashmode,"Hash mode");
- if (!strcmp("glass",w2))
- return SetLogicalVar(*w3,&glassmode,"Glass mode");
- if (!strcmp("rest",w2)||!strcmp(w2,"restore"))
- return SetLogicalVar(*w3,&restmode,"Restore mode");
-
- if (!strcmp("prompt",w2))
- {
- strcpy(prompt,w3);
- return;
- }
-
- if (!strcmp("port",w2))
- {
- if ( isdigit(*w3))
- return FtpSetPort(&FtpInit,atoi(w3));
- puts("Port must be number");
- fflush(stdout);
- return;
- }
-
- if (!strcmp("noopinterval",w2)||!strcmp("noop",w2))
- {
- if ( isdigit(*w3))
- return noopinterval=(time_t)atoi(w3);
- puts("Time must be number");
- fflush(stdout);
- return;
- }
-
- if (!strcmp("nooptimeout",w2))
- {
- if ( isdigit(*w3))
- return nooptimeout=(time_t)atoi(w3);
- puts("Time must be number");
- fflush(stdout);
- return;
- }
-
-
-
- if (!strcmp("user",w2)||!strcmp("login",w2))
- {
- strcpy(defaultuser,w3);
- return;
- }
-
- if (!strcmp("",w2))
- {
-
- printf("frime %d\n",frame);
- printf("timeout %d secs\n",FtpInit.timeout.tv_sec);
- printf("sleep time %d secs\n",sleeptime);
- printf("debug %s\n",(FtpInit.debug!=NULL)?"enable":"disable");
- printf("glass mode %s\n",glassmode?"enable":"disable");
- printf("try mode %s\n",trymode?"enable":"disable");
- printf("hash mode %s\n",hashmode?"enable":"disable");
- printf("restore mode %s\n",restmode?"enable":"disable");
- printf("automatic binary mode %s\n",(FtpInit.mode=='I')?"enable":"disable");
- printf("prompt \"%s\"\n",prompt);
- printf("port %d\n",FtpInit.port);
- printf("noop interval %d\n",noopinterval);
- printf("noop timeout %d\n",nooptimeout);
- printf("Default login name \"%s\"\n",defaultuser);
- fflush(stdout);
- return;
- }
- return puts("arg 2 unknown");
-
-}
-
-jmp_buf getstack;
-
-Ftp_get_hook(FTP *con,int code, char *msg)
-{
-
- if ( abs(code)==550 && FtpBadReply550(msg) )
- {
- FtpLog(con->title,msg);
- log("Transfer cancel");
- longjmp(getstack,2);
- }
-
- if ( code == LQUIT )
- {
- log(msg);
- log("Transfer leave after I/O error with local file");
- longjmp(getstack,2);
- }
-
-
-
- FtpLog(con->title,msg);
- FtpQuickBye(LINK);
- LINK=NULL;
-
- log("sleeping......");
- sleep(sleeptime);
- log("try again...");
-
- longjmp(getstack,1);
-
-}
-
-void Ftp_get_intr(int sig)
-{
- signal(SIGINT,intr);
- log("Transfer interupt");
- Ftp_abort();
- longjmp(getstack,3);
-}
-
-Ftp_get(ARGS)
-{
- FTP OldInit;
- int back=0;
- int code;
- int status=0;
-
- OldInit=FtpInit;
-
- if (strstr(w1,"put")!=NULL) back=1;
-
-
- if (restmode || ((*w1=='r')&&(*(w1+1)=='e')) )
- FtpSetFlag(LINK,FTP_REST);
- else
- FtpClearFlag(LINK,FTP_REST);
-
-
-
- if (trymode)
- {
- FtpSetErrorHandler(LINK,Ftp_get_hook);
- FtpSetIOHandler(LINK,Ftp_get_hook);
- FtpInit=*LINK;
- FTPCMD(&FtpInit)=FTPCMD(&OldInit);
- FTPDATA(&FtpInit)=FTPDATA(&OldInit);
- }
-
- signal(SIGINT,Ftp_get_intr);
- FtpSetHashHandler(LINK,NULL);
-
-
- if ((status=setjmp(getstack))==2||status==3)
- goto done;
-
- if ((LINK==NULL)||(LINK->sock==FtpInit.sock))
- {
- FtpLogin(&LINK,iftp[frame].host,iftp[frame].user,
- iftp[frame].pass,NULL);
- FtpChdir(LINK,iftp[frame].pwd);
- }
-
- if (hashmode && isatty(fileno(stdout)))
- FtpSetHashHandler(LINK,myhash);
- else
- FtpSetHashHandler(LINK,NULL);
-
- myhash(LINK,0);
-
- if (!back)
- FtpGet(LINK,w2,makefilename(w2,w3));
- else
- FtpPut(LINK,w2,makefilename(w2,w3));
-
-
- log("Transfer compliete");
-
-
-done:
-
-
- FtpSetHashHandler(LINK,NULL);
- FtpSetErrorHandler(LINK,my_error);
- FtpSetIOHandler(LINK,my_error);
- FtpClearFlag(LINK,FTP_REST);
- FtpInit=OldInit;
-}
-
-Ftp_mget(ARGS)
-{
- FILE *list;
- char mode=LINK->mode;
-
- sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name);
- mktemp(tmp);
-
- if ( LINK->mode != 'A' ) FtpAscii(LINK);
-
- if (*w2==0)
- FtpRetr(LINK,"NLST","",tmp);
- else
- FtpRetr(LINK,"NLST %s",w2,tmp);
-
- if ( LINK->mode != mode ) FtpType(LINK,mode);
-
- if ((list=fopen(tmp,"r"))==NULL)
- return FtpLog(tmp,sys_errlist[errno]);
-
- while ( fgets(tmp,sizeof tmp,list)!=NULL)
- {
- tmp[strlen(tmp)-1]=0;
- Ftp_get("get",tmp,w3,"","","");
- }
-
- fclose(list);
-}
-
-Ftp_mput(ARGS)
-{
- glob_t gl;
-
- glob(w2,GLOB_BRACE|GLOB_TILDE|GLOB_QUOTE,
- Ftp_mput_handler, &gl);
-
- while(gl.gl_matchc--)
- {
- Ftp_get("put",*gl.gl_pathv,"","","","");
- gl.gl_pathv++;
- }
-}
-
-
-Ftp_bget(ARGS)
-{
-
- String fn,lfn;
- char *p;
-
- newframe(0);
-
- if (!FtpFullSyntax(w2,iftp[frame].host,iftp[frame].user,
- iftp[frame].pass,fn))
- return puts("Filename syntax error");
-
- strcpy(iftp[frame].pwd,"/");
-
- if ((p=strrchr(fn,'/'))!=NULL)
- strcpy(lfn,p+1);
- else
- strcpy(lfn,fn);
-
- FtpQuickBye(LINK);
- LINK=FtpCreateObject();
- LINK->sock=NULL;
-
- Ftp_get("get",fn,(*w3==0)?lfn:w3,"","","");
-}
-
-Ftp_bput(ARGS)
-{
-
- String fn,lfn;
- char *p;
-
- if (!FtpFullSyntax((*w3==0)?w2:w3,iftp[frame].host,iftp[frame].user,
- iftp[frame].pass,fn))
- return puts("Filename syntax error");
-
- strcpy(iftp[frame].pwd,"/");
-
- if ((p=strrchr(fn,'/'))!=NULL)
- strcpy(lfn,p+1);
- else
- strcpy(lfn,fn);
-
- FtpQuickBye(LINK);
- LINK=FtpCreateObject();
- LINK->sock=NULL;
-
- Ftp_get("put",(*w3==0)?lfn:w2,fn,"","","");
-}
-
-Ftp_copy(ARGS)
-{
- char *p;
- int in,out;
-
- if ( !*w2 || !*w3 ) return puts("Must pass two args");
-
- if ((p=strchr(w2,'!'))!=NULL)
- {
- *p=0;
- in=atoi(w2);
- w2=p+1;
- }
- else
- in=frame;
-
- if ((p=strchr(w3,'!'))!=NULL)
- {
- *p=0;
- out=atoi(w3);
- w3=p+1;
- }
- else
- in=frame;
-
- if (in==out) return puts("Files must been from different frames");
-
- FtpCopy(ftp[in],ftp[out],w2,w3);
-}
-
-Ftp_ccopy(ARGS)
-{
- char *p;
- int in,out;
-
- if ( !*w2 || !*w3 ) return puts("Must pass two args");
-
- if ((p=strchr(w2,'!'))!=NULL)
- {
- *p=0;
- in=atoi(w2);
- w2=p+1;
- }
- else
- in=frame;
-
- if ((p=strchr(w3,'!'))!=NULL)
- {
- *p=0;
- out=atoi(w3);
- w3=p+1;
- }
- else
- in=frame;
-
- if (in==out) return puts("Files must been from different frames");
-
- FtpPassiveTransfer(ftp[in],ftp[out],w2,w3);
-}
-
-Ftp_bin(ARGS)
-{
- FtpBinary(LINK);
-}
-
-Ftp_ascii(ARGS)
-{
- FtpAscii(LINK);
-}
-
-Ftp_cd(ARGS)
-{
- FtpChdir(LINK,w2);
- strcpy(iftp[frame].pwd,FtpPwd(LINK));
- if (ifalias("autocd")) execute("autocd");
-}
-
-
-Ftp_dup(ARGS)
-{
- LINKINFO oldinfo;
- FTP oldftp;
-
- oldinfo=iftp[frame];
- oldftp=*LINK;
-
- newframe(0);
- puts("Make alternative connection...");
- Ftp_open("",oldinfo.host,oldinfo.user,oldinfo.pass,"","");
- if (strcmp(oldinfo.pwd,iftp[frame].pwd))
- Ftp_cd("",oldinfo.pwd,"","","","");
- if (LINK->mode!=oldftp.mode)
- FtpType(LINK,oldftp.mode);
- LINK -> timeout = oldftp.timeout;
- LINK -> flags = oldftp.flags;
- FtpSetDebugHandler(LINK,oldftp.debug);
- FtpSetErrorHandler(LINK,oldftp.error);
- FtpSetIOHandler(LINK,oldftp.IO);
- FtpSetHashHandler(LINK,oldftp.hash);
-}
-
-
-
-Ftp_bg(ARGS)
-{
- if (fork())
- {
-
- log("Backgrounding...");
- return;
- }
- else
- {
- int i=frame;
-
- lastcmd=1;
-
- /* Ignoring keypad */
-
- alarm (0);
- signal(SIGALRM,SIG_IGN);
- signal(SIGURG,SIG_IGN);
- signal(SIGPIPE,SIG_IGN);
- signal(SIGTSTP,SIG_IGN);
- signal(SIGINT,SIG_IGN);
- signal(SIGQUIT,SIG_IGN);
- signal(SIGCHLD,SIG_IGN);
- signal(SIGIO,SIG_IGN);
-
- /* Droping output */
-
-
- sprintf(tmp,"/tmp/uftp-%s.XXXXXX",getpwuid(getuid())->pw_name);
- mktemp(tmp);
- close(0);close(1);close(2);
- open(tmp,O_RDWR|O_TRUNC|O_CREAT,0600);
- dup(0);dup(0);
-
- if (LINK!=NULL)
- {
- Ftp_dup("","","","","","");
- free(ftp[i]);
- ftp[i]=NULL;
- }
-
- return executev(w2,w3,w4,w5,w6,"");
- }
-}
-
-
-Ftp_list()
-{
- register int i;
-
-#define _FMT "%-5s %-15s %-10s %-25s %-7s %-4s\n"
-#define FMT "%-5d %-15s %-10s %-25s %-7d %-4d\n"
-
- printf(_FMT,"Frame","Host name","User's name","Working directory","Timeout","Port");
-
- for ( i = 0 ; i < NFRAMES ; i++ )
- if (ftp[i]!=NULL)
- printf(FMT,i,iftp[i].host,iftp[i].user,iftp[i].pwd,
- ftp[i]->timeout.tv_sec,ftp[i]->port);
- fflush(stdout);
- return;
-}
-
-Ftp_abort(ARGS)
-{
- time_t save;
-
- if (LINK!=NULL)
- {
- save = LINK ->timeout.tv_sec;
- LINK->timeout.tv_sec = nooptimeout;
- FtpAbort(LINK);
- LINK->timeout.tv_sec = save;
- }
-}
-
-Ftp_type(ARGS)
-{
- FtpGet(LINK,w2,"*STDOUT*");
-}
-
-
-Ftp_page(ARGS)
-{
- register char *pager;
- String out={'|',0};
-
- if ((pager=(char *)getenv("PAGER"))==NULL)
- pager="more";
-
- strcat(out,pager);
- FtpGet(LINK,w2,out);
-}
-
-
-Ftp_mkdir(ARGS)
-{
- FtpMkdir(LINK,w2);
-}
-
-Ftp_rm(ARGS)
-{
- FILE *list;
-
- sprintf(tmp,"/tmp/uftplist-%s.XXXXXX",getpwuid(getuid())->pw_name);
- mktemp(tmp);
-
- if (*w2==0)
- {
- log("Filename specification must present");
- return;
- }
-
- FtpRetr(LINK,"NLST %s",w2,tmp);
-
- if ((list=fopen(tmp,"r"))==NULL)
- return FtpLog(tmp,sys_errlist[errno]);
-
- while ( fgets(tmp,sizeof tmp,list)!=NULL)
- {
- tmp[strlen(tmp)-1]=0;
- FtpCommand(LINK,"DELE %s",tmp,0,EOF);
- }
-
- fclose(list);
-}
-
-
-
-
-Ftp_move(ARGS)
-{
- FtpMove(LINK,w2,w3);
-}
-
-Ftp_help(ARGS)
-{
- register int i,ii;
-
- if ( !*w2 )
- {
- puts("Warrning!!!! \nPlease read general information using command \"help etc\"\n\n");
-
- for ( i = 0 ;1; i++)
- {
- for ( ii = 0 ; ii < 5 ; ii++)
- {
- if (cmds[ii+i*5].cmd==NULL) return putchar('\n');
- printf("%-16s",cmds[ii+i*5].cmd);
- }
- putchar ('\n');
- }
- }
-
-
- for ( i = 0 ; 1; i++)
- {
-
- if (cmds[i].cmd==NULL) return puts("Command not found");
- if (!strcmp(cmds[i].cmd,w2))
- break;
- }
-
- puts(cmds[i].help);
-
-}
-
-Ftp_quote(ARGS)
-{
- String new;
-
- new[0]=0;
-
- if (*w2!=0) strcpy(new,w2);
- if (*w3!=0) strcat(new," "),strcat(new,w3);
- if (*w4!=0) strcat(new," "),strcat(new,w4);
- if (*w5!=0) strcat(new," "),strcat(new,w5);
- if (*w6!=0) strcat(new," "),strcat(new,w6);
-
- FtpCommand(LINK,new,"",0,EOF);
-}
-
-Ftp_alias(ARGS)
-{
- ALIAS *a=firstalias;
-
-
- if ( *w2==0 )
- {
- while (a!=NULL)
- {
- printf("%s=%s\n",a->name,a->str);
- a=a->next;
- }
- return;
- }
-
-
- while (1)
- {
-
- if ( a == NULL )
- {
- firstalias = a = (ALIAS *) malloc(sizeof(ALIAS));
- memset(a,0,sizeof(ALIAS));
- a -> next = NULL;
- break;
- }
-
- if (!strcmp(a->name,w2))
- break;
-
- if ( a->next == NULL)
- {
- a -> next = (ALIAS *) malloc(sizeof(ALIAS));
- a = a->next;
- memset(a,0,sizeof(ALIAS));
- a -> next = NULL;
- break;
- }
- a=a->next;
- }
-
- strcpy(a -> name,w2);
- strcpy(a -> str,makestr(w3,w4,w5,w6,NULL));
-}
-
-Ftp_mkalias(ARGS)
-{
- String new;
-
- if (!*w2) return puts("Arg must present\n");
-
- sprintf(new,"open \"%s\" \"%s\" \"%s\" \"%s\"",
- iftp[frame].host,iftp[frame].user,
- iftp[frame].pass,iftp[frame].pwd);
-
- Ftp_alias("alias",w2,new,"","","");
-}
-
-Ftp_unalias(ARGS)
-{
- ALIAS *cur,*prev;
-
- cur=prev=firstalias;
-
- while ( cur != NULL )
- {
- if (!strcmp(cur->name,w2))
- {
- if ( cur == firstalias )
- {
- firstalias = cur->next;
- free(cur);
- return;
- }
- prev -> next = cur -> next;
- free(cur);
- }
- prev=cur;
- cur=cur->next;
- }
-}
-
-
-Ftp_save(ARGS)
-{
- ALIAS *a=firstalias;
- String fn;
- FILE *out;
-
- if ((out=fopen (getaliasrcname(),"w"))==NULL)
- {
- perror(getaliasrcname());
- return;
- }
-
- while (a!=NULL)
- {
- fprintf(out,"alias %s '%s'\n",a->name,a->str);
- a=a->next;
- }
- fclose(out);
- chmod ( getaliasrcname(), 0600);
- puts("Aliases saved");
-}
-
-#define ARCHIE_MAX_TARGETS 20
-
-Ftp_acd(ARGS)
-{
- static int targets=0;
- static String what={0};
- static ARCHIE result[ARCHIE_MAX_TARGETS];
-
- int i, selected_target;
- String tmp;
- char *p;
-
-
- if ( (what[0] == 0 || strcmp(w2,what) != 0) && *w2!=0 )
- {
- if ((targets=FtpArchie(w2,result,ARCHIE_MAX_TARGETS))<1)
- return puts("Archie failure or target not found");
- strcpy(what,w2);
- }
-
- for (i=0;i<targets;i++)
- printf("%2d %s:%s\n",i,result[i].host,result[i].file);
-
- if (strcmp(w1,"archie")==0)
- return;
-
-
- p = readline("Your selection? ");
- if (p==NULL) return;
-
- selected_target = atoi(p);
-
- if ( result[selected_target].file[strlen(result[selected_target].file)-1]
- == '/' )
- {
- Ftp_ftp("ftp",result[selected_target].host,result[selected_target].file,
- "","","");
- return;
- }
- else
- {
- sprintf(tmp,"%s:%s",
- result[selected_target].host,result[selected_target].file);
- Ftp_bget("bget",tmp,"","","","");
- }
-}
-
-
-CMDS cmds[]={
-
- "connect", Ftp_connect, 0,
- "connect <hostname> - make new ftp connection",
-
- "open", Ftp_open, 0,
- "open <hostname> <user> <pass> <directory> - login to server",
-
- "reopen", Ftp_reopen, 1,
- "Open again connection with existing frame information",
-
- "ftp", Ftp_ftp, 0,
- "ftp <hostname> - anonymously login to server",
-
- "close", Ftp_close, 1,
- "Close connection",
-
- "quit", Ftp_quit, 0,
- "Exit from uftp",
-
- "set", Ftp_set, 0,
-"Set variables: (Without args print current settings)\n\
- frame <number> - select another session(frame)\n\
- timeout <secs> - Set network timeout\n\
- nooptimeout <secs>- Set network timeout with clearing timeout\n\
- noop <secs> - Set time interval for sending NOOP operator\n\
- to server for erased delay\n\
- sleep <secs> - Set pause beetween transfer attempt\n\
- debug <y|n> - Set debuging ftp's protocol (Default no)\n\
- try <y|n> - Set retransfer mode with broken network (Default yes)\n\
- hash <y|n> - Set hashing transfer (Default no)\n\
- restore <y|n> - Set retransfer mode (reget/reput) (Default yes!!!!)\n\
- bin <y|n> - Set automatic turn on binary mode (Default no) \n\
- glass <y|n> - Set glass mode (bad commands interprets as commands for FTPD)\n\
- prompt <string> - Set prompt (See help prompt)\n\
- port <number> - Set ftpd's port for next sessions\n\
- user <name> - Set default user name (default you name)",
-
- "prompt", NULL, 0,
- "\
-prompt is a string, which may be contains %<char>
-or ^<char> combitanion, which have next interprets:
-
-%H, %h - full and short remote host names
-%M, %m - full and short local host names
-%u - remote user's name
-%d - remote current directory
-%D - local current directory
-%f - number of current frame
-%p - the ftp's port number
-%t - timeout
-%T - current time
-%P - uftp process id
-%% - character %
-^<char>- control character
-%^ - character ^
-",
-
- "list", Ftp_list, 0,
-"List session's information",
-
- "user", Ftp_user, 1,
-"user <user> - send user's name",
-
- "pass", Ftp_pass, 1,
-"pass <pass> - send user's password",
-
- "bin", Ftp_bin, 1,
-"Set binary mode for current frame",
-
- "ascii", Ftp_ascii, 1,
-"Set ASCII mode for current frame",
-
- "cd", Ftp_cd, 1,
-"cd <directory> - change current remote directory ",
-
- "acd", Ftp_acd, 0,
-"acd <file_or_directory> - search pointed directory using archie, and setup connection to it",
-
- "lcd", Ftp_lcd, 0,
-"Change local directory",
-
- "abort", Ftp_abort, 1,
-"abort last operation",
-
- "mkdir", Ftp_mkdir, 1,
-"mkdir <dirname> - create new directory",
-
- "rm", Ftp_rm, 1,
-"rm <filename_spec> - remove file(s)",
-
- "mv", Ftp_move, 1,
-"mv <old> <new> - rename file",
-
- "dir", Ftp_dir, 1,
-"dir <argslist> ... - print list of files",
-
- "ls", Ftp_dir, 1,
-"ls <arglist> ... - print short list of files",
-
- "get", Ftp_get, 1,
-"get <remote_file> [<local_file>] - receive file from server",
-
- "mget", Ftp_mget, 1,
-"mget <remote_file(s)> [<local_directory>] - receive file(s) from server",
-
- "reget", Ftp_get, 1,
-"reget <remote_file> <local_file> - receive file restarting at end of local file",
-
- "aget", Ftp_acd, 0,
-"aget <file> - search pointed file using archie, and retrive it",
-
- "put", Ftp_get, 1,
-"put <local_file> [<remote_file>] - send server to file",
-
- "mput", Ftp_mput, 1,
-"mput <local_file(s)> - send file(s) from server",
-
- "reput", Ftp_get, 1,
-"reput <local_file> [<remote_file>] - send file restarting at end of remote file",
-
- "bget", Ftp_bget, 0,
-"bget <libftp_file> [<localfile>] - full session procedure (See \"help etc\")",
-
- "bput", Ftp_bput, 0,
-"bput [<localfile>] <libftp_file> - full session procedure (See \"help etc\")",
-
- "copy", Ftp_copy, 1,
-"copy [<frame>!]file [<frame>!]file - copy file via client cache",
-
- "ccopy", Ftp_ccopy, 1,
-"ccopy [<frame>!]file [<frame>!]file - copy file directly beetween servers",
-
- "cat", Ftp_type, 1,
-"cat <file> - print body of remote file to screen",
-
- "page", Ftp_page, 1,
-"page <file> - print body of remote file to screen via pager",
-
- "bg", Ftp_bg, 0,
-"bg <any_command> - run command(s) backgroundly (output redirect to file),\n\
-You can also add &-char to back of line without \"bg\"",
-
- "archie", Ftp_acd, 0,
-"Find file using archie service and display to screen",
-
- "dup", Ftp_dup, 1,
-"Make new analogous frame",
-
- "quote", Ftp_quote, 1,
-"quote <some_string> - send command directly to server",
-
- "help", Ftp_help, 0,
-"help <command> - print list of commands or command description",
-
- "alias", Ftp_alias, 0,
-"\
-alias aliasname <list> .... - make new alias, use $X for taking \n\
- X's argument from command string, and $* for taking\n\
- all arguments. If $<anything> on alias not present,\n\
- the arguments appending to end of command string",
-
- "unalias", Ftp_unalias, 0,
-"unalias <aliasname> - remove alias",
-
- "mkalias", Ftp_mkalias, 0,
-"make alias for create this frame, use savealias for saving it to file",
-
- "savealias", Ftp_save, 0,
- "Save aliases to file",
-
- "etc", NULL, 0,
- "\
-1. In any command you may use constructions <file and >file for\n\
- redirect input output.\n\
-\n\
-2. All local files files interprets as libftp file(s), \n\
- this support next specification:\n\
-\n\
- |string - interprets string as shell command, which must be\n\
- execute and input or output take from/to it.\n\
- \n\
- hostname:filename - interprets as file, witch must be take \n\
- using ftp protocol with anonymously access\n\
- \n\
- user@hostname:filename - interprets as file accesses via ftp\n\
- with password yourname@your_host.your_domain\n\
-\n\
- user/pass@hostname:filename - also ftp file.\n\
-\n\
- *STDIN*, *STDOUT*, *STDERR* - opened streams.\n\
-\n\
- anything - local file name.\n\
-\n\
-3. Command started with '!' passed to shell.\n
-\n\
-4. If string beetween two \" or \', its interprets as one word.\n\
-\n\
-5. Any string may be devide to few commands using ';'.",
-
-
-
- NULL
-
-};
-
-
-
-
-
-
-
diff --git a/lib/libncurses/TESTS/bs.c b/lib/libncurses/TESTS/bs.c
deleted file mode 100644
index 3785fcd..0000000
--- a/lib/libncurses/TESTS/bs.c
+++ /dev/null
@@ -1,1252 +0,0 @@
-/*
- * bs.c - original author: Bruce Holloway
- * salvo option by: Chuck A DeGaul
- * with improved user interface, autoconfiguration and code cleanup
- * by Eric S. Raymond <esr@snark.thyrsus.com>
- * v1.2 with color support and minor portability fixes, November 1990
- * v2.0 featuring strict ANSI/POSIX conformance, November 1993.
- */
-
-#include <ncurses.h>
-#include <signal.h>
-#include <ctype.h>
-#include <assert.h>
-
-#ifndef A_UNDERLINE /* BSD curses */
-#define beep() write(1,"\007",1);
-#define cbreak crmode
-#define saveterm savetty
-#define resetterm resetty
-#define nocbreak nocrmode
-#define strchr index
-#endif /* !A_UNDERLINE */
-
-#ifdef isxdigit /* aha, must be an AT&T system... */
-#define srand(n) srand48(n)
-#define rand() lrand48()
-extern long lrand48();
-extern void srand48();
-#define bzero(s, n) (void)memset((char *)(s), '\0', n)
-extern char *memset();
-/*
- * Try this if ungetch() fails to resolve.
- *
- * #define ungetch ungetc
- */
-#endif /* isxdigit */
-
-extern unsigned sleep();
-extern char *strchr(), *strcpy();
-extern long time();
-extern void exit();
-
-static bool checkplace();
-
-/*
- * Constants for tuning the random-fire algorithm. It prefers moves that
- * diagonal-stripe the board with a stripe separation of srchstep. If
- * no such preferred moves are found, srchstep is decremented.
- */
-#define BEGINSTEP 3 /* initial value of srchstep */
-
-/* miscellaneous constants */
-#define SHIPTYPES 5
-#define OTHER (1-turn)
-#define PLAYER 0
-#define COMPUTER 1
-#define MARK_HIT 'H'
-#define MARK_MISS 'o'
-#define CTRLC '\003' /* used as terminate command */
-#define FF '\014' /* used as redraw command */
-
-/* coordinate handling */
-#define BWIDTH 10
-#define BDEPTH 10
-
-/* display symbols */
-#define SHOWHIT '*'
-#define SHOWSPLASH ' '
-#define IS_SHIP(c) isupper(c)
-
-/* how to position us on player board */
-#define PYBASE 3
-#define PXBASE 3
-#define PY(y) (PYBASE + (y))
-#define PX(x) (PXBASE + (x)*3)
-#define pgoto(y, x) (void)move(PY(y), PX(x))
-
-/* how to position us on cpu board */
-#define CYBASE 3
-#define CXBASE 48
-#define CY(y) (CYBASE + (y))
-#define CX(x) (CXBASE + (x)*3)
-#define cgoto(y, x) (void)move(CY(y), CX(x))
-
-#define ONBOARD(x, y) (x >= 0 && x < BWIDTH && y >= 0 && y < BDEPTH)
-
-/* other board locations */
-#define COLWIDTH 80
-#define PROMPTLINE 21 /* prompt line */
-#define SYBASE CYBASE + BDEPTH + 3 /* move key diagram */
-#define SXBASE 63
-#define MYBASE SYBASE - 1 /* diagram caption */
-#define MXBASE 64
-#define HYBASE SYBASE - 1 /* help area */
-#define HXBASE 0
-
-/* this will need to be changed if BWIDTH changes */
-static char numbers[] = " 0 1 2 3 4 5 6 7 8 9";
-
-static char carrier[] = "Aircraft Carrier";
-static char battle[] = "Battleship";
-static char sub[] = "Submarine";
-static char destroy[] = "Destroyer";
-static char ptboat[] = "PT Boat";
-
-static char name[40];
-static char dftname[] = "stranger";
-
-/* direction constants */
-#define E 0
-#define SE 1
-#define S 2
-#define SW 3
-#define W 4
-#define NW 5
-#define N 6
-#define NE 7
-static int xincr[8] = {1, 1, 0, -1, -1, -1, 0, 1};
-static int yincr[8] = {0, 1, 1, 1, 0, -1, -1, -1};
-
-/* current ship position and direction */
-static int curx = (BWIDTH / 2);
-static int cury = (BDEPTH / 2);
-
-typedef struct
-{
- char *name; /* name of the ship type */
- unsigned hits; /* how many times has this ship been hit? */
- char symbol; /* symbol for game purposes */
- char length; /* length of ship */
- char x, y; /* coordinates of ship start point */
- char dir; /* direction of `bow' */
- bool placed; /* has it been placed on the board? */
-}
-ship_t;
-
-ship_t plyship[SHIPTYPES] =
-{
- { carrier, 0, 'A', 5},
- { battle, 0, 'B', 4},
- { destroy, 0, 'D', 3},
- { sub, 0, 'S', 3},
- { ptboat, 0, 'P', 2},
-};
-
-ship_t cpuship[SHIPTYPES] =
-{
- { carrier, 0, 'A', 5},
- { battle, 0, 'B', 4},
- { destroy, 0, 'D', 3},
- { sub, 0, 'S', 3},
- { ptboat, 0, 'P', 2},
-};
-
-/* "Hits" board, and main board. */
-static char hits[2][BWIDTH][BDEPTH], board[2][BWIDTH][BDEPTH];
-
-static int turn; /* 0=player, 1=computer */
-static int plywon=0, cpuwon=0; /* How many games has each won? */
-
-static int salvo, blitz, closepack;
-
-#define PR (void)addstr
-
-static void uninitgame(sig)
-/* end the game, either normally or due to signal */
-int sig;
-{
- clear();
- (void)refresh();
- (void)resetterm();
- (void)echo();
- (void)endwin();
- exit(0);
-}
-
-static void announceopts()
-/* announce which game options are enabled */
-{
- if (salvo || blitz || closepack)
- {
- (void) printw("Playing optional game (");
- if (salvo)
- (void) printw("salvo, ");
- else
- (void) printw("nosalvo, ");
- if (blitz)
- (void) printw("blitz ");
- else
- (void) printw("noblitz, ");
- if (closepack)
- (void) printw("closepack)");
- else
- (void) printw("noclosepack)");
- }
- else
- (void) printw(
- "Playing standard game (noblitz, nosalvo, noclosepack)");
-}
-
-static void intro()
-{
- extern char *getlogin();
- char *tmpname;
-
- srand(time(0L)+getpid()); /* Kick the random number generator */
-
- (void) signal(SIGINT,uninitgame);
- (void) signal(SIGINT,uninitgame);
- (void) signal(SIGIOT,uninitgame); /* for assert(3) */
- if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
- (void)signal(SIGQUIT,uninitgame);
-
- if(tmpname = getlogin())
- {
- (void)strcpy(name,tmpname);
- name[0] = toupper(name[0]);
- }
- else
- (void)strcpy(name,dftname);
-
- (void)initscr();
-#ifdef KEY_MIN
- keypad(stdscr, TRUE);
-#endif /* KEY_MIN */
- (void)saveterm();
- (void)nonl();
- (void)cbreak();
- (void)noecho();
-
-#ifdef PENGUIN
- (void)clear();
- (void)mvaddstr(4,29,"Welcome to Battleship!");
- (void)move(8,0);
- PR(" \\\n");
- PR(" \\ \\ \\\n");
- PR(" \\ \\ \\ \\ \\_____________\n");
- PR(" \\ \\ \\_____________ \\ \\/ |\n");
- PR(" \\ \\/ \\ \\/ |\n");
- PR(" \\/ \\_____/ |__\n");
- PR(" ________________/ |\n");
- PR(" \\ S.S. Penguin |\n");
- PR(" \\ /\n");
- PR(" \\___________________________________________________/\n");
-
- (void) mvaddstr(22,27,"Hit any key to continue..."); (void)refresh();
- (void) getch();
-#endif /* PENGUIN */
-
-#ifdef A_COLOR
- start_color();
-
- init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK);
- init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK);
- init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK);
- init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK);
- init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK);
- init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK);
- init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK);
- init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK);
-#endif /* A_COLOR */
-
-}
-
-/* VARARGS1 */
-static void prompt(n, f, s)
-/* print a message at the prompt line */
-int n;
-char *f, *s;
-{
- (void) move(PROMPTLINE + n, 0);
- (void) clrtoeol();
- (void) printw(f, s);
- (void) refresh();
-}
-
-static void error(s)
-char *s;
-{
- (void) move(PROMPTLINE + 2, 0);
- (void) clrtoeol();
- if (s)
- {
- (void) addstr(s);
- (void) beep();
- }
-}
-
-static void placeship(b, ss, vis)
-int b;
-ship_t *ss;
-int vis;
-{
- int l;
-
- for(l = 0; l < ss->length; ++l)
- {
- int newx = ss->x + l * xincr[ss->dir];
- int newy = ss->y + l * yincr[ss->dir];
-
- board[b][newx][newy] = ss->symbol;
- if (vis)
- {
- pgoto(newy, newx);
- (void) addch((chtype)ss->symbol);
- }
- }
- ss->hits = 0;
-}
-
-static int rnd(n)
-int n;
-{
- return(((rand() & 0x7FFF) % n));
-}
-
-static void randomplace(b, ss)
-/* generate a valid random ship placement into px,py */
-int b;
-ship_t *ss;
-{
- register int bwidth = BWIDTH - ss->length;
- register int bdepth = BDEPTH - ss->length;
-
- do {
- ss->y = rnd(bdepth);
- ss->x = rnd(bwidth);
- ss->dir = rnd(2) ? E : S;
- } while
- (!checkplace(b, ss, FALSE));
-}
-
-static void initgame()
-{
- int i, j, unplaced;
- ship_t *ss;
-
- (void) clear();
- (void) mvaddstr(0,35,"BATTLESHIPS");
- (void) move(PROMPTLINE + 2, 0);
- announceopts();
-
- bzero(board, sizeof(char) * BWIDTH * BDEPTH * 2);
- bzero(hits, sizeof(char) * BWIDTH * BDEPTH * 2);
- for (i = 0; i < SHIPTYPES; i++)
- {
- ss = cpuship + i;
- ss->x = ss->y = ss->dir = ss->hits = ss->placed = 0;
- ss = plyship + i;
- ss->x = ss->y = ss->dir = ss->hits = ss->placed = 0;
- }
-
- /* draw empty boards */
- (void) mvaddstr(PYBASE - 2, PXBASE + 5, "Main Board");
- (void) mvaddstr(PYBASE - 1, PXBASE - 3,numbers);
- for(i=0; i < BDEPTH; ++i)
- {
- (void) mvaddch(PYBASE + i, PXBASE - 3, i + 'A');
-#ifdef A_COLOR
- if (has_colors())
- attron(COLOR_PAIR(COLOR_BLUE));
-#endif /* A_COLOR */
- (void) addch(' ');
- for (j = 0; j < BWIDTH; j++)
- (void) addstr(" . ");
-#ifdef A_COLOR
- attrset(0);
-#endif /* A_COLOR */
- (void) addch(' ');
- (void) addch(i + 'A');
- }
- (void) mvaddstr(PYBASE + BDEPTH, PXBASE - 3,numbers);
- (void) mvaddstr(CYBASE - 2, CXBASE + 7,"Hit/Miss Board");
- (void) mvaddstr(CYBASE - 1, CXBASE - 3, numbers);
- for(i=0; i < BDEPTH; ++i)
- {
- (void) mvaddch(CYBASE + i, CXBASE - 3, i + 'A');
-#ifdef A_COLOR
- if (has_colors())
- attron(COLOR_PAIR(COLOR_BLUE));
-#endif /* A_COLOR */
- (void) addch(' ');
- for (j = 0; j < BWIDTH; j++)
- (void) addstr(" . ");
-#ifdef A_COLOR
- attrset(0);
-#endif /* A_COLOR */
- (void) addch(' ');
- (void) addch(i + 'A');
- }
-
- (void) mvaddstr(CYBASE + BDEPTH,CXBASE - 3,numbers);
-
- (void) mvprintw(HYBASE, HXBASE,
- "To position your ships: move the cursor to a spot, then");
- (void) mvprintw(HYBASE+1,HXBASE,
- "type the first letter of a ship type to select it, then");
- (void) mvprintw(HYBASE+2,HXBASE,
- "type a direction ([hjkl] or [4862]), indicating how the");
- (void) mvprintw(HYBASE+3,HXBASE,
- "ship should be pointed. You may also type a ship letter");
- (void) mvprintw(HYBASE+4,HXBASE,
- "followed by `r' to position it randomly, or type `R' to");
- (void) mvprintw(HYBASE+5,HXBASE,
- "place all remaining ships randomly.");
-
- (void) mvaddstr(MYBASE, MXBASE, "Aiming keys:");
- (void) mvaddstr(SYBASE, SXBASE, "y k u 7 8 9");
- (void) mvaddstr(SYBASE+1, SXBASE, " \\|/ \\|/ ");
- (void) mvaddstr(SYBASE+2, SXBASE, "h-+-l 4-+-6");
- (void) mvaddstr(SYBASE+3, SXBASE, " /|\\ /|\\ ");
- (void) mvaddstr(SYBASE+4, SXBASE, "b j n 1 2 3");
-
- /* have the computer place ships */
- for(ss = cpuship; ss < cpuship + SHIPTYPES; ss++)
- {
- randomplace(COMPUTER, ss);
- placeship(COMPUTER, ss, FALSE);
- }
-
- ss = (ship_t *)NULL;
- do {
- extern char *strchr();
- static char getcoord();
- char c, docked[SHIPTYPES + 2], *cp = docked;
-
- /* figure which ships still wait to be placed */
- *cp++ = 'R';
- for (i = 0; i < SHIPTYPES; i++)
- if (!plyship[i].placed)
- *cp++ = plyship[i].symbol;
- *cp = '\0';
-
- /* get a command letter */
- prompt(1, "Type one of [%s] to pick a ship.", docked+1);
- do {
- c = getcoord(PLAYER);
- } while
- (!strchr(docked, c));
-
- if (c == 'R')
- (void) ungetch('R');
- else
- {
- /* map that into the corresponding symbol */
- for (ss = plyship; ss < plyship + SHIPTYPES; ss++)
- if (ss->symbol == c)
- break;
-
- prompt(1, "Type one of [hjklrR] to place your %s.", ss->name);
- pgoto(cury, curx);
- }
-
- do {
- c = getch();
- } while
- (!strchr("hjklrR", c) || c == FF);
-
- if (c == FF)
- {
- (void)clearok(stdscr, TRUE);
- (void)refresh();
- }
- else if (c == 'r')
- {
- prompt(1, "Random-placing your %s", ss->name);
- randomplace(PLAYER, ss);
- placeship(PLAYER, ss, TRUE);
- error((char *)NULL);
- ss->placed = TRUE;
- }
- else if (c == 'R')
- {
- prompt(1, "Placing the rest of your fleet at random...");
- for (ss = plyship; ss < plyship + SHIPTYPES; ss++)
- if (!ss->placed)
- {
- randomplace(PLAYER, ss);
- placeship(PLAYER, ss, TRUE);
- ss->placed = TRUE;
- }
- error((char *)NULL);
- }
- else if (strchr("hjkl8462", c))
- {
- ss->x = curx;
- ss->y = cury;
-
- switch(c)
- {
- case 'k': case '8': ss->dir = N; break;
- case 'j': case '2': ss->dir = S; break;
- case 'h': case '4': ss->dir = W; break;
- case 'l': case '6': ss->dir = E; break;
- }
-
- if (checkplace(PLAYER, ss, TRUE))
- {
- placeship(PLAYER, ss, TRUE);
- error((char *)NULL);
- ss->placed = TRUE;
- }
- }
-
- for (unplaced = i = 0; i < SHIPTYPES; i++)
- unplaced += !plyship[i].placed;
- } while
- (unplaced);
-
- turn = rnd(2);
-
- (void) mvprintw(HYBASE, HXBASE,
- "To fire, move the cursor to your chosen aiming point ");
- (void) mvprintw(HYBASE+1, HXBASE,
- "and strike any key other than a motion key. ");
- (void) mvprintw(HYBASE+2, HXBASE,
- " ");
- (void) mvprintw(HYBASE+3, HXBASE,
- " ");
- (void) mvprintw(HYBASE+4, HXBASE,
- " ");
- (void) mvprintw(HYBASE+5, HXBASE,
- " ");
-
- (void) prompt(0, "Press any key to start...");
- (void) getch();
-}
-
-static int getcoord(atcpu)
-int atcpu;
-{
- int ny, nx, c;
-
- if (atcpu)
- cgoto(cury,curx);
- else
- pgoto(cury, curx);
- (void)refresh();
- for (;;)
- {
- if (atcpu)
- {
- (void) mvprintw(CYBASE + BDEPTH+1, CXBASE+11, "(%d, %c)", curx, 'A'+cury);
- cgoto(cury, curx);
- }
- else
- {
- (void) mvprintw(PYBASE + BDEPTH+1, PXBASE+11, "(%d, %c)", curx, 'A'+cury);
- pgoto(cury, curx);
- }
-
- switch(c = getch())
- {
- case 'k': case '8':
-#ifdef KEY_MIN
- case KEY_UP:
-#endif /* KEY_MIN */
- ny = cury+BDEPTH-1; nx = curx;
- break;
- case 'j': case '2':
-#ifdef KEY_MIN
- case KEY_DOWN:
-#endif /* KEY_MIN */
- ny = cury+1; nx = curx;
- break;
- case 'h': case '4':
-#ifdef KEY_MIN
- case KEY_LEFT:
-#endif /* KEY_MIN */
- ny = cury; nx = curx+BWIDTH-1;
- break;
- case 'l': case '6':
-#ifdef KEY_MIN
- case KEY_RIGHT:
-#endif /* KEY_MIN */
- ny = cury; nx = curx+1;
- break;
- case 'y': case '7':
-#ifdef KEY_MIN
- case KEY_A1:
-#endif /* KEY_MIN */
- ny = cury+BDEPTH-1; nx = curx+BWIDTH-1;
- break;
- case 'b': case '1':
-#ifdef KEY_MIN
- case KEY_C1:
-#endif /* KEY_MIN */
- ny = cury+1; nx = curx+BWIDTH-1;
- break;
- case 'u': case '9':
-#ifdef KEY_MIN
- case KEY_A3:
-#endif /* KEY_MIN */
- ny = cury+BDEPTH-1; nx = curx+1;
- break;
- case 'n': case '3':
-#ifdef KEY_MIN
- case KEY_C3:
-#endif /* KEY_MIN */
- ny = cury+1; nx = curx+1;
- break;
- case FF:
- nx = curx; ny = cury;
- (void)clearok(stdscr, TRUE);
- (void)refresh();
- break;
- default:
- if (atcpu)
- (void) mvaddstr(CYBASE + BDEPTH + 1, CXBASE + 11, " ");
- else
- (void) mvaddstr(PYBASE + BDEPTH + 1, PXBASE + 11, " ");
- return(c);
- }
-
- curx = nx % BWIDTH;
- cury = ny % BDEPTH;
- }
-}
-
-static int collidecheck(b, y, x)
-/* is this location on the selected zboard adjacent to a ship? */
-int b;
-int y, x;
-{
- int collide;
-
- /* anything on the square */
- if (collide = IS_SHIP(board[b][x][y]))
- return(collide);
-
- /* anything on the neighbors */
- if (!closepack)
- {
- int i;
-
- for (i = 0; i < 8; i++)
- {
- int xend, yend;
-
- yend = y + yincr[i];
- xend = x + xincr[i];
- if (ONBOARD(xend, yend))
- collide += IS_SHIP(board[b][xend][yend]);
- }
- }
- return(collide);
-}
-
-static bool checkplace(b, ss, vis)
-int b;
-ship_t *ss;
-int vis;
-{
- int l, xend, yend;
-
- /* first, check for board edges */
- xend = ss->x + ss->length * xincr[ss->dir];
- yend = ss->y + ss->length * yincr[ss->dir];
- if (!ONBOARD(xend, yend))
- {
- if (vis)
- switch(rnd(3))
- {
- case 0:
- error("Ship is hanging from the edge of the world");
- break;
- case 1:
- error("Try fitting it on the board");
- break;
- case 2:
- error("Figure I won't find it if you put it there?");
- break;
- }
- return(0);
- }
-
- for(l = 0; l < ss->length; ++l)
- {
- if(collidecheck(b, ss->y+l*yincr[ss->dir], ss->x+l*xincr[ss->dir]))
- {
- if (vis)
- switch(rnd(3))
- {
- case 0:
- error("There's already a ship there");
- break;
- case 1:
- error("Collision alert! Aaaaaagh!");
- break;
- case 2:
- error("Er, Admiral, what about the other ship?");
- break;
- }
- return(FALSE);
- }
- }
- return(TRUE);
-}
-
-static int awinna()
-{
- int i, j;
- ship_t *ss;
-
- for(i=0; i<2; ++i)
- {
- ss = (i) ? cpuship : plyship;
- for(j=0; j < SHIPTYPES; ++j, ++ss)
- if(ss->length > ss->hits)
- break;
- if (j == SHIPTYPES)
- return(OTHER);
- }
- return(-1);
-}
-
-static ship_t *hitship(x, y)
-/* register a hit on the targeted ship */
-int x, y;
-{
- ship_t *sb, *ss;
- char sym;
- int oldx, oldy;
-
- getyx(stdscr, oldy, oldx);
- sb = (turn) ? plyship : cpuship;
- if(!(sym = board[OTHER][x][y]))
- return((ship_t *)NULL);
- for(ss = sb; ss < sb + SHIPTYPES; ++ss)
- if(ss->symbol == sym)
- {
- if (++ss->hits < ss->length) /* still afloat? */
- return((ship_t *)NULL);
- else /* sunk! */
- {
- int i, j;
-
- if (!closepack)
- for (j = -1; j <= 1; j++)
- {
- int bx = ss->x + j * xincr[(ss->dir + 2) % 8];
- int by = ss->y + j * yincr[(ss->dir + 2) % 8];
-
- for (i = -1; i <= ss->length; ++i)
- {
- int x, y;
-
- x = bx + i * xincr[ss->dir];
- y = by + i * yincr[ss->dir];
- if (ONBOARD(x, y))
- {
- hits[turn][x][y] = MARK_MISS;
- if (turn % 2 == PLAYER)
- {
- cgoto(y, x);
-#ifdef A_COLOR
- if (has_colors())
- attron(COLOR_PAIR(COLOR_GREEN));
-#endif /* A_COLOR */
- (void)addch(MARK_MISS);
-#ifdef A_COLOR
- attrset(0);
-#endif /* A_COLOR */
- }
- }
- }
- }
-
- for (i = 0; i < ss->length; ++i)
- {
- int x = ss->x + i * xincr[ss->dir];
- int y = ss->y + i * yincr[ss->dir];
-
- hits[turn][x][y] = ss->symbol;
- if (turn % 2 == PLAYER)
- {
- cgoto(y, x);
- (void) addch(ss->symbol);
- }
- }
-
- (void) move(oldy, oldx);
- return(ss);
- }
- }
- (void) move(oldy, oldx);
- return((ship_t *)NULL);
-}
-
-static int plyturn()
-{
- ship_t *ss;
- bool hit;
- char *m;
-
- prompt(1, "Where do you want to shoot? ");
- for (;;)
- {
- (void) getcoord(COMPUTER);
- if (hits[PLAYER][curx][cury])
- {
- prompt(1, "You shelled this spot already! Try again.");
- beep();
- }
- else
- break;
- }
- hit = IS_SHIP(board[COMPUTER][curx][cury]);
- hits[PLAYER][curx][cury] = hit ? MARK_HIT : MARK_MISS;
- cgoto(cury, curx);
-#ifdef A_COLOR
- if (has_colors())
- if (hit)
- attron(COLOR_PAIR(COLOR_RED));
- else
- attron(COLOR_PAIR(COLOR_GREEN));
-#endif /* A_COLOR */
- (void) addch((chtype)hits[PLAYER][curx][cury]);
-#ifdef A_COLOR
- attrset(0);
-#endif /* A_COLOR */
-
- prompt(1, "You %s.", hit ? "scored a hit" : "missed");
- if(hit && (ss = hitship(curx, cury)))
- {
- switch(rnd(5))
- {
- case 0:
- m = " You sank my %s!";
- break;
- case 1:
- m = " I have this sinking feeling about my %s....";
- break;
- case 2:
- m = " My %s has gone to Davy Jones's locker!";
- break;
- case 3:
- m = " Glub, glub -- my %s is headed for the bottom!";
- break;
- case 4:
- m = " You'll pick up survivors from my my %s, I hope...!";
- break;
- }
- (void)printw(m, ss->name);
- (void)beep();
- return(awinna() == -1);
- }
- return(hit);
-}
-
-static int sgetc(s)
-char *s;
-{
- char *s1;
- int ch;
-
- (void)refresh();
- for(;;)
- {
- ch = getch();
- if (islower(ch))
- ch = toupper(ch);
- if (ch == CTRLC)
- uninitgame();
- for (s1=s; *s1 && ch != *s1; ++s1)
- continue;
- if (*s1)
- {
- (void) addch((chtype)ch);
- (void)refresh();
- return(ch);
- }
- }
-}
-
-
-static void randomfire(px, py)
-/* random-fire routine -- implements simple diagonal-striping strategy */
-int *px, *py;
-{
- static int turncount = 0;
- static int srchstep = BEGINSTEP;
- static int huntoffs; /* Offset on search strategy */
- int ypossible[BWIDTH * BDEPTH], xpossible[BWIDTH * BDEPTH], nposs;
- int ypreferred[BWIDTH * BDEPTH], xpreferred[BWIDTH * BDEPTH], npref;
- int x, y, i;
-
- if (turncount++ == 0)
- huntoffs = rnd(srchstep);
-
- /* first, list all possible moves */
- nposs = npref = 0;
- for (x = 0; x < BWIDTH; x++)
- for (y = 0; y < BDEPTH; y++)
- if (!hits[COMPUTER][x][y])
- {
- xpossible[nposs] = x;
- ypossible[nposs] = y;
- nposs++;
- if (((x+huntoffs) % srchstep) != (y % srchstep))
- {
- xpreferred[npref] = x;
- ypreferred[npref] = y;
- npref++;
- }
- }
-
- if (npref)
- {
- i = rnd(npref);
-
- *px = xpreferred[i];
- *py = ypreferred[i];
- }
- else if (nposs)
- {
- i = rnd(nposs);
-
- *px = xpossible[i];
- *py = ypossible[i];
-
- if (srchstep > 1)
- --srchstep;
- }
- else
- {
- error("No moves possible?? Help!");
- exit(1);
- /*NOTREACHED*/
- }
-}
-
-#define S_MISS 0
-#define S_HIT 1
-#define S_SUNK -1
-
-static bool cpufire(x, y)
-/* fire away at given location */
-int x, y;
-{
- bool hit, sunk;
- ship_t *ss;
-
- hits[COMPUTER][x][y] = (hit = (board[PLAYER][x][y])) ? MARK_HIT : MARK_MISS;
- (void) mvprintw(PROMPTLINE, 0,
- "I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : "miss");
- if (sunk = (hit && (ss = hitship(x, y))))
- (void) printw(" I've sunk your %s", ss->name);
- (void)clrtoeol();
-
- pgoto(y, x);
-#ifdef A_COLOR
- if (has_colors())
- if (hit)
- attron(COLOR_PAIR(COLOR_RED));
- else
- attron(COLOR_PAIR(COLOR_GREEN));
-#endif /* A_COLOR */
- (void)addch((chtype)(hit ? SHOWHIT : SHOWSPLASH));
-#ifdef A_COLOR
- attrset(0);
-#endif /* A_COLOR */
-
- return(hit ? (sunk ? S_SUNK : S_HIT) : S_MISS);
-}
-
-/*
- * This code implements a fairly irregular FSM, so please forgive the rampant
- * unstructuredness below. The five labels are states which need to be held
- * between computer turns.
- */
-static bool cputurn()
-{
-#define POSSIBLE(x, y) (ONBOARD(x, y) && !hits[COMPUTER][x][y])
-#define RANDOM_FIRE 0
-#define RANDOM_HIT 1
-#define HUNT_DIRECT 2
-#define FIRST_PASS 3
-#define REVERSE_JUMP 4
-#define SECOND_PASS 5
- static int next = RANDOM_FIRE;
- static bool used[4];
- static ship_t ts;
- int navail, x, y, d, n, hit = S_MISS;
-
- switch(next)
- {
- case RANDOM_FIRE: /* last shot was random and missed */
- refire:
- randomfire(&x, &y);
- if (!(hit = cpufire(x, y)))
- next = RANDOM_FIRE;
- else
- {
- ts.x = x; ts.y = y;
- ts.hits = 1;
- next = (hit == S_SUNK) ? RANDOM_FIRE : RANDOM_HIT;
- }
- break;
-
- case RANDOM_HIT: /* last shot was random and hit */
- used[E/2] = used[S/2] = used[W/2] = used[N/2] = FALSE;
- /* FALLTHROUGH */
-
- case HUNT_DIRECT: /* last shot hit, we're looking for ship's long axis */
- for (d = navail = 0; d < 4; d++)
- {
- x = ts.x + xincr[d*2]; y = ts.y + yincr[d*2];
- if (!used[d] && POSSIBLE(x, y))
- navail++;
- else
- used[d] = TRUE;
- }
- if (navail == 0) /* no valid places for shots adjacent... */
- goto refire; /* ...so we must random-fire */
- else
- {
- for (d = 0, n = rnd(navail) + 1; n; n--)
- while (used[d])
- d++;
-
- assert(d <= 4);
-
- used[d] = FALSE;
- x = ts.x + xincr[d*2];
- y = ts.y + yincr[d*2];
-
- assert(POSSIBLE(x, y));
-
- if (!(hit = cpufire(x, y)))
- next = HUNT_DIRECT;
- else
- {
- ts.x = x; ts.y = y; ts.dir = d*2; ts.hits++;
- next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS;
- }
- }
- break;
-
- case FIRST_PASS: /* we have a start and a direction now */
- x = ts.x + xincr[ts.dir];
- y = ts.y + yincr[ts.dir];
- if (POSSIBLE(x, y) && (hit = cpufire(x, y)))
- {
- ts.x = x; ts.y = y; ts.hits++;
- next = (hit == S_SUNK) ? RANDOM_FIRE : FIRST_PASS;
- }
- else
- next = REVERSE_JUMP;
- break;
-
- case REVERSE_JUMP: /* nail down the ship's other end */
- d = ts.dir + 4;
- x = ts.x + ts.hits * xincr[d];
- y = ts.y + ts.hits * yincr[d];
- if (POSSIBLE(x, y) && (hit = cpufire(x, y)))
- {
- ts.x = x; ts.y = y; ts.dir = d; ts.hits++;
- next = (hit == S_SUNK) ? RANDOM_FIRE : SECOND_PASS;
- }
- else
- next = RANDOM_FIRE;
- break;
-
- case SECOND_PASS: /* kill squares not caught on first pass */
- x = ts.x + xincr[ts.dir];
- y = ts.y + yincr[ts.dir];
- if (POSSIBLE(x, y) && (hit = cpufire(x, y)))
- {
- ts.x = x; ts.y = y; ts.hits++;
- next = (hit == S_SUNK) ? RANDOM_FIRE: SECOND_PASS;
- break;
- }
- else
- next = RANDOM_FIRE;
- break;
- }
-
- /* check for continuation and/or winner */
- if (salvo)
- {
- (void)refresh();
- (void)sleep(1);
- }
- if (awinna() != -1)
- return(FALSE);
-
-#ifdef DEBUG
- (void) mvprintw(PROMPTLINE + 2, 0,
- "New state %d, x=%d, y=%d, d=%d",
- next, x, y, d);
-#endif /* DEBUG */
- return(hit);
-}
-
-playagain()
-{
- int j;
- ship_t *ss;
-
- for (ss = cpuship; ss < cpuship + SHIPTYPES; ss++)
- for(j = 0; j < ss->length; j++)
- {
- cgoto(ss->y + j * yincr[ss->dir], ss->x + j * xincr[ss->dir]);
- (void)addch((chtype)ss->symbol);
- }
-
- if(awinna())
- ++cpuwon;
- else
- ++plywon;
- j = 18 + strlen(name);
- if(plywon >= 10)
- ++j;
- if(cpuwon >= 10)
- ++j;
- (void) mvprintw(1,(COLWIDTH-j)/2,
- "%s: %d Computer: %d",name,plywon,cpuwon);
-
- prompt(2, (awinna()) ? "Want to be humiliated again, %s [yn]? "
- : "Going to give me a chance for revenge, %s [yn]? ",name);
- return(sgetc("YN") == 'Y');
-}
-
-static void do_options(c,op)
-int c;
-char *op[];
-{
- register int i;
-
- if (c > 1)
- {
- for (i=1; i<c; i++)
- {
- switch(op[i][0])
- {
- default:
- case '?':
- (void) fprintf(stderr, "Usage: battle [-s | -b] [-c]\n");
- (void) fprintf(stderr, "\tWhere the options are:\n");
- (void) fprintf(stderr, "\t-s : play a salvo game\n");
- (void) fprintf(stderr, "\t-b : play a blitz game\n");
- (void) fprintf(stderr, "\t-c : ships may be adjacent\n");
- exit(1);
- break;
- case '-':
- switch(op[i][1])
- {
- case 'b':
- blitz = 1;
- if (salvo == 1)
- {
- (void) fprintf(stderr,
- "Bad Arg: -b and -s are mutually exclusive\n");
- exit(1);
- }
- break;
- case 's':
- salvo = 1;
- if (blitz == 1)
- {
- (void) fprintf(stderr,
- "Bad Arg: -s and -b are mutually exclusive\n");
- exit(1);
- }
- break;
- case 'c':
- closepack = 1;
- break;
- default:
- (void) fprintf(stderr,
- "Bad arg: type \"%s ?\" for usage message\n", op[0]);
- exit(1);
- }
- }
- }
- }
-}
-
-static int scount(who)
-int who;
-{
- register int i, shots;
- register ship_t *sp;
-
- if (who)
- sp = cpuship; /* count cpu shots */
- else
- sp = plyship; /* count player shots */
-
- for (i=0, shots = 0; i < SHIPTYPES; i++, sp++)
- {
- if (sp->hits >= sp->length)
- continue; /* dead ship */
- else
- shots++;
- }
- return(shots);
-}
-
-main(argc, argv)
-int argc;
-char *argv[];
-{
- do_options(argc, argv);
-
- intro();
- do {
- initgame();
- while(awinna() == -1)
- {
- if (!blitz)
- {
- if (!salvo)
- {
- if(turn)
- (void) cputurn();
- else
- (void) plyturn();
- }
- else
- {
- register int i;
-
- i = scount(turn);
- while (i--)
- {
- if (turn)
- {
- if (cputurn() && awinna() != -1)
- i = 0;
- }
- else
- {
- if (plyturn() && awinna() != -1)
- i = 0;
- }
- }
- }
- }
- else
- while(turn ? cputurn() : plyturn())
- continue;
- turn = OTHER;
- }
- } while
- (playagain());
- uninitgame();
- /*NOTREACHED*/
-}
-
-/* bs.c ends here */
diff --git a/lib/libncurses/TESTS/gdc.c b/lib/libncurses/TESTS/gdc.c
deleted file mode 100644
index 84bd651..0000000
--- a/lib/libncurses/TESTS/gdc.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * Grand digital clock for curses compatible terminals
- * Usage: gdc [-s] [n] -- run for n seconds (default infinity)
- * Flags: -s: scroll
- *
- * modified 10-18-89 for curses (jrl)
- * 10-18-89 added signal handling
- */
-
-#include <time.h>
-#include <signal.h>
-#include <ncurses.h>
-#include <stdlib.h>
-#ifndef NONPOSIX
-#include <unistd.h>
-#endif
-
-#define YBASE 10
-#define XBASE 10
-#define XLENGTH 54
-#define YDEPTH 5
-
-/* it won't be */
-long now; /* yeah! */
-struct tm *tm;
-
-short disp[11] = {
- 075557, 011111, 071747, 071717, 055711,
- 074717, 074757, 071111, 075757, 075717, 002020
-};
-long old[6], next[6], new[6], mask;
-char scrol;
-
-int sigtermed=0;
-
-int hascolor = 0;
-
-void set(int, int);
-void standt(int);
-void movto(int, int);
-
-void sighndl(signo)
-int signo;
-{
- signal(signo, sighndl);
- sigtermed=signo;
-}
-
-int
-main(argc, argv)
-int argc;
-char **argv;
-{
-long t, a;
-int i, j, s, k;
-int n = 0;
-
- signal(SIGINT,sighndl);
- signal(SIGTERM,sighndl);
- signal(SIGKILL,sighndl);
-
- initscr();
- cbreak();
- noecho();
-
- hascolor = has_colors();
-
- if(hascolor) {
- start_color();
- init_pair(1, COLOR_BLACK, COLOR_RED);
- init_pair(2, COLOR_RED, COLOR_BLACK);
- init_pair(3, COLOR_WHITE, COLOR_BLACK);
- attrset(COLOR_PAIR(2));
- }
-
- clear();
- refresh();
- while(--argc > 0) {
- if(**++argv == '-')
- scrol = 1;
- else
- n = atoi(*argv);
- }
-
- if(hascolor) {
- attrset(COLOR_PAIR(3));
-
- mvaddch(YBASE - 1, XBASE - 1, ACS_ULCORNER);
- hline(ACS_HLINE, XLENGTH);
- mvaddch(YBASE - 1, XBASE + XLENGTH, ACS_URCORNER);
-
- mvaddch(YBASE + YDEPTH, XBASE - 1, ACS_LLCORNER);
- hline(ACS_HLINE, XLENGTH);
- mvaddch(YBASE + YDEPTH, XBASE + XLENGTH, ACS_LRCORNER);
-
- move(YBASE, XBASE - 1);
- vline(ACS_VLINE, YDEPTH);
-
- move(YBASE, XBASE + XLENGTH);
- vline(ACS_VLINE, YDEPTH);
-
- attrset(COLOR_PAIR(2));
- }
- do {
- mask = 0;
- time(&now);
- tm = localtime(&now);
- set(tm->tm_sec%10, 0);
- set(tm->tm_sec/10, 4);
- set(tm->tm_min%10, 10);
- set(tm->tm_min/10, 14);
- set(tm->tm_hour%10, 20);
- set(tm->tm_hour/10, 24);
- set(10, 7);
- set(10, 17);
- for(k=0; k<6; k++) {
- if(scrol) {
- for(i=0; i<5; i++)
- new[i] = (new[i]&~mask) | (new[i+1]&mask);
- new[5] = (new[5]&~mask) | (next[k]&mask);
- } else
- new[k] = (new[k]&~mask) | (next[k]&mask);
- next[k] = 0;
- for(s=1; s>=0; s--) {
- standt(s);
- for(i=0; i<6; i++) {
- if((a = (new[i]^old[i])&(s ? new : old)[i]) != 0) {
- for(j=0,t=1<<26; t; t>>=1,j++) {
- if(a&t) {
- if(!(a&(t<<1))) {
- movto(YBASE + i, XBASE + 2*j);
- }
- addstr(" ");
- }
- }
- }
- if(!s) {
- old[i] = new[i];
- }
- }
- if(!s) {
- refresh();
- }
- }
- }
- movto(6, 0);
- refresh();
- sleep(1);
- if (sigtermed) {
- standend();
- clear();
- refresh();
- endwin();
- fprintf(stderr, "gdc terminated by signal %d\n", sigtermed);
- exit(1);
- }
- } while(--n);
- standend();
- clear();
- refresh();
- endwin();
- return(0);
-}
-
-void
-set(int t, int n)
-{
-int i, m;
-
- m = 7<<n;
- for(i=0; i<5; i++) {
- next[i] |= ((disp[t]>>(4-i)*3)&07)<<n;
- mask |= (next[i]^old[i])&m;
- }
- if(mask&m)
- mask |= m;
-}
-
-void
-standt(int on)
-{
- if (on) {
- if(hascolor) {
- attron(COLOR_PAIR(1));
- } else {
- attron(A_STANDOUT);
- }
- } else {
- if(hascolor) {
- attron(COLOR_PAIR(2));
- } else {
- attroff(A_STANDOUT);
- }
- }
-}
-
-void
-movto(int line, int col)
-{
- move(line, col);
-}
-
diff --git a/lib/libncurses/lib_deleteln.c b/lib/libncurses/lib_deleteln.c
deleted file mode 100644
index 054b99f..0000000
--- a/lib/libncurses/lib_deleteln.c
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
-* details. If they are missing then this copy is in violation of *
-* the copyright conditions. */
-
-/*
-** lib_deleteln.c
-**
-** The routine wdeleteln().
-**
-*/
-
-#include "curses.priv.h"
-#include <nterm.h>
-
-int wdeleteln(WINDOW *win)
-{
-chtype *end, *temp;
-int y, touched = 0;
-
- T(("wdeleteln(%x) called", win));
-
- temp = win->_line[win->_cury];
-
- if (win->_idlok && (delete_line != NULL)) {
- wrefresh(win);
- putp(delete_line);
- touched = 1;
- }
-
- for (y = win->_cury; y < win->_regbottom; y++) {
- win->_line[y] = win->_line[y+1];
-
- if (!touched) {
- win->_firstchar[y] = 0;
- win->_lastchar[y] = win->_maxx;
- }
- }
-
- win->_line[win->_regbottom] = temp;
- if (!touched) {
- win->_firstchar[win->_regbottom] = 0;
- win->_lastchar[win->_regbottom] = win->_maxx;
- }
-
- for (end = &(temp[win->_maxx]); temp <= end; )
- *temp++ = ' ';
- return OK;
-}
diff --git a/lib/libncurses/lib_insertln.c b/lib/libncurses/lib_insertln.c
deleted file mode 100644
index 4a39ce0..0000000
--- a/lib/libncurses/lib_insertln.c
+++ /dev/null
@@ -1,50 +0,0 @@
-
-/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
-* details. If they are missing then this copy is in violation of *
-* the copyright conditions. */
-
-/*
-** lib_insertln.c
-**
-** The routine winsertln().
-**
-*/
-
-#include "curses.priv.h"
-#include <nterm.h>
-
-int winsertln(WINDOW *win)
-{
-chtype *temp, *end;
-int y, touched = 0;
-
- T(("winsertln(%x) called", win));
-
- temp = win->_line[win->_regbottom];
-
- if (win->_idlok && (insert_line != NULL)) {
- wrefresh(win);
- putp(insert_line);
- touched = 1;
- }
-
- if (!touched) {
- win->_firstchar[win->_cury] = 0;
- win->_lastchar[win->_cury] = win->_maxx;
- }
-
- for (y = win->_regbottom; y > win->_cury; y--) {
- win->_line[y] = win->_line[y-1];
-
- if (!touched) {
- win->_firstchar[y] = 0;
- win->_lastchar[y] = win->_maxx;
- }
- }
-
- win->_line[win->_cury] = temp;
-
- for (end = &temp[win->_maxx]; temp <= end; temp++)
- *temp = ' ';
- return OK;
-}
diff --git a/lib/libncurses/ncurses.h b/lib/libncurses/ncurses.h
deleted file mode 100644
index d9f615a..0000000
--- a/lib/libncurses/ncurses.h
+++ /dev/null
@@ -1,497 +0,0 @@
-
-/* This work is copyrighted. See COPYRIGHT.OLD & COPYRIGHT.NEW for *
-* details. If they are missing then this copy is in violation of *
-* the copyright conditions. */
-
-#ifndef __NCURSES_H
-#define __NCURSES_H
-#define CURSES 1
-#define CURSES_H 1
-
-#include <stdio.h>
-#include <stdarg.h>
-#ifndef NOTERMIOS
-#include <termios.h>
-#else
-#include <sgtty.h>
-#include <sys/ioctl.h>
-#endif
-#include <unctrl.h>
-
-#define bool char
-
-typedef unsigned long chtype;
-
-/* attributes */
-#define A_ATTRIBUTES 0xffffff00
-#define A_NORMAL 0x00000000
-#define A_STANDOUT 0x00010000
-#define A_UNDERLINE 0x00020000
-#define A_REVERSE 0x00040000
-#define A_BLINK 0x00080000
-#define A_DIM 0x00100000
-#define A_BOLD 0x00200000
-#define A_ALTCHARSET 0x00400000
-#define A_INVIS 0x00800000
-#define A_PROTECT 0x01000000
-#define A_CHARTEXT 0x000000ff
-#define A_COLOR 0x0000ff00
-#define COLOR_PAIR(n) (n << 8)
-#define PAIR_NUMBER(a) ((a & A_COLOR) >> 8)
-
-/* colors */
-extern int COLORS;
-extern int COLOR_PAIRS;
-extern unsigned char color_pairs[];
-
-#define COLOR_BLACK 0
-#define COLOR_RED 1
-#define COLOR_GREEN 2
-#define COLOR_YELLOW 3
-#define COLOR_BLUE 4
-#define COLOR_MAGENTA 5
-#define COLOR_CYAN 6
-#define COLOR_WHITE 7
-
-/* line graphics */
-
-extern chtype acs_map[];
-
-
-#define ACS_ULCORNER (acs_map['l'])
-#define ACS_LLCORNER (acs_map['m'])
-#define ACS_URCORNER (acs_map['k'])
-#define ACS_LRCORNER (acs_map['j'])
-#define ACS_RTEE (acs_map['u'])
-#define ACS_LTEE (acs_map['t'])
-#define ACS_BTEE (acs_map['v'])
-#define ACS_TTEE (acs_map['w'])
-#define ACS_HLINE (acs_map['q'])
-#define ACS_VLINE (acs_map['x'])
-#define ACS_PLUS (acs_map['n'])
-#define ACS_S1 (acs_map['o']) /* scan line 1 */
-#define ACS_S9 (acs_map['s']) /* scan line 9 */
-#define ACS_DIAMOND (acs_map['`']) /* diamond */
-#define ACS_CKBOARD (acs_map['a']) /* checker board (stipple) */
-#define ACS_DEGREE (acs_map['f']) /* degree symbol */
-#define ACS_PLMINUS (acs_map['g']) /* plus/minus */
-#define ACS_BULLET (acs_map['~']) /* bullet */
-#define ACS_LARROW (acs_map[',']) /* arrow pointing left */
-#define ACS_RARROW (acs_map['+']) /* arrow pointing right */
-#define ACS_DARROW (acs_map['.']) /* arrow pointing down */
-#define ACS_UARROW (acs_map['-']) /* arrow pointing up */
-#define ACS_BOARD (acs_map['h']) /* board of squares */
-#define ACS_LANTERN (acs_map['I']) /* lantern symbol */
-#define ACS_BLOCK (acs_map['0']) /* solid square block */
-
-#ifndef TRUE
-# define TRUE (1)
-# define FALSE (0)
-#endif
-
-#define ERR (-1)
-#define OK (0)
-
-#define _SUBWIN 0x01
-#define _ENDLINE 0x02
-#define _FULLWIN 0x04
-#define _SCROLLWIN 0x08
-#define _ISPAD 0x10
-#define _HASMOVED 0x20
-
-#define _NOCHANGE -1
-
-typedef struct screen SCREEN;
-typedef struct _win_st WINDOW;
-
-struct _win_st {
- short _cury, _curx; /* current cursor position */
- short _maxy, _maxx; /* maximum values of x and y NOT the screen dimensions */
- short _begy, _begx;
- short _flags;
- chtype _attrs;
- chtype _bkgd;
-
- /* The following should be consolidated into one bitset */
- bool _notimeout;
- bool _use_idc;
- bool _clear;
- bool _leave;
- bool _scroll;
- bool _idlok;
- bool _immed;
- bool _sync;
- bool _use_keypad; /* 0=no, 1=yes */
- bool _use_meta; /* T=use the meta key */
-
- int _delay; /* 0 = nodelay
- <0 = blocking
- >0 = delay */
- chtype **_line;
- short *_firstchar; /* First changed character in the line */
- short *_lastchar; /* Last changed character in the line */
- short _regtop; /* Top and bottom of scrolling region */
- short _regbottom;
- int _parx;
- int _pary;
- WINDOW *_parent; /* parent if a sub-window */
-};
-
-extern WINDOW *stdscr, *curscr, *newscr;
-
-extern int LINES, COLS;
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char ttytype[]; /* needed for backward compatibility */
-
-extern int tigetflag(char *);
-extern int tigetnum(char *);
-extern char *tigetstr(char *);
-
-/* Debugging : use with libdcurses.a */
-
-extern void _init_trace(void);
-extern void _tracef(char *, ...);
-extern char *_traceattr(int mode);
-extern void traceon(void);
-extern void traceoff(void);
-
-/* function prototypes */
-
-extern int baudrate(void);
-extern int beep(void);
-extern int cbreak(void);
-extern int clearok(WINDOW *,int);
-extern int copywin(WINDOW *,WINDOW *,int,int,int,int,int,int,int);
-extern int crmode(void);
-extern int curs_set(int);
-extern int def_prog_mode(void);
-extern int def_shell_mode(void);
-extern int delwin(WINDOW *);
-extern WINDOW *derwin(WINDOW *,int,int,int,int);
-extern int doupdate(void);
-extern int echo(void);
-extern int endwin(void);
-extern char erasechar(void);
-extern int flash(void);
-extern int flushinp(void);
-extern int idlok(WINDOW *,int);
-extern int is_linetouched(WINDOW *,int);
-extern int is_wintouched(WINDOW *);
-extern WINDOW *initscr(void);
-extern int isendwin(void);
-extern char *keyname(int);
-extern int keypad(WINDOW *,int);
-extern char killchar(void);
-extern int leaveok(WINDOW *,int);
-extern char *longname(void);
-extern int meta(WINDOW *,int);
-extern int mvcur(int,int,int,int);
-extern int mvprintw(int,int,char *,...);
-extern int mvscanw(int,int,char *,...);
-extern int mvwin(WINDOW *,int,int);
-extern int mvwprintw(WINDOW *,int,int,char *,...);
-extern int mvwscanw(WINDOW *,int,int,char *,...);
-extern WINDOW *newpad(int,int);
-extern SCREEN *newterm(char *,FILE *,FILE *);
-extern WINDOW *newwin(int,int,int,int);
-extern int nl(void);
-extern int nocbreak(void);
-extern int nocrmode(void);
-extern int nodelay(WINDOW *,int);
-extern int noecho(void);
-extern int nonl(void);
-extern int noraw(void);
-extern int overlay(WINDOW *,WINDOW *);
-extern int overwrite(WINDOW *,WINDOW *);
-extern int pnoutrefresh(WINDOW *,int,int,int,int,int,int);
-extern int prefresh(WINDOW *,int,int,int,int,int,int);
-extern int printw(char *,...);
-extern int putp(char *);
-extern int raw(void);
-extern int reset_prog_mode(void);
-extern int reset_shell_mode(void);
-extern int resetty(void);
-extern int ripoffline(int line, int (*init)(WINDOW *, int));
-extern int savetty(void);
-extern int scanw(char *,...);
-extern int scrollok(WINDOW *,int);
-extern SCREEN *set_term(SCREEN *);
-extern int setupterm(char *,int,int *);
-extern WINDOW *subwin(WINDOW *,int,int,int,int);
-extern char *tgoto(char *,int,int);
-extern int timeout(int);
-extern char *tparm(char *, ...);
-extern int tputs(char *,int,int (*)(char));
-extern int ungetch(int);
-extern int vidattr(chtype);
-extern int vidputs(chtype,int (*)(char));
-extern int vwscanw(WINDOW *,char *,va_list);
-extern int vwprintw(WINDOW *,char *,va_list);
-extern int waddch(WINDOW *,chtype);
-extern int waddchnstr(WINDOW *,chtype *,int);
-extern int waddnstr(WINDOW *,char *,int);
-extern int wattron(WINDOW *,chtype);
-extern int wborder(WINDOW *,chtype,chtype,chtype,chtype,chtype,chtype,chtype,chtype);
-extern int wclear(WINDOW *);
-extern int wclrtobot(WINDOW *);
-extern int wclrtoeol(WINDOW *);
-extern int wdelch(WINDOW *);
-extern int werase(WINDOW *);
-extern int wgetch(WINDOW *);
-extern int wgetnstr(WINDOW *,char *,int maxlen);
-extern int whline(WINDOW *,chtype,int);
-extern int winsch(WINDOW *,chtype);
-extern int winsdel(WINDOW *,int);
-extern int winsnstr(WINDOW *,char *,int);
-extern int wmove(WINDOW *,int,int);
-extern int wnoutrefresh(WINDOW *);
-extern int wprintw(WINDOW *,char *,...);
-extern int redrawln(WINDOW *,int,int);
-extern int wrefresh(WINDOW *);
-extern int wscanw(WINDOW *,char *,...);
-extern int wscrl(WINDOW *,int);
-extern int wsetscrreg(WINDOW *,int,int);
-extern int wtimeout(WINDOW *,int);
-extern int wtouchln(WINDOW *,int,int,int);
-extern int wvline(WINDOW *,chtype,int);
-
-extern bool can_change_color(void);
-extern int color_content(short,short *,short *, short *);
-extern int has_colors(void);
-extern int init_color(short,short,short,short);
-extern int init_pair(short,short,short);
-extern int pair_content(short,short*,short*);
-extern int start_color(void);
-
-extern int slk_init(int);
-extern int slk_set(int,char *,int);
-extern int slk_refresh(void);
-extern int slk_noutrefresh(void);
-extern char *slk_label(int);
-extern int slk_clear(void);
-extern int slk_restore(void);
-extern int slk_touch(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*
- * pseudo functions
- */
-#define wgetstr(w, s) wgetnstr(w, s, -1)
-
-#define napms(x) usleep(1000*x)
-#define setterm(term) setupterm(term, 1, (int *)0)
-
-#define fixterm() reset_prog_mode()
-#define resetterm() reset_shell_mode()
-#define saveterm() def_prog_mode()
-#define crmode() cbreak()
-#define nocrmode() nocbreak()
-#define gettmode()
-
-#define getyx(win,y,x) (y = (win)->_cury, x = (win)->_curx)
-#define getbegyx(win,y,x) (y = (win)->_begy, x = (win)->_begx)
-#define getmaxyx(win,y,x) (y = (win)->_maxy + 1, x = (win)->_maxx + 1)
-#define getsyx(y,x) getyx(stdscr, y, x)
-#define setsyx(y,x) (stdscr->_cury = y, stdscr->_curx = x)
-
-/* It seems older SYSV curses define these */
-#define getattrs(win) (win->_attrs)
-#define getmaxx(win) ((win)->_maxx + 1)
-#define getmaxy(win) ((win)->_maxy + 1)
-
-#define winch(win) ((win)->_line[(win)->_cury][(win)->_curx])
-#define wstandout(win) (wattrset(win,A_STANDOUT))
-#define wstandend(win) (wattrset(win,A_NORMAL))
-#define wattroff(win,at) ((win)->_attrs &= ~(at))
-#define wattrset(win,at) ((win)->_attrs = (at))
-
-#define subpad(p,l,c,y,x) derwin(p,l,c,y,x)
-#define scroll(win) wscrl(win,1)
-
-#define touchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 1)
-#define touchline(win, s, c) wtouchln((win), s, c, 1)
-#define untouchwin(win) wtouchln((win), 0, (win)->_maxy + 1, 0)
-
-#define box(win, v, h) wborder(win, v, v, h, h, 0, 0, 0, 0)
-#define border(ls, rs, ts, bs, tl, tr, bl, br) wborder(stdscr, ls, rs, ts, bs, tl, tr, bl, br)
-#define hline(ch, n) whline(stdscr, ch, n)
-#define vline(ch, n) wvline(stdscr, ch, n)
-
-#define winsstr(w, s) winsnstr(w, s, 0)
-#define winsertln(w) winsdel(w, 1)
-#define wdeleteln(w) winsdel(w, -1)
-
-#define redrawwin(w) redrawln(w, 0, w->_maxy+1)
-
-/*
- * psuedo functions for standard screen
- */
-
-#define inch() winch(stdscr)
-#define standout() wstandout(stdscr)
-#define standend() wstandend(stdscr)
-#define attron(at) wattron(stdscr,at)
-#define attroff(at) wattroff(stdscr,at)
-#define attrset(at) wattrset(stdscr,at)
-#define addch(ch) waddch(stdscr,ch)
-#define getch() wgetch(stdscr)
-#define addstr(str) waddnstr(stdscr,str,-1)
-#define getstr(str) wgetstr(stdscr,str)
-#define move(y, x) wmove(stdscr,y,x)
-#define clear() wclear(stdscr)
-#define erase() werase(stdscr)
-#define clrtobot() wclrtobot(stdscr)
-#define clrtoeol() wclrtoeol(stdscr)
-#define insertln() winsertln(stdscr)
-#define deleteln() wdeleteln(stdscr)
-#define refresh() wrefresh(stdscr)
-#define insch(c) winsch(stdscr,c)
-#define delch() wdelch(stdscr)
-#define setscrreg(t,b) wsetscrreg(stdscr,t,b)
-#define scrl(n) wscrl(stdscr,n)
-#define timeout(delay) wtimeout(stdscr, delay)
-#define waddstr(win,str) waddnstr(win,str,-1)
-#define waddchstr(win,str) waddchnstr(win,str,-1)
-#define addchstr(str) waddchstr(stdscr, str)
-#define addchnstr(str, n) waddchnstr(stdscr, str, n)
-#define insdel(n) winsdel(stdscr, n)
-#define insstr(s) winsstr(stdscr, s)
-#define insnstr(s, n) winsnstr(stdscr, s, n)
-
-/*
- * mv functions
-*/
-
-#define mvwaddch(win,y,x,ch) (wmove(win,y,x) == ERR ? ERR : waddch(win,ch))
-#define mvwgetch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wgetch(win))
-#define mvwaddchnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,n))
-#define mvwaddchstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddchnstr(win,str,-1))
-#define mvwaddnstr(win,y,x,str,n) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,n))
-#define mvwaddstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : waddnstr(win,str,-1))
-#define mvwgetstr(win,y,x,str) (wmove(win,y,x) == ERR ? ERR : wgetstr(win,str))
-#define mvwinch(win,y,x) (wmove(win,y,x) == ERR ? ERR : winch(win))
-#define mvwdelch(win,y,x) (wmove(win,y,x) == ERR ? ERR : wdelch(win))
-#define mvwinsch(win,y,x,c) (wmove(win,y,x) == ERR ? ERR : winsch(win,c))
-#define mvaddch(y,x,ch) mvwaddch(stdscr,y,x,ch)
-#define mvgetch(y,x) mvwgetch(stdscr,y,x)
-#define mvaddnstr(y,x,str,n) mvwaddnstr(stdscr,y,x,str,n)
-#define mvaddstr(y,x,str) mvwaddstr(stdscr,y,x,str)
-#define mvgetstr(y,x,str) mvwgetstr(stdscr,y,x,str)
-#define mvinch(y,x) mvwinch(stdscr,y,x)
-#define mvdelch(y,x) mvwdelch(stdscr,y,x)
-#define mvinsch(y,x,c) mvwinsch(stdscr,y,x,c)
-#define mvwinsstr(w, y, x, s) (wmove(w,y,x) == ERR ? ERR : winsstr(w,s))
-#define mvwinsnstr(w, y, x, s, n) (wmove(w,y,x) == ERR ? ERR : winsnstr(w,s,n))
-#define mvinsstr(y,x,s) mvwinsstr(stdscr,y,x,s)
-#define mvinsnstr(y,x,s,n) mvwinsnstr(stdscr,y,x,s,n)
-
-/* Funny "characters" enabled for various special function keys for input */
-/* Whether such a key exists depend if its definition is in the terminfo entry */
-
-#define KEY_MIN 0401 /* Minimum curses key */
-#define KEY_BREAK 0401 /* break key (unreliable) */
-#define KEY_DOWN 0402 /* The four arrow keys ... */
-#define KEY_UP 0403
-#define KEY_LEFT 0404
-#define KEY_RIGHT 0405 /* ... */
-#define KEY_HOME 0406 /* Home key (upward+left arrow) */
-#define KEY_BACKSPACE 0407 /* backspace (unreliable) */
-#define KEY_F0 0410 /* Function keys. Space for 64 */
-#define KEY_F(n) (KEY_F0+(n)) /* keys is reserved. */
-#define KEY_DL 0510 /* Delete line */
-#define KEY_IL 0511 /* Insert line */
-#define KEY_DC 0512 /* Delete character */
-#define KEY_IC 0513 /* Insert char or enter insert mode */
-#define KEY_EIC 0514 /* Exit insert char mode */
-#define KEY_CLEAR 0515 /* Clear screen */
-#define KEY_EOS 0516 /* Clear to end of screen */
-#define KEY_EOL 0517 /* Clear to end of line */
-#define KEY_SF 0520 /* Scroll 1 line forward */
-#define KEY_SR 0521 /* Scroll 1 line backwards (reverse) */
-#define KEY_NPAGE 0522 /* Next page */
-#define KEY_PPAGE 0523 /* Previous page */
-#define KEY_STAB 0524 /* Set tab */
-#define KEY_CTAB 0525 /* Clear tab */
-#define KEY_CATAB 0526 /* Clear all tabs */
-#define KEY_ENTER 0527 /* Enter or send (unreliable) */
-#define KEY_SRESET 0530 /* soft (partial) reset (unreliable) */
-#define KEY_RESET 0531 /* reset or hard reset (unreliable) */
-#define KEY_PRINT 0532 /* print or copy */
-#define KEY_LL 0533 /* home down or bottom (lower left) */
-
-/* The keypad is arranged like this: */
-/* a1 up a3 */
-/* left b2 right */
-/* c1 down c3 */
-
-#define KEY_A1 0534 /* Upper left of keypad */
-#define KEY_A3 0535 /* Upper right of keypad */
-#define KEY_B2 0536 /* Center of keypad */
-#define KEY_C1 0537 /* Lower left of keypad */
-#define KEY_C3 0540 /* Lower right of keypad */
-#define KEY_BTAB 0541 /* Back tab key */
-#define KEY_BEG 0542 /* beg(inning) key */
-#define KEY_CANCEL 0543 /* cancel key */
-#define KEY_CLOSE 0544 /* close key */
-#define KEY_COMMAND 0545 /* cmd (command) key */
-#define KEY_COPY 0546 /* copy key */
-#define KEY_CREATE 0547 /* create key */
-#define KEY_END 0550 /* end key */
-#define KEY_EXIT 0551 /* exit key */
-#define KEY_FIND 0552 /* find key */
-#define KEY_HELP 0553 /* help key */
-#define KEY_MARK 0554 /* mark key */
-#define KEY_MESSAGE 0555 /* message key */
-#define KEY_MOVE 0556 /* move key */
-#define KEY_NEXT 0557 /* next object key */
-#define KEY_OPEN 0560 /* open key */
-#define KEY_OPTIONS 0561 /* options key */
-#define KEY_PREVIOUS 0562 /* previous object key */
-#define KEY_REDO 0563 /* redo key */
-#define KEY_REFERENCE 0564 /* ref(erence) key */
-#define KEY_REFRESH 0565 /* refresh key */
-#define KEY_REPLACE 0566 /* replace key */
-#define KEY_RESTART 0567 /* restart key */
-#define KEY_RESUME 0570 /* resume key */
-#define KEY_SAVE 0571 /* save key */
-#define KEY_SBEG 0572 /* shifted beginning key */
-#define KEY_SCANCEL 0573 /* shifted cancel key */
-#define KEY_SCOMMAND 0574 /* shifted command key */
-#define KEY_SCOPY 0575 /* shifted copy key */
-#define KEY_SCREATE 0576 /* shifted create key */
-#define KEY_SDC 0577 /* shifted delete char key */
-#define KEY_SDL 0600 /* shifted delete line key */
-#define KEY_SELECT 0601 /* select key */
-#define KEY_SEND 0602 /* shifted end key */
-#define KEY_SEOL 0603 /* shifted clear line key */
-#define KEY_SEXIT 0604 /* shifted exit key */
-#define KEY_SFIND 0605 /* shifted find key */
-#define KEY_SHELP 0606 /* shifted help key */
-#define KEY_SHOME 0607 /* shifted home key */
-#define KEY_SIC 0610 /* shifted input key */
-#define KEY_SLEFT 0611 /* shifted left arrow key */
-#define KEY_SMESSAGE 0612 /* shifted message key */
-#define KEY_SMOVE 0613 /* shifted move key */
-#define KEY_SNEXT 0614 /* shifted next key */
-#define KEY_SOPTIONS 0615 /* shifted options key */
-#define KEY_SPREVIOUS 0616 /* shifted prev key */
-#define KEY_SPRINT 0617 /* shifted print key */
-#define KEY_SREDO 0620 /* shifted redo key */
-#define KEY_SREPLACE 0621 /* shifted replace key */
-#define KEY_SRIGHT 0622 /* shifted right arrow */
-#define KEY_SRSUME 0623 /* shifted resume key */
-#define KEY_SSAVE 0624 /* shifted save key */
-#define KEY_SSUSPEND 0625 /* shifted suspend key */
-#define KEY_SUNDO 0626 /* shifted undo key */
-#define KEY_SUSPEND 0627 /* suspend key */
-#define KEY_UNDO 0630 /* undo key */
-#define KEY_MAX 0777 /* Maximum curses key */
-
-#endif
diff --git a/lib/libncurses/termcap.h b/lib/libncurses/termcap.h
deleted file mode 100644
index 68fa7e5..0000000
--- a/lib/libncurses/termcap.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef _TERMCAP_H
-#define _TERMCAP_H 1
-
-#ifdef __FreeBSD__
-#include <sys/cdefs.h>
-#else
-#ifndef __P
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos
-#else
-#define __P(protos) () /* traditional C preprocessor */
-#endif
-#endif
-#ifndef __BEGIN_DECLS
-#ifdef __cplusplus
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS };
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-#endif
-#endif
-
-__BEGIN_DECLS
-
-#ifndef __FreeBSD__
-#include <sys/types.h>
-#endif
-
-extern char PC;
-extern char *UP;
-extern char *BC;
-#ifdef __FreeBSD__
-extern short ospeed;
-#else
-extern speed_t ospeed;
-#endif
-
-extern int tgetent __P((char *, const char *));
-extern int tgetflag __P((const char *));
-extern int tgetnum __P((const char *));
-extern char *tgetstr __P((const char *, char **));
-
-extern int tputs __P((const char *, int, int (*)(int)));
-
-extern char *tgoto __P((const char *, int, int));
-extern char *tparam __P((const char *, char *, int, ...));
-
-__END_DECLS
-
-#endif /* _TERMCAP_H */
diff --git a/lib/librpc/Makefile.inc b/lib/librpc/Makefile.inc
deleted file mode 100644
index 15759b5..0000000
--- a/lib/librpc/Makefile.inc
+++ /dev/null
@@ -1,4 +0,0 @@
-#
-# Temporarily force creation of librpc.so.2.0.
-#
-.include "${.CURDIR}/../../Makefile.inc"
diff --git a/lib/librpc/rpc/Makefile b/lib/librpc/rpc/Makefile
deleted file mode 100644
index 55ee25a..0000000
--- a/lib/librpc/rpc/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-# @(#)Makefile 5.12 (Berkeley) 7/15/92
-
-LIB= rpc
-CFLAGS+=-I${.CURDIR}/..
-SRCS= auth_none.c auth_unix.c authunix_prot.c bindresvport.c \
- clnt_generic.c clnt_perror.c clnt_raw.c clnt_simple.c clnt_tcp.c \
- clnt_udp.c rpc_dtablesize.c get_myaddress.c getrpcent.c getrpcport.c \
- pmap_clnt.c pmap_getmaps.c pmap_getport.c pmap_prot.c \
- pmap_prot2.c pmap_rmt.c rpc_prot.c rpc_commondata.c rpc_callmsg.c \
- svc.c svc_auth.c svc_auth_unix.c svc_raw.c svc_run.c svc_simple.c \
- svc_tcp.c svc_udp.c xdr.c xdr_array.c xdr_mem.c \
- xdr_rec.c xdr_reference.c xdr_stdio.c
-
-UNSUPPORTED= xdr_float.c
-
-all: librpc.a
-
-.include <bsd.lib.mk>
diff --git a/lib/libskey/authfile.c b/lib/libskey/authfile.c
deleted file mode 100644
index ae7b0ac..0000000
--- a/lib/libskey/authfile.c
+++ /dev/null
@@ -1,177 +0,0 @@
- /* Portions taken from the skey distribution on Oct 21 1993 */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-#include <pwd.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <skey.h>
-
-#if (MAXHOSTNAMELEN < 64) /* AIX weirdness */
-#undef MAXHOSTNAMELEN
-#endif
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 255
-#endif
-
-#include "pathnames.h"
-
-static int isaddr();
-static int rdnets();
-
-#define MAXADDR 16 /* how many addresses can a machine
- * have? */
-
- /*
- * Turn host into an IP address and then look it up in the authorization
- * database to determine if ordinary password logins are OK
- */
-int authfile(host)
-char *host;
-{
- char *addr[MAXADDR];
- char **ap;
- long n;
- struct hostent *hp;
- char **lp;
- struct hostent *xp;
- int addr_length;
-
- if (strlen(host) == 0) {
- /* Local login, okay */
- return 1;
- }
- if (isaddr(host)) {
- return rdnets(inet_addr(host));
- } else {
-
- /*
- * Stash away a copy of the host address list because it will be
- * clobbered by other gethostbyXXX() calls.
- */
-
- hp = gethostbyname(host);
- if (hp == NULL) {
- syslog(LOG_ERR, "unknown host: %s", host);
- return 0;
- }
- if (hp->h_addrtype != AF_INET) {
- syslog(LOG_ERR, "unknown network family: %d", hp->h_addrtype);
- return 0;
- }
- for (lp = hp->h_addr_list, ap = addr; ap < addr + MAXADDR; lp++, ap++) {
- if (*lp == NULL) {
- *ap = 0;
- break;
- } else {
- if ((*ap = malloc(hp->h_length)) == 0) {
- syslog(LOG_ERR, "out of memory");
- return 0;
- }
- memcpy(*ap, *lp, hp->h_length);
- }
- }
- addr_length = hp->h_length;
-
- /*
- * See if any of the addresses matches a pattern in the control file.
- * Report and skip the address if it does not belong to the remote
- * host. Assume localhost == localhost.domain.
- */
-
-#define NEQ(x,y) (strcasecmp((x),(y)) != 0)
-
- while (ap-- > addr) {
- memcpy((char *) &n, *ap, addr_length);
- if (rdnets(n)) {
- if ((hp = gethostbyaddr(*ap, addr_length, AF_INET)) == 0
- || (NEQ(host, hp->h_name) && NEQ(host, "localhost"))) {
- syslog(LOG_ERR, "IP address %s not registered for host %s",
- inet_ntoa(*(struct in_addr *) * ap), host);
- continue;
- }
- return 1;
- }
- }
- return 0;
- }
-}
-static int rdnets(host)
-unsigned long host;
-{
- FILE *fp;
- char buf[128],
- *cp;
- long pattern,
- mask;
- char *strtok();
- int permit_it = 0;
-
- /*
- * If auth file not found, be backwards compatible with standard login
- * and allow hard coded passwords in from anywhere. Some may consider
- * this a security hole, but backwards compatibility is more desirable
- * than others. If you don't like it, change the return value to be zero.
- */
- if ((fp = fopen(_PATH_SKEYACCESS, "r")) == NULL)
- return 1;
-
- while (fgets(buf, sizeof(buf), fp), !feof(fp)) {
- if (buf[0] == '#')
- continue; /* Comment */
- cp = strtok(buf, " \t");
- if (cp == NULL)
- continue;
- /* two choices permit or deny */
- if (strncasecmp(cp, "permit", 4) == 0) {
- permit_it = 1;
- } else {
- if (strncasecmp(cp, "deny", 4) == 0) {
- permit_it = 0;
- } else {
- continue; /* ignore this it is not
- * permit/deny */
- }
- }
- cp = strtok(NULL, " \t");
- if (cp == NULL)
- continue; /* Invalid line */
- pattern = inet_addr(cp);
- cp = strtok(NULL, " \t");
- if (cp == NULL)
- continue; /* Invalid line */
- mask = inet_addr(cp);
- if ((host & mask) == pattern) {
- fclose(fp);
- return permit_it;
- }
- }
- fclose(fp);
- return 0;
-}
-
- /*
- * Return TRUE if string appears to be an IP address in dotted decimal;
- * return FALSE otherwise (i.e., if string is a domain name)
- */
-static int isaddr(s)
-register char *s;
-{
- char c;
-
- if (s == NULL)
- return 1; /* Can't happen */
-
- while ((c = *s++) != '\0') {
- if (c != '[' && c != ']' && !isdigit(c) && c != '.')
- return 0;
- }
- return 1;
-}
diff --git a/lib/libskey/md4.c b/lib/libskey/md4.c
deleted file mode 100644
index 495f444..0000000
--- a/lib/libskey/md4.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/*
- * md4.c -- Implementation of MD4 Message Digest Algorithm
- * Updated: 2/16/90 by Ronald L. Rivest
- *
- * Portability nits fixed and reformatted - 2/12/91 Phil Karn
- *
- * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
- * rights reserved.
- *
- * License to copy and use this software is granted provided that it
- * is identified as the "RSA Data Security, Inc. MD5 Message-Digest
- * Algorithm" in all material mentioning or referencing this software
- * or this function.
- *
- * License is also granted to make and use derivative works provided
- * that such works are identified as "derived from the RSA Data
- * Security, Inc. MD5 Message-Digest Algorithm" in all material
- * mentioning or referencing the derived work.
- *
- * RSA Data Security, Inc. makes no representations concerning either
- * the merchantability of this software or the suitability of this
- * software for any particular purpose. It is provided "as is"
- * without express or implied warranty of any kind.
- *
- * These notices must be retained in any copies of any part of this
- * documentation and/or software.
- */
-
-/*
- * To use MD4:
- * -- Include md4.h in your program
- * -- Declare an MDstruct MD to hold the state of the digest computation.
- * -- Initialize MD using MDbegin(&MD)
- * -- For each full block (64 bytes) X you wish to process, call
- * MDupdate(&MD,X,512)
- * (512 is the number of bits in a full block.)
- * -- For the last block (less than 64 bytes) you wish to process,
- * MDupdate(&MD,X,n)
- * where n is the number of bits in the partial block. A partial
- * block terminates the computation, so every MD computation should
- * terminate by processing a partial block, even if it has n = 0.
- * -- The message digest is available in MD.buffer[0] ... MD.buffer[3].
- * (Least-significant byte of each word should be output first.)
- * -- You can print out the digest using MDprint(&MD)
- */
-
-/* Implementation notes:
- * This implementation assumes that longs are 32-bit quantities.
- * If the machine stores the least-significant byte of an long in the
- * least-addressed byte (eg., VAX and 8086), then LOWBYTEFIRST should be
- * set to TRUE. Otherwise (eg., SUNS), LOWBYTEFIRST should be set to
- * FALSE. Note that on machines with LOWBYTEFIRST FALSE the routine
- * MDupdate modifies has a side-effect on its input array (the order of bytes
- * in each word are reversed). If this is undesired a call to MDreverse(X) can
- * reverse the bytes of X back into order after each call to MDupdate.
- */
-#define TRUE 1
-#define FALSE 0
-
-#if (defined(__MSDOS__) || defined(MPU8086) || defined(MPU8080) \
- || defined(vax) || defined (MIPSEL))
-#define LOWBYTEFIRST TRUE /* Low order bytes are first in memory */
-#else /* Almost all other machines are big-endian */
-#define LOWBYTEFIRST FALSE
-#endif
-
-
-/* Compile-time includes */
-#include <stdio.h>
-#include "md4.h"
-
-/* Compile-time declarations of MD4 ``magic constants'' */
-#define I0 0x67452301 /* Initial values for MD buffer */
-#define I1 0xefcdab89
-#define I2 0x98badcfe
-#define I3 0x10325476
-#define C2 013240474631 /* round 2 constant = sqrt(2) in octal */
-#define C3 015666365641 /* round 3 constant = sqrt(3) in octal */
-/* C2 and C3 are from Knuth, The Art of Programming, Volume 2
- * (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
- * Table 2, page 660.
- */
-#define fs1 3 /* round 1 shift amounts */
-#define fs2 7
-#define fs3 11
-#define fs4 19
-#define gs1 3 /* round 2 shift amounts */
-#define gs2 5
-#define gs3 9
-#define gs4 13
-#define hs1 3 /* round 3 shift amounts */
-#define hs2 9
-#define hs3 11
-#define hs4 15
-
-
-/* Compile-time macro declarations for MD4.
- * Note: The ``rot'' operator uses the variable ``tmp''.
- * It assumes tmp is declared as unsigned long, so that the >>
- * operator will shift in zeros rather than extending the sign bit.
- */
-#define f(X,Y,Z) ((X&Y) | ((~X)&Z))
-#define g(X,Y,Z) ((X&Y) | (X&Z) | (Y&Z))
-#define h(X,Y,Z) (X^Y^Z)
-#define rot(X,S) (tmp=X,(tmp<<S) | (tmp>>(32-S)))
-#define ff(A,B,C,D,i,s) A = rot((A + f(B,C,D) + X[i]),s)
-#define gg(A,B,C,D,i,s) A = rot((A + g(B,C,D) + X[i] + C2),s)
-#define hh(A,B,C,D,i,s) A = rot((A + h(B,C,D) + X[i] + C3),s)
-
-void MDreverse __P((unsigned long *X));
-
-/* MDprint(MDp)
- * Print message digest buffer MDp as 32 hexadecimal digits.
- * Order is from low-order byte of buffer[0] to high-order byte of buffer[3].
- * Each byte is printed with high-order hexadecimal digit first.
- * This is a user-callable routine.
- */
-void
-MDprint(MDp)
-MDptr MDp;
-{
- int i,j;
-
- for(i=0;i<4;i++)
- for(j=0;j<32;j=j+8)
- printf("%02lx",(MDp->buffer[i]>>j) & 0xFF);
-}
-
-/* MDbegin(MDp)
- * Initialize message digest buffer MDp.
- * This is a user-callable routine.
- */
-void
-MDbegin(MDp)
-MDptr MDp;
-{
- int i;
-
- MDp->buffer[0] = I0;
- MDp->buffer[1] = I1;
- MDp->buffer[2] = I2;
- MDp->buffer[3] = I3;
- for(i=0;i<8;i++)
- MDp->count[i] = 0;
- MDp->done = 0;
-}
-
-/* MDreverse(X)
- * Reverse the byte-ordering of every long in X.
- * Assumes X is an array of 16 longs.
- * The macro revx reverses the byte-ordering of the next word of X.
- */
-#define revx { t = (*X << 16) | (*X >> 16); \
- *X++ = ((t & 0xFF00FF00) >> 8) | ((t & 0x00FF00FF) << 8); }
-void
-MDreverse(X)
-unsigned long *X;
-{
- register unsigned long t;
-
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
- revx;
-}
-
-/* MDblock(MDp,X)
- * Update message digest buffer MDp->buffer using 16-word data block X.
- * Assumes all 16 words of X are full of data.
- * Does not update MDp->count.
- * This routine is not user-callable.
- */
-static void
-MDblock(MDp,X)
-MDptr MDp;
-unsigned long *X;
-{
- register unsigned long tmp, A, B, C, D;
-
-#if LOWBYTEFIRST == FALSE
- MDreverse(X);
-#endif
- A = MDp->buffer[0];
- B = MDp->buffer[1];
- C = MDp->buffer[2];
- D = MDp->buffer[3];
- /* Update the message digest buffer */
- ff(A,B,C,D,0,fs1); /* Round 1 */
- ff(D,A,B,C,1,fs2);
- ff(C,D,A,B,2,fs3);
- ff(B,C,D,A,3,fs4);
- ff(A,B,C,D,4,fs1);
- ff(D,A,B,C,5,fs2);
- ff(C,D,A,B,6,fs3);
- ff(B,C,D,A,7,fs4);
- ff(A,B,C,D,8,fs1);
- ff(D,A,B,C,9,fs2);
- ff(C,D,A,B,10,fs3);
- ff(B,C,D,A,11,fs4);
- ff(A,B,C,D,12,fs1);
- ff(D,A,B,C,13,fs2);
- ff(C,D,A,B,14,fs3);
- ff(B,C,D,A,15,fs4);
- gg(A,B,C,D,0,gs1); /* Round 2 */
- gg(D,A,B,C,4,gs2);
- gg(C,D,A,B,8,gs3);
- gg(B,C,D,A,12,gs4);
- gg(A,B,C,D,1,gs1);
- gg(D,A,B,C,5,gs2);
- gg(C,D,A,B,9,gs3);
- gg(B,C,D,A,13,gs4);
- gg(A,B,C,D,2,gs1);
- gg(D,A,B,C,6,gs2);
- gg(C,D,A,B,10,gs3);
- gg(B,C,D,A,14,gs4);
- gg(A,B,C,D,3,gs1);
- gg(D,A,B,C,7,gs2);
- gg(C,D,A,B,11,gs3);
- gg(B,C,D,A,15,gs4);
- hh(A,B,C,D,0,hs1); /* Round 3 */
- hh(D,A,B,C,8,hs2);
- hh(C,D,A,B,4,hs3);
- hh(B,C,D,A,12,hs4);
- hh(A,B,C,D,2,hs1);
- hh(D,A,B,C,10,hs2);
- hh(C,D,A,B,6,hs3);
- hh(B,C,D,A,14,hs4);
- hh(A,B,C,D,1,hs1);
- hh(D,A,B,C,9,hs2);
- hh(C,D,A,B,5,hs3);
- hh(B,C,D,A,13,hs4);
- hh(A,B,C,D,3,hs1);
- hh(D,A,B,C,11,hs2);
- hh(C,D,A,B,7,hs3);
- hh(B,C,D,A,15,hs4);
- MDp->buffer[0] += A;
- MDp->buffer[1] += B;
- MDp->buffer[2] += C;
- MDp->buffer[3] += D;
-}
-
-/* MDupdate(MDp,X,count)
- * Input: MDp -- an MDptr
- * X -- a pointer to an array of unsigned characters.
- * count -- the number of bits of X to use.
- * (if not a multiple of 8, uses high bits of last byte.)
- * Update MDp using the number of bits of X given by count.
- * This is the basic input routine for an MD4 user.
- * The routine completes the MD computation when count < 512, so
- * every MD computation should end with one call to MDupdate with a
- * count less than 512. A call with count 0 will be ignored if the
- * MD has already been terminated (done != 0), so an extra call with count
- * 0 can be given as a ``courtesy close'' to force termination if desired.
- */
-void
-MDupdate(MDp,X,count)
-MDptr MDp;
-unsigned char *X;
-unsigned int count;
-{
- int i,bit,byte,mask;
- unsigned long tmp;
- unsigned char XX[64];
- unsigned char *p;
-
- /* return with no error if this is a courtesy close with count
- * zero and MDp->done is true.
- */
- if(count == 0 && MDp->done)
- return;
- /* check to see if MD is already done and report error */
- if(MDp->done){
- printf("\nError: MDupdate MD already done.");
- return;
- }
- /* Add count to MDp->count */
- tmp = count;
- p = MDp->count;
- while(tmp){
- tmp += *p;
- *p++ = tmp;
- tmp = tmp >> 8;
- }
- /* Process data */
- if(count == 512){
- /* Full block of data to handle */
- MDblock(MDp,(unsigned long *)X);
- } else if(count > 512){
- /* Check for count too large */
- printf("\nError: MDupdate called with illegal count value %ld.",count);
- return;
- } else {
- /* partial block -- must be last block so finish up
- * Find out how many bytes and residual bits there are
- */
- byte = count >> 3;
- bit = count & 7;
- /* Copy X into XX since we need to modify it */
- for(i=0;i<=byte;i++)
- XX[i] = X[i];
- for(i=byte+1;i<64;i++)
- XX[i] = 0;
- /* Add padding '1' bit and low-order zeros in last byte */
- mask = 1 << (7 - bit);
- XX[byte] = (XX[byte] | mask) & ~( mask - 1);
- /* If room for bit count, finish up with this block */
- if(byte <= 55){
- for(i=0;i<8;i++)
- XX[56+i] = MDp->count[i];
- MDblock(MDp,(unsigned long *)XX);
- } else {
- /* need to do two blocks to finish up */
- MDblock(MDp,(unsigned long *)XX);
- for(i=0;i<56;i++)
- XX[i] = 0;
- for(i=0;i<8;i++)
- XX[56+i] = MDp->count[i];
- MDblock(MDp,(unsigned long *)XX);
- }
- /* Set flag saying we're done with MD computation */
- MDp->done = 1;
- }
-}
-/* End of md4.c */
diff --git a/lib/libskey/md4.h b/lib/libskey/md4.h
deleted file mode 100644
index c0d3419..0000000
--- a/lib/libskey/md4.h
+++ /dev/null
@@ -1,47 +0,0 @@
-
-#include <sys/cdefs.h>
-
-/*
- *
- * md4.h -- Header file for implementation of MD4 Message Digest Algorithm
- * Updated: 2/13/90 by Ronald L. Rivest
- * (C) 1990 RSA Data Security, Inc.
- * Reformatted and de-linted - 2/12/91 Phil Karn
- */
-
-/* MDstruct is the data structure for a message digest computation. */
-typedef struct {
- unsigned long buffer[4];/* Holds 4-word result of MD computation */
- unsigned char count[8]; /* Number of bits processed so far */
- unsigned int done; /* Nonzero means MD computation finished */
-} MDstruct, *MDptr;
-
-/* MDbegin(MD)
- * Input: MD -- an MDptr
- * Initialize the MDstruct prepatory to doing a message digest computation.
- */
-extern void MDbegin __P((MDptr MDp));
-
-/* MDupdate(MD,X,count)
- * Input: MD -- an MDptr
- * X -- a pointer to an array of unsigned characters.
- * count -- the number of bits of X to use (an unsigned int).
- * Updates MD using the first ``count'' bits of X.
- * The array pointed to by X is not modified.
- * If count is not a multiple of 8, MDupdate uses high bits of last byte.
- * This is the basic input routine for a user.
- * The routine terminates the MD computation when count < 512, so
- * every MD computation should end with one call to MDupdate with a
- * count less than 512. Zero is OK for a count.
- */
-extern void MDupdate __P((MDptr MDp,unsigned char *X,unsigned int count));
-
-/* MDprint(MD)
- * Input: MD -- an MDptr
- * Prints message digest buffer MD as 32 hexadecimal digits.
- * Order is from low-order byte of buffer[0] to high-order byte of buffer[3].
- * Each byte is printed with high-order hexadecimal digit first.
- */
-extern void MDprint __P((MDptr MDp));
-
-/* End of md4.h */
diff --git a/lib/libterm/Makefile b/lib/libterm/Makefile
deleted file mode 100644
index 319899f..0000000
--- a/lib/libterm/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-# @(#)Makefile 8.1 (Berkeley) 6/4/93
-
-LIB= termcap
-CFLAGS+=-DCM_N -DCM_GT -DCM_B -DCM_D
-SRCS= termcap.c tgoto.c tputs.c
-
-MAN3= termcap.3
-MLINKS= termcap.3 tgetent.3 termcap.3 tgetflag.3 termcap.3 tgetnum.3 \
- termcap.3 tgetstr.3 termcap.3 tgoto.3 termcap.3 tputs.3
-LINKS= ${LIBDIR}/libtermcap.a ${LIBDIR}/libtermlib.a
-.if !defined(NOPROFILE)
-LINKS+= ${LIBDIR}/libtermcap_p.a ${LIBDIR}/libtermlib_p.a
-.endif
-
-.include <bsd.lib.mk>
diff --git a/lib/rpcsvc/Makefile b/lib/rpcsvc/Makefile
deleted file mode 100644
index 291b091..0000000
--- a/lib/rpcsvc/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-# from: @(#)Makefile 5.10 (Berkeley) 6/24/90
-# $Id: Makefile,v 1.6 1994/02/07 09:07:48 rgrimes Exp $
-
-.PATH: ${DESTDIR}/usr/include/rpcsvc
-
-LIB= rpcsvc
-
-RPCSRCS= klm_prot.x mount.x nfs_prot.x nlm_prot.x rex.x rnusers.x \
- rquota.x rstat.x rwall.x sm_inter.x spray.x yppasswd.x
-
-RPCCOM = rpcgen
-
-INCDIRS= -I/usr/include/rpcsvc
-CFLAGS+= ${INCDIRS}
-
-SRCS= ${RPCSRCS:R:S/$/_xdr.c/g}
-
-CLEANFILES+= ${SRCS} ${RPCSRCS}
-
-NOMAN= noman
-
-.include <bsd.lib.mk>
-
-.SUFFIXES: .x _xdr.c
-
-.x_xdr.c:
- @echo generating $@...
- @PWD=`pwd` ; cd ${.CURDIR} ; if cmp -s ${.IMPSRC} ${*F}.x > /dev/null; then :; else cp -f ${.IMPSRC} $$PWD/${*F}.x ; fi
- @${RPCCOM} -c ${*F}.x -o ${.TARGET}
-
-OBJS+= ${RPCSRCS:R:S/$/_xdr.o/g}
OpenPOWER on IntegriCloud