Vendor import of tnftp-20100108.
This commit is contained in:
parent
04a7382c46
commit
1d78dcfdf2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/tnftp/dist/; revision=223304 svn path=/vendor/tnftp/20100108/; revision=223305; tag=vendor/tnftp/20100108
40
COPYING
40
COPYING
@ -1,4 +1,10 @@
|
||||
Copyright 1999, 2000 Luke Mewburn <lukem@netbsd.org>. All rights reserved.
|
||||
$NetBSD: COPYING,v 1.7 2010/01/12 07:01:01 lukem Exp $
|
||||
|
||||
Copyright (c) 2001-2010 The NetBSD Foundation, Inc.
|
||||
All rights reserved.
|
||||
|
||||
This code is derived from software contributed to The NetBSD Foundation
|
||||
by Simon Burge, Luke Mewburn, and Christos Zoulas.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
@ -10,20 +16,24 @@ are met:
|
||||
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 Luke Mewburn.
|
||||
4. The name of the author may not be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
This product includes software developed by the NetBSD
|
||||
Foundation, Inc. and its contributors.
|
||||
4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
This product also contains software developed by other people, and you
|
||||
are advised to read the various source files to read the full details
|
||||
@ -32,11 +42,13 @@ acknowledgements:
|
||||
|
||||
This product includes software developed by the NetBSD Foundation,
|
||||
Inc. and its contributors. Those contributors include:
|
||||
- Simon Burge
|
||||
- Jaromir Dolecek
|
||||
- Klaus Klein
|
||||
- Luke Mewburn
|
||||
- Jason R. Thorpe of the Numerical Aerospace Simulation
|
||||
Facility, NASA Ames Research Center.
|
||||
- Christos Zoulas
|
||||
|
||||
This product includes software developed by the University of
|
||||
California, Berkeley and its contributors. Those contributors include:
|
||||
|
728
ChangeLog
728
ChangeLog
@ -1,3 +1,713 @@
|
||||
$NetBSD: ChangeLog,v 1.58 2010/01/12 06:58:57 lukem Exp $
|
||||
|
||||
Tue Jan 12 06:58:15 UTC 2010 lukem
|
||||
|
||||
* Release as "tnftp 20100108"
|
||||
|
||||
* Rename onoff() argument "bool" to "val".
|
||||
|
||||
Tue Jan 5 09:12:01 UTC 2010 lukem
|
||||
|
||||
* If ARG_MAX isn't defined, use the result from sysconf(_SC_ARG_MAX).
|
||||
Fixes build when using newer glibc.
|
||||
|
||||
* Add libnetbsd.la to the LIBADD for libedit.
|
||||
Fix provided by Adam Sampson.
|
||||
|
||||
Mon Jan 4 06:28:07 UTC 2010 lukem
|
||||
|
||||
* Distribute various files not shipped by default automake rules,
|
||||
to use 'make dist' instead of 'cvs export'.
|
||||
|
||||
Wed Dec 30 00:12:47 UTC 2009 lukem
|
||||
|
||||
* Release as "tnftp 20091122"
|
||||
|
||||
Sun Nov 15 10:14:44 UTC 2009 lukem
|
||||
|
||||
* Merge NetBSD ftp from 20090520 to 20090915. Change:
|
||||
- Rename internal getline() to get_line() to avoid
|
||||
conflict with libc with former.
|
||||
- Avoid a NULL dereference in an error message.
|
||||
|
||||
Sat Nov 14 09:21:19 UTC 2009 lukem
|
||||
|
||||
* Convert to automake & libtool.
|
||||
|
||||
Sat Jun 6 07:17:38 UTC 2009 lukem
|
||||
|
||||
* Release as "tnftp 20090606"
|
||||
|
||||
Fri May 22 01:11:15 UTC 2009 lukem
|
||||
|
||||
* configure fixes:
|
||||
- Add the time.h headers to accheck_includes, for the strptime check.
|
||||
- Remove the check for el_init in libedit; we're always replacing
|
||||
the library and the presence of strvis() in some versions
|
||||
confuses other checks.
|
||||
|
||||
Wed May 20 13:47:43 UTC 2009 lukem
|
||||
|
||||
* Release as "tnftp 20090520"
|
||||
|
||||
* Merge NetBSD ftp from 20070722 to 20090520. Changes:
|
||||
- Only attempt to el_parse() a command unknown by the default
|
||||
parser if editing is enabled.
|
||||
Fixes PR 38589.
|
||||
- Turn off the alarmtimer before resetting the SIGALRM handler
|
||||
back to SIG_DFL.
|
||||
Fixes PR 35630.
|
||||
- Add epsv6 and epsv to disable extended passive mode for ipv6 or
|
||||
both ipv4 and ipv6 respectively. This hack is due to our
|
||||
friends a Juniper Networks who break epsv in ipv6.
|
||||
Should be fixed in ScreenOS 6.2.X.
|
||||
- Improve parsing of chunked transfer chunks per RFC2616:
|
||||
- more stringent chunk-size parsing
|
||||
- ignore optional trailing ';chunk-ext' stuff, instead of barfing
|
||||
- detect EOF before final \r\n.
|
||||
- Use the service name to getaddrinfo() (along with the host
|
||||
name), so that features such as DNS Service Discovery have a
|
||||
better chance of working.
|
||||
Display the service name in various status & error messages.
|
||||
- Don't getservbyname() the :port component of a URL; RFC 3986
|
||||
says it's just an unsigned number, not a service name.
|
||||
- Fix numerous WARNS=4 issues (-Wcast-qual -Wsign-compare).
|
||||
- Fix -Wshadow issues
|
||||
- Update copyrights
|
||||
- Remove clause 3 and 4 from TNF licenses
|
||||
- Rename HAVE_STRUCT_SOCKADDR_SA_LEN to
|
||||
HAVE_STRUCT_SOCKADDR_IN_SIN_LEN to accurately reflect the
|
||||
structure member being used.
|
||||
- Use AF_INET instead of AF_UNSPEC as the default family if
|
||||
!defined(INET6).
|
||||
|
||||
* configure improvements:
|
||||
- Style tweaks.
|
||||
- Use AC_LANG_PROGRAM() instead of AC_LANG_SOURCE()
|
||||
- Add a check for strptime() requiring separators between
|
||||
conversions, and use our replacement one if it does.
|
||||
|
||||
Sat Dec 20 15:28:24 UTC 2008 lukem
|
||||
|
||||
* configure improvements:
|
||||
- Move IPv6 check from tnftp.h to configure.ac (as per tnftpd).
|
||||
- Rework option descriptions.
|
||||
- Highlight when tests are for a specific option.
|
||||
- Move configuration results to the end of the file.
|
||||
- Display $prefix in configure results.
|
||||
|
||||
Fri Aug 15 03:03:36 UTC 2008 lukem
|
||||
|
||||
* Add a "Configuration results" display at the end of configure.
|
||||
Cosmetic tweaks.
|
||||
|
||||
Fri Feb 29 09:45:56 UTC 2008 lukem
|
||||
|
||||
* Support @EXEEXT@ for Cygwin (etc).
|
||||
|
||||
Mon Aug 6 04:55:19 UTC 2007 lukem
|
||||
|
||||
* Release as "tnftp 20070806"
|
||||
|
||||
* Add a NEWS file.
|
||||
|
||||
* Reduce differences between NetBSD-ftp and local copy.
|
||||
|
||||
* Merge NetBSD ftp from 20070605 to 20070722.
|
||||
Changes:
|
||||
- Document about:ftp and about:version.
|
||||
|
||||
* Add autoconf check for (Dante) SOCKS5.
|
||||
(Needs run-time testing and more portability testing.)
|
||||
|
||||
Mon Jul 23 11:44:42 UTC 2007 lukem
|
||||
|
||||
* Don't use non-standard: u_char u_short u_int.
|
||||
Use uint32_t instead of u_int32_t.
|
||||
|
||||
* Consistently use AS_CASE() and AS_IF() in configure.ac.
|
||||
|
||||
* Don't use defined() with HAVE_DECL_xxx.
|
||||
Use `LL' instead of `L' suffix for fallback
|
||||
defines of LLONG_MIN and LLONG_MAX.
|
||||
|
||||
Sun Jul 22 12:00:17 UTC 2007 lukem
|
||||
|
||||
* Include <arpa/nameser.h> if available, and provide fallback #defines.
|
||||
|
||||
* Sync with lib/libc/inet/inet_pton.c 1.3:
|
||||
* Sync to bind 9.3.x version
|
||||
* Update ISC copyright
|
||||
* Fix some lint
|
||||
|
||||
* Sync with lib/libc/inet/inet_ntop.c 1.3:
|
||||
* Sync to bind 9.3.x version
|
||||
* Update ISC copyright
|
||||
* Use socklen_t instead of size_t
|
||||
* Use snprintf() instead of SPRINTF()
|
||||
* Improve detection of various boundary conditions
|
||||
|
||||
* Sync to NetBSD glob.h 1.21, glob.c 1.16:
|
||||
* Standards compliance fix
|
||||
* De-lint
|
||||
* Don't overflow when DEBUG is defined.
|
||||
|
||||
* Sync fgetln.c to tools/compat/fgetln.c 1.7:
|
||||
* Clause 3 removal.
|
||||
|
||||
* Sync to config.guess 2007-07-22, config.sub 2007-06-28.
|
||||
|
||||
* Consistency tweaks in configure help strings.
|
||||
|
||||
* Add check for struct sockaddr.sa_len.
|
||||
Change tests for HAVE_foo to defined(HAVE_foo).
|
||||
Replace HAVE_SOCKADDR_SA_LEN with HAVE_STRUCT_SOCKADDR_SA_LEN.
|
||||
|
||||
* Remove pretence of supporting SOCKS for now;
|
||||
no test system is available, and the old
|
||||
autoconf 2.13 support wasn't upgraded to 2.61.
|
||||
|
||||
* configure.ac style consistency tweaks.
|
||||
Move autoconf aux files from ./ to build-aux/
|
||||
|
||||
* Remove duplicate HAVE_STRERROR replacement in tnftp.h.
|
||||
|
||||
Thu Jun 7 04:47:47 UTC 2007 lukem
|
||||
|
||||
* Merge NetBSD ftp from 20070510 to 20070605. Changes:
|
||||
- Enforce restriction that (http) proxied URL fetchs don't
|
||||
support being restarted at this time.
|
||||
Addresses NetBSD Problem Report 28697.
|
||||
- Display times in RFC2822 form rather than using ctime(3),
|
||||
since the former is more explicit about the timezone offset.
|
||||
- main: call tzset() to ensure TZ is setup for other <time.h>
|
||||
functions.
|
||||
- remotemodtime(): use strptime() to parse the reply.
|
||||
- fetch_url(): ensure struct tm is zeroed before calling
|
||||
strptime().
|
||||
- Modify parse_url() to consistently strip the leading `/'
|
||||
off ftp URLs.
|
||||
Fixes NetBSD Problem Report 17617.
|
||||
- Use 'RFCnnnn' (with leading 0) instead of 'RFC nnnn', to be
|
||||
consistent with the style in the RFC index.
|
||||
- Refer to RFC3916 instead of 1738 or 2732.
|
||||
- Expand the list of supported RFCs in ftp(1) to contain the
|
||||
document name as well.
|
||||
|
||||
Fri May 11 04:39:55 UTC 2007 lukem
|
||||
|
||||
* Update INSTALL and COPYING.
|
||||
|
||||
* Rename HAVE_QUAD_SUPPORT to HAVE_PRINTF_LONG_LONG, and only
|
||||
require support for 'long long' in that check rather than
|
||||
needing sizeof(off_t)>=8, as some systems have a separate
|
||||
off64_t when Large File Support is enabled.
|
||||
|
||||
* config.guess: treat 'i86xen:SunOS:5.*' as 'i86pc:SunOS:5.*'
|
||||
|
||||
Thu May 10 15:23:33 UTC 2007 lukem
|
||||
|
||||
* Remove checks for util.h and libutil.h, and replacement for
|
||||
fparseln(), since fparseln() isn't used any more.
|
||||
|
||||
* Merge NetBSD ftp from 20070418 to 20070510. Changes:
|
||||
- Switch from fparseln() to the internal getline() when
|
||||
parsing HTTP headers. Makes ftp a bit more portable
|
||||
(not needing fparseln()) at the expense of not supporting
|
||||
arbitrary long header lines, which I'm not concerned about
|
||||
because we don't support header line continuation either...
|
||||
- Replace references from draft-ietf-ftpext-mlst-NN to RFC 3659.
|
||||
- Fix misplaced const.
|
||||
- Implement copy_bytes() to copy bytes from one fd to another
|
||||
via the provided buffer, with optional rate-limiting and
|
||||
hash-mark printing, using one loop and handle short writes.
|
||||
Refactor sendrequest() and recvrequest() to use copy_data().
|
||||
Addresses NetBSD Problem Report 15943.
|
||||
|
||||
Wed May 9 05:24:55 UTC 2007 lukem
|
||||
|
||||
* Fix typo in poll()-based implementation of usleep() replacement.
|
||||
|
||||
Wed May 9 04:58:50 UTC 2007 lukem
|
||||
|
||||
* Rename configure.in to configure.ac, as the latter is the
|
||||
preferred name in autoconf 2.61.
|
||||
|
||||
* Convert from autoconf 2.13 to 2.61:
|
||||
* Use a consistent quoting mechanism.
|
||||
* Use modern autoconf macros, #define names, etc.
|
||||
* Search for more header files, and only #include if found.
|
||||
* Remove old-style config.h.in generation.
|
||||
This may fix various tests on platforms such as FreeBSD and OS X.
|
||||
|
||||
* Add -Wl,-search_paths_first to LDFLAGS on OS X (Darwin) if the
|
||||
linker supports it. This is needed so we use our libedit
|
||||
rather than the system one.
|
||||
|
||||
XXX: SOCKS support is currently disabled until I update the
|
||||
autoconf support.
|
||||
|
||||
Mon Apr 23 06:04:26 UTC 2007 lukem
|
||||
|
||||
* Merge NetBSD ftp from 20050610 to 20070418. Changes:
|
||||
- Add '-s srcaddr'.
|
||||
- Use IEC 60027-2 2^N based "KiB", "MiB" (etc) instead of
|
||||
10^n "KB", "MB", ...
|
||||
- Recognize 307 redirect code.
|
||||
- Suppress printing non-COMPLETE reply strings when EPSV/EPRT
|
||||
fails and we fall-back to PASV/PORT. Should fix a problem
|
||||
with the emacs ftp wrapper.
|
||||
- Fix display of 'Continue with <cmd>' messages.
|
||||
- Prevent segfaults in .netrc parsing.
|
||||
- Flush stdout before each command; ftp as slave process on
|
||||
a pipe should work.
|
||||
- getpass() can return NULL in some implementations; cope.
|
||||
- Support '-q quittime' when waiting for server replies.
|
||||
- Various spelling & grammatical fixes in the manual.
|
||||
- Plug some memory leaks.
|
||||
- If a file upload (via -u) fails, return an non-zero exit
|
||||
value based on the index of the file that caused the
|
||||
problem (a la auto-fetch retrieval).
|
||||
- Coverity fixes for CIDs: 873 874 875 1447 1448 2194 2195 3610
|
||||
- Don't remove trailing character during auth_url()
|
||||
- Fix progressbar display on narrow terminals (<43 columns)
|
||||
|
||||
Fri Mar 16 06:00:14 UTC 2007 lukem
|
||||
|
||||
* Change the return value of the replacement gai_strerror()
|
||||
from "char *" to "const char *", to match the current
|
||||
standards.
|
||||
Problem noted by Thomas Klausner.
|
||||
|
||||
Thu Oct 26 07:24:22 UTC 2006 lukem
|
||||
|
||||
* Correctly parse "AM" and "PM" in the replacement strptime().
|
||||
Problem noted by Kathryn Hogg.
|
||||
|
||||
Sat Jun 25 06:27:00 UTC 2005 lukem
|
||||
|
||||
* Release as "tnftp 20050625"
|
||||
|
||||
* Simplify the detection & replacement of dirname() and fparseln()
|
||||
and just use AC_REPLACE_FUNCS.
|
||||
(We don't care if the vendor has a working version in -lgen or -lutil
|
||||
instead of -lc; they'll get our replacement version in that case).
|
||||
Fixes build issue on older Darwin where the previous autoconf check
|
||||
wouldn't find dirname() in the default system libraries.
|
||||
|
||||
* Only provide a prototype for dirname() if we can't find one in
|
||||
<libgen.h>
|
||||
|
||||
* Search for NS_IN6ADDRSZ instead of IN6ADDRSZ, since we use the
|
||||
former and not the latter and older Darwin has the former.
|
||||
(This allows INET6 support to be enabled on Darwin 7.9.0)
|
||||
|
||||
Mon Jun 13 09:22:13 UTC 2005 lukem
|
||||
|
||||
* Tweak SOCKS5 support:
|
||||
acconfig.h:
|
||||
- fix a comment
|
||||
- ensure close() is replaced
|
||||
- list entries in the same order as aclocal.m4
|
||||
(and the SOCKS5 FAQ)
|
||||
aclocal.m4:
|
||||
- ensure getpeername() is replaced
|
||||
- don't replace listen() twice
|
||||
|
||||
Fri Jun 10 04:39:33 UTC 2005 lukem
|
||||
|
||||
* Release as "tnftp 20050610"
|
||||
|
||||
* Add dependencies on ${srcdir}/../tnftp.h and ../config.h
|
||||
|
||||
* Merge NetBSD ftp from 20050609 to 20050610. Changes:
|
||||
- Implement getline() to read a line into a buffer.
|
||||
- Convert to use getline() instead of fgets() whenever reading
|
||||
user input to ensure that an overly long input line doesn't
|
||||
leave excess characters for the next input operation to
|
||||
accidentally use as input.
|
||||
- Zero out the password & account after we've finished with it.
|
||||
- Consistently use getpass(3) (i.e, character echo suppressed)
|
||||
when reading the account data. For some reason, historically
|
||||
the "login" code suppressed echo for Account: yet the "user"
|
||||
command did not!
|
||||
- Display the hostname in the "getaddrinfo failed" warning.
|
||||
- Appease some -Wcast-qual warnings. Fixing all of these
|
||||
requires significant code refactoring. (mmm, legacy code).
|
||||
|
||||
Thu Jun 9 16:49:05 UTC 2005 lukem
|
||||
|
||||
* src, libnetbsd: Excise RCSID block, rather than using
|
||||
#if 0 ... #endif. The point was to minimise RCSID
|
||||
conflicts, and the latter isn't helping there.
|
||||
|
||||
* Merge NetBSD ftp from 20050531 to 20050609. Changes:
|
||||
- Only print the "Trying <address>..." message if verbose
|
||||
and there's more than one struct addrinfo in the
|
||||
getaddrinfo() result.
|
||||
- Don't use non-standard "u_int".
|
||||
|
||||
Wed Jun 1 15:08:01 UTC 2005 lukem
|
||||
|
||||
* Look for dirname(3), which may be in -lgen on IRIX, and
|
||||
replace it if not found..
|
||||
|
||||
Wed Jun 1 11:48:58 UTC 2005 lukem
|
||||
|
||||
* libnetbsd:
|
||||
- Don't use non-standard: u_char u_short u_int.
|
||||
- Use uint32_t instead of u_int32_t.
|
||||
- Don't use register.
|
||||
|
||||
* libedit: Don't use non-standard uint or u_int.
|
||||
|
||||
Tue May 31 02:23:08 UTC 2005 lukem
|
||||
|
||||
* tnftp.h: need <libgen.h> for dirname(3)
|
||||
|
||||
* Merge ftp from 20050513 to 20050531. Changes:
|
||||
- Helps if the definition of xconnect() matches its
|
||||
declaration....
|
||||
- Fix some cast issues highlighted by Scott Reynolds using
|
||||
gcc 4 on OSX.4
|
||||
- Use size_t instead of int where appropriate.
|
||||
- Make this compile on sparc64 (size_t != int).
|
||||
- Printf field widths and size_t don't always mix well, so
|
||||
cast to int. Fixes build problem for alpha.
|
||||
- Some const cleanups.
|
||||
- tab cleanup
|
||||
- Improve method used in fileindir() to determine if `file'
|
||||
is in or under `dir': realpath(3) on non-NetBSD systems may
|
||||
fail if the target filename doesn't exist, so instead use
|
||||
realpath(3) on the parent directory of `file'.
|
||||
Per discussion with Todd Eigenschink.
|
||||
- formatbuf(): fix %m and %M to use the hostname, not the
|
||||
username.
|
||||
- fetch_ftp(): preserve 'anonftp' across a disconnect() so
|
||||
that multiple ftp auto-fetches on the same command line
|
||||
login automatically.
|
||||
- auto_fetch(): use an initialized volatile int to appease
|
||||
IRIX cc.
|
||||
|
||||
* Merge libedit from NetBSD 20050105 to 20050531. Changes include:
|
||||
- Rui Paulo: Incorrect tok_line and tok_str declarations.
|
||||
- Remove clause 3 from the UCB license.
|
||||
- Luke Mewburn: Don't abuse unconstify'ing a string
|
||||
and writing to it, because you'll core dump. Also remove
|
||||
extra const that gives pain to the irix compiler.
|
||||
- Make sure we flush after we prepare when we are unbuffered
|
||||
otherwise the prompt will not appear immediately.
|
||||
- Terminate the arglist with a NULL instead of 0.
|
||||
(Shuts up gcc4.x)
|
||||
|
||||
Sat May 28 13:19:38 UTC 2005 lukem
|
||||
|
||||
* libnetbsd/strvis.c:
|
||||
- Sync to NetBSD's vis.c 1.33:
|
||||
Use malloc(3) instead of alloca(3).
|
||||
- Remove extraenous #endif
|
||||
|
||||
Fri May 27 05:46:58 UTC 2005 lukem
|
||||
|
||||
* libnetbsd/strvis.c: Sync to NetBSD's vis.c 1.30:
|
||||
Use a more standard TNF license.
|
||||
|
||||
* libedit/sig.c: Include "src/progressbar.h" for xsignal_restart()
|
||||
prototype.
|
||||
|
||||
* Ensure that fallback #define of __attribute__ is available.
|
||||
Fixes build problem on HP-UX with cc.
|
||||
|
||||
Thu May 26 14:21:08 UTC 2005 lukem
|
||||
|
||||
* Extend xpoll()'s HAVE_SELECT implementation to support POLLRDNORM,
|
||||
POLLWRNORM, and POLLRDBAND - the latter using exceptfds.
|
||||
Per discussion with Christos Zoulas.
|
||||
|
||||
Mon May 16 13:33:27 UTC 2005 lukem
|
||||
|
||||
* Pull in <poll.h> or <sys/poll.h> if they exist even if we're
|
||||
not using poll, as struct pollfd might exist in those.
|
||||
Fixes build problem on OSX.3.
|
||||
|
||||
* Separate CPPFLAGS from CFLAGS.
|
||||
|
||||
* Sync various files in libnetbsd with the original versions
|
||||
in NetBSD. Notable changes
|
||||
- Convert 4 clause UCB license to 3 clause.
|
||||
- Use strlcpy instead of strcpy.
|
||||
- Update ISC copyright.
|
||||
- Use NS_INADDRSZ, NS_IN6ADDRSZ and NS_INT16SZ instead of
|
||||
equivalents without NS_ prefix.
|
||||
- Use socklen_t instead of size_t where appropriate.
|
||||
- Improve bounds checking.
|
||||
- Don't update the size of allocated storage until
|
||||
realloc succeeds.
|
||||
- Fix comment about return value.
|
||||
- Reverse the order of two loop invariant to make
|
||||
'strlcat(0, "foo", 0)' not get a SEGV.
|
||||
- Use Todd C. Miller's latest copyright notice (more loose).
|
||||
- Use "long long" instead of "quad" in various
|
||||
comments & constants.
|
||||
- Support VIS_HTTPSTYLE.
|
||||
- Implement svis(), strsvis(), strsvisx(), strunvisx().
|
||||
|
||||
* Prefer poll over select when implementing replacement usleep().
|
||||
|
||||
Sat May 14 04:44:35 UTC 2005 lukem
|
||||
|
||||
* Release "tnftp 20050514"
|
||||
|
||||
* Fail if we can't find a library with tgetent (needed for libedit).
|
||||
NetBSD PR pkg/28925.
|
||||
* Improve quoting when using various autoconf macros.
|
||||
|
||||
* Merge NetBSD-ftp 20050513:
|
||||
- Correct the "optlen" argument passed to getsockopt(3) and
|
||||
setsockopt(3) in various places. Fixes a problem noted by
|
||||
Allen Briggs.
|
||||
- Improve warning printed when connect(2) for the data
|
||||
channel fails.
|
||||
|
||||
Wed May 11 04:19:43 UTC 2005 lukem
|
||||
|
||||
* Release "tnftp 20050511"
|
||||
|
||||
Wed May 11 04:10:01 UTC 2005 lukem
|
||||
|
||||
* Update the THANKS file.
|
||||
|
||||
* Only use poll() to implement xpoll() if it's available,
|
||||
otherwise attempt to use select() if that's available,
|
||||
otherwise #error.
|
||||
|
||||
* Detect if struct pollfd is available in <poll.h> or <sys/poll.h>.
|
||||
Improve consistency in use of autoconf macros.
|
||||
|
||||
Wed May 11 02:42:08 UTC 2005 lukem
|
||||
|
||||
* Merge NetBSD-ftp 20050511:
|
||||
- Use socklen_t instead of int as the 5th argument to
|
||||
getsockopt(). Improve invocation of setsockopt() and
|
||||
associated failure messages.
|
||||
|
||||
Wed May 11 01:46:29 UTC 2005 lukem
|
||||
|
||||
* Clean up RCSID usage in vendor-derived code, restoring original
|
||||
IDs where possible.
|
||||
|
||||
Wed May 11 00:08:16 UTC 2005 lukem
|
||||
|
||||
* Merge NetBSD-ftp 20050510:
|
||||
- Prevent an overly-long input line causing a core dump when
|
||||
editing is enabled.
|
||||
Issue noted by Ryoji Kanai in FreeBSD Problem Report # 77158.
|
||||
- Implement a timeout on the accept(2) in dataconn() and the
|
||||
connect(2) in xconnect() by temporarily setting O_NONBLOCK
|
||||
on the socket and using xpoll() to wait for the operation
|
||||
to succeed. The timeout used is the '-q quittime' argument
|
||||
(defaults to 60s for accept(2), and the system default for
|
||||
connect(2)). Idea inspired by discussion with Chuck Cranor.
|
||||
This may (indirectly) fix various problems with timeouts in
|
||||
active mode through broken firewalls.
|
||||
- Implement xpoll() as a wrapper around poll(2), to make it
|
||||
easier to replace on systems without a functional poll(2).
|
||||
Unconditionally use xpoll() instead of conditionally using
|
||||
select(2) or poll(2).
|
||||
- In fetch_url(), don't call freeaddrinfo(res0) too early, as
|
||||
we use pointers to its contents later in the function.
|
||||
Problem found by Onno van der Linden.
|
||||
- Fix ftp url reget when globs are being used.
|
||||
Provided by Mathieu Arnold <mat@FreeBSD.org>.
|
||||
- Factor out common string processing code eliminating static
|
||||
buffers, making functions that should be static be static,
|
||||
and cleaning up const usage. Added a guard against buffer
|
||||
overflow, but the domap function is a bit too complicated
|
||||
to tackle right now.
|
||||
- Clean up whitespace.
|
||||
- Expand description of http_proxy by suggesting the use of
|
||||
RFC 1738 '%xx' encoding for "unsafe URL" characters in
|
||||
usernames and passwords.
|
||||
|
||||
Wed Jan 5 05:53:59 UTC 2005 lukem
|
||||
|
||||
* For now, assume libedit is not up-to-date and use our own version.
|
||||
|
||||
* Merge libedit from NetBSD 20020605 to 20050105. Changes include:
|
||||
- Improve vi-mode.
|
||||
- Delete-previous-char and delete-next-char without an
|
||||
argument are not supposed to modify the yank buffer in
|
||||
emacs-mode.
|
||||
- Improve incremental searching.
|
||||
- Improve memory allocation & usage.
|
||||
- Move UCB-licensed code from 4-clause to 3-clause.
|
||||
- Make the tokenization functions publically available.
|
||||
- Various tty access bug-fixes.
|
||||
- Improve readline emulation.
|
||||
|
||||
Tue Jan 4 13:33:40 UTC 2005 lukem
|
||||
|
||||
* Unixware 7.1.1 implements RFC 2133 (Basic Socket Interface
|
||||
Extensions for IPv6) but not the successor RFC 2553. The configure
|
||||
script detects this and decides that tnftp needs to compile its own
|
||||
version of getaddrinfo(). This produces the error message
|
||||
/usr/include/netdb.h:248: `getaddrinfo' previously defined here
|
||||
because Unixware provides an implementation of getaddrinfo() in
|
||||
netdb.h instead of a prototype declaration :-/. Since netdb.h
|
||||
cannot be omitted, we will always get this definition and tnftp's
|
||||
version of getaddrinfo will always create a conflict. This ugly
|
||||
preprocessor hack works around the problem. Hints for a better
|
||||
solution welcome. Fix from pkgsrc/net/tnftp.
|
||||
|
||||
* Workaround poll() being a compatibility function on Darwin 7
|
||||
(MacOSX 10.3) by adding a custom test for _POLL_EMUL_H_ which
|
||||
is defined in poll.h on some MacOSX 10.3 systems. Not all 10.3
|
||||
systems have poll.h, so only do the poll() test if at least one
|
||||
of the header files is found. Fix from pkgsrc/net/tnftp.
|
||||
|
||||
* Add a utimes() replacement (using utime()) for Interix.
|
||||
From pkgsrc/net/tnftp.
|
||||
|
||||
Mon Jan 3 10:21:57 UTC 2005 lukem
|
||||
|
||||
* Release "tnftp 20050103"
|
||||
|
||||
* Merge NetBSD-ftp 20050103:
|
||||
- Forbid filenames returned from mget that aren't in (or below)
|
||||
the current directory. The previous behaviour (of trusting
|
||||
the remote server's response when retrieving the list of
|
||||
files to mget with prompting disabled) has been in ftp
|
||||
~forever, and has been a "known issue" for a long time.
|
||||
Recently an advisory was published by D.J. Bernstein on
|
||||
behalf of Yosef Klein warning of the problems with the
|
||||
previous behaviour, so to alleviate concern I've fixed
|
||||
this with a sledgehammer.
|
||||
- Remember the local cwd after any operation which may
|
||||
change it.
|
||||
- Use "remotecwd" instead of "remotepwd".
|
||||
- Add (unsigned char) cast to ctype functions
|
||||
- Ensure that "mname" is set in ls() and mls() so that an
|
||||
aborted confirm() prints the correct name.
|
||||
Problem highlighted & suggested fix from PR [bin/17766]
|
||||
by Steve McClellan.
|
||||
- If an ftp auto-fetch transfer is interrupted by SIGINT
|
||||
(usually ^C), exit with 130 instead of 1 (or rarely, 0).
|
||||
This allows an ftp auto-fetch in a shell loop to correctly
|
||||
terminate the loop.
|
||||
Should fix PR [pkg/26351], and possibly others.
|
||||
- Save approximately 8K by not including http authentication,
|
||||
extended status messages and help strings when the
|
||||
appropriate options are set.
|
||||
- Move UCB-licensed code from 4-clause to 3-clause licence.
|
||||
Patches provided by Joel Baker in PR 22365, verified by
|
||||
Alistair Crooks.
|
||||
- Always decode %xx in a url's user & pass components.
|
||||
- Only remember {WWW,Proxy}-Authenticate "Basic" challenges; no
|
||||
point in tracking any others since ftp doesn't support them.
|
||||
- Improve the parsing of HTTP responses.
|
||||
- Don't base64 encode the trailing NUL in the HTTP basic auth
|
||||
response. Problem noted by Eric Haszlakiewicz.
|
||||
- Improve parsing of HTTP response headers to be more RFC2616
|
||||
compliant, and skip LWS (linear white space; CR, LF, space,
|
||||
tab) and the end of lines and between the field name and
|
||||
the field value. This still isn't 100% compliant, since we
|
||||
don't support "multi line" responses at this time.
|
||||
This should fix PR [bin/22611] from TAMURA Kent (although I
|
||||
can't easily find a http server to reproduce the problem
|
||||
against.)
|
||||
- Fix a minor memory leak when parsing HTTP response headers.
|
||||
- Don't unnecessarily display a 401/407 error when running
|
||||
with -V. Fix from PR [bin/18535] by Jeremy Reed.
|
||||
- Don't warn about "ignored setsockopt" failures unless
|
||||
debugging is enabled. Suggested by Todd Vierling.
|
||||
- Allow empty passwords in ftp://user:@host/file auto-fetch
|
||||
URLs, per RFC 1738. Requested by Simon Poole.
|
||||
- correct URL syntax in comment
|
||||
- Note potentially surprising file-saving behaviour in case
|
||||
of HTTP redirects
|
||||
- -n is ignored for auto-fetch transfers
|
||||
- If connect(2) in xconnect() fails with EINTR, call select(2)
|
||||
on the socket until it's writable or it fails with something
|
||||
other than EINTR. This matches the behaviour in SUSv3, and
|
||||
prevents the problem when pressing ^T (SIGINFO, which is
|
||||
marked as restartable) during connection setup would cause
|
||||
ftp to fail with EADDRINUSE or EALREADY when the second
|
||||
connect(2) was attempted on the same socket. Problem found
|
||||
and solution provided by Maxime Henrion <mux@freebsd.org>.
|
||||
- Add -q to usage. From Kouichirou Hiratsuka in PR 26199.
|
||||
- PR/25566: Anders Magnusson: ftp(1) do not like large TCP
|
||||
windows. Limit it to 8M.
|
||||
|
||||
Mon Oct 6 01:23:03 UTC 2003 lukem
|
||||
|
||||
* configure.in improvements:
|
||||
- When testing for IN6ADDRSZ in <arpa/nameser.h>, pull in
|
||||
<sys/types.h> first. From Stoned Elipot <seb @ NetBSD>
|
||||
- Whitespace cleanup
|
||||
|
||||
Mon Aug 25 11:45:45 UTC 2003 lukem
|
||||
|
||||
* Release "tnftp 20030825"
|
||||
|
||||
* Add autoconf test for <sys/syslimits.h>; Cygwin needs it for ARG_MAX.
|
||||
Per discussion with Eugene Kotlyarov <ekot@protek36.esoo.ru>.
|
||||
|
||||
Thu Jul 31 07:30:00 UTC 2003 lukem
|
||||
|
||||
* release "tnftp 20030731"
|
||||
|
||||
* merge ftp from NetBSD 20030731 to 20030731b:
|
||||
- Work around broken ftp servers (notably ProFTPd) that can't
|
||||
even follow RFC 2389, and skip any amount of whitespace
|
||||
before a FEATure response. The RFC says 'single space' yet
|
||||
ProFTPd puts two. Noted by DervishD <raul@pleyades.net>.
|
||||
- Improve formatting of features[] debug dump.
|
||||
- Invalidate remote directory completion cache if any command
|
||||
which may change the remote contents completes successfully,
|
||||
including: del, mdel, ren, mkdir, rmdir, quote, and all
|
||||
upload commands. Patch from Yar Tikhiy <yar@freebsd.org>.
|
||||
|
||||
* merge ftp from NetBSD 20030228 to 20030731:
|
||||
- $FTPUSERAGENT overrides the HTTP User-Agent header.
|
||||
Based on patch from Douwe Kiela <virtus@wanadoo.nl>.
|
||||
- Add about:tnftp
|
||||
- Fix URL in about:netbsd
|
||||
- netbsd.org->NetBSD.org
|
||||
- strlcpy fix in fetch.c
|
||||
- Uppercase "URL"
|
||||
- fix a bogus error message when given a HTTP URL with a
|
||||
trailing slash
|
||||
- groff fixes in man page
|
||||
- tweak progressbar.c copyright; the stuff jason did in util.c
|
||||
wasn't migrated to this file
|
||||
- Don't coredump when printing '%n' in the prompt if there's
|
||||
no username yet.
|
||||
Fix from Maxim Konovalov <maxim@freebsd.org>
|
||||
|
||||
* Add test for HAVE_IN6ADDRSZ (which older Darwin is lacking),
|
||||
and only enable INET6 if it exists.
|
||||
Patch from Amitai Schlair <schmonz@schmonz.com>.
|
||||
|
||||
* Improve ipv6 check for older linux systems that don't provide
|
||||
sin6_scope_id.
|
||||
Patch from YAMANO Yuji <Yamano_Yuji@tk-bay.ogis-ri.co.jp>.
|
||||
|
||||
Fri Feb 28 10:57:30 UTC 2003 lukem
|
||||
|
||||
* tagged as "tnftp 2.0 beta1"
|
||||
|
||||
Fri Feb 28 10:07:07 UTC 2003 lukem
|
||||
|
||||
* renamed to `tnftp' (from `lukemftp')
|
||||
|
||||
* renamed `libukem' to `libnetbsd'
|
||||
|
||||
|
||||
Mon Jun 17 06:50:13 UTC 2002 lukem
|
||||
|
||||
* #if USE_GLOB_H, use <glob.h> instead of "ftpglob.h".
|
||||
Requested by Mike Heffner <mikeh@freebsd.org>
|
||||
|
||||
Mon Jun 10 08:12:35 UTC 2002 lukem
|
||||
|
||||
* crank FTP_VERSION from 1.6-beta1 to 1.6-beta2
|
||||
@ -223,7 +933,7 @@ Tue Oct 3 10:22:36 EST 2000 lukem
|
||||
Mon Sep 25 21:52:12 EST 2000 lukem
|
||||
|
||||
* crank to version 1.5 beta5
|
||||
|
||||
|
||||
Sun Sep 24 13:31:19 EST 2000 lukem
|
||||
|
||||
* merge ftp from NetBSD-current (20000924)
|
||||
@ -243,7 +953,7 @@ Sun Sep 24 13:31:19 EST 2000 lukem
|
||||
- in progressmeter() perform the check for foregroundproc() a
|
||||
little earlier
|
||||
- removed unused variable `items' in list_vertical()
|
||||
|
||||
|
||||
Sat Sep 23 15:43:34 EST 2000 lukem
|
||||
|
||||
* remove unused sverrno in warnx() and errx()
|
||||
@ -406,7 +1116,7 @@ Wed Aug 2 23:43:50 EST 2000 lukem
|
||||
* update from NetBSD-current (20000802):
|
||||
- rename NO_QUAD to NO_LONG_LONG, QUAD* -> LL* and add ULL*
|
||||
(unsigned) equivalents. name change suggested by Klaus
|
||||
Klein <kjk@netbsd.org>
|
||||
Klein <kjk@NetBSD.org>
|
||||
- change defined(BSD4_4) || HAVE_SIN_LEN tests into
|
||||
HAVE_SOCKADDR_SA_LEN, and set the latter if BSD4_4 exists
|
||||
|
||||
@ -451,7 +1161,7 @@ Wed Jul 26 18:59:19 EST 2000 lukem
|
||||
- add support for FEAT and OPTS commands with `features' and
|
||||
`opts'. (from RFC 2389).
|
||||
- add support for MLST & MLSD (machine parseble listings)
|
||||
with 'mlst', 'mlsd' and 'pmlsd' (mlsd |$PAGER) commands.
|
||||
with 'mlst', 'mlsd' and 'pmlsd' (mlsd |$PAGER) commands.
|
||||
(from draft-ietf-ftpext-mlst-11)
|
||||
- rename remotesyst() to getremoteinfo(), and modify to parse
|
||||
the result from FEAT (if supported), and take into account
|
||||
@ -473,7 +1183,7 @@ Wed Jul 26 18:59:19 EST 2000 lukem
|
||||
- minor knf (indent goto labels by one space, etc).
|
||||
- simply various command usage handlers by assuming that
|
||||
argv != NULL except for quit() and disconnect().
|
||||
- errx?/warnx? audit. do not pass variable alone, use %s.
|
||||
- errx?/warnx? audit. do not pass variable alone, use %s.
|
||||
|
||||
* check for issetugid() and don't use in libedit if it doesn't exist.
|
||||
|
||||
@ -572,12 +1282,12 @@ Sun Jun 4 18:00:07 EST 2000 lukem
|
||||
- do not pass scoped IPv6 address notation on Host: directive,
|
||||
since scope identifier is local to the originating node.
|
||||
do not allow scoped IPv6 address notation in URL, if it is
|
||||
via proxy.
|
||||
via proxy.
|
||||
- fixes from cgd:
|
||||
* sanity check a length (otherwise certain bogus responses
|
||||
can crash ftp)
|
||||
* allow a transfer encoding type of `binary'; certain
|
||||
firewall vendors return this bogus type...
|
||||
firewall vendors return this bogus type...
|
||||
- make debugging output unambiguous on IPv6 numeric addrs
|
||||
(don't use host:port)
|
||||
- http://[::1]:8080/ is legal.
|
||||
@ -705,7 +1415,7 @@ Sun Nov 28 18:20:41 EST 1999 lukem
|
||||
- implement xsl_init() and xsl_add(); error checking forms of
|
||||
sl_{init,add}()
|
||||
- fix bug where the second press of <TAB> on an empty word (i.e, list
|
||||
all options) may have resulted in an strncmp() against NULL.
|
||||
all options) may have resulted in an strncmp() against NULL.
|
||||
(detected by _DIAGASSERT())
|
||||
- in cleanuppeer(), reset username to NULL after free()ing it.
|
||||
fixes [bin/8870] by Wolfgang Rupprecht <wolfgang@wsrcc.com>
|
||||
@ -985,7 +1695,7 @@ Mon Oct 4 10:57:41 EST 1999 lukem
|
||||
|
||||
* Add support for --{en,dis}able-editcomplete (defaults to enabled),
|
||||
which prevents libedit support from being compiled in.
|
||||
From Chris G. Demetriou <cgd@netbsd.org>
|
||||
From Chris G. Demetriou <cgd@NetBSD.org>
|
||||
|
||||
Sun Oct 3 16:49:01 EST 1999 lukem
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
diff -ru src.orig/cmds.c src/cmds.c
|
||||
--- src.orig/cmds.c Sun Jun 15 22:11:43 2003
|
||||
+++ src/cmds.c Sun Jun 15 21:46:37 2003
|
||||
@@ -131,6 +131,7 @@
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
+#include <libutil.h>
|
||||
|
||||
#include "ftp_var.h"
|
||||
#include "version.h"
|
||||
diff -ru src.orig/fetch.c src/fetch.c
|
||||
--- src.orig/fetch.c Sun Jun 15 22:11:43 2003
|
||||
+++ src/fetch.c Sun Jun 15 21:46:53 2003
|
||||
@@ -69,6 +69,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
+#include <libutil.h>
|
||||
|
||||
#include "ftp_var.h"
|
||||
#include "version.h"
|
||||
Only in src: ftp.cat1
|
||||
diff -ru src.orig/progressbar.c src/progressbar.c
|
||||
--- src.orig/progressbar.c Sun Jun 15 22:11:43 2003
|
||||
+++ src/progressbar.c Sun Jun 15 21:50:48 2003
|
||||
@@ -50,6 +50,7 @@
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
+#include <sys/time.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
@@ -57,10 +58,12 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
-#include <tzfile.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "progressbar.h"
|
||||
+
|
||||
+#define SECSPERHOUR (60 * 60)
|
||||
+#define SECSPERDAY ((long)60 * 60 * 24)
|
||||
|
||||
#if !defined(NO_PROGRESS)
|
||||
/*
|
||||
diff -ru src.orig/util.c src/util.c
|
||||
--- src.orig/util.c Sun Jun 15 22:11:44 2003
|
||||
+++ src/util.c Sun Jun 15 21:51:31 2003
|
||||
@@ -101,10 +101,11 @@
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <time.h>
|
||||
-#include <tzfile.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ftp_var.h"
|
||||
+
|
||||
+#define TM_YEAR_BASE 1900
|
||||
|
||||
/*
|
||||
* Connect to peer server and auto-login, if possible.
|
173
INSTALL
173
INSTALL
@ -1,8 +1,7 @@
|
||||
INSTALLATION INTRODUCTION
|
||||
-------------------------
|
||||
|
||||
This file describes how to compile and install lukemftp on your
|
||||
system.
|
||||
This file describes how to compile and install tnftp on your system.
|
||||
|
||||
============================================
|
||||
= =
|
||||
@ -11,24 +10,20 @@ system.
|
||||
============================================
|
||||
|
||||
|
||||
For most systems, execute the following to compile and install
|
||||
lukemftp:
|
||||
For most systems, execute the following to compile and install tnftp:
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
A preformatted manual page (src/ftp.cat1) is also installed. If
|
||||
you wish to install the source (src/ftp.1), ensure that your system
|
||||
has up-to-date mandoc macros. groff ships with this macro suite,
|
||||
but it has bugs. Try:
|
||||
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/tmac/
|
||||
for a more recent version.
|
||||
A preformatted manual page (src/ftp.cat1) is also installed.
|
||||
If you wish to install the source (src/ftp.1), ensure that your system
|
||||
has up-to-date mandoc macros, such as those that are shipped with groff.
|
||||
|
||||
|
||||
CONFIGURATION OPTIONS
|
||||
---------------------
|
||||
|
||||
lukemftp is configured using an `autoconf' generated `configure'
|
||||
tnftp is configured using an `autoconf' generated `configure'
|
||||
script. `configure' supports the following options:
|
||||
|
||||
* The standard `autoconf configure' options, including:
|
||||
@ -41,14 +36,11 @@ script. `configure' supports the following options:
|
||||
|
||||
* Specific options:
|
||||
--enable-editcomplete Turn on command line editing and completion.
|
||||
--disable-editcomplete Turn off command line editing and completion
|
||||
[default: enabled].
|
||||
--enable-ipv6 Enable IPv6 support (if your OS supports it)
|
||||
--disable-ipv6 Disable IPv6 support (even if your OS supports it.)
|
||||
[default: enabled].
|
||||
--with-socks Compile with SOCKS firewall traversal support.
|
||||
--with-socks5[=PATH] Compile with SOCKS5 firewall traversal support.
|
||||
--with-socks4[=PATH] Compile with SOCKS4 firewall traversal support.
|
||||
(default: enabled)
|
||||
--enable-ipv6 Enable IPv6 support (if your OS supports it).
|
||||
(default: enabled)
|
||||
--disable-largefile omit support for large files
|
||||
--with-socks enable support for (Dante) SOCKS5 proxy
|
||||
|
||||
The following environment variables can be set to override various
|
||||
compiler related settings.
|
||||
@ -66,146 +58,3 @@ This can be achieved with:
|
||||
= =
|
||||
============================================
|
||||
|
||||
|
||||
PLATFORM SPECIFIC NOTES
|
||||
-----------------------
|
||||
|
||||
The following platforms & compilers have been tested:
|
||||
|
||||
- AIX 4.1.5:
|
||||
- AIX 4.2.1:
|
||||
- AIX 4.3.3:
|
||||
- Compiler: xlc -qlanglvl=ansi
|
||||
version: xlC 3.1.4.10 -- C for AIX Compiler
|
||||
version: ibmcxx.cmp 3.6.6.6 -- IBM C and C++ Compilers
|
||||
|
||||
Configure with:
|
||||
env CC="xlc" CFLAGS="-qlanglvl=ansi" ./configure
|
||||
|
||||
- BSD/OS 4.0.1 (x86)
|
||||
- BSD/OS 4.1 (x86)
|
||||
- BSD/OS 4.1 (sparc)
|
||||
- BSD/OS 4.2 (x86)
|
||||
- Compiler: /bin/cc
|
||||
version: gcc 2.7.2.1
|
||||
version: gcc version 2.95.2 19991024
|
||||
|
||||
- Digital UNIX 4.0b
|
||||
- Digital UNIX 4.0d
|
||||
- Digital UNIX 4.0f
|
||||
- Compiler: cc -std
|
||||
version: DEC C V5.2-036 on Digital UNIX V4.0 (Rev. 564)
|
||||
version: DEC C V5.9-005 on Digital UNIX V4.0 (Rev. 1229)
|
||||
|
||||
Configure with
|
||||
env CC="cc -std" ./configure
|
||||
|
||||
- Compiler: gcc
|
||||
version: 2.95.1
|
||||
|
||||
- Digital UNIX 5.0
|
||||
- Compiler: cc
|
||||
version: Compaq C V6.1-011 on Digital UNIX V5.0 (Rev. 910)
|
||||
|
||||
- FreeBSD 3.4 (i386):
|
||||
- FreeBSD 3.5 (i386):
|
||||
- FreeBSD 4.1 (i386):
|
||||
- Compiler: cc
|
||||
version: gcc version 2.7.2.3
|
||||
version: gcc version 2.95.2 19991024
|
||||
|
||||
- HP/UX 10.20:
|
||||
- HP/UX 11.00:
|
||||
- Compiler: /opt/ansic/bin/cc -Ae
|
||||
version: A.10.32.03
|
||||
|
||||
Configure with
|
||||
env CC="cc -Ae" ./configure
|
||||
|
||||
To generate code that will run on old architectures you
|
||||
may need to add "+DAportable" to CC.
|
||||
|
||||
|
||||
- IRIX 6.5.4
|
||||
- IRIX 6.5.8
|
||||
Compiler: /bin/cc
|
||||
version: MIPSpro Compilers: Version 7.2.1
|
||||
Compiler:
|
||||
version: gcc version 2.95.2
|
||||
|
||||
- HP/UX 11.00:
|
||||
- HP/UX 11.00 64 bit:
|
||||
- Compiler: /opt/ansic/bin/cc -Ae
|
||||
version: A.11.01.00
|
||||
|
||||
Configure with
|
||||
env CC="cc -Ae" ./configure
|
||||
|
||||
- NetBSD 1.3.3 (i386)
|
||||
Compiler: /usr/bin/cc
|
||||
Compiler: /usr/bin/cc
|
||||
|
||||
Ignore warnings about ``passing arg 3 of `tputs' from
|
||||
incompatible pointer type''.
|
||||
|
||||
- RedHat Linux 5.1 (?? i386)
|
||||
- RedHat Linux 5.2 (?? i386)
|
||||
- RedHat Linux 6.0 (Linux 2.2.10 i686)
|
||||
- RedHat Linux 6.1 (Linux 2.2.5-15 i686)
|
||||
- RedHat Linux 6.2 (Linux 2.2.16-3smp i686)
|
||||
- Compiler: cc
|
||||
version: egcs-1.1.2
|
||||
|
||||
- Slackware (Linux 2.0.35 i686)
|
||||
- Compiler: cc
|
||||
version: 2.7.2.3
|
||||
|
||||
- Solaris 2.6 (sparc)
|
||||
- Solaris 7 (sparc)
|
||||
- Compiler: /opt/SUNWspro/bin/cc
|
||||
version: WorkShop Compilers 5.0
|
||||
|
||||
- Compiler: gcc
|
||||
version: egcs-1.1.2
|
||||
|
||||
=============
|
||||
= OLD NOTES =
|
||||
=============
|
||||
|
||||
XXX: clean up to match reality
|
||||
------------------------------
|
||||
|
||||
- RedHat Linux 5.0 (i386)
|
||||
Compiler: cc
|
||||
|
||||
- Solaris 2.5 (sparc)
|
||||
- Solaris 7 (x86)
|
||||
Compiler: /opt/SUNWspro/bin/cc
|
||||
version: SC3.0 15 Dec 1993
|
||||
version: WorkShop Compilers 5.0
|
||||
Compiler: gcc
|
||||
version: egcs-1.1.2
|
||||
version: gcc 2.8.1
|
||||
version: gcc 2.95.1
|
||||
|
||||
- Solaris 7 (sparc) 64 bit
|
||||
Compiler: /opt/SUNWspro/bin/cc -xarch=v9
|
||||
version: WorkShop Compilers 5.0
|
||||
|
||||
- SunOS 4
|
||||
Compiler: gcc -lresolv
|
||||
version:
|
||||
|
||||
- SuSE Linux
|
||||
Compiler: gcc
|
||||
version:
|
||||
|
||||
/usr/bin/ftp on SuSE Linux 6.4 is this ftp client.
|
||||
|
||||
May need `gcc -L/usr/lib/termcap' if tgetent() et al aren't found.
|
||||
|
||||
- Ultrix 4.5
|
||||
Compiler: cc
|
||||
version: MIPS C Compiler 3.0
|
||||
Compiler: gcc
|
||||
version: 2.7.2.2
|
||||
|
13
Makefile.am
Normal file
13
Makefile.am
Normal file
@ -0,0 +1,13 @@
|
||||
## $NetBSD: Makefile.am,v 1.2 2010/01/04 06:24:58 lukem Exp $
|
||||
|
||||
SUBDIRS = libnetbsd
|
||||
|
||||
if USE_LIBEDIT
|
||||
SUBDIRS += libedit
|
||||
endif
|
||||
|
||||
SUBDIRS += src
|
||||
|
||||
EXTRA_DIST = \
|
||||
todo \
|
||||
tnftp.h
|
733
Makefile.in
733
Makefile.in
@ -1,33 +1,726 @@
|
||||
# $Id: Makefile.in,v 1.6 1999/11/13 01:18:22 lukem Exp $
|
||||
#
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
SHELL = /bin/sh
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@USE_LIBEDIT_TRUE@am__append_1 = libedit
|
||||
subdir = .
|
||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in $(srcdir)/tnftp_config.h.in \
|
||||
$(top_srcdir)/configure COPYING ChangeLog INSTALL NEWS THANKS \
|
||||
buildaux/config.guess buildaux/config.sub buildaux/depcomp \
|
||||
buildaux/install-sh buildaux/ltmain.sh buildaux/missing
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = tnftp_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
AM_V_GEN = $(am__v_GEN_$(V))
|
||||
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
AM_V_at = $(am__v_at_$(V))
|
||||
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_at_0 = @
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
html-recursive info-recursive install-data-recursive \
|
||||
install-dvi-recursive install-exec-recursive \
|
||||
install-html-recursive install-info-recursive \
|
||||
install-pdf-recursive install-ps-recursive install-recursive \
|
||||
installcheck-recursive installdirs-recursive pdf-recursive \
|
||||
ps-recursive uninstall-recursive
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
|
||||
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
|
||||
distdir dist dist-all distcheck
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = libnetbsd libedit src
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
{ test ! -d "$(distdir)" \
|
||||
|| { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -fr "$(distdir)"; }; }
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
SUBDIRS = libnetbsd $(am__append_1) src
|
||||
EXTRA_DIST = \
|
||||
todo \
|
||||
tnftp.h
|
||||
|
||||
all: tnftp_config.h
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||
|
||||
SUBDIRS = libedit libukem src
|
||||
.SUFFIXES:
|
||||
am--refresh:
|
||||
@:
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
all: ftp
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
ftp: @LIBEDIT@ @LIBUKEM@
|
||||
( cd src; ${MAKE} )
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
libedit.a:
|
||||
( cd libedit; ${MAKE} )
|
||||
tnftp_config.h: stamp-h1
|
||||
@if test ! -f $@; then \
|
||||
rm -f stamp-h1; \
|
||||
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
|
||||
else :; fi
|
||||
|
||||
libukem.a:
|
||||
( cd libukem; ${MAKE} )
|
||||
stamp-h1: $(srcdir)/tnftp_config.h.in $(top_builddir)/config.status
|
||||
@rm -f stamp-h1
|
||||
cd $(top_builddir) && $(SHELL) ./config.status tnftp_config.h
|
||||
$(srcdir)/tnftp_config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
($(am__cd) $(top_srcdir) && $(AUTOHEADER))
|
||||
rm -f stamp-h1
|
||||
touch $@
|
||||
|
||||
install clean:
|
||||
@for i in ${SUBDIRS}; do \
|
||||
( echo "$@ ===> $$i" ; cd $$i ; ${MAKE} $@ ); \
|
||||
distclean-hdr:
|
||||
-rm -f tnftp_config.h stamp-h1
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
$(RECURSIVE_TARGETS):
|
||||
@failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
$(RECURSIVE_CLEAN_TARGETS):
|
||||
@failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
case "$@" in \
|
||||
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
*) list='$(SUBDIRS)' ;; \
|
||||
esac; \
|
||||
rev=''; for subdir in $$list; do \
|
||||
if test "$$subdir" = "."; then :; else \
|
||||
rev="$$subdir $$rev"; \
|
||||
fi; \
|
||||
done; \
|
||||
rev="$$rev ."; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
ctags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
done
|
||||
|
||||
distclean: clean
|
||||
@for i in ${SUBDIRS}; do \
|
||||
( echo "$@ ===> $$i" ; cd $$i ; ${MAKE} $@ ); \
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) tnftp_config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
empty_fix=.; \
|
||||
else \
|
||||
include_option=--include; \
|
||||
empty_fix=; \
|
||||
fi; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS) tnftp_config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) tnftp_config.h.in $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) tnftp_config.h.in $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
rm -f Makefile config.cache config.log config.status config.h
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-lzma: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist dist-all: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lzma*) \
|
||||
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir); chmod a+w $(distdir)
|
||||
mkdir $(distdir)/_build
|
||||
mkdir $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@$(am__cd) '$(distuninstallcheck_dir)' \
|
||||
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
all-am: Makefile tnftp_config.h
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
install: install-recursive
|
||||
install-exec: install-exec-recursive
|
||||
install-data: install-data-recursive
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-recursive
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-recursive
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-recursive
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-recursive
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
|
||||
ctags-recursive install-am install-strip tags-recursive
|
||||
|
||||
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
|
||||
all all-am am--refresh check check-am clean clean-generic \
|
||||
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
|
||||
distcheck distclean distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags distcleancheck distdir \
|
||||
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
installdirs-am maintainer-clean maintainer-clean-generic \
|
||||
mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
|
||||
ps ps-am tags tags-recursive uninstall uninstall-am
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
86
NEWS
86
NEWS
@ -1,84 +1,36 @@
|
||||
This is a brief description of the new features and fixes added to
|
||||
lukemftp-1.5 since the release of lukemftp-1.4. As always, the manual
|
||||
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||
This is tnftp version 20091122.
|
||||
|
||||
* Add new commands:
|
||||
features list remote features supported by servers
|
||||
mlsd machine parseable directory listing
|
||||
mlst machine parseable file listing
|
||||
remopts set options on remote features
|
||||
Changes in tnftp from 20090606 to 20091122:
|
||||
|
||||
These require support in the remote server for the ftp extensions
|
||||
described in RFC 2389 and draft-ietf-ftpext-mlst-11.
|
||||
Portability fixes.
|
||||
|
||||
* Fix support for the --program-prefix and --program-suffix configure
|
||||
options.
|
||||
Changes in tnftp from 20090520 to 20090606:
|
||||
|
||||
---
|
||||
This is a brief description of the new features and fixes added to
|
||||
lukemftp-1.4 since the release of lukemftp-1.3. As always, the manual
|
||||
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||
Portability fixes.
|
||||
|
||||
* Fix compilation problems on various non 4.4BSD derived platforms which
|
||||
support IPv6, and on Linux systems which have strdup() as a macro.
|
||||
Changes in tnftp from 20070806 to 20090520:
|
||||
|
||||
* During auto-fetch, don't attempt to autologin a second time if the first
|
||||
time failed.
|
||||
Fix intermittent "Alarm clock" error.
|
||||
|
||||
---
|
||||
This is a brief description of the new features and fixes added to
|
||||
lukemftp-1.3 since the release of lukemftp-1.2. As always, the manual
|
||||
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||
Add epsv6 and epsv to disable extended passive mode for IPv6 or
|
||||
both IPv4 and IPv6 respectively.
|
||||
|
||||
* The `ls' command now uses the `LIST' directive instead of `NLST',
|
||||
in order to be compatible with RFC959.
|
||||
Improve parsing of HTTP chunked transfers per RFC2616.
|
||||
|
||||
* Add fget command, which reads a list of filenames to retrieve from
|
||||
the given file.
|
||||
Use the service name to getaddrinfo() (along with the host name),
|
||||
so that features such as DNS Service Discovery will work.
|
||||
|
||||
* Add support for uploading files on the command-line with `ftp -u'.
|
||||
Fix various compiler warnings.
|
||||
|
||||
* Various fixes to the IPv6 support.
|
||||
|
||||
---
|
||||
This is a brief description of the new features and fixes added to
|
||||
lukemftp-1.2 since the release of lukemftp-1.1. As always, the manual
|
||||
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||
Changes in tnftp from 20050625 to 20070806:
|
||||
|
||||
* During remote completion, only send ``NLST'' instead of ``NLST .''
|
||||
when reading the list of files from the remote server; some servers
|
||||
don't like the trailing `.'.
|
||||
Implement '-s srcaddr' to set the local IP address for
|
||||
all connections.
|
||||
|
||||
* Support a leading ``[user@]'' for ``[user@]host[:][path]'' auto-fetches
|
||||
and ``[user@]host'' connections.
|
||||
Support '-q quittime' when waiting for server replies.
|
||||
|
||||
* Always compile in support for setting the type of service on transfers.
|
||||
Should speed up transfers on Linux systems.
|
||||
Use IEC 60027-2 "KiB", "MiB" (etc) instead of "KB", "MB", ...
|
||||
|
||||
* Improve performance of non-rate-limited transfers.
|
||||
Portability fixes, including for FreeBSD, Mac OS X, and Solaris.
|
||||
|
||||
* Work around ftp servers that aren't Y2K compliant in returning the
|
||||
modification time of a file.
|
||||
|
||||
* Update the libedit library to support automatic and magic margins,
|
||||
allowing ftp's rprompt to move an extra character to the right.
|
||||
|
||||
---
|
||||
This is a brief description of the new features and fixes added to
|
||||
lukemftp-1.1 since the release of lukemftp-1.0. As always, the manual
|
||||
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||
|
||||
* Implemented `set prompt' and `set rprompt', which allow you to
|
||||
configure the prompt and right side prompt (respectively).
|
||||
Some tcsh(1) style `%' escapes are supported, including
|
||||
%. %c %/ %m %M %n
|
||||
|
||||
* Implemented restarting of file:/// and non-proxied http:// URLs
|
||||
(using -R)
|
||||
|
||||
* Correctly parse remote ports given as numbers that don't appear in
|
||||
the services(5) database.
|
||||
|
||||
* Prevent a couple of minor memory leaks
|
||||
|
||||
* Add missing compilation setting for SOCKS
|
||||
|
53
README
53
README
@ -1,61 +1,68 @@
|
||||
WHAT IS LUKEMFTP?
|
||||
-----------------
|
||||
WHAT IS TNFTP?
|
||||
--------------
|
||||
|
||||
`lukemftp' is what many users affectionately call the enhanced ftp
|
||||
client in NetBSD (http://www.netbsd.org). The `lukem' comes from
|
||||
the account name of the NetBSD developer who wrote most of the
|
||||
enhancements: Luke Mewburn <lukem@netbsd.org>.
|
||||
`tnftp' is a `port' of the NetBSD FTP client to other systems.
|
||||
See http://www.NetBSD.org/ for more details about NetBSD.
|
||||
|
||||
This package is a `port' of the NetBSD ftp client to other systems.
|
||||
tnftp was formerly known as `lukemftp'
|
||||
It was renamed to `tnftp' by Luke Mewburn in February 2003.
|
||||
|
||||
The enhancements over the standard ftp client in 4.4BSD (and
|
||||
derivatives) include:
|
||||
* command-line editing within ftp
|
||||
* command-line fetching of URLS, including support for:
|
||||
- http proxies (c.f: $http_proxy, $ftp_proxy)
|
||||
- http proxies (see $http_proxy, $ftp_proxy)
|
||||
- authentication
|
||||
* configurable prompt
|
||||
* context sensitive command and filename completion
|
||||
* dynamic progress bar
|
||||
* feature negotiation extensions from RFC 2389
|
||||
(c.f: `feat' and `remopts')
|
||||
(see `feat' and `remopts')
|
||||
* extensions to ftp from the IETF ftpext working group
|
||||
(c.f: `mlsd' and `mlst')
|
||||
(see `mlsd' and `mlst')
|
||||
* IPv6 support (from the WIDE project)
|
||||
* modification time preservation
|
||||
* paging of local and remote files, and of directory listings
|
||||
(c.f: `lpage', `page', `pdir')
|
||||
(see `lpage', `page', `pdir')
|
||||
* passive mode support, with fallback to active mode
|
||||
* retrieval of filenames listed in a given file (c.f: `fget')
|
||||
* retrieval of filenames listed in a given file (see `fget')
|
||||
* `set option' override of ftp environment variables
|
||||
* socks4/socks5 support
|
||||
* TIS Firewall Toolkit gate ftp proxy support (c.f: `gate')
|
||||
* transfer-rate throttling (c.f: `-T', `rate')
|
||||
* uploading of files on the command line (c.f: `-u')
|
||||
* TIS Firewall Toolkit gate ftp proxy support (see `gate')
|
||||
* transfer-rate throttling (see `-T', `rate')
|
||||
* uploading of files on the command line (see `-u')
|
||||
* (Dante) SOCKS5 support
|
||||
|
||||
Previous features, currently disabled until a test system is available:
|
||||
* SOCKS4 support
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
Refer to `INSTALL' for more information on how to compile and install
|
||||
lukemftp.
|
||||
Refer to `INSTALL' for more information on how to compile and install tnftp.
|
||||
|
||||
|
||||
FEEDBACK / BUG REPORTS
|
||||
----------------------
|
||||
|
||||
Please email feedback back to the maintainer: <lukem@netbsd.org>.
|
||||
Please email feedback back to the maintainer:
|
||||
Luke Mewburn <lukem@NetBSD.org>.
|
||||
|
||||
|
||||
COPYRIGHT
|
||||
---------
|
||||
|
||||
lukemftp is covered by a BSD-style copyright notice. Please refer to
|
||||
the file `COPYING' for more information.
|
||||
tnftp is covered by a BSD-style copyright notice.
|
||||
Please refer to the file `COPYING' for more information.
|
||||
|
||||
|
||||
AVAILABILITY
|
||||
------------
|
||||
|
||||
The primary ftp site for lukemftp is:
|
||||
ftp://ftp.netbsd.org/pub/NetBSD/misc/lukemftp/
|
||||
The primary ftp site for tnftp is:
|
||||
ftp://ftp.NetBSD.org/pub/NetBSD/misc/tnftp/
|
||||
|
||||
|
||||
DOCUMENT REFERENCE
|
||||
------------------
|
||||
$NetBSD: README,v 1.10 2007/08/06 01:58:57 lukem Exp $
|
||||
|
47
THANKS
47
THANKS
@ -1,30 +1,53 @@
|
||||
Whilst a lot of the work in lukemftp (both the original sources in NetBSD
|
||||
and this port) was done by me (Luke Mewburn), it would not be as useable
|
||||
without the enhancements, fixes, or input from the following people:
|
||||
Whilst a lot of the work in tnftp (both the original sources in NetBSD
|
||||
and this port) was done by Luke Mewburn, it would not be as usable
|
||||
without the enhancements, bug fixes, or input from the following people:
|
||||
|
||||
Amitai Schlair <schmonz@schmonz.com>
|
||||
Anders Dinsen <anders@dinsen.net>
|
||||
Anders Magnusson <ragge@ltu.se>
|
||||
Arkadiusz Miskiewicz <misiek@pld.org.pl>
|
||||
Brian Stark <bstark1990@netscape.net>
|
||||
Chris G. Demetriou <cgd@netbsd.org>
|
||||
Christos Zoulas <christos@netbsd.org>
|
||||
Chris G. Demetriou <cgd@NetBSD.org>
|
||||
Christos Zoulas <christos@NetBSD.org>
|
||||
Dan Winship <danw@mit.edu>
|
||||
Darren Reed <darrenr@pobox.com>
|
||||
David Carrel <carrel@netbsd.org>
|
||||
David Brownlee <abs@mono.org>
|
||||
David Carrel <carrel@NetBSD.org>
|
||||
DervishD <raul@pleyades.net>
|
||||
Douwe Kiela <virtus@wanadoo.nl>
|
||||
Eugene Kotlyarov <ekot@protek36.esoo.ru>
|
||||
Geoff Wing <mason@primenet.com.au>
|
||||
Giles Lean <giles@nemeton.com.au>
|
||||
Havard Eidnes <Havard.Eidnes@runit.sintef.no>
|
||||
ITOH Yasufumi <itohy@netbsd.org>
|
||||
Jason R. Thorpe <thorpej@netbsd.org>
|
||||
Hubert Feyrer <hubert@feyrer.de>
|
||||
ITOH Yasufumi <itohy@NetBSD.org>
|
||||
Jason R. Thorpe <thorpej@NetBSD.org>
|
||||
John Hawkinson <jhawk@mit.edu>
|
||||
Joseph S. Myers <jsm28@cam.ac.uk>
|
||||
Jun-ichiro itojun Hagino <itojun@netbsd.org>
|
||||
Jun-ichiro itojun Hagino <itojun@NetBSD.org>
|
||||
Kimmo Suominen <kim@tac.nyc.ny.us>
|
||||
Klaus Klein <kleink@netbsd.org>
|
||||
Luke Mewburn <lukem@netbsd.org>
|
||||
Klaus Klein <kleink@NetBSD.org>
|
||||
Launey Thomas <ljt@alum.mit.edu>
|
||||
Luke Mewburn <lukem@NetBSD.org>
|
||||
Marc Horowitz <marc@mit.edu>
|
||||
Mathieu Arnold <mat@FreeBSD.org>
|
||||
Matthew R. Green <mrg@eterna.com.au>
|
||||
Matthias Pfaller <leo@dachau.marco.de>
|
||||
Matthias Scheler <tron@zhadum.de>
|
||||
Maxim Konovalov <maxim@FreeBSD.org>
|
||||
Maxime Henrion <mux@FreeBSD.org>
|
||||
Michael L. Hitch <osymh@terra.oscs.montana.edu>
|
||||
Mike Heffner <mikeh@FreeBSD.org>
|
||||
Onno van der Linden <o.vd.linden@quicknet.nl>
|
||||
Ruslan Ermilov <ru@FreeBSD.org>
|
||||
Ryoji Kanai <rkanai@eeye.com>
|
||||
Scott Aaron Bamford <sab@ansic.net>
|
||||
Simon Burge <simonb@thistledown.com.au>
|
||||
Steve McClellan <steve.mcclellan@radisys.com>
|
||||
TAMURA Kent <kent@NetBSD.org>
|
||||
Stoned Elipot <seb@NetBSD.org>
|
||||
Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
YAMANO Yuji <yyamano@NetBSD.org>
|
||||
Yar Tikhiy <yar@FreeBSD.org>
|
||||
|
||||
Apologies to anyone I've missed.
|
||||
Apologies to anyone missed.
|
||||
|
92
acconfig.h
92
acconfig.h
@ -1,92 +0,0 @@
|
||||
/* $Id: acconfig.h,v 1.9 2002/06/10 01:27:13 lukem Exp $ */
|
||||
|
||||
@TOP@
|
||||
@BOTTOM@
|
||||
|
||||
/* Define if your compiler supports `long long' */
|
||||
#undef HAVE_LONG_LONG
|
||||
|
||||
/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
|
||||
#undef HAVE_PRINTF_QD
|
||||
|
||||
/* Define if in_port_t exists */
|
||||
#undef HAVE_IN_PORT_T
|
||||
|
||||
/* Define if sa_family_t exists in <sys/socket.h> */
|
||||
#undef HAVE_SA_FAMILY_T
|
||||
|
||||
/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
|
||||
/* Define if socklen_t exists */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
/* Define if AF_INET6 exists in <sys/socket.h> */
|
||||
#undef HAVE_AF_INET6
|
||||
|
||||
/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
|
||||
#undef HAVE_SOCKADDR_IN6
|
||||
|
||||
/* Define if `struct addrinfo' exists in <netdb.h> */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
/*
|
||||
* Define if <netdb.h> contains AI_NUMERICHOST et al.
|
||||
* Systems which only implement RFC2133 will need this.
|
||||
*/
|
||||
#undef HAVE_RFC2553_NETDB
|
||||
|
||||
/* Define if `struct direct' has a d_namlen element */
|
||||
#undef HAVE_D_NAMLEN
|
||||
|
||||
/* Define if h_errno exists in <netdb.h> */
|
||||
#undef HAVE_H_ERRNO_D
|
||||
|
||||
/* Define if fclose() is declared in <stdio.h> */
|
||||
#undef HAVE_FCLOSE_D
|
||||
|
||||
/* Define if getpass() is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_GETPASS_D
|
||||
|
||||
/* Define if optarg is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_OPTARG_D
|
||||
|
||||
/* Define if optind is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_OPTIND_D
|
||||
|
||||
/* Define if pclose() is declared in <stdio.h> */
|
||||
#undef HAVE_PCLOSE_D
|
||||
|
||||
/* Define if `long long' is supported and sizeof(off_t) >= 8 */
|
||||
#undef HAVE_QUAD_SUPPORT
|
||||
|
||||
/* Define if strptime() is declared in <time.h> */
|
||||
#undef HAVE_STRPTIME_D
|
||||
|
||||
/*
|
||||
* Define this if compiling with SOCKS (the firewall traversal library).
|
||||
* Also, you must define connect, getsockname, bind, accept, listen, and
|
||||
* select to their R-versions.
|
||||
*/
|
||||
#undef SOCKS
|
||||
#undef SOCKS4
|
||||
#undef SOCKS5
|
||||
#undef connect
|
||||
#undef getsockname
|
||||
#undef bind
|
||||
#undef accept
|
||||
#undef listen
|
||||
#undef select
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef fclose
|
||||
#undef gethostbyname
|
||||
#undef getpeername
|
||||
#undef read
|
||||
#undef recv
|
||||
#undef recvfrom
|
||||
#undef rresvport
|
||||
#undef send
|
||||
#undef sendto
|
||||
#undef shutdown
|
||||
#undef write
|
7877
aclocal.m4
vendored
7877
aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
1561
buildaux/config.guess
vendored
Executable file
1561
buildaux/config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1686
buildaux/config.sub
vendored
Executable file
1686
buildaux/config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
630
buildaux/depcomp
Executable file
630
buildaux/depcomp
Executable file
@ -0,0 +1,630 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
|
||||
# Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
@ -1,5 +1,9 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: install-sh,v 1.2 2009/11/14 09:18:49 lukem Exp $
|
||||
# This script now also installs multiple files, but might choke on installing
|
||||
# multiple files with spaces in the file names.
|
||||
#
|
||||
# install - install a program, script, or datafile
|
||||
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||
#
|
||||
@ -20,9 +24,7 @@
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
# from scratch.
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
@ -32,6 +34,7 @@ doit="${DOITPROG-}"
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
awkprog="${AWKPROG-awk}"
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
@ -41,21 +44,33 @@ stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
transformbasename=""
|
||||
transform_arg=""
|
||||
instcmd="$mvprog"
|
||||
chmodcmd="$chmodprog 0755"
|
||||
pathcompchmodcmd="$chmodprog 755"
|
||||
chmodcmd="$chmodprog 755"
|
||||
chowncmd=""
|
||||
chgrpcmd=""
|
||||
stripcmd=""
|
||||
stripflags=""
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=""
|
||||
msrc=""
|
||||
dst=""
|
||||
dir_arg=""
|
||||
suffix=""
|
||||
suffixfmt=""
|
||||
|
||||
while [ x"$1" != x ]; do
|
||||
case $1 in
|
||||
-b) suffix=".old"
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-B) suffixfmt="$2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-c) instcmd="$cpprog"
|
||||
shift
|
||||
continue;;
|
||||
@ -83,80 +98,86 @@ while [ x"$1" != x ]; do
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||
-S) stripcmd="$stripprog"
|
||||
stripflags="-S $2 $stripflags"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||
shift
|
||||
continue;;
|
||||
|
||||
*) if [ x"$src" = x ]
|
||||
*) if [ x"$msrc" = x ]
|
||||
then
|
||||
src=$1
|
||||
msrc="$dst"
|
||||
else
|
||||
# this colon is to work around a 386BSD /bin/sh bug
|
||||
:
|
||||
dst=$1
|
||||
msrc="$msrc $dst"
|
||||
fi
|
||||
src="$dst"
|
||||
dst="$1"
|
||||
shift
|
||||
continue;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ x"$src" = x ]
|
||||
if [ x"$dir_arg" = x ]
|
||||
then
|
||||
echo "install: no input file specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
dst=$src
|
||||
src=""
|
||||
|
||||
if [ -d $dst ]; then
|
||||
instcmd=:
|
||||
chmodcmd=""
|
||||
else
|
||||
instcmd=mkdir
|
||||
dstisfile=""
|
||||
if [ ! -d "$dst" ]
|
||||
then
|
||||
if [ x"$msrc" = x"$src" ]
|
||||
then
|
||||
dstisfile=true
|
||||
else
|
||||
echo "install: destination is not a directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
msrc="$msrc $dst"
|
||||
fi
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||
if [ x"$msrc" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for srcarg in $msrc; do
|
||||
|
||||
if [ x"$dir_arg" != x ]; then
|
||||
|
||||
dstarg="$srcarg"
|
||||
else
|
||||
dstarg="$dst"
|
||||
|
||||
# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
|
||||
if [ -f $src -o -d $src ]
|
||||
if [ -f "$srcarg" ]
|
||||
then
|
||||
true
|
||||
doinst="$instcmd"
|
||||
elif [ -d "$srcarg" ]
|
||||
then
|
||||
echo "install: $srcarg: not a regular file"
|
||||
exit 1
|
||||
elif [ "$srcarg" = "/dev/null" ]
|
||||
then
|
||||
doinst="$cpprog"
|
||||
else
|
||||
echo "install: $src does not exist"
|
||||
echo "install: $srcarg does not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ x"$dst" = x ]
|
||||
then
|
||||
echo "install: no destination specified"
|
||||
exit 1
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
# If destination is a directory, append the input filename; if your system
|
||||
# does not like double slashes in filenames, you may need to add some logic
|
||||
|
||||
if [ -d $dst ]
|
||||
if [ -d "$dstarg" ]
|
||||
then
|
||||
dst="$dst"/`basename $src`
|
||||
else
|
||||
true
|
||||
dstarg="$dstarg"/`basename "$srcarg"`
|
||||
fi
|
||||
fi
|
||||
|
||||
## this sed command emulates the dirname command
|
||||
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||
@ -181,7 +202,11 @@ while [ $# -ne 0 ] ; do
|
||||
|
||||
if [ ! -d "${pathcomp}" ] ;
|
||||
then
|
||||
$mkdirprog "${pathcomp}"
|
||||
$doit $mkdirprog "${pathcomp}"
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
|
||||
if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi
|
||||
|
||||
else
|
||||
true
|
||||
fi
|
||||
@ -190,44 +215,53 @@ while [ $# -ne 0 ] ; do
|
||||
done
|
||||
fi
|
||||
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
$doit $instcmd $dst &&
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||
else
|
||||
|
||||
# If we're going to rename the final executable, determine the name now.
|
||||
|
||||
if [ x"$transformarg" = x ]
|
||||
if [ x"$dir_arg" != x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
else
|
||||
dstfile=`basename $dst $transformbasename |
|
||||
sed $transformarg`$transformbasename
|
||||
fi
|
||||
if [ -d "$dstarg" ]; then
|
||||
true
|
||||
else
|
||||
$doit $mkdirprog "$dstarg" &&
|
||||
|
||||
# don't allow the sed command to completely eliminate the filename
|
||||
|
||||
if [ x"$dstfile" = x ]
|
||||
then
|
||||
dstfile=`basename $dst`
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi
|
||||
fi
|
||||
else
|
||||
true
|
||||
fi
|
||||
|
||||
if [ x"$dstisfile" = x ]
|
||||
then
|
||||
file=$srcarg
|
||||
else
|
||||
file=$dst
|
||||
fi
|
||||
|
||||
dstfile=`basename "$file"`
|
||||
dstfinal="$dstdir/$dstfile"
|
||||
|
||||
# Make a temp file name in the proper directory.
|
||||
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
dsttmp=$dstdir/#inst.$$#
|
||||
|
||||
# Make a backup file name in the proper directory.
|
||||
case x$suffixfmt in
|
||||
*%*) suffix=`echo x |
|
||||
$awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" '
|
||||
{ cnt = 0;
|
||||
do {
|
||||
sfx = sprintf(fmt, cnt++);
|
||||
name = bname sfx;
|
||||
} while (system("test -f " name) == 0);
|
||||
print sfx; }' -`;;
|
||||
x) ;;
|
||||
*) suffix="$suffixfmt";;
|
||||
esac
|
||||
dstbackup="$dstfinal$suffix"
|
||||
|
||||
# Move or copy the file name to the temp name
|
||||
|
||||
$doit $instcmd $src $dsttmp &&
|
||||
$doit $doinst $srcarg "$dsttmp" &&
|
||||
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
trap "rm -f ${dsttmp}" 0 &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits
|
||||
|
||||
@ -235,17 +269,23 @@ else
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||
if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi &&
|
||||
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi &&
|
||||
if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi &&
|
||||
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
|
||||
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||
if [ x"$suffix" != x ] && [ -f "$dstfinal" ]
|
||||
then
|
||||
$doit $mvcmd "$dstfinal" "$dstbackup"
|
||||
else
|
||||
$doit $rmcmd -f "$dstfinal"
|
||||
fi &&
|
||||
$doit $mvcmd "$dsttmp" "$dstfinal"
|
||||
fi
|
||||
|
||||
fi &&
|
||||
done &&
|
||||
|
||||
|
||||
exit 0
|
7050
buildaux/ltmain.sh
Executable file
7050
buildaux/ltmain.sh
Executable file
File diff suppressed because it is too large
Load Diff
376
buildaux/missing
Executable file
376
buildaux/missing
Executable file
@ -0,0 +1,376 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
autom4te touch the output file, or create a stub one
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar*)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison*|yacc*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar*)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case $firstarg in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case $firstarg in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
275
config.h.in
275
config.h.in
@ -1,275 +0,0 @@
|
||||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* $Id: config.h.in,v 1.28 2002/06/10 08:10:33 lukem Exp $ */
|
||||
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
#undef _ALL_SOURCE
|
||||
#endif
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define if the `getpgrp' function takes no argument. */
|
||||
#undef GETPGRP_VOID
|
||||
|
||||
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||
#undef NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */
|
||||
#undef F77_NO_MINUS_C_MINUS_O
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
#undef off_t
|
||||
|
||||
/* Define to the type of arg1 for select(). */
|
||||
#undef SELECT_TYPE_ARG1
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for select(). */
|
||||
#undef SELECT_TYPE_ARG234
|
||||
|
||||
/* Define to the type of arg5 for select(). */
|
||||
#undef SELECT_TYPE_ARG5
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#undef TIME_WITH_SYS_TIME
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
#undef VOID_CLOSEDIR
|
||||
|
||||
/* The number of bytes in a off_t. */
|
||||
#undef SIZEOF_OFF_T
|
||||
|
||||
/* Define if you have the err function. */
|
||||
#undef HAVE_ERR
|
||||
|
||||
/* Define if you have the fgetln function. */
|
||||
#undef HAVE_FGETLN
|
||||
|
||||
/* Define if you have the fparseln function. */
|
||||
#undef HAVE_FPARSELN
|
||||
|
||||
/* Define if you have the fseeko function. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
/* Define if you have the getaddrinfo function. */
|
||||
#undef HAVE_GETADDRINFO
|
||||
|
||||
/* Define if you have the gethostbyname2 function. */
|
||||
#undef HAVE_GETHOSTBYNAME2
|
||||
|
||||
/* Define if you have the getnameinfo function. */
|
||||
#undef HAVE_GETNAMEINFO
|
||||
|
||||
/* Define if you have the getpassphrase function. */
|
||||
#undef HAVE_GETPASSPHRASE
|
||||
|
||||
/* Define if you have the getpgrp function. */
|
||||
#undef HAVE_GETPGRP
|
||||
|
||||
/* Define if you have the inet_ntop function. */
|
||||
#undef HAVE_INET_NTOP
|
||||
|
||||
/* Define if you have the inet_pton function. */
|
||||
#undef HAVE_INET_PTON
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the mkstemp function. */
|
||||
#undef HAVE_MKSTEMP
|
||||
|
||||
/* Define if you have the poll function. */
|
||||
#undef HAVE_POLL
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define if you have the setprogname function. */
|
||||
#undef HAVE_SETPROGNAME
|
||||
|
||||
/* Define if you have the sl_init function. */
|
||||
#undef HAVE_SL_INIT
|
||||
|
||||
/* Define if you have the snprintf function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define if you have the strlcat function. */
|
||||
#undef HAVE_STRLCAT
|
||||
|
||||
/* Define if you have the strlcpy function. */
|
||||
#undef HAVE_STRLCPY
|
||||
|
||||
/* Define if you have the strptime function. */
|
||||
#undef HAVE_STRPTIME
|
||||
|
||||
/* Define if you have the strsep function. */
|
||||
#undef HAVE_STRSEP
|
||||
|
||||
/* Define if you have the strtoll function. */
|
||||
#undef HAVE_STRTOLL
|
||||
|
||||
/* Define if you have the strunvis function. */
|
||||
#undef HAVE_STRUNVIS
|
||||
|
||||
/* Define if you have the strvis function. */
|
||||
#undef HAVE_STRVIS
|
||||
|
||||
/* Define if you have the timegm function. */
|
||||
#undef HAVE_TIMEGM
|
||||
|
||||
/* Define if you have the usleep function. */
|
||||
#undef HAVE_USLEEP
|
||||
|
||||
/* Define if you have the <arpa/nameser.h> header file. */
|
||||
#undef HAVE_ARPA_NAMESER_H
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <err.h> header file. */
|
||||
#undef HAVE_ERR_H
|
||||
|
||||
/* Define if you have the <libutil.h> header file. */
|
||||
#undef HAVE_LIBUTIL_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define if you have the <poll.h> header file. */
|
||||
#undef HAVE_POLL_H
|
||||
|
||||
/* Define if you have the <regex.h> header file. */
|
||||
#undef HAVE_REGEX_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <sys/poll.h> header file. */
|
||||
#undef HAVE_SYS_POLL_H
|
||||
|
||||
/* Define if you have the <termcap.h> header file. */
|
||||
#undef HAVE_TERMCAP_H
|
||||
|
||||
/* Define if you have the <util.h> header file. */
|
||||
#undef HAVE_UTIL_H
|
||||
|
||||
/* Define if you have the <vis.h> header file. */
|
||||
#undef HAVE_VIS_H
|
||||
|
||||
/* Define if you have the nsl library (-lnsl). */
|
||||
#undef HAVE_LIBNSL
|
||||
|
||||
/* Define if you have the socket library (-lsocket). */
|
||||
#undef HAVE_LIBSOCKET
|
||||
|
||||
/* Define if you have the tinfo library (-ltinfo). */
|
||||
#undef HAVE_LIBTINFO
|
||||
|
||||
/* Define if you have the util library (-lutil). */
|
||||
#undef HAVE_LIBUTIL
|
||||
|
||||
/* Define if your compiler supports `long long' */
|
||||
#undef HAVE_LONG_LONG
|
||||
|
||||
/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
|
||||
#undef HAVE_PRINTF_QD
|
||||
|
||||
/* Define if in_port_t exists */
|
||||
#undef HAVE_IN_PORT_T
|
||||
|
||||
/* Define if sa_family_t exists in <sys/socket.h> */
|
||||
#undef HAVE_SA_FAMILY_T
|
||||
|
||||
/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
|
||||
#undef HAVE_SOCKADDR_SA_LEN
|
||||
|
||||
/* Define if socklen_t exists */
|
||||
#undef HAVE_SOCKLEN_T
|
||||
|
||||
/* Define if AF_INET6 exists in <sys/socket.h> */
|
||||
#undef HAVE_AF_INET6
|
||||
|
||||
/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
|
||||
#undef HAVE_SOCKADDR_IN6
|
||||
|
||||
/* Define if `struct addrinfo' exists in <netdb.h> */
|
||||
#undef HAVE_ADDRINFO
|
||||
|
||||
/*
|
||||
* Define if <netdb.h> contains AI_NUMERICHOST et al.
|
||||
* Systems which only implement RFC2133 will need this.
|
||||
*/
|
||||
#undef HAVE_RFC2553_NETDB
|
||||
|
||||
/* Define if `struct direct' has a d_namlen element */
|
||||
#undef HAVE_D_NAMLEN
|
||||
|
||||
/* Define if h_errno exists in <netdb.h> */
|
||||
#undef HAVE_H_ERRNO_D
|
||||
|
||||
/* Define if fclose() is declared in <stdio.h> */
|
||||
#undef HAVE_FCLOSE_D
|
||||
|
||||
/* Define if getpass() is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_GETPASS_D
|
||||
|
||||
/* Define if optarg is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_OPTARG_D
|
||||
|
||||
/* Define if optind is declared in <stdlib.h> or <unistd.h> */
|
||||
#undef HAVE_OPTIND_D
|
||||
|
||||
/* Define if pclose() is declared in <stdio.h> */
|
||||
#undef HAVE_PCLOSE_D
|
||||
|
||||
/* Define if `long long' is supported and sizeof(off_t) >= 8 */
|
||||
#undef HAVE_QUAD_SUPPORT
|
||||
|
||||
/* Define if strptime() is declared in <time.h> */
|
||||
#undef HAVE_STRPTIME_D
|
||||
|
||||
/*
|
||||
* Define this if compiling with SOCKS (the firewall traversal library).
|
||||
* Also, you must define connect, getsockname, bind, accept, listen, and
|
||||
* select to their R-versions.
|
||||
*/
|
||||
#undef SOCKS
|
||||
#undef SOCKS4
|
||||
#undef SOCKS5
|
||||
#undef connect
|
||||
#undef getsockname
|
||||
#undef bind
|
||||
#undef accept
|
||||
#undef listen
|
||||
#undef select
|
||||
#undef dup
|
||||
#undef dup2
|
||||
#undef fclose
|
||||
#undef gethostbyname
|
||||
#undef getpeername
|
||||
#undef read
|
||||
#undef recv
|
||||
#undef recvfrom
|
||||
#undef rresvport
|
||||
#undef send
|
||||
#undef sendto
|
||||
#undef shutdown
|
||||
#undef write
|
404
configure.ac
Normal file
404
configure.ac
Normal file
@ -0,0 +1,404 @@
|
||||
# $NetBSD: configure.ac,v 1.22 2010/01/12 06:57:31 lukem Exp $
|
||||
#
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT([tnftp], [20100108], [lukem@NetBSD.org])
|
||||
AC_PREREQ([2.61])
|
||||
|
||||
AC_COPYRIGHT([
|
||||
Copyright (c) 1999-2010 The NetBSD Foundation, Inc.
|
||||
All rights reserved.
|
||||
])
|
||||
AC_REVISION([$Revision: 1.22 $])
|
||||
|
||||
AS_SHELL_SANITIZE
|
||||
|
||||
AC_CONFIG_SRCDIR([tnftp.h])
|
||||
AC_CONFIG_AUX_DIR([buildaux])
|
||||
AC_CONFIG_HEADERS([tnftp_config.h])
|
||||
AC_CONFIG_LIBOBJ_DIR([libnetbsd])
|
||||
|
||||
AM_INIT_AUTOMAKE([-Wall -Werror foreign nostdinc silent-rules])
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
#
|
||||
# Arguments for which features are included.
|
||||
#
|
||||
AC_ARG_ENABLE([editcomplete],
|
||||
[AS_HELP_STRING([--enable-editcomplete],
|
||||
[turn on command line editing and completion
|
||||
[default=enabled]])],
|
||||
[opt_editcomplete=$enableval],
|
||||
[opt_editcomplete=yes])
|
||||
AC_ARG_ENABLE([ipv6],
|
||||
[AS_HELP_STRING([--enable-ipv6],
|
||||
[enable IPv6 support (if your OS supports it)
|
||||
[default=enabled]])],
|
||||
[opt_ipv6=$enableval],
|
||||
[opt_ipv6=yes])
|
||||
AC_ARG_WITH([socks],
|
||||
[AS_HELP_STRING([--with-socks],
|
||||
[enable support for (Dante) SOCKS5 proxy
|
||||
[default=auto]])],
|
||||
[],
|
||||
[with_socks=auto])
|
||||
|
||||
#
|
||||
# Autoheader templates symbols.
|
||||
#
|
||||
AH_TEMPLATE([HAVE_POLL],
|
||||
[Define if we have poll() and it is not emulated.])
|
||||
AH_TEMPLATE([HAVE_PRINTF_QD],
|
||||
[Define if *printf() uses %qd to print `long long'
|
||||
(otherwise uses %lld).])
|
||||
AH_TEMPLATE([HAVE_PRINTF_LONG_LONG],
|
||||
[Define if `long long' is supported and
|
||||
*printf() supports %lld or %qd to print them.])
|
||||
AH_TEMPLATE([USE_INET6],
|
||||
[Define if using IPv6 support.])
|
||||
AH_TEMPLATE([USE_SOCKS],
|
||||
[Define if using (Dante) SOCKS5 proxy.])
|
||||
|
||||
#
|
||||
# Checks for programs.
|
||||
#
|
||||
AC_PROG_CC
|
||||
AC_PROG_AWK
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
#
|
||||
# Checks for tool features.
|
||||
#
|
||||
AS_CASE([$target_os],
|
||||
[darwin*],
|
||||
[# Mac OS X linker needs -search_paths_first so our private libraries
|
||||
# are used before system libraries.
|
||||
#
|
||||
old_LDFLAGS=$LDFLAGS
|
||||
LDFLAGS="$LDFLAGS -Wl,-search_paths_first"
|
||||
AC_MSG_CHECKING([if ld accepts -search_paths_first])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [[int i;]])],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([no])
|
||||
LDFLAGS=$old_LDFLAGS])],
|
||||
)
|
||||
|
||||
#
|
||||
# Checks for libraries.
|
||||
#
|
||||
AS_IF([test "$opt_editcomplete" = yes],
|
||||
[AC_SEARCH_LIBS([tgetent],
|
||||
[termcap termlib curses ncurses tinfo],
|
||||
[],
|
||||
[AC_MSG_ERROR(
|
||||
[no relevant library found containing tgetent])])
|
||||
])
|
||||
|
||||
AC_SEARCH_LIBS([gethostbyname], [nsl])
|
||||
AC_SEARCH_LIBS([socket],
|
||||
[socket],
|
||||
[],
|
||||
[AC_CHECK_LIB([socket],
|
||||
[socket],
|
||||
[LIBS="-lsocket -lnsl $LIBS"],
|
||||
[],
|
||||
[-lnsl])])
|
||||
|
||||
# Check for (Dante) SOCKS5.
|
||||
#
|
||||
AS_IF([test "$with_socks" != no],
|
||||
[AC_MSG_NOTICE([--with-socks=$with_socks; checking for required SOCKS5 features])
|
||||
AC_SEARCH_LIBS([SOCKSinit],
|
||||
[socksd socks],
|
||||
[AC_DEFINE([USE_SOCKS], [1])
|
||||
AC_MSG_NOTICE([enabling SOCKS5 support])
|
||||
with_socks=yes
|
||||
AS_IF([test "$opt_ipv6" = yes],
|
||||
[AC_MSG_WARN(
|
||||
[IPv6 is incompatible with socks, disabling IPv6 support])
|
||||
opt_ipv6=no])],
|
||||
[AS_IF([test "$with_socks" != "auto"],
|
||||
[AC_MSG_FAILURE(
|
||||
[--with-socks was given, but SOCKSinit() wasn't found])])
|
||||
AC_MSG_NOTICE([disabling --with-socks])
|
||||
with_socks=no])])
|
||||
|
||||
#
|
||||
# Checks for header files.
|
||||
#
|
||||
accheck_includes='
|
||||
#include <stdio.h>
|
||||
#if defined(HAVE_SYS_TYPES_H)
|
||||
# include <sys/types.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_STAT_H)
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#if defined(STDC_HEADERS)
|
||||
# include <stdarg.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
#endif
|
||||
#if defined(TIME_WITH_SYS_TIME)
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if defined(HAVE_SYS_TIME_H)
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
#if defined(HAVE_LIBGEN_H)
|
||||
# include <libgen.h>
|
||||
#endif
|
||||
#if defined(HAVE_PWD_H)
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
#if defined(HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#if defined(HAVE_POLL_H)
|
||||
# include <poll.h>
|
||||
#elif defined(HAVE_SYS_POLL_H)
|
||||
# include <sys/poll.h>
|
||||
#endif
|
||||
#if defined(HAVE_SYS_SOCKET_H)
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#if defined(HAVE_NETINET_IN_H)
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
#if defined(HAVE_NETINET_IN_SYSTM_H)
|
||||
# include <netinet/in_systm.h>
|
||||
#endif
|
||||
#if defined(HAVE_NETDB_H)
|
||||
# include <netdb.h>
|
||||
#endif
|
||||
#if defined(HAVE_ARPA_INET_H)
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
#if defined(HAVE_DIRENT_H)
|
||||
# include <dirent.h>
|
||||
#else
|
||||
# define dirent direct
|
||||
# if defined(HAVE_SYS_NDIR_H)
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_DIR_H)
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if defined(HAVE_NDIR_H)
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
' # accheck_includes
|
||||
|
||||
AC_CHECK_HEADERS([sys/types.h sys/ioctl.h sys/param.h sys/stat.h \
|
||||
sys/socket.h sys/syslimits.h sys/time.h sys/wait.h],
|
||||
[], [], [$accheck_includes])
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_RESOLV
|
||||
AC_HEADER_STAT
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_TIOCGWINSZ
|
||||
AC_CHECK_HEADERS([arpa/ftp.h arpa/inet.h arpa/nameser.h err.h \
|
||||
fcntl.h libgen.h limits.h malloc.h \
|
||||
netinet/in.h netinet/in_systm.h netinet/ip.h \
|
||||
paths.h poll.h pwd.h sys/poll.h regex.h \
|
||||
setjmp.h signal.h stddef.h termcap.h termios.h \
|
||||
unistd.h utime.h vis.h],
|
||||
[], [], [$accheck_includes])
|
||||
|
||||
#
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
#
|
||||
AC_CHECK_DECLS([AI_NUMERICHOST, dirname, fclose, getpass, h_errno, pclose,
|
||||
optarg, optind],
|
||||
[], [], [$accheck_includes])
|
||||
AC_TYPE_LONG_DOUBLE
|
||||
AC_TYPE_LONG_LONG_INT
|
||||
AC_TYPE_UINT32_T
|
||||
AC_TYPE_OFF_T
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIGNAL
|
||||
AC_TYPE_SIZE_T
|
||||
AC_STRUCT_TM
|
||||
AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len,
|
||||
struct dirent.d_namlen],
|
||||
[], [], [$accheck_includes])
|
||||
AC_CHECK_TYPES([in_port_t, sa_family_t, socklen_t, struct addrinfo],
|
||||
[], [], [$accheck_includes])
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# If IPv6 is enabled, check for necessary items.
|
||||
#
|
||||
AS_IF([test "$opt_ipv6" = yes],
|
||||
[AC_MSG_NOTICE([--enable-ipv6; checking for required IPv6 features])
|
||||
AC_CHECK_DECLS([AF_INET6, NS_IN6ADDRSZ], [], [],
|
||||
[$accheck_includes
|
||||
#if defined(HAVE_ARPA_NAMESER_H)
|
||||
#include <arpa/nameser.h>
|
||||
#endif
|
||||
])
|
||||
AC_CHECK_TYPES([struct sockaddr_in6], [], [opt_ipv6=no],
|
||||
[$accheck_includes])
|
||||
AS_IF([test "$opt_ipv6" = yes],
|
||||
[AC_MSG_NOTICE([enabling IPv6 support])
|
||||
AC_DEFINE([USE_INET6], [1])],
|
||||
[AC_MSG_NOTICE([disabling IPv6 support])])
|
||||
])
|
||||
|
||||
#
|
||||
# Checks for library functions.
|
||||
#
|
||||
#XXX remove alloca use
|
||||
AC_FUNC_ALLOCA
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_FORK
|
||||
AC_FUNC_FSEEKO
|
||||
AC_FUNC_STRCOLL
|
||||
AC_REPLACE_FUNCS([dirname err fgetln getaddrinfo getnameinfo \
|
||||
inet_ntop inet_pton mkstemp setprogname sl_init snprintf \
|
||||
strdup strerror strlcat strlcpy strptime strsep strunvis \
|
||||
strvis timegm usleep utimes])
|
||||
AC_CHECK_FUNCS([getcwd gethostbyaddr gethostbyname gethostbyname2 gethostname \
|
||||
getpass getpassphrase getpgrp gettimeofday isascii \
|
||||
memchr memmove memset realpath regcomp \
|
||||
select setlocale socket strcasecmp strchr strcspn strdup \
|
||||
strerror strncasecmp strpbrk strrchr strstr strtol strtoul \
|
||||
utime])
|
||||
AS_IF([test "$ac_cv_func_getpgrp" = yes], [AC_FUNC_GETPGRP])
|
||||
AS_IF([test "$ac_cv_func_strptime" = yes], [AC_CHECK_DECLS([strptime])])
|
||||
|
||||
# Always replace glob(); the vendor's may not be secure.
|
||||
#
|
||||
AC_LIBOBJ([glob])
|
||||
|
||||
# We assume that if sprintf() supports %lld or %qd,
|
||||
# then all of *printf() does. If not, disable long long
|
||||
# support because we don't know how to display it.
|
||||
#
|
||||
AS_IF([test "$ac_cv_type_long_long_int" = yes],
|
||||
[AC_MSG_CHECKING([*printf() support for %lld])
|
||||
can_printf_longlong=no
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
$accheck_includes
|
||||
]], [[
|
||||
char buf[100];
|
||||
sprintf(buf, "%lld", 4294967300LL);
|
||||
exit(0 != strcmp(buf, "4294967300"));
|
||||
]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
can_printf_longlong=yes],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([unknown - cross-compiling])])
|
||||
AS_IF([test "$can_printf_longlong" != yes],
|
||||
[AC_MSG_CHECKING([*printf() support for %qd])
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
$accheck_includes
|
||||
]], [[
|
||||
char buf[100];
|
||||
sprintf(buf, "%qd", 4294967300LL);
|
||||
exit(0 != strcmp(buf, "4294967300"));
|
||||
]])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
can_printf_longlong=yes
|
||||
AC_DEFINE([HAVE_PRINTF_QD], [1])],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([unknown - cross-compiling])])])
|
||||
AC_MSG_CHECKING([if *printf() can print long long ints])
|
||||
AS_IF([test "$can_printf_longlong" = yes],
|
||||
[AC_MSG_RESULT([yes])
|
||||
AC_DEFINE([HAVE_PRINTF_LONG_LONG], [1])
|
||||
AC_REPLACE_FUNCS([strtoll])],
|
||||
[AC_MSG_RESULT([no])])])
|
||||
|
||||
# Handle Darwin 7 having a poll() compatibility function,
|
||||
# and don't use it if it's emulated.
|
||||
# Be conservative, if we don't find one of poll.h or sys/poll.h,
|
||||
# don't attempt to use poll().
|
||||
#
|
||||
AC_CHECK_TYPES([struct pollfd], [], [], [$accheck_includes])
|
||||
AC_CHECK_FUNC([poll],
|
||||
[AC_CHECK_DECL([_POLL_EMUL_H_],
|
||||
[],
|
||||
[AC_DEFINE([HAVE_POLL], [1])],
|
||||
[$accheck_includes])])
|
||||
|
||||
AS_IF([test "$ac_cv_func_strptime" = yes],
|
||||
[AC_MSG_CHECKING([if strptime() needs separators between conversions])
|
||||
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
|
||||
$accheck_includes
|
||||
]], [[
|
||||
struct tm timebuf;
|
||||
char * res;
|
||||
memset(&timebuf, 0, sizeof(timebuf));
|
||||
res = strptime("20011122161900", "%Y%m%d%H%M%S", &timebuf);
|
||||
exit(!res);
|
||||
]])],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([yes - using local version])
|
||||
AC_LIBOBJ([strptime])],
|
||||
[AC_MSG_RESULT([unknown - cross-compiling])])])
|
||||
|
||||
# Use local libedit if editcomplete is requested
|
||||
#
|
||||
AS_IF([test "$opt_editcomplete" = yes],
|
||||
[AC_MSG_NOTICE([--enable-editcomplete; using internal libedit])],
|
||||
[CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"])
|
||||
|
||||
# Replace sl_init() (et al) if it provides the older API.
|
||||
#
|
||||
AS_IF([test "$ac_cv_func_sl_init" = yes],
|
||||
[AC_MSG_CHECKING([if sl_add() returns int])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stringlist.h>]],
|
||||
[[int f = sl_add((StringList *)0,
|
||||
"foo");]])],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_RESULT([no - using local version])
|
||||
AC_LIBOBJ([sl_init])],
|
||||
[AC_MSG_RESULT([unknown - cross-compiling])])])
|
||||
|
||||
# Replace getaddrinfo() if missing or AI_NUMERICHOST isn't declared.
|
||||
#
|
||||
AC_MSG_CHECKING([for working getaddrinfo()])
|
||||
AS_IF([test "$ac_cv_have_decl_AI_NUMERICHOST" = yes],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AS_IF([test "$ac_cv_func_getaddrinfo" = yes],
|
||||
[AC_LIBOBJ([getaddrinfo])
|
||||
AC_MSG_RESULT([no - using local version])],
|
||||
[AC_MSG_RESULT([using local version])])])
|
||||
|
||||
# Check for VIS_WHITE in <vis.h>
|
||||
#
|
||||
AS_IF([test "$ac_cv_header_vis_h" = yes],
|
||||
[AC_CHECK_DECL([VIS_WHITE], [], [], [
|
||||
#include <vis.h>
|
||||
])])
|
||||
|
||||
AM_CONDITIONAL([USE_LIBEDIT], [test "$opt_editcomplete" = yes])
|
||||
|
||||
#
|
||||
# Create the Makefiles.
|
||||
#
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
libedit/Makefile
|
||||
libedit/makelist
|
||||
libnetbsd/Makefile
|
||||
src/Makefile
|
||||
])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
# Display feature results.
|
||||
#
|
||||
AC_MSG_NOTICE([ === Configuration results ===])
|
||||
AC_MSG_NOTICE([Package: $PACKAGE_STRING])
|
||||
AC_MSG_NOTICE([Prefix: $prefix])
|
||||
AC_MSG_NOTICE([Command-line editing: $opt_editcomplete])
|
||||
AC_MSG_NOTICE([IPv6 support: $opt_ipv6])
|
||||
AC_MSG_NOTICE([SOCKS5 proxy support: $with_socks])
|
||||
AC_MSG_NOTICE([ =============================])
|
307
configure.in
307
configure.in
@ -1,307 +0,0 @@
|
||||
dnl $Id: configure.in,v 1.37 2002/06/10 08:08:53 lukem Exp $
|
||||
dnl
|
||||
dnl configure.in --
|
||||
dnl process this file with autoconf to produce a configure script.
|
||||
dnl
|
||||
|
||||
AC_REVISION($Revision: 1.37 $)dnl
|
||||
|
||||
AC_INIT(lukemftp.h)
|
||||
|
||||
dnl Arguments for which features are included
|
||||
dnl
|
||||
AC_ARG_PROGRAM
|
||||
AC_ARG_ENABLE(editcomplete, [\
|
||||
--enable-editcomplete Turn on command line editing and completion.
|
||||
--disable-editcomplete Turn off command line editing and completion
|
||||
[default: enabled].],
|
||||
opt_editcomplete=$enableval,
|
||||
opt_editcomplete=yes)
|
||||
AC_ARG_ENABLE(ipv6, [\
|
||||
--enable-ipv6 Enable IPv6 support (if your OS supports it).
|
||||
--disable-ipv6 Disable IPv6 support (even if your OS supports it)
|
||||
[default: enabled].],
|
||||
opt_ipv6=$enableval,
|
||||
opt_ipv6=yes)
|
||||
|
||||
dnl Checks for programs.
|
||||
dnl
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_RANLIB
|
||||
AC_CHECK_PROGS(AR, ar)
|
||||
AC_AIX
|
||||
|
||||
|
||||
dnl Checks for libraries.
|
||||
dnl
|
||||
AC_CHECK_LIB(util, fparseln)
|
||||
if test $opt_editcomplete = yes; then
|
||||
AC_CHECK_LIB(tinfo, tgetent, ,
|
||||
AC_CHECK_LIB(termcap, tgetent, ,
|
||||
AC_CHECK_LIB(curses, tgetent, ,
|
||||
AC_CHECK_LIB(ncurses, tgetent))))
|
||||
AC_SEARCH_LIBS(el_init, edit, have_libedit=yes, have_libedit=no)
|
||||
fi
|
||||
AC_LIBRARY_NET
|
||||
AC_LIBRARY_SOCKS
|
||||
if test -n "$socks"; then
|
||||
if test $opt_ipv6 = yes; then
|
||||
echo "IPv6 is incompatible with socks, disabling IPv6 support"
|
||||
opt_ipv6=no
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
dnl Checks for header files.
|
||||
dnl
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(arpa/nameser.h err.h regex.h paths.h poll.h sys/poll.h \
|
||||
termcap.h util.h libutil.h vis.h)
|
||||
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
dnl
|
||||
AC_HEADER_TIME
|
||||
AC_TYPE_OFF_T
|
||||
AC_CHECK_SIZEOF(off_t, 0)
|
||||
AC_MSG_TRY_LINK(for long long, ftp_cv_HAVE_LONG_LONG, [
|
||||
#include <sys/types.h>] , [
|
||||
long long X = 2, Y = 1, Z;
|
||||
Z = X / Y; ], [
|
||||
AC_DEFINE(HAVE_LONG_LONG, 1)
|
||||
have_long_long=yes], [have_long_long=no])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for in_port_t, ftp_cv_HAVE_IN_PORT_T, [
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h> ], [ in_port_t X ], [AC_DEFINE(HAVE_IN_PORT_T, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for sa_family_t, ftp_cv_HAVE_SA_FAMILY_T, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> ], [ sa_family_t X ], [AC_DEFINE(HAVE_SA_FAMILY_T, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ftp_cv_HAVE_SOCKADDR_SA_LEN, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h> ], [
|
||||
struct sockaddr_in sin;
|
||||
int X = sin.sin_len ], [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for socklen_t, ftp_cv_HAVE_SOCKLEN_T, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> ], [ socklen_t X ], [AC_DEFINE(HAVE_SOCKLEN_T, 1)])
|
||||
|
||||
if test $opt_ipv6 = yes; then
|
||||
|
||||
AC_MSG_TRY_COMPILE(for AF_INET6, ftp_cv_HAVE_AF_INET6, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h> ],
|
||||
[ int X = AF_INET6 ], [AC_DEFINE(HAVE_AF_INET6, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for struct sockaddr_in6, ftp_cv_HAVE_SOCKADDR_IN6, [
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h> ],
|
||||
[ struct sockaddr_in6 X ], [AC_DEFINE(HAVE_SOCKADDR_IN6, 1)])
|
||||
|
||||
fi
|
||||
|
||||
AC_MSG_TRY_COMPILE(for struct addrinfo, ftp_cv_HAVE_ADDRINFO, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h> ],
|
||||
[ struct addrinfo X ], [AC_DEFINE(HAVE_ADDRINFO, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for d_namlen in struct dirent, ftp_cv_HAVE_D_NAMLEN, [
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else
|
||||
# define dirent direct
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif ], [
|
||||
struct dirent dp;
|
||||
int X = dp.d_namlen; ], [AC_DEFINE(HAVE_D_NAMLEN, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for h_errno declaration, ftp_cv_HAVE_H_ERRNO_D, [
|
||||
#include <netdb.h> ], [ int X = h_errno ], [AC_DEFINE(HAVE_H_ERRNO_D, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for fclose() declaration, ftp_cv_HAVE_FCLOSE_D, [
|
||||
#include <stdio.h> ], [ int (*X)() = fclose ], [AC_DEFINE(HAVE_FCLOSE_D, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for getpass() declaration, ftp_cv_HAVE_GETPASS_D, [
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> ], [ char *(*X)() = getpass ], [
|
||||
AC_DEFINE(HAVE_GETPASS_D, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for optarg declaration, ftp_cv_HAVE_OPTARG_D, [
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> ], [ char *X = optarg ], [AC_DEFINE(HAVE_OPTARG_D, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for optind declaration, ftp_cv_HAVE_OPTIND_D, [
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> ], [ int X = optind ], [AC_DEFINE(HAVE_OPTIND_D, 1)])
|
||||
|
||||
AC_MSG_TRY_COMPILE(for pclose() declaration, ftp_cv_HAVE_PCLOSE_D, [
|
||||
#include <stdio.h> ], [ int (*X)() = pclose ], [AC_DEFINE(HAVE_PCLOSE_D, 1)])
|
||||
|
||||
|
||||
dnl Checks for library functions.
|
||||
dnl
|
||||
AC_REPLACE_FUNCS(err fgetln fseeko getaddrinfo getnameinfo inet_ntop inet_pton \
|
||||
mkstemp setprogname sl_init snprintf strdup strerror strlcat \
|
||||
strlcpy strptime strsep strunvis strvis timegm usleep)
|
||||
AC_CHECK_FUNCS(gethostbyname2 getpassphrase getpgrp memmove poll select)
|
||||
if test $ac_cv_func_getpgrp = yes; then
|
||||
AC_FUNC_GETPGRP
|
||||
fi
|
||||
if test $ac_cv_lib_util_fparseln != yes; then
|
||||
AC_REPLACE_FUNCS(fparseln)
|
||||
fi
|
||||
|
||||
LIBOBJS="$LIBOBJS glob.o"
|
||||
|
||||
if test $ac_cv_func_strptime = yes; then
|
||||
AC_MSG_TRY_COMPILE(for strptime() declaration, ftp_cv_HAVE_STRPTIME_D, [
|
||||
#include <time.h> ], [ char *X = strptime("", "", NULL) ],
|
||||
[AC_DEFINE(HAVE_STRPTIME_D, 1)])
|
||||
fi
|
||||
|
||||
if test $have_long_long = yes -a $ac_cv_sizeof_off_t -ge 8; then
|
||||
|
||||
dnl We assume that if sprintf() supports %lld or %qd,
|
||||
dnl then all of *printf() does. If not, disable long long
|
||||
dnl support because we don't know how to display it.
|
||||
|
||||
AC_MSG_CHECKING(*printf() support for %lld)
|
||||
can_printf_longlong=no
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
char buf[100];
|
||||
sprintf(buf, "%lld", 4294967300LL);
|
||||
return (strcmp(buf, "4294967300"));
|
||||
}
|
||||
], [
|
||||
AC_MSG_RESULT(yes)
|
||||
can_printf_longlong=yes
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
], [ : ])
|
||||
|
||||
if test $can_printf_longlong != yes; then
|
||||
AC_MSG_CHECKING(*printf() support for %qd)
|
||||
AC_TRY_RUN([
|
||||
#include <stdio.h>
|
||||
int main() {
|
||||
char buf[100];
|
||||
sprintf(buf, "%qd", 4294967300LL);
|
||||
return (strcmp(buf, "4294967300"));
|
||||
}
|
||||
], [
|
||||
AC_MSG_RESULT(yes)
|
||||
can_printf_longlong=yes
|
||||
AC_DEFINE(HAVE_PRINTF_QD, 1)
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
], [ : ])
|
||||
fi
|
||||
|
||||
if test $can_printf_longlong = yes; then
|
||||
AC_DEFINE(HAVE_QUAD_SUPPORT, 1)
|
||||
AC_REPLACE_FUNCS(strtoll)
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
|
||||
if test $opt_editcomplete = yes; then
|
||||
if test $have_libedit = yes; then
|
||||
AC_MSG_TRY_COMPILE(for EL_RPROMPT in libedit,
|
||||
ftp_cv_have_libedit, [
|
||||
#include <histedit.h> ], [ int X = EL_RPROMPT ], [:],
|
||||
have_libedit=no )
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING(for working libedit)
|
||||
if test $have_libedit = no; then
|
||||
AC_MSG_RESULT(no - using my own)
|
||||
INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
|
||||
LDFLAGS="-L../libedit $LDFLAGS"
|
||||
LIBS="-ledit $LIBS"
|
||||
LIBEDIT=libedit.a
|
||||
LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"
|
||||
else
|
||||
AC_MSG_RESULT(yes)
|
||||
fi
|
||||
else
|
||||
CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"
|
||||
fi
|
||||
|
||||
if test $ac_cv_func_sl_init = yes; then
|
||||
AC_MSG_TRY_COMPILE(if sl_add() returns int, ftp_cv_INT_SL_ADD, [
|
||||
#include <stringlist.h> ], [ int f = sl_add((StringList *)0, "foo") ],
|
||||
[:] , [LIBOBJS="$LIBOBJS sl_init.o"])
|
||||
fi
|
||||
|
||||
|
||||
have_rfc2553_netdb=no
|
||||
if test $ac_cv_func_getaddrinfo = yes -a ! -n "$socks"; then
|
||||
AC_MSG_TRY_COMPILE(for AI_NUMERICHOST,
|
||||
ftp_cv_have_ai_numerichost, [
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h> ],
|
||||
[ int X = AI_NUMERICHOST ], [ have_rfc2553_netdb=yes ])
|
||||
fi
|
||||
AC_MSG_CHECKING(for working getaddrinfo())
|
||||
if test $have_rfc2553_netdb = yes; then
|
||||
AC_DEFINE(HAVE_RFC2553_NETDB, 1)
|
||||
AC_MSG_RESULT(yes)
|
||||
else
|
||||
if test $ac_cv_func_getaddrinfo = yes; then
|
||||
LIBOBJS="$LIBOBJS getaddrinfo.o"
|
||||
AC_MSG_RESULT(no - using local version)
|
||||
else
|
||||
AC_MSG_RESULT(using local version)
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if test $ac_cv_header_vis_h = yes; then
|
||||
AC_MSG_TRY_COMPILE(for VIS_WHITE in vis.h,
|
||||
ftp_cv_have_vis_white, [
|
||||
#include <sys/types.h>
|
||||
#include <vis.h> ], [ int X = VIS_WHITE ], [:],
|
||||
ac_cv_header_vis_h=no )
|
||||
fi
|
||||
|
||||
|
||||
if test -n "$LIBOBJS"; then
|
||||
INCLUDES="$INCLUDES -I\${srcdir}/../libukem"
|
||||
LDFLAGS="$LDFLAGS -L../libukem"
|
||||
LIBS="$LIBS -lukem"
|
||||
LIBUKEM=libukem.a
|
||||
LIBDEPENDS="$LIBDEPENDS ../libukem/libukem.a"
|
||||
fi
|
||||
|
||||
dnl Create the Makefiles
|
||||
dnl
|
||||
|
||||
AC_SUBST(INCLUDES)
|
||||
AC_SUBST(LIBEDIT)
|
||||
AC_SUBST(LIBUKEM)
|
||||
AC_SUBST(LIBDEPENDS)
|
||||
|
||||
AC_OUTPUT(Makefile libedit/Makefile libedit/makelist libukem/Makefile \
|
||||
src/Makefile)
|
104
libedit/Makefile.am
Normal file
104
libedit/Makefile.am
Normal file
@ -0,0 +1,104 @@
|
||||
## $NetBSD: Makefile.am,v 1.3 2010/01/05 07:15:58 lukem Exp $
|
||||
|
||||
noinst_LTLIBRARIES = libedit.la
|
||||
|
||||
libedit_la_SOURCES = \
|
||||
chared.c \
|
||||
common.c \
|
||||
el.c \
|
||||
emacs.c \
|
||||
hist.c \
|
||||
history.c \
|
||||
key.c \
|
||||
map.c \
|
||||
parse.c \
|
||||
prompt.c \
|
||||
read.c \
|
||||
refresh.c \
|
||||
search.c \
|
||||
sig.c \
|
||||
term.c \
|
||||
tokenizer.c \
|
||||
tty.c \
|
||||
vi.c
|
||||
|
||||
libedit_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir)/libnetbsd \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)
|
||||
|
||||
libedit_la_LIBADD = \
|
||||
$(top_builddir)/libnetbsd/libnetbsd.la
|
||||
|
||||
generated_files = \
|
||||
common.h \
|
||||
emacs.h \
|
||||
fcns.c \
|
||||
fcns.h \
|
||||
help.c \
|
||||
help.h\
|
||||
vi.h
|
||||
|
||||
nodist_libedit_la_SOURCES = \
|
||||
$(generated_files)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generated_files)
|
||||
|
||||
CLEANFILES = \
|
||||
$(generated_files)
|
||||
|
||||
|
||||
|
||||
vi.h: vi.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/vi.c > $@
|
||||
|
||||
emacs.h: emacs.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/emacs.c > $@
|
||||
|
||||
common.h: common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/common.c > $@
|
||||
|
||||
fcns.h: vi.h emacs.h common.h
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -fh vi.h emacs.h common.h > $@
|
||||
|
||||
fcns.c: vi.h emacs.h common.h fcns.h
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -fc vi.h emacs.h common.h > $@
|
||||
|
||||
help.c: vi.c emacs.c common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -bc $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c > $@
|
||||
|
||||
help.h: vi.c emacs.c common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -bh $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c > $@
|
||||
|
||||
EXTRA_DIST = \
|
||||
chared.h \
|
||||
editline.3 \
|
||||
editrc.5 \
|
||||
el.h \
|
||||
filecomplete.c \
|
||||
filecomplete.h \
|
||||
hist.h \
|
||||
histedit.h \
|
||||
key.h \
|
||||
map.h \
|
||||
parse.h \
|
||||
prompt.h \
|
||||
read.h \
|
||||
readline.c \
|
||||
readline/readline.h \
|
||||
refresh.h \
|
||||
search.h \
|
||||
sig.h \
|
||||
sys.h \
|
||||
term.h \
|
||||
tty.h
|
778
libedit/Makefile.in
Normal file
778
libedit/Makefile.in
Normal file
@ -0,0 +1,778 @@
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = libedit
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
|
||||
$(srcdir)/makelist.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/tnftp_config.h
|
||||
CONFIG_CLEAN_FILES = makelist
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libedit_la_DEPENDENCIES = $(top_builddir)/libnetbsd/libnetbsd.la
|
||||
am_libedit_la_OBJECTS = libedit_la-chared.lo libedit_la-common.lo \
|
||||
libedit_la-el.lo libedit_la-emacs.lo libedit_la-hist.lo \
|
||||
libedit_la-history.lo libedit_la-key.lo libedit_la-map.lo \
|
||||
libedit_la-parse.lo libedit_la-prompt.lo libedit_la-read.lo \
|
||||
libedit_la-refresh.lo libedit_la-search.lo libedit_la-sig.lo \
|
||||
libedit_la-term.lo libedit_la-tokenizer.lo libedit_la-tty.lo \
|
||||
libedit_la-vi.lo
|
||||
am__objects_1 = libedit_la-fcns.lo libedit_la-help.lo
|
||||
nodist_libedit_la_OBJECTS = $(am__objects_1)
|
||||
libedit_la_OBJECTS = $(am_libedit_la_OBJECTS) \
|
||||
$(nodist_libedit_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/buildaux/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_$(V))
|
||||
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
AM_V_at = $(am__v_at_$(V))
|
||||
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_at_0 = @
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_$(V))
|
||||
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
AM_V_GEN = $(am__v_GEN_$(V))
|
||||
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
SOURCES = $(libedit_la_SOURCES) $(nodist_libedit_la_SOURCES)
|
||||
DIST_SOURCES = $(libedit_la_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
noinst_LTLIBRARIES = libedit.la
|
||||
libedit_la_SOURCES = \
|
||||
chared.c \
|
||||
common.c \
|
||||
el.c \
|
||||
emacs.c \
|
||||
hist.c \
|
||||
history.c \
|
||||
key.c \
|
||||
map.c \
|
||||
parse.c \
|
||||
prompt.c \
|
||||
read.c \
|
||||
refresh.c \
|
||||
search.c \
|
||||
sig.c \
|
||||
term.c \
|
||||
tokenizer.c \
|
||||
tty.c \
|
||||
vi.c
|
||||
|
||||
libedit_la_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir)/libnetbsd \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)
|
||||
|
||||
libedit_la_LIBADD = \
|
||||
$(top_builddir)/libnetbsd/libnetbsd.la
|
||||
|
||||
generated_files = \
|
||||
common.h \
|
||||
emacs.h \
|
||||
fcns.c \
|
||||
fcns.h \
|
||||
help.c \
|
||||
help.h\
|
||||
vi.h
|
||||
|
||||
nodist_libedit_la_SOURCES = \
|
||||
$(generated_files)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
$(generated_files)
|
||||
|
||||
CLEANFILES = \
|
||||
$(generated_files)
|
||||
|
||||
EXTRA_DIST = \
|
||||
chared.h \
|
||||
editline.3 \
|
||||
editrc.5 \
|
||||
el.h \
|
||||
filecomplete.c \
|
||||
filecomplete.h \
|
||||
hist.h \
|
||||
histedit.h \
|
||||
key.h \
|
||||
map.h \
|
||||
parse.h \
|
||||
prompt.h \
|
||||
read.h \
|
||||
readline.c \
|
||||
readline/readline.h \
|
||||
refresh.h \
|
||||
search.h \
|
||||
sig.h \
|
||||
sys.h \
|
||||
term.h \
|
||||
tty.h
|
||||
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libedit/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign libedit/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
makelist: $(top_builddir)/config.status $(srcdir)/makelist.in
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libedit.la: $(libedit_la_OBJECTS) $(libedit_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(LINK) $(libedit_la_OBJECTS) $(libedit_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-chared.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-common.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-el.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-emacs.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-fcns.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-help.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-hist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-history.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-key.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-map.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-parse.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-prompt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-read.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-refresh.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-search.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-sig.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-term.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-tokenizer.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-tty.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libedit_la-vi.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
libedit_la-chared.lo: chared.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-chared.lo -MD -MP -MF $(DEPDIR)/libedit_la-chared.Tpo -c -o libedit_la-chared.lo `test -f 'chared.c' || echo '$(srcdir)/'`chared.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-chared.Tpo $(DEPDIR)/libedit_la-chared.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='chared.c' object='libedit_la-chared.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-chared.lo `test -f 'chared.c' || echo '$(srcdir)/'`chared.c
|
||||
|
||||
libedit_la-common.lo: common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-common.lo -MD -MP -MF $(DEPDIR)/libedit_la-common.Tpo -c -o libedit_la-common.lo `test -f 'common.c' || echo '$(srcdir)/'`common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-common.Tpo $(DEPDIR)/libedit_la-common.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='common.c' object='libedit_la-common.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-common.lo `test -f 'common.c' || echo '$(srcdir)/'`common.c
|
||||
|
||||
libedit_la-el.lo: el.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-el.lo -MD -MP -MF $(DEPDIR)/libedit_la-el.Tpo -c -o libedit_la-el.lo `test -f 'el.c' || echo '$(srcdir)/'`el.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-el.Tpo $(DEPDIR)/libedit_la-el.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='el.c' object='libedit_la-el.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-el.lo `test -f 'el.c' || echo '$(srcdir)/'`el.c
|
||||
|
||||
libedit_la-emacs.lo: emacs.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-emacs.lo -MD -MP -MF $(DEPDIR)/libedit_la-emacs.Tpo -c -o libedit_la-emacs.lo `test -f 'emacs.c' || echo '$(srcdir)/'`emacs.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-emacs.Tpo $(DEPDIR)/libedit_la-emacs.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='emacs.c' object='libedit_la-emacs.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-emacs.lo `test -f 'emacs.c' || echo '$(srcdir)/'`emacs.c
|
||||
|
||||
libedit_la-hist.lo: hist.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-hist.lo -MD -MP -MF $(DEPDIR)/libedit_la-hist.Tpo -c -o libedit_la-hist.lo `test -f 'hist.c' || echo '$(srcdir)/'`hist.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-hist.Tpo $(DEPDIR)/libedit_la-hist.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='hist.c' object='libedit_la-hist.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-hist.lo `test -f 'hist.c' || echo '$(srcdir)/'`hist.c
|
||||
|
||||
libedit_la-history.lo: history.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-history.lo -MD -MP -MF $(DEPDIR)/libedit_la-history.Tpo -c -o libedit_la-history.lo `test -f 'history.c' || echo '$(srcdir)/'`history.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-history.Tpo $(DEPDIR)/libedit_la-history.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='history.c' object='libedit_la-history.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-history.lo `test -f 'history.c' || echo '$(srcdir)/'`history.c
|
||||
|
||||
libedit_la-key.lo: key.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-key.lo -MD -MP -MF $(DEPDIR)/libedit_la-key.Tpo -c -o libedit_la-key.lo `test -f 'key.c' || echo '$(srcdir)/'`key.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-key.Tpo $(DEPDIR)/libedit_la-key.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='key.c' object='libedit_la-key.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-key.lo `test -f 'key.c' || echo '$(srcdir)/'`key.c
|
||||
|
||||
libedit_la-map.lo: map.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-map.lo -MD -MP -MF $(DEPDIR)/libedit_la-map.Tpo -c -o libedit_la-map.lo `test -f 'map.c' || echo '$(srcdir)/'`map.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-map.Tpo $(DEPDIR)/libedit_la-map.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='map.c' object='libedit_la-map.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-map.lo `test -f 'map.c' || echo '$(srcdir)/'`map.c
|
||||
|
||||
libedit_la-parse.lo: parse.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-parse.lo -MD -MP -MF $(DEPDIR)/libedit_la-parse.Tpo -c -o libedit_la-parse.lo `test -f 'parse.c' || echo '$(srcdir)/'`parse.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-parse.Tpo $(DEPDIR)/libedit_la-parse.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='parse.c' object='libedit_la-parse.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-parse.lo `test -f 'parse.c' || echo '$(srcdir)/'`parse.c
|
||||
|
||||
libedit_la-prompt.lo: prompt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-prompt.lo -MD -MP -MF $(DEPDIR)/libedit_la-prompt.Tpo -c -o libedit_la-prompt.lo `test -f 'prompt.c' || echo '$(srcdir)/'`prompt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-prompt.Tpo $(DEPDIR)/libedit_la-prompt.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='prompt.c' object='libedit_la-prompt.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-prompt.lo `test -f 'prompt.c' || echo '$(srcdir)/'`prompt.c
|
||||
|
||||
libedit_la-read.lo: read.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-read.lo -MD -MP -MF $(DEPDIR)/libedit_la-read.Tpo -c -o libedit_la-read.lo `test -f 'read.c' || echo '$(srcdir)/'`read.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-read.Tpo $(DEPDIR)/libedit_la-read.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='read.c' object='libedit_la-read.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-read.lo `test -f 'read.c' || echo '$(srcdir)/'`read.c
|
||||
|
||||
libedit_la-refresh.lo: refresh.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-refresh.lo -MD -MP -MF $(DEPDIR)/libedit_la-refresh.Tpo -c -o libedit_la-refresh.lo `test -f 'refresh.c' || echo '$(srcdir)/'`refresh.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-refresh.Tpo $(DEPDIR)/libedit_la-refresh.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='refresh.c' object='libedit_la-refresh.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-refresh.lo `test -f 'refresh.c' || echo '$(srcdir)/'`refresh.c
|
||||
|
||||
libedit_la-search.lo: search.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-search.lo -MD -MP -MF $(DEPDIR)/libedit_la-search.Tpo -c -o libedit_la-search.lo `test -f 'search.c' || echo '$(srcdir)/'`search.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-search.Tpo $(DEPDIR)/libedit_la-search.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='search.c' object='libedit_la-search.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-search.lo `test -f 'search.c' || echo '$(srcdir)/'`search.c
|
||||
|
||||
libedit_la-sig.lo: sig.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-sig.lo -MD -MP -MF $(DEPDIR)/libedit_la-sig.Tpo -c -o libedit_la-sig.lo `test -f 'sig.c' || echo '$(srcdir)/'`sig.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-sig.Tpo $(DEPDIR)/libedit_la-sig.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='sig.c' object='libedit_la-sig.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-sig.lo `test -f 'sig.c' || echo '$(srcdir)/'`sig.c
|
||||
|
||||
libedit_la-term.lo: term.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-term.lo -MD -MP -MF $(DEPDIR)/libedit_la-term.Tpo -c -o libedit_la-term.lo `test -f 'term.c' || echo '$(srcdir)/'`term.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-term.Tpo $(DEPDIR)/libedit_la-term.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='term.c' object='libedit_la-term.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-term.lo `test -f 'term.c' || echo '$(srcdir)/'`term.c
|
||||
|
||||
libedit_la-tokenizer.lo: tokenizer.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-tokenizer.lo -MD -MP -MF $(DEPDIR)/libedit_la-tokenizer.Tpo -c -o libedit_la-tokenizer.lo `test -f 'tokenizer.c' || echo '$(srcdir)/'`tokenizer.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-tokenizer.Tpo $(DEPDIR)/libedit_la-tokenizer.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tokenizer.c' object='libedit_la-tokenizer.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-tokenizer.lo `test -f 'tokenizer.c' || echo '$(srcdir)/'`tokenizer.c
|
||||
|
||||
libedit_la-tty.lo: tty.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-tty.lo -MD -MP -MF $(DEPDIR)/libedit_la-tty.Tpo -c -o libedit_la-tty.lo `test -f 'tty.c' || echo '$(srcdir)/'`tty.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-tty.Tpo $(DEPDIR)/libedit_la-tty.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='tty.c' object='libedit_la-tty.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-tty.lo `test -f 'tty.c' || echo '$(srcdir)/'`tty.c
|
||||
|
||||
libedit_la-vi.lo: vi.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-vi.lo -MD -MP -MF $(DEPDIR)/libedit_la-vi.Tpo -c -o libedit_la-vi.lo `test -f 'vi.c' || echo '$(srcdir)/'`vi.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-vi.Tpo $(DEPDIR)/libedit_la-vi.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='vi.c' object='libedit_la-vi.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-vi.lo `test -f 'vi.c' || echo '$(srcdir)/'`vi.c
|
||||
|
||||
libedit_la-fcns.lo: fcns.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-fcns.lo -MD -MP -MF $(DEPDIR)/libedit_la-fcns.Tpo -c -o libedit_la-fcns.lo `test -f 'fcns.c' || echo '$(srcdir)/'`fcns.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-fcns.Tpo $(DEPDIR)/libedit_la-fcns.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fcns.c' object='libedit_la-fcns.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-fcns.lo `test -f 'fcns.c' || echo '$(srcdir)/'`fcns.c
|
||||
|
||||
libedit_la-help.lo: help.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libedit_la-help.lo -MD -MP -MF $(DEPDIR)/libedit_la-help.Tpo -c -o libedit_la-help.lo `test -f 'help.c' || echo '$(srcdir)/'`help.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libedit_la-help.Tpo $(DEPDIR)/libedit_la-help.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='help.c' object='libedit_la-help.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libedit_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libedit_la-help.lo `test -f 'help.c' || echo '$(srcdir)/'`help.c
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: all check install install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags uninstall uninstall-am
|
||||
|
||||
|
||||
vi.h: vi.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/vi.c > $@
|
||||
|
||||
emacs.h: emacs.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/emacs.c > $@
|
||||
|
||||
common.h: common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -h $(srcdir)/common.c > $@
|
||||
|
||||
fcns.h: vi.h emacs.h common.h
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -fh vi.h emacs.h common.h > $@
|
||||
|
||||
fcns.c: vi.h emacs.h common.h fcns.h
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -fc vi.h emacs.h common.h > $@
|
||||
|
||||
help.c: vi.c emacs.c common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -bc $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c > $@
|
||||
|
||||
help.h: vi.c emacs.c common.c
|
||||
@echo "Create $@"
|
||||
$(SHELL) ./makelist -bh $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c > $@
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
759
libedit/chared.c
Normal file
759
libedit/chared.c
Normal file
@ -0,0 +1,759 @@
|
||||
/* $NetBSD: chared.c,v 1.6 2005/06/09 16:48:57 lukem Exp $ */
|
||||
/* from NetBSD: chared.c,v 1.22 2004/08/13 12:10:38 mycroft Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* chared.c: Character editor utilities
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
/* value to leave unused in line buffer */
|
||||
#define EL_LEAVE 2
|
||||
|
||||
/* cv_undo():
|
||||
* Handle state for the vi undo command
|
||||
*/
|
||||
protected void
|
||||
cv_undo(EditLine *el)
|
||||
{
|
||||
c_undo_t *vu = &el->el_chared.c_undo;
|
||||
c_redo_t *r = &el->el_chared.c_redo;
|
||||
unsigned int size;
|
||||
|
||||
/* Save entire line for undo */
|
||||
size = el->el_line.lastchar - el->el_line.buffer;
|
||||
vu->len = size;
|
||||
vu->cursor = el->el_line.cursor - el->el_line.buffer;
|
||||
memcpy(vu->buf, el->el_line.buffer, size);
|
||||
|
||||
/* save command info for redo */
|
||||
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
|
||||
r->action = el->el_chared.c_vcmd.action;
|
||||
r->pos = r->buf;
|
||||
r->cmd = el->el_state.thiscmd;
|
||||
r->ch = el->el_state.thisch;
|
||||
}
|
||||
|
||||
/* cv_yank():
|
||||
* Save yank/delete data for paste
|
||||
*/
|
||||
protected void
|
||||
cv_yank(EditLine *el, const char *ptr, int size)
|
||||
{
|
||||
c_kill_t *k = &el->el_chared.c_kill;
|
||||
|
||||
memcpy(k->buf, ptr, size +0u);
|
||||
k->last = k->buf + size;
|
||||
}
|
||||
|
||||
|
||||
/* c_insert():
|
||||
* Insert num characters
|
||||
*/
|
||||
protected void
|
||||
c_insert(EditLine *el, int num)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (el->el_line.lastchar + num >= el->el_line.limit) {
|
||||
if (!ch_enlargebufs(el, num +0u))
|
||||
return; /* can't go past end of buffer */
|
||||
}
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
/* if I must move chars */
|
||||
for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
|
||||
cp[num] = *cp;
|
||||
}
|
||||
el->el_line.lastchar += num;
|
||||
}
|
||||
|
||||
|
||||
/* c_delafter():
|
||||
* Delete num characters after the cursor
|
||||
*/
|
||||
protected void
|
||||
c_delafter(EditLine *el, int num)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor + num > el->el_line.lastchar)
|
||||
num = el->el_line.lastchar - el->el_line.cursor;
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
cv_yank(el, el->el_line.cursor, num);
|
||||
}
|
||||
|
||||
if (num > 0) {
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[num];
|
||||
|
||||
el->el_line.lastchar -= num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* c_delafter1():
|
||||
* Delete the character after the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delafter1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore():
|
||||
* Delete num characters before the cursor
|
||||
*/
|
||||
protected void
|
||||
c_delbefore(EditLine *el, int num)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor - num < el->el_line.buffer)
|
||||
num = el->el_line.cursor - el->el_line.buffer;
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
cv_yank(el, el->el_line.cursor - num, num);
|
||||
}
|
||||
|
||||
if (num > 0) {
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor - num;
|
||||
cp <= el->el_line.lastchar;
|
||||
cp++)
|
||||
*cp = cp[num];
|
||||
|
||||
el->el_line.lastchar -= num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore1():
|
||||
* Delete the character before the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delbefore1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* ce__isword():
|
||||
* Return if p is part of a word according to emacs
|
||||
*/
|
||||
protected int
|
||||
ce__isword(int p)
|
||||
{
|
||||
return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
|
||||
}
|
||||
|
||||
|
||||
/* cv__isword():
|
||||
* Return if p is part of a word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isword(int p)
|
||||
{
|
||||
if (isalnum(p) || p == '_')
|
||||
return 1;
|
||||
if (isgraph(p))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* cv__isWord():
|
||||
* Return if p is part of a big word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isWord(int p)
|
||||
{
|
||||
return (!isspace(p));
|
||||
}
|
||||
|
||||
|
||||
/* c__prev_word():
|
||||
* Find the previous word
|
||||
*/
|
||||
protected char *
|
||||
c__prev_word(char *p, char *low, int n, int (*wtest)(int))
|
||||
{
|
||||
p--;
|
||||
|
||||
while (n--) {
|
||||
while ((p >= low) && !(*wtest)((unsigned char) *p))
|
||||
p--;
|
||||
while ((p >= low) && (*wtest)((unsigned char) *p))
|
||||
p--;
|
||||
}
|
||||
|
||||
/* cp now points to one character before the word */
|
||||
p++;
|
||||
if (p < low)
|
||||
p = low;
|
||||
/* cp now points where we want it */
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* c__next_word():
|
||||
* Find the next word
|
||||
*/
|
||||
protected char *
|
||||
c__next_word(char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
while (n--) {
|
||||
while ((p < high) && !(*wtest)((unsigned char) *p))
|
||||
p++;
|
||||
while ((p < high) && (*wtest)((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
if (p > high)
|
||||
p = high;
|
||||
/* p now points where we want it */
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* cv_next_word():
|
||||
* Find the next word vi style
|
||||
*/
|
||||
protected char *
|
||||
cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
while (n--) {
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p < high) && (*wtest)((unsigned char) *p) == test)
|
||||
p++;
|
||||
/*
|
||||
* vi historically deletes with cw only the word preserving the
|
||||
* trailing whitespace! This is not what 'w' does..
|
||||
*/
|
||||
if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
|
||||
/* p now points where we want it */
|
||||
if (p > high)
|
||||
return (high);
|
||||
else
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* cv_prev_word():
|
||||
* Find the previous word vi style
|
||||
*/
|
||||
protected char *
|
||||
cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
p--;
|
||||
while (n--) {
|
||||
while ((p > low) && isspace((unsigned char) *p))
|
||||
p--;
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p >= low) && (*wtest)((unsigned char) *p) == test)
|
||||
p--;
|
||||
}
|
||||
p++;
|
||||
|
||||
/* p now points where we want it */
|
||||
if (p < low)
|
||||
return (low);
|
||||
else
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/* c__number():
|
||||
* Ignore character p points to, return number appearing after that.
|
||||
* A '$' by itself means a big number; "$-" is for negative; '^' means 1.
|
||||
* Return p pointing to last char used.
|
||||
*/
|
||||
protected char *
|
||||
c__number(
|
||||
char *p, /* character position */
|
||||
int *num, /* Return value */
|
||||
int dval) /* dval is the number to subtract from like $-3 */
|
||||
{
|
||||
int i;
|
||||
int sign = 1;
|
||||
|
||||
if (*++p == '^') {
|
||||
*num = 1;
|
||||
return (p);
|
||||
}
|
||||
if (*p == '$') {
|
||||
if (*++p != '-') {
|
||||
*num = 0x7fffffff; /* Handle $ */
|
||||
return (--p);
|
||||
}
|
||||
sign = -1; /* Handle $- */
|
||||
++p;
|
||||
}
|
||||
for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
|
||||
continue;
|
||||
*num = (sign < 0 ? dval - i : i);
|
||||
return (--p);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* cv_delfini():
|
||||
* Finish vi delete action
|
||||
*/
|
||||
protected void
|
||||
cv_delfini(EditLine *el)
|
||||
{
|
||||
int size;
|
||||
int action = el->el_chared.c_vcmd.action;
|
||||
|
||||
if (action & INSERT)
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
if (el->el_chared.c_vcmd.pos == 0)
|
||||
/* sanity */
|
||||
return;
|
||||
|
||||
size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
el->el_line.cursor = el->el_chared.c_vcmd.pos;
|
||||
if (action & YANK) {
|
||||
if (size > 0)
|
||||
cv_yank(el, el->el_line.cursor, size);
|
||||
else
|
||||
cv_yank(el, el->el_line.cursor + size, -size);
|
||||
} else {
|
||||
if (size > 0) {
|
||||
c_delafter(el, size);
|
||||
re_refresh_cursor(el);
|
||||
} else {
|
||||
c_delbefore(el, -size);
|
||||
el->el_line.cursor += size;
|
||||
}
|
||||
}
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/* ce__endword():
|
||||
* Go to the end of this word according to emacs
|
||||
*/
|
||||
protected char *
|
||||
ce__endword(char *p, char *high, int n)
|
||||
{
|
||||
p++;
|
||||
|
||||
while (n--) {
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
while ((p < high) && !isspace((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
|
||||
p--;
|
||||
return (p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* cv__endword():
|
||||
* Go to the end of this word according to vi
|
||||
*/
|
||||
protected char *
|
||||
cv__endword(char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
p++;
|
||||
|
||||
while (n--) {
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p < high) && (*wtest)((unsigned char) *p) == test)
|
||||
p++;
|
||||
}
|
||||
p--;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* ch_init():
|
||||
* Initialize the character editor
|
||||
*/
|
||||
protected int
|
||||
ch_init(EditLine *el)
|
||||
{
|
||||
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_line.buffer == NULL)
|
||||
return (-1);
|
||||
|
||||
(void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE];
|
||||
|
||||
el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_undo.buf == NULL)
|
||||
return (-1);
|
||||
(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
|
||||
el->el_chared.c_undo.len = -1;
|
||||
el->el_chared.c_undo.cursor = 0;
|
||||
el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_redo.buf == NULL)
|
||||
return (-1);
|
||||
el->el_chared.c_redo.pos = el->el_chared.c_redo.buf;
|
||||
el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ;
|
||||
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_vcmd.pos = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_kill.buf == NULL)
|
||||
return (-1);
|
||||
(void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer;
|
||||
el->el_chared.c_kill.last = el->el_chared.c_kill.buf;
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_state.metanext = 0;
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||
|
||||
el->el_chared.c_macro.level = -1;
|
||||
el->el_chared.c_macro.offset = 0;
|
||||
el->el_chared.c_macro.macro = (char **) el_malloc(EL_MAXMACRO *
|
||||
sizeof(char *));
|
||||
if (el->el_chared.c_macro.macro == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ch_reset():
|
||||
* Reset the character editor
|
||||
*/
|
||||
protected void
|
||||
ch_reset(EditLine *el)
|
||||
{
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
el->el_chared.c_undo.cursor = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_vcmd.pos = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer;
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_state.metanext = 0;
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||
|
||||
el->el_chared.c_macro.level = -1;
|
||||
|
||||
el->el_history.eventno = 0;
|
||||
}
|
||||
|
||||
/* ch_enlargebufs():
|
||||
* Enlarge line buffer to be able to hold twice as much characters.
|
||||
* Returns 1 if successful, 0 if not.
|
||||
*/
|
||||
protected int
|
||||
ch_enlargebufs(el, addlen)
|
||||
EditLine *el;
|
||||
size_t addlen;
|
||||
{
|
||||
size_t sz, newsz;
|
||||
char *newbuffer, *oldbuf, *oldkbuf;
|
||||
|
||||
sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
|
||||
newsz = sz * 2;
|
||||
/*
|
||||
* If newly required length is longer than current buffer, we need
|
||||
* to make the buffer big enough to hold both old and new stuff.
|
||||
*/
|
||||
if (addlen > sz) {
|
||||
while(newsz - sz < addlen)
|
||||
newsz *= 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reallocate line buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_line.buffer, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
|
||||
oldbuf = el->el_line.buffer;
|
||||
|
||||
el->el_line.buffer = newbuffer;
|
||||
el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
|
||||
el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
|
||||
/* don't set new size until all buffers are enlarged */
|
||||
el->el_line.limit = &newbuffer[sz - EL_LEAVE];
|
||||
|
||||
/*
|
||||
* Reallocate kill buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
|
||||
oldkbuf = el->el_chared.c_kill.buf;
|
||||
|
||||
el->el_chared.c_kill.buf = newbuffer;
|
||||
el->el_chared.c_kill.last = newbuffer +
|
||||
(el->el_chared.c_kill.last - oldkbuf);
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer +
|
||||
(el->el_chared.c_kill.mark - oldbuf);
|
||||
|
||||
/*
|
||||
* Reallocate undo buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
el->el_chared.c_undo.buf = newbuffer;
|
||||
|
||||
newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
el->el_chared.c_redo.pos = newbuffer +
|
||||
(el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.lim = newbuffer +
|
||||
(el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.buf = newbuffer;
|
||||
|
||||
if (!hist_enlargebuf(el, sz, newsz))
|
||||
return 0;
|
||||
|
||||
/* Safe to set enlarged buffer size */
|
||||
el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ch_end():
|
||||
* Free the data structures used by the editor
|
||||
*/
|
||||
protected void
|
||||
ch_end(EditLine *el)
|
||||
{
|
||||
el_free((ptr_t) el->el_line.buffer);
|
||||
el->el_line.buffer = NULL;
|
||||
el->el_line.limit = NULL;
|
||||
el_free((ptr_t) el->el_chared.c_undo.buf);
|
||||
el->el_chared.c_undo.buf = NULL;
|
||||
el_free((ptr_t) el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.buf = NULL;
|
||||
el->el_chared.c_redo.pos = NULL;
|
||||
el->el_chared.c_redo.lim = NULL;
|
||||
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
||||
el_free((ptr_t) el->el_chared.c_kill.buf);
|
||||
el->el_chared.c_kill.buf = NULL;
|
||||
el_free((ptr_t) el->el_chared.c_macro.macro);
|
||||
el->el_chared.c_macro.macro = NULL;
|
||||
ch_reset(el);
|
||||
}
|
||||
|
||||
|
||||
/* el_insertstr():
|
||||
* Insert string at cursorI
|
||||
*/
|
||||
public int
|
||||
el_insertstr(EditLine *el, const char *s)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if ((len = strlen(s)) == 0)
|
||||
return (-1);
|
||||
if (el->el_line.lastchar + len >= el->el_line.limit) {
|
||||
if (!ch_enlargebufs(el, len))
|
||||
return (-1);
|
||||
}
|
||||
|
||||
c_insert(el, (int)len);
|
||||
while (*s)
|
||||
*el->el_line.cursor++ = *s++;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* el_deletestr():
|
||||
* Delete num characters before the cursor
|
||||
*/
|
||||
public void
|
||||
el_deletestr(EditLine *el, int n)
|
||||
{
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
if (el->el_line.cursor < &el->el_line.buffer[n])
|
||||
return;
|
||||
|
||||
c_delbefore(el, n); /* delete before dot */
|
||||
el->el_line.cursor -= n;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
}
|
||||
|
||||
/* c_gets():
|
||||
* Get a string
|
||||
*/
|
||||
protected int
|
||||
c_gets(EditLine *el, char *buf, const char *prompt)
|
||||
{
|
||||
char ch;
|
||||
int len;
|
||||
char *cp = el->el_line.buffer;
|
||||
|
||||
if (prompt) {
|
||||
len = strlen(prompt);
|
||||
memcpy(cp, prompt, len + 0u);
|
||||
cp += len;
|
||||
}
|
||||
len = 0;
|
||||
|
||||
for (;;) {
|
||||
el->el_line.cursor = cp;
|
||||
*cp = ' ';
|
||||
el->el_line.lastchar = cp + 1;
|
||||
re_refresh(el);
|
||||
|
||||
if (el_getc(el, &ch) != 1) {
|
||||
ed_end_of_file(el, 0);
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
|
||||
case 0010: /* Delete and backspace */
|
||||
case 0177:
|
||||
if (len <= 0) {
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
cp--;
|
||||
continue;
|
||||
|
||||
case 0033: /* ESC */
|
||||
case '\r': /* Newline */
|
||||
case '\n':
|
||||
buf[len] = ch;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (len >= EL_BUFSIZ - 16)
|
||||
term_beep(el);
|
||||
else {
|
||||
buf[len++] = ch;
|
||||
*cp++ = ch;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.buffer[0] = '\0';
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/* c_hpos():
|
||||
* Return the current horizontal position of the cursor
|
||||
*/
|
||||
protected int
|
||||
c_hpos(EditLine *el)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
/*
|
||||
* Find how many characters till the beginning of this line.
|
||||
*/
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (0);
|
||||
else {
|
||||
for (ptr = el->el_line.cursor - 1;
|
||||
ptr >= el->el_line.buffer && *ptr != '\n';
|
||||
ptr--)
|
||||
continue;
|
||||
return (el->el_line.cursor - ptr - 1);
|
||||
}
|
||||
}
|
169
libedit/chared.h
Normal file
169
libedit/chared.h
Normal file
@ -0,0 +1,169 @@
|
||||
/* $NetBSD: chared.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: chared.h,v 1.14 2004/08/13 12:10:39 mycroft Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)chared.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.chared.h: Character editor interface
|
||||
*/
|
||||
#ifndef _h_el_chared
|
||||
#define _h_el_chared
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
#define EL_MAXMACRO 10
|
||||
|
||||
/*
|
||||
* This is a issue of basic "vi" look-and-feel. Defining VI_MOVE works
|
||||
* like real vi: i.e. the transition from command<->insert modes moves
|
||||
* the cursor.
|
||||
*
|
||||
* On the other hand we really don't want to move the cursor, because
|
||||
* all the editing commands don't include the character under the cursor.
|
||||
* Probably the best fix is to make all the editing commands aware of
|
||||
* this fact.
|
||||
*/
|
||||
#define VI_MOVE
|
||||
|
||||
|
||||
typedef struct c_macro_t {
|
||||
int level;
|
||||
int offset;
|
||||
char **macro;
|
||||
} c_macro_t;
|
||||
|
||||
/*
|
||||
* Undo information for vi - no undo in emacs (yet)
|
||||
*/
|
||||
typedef struct c_undo_t {
|
||||
int len; /* length of saved line */
|
||||
int cursor; /* position of saved cursor */
|
||||
char *buf; /* full saved text */
|
||||
} c_undo_t;
|
||||
|
||||
/* redo for vi */
|
||||
typedef struct c_redo_t {
|
||||
char *buf; /* redo insert key sequence */
|
||||
char *pos;
|
||||
char *lim;
|
||||
el_action_t cmd; /* command to redo */
|
||||
char ch; /* char that invoked it */
|
||||
int count;
|
||||
int action; /* from cv_action() */
|
||||
} c_redo_t;
|
||||
|
||||
/*
|
||||
* Current action information for vi
|
||||
*/
|
||||
typedef struct c_vcmd_t {
|
||||
int action;
|
||||
char *pos;
|
||||
} c_vcmd_t;
|
||||
|
||||
/*
|
||||
* Kill buffer for emacs
|
||||
*/
|
||||
typedef struct c_kill_t {
|
||||
char *buf;
|
||||
char *last;
|
||||
char *mark;
|
||||
} c_kill_t;
|
||||
|
||||
/*
|
||||
* Note that we use both data structures because the user can bind
|
||||
* commands from both editors!
|
||||
*/
|
||||
typedef struct el_chared_t {
|
||||
c_undo_t c_undo;
|
||||
c_kill_t c_kill;
|
||||
c_redo_t c_redo;
|
||||
c_vcmd_t c_vcmd;
|
||||
c_macro_t c_macro;
|
||||
} el_chared_t;
|
||||
|
||||
|
||||
#define STReof "^D\b\b"
|
||||
#define STRQQ "\"\""
|
||||
|
||||
#define isglob(a) (strchr("*[]?", (a)) != NULL)
|
||||
#define isword(a) (isprint(a))
|
||||
|
||||
#define NOP 0x00
|
||||
#define DELETE 0x01
|
||||
#define INSERT 0x02
|
||||
#define YANK 0x04
|
||||
|
||||
#define CHAR_FWD (+1)
|
||||
#define CHAR_BACK (-1)
|
||||
|
||||
#define MODE_INSERT 0
|
||||
#define MODE_REPLACE 1
|
||||
#define MODE_REPLACE_1 2
|
||||
|
||||
#include "common.h"
|
||||
#include "vi.h"
|
||||
#include "emacs.h"
|
||||
#include "search.h"
|
||||
#include "fcns.h"
|
||||
|
||||
|
||||
protected int cv__isword(int);
|
||||
protected int cv__isWord(int);
|
||||
protected void cv_delfini(EditLine *);
|
||||
protected char *cv__endword(char *, char *, int, int (*)(int));
|
||||
protected int ce__isword(int);
|
||||
protected void cv_undo(EditLine *);
|
||||
protected void cv_yank(EditLine *, const char *, int);
|
||||
protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
|
||||
protected char *cv_prev_word(char *, char *, int, int (*)(int));
|
||||
protected char *c__next_word(char *, char *, int, int (*)(int));
|
||||
protected char *c__prev_word(char *, char *, int, int (*)(int));
|
||||
protected void c_insert(EditLine *, int);
|
||||
protected void c_delbefore(EditLine *, int);
|
||||
protected void c_delbefore1(EditLine *);
|
||||
protected void c_delafter(EditLine *, int);
|
||||
protected void c_delafter1(EditLine *);
|
||||
protected int c_gets(EditLine *, char *, const char *);
|
||||
protected int c_hpos(EditLine *);
|
||||
|
||||
protected int ch_init(EditLine *);
|
||||
protected void ch_reset(EditLine *);
|
||||
protected int ch_enlargebufs(EditLine *, size_t);
|
||||
protected void ch_end(EditLine *);
|
||||
|
||||
#endif /* _h_el_chared */
|
917
libedit/common.c
Normal file
917
libedit/common.c
Normal file
@ -0,0 +1,917 @@
|
||||
/* $NetBSD: common.c,v 1.5 2005/06/09 16:48:57 lukem Exp $ */
|
||||
/* from NetBSD: common.c,v 1.16 2003/08/07 16:44:30 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* common.c: Common Editor functions
|
||||
*/
|
||||
#include "el.h"
|
||||
|
||||
/* ed_end_of_file():
|
||||
* Indicate end of file
|
||||
* [^D]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_end_of_file(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_EOF);
|
||||
}
|
||||
|
||||
|
||||
/* ed_insert():
|
||||
* Add character to the line
|
||||
* Insert a character [bound to all insert keys]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_insert(EditLine *el, int c)
|
||||
{
|
||||
int count = el->el_state.argument;
|
||||
|
||||
if (c == '\0')
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_line.lastchar + el->el_state.argument >=
|
||||
el->el_line.limit) {
|
||||
/* end of buffer space, try to allocate more */
|
||||
if (!ch_enlargebufs(el, (size_t) count))
|
||||
return CC_ERROR; /* error allocating more */
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (el->el_state.inputmode == MODE_INSERT
|
||||
|| el->el_line.cursor >= el->el_line.lastchar)
|
||||
c_insert(el, 1);
|
||||
|
||||
*el->el_line.cursor++ = c;
|
||||
re_fastaddc(el); /* fast refresh for one char. */
|
||||
} else {
|
||||
if (el->el_state.inputmode != MODE_REPLACE_1)
|
||||
c_insert(el, el->el_state.argument);
|
||||
|
||||
while (count-- && el->el_line.cursor < el->el_line.lastchar)
|
||||
*el->el_line.cursor++ = c;
|
||||
re_refresh(el);
|
||||
}
|
||||
|
||||
if (el->el_state.inputmode == MODE_REPLACE_1)
|
||||
return vi_command_mode(el, 0);
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_prev_word():
|
||||
* Delete from beginning of current word to cursor
|
||||
* [M-^?] [^W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *p, *kp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
|
||||
*kp++ = *p;
|
||||
el->el_chared.c_kill.last = kp;
|
||||
|
||||
c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */
|
||||
el->el_line.cursor = cp;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer; /* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_next_char():
|
||||
* Delete character under cursor
|
||||
* [^D] [x]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_next_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
#ifdef notdef /* XXX */
|
||||
#define EL el->el_line
|
||||
(void) fprintf(el->el_errlfile,
|
||||
"\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
|
||||
EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
|
||||
EL.lastchar, EL.limit, EL.limit);
|
||||
#endif
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
/* if I'm at the end */
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
if (el->el_line.cursor == el->el_line.buffer) {
|
||||
/* if I'm also at the beginning */
|
||||
#ifdef KSHVI
|
||||
return (CC_ERROR);
|
||||
#else
|
||||
term_overwrite(el, STReof, 4);
|
||||
/* then do a EOF */
|
||||
term__flush();
|
||||
return (CC_EOF);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef KSHVI
|
||||
el->el_line.cursor--;
|
||||
#else
|
||||
return (CC_ERROR);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (el->el_line.cursor != el->el_line.buffer)
|
||||
el->el_line.cursor--;
|
||||
else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
c_delafter(el, el->el_state.argument); /* delete after dot */
|
||||
if (el->el_line.cursor >= el->el_line.lastchar &&
|
||||
el->el_line.cursor > el->el_line.buffer)
|
||||
/* bounds check */
|
||||
el->el_line.cursor = el->el_line.lastchar - 1;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_kill_line():
|
||||
* Cut to the end of line
|
||||
* [^K] [^K]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_kill_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.lastchar)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
/* zap! -- delete to end */
|
||||
el->el_line.lastchar = el->el_line.cursor;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_move_to_end():
|
||||
* Move cursor to the end of line
|
||||
* [^E] [^E]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
#ifdef VI_MOVE
|
||||
el->el_line.cursor--;
|
||||
#endif
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_move_to_beg():
|
||||
* Move cursor to the beginning of line
|
||||
* [^A] [^A]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_beg(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
/* We want FIRST non space character */
|
||||
while (isspace((unsigned char) *el->el_line.cursor))
|
||||
el->el_line.cursor++;
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_transpose_chars():
|
||||
* Exchange the character to the left of the cursor with the one under it
|
||||
* [^T] [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_transpose_chars(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
if (el->el_line.lastchar <= &el->el_line.buffer[1])
|
||||
return (CC_ERROR);
|
||||
else
|
||||
el->el_line.cursor++;
|
||||
}
|
||||
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
return (CC_REFRESH);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_char():
|
||||
* Move to the right one character
|
||||
* [^F] [^F]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *lim = el->el_line.lastchar;
|
||||
|
||||
if (el->el_line.cursor >= lim ||
|
||||
(el->el_line.cursor == lim - 1 &&
|
||||
el->el_map.type == MAP_VI &&
|
||||
el->el_chared.c_vcmd.action == NOP))
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor += el->el_state.argument;
|
||||
if (el->el_line.cursor > lim)
|
||||
el->el_line.cursor = lim;
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_word():
|
||||
* Move to the beginning of the current word
|
||||
* [M-b] [b]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor = c__prev_word(el->el_line.cursor,
|
||||
el->el_line.buffer,
|
||||
el->el_state.argument,
|
||||
ce__isword);
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_char():
|
||||
* Move to the left one character
|
||||
* [^B] [^B]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.buffer) {
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_quoted_insert():
|
||||
* Add the next character typed verbatim
|
||||
* [^V] [^V]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_quoted_insert(EditLine *el, int c)
|
||||
{
|
||||
int num;
|
||||
char tc;
|
||||
|
||||
tty_quotemode(el);
|
||||
num = el_getc(el, &tc);
|
||||
c = (unsigned char) tc;
|
||||
tty_noquotemode(el);
|
||||
if (num == 1)
|
||||
return (ed_insert(el, c));
|
||||
else
|
||||
return (ed_end_of_file(el, 0));
|
||||
}
|
||||
|
||||
|
||||
/* ed_digit():
|
||||
* Adds to argument or enters a digit
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_digit(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (!isdigit(c))
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
/* if doing an arg, add this in... */
|
||||
if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
|
||||
el->el_state.argument = c - '0';
|
||||
else {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.argument =
|
||||
(el->el_state.argument * 10) + (c - '0');
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
return ed_insert(el, c);
|
||||
}
|
||||
|
||||
|
||||
/* ed_argument_digit():
|
||||
* Digit that starts argument
|
||||
* For ESC-n
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_argument_digit(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (!isdigit(c))
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.argument = (el->el_state.argument * 10) +
|
||||
(c - '0');
|
||||
} else { /* else starting an argument */
|
||||
el->el_state.argument = c - '0';
|
||||
el->el_state.doingarg = 1;
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* ed_unassigned():
|
||||
* Indicates unbound character
|
||||
* Bound to keys that are not assigned
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_unassigned(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** TTY key handling.
|
||||
**/
|
||||
|
||||
/* ed_tty_sigint():
|
||||
* Tty interrupt character
|
||||
* [^C]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_dsusp():
|
||||
* Tty delayed suspend character
|
||||
* [^Y]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_flush_output():
|
||||
* Tty flush output characters
|
||||
* [^O]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigquit():
|
||||
* Tty quit character
|
||||
* [^\]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigtstp():
|
||||
* Tty suspend character
|
||||
* [^Z]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_stop_output():
|
||||
* Tty disallow output characters
|
||||
* [^S]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_start_output():
|
||||
* Tty allow output characters
|
||||
* [^Q]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_newline():
|
||||
* Execute command
|
||||
* [^J]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_newline(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar++ = '\n';
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_NEWLINE);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_prev_char():
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_clear_screen():
|
||||
* Clear screen leaving current line at the top
|
||||
* [^L]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_clear_screen(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
term_clear_screen(el); /* clear the whole real screen */
|
||||
re_clear_display(el); /* reset everything */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_redisplay():
|
||||
* Redisplay everything
|
||||
* ^R
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_REDISPLAY);
|
||||
}
|
||||
|
||||
|
||||
/* ed_start_over():
|
||||
* Erase current line and start from scratch
|
||||
* [^G]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
ch_reset(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_sequence_lead_in():
|
||||
* First character in a bound sequence
|
||||
* Placeholder for external keys
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_history():
|
||||
* Move to the previous history line
|
||||
* [^P] [k]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char beep = 0;
|
||||
int sv_event = el->el_history.eventno;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
if (el->el_history.eventno == 0) { /* save the current buffer
|
||||
* away */
|
||||
(void) strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
}
|
||||
el->el_history.eventno += el->el_state.argument;
|
||||
|
||||
if (hist_get(el) == CC_ERROR) {
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
el->el_history.eventno = sv_event;
|
||||
return CC_ERROR;
|
||||
}
|
||||
beep = 1;
|
||||
/* el->el_history.eventno was fixed by first call */
|
||||
(void) hist_get(el);
|
||||
}
|
||||
if (beep)
|
||||
return CC_REFRESH_BEEP;
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_history():
|
||||
* Move to the next history line
|
||||
* [^N] [j]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
el_action_t beep = CC_REFRESH, rval;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
el->el_history.eventno -= el->el_state.argument;
|
||||
|
||||
if (el->el_history.eventno < 0) {
|
||||
el->el_history.eventno = 0;
|
||||
beep = CC_REFRESH_BEEP;
|
||||
}
|
||||
rval = hist_get(el);
|
||||
if (rval == CC_REFRESH)
|
||||
return beep;
|
||||
return rval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ed_search_prev_history():
|
||||
* Search previous in history for a line matching the current
|
||||
* next search history [M-P] [K]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_prev_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
if (el->el_history.eventno < 0) {
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"e_prev_search_hist(): eventno < 0;\n");
|
||||
#endif
|
||||
el->el_history.eventno = 0;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
if (el->el_history.eventno == 0) {
|
||||
(void) strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
}
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
for (h = 1; h <= el->el_history.eventno; h++)
|
||||
hp = HIST_NEXT(el);
|
||||
|
||||
while (hp != NULL) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((strncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp)) {
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
h++;
|
||||
hp = HIST_NEXT(el);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_history.eventno = h;
|
||||
|
||||
return (hist_get(el));
|
||||
}
|
||||
|
||||
|
||||
/* ed_search_next_history():
|
||||
* Search next in history for a line matching the current
|
||||
* [M-N] [J]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_next_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
if (el->el_history.eventno == 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
for (h = 1; h < el->el_history.eventno && hp; h++) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((strncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp))
|
||||
found = h;
|
||||
hp = HIST_NEXT(el);
|
||||
}
|
||||
|
||||
if (!found) { /* is it the current history number? */
|
||||
if (!c_hmatch(el, el->el_history.buf)) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
el->el_history.eventno = found;
|
||||
|
||||
return (hist_get(el));
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_line():
|
||||
* Move up one line
|
||||
* Could be [k] [^p]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
* Move to the line requested
|
||||
*/
|
||||
if (*(ptr = el->el_line.cursor) == '\n')
|
||||
ptr--;
|
||||
|
||||
for (; ptr >= el->el_line.buffer; ptr--)
|
||||
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
/*
|
||||
* Move to the beginning of the line
|
||||
*/
|
||||
for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Move to the character requested
|
||||
*/
|
||||
for (ptr++;
|
||||
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
||||
ptr++)
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_line():
|
||||
* Move down one line
|
||||
* Could be [j] [^n]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
* Move to the line requested
|
||||
*/
|
||||
for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
|
||||
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
/*
|
||||
* Move to the character requested
|
||||
*/
|
||||
for (ptr++;
|
||||
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
||||
ptr++)
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_command():
|
||||
* Editline extended command
|
||||
* [M-X] [:]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_command(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
||||
tmplen = c_gets(el, tmpbuf, "\n: ");
|
||||
term__putc('\n');
|
||||
|
||||
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
||||
term_beep(el);
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
re_clear_display(el);
|
||||
return CC_REFRESH;
|
||||
}
|
771
libedit/editline.3
Normal file
771
libedit/editline.3
Normal file
@ -0,0 +1,771 @@
|
||||
.\" $NetBSD: editline.3,v 1.3 2005/05/31 02:07:02 lukem Exp $
|
||||
.\" from NetBSD: editline.3,v 1.46 2005/03/19 17:36:02 christos Exp
|
||||
.\"
|
||||
.\" Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
|
||||
.\"
|
||||
.\" 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 NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd March 19, 2005
|
||||
.Os
|
||||
.Dt EDITLINE 3
|
||||
.Sh NAME
|
||||
.Nm editline ,
|
||||
.Nm el_init ,
|
||||
.Nm el_end ,
|
||||
.Nm el_reset ,
|
||||
.Nm el_gets ,
|
||||
.Nm el_getc ,
|
||||
.Nm el_push ,
|
||||
.Nm el_parse ,
|
||||
.Nm el_set ,
|
||||
.Nm el_source ,
|
||||
.Nm el_resize ,
|
||||
.Nm el_line ,
|
||||
.Nm el_insertstr ,
|
||||
.Nm el_deletestr ,
|
||||
.Nm history_init ,
|
||||
.Nm history_end ,
|
||||
.Nm history ,
|
||||
.Nm tok_init ,
|
||||
.Nm tok_end ,
|
||||
.Nm tok_reset ,
|
||||
.Nm tok_line ,
|
||||
.Nm tok_str
|
||||
.Nd line editor, history and tokenization functions
|
||||
.Sh LIBRARY
|
||||
.Lb libedit
|
||||
.Sh SYNOPSIS
|
||||
.In histedit.h
|
||||
.Ft EditLine *
|
||||
.Fn el_init "const char *prog" "FILE *fin" "FILE *fout" "FILE *ferr"
|
||||
.Ft void
|
||||
.Fn el_end "EditLine *e"
|
||||
.Ft void
|
||||
.Fn el_reset "EditLine *e"
|
||||
.Ft const char *
|
||||
.Fn el_gets "EditLine *e" "int *count"
|
||||
.Ft int
|
||||
.Fn el_getc "EditLine *e" "char *ch"
|
||||
.Ft void
|
||||
.Fn el_push "EditLine *e" "const char *str"
|
||||
.Ft int
|
||||
.Fn el_parse "EditLine *e" "int argc" "const char *argv[]"
|
||||
.Ft int
|
||||
.Fn el_set "EditLine *e" "int op" "..."
|
||||
.Ft int
|
||||
.Fn el_get "EditLine *e" "int op" "void *result"
|
||||
.Ft int
|
||||
.Fn el_source "EditLine *e" "const char *file"
|
||||
.Ft void
|
||||
.Fn el_resize "EditLine *e"
|
||||
.Ft const LineInfo *
|
||||
.Fn el_line "EditLine *e"
|
||||
.Ft int
|
||||
.Fn el_insertstr "EditLine *e" "const char *str"
|
||||
.Ft void
|
||||
.Fn el_deletestr "EditLine *e" "int count"
|
||||
.Ft History *
|
||||
.Fn history_init
|
||||
.Ft void
|
||||
.Fn history_end "History *h"
|
||||
.Ft int
|
||||
.Fn history "History *h" "HistEvent *ev" "int op" "..."
|
||||
.Ft Tokenizer *
|
||||
.Fn tok_init "const char *IFS"
|
||||
.Ft void
|
||||
.Fn tok_end "Tokenizer *t"
|
||||
.Ft void
|
||||
.Fn tok_reset "Tokenizer *t"
|
||||
.Ft int
|
||||
.Fn tok_line "Tokenizer *t" "const LineInfo *li" "int *argc" "const char **argv[]" "int *cursorc" "int *cursoro"
|
||||
.Ft int
|
||||
.Fn tok_str "Tokenizer *t" "const char *str" "int *argc" "const char **argv[]"
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
library provides generic line editing, history and tokenization functions,
|
||||
similar to those found in
|
||||
.Xr sh 1 .
|
||||
.Pp
|
||||
These functions are available in the
|
||||
.Nm libedit
|
||||
library (which needs the
|
||||
.Nm libtermcap
|
||||
library).
|
||||
Programs should be linked with
|
||||
.Fl ledit ltermcap .
|
||||
.Sh LINE EDITING FUNCTIONS
|
||||
The line editing functions use a common data structure,
|
||||
.Fa EditLine ,
|
||||
which is created by
|
||||
.Fn el_init
|
||||
and freed by
|
||||
.Fn el_end .
|
||||
.Pp
|
||||
The following functions are available:
|
||||
.Bl -tag -width 4n
|
||||
.It Fn el_init
|
||||
Initialise the line editor, and return a data structure
|
||||
to be used by all other line editing functions.
|
||||
.Fa prog
|
||||
is the name of the invoking program, used when reading the
|
||||
.Xr editrc 5
|
||||
file to determine which settings to use.
|
||||
.Fa fin ,
|
||||
.Fa fout
|
||||
and
|
||||
.Fa ferr
|
||||
are the input, output, and error streams (respectively) to use.
|
||||
In this documentation, references to
|
||||
.Dq the tty
|
||||
are actually to this input/output stream combination.
|
||||
.It Fn el_end
|
||||
Clean up and finish with
|
||||
.Fa e ,
|
||||
assumed to have been created with
|
||||
.Fn el_init .
|
||||
.It Fn el_reset
|
||||
Reset the tty and the parser.
|
||||
This should be called after an error which may have upset the tty's
|
||||
state.
|
||||
.It Fn el_gets
|
||||
Read a line from the tty.
|
||||
.Fa count
|
||||
is modified to contain the number of characters read.
|
||||
Returns the line read if successful, or
|
||||
.Dv NULL
|
||||
if no characters were read or if an error occurred.
|
||||
.It Fn el_getc
|
||||
Read a character from the tty.
|
||||
.Fa ch
|
||||
is modified to contain the character read.
|
||||
Returns the number of characters read if successful, \-1 otherwise.
|
||||
.It Fn el_push
|
||||
Pushes
|
||||
.Fa str
|
||||
back onto the input stream.
|
||||
This is used by the macro expansion mechanism.
|
||||
Refer to the description of
|
||||
.Ic bind
|
||||
.Fl s
|
||||
in
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Fn el_parse
|
||||
Parses the
|
||||
.Fa argv
|
||||
array (which is
|
||||
.Fa argc
|
||||
elements in size)
|
||||
to execute builtin
|
||||
.Nm
|
||||
commands.
|
||||
If the command is prefixed with
|
||||
.Dq prog :
|
||||
then
|
||||
.Fn el_parse
|
||||
will only execute the command if
|
||||
.Dq prog
|
||||
matches the
|
||||
.Fa prog
|
||||
argument supplied to
|
||||
.Fn el_init .
|
||||
The return value is
|
||||
\-1 if the command is unknown,
|
||||
0 if there was no error or
|
||||
.Dq prog
|
||||
didn't match, or
|
||||
1 if the command returned an error.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Fn el_set
|
||||
Set
|
||||
.Nm
|
||||
parameters.
|
||||
.Fa op
|
||||
determines which parameter to set, and each operation has its
|
||||
own parameter list.
|
||||
.Pp
|
||||
The following values for
|
||||
.Fa op
|
||||
are supported, along with the required argument list:
|
||||
.Bl -tag -width 4n
|
||||
.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
|
||||
Define prompt printing function as
|
||||
.Fa f ,
|
||||
which is to return a string that contains the prompt.
|
||||
.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
|
||||
Define right side prompt printing function as
|
||||
.Fa f ,
|
||||
which is to return a string that contains the prompt.
|
||||
.It Dv EL_TERMINAL , Fa "const char *type"
|
||||
Define terminal type of the tty to be
|
||||
.Fa type ,
|
||||
or to
|
||||
.Ev TERM
|
||||
if
|
||||
.Fa type
|
||||
is
|
||||
.Dv NULL .
|
||||
.It Dv EL_EDITOR , Fa "const char *mode"
|
||||
Set editing mode to
|
||||
.Fa mode ,
|
||||
which must be one of
|
||||
.Dq emacs
|
||||
or
|
||||
.Dq vi .
|
||||
.It Dv EL_SIGNAL , Fa "int flag"
|
||||
If
|
||||
.Fa flag
|
||||
is non-zero,
|
||||
.Nm
|
||||
will install its own signal handler for the following signals when
|
||||
reading command input:
|
||||
.Dv SIGCONT ,
|
||||
.Dv SIGHUP ,
|
||||
.Dv SIGINT ,
|
||||
.Dv SIGQUIT ,
|
||||
.Dv SIGSTOP ,
|
||||
.Dv SIGTERM ,
|
||||
.Dv SIGTSTP ,
|
||||
and
|
||||
.Dv SIGWINCH .
|
||||
Otherwise, the current signal handlers will be used.
|
||||
.It Dv EL_BIND , Xo
|
||||
.Fa "const char *" ,
|
||||
.Fa "..." ,
|
||||
.Dv NULL
|
||||
.Xc
|
||||
Perform the
|
||||
.Ic bind
|
||||
builtin command.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Dv EL_ECHOTC , Xo
|
||||
.Fa "const char *" ,
|
||||
.Fa "..." ,
|
||||
.Dv NULL
|
||||
.Xc
|
||||
Perform the
|
||||
.Ic echotc
|
||||
builtin command.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Dv EL_SETTC , Xo
|
||||
.Fa "const char *" ,
|
||||
.Fa "..." ,
|
||||
.Dv NULL
|
||||
.Xc
|
||||
Perform the
|
||||
.Ic settc
|
||||
builtin command.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Dv EL_SETTY , Xo
|
||||
.Fa "const char *" ,
|
||||
.Fa "..." ,
|
||||
.Dv NULL
|
||||
.Xc
|
||||
Perform the
|
||||
.Ic setty
|
||||
builtin command.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Dv EL_TELLTC , Xo
|
||||
.Fa "const char *" ,
|
||||
.Fa "..." ,
|
||||
.Dv NULL
|
||||
.Xc
|
||||
Perform the
|
||||
.Ic telltc
|
||||
builtin command.
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for more information.
|
||||
.It Dv EL_ADDFN , Xo
|
||||
.Fa "const char *name" ,
|
||||
.Fa "const char *help" ,
|
||||
.Fa "unsigned char (*func)(EditLine *e, int ch)"
|
||||
.Xc
|
||||
Add a user defined function,
|
||||
.Fn func ,
|
||||
referred to as
|
||||
.Fa name
|
||||
which is invoked when a key which is bound to
|
||||
.Fa name
|
||||
is entered.
|
||||
.Fa help
|
||||
is a description of
|
||||
.Fa name .
|
||||
At invocation time,
|
||||
.Fa ch
|
||||
is the key which caused the invocation.
|
||||
The return value of
|
||||
.Fn func
|
||||
should be one of:
|
||||
.Bl -tag -width "CC_REDISPLAY"
|
||||
.It Dv CC_NORM
|
||||
Add a normal character.
|
||||
.It Dv CC_NEWLINE
|
||||
End of line was entered.
|
||||
.It Dv CC_EOF
|
||||
EOF was entered.
|
||||
.It Dv CC_ARGHACK
|
||||
Expecting further command input as arguments, do nothing visually.
|
||||
.It Dv CC_REFRESH
|
||||
Refresh display.
|
||||
.It Dv CC_REFRESH_BEEP
|
||||
Refresh display, and beep.
|
||||
.It Dv CC_CURSOR
|
||||
Cursor moved, so update and perform
|
||||
.Dv CC_REFRESH .
|
||||
.It Dv CC_REDISPLAY
|
||||
Redisplay entire input line.
|
||||
This is useful if a key binding outputs extra information.
|
||||
.It Dv CC_ERROR
|
||||
An error occurred.
|
||||
Beep, and flush tty.
|
||||
.It Dv CC_FATAL
|
||||
Fatal error, reset tty to known state.
|
||||
.El
|
||||
.It Dv EL_HIST , Xo
|
||||
.Fa "History *(*func)(History *, int op, ...)" ,
|
||||
.Fa "const char *ptr"
|
||||
.Xc
|
||||
Defines which history function to use, which is usually
|
||||
.Fn history .
|
||||
.Fa ptr
|
||||
should be the value returned by
|
||||
.Fn history_init .
|
||||
.It Dv EL_EDITMODE , Fa "int flag"
|
||||
If
|
||||
.Fa flag
|
||||
is non-zero,
|
||||
editing is enabled (the default).
|
||||
Note that this is only an indication, and does not
|
||||
affect the operation of
|
||||
.Nm .
|
||||
At this time, it is the caller's responsibility to
|
||||
check this
|
||||
(using
|
||||
.Fn el_get )
|
||||
to determine if editing should be enabled or not.
|
||||
.It Dv EL_GETCFN , Fa "int (*f)(EditLine *, char *c)"
|
||||
Define the character reading function as
|
||||
.Fa f ,
|
||||
which is to return the number of characters read and store them in
|
||||
.Fa c .
|
||||
This function is called internally by
|
||||
.Fn el_gets
|
||||
and
|
||||
.Fn el_getc .
|
||||
The builtin function can be set or restored with the special function
|
||||
name ``EL_BUILTIN_GETCFN''.
|
||||
.It Dv EL_CLIENTDATA , Fa "void *data"
|
||||
Register
|
||||
.Fa data
|
||||
to be associated with this EditLine structure.
|
||||
It can be retrieved with the corresponding
|
||||
.Fn el_get
|
||||
call.
|
||||
.El
|
||||
.It Fn el_get
|
||||
Get
|
||||
.Nm
|
||||
parameters.
|
||||
.Fa op
|
||||
determines which parameter to retrieve into
|
||||
.Fa result .
|
||||
Returns 0 if successful, \-1 otherwise.
|
||||
.Pp
|
||||
The following values for
|
||||
.Fa op
|
||||
are supported, along with actual type of
|
||||
.Fa result :
|
||||
.Bl -tag -width 4n
|
||||
.It Dv EL_PROMPT , Fa "char *(*f)(EditLine *)"
|
||||
Return a pointer to the function that displays the prompt.
|
||||
.It Dv EL_RPROMPT , Fa "char *(*f)(EditLine *)"
|
||||
Return a pointer to the function that displays the rightside prompt.
|
||||
.It Dv EL_EDITOR , Fa "const char *"
|
||||
Return the name of the editor, which will be one of
|
||||
.Dq emacs
|
||||
or
|
||||
.Dq vi .
|
||||
.It Dv EL_SIGNAL , Fa "int *"
|
||||
Return non-zero if
|
||||
.Nm
|
||||
has installed private signal handlers (see
|
||||
.Fn el_get
|
||||
above).
|
||||
.It Dv EL_EDITMODE, Fa "int *"
|
||||
Return non-zero if editing is enabled.
|
||||
.It Dv EL_GETCFN, Fa "int (**f)(EditLine *, char *)"
|
||||
Return a pointer to the function that read characters, which is equal to
|
||||
``EL_BUILTIN_GETCFN'' in the case of the default builtin function.
|
||||
.It Dv EL_CLIENTDATA , Fa "void **data"
|
||||
Retrieve
|
||||
.Fa data
|
||||
previously registered with the corresponding
|
||||
.Fn el_set
|
||||
call.
|
||||
.It Dv EL_UNBUFFERED, Fa "int"
|
||||
Sets or clears unbuffered mode.
|
||||
In this mode,
|
||||
.Fn el_gets
|
||||
will return immediately after processing a single character.
|
||||
.It Dv EL_PREP_TERM, Fa "int"
|
||||
Sets or clears terminal editing mode.
|
||||
.El
|
||||
.It Fn el_source
|
||||
Initialise
|
||||
.Nm
|
||||
by reading the contents of
|
||||
.Fa file .
|
||||
.Fn el_parse
|
||||
is called for each line in
|
||||
.Fa file .
|
||||
If
|
||||
.Fa file
|
||||
is
|
||||
.Dv NULL ,
|
||||
try
|
||||
.Pa $PWD/.editrc
|
||||
then
|
||||
.Pa $HOME/.editrc .
|
||||
Refer to
|
||||
.Xr editrc 5
|
||||
for details on the format of
|
||||
.Fa file .
|
||||
.It Fn el_resize
|
||||
Must be called if the terminal size changes.
|
||||
If
|
||||
.Dv EL_SIGNAL
|
||||
has been set with
|
||||
.Fn el_set ,
|
||||
then this is done automatically.
|
||||
Otherwise, it's the responsibility of the application to call
|
||||
.Fn el_resize
|
||||
on the appropriate occasions.
|
||||
.It Fn el_line
|
||||
Return the editing information for the current line in a
|
||||
.Fa LineInfo
|
||||
structure, which is defined as follows:
|
||||
.Bd -literal
|
||||
typedef struct lineinfo {
|
||||
const char *buffer; /* address of buffer */
|
||||
const char *cursor; /* address of cursor */
|
||||
const char *lastchar; /* address of last character */
|
||||
} LineInfo;
|
||||
.Ed
|
||||
.Pp
|
||||
.Fa buffer
|
||||
is not NUL terminated.
|
||||
This function may be called after
|
||||
.Fn el_gets
|
||||
to obtain the
|
||||
.Fa LineInfo
|
||||
structure pertaining to line returned by that function,
|
||||
and from within user defined functions added with
|
||||
.Dv EL_ADDFN .
|
||||
.It Fn el_insertstr
|
||||
Insert
|
||||
.Fa str
|
||||
into the line at the cursor.
|
||||
Returns \-1 if
|
||||
.Fa str
|
||||
is empty or won't fit, and 0 otherwise.
|
||||
.It Fn el_deletestr
|
||||
Delete
|
||||
.Fa num
|
||||
characters before the cursor.
|
||||
.El
|
||||
.Sh HISTORY LIST FUNCTIONS
|
||||
The history functions use a common data structure,
|
||||
.Fa History ,
|
||||
which is created by
|
||||
.Fn history_init
|
||||
and freed by
|
||||
.Fn history_end .
|
||||
.Pp
|
||||
The following functions are available:
|
||||
.Bl -tag -width 4n
|
||||
.It Fn history_init
|
||||
Initialise the history list, and return a data structure
|
||||
to be used by all other history list functions.
|
||||
.It Fn history_end
|
||||
Clean up and finish with
|
||||
.Fa h ,
|
||||
assumed to have been created with
|
||||
.Fn history_init .
|
||||
.It Fn history
|
||||
Perform operation
|
||||
.Fa op
|
||||
on the history list, with optional arguments as needed by the
|
||||
operation.
|
||||
.Fa ev
|
||||
is changed accordingly to operation.
|
||||
The following values for
|
||||
.Fa op
|
||||
are supported, along with the required argument list:
|
||||
.Bl -tag -width 4n
|
||||
.It Dv H_SETSIZE , Fa "int size"
|
||||
Set size of history to
|
||||
.Fa size
|
||||
elements.
|
||||
.It Dv H_GETSIZE
|
||||
Get number of events currently in history.
|
||||
.It Dv H_END
|
||||
Cleans up and finishes with
|
||||
.Fa h ,
|
||||
assumed to be created with
|
||||
.Fn history_init .
|
||||
.It Dv H_CLEAR
|
||||
Clear the history.
|
||||
.It Dv H_FUNC , Xo
|
||||
.Fa "void *ptr" ,
|
||||
.Fa "history_gfun_t first" ,
|
||||
.Fa "history_gfun_t next" ,
|
||||
.Fa "history_gfun_t last" ,
|
||||
.Fa "history_gfun_t prev" ,
|
||||
.Fa "history_gfun_t curr" ,
|
||||
.Fa "history_sfun_t set" ,
|
||||
.Fa "history_vfun_t clear" ,
|
||||
.Fa "history_efun_t enter" ,
|
||||
.Fa "history_efun_t add"
|
||||
.Xc
|
||||
Define functions to perform various history operations.
|
||||
.Fa ptr
|
||||
is the argument given to a function when it's invoked.
|
||||
.It Dv H_FIRST
|
||||
Return the first element in the history.
|
||||
.It Dv H_LAST
|
||||
Return the last element in the history.
|
||||
.It Dv H_PREV
|
||||
Return the previous element in the history.
|
||||
.It Dv H_NEXT
|
||||
Return the next element in the history.
|
||||
.It Dv H_CURR
|
||||
Return the current element in the history.
|
||||
.It Dv H_SET
|
||||
Set the cursor to point to the requested element.
|
||||
.It Dv H_ADD , Fa "const char *str"
|
||||
Append
|
||||
.Fa str
|
||||
to the current element of the history, or perform the
|
||||
.Dv H_ENTER
|
||||
operation with argument
|
||||
.Fa str
|
||||
if there is no current element.
|
||||
.It Dv H_APPEND , Fa "const char *str"
|
||||
Append
|
||||
.Fa str
|
||||
to the last new element of the history.
|
||||
.It Dv H_ENTER , Fa "const char *str"
|
||||
Add
|
||||
.Fa str
|
||||
as a new element to the history, and, if necessary,
|
||||
removing the oldest entry to keep the list to the created size.
|
||||
If
|
||||
.Dv H_SETUNIQUE
|
||||
was has been called with a non-zero arguments, the element
|
||||
will not be entered into the history if its contents match
|
||||
the ones of the current history element.
|
||||
If the element is entered
|
||||
.Fn history
|
||||
returns 1, if it is ignored as a duplicate returns 0.
|
||||
Finally
|
||||
.Fn history
|
||||
returns \-1 if an error occurred.
|
||||
.It Dv H_PREV_STR , Fa "const char *str"
|
||||
Return the closest previous event that starts with
|
||||
.Fa str .
|
||||
.It Dv H_NEXT_STR , Fa "const char *str"
|
||||
Return the closest next event that starts with
|
||||
.Fa str .
|
||||
.It Dv H_PREV_EVENT , Fa "int e"
|
||||
Return the previous event numbered
|
||||
.Fa e .
|
||||
.It Dv H_NEXT_EVENT , Fa "int e"
|
||||
Return the next event numbered
|
||||
.Fa e .
|
||||
.It Dv H_LOAD , Fa "const char *file"
|
||||
Load the history list stored in
|
||||
.Fa file .
|
||||
.It Dv H_SAVE , Fa "const char *file"
|
||||
Save the history list to
|
||||
.Fa file .
|
||||
.It Dv H_SETUNIQUE , Fa "int unique"
|
||||
Set if the adjacent identical event strings should not be entered into
|
||||
the history.
|
||||
.It Dv H_GETUNIQUE
|
||||
Retrieve the current setting if if adjacent elements should be entered into
|
||||
the history.
|
||||
.El
|
||||
.Pp
|
||||
.Fn history
|
||||
returns \*[Gt]= 0 if the operation
|
||||
.Fa op
|
||||
succeeds.
|
||||
Otherwise, \-1 is returned and
|
||||
.Fa ev
|
||||
is updated to contain more details about the error.
|
||||
.El
|
||||
.Sh TOKENIZATION FUNCTIONS
|
||||
The tokenization functions use a common data structure,
|
||||
.Fa Tokenizer ,
|
||||
which is created by
|
||||
.Fn tok_init
|
||||
and freed by
|
||||
.Fn tok_end .
|
||||
.Pp
|
||||
The following functions are available:
|
||||
.Bl -tag -width 4n
|
||||
.It Fn tok_init
|
||||
Initialise the tokenizer, and return a data structure
|
||||
to be used by all other tokenizer functions.
|
||||
.Fa IFS
|
||||
contains the Input Field Separators, which defaults to
|
||||
.Aq space ,
|
||||
.Aq tab ,
|
||||
and
|
||||
.Aq newline
|
||||
if
|
||||
.Dv NULL .
|
||||
.It Fn tok_end
|
||||
Clean up and finish with
|
||||
.Fa t ,
|
||||
assumed to have been created with
|
||||
.Fn tok_init .
|
||||
.It Fn tok_reset
|
||||
Reset the tokenizer state.
|
||||
Use after a line has been successfully tokenized
|
||||
by
|
||||
.Fn tok_line
|
||||
or
|
||||
.Fn tok_str
|
||||
and before a new line is to be tokenized.
|
||||
.It Fn tok_line
|
||||
Tokenize
|
||||
.Fa li ,
|
||||
If successful, modify:
|
||||
.Fa argv
|
||||
to contain the words,
|
||||
.Fa argc
|
||||
to contain the number of words,
|
||||
.Fa cursorc
|
||||
(if not
|
||||
.Dv NULL )
|
||||
to contain the index of the word containing the cursor,
|
||||
and
|
||||
.Fa cursoro
|
||||
(if not
|
||||
.Dv NULL )
|
||||
to contain the offset within
|
||||
.Fa argv[cursorc]
|
||||
of the cursor.
|
||||
.Pp
|
||||
Returns
|
||||
0 if successful,
|
||||
\-1 for an internal error,
|
||||
1 for an unmatched single quote,
|
||||
2 for an unmatched double quote,
|
||||
and
|
||||
3 for a backslash quoted
|
||||
.Aq newline .
|
||||
A positive exit code indicates that another line should be read
|
||||
and tokenization attempted again.
|
||||
.
|
||||
.It Fn tok_str
|
||||
A simpler form of
|
||||
.Fn tok_line ;
|
||||
.Fa str
|
||||
is a NUL terminated string to tokenize.
|
||||
.El
|
||||
.
|
||||
.\"XXX.Sh EXAMPLES
|
||||
.\"XXX: provide some examples
|
||||
.Sh SEE ALSO
|
||||
.Xr sh 1 ,
|
||||
.Xr signal 3 ,
|
||||
.Xr termcap 3 ,
|
||||
.Xr editrc 5
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm
|
||||
library first appeared in
|
||||
.Bx 4.4 .
|
||||
.Dv CC_REDISPLAY
|
||||
appeared in
|
||||
.Nx 1.3 .
|
||||
.Dv CC_REFRESH_BEEP ,
|
||||
.Dv EL_EDITMODE
|
||||
and the readline emulation appeared in
|
||||
.Nx 1.4 .
|
||||
.Dv EL_RPROMPT
|
||||
appeared in
|
||||
.Nx 1.5 .
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm
|
||||
library was written by Christos Zoulas.
|
||||
Luke Mewburn wrote this manual and implemented
|
||||
.Dv CC_REDISPLAY ,
|
||||
.Dv CC_REFRESH_BEEP ,
|
||||
.Dv EL_EDITMODE ,
|
||||
and
|
||||
.Dv EL_RPROMPT .
|
||||
Jaromir Dolecek implemented the readline emulation.
|
||||
.Sh BUGS
|
||||
At this time, it is the responsibility of the caller to
|
||||
check the result of the
|
||||
.Dv EL_EDITMODE
|
||||
operation of
|
||||
.Fn el_get
|
||||
(after an
|
||||
.Fn el_source
|
||||
or
|
||||
.Fn el_parse )
|
||||
to determine if
|
||||
.Nm
|
||||
should be used for further input.
|
||||
I.e.,
|
||||
.Dv EL_EDITMODE
|
||||
is purely an indication of the result of the most recent
|
||||
.Xr editrc 5
|
||||
.Ic edit
|
||||
command.
|
518
libedit/editrc.5
Normal file
518
libedit/editrc.5
Normal file
@ -0,0 +1,518 @@
|
||||
.\" $NetBSD: editrc.5,v 1.2 2005/05/11 01:17:39 lukem Exp $
|
||||
.\" from NetBSD: editrc.5,v 1.19 2003/11/01 23:35:33 christos Exp
|
||||
.\"
|
||||
.\" Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
.\"
|
||||
.\" This file was contributed to The NetBSD Foundation by Luke Mewburn.
|
||||
.\"
|
||||
.\" 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 NetBSD
|
||||
.\" Foundation, Inc. and its contributors.
|
||||
.\" 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd October 18, 2003
|
||||
.Os
|
||||
.Dt EDITRC 5
|
||||
.Sh NAME
|
||||
.Nm editrc
|
||||
.Nd configuration file for editline library
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm
|
||||
file defines various settings to be used by the
|
||||
.Xr editline 3
|
||||
library.
|
||||
.Pp
|
||||
The format of each line is:
|
||||
.Dl [prog:]command [arg [...]]
|
||||
.Pp
|
||||
.Ar command
|
||||
is one of the
|
||||
.Xr editline 3
|
||||
builtin commands.
|
||||
Refer to
|
||||
.Sx BUILTIN COMMANDS
|
||||
for more information.
|
||||
.Pp
|
||||
.Ar prog
|
||||
is the program name string that a program defines when it calls
|
||||
.Xr el_init 3
|
||||
to set up
|
||||
.Xr editline 3 ,
|
||||
which is usually
|
||||
.Va argv[0] .
|
||||
.Ar command
|
||||
will be executed for any program which matches
|
||||
.Ar prog .
|
||||
.Pp
|
||||
.Ar prog
|
||||
may also be a
|
||||
.Xr regex 3
|
||||
style
|
||||
regular expression, in which case
|
||||
.Ar command
|
||||
will be executed for any program that matches the regular expression.
|
||||
.Pp
|
||||
If
|
||||
.Ar prog
|
||||
is absent,
|
||||
.Ar command
|
||||
is executed for all programs.
|
||||
.Sh BUILTIN COMMANDS
|
||||
The
|
||||
.Nm editline
|
||||
library has some builtin commands, which affect the way
|
||||
that the line editing and history functions operate.
|
||||
These are based on similar named builtins present in the
|
||||
.Xr tcsh 1
|
||||
shell.
|
||||
.Pp
|
||||
The following builtin commands are available:
|
||||
.Bl -tag -width 4n
|
||||
.It Ic bind Xo
|
||||
.Op Fl a
|
||||
.Op Fl e
|
||||
.Op Fl k
|
||||
.Op Fl l
|
||||
.Op Fl r
|
||||
.Op Fl s
|
||||
.Op Fl v
|
||||
.Op Ar key Op Ar command
|
||||
.Xc
|
||||
Without options, list all bound keys, and the editor command to which
|
||||
each is bound.
|
||||
If
|
||||
.Ar key
|
||||
is supplied, show the bindings for
|
||||
.Ar key .
|
||||
If
|
||||
.Ar key command
|
||||
is supplied, bind
|
||||
.Ar command
|
||||
to
|
||||
.Ar key .
|
||||
Options include:
|
||||
.Bl -tag -width 4n
|
||||
.It Fl e
|
||||
Bind all keys to the standard GNU Emacs-like bindings.
|
||||
.It Fl v
|
||||
Bind all keys to the standard
|
||||
.Xr vi 1 Ns -like
|
||||
bindings.
|
||||
.It Fl a
|
||||
List or change key bindings in the
|
||||
.Xr vi 1
|
||||
mode alternate (command mode) key map.
|
||||
.It Fl k
|
||||
.Ar key
|
||||
is interpreted as a symbolic arrow key name, which may be one of
|
||||
.Sq up ,
|
||||
.Sq down ,
|
||||
.Sq left
|
||||
or
|
||||
.Sq right .
|
||||
.It Fl l
|
||||
List all editor commands and a short description of each.
|
||||
.It Fl r
|
||||
Remove a key's binding.
|
||||
.It Fl s
|
||||
.Ar command
|
||||
is taken as a literal string and treated as terminal input when
|
||||
.Ar key
|
||||
is typed.
|
||||
Bound keys in
|
||||
.Ar command
|
||||
are themselves reinterpreted, and this continues for ten levels of
|
||||
interpretation.
|
||||
.El
|
||||
.Pp
|
||||
.Ar command
|
||||
may be one of the commands documented in
|
||||
.Sx "EDITOR COMMANDS"
|
||||
below, or another key.
|
||||
.Pp
|
||||
.Ar key
|
||||
and
|
||||
.Ar command
|
||||
can contain control characters of the form
|
||||
.Sm off
|
||||
.Sq No ^ Ar character
|
||||
.Sm on
|
||||
.Po
|
||||
e.g.
|
||||
.Sq ^A
|
||||
.Pc ,
|
||||
and the following backslashed escape sequences:
|
||||
.Pp
|
||||
.Bl -tag -compact -offset indent -width 4n
|
||||
.It Ic \ea
|
||||
Bell
|
||||
.It Ic \eb
|
||||
Backspace
|
||||
.It Ic \ee
|
||||
Escape
|
||||
.It Ic \ef
|
||||
Formfeed
|
||||
.It Ic \en
|
||||
Newline
|
||||
.It Ic \er
|
||||
Carriage return
|
||||
.It Ic \et
|
||||
Horizontal tab
|
||||
.It Ic \ev
|
||||
Vertical tab
|
||||
.Sm off
|
||||
.It Sy \e Ar nnn
|
||||
.Sm on
|
||||
The ASCII character corresponding to the octal number
|
||||
.Ar nnn .
|
||||
.El
|
||||
.Pp
|
||||
.Sq \e
|
||||
nullifies the special meaning of the following character,
|
||||
if it has any, notably
|
||||
.Sq \e
|
||||
and
|
||||
.Sq ^ .
|
||||
.It Ic echotc Xo
|
||||
.Op Fl sv
|
||||
.Ar arg
|
||||
.Ar ...
|
||||
.Xc
|
||||
Exercise terminal capabilities given in
|
||||
.Ar arg Ar ... .
|
||||
If
|
||||
.Ar arg
|
||||
is
|
||||
.Sq baud ,
|
||||
.Sq cols ,
|
||||
.Sq lines ,
|
||||
.Sq rows ,
|
||||
.Sq meta or
|
||||
.Sq tabs ,
|
||||
the value of that capability is printed, with
|
||||
.Dq yes
|
||||
or
|
||||
.Dq no
|
||||
indicating that the terminal does or does not have that capability.
|
||||
.Pp
|
||||
.Fl s
|
||||
returns an empty string for non-existent capabilities, rather than
|
||||
causing an error.
|
||||
.Fl v
|
||||
causes messages to be verbose.
|
||||
.It Ic edit Op Li on | Li off
|
||||
Enable or disable the
|
||||
.Nm editline
|
||||
functionality in a program.
|
||||
.It Ic history Ar list | Ar size Dv n | Ar unique Dv n
|
||||
The
|
||||
.Ar list
|
||||
command lists all entries in the history.
|
||||
The
|
||||
.Ar size
|
||||
command sets the history size to
|
||||
.Dv n
|
||||
entries.
|
||||
The
|
||||
.Ar unique
|
||||
command controls if history should keep duplicate entries.
|
||||
If
|
||||
.Dv n
|
||||
is non zero, only keep unique history entries.
|
||||
If
|
||||
.Dv n
|
||||
is zero, then keep all entries (the default).
|
||||
.It Ic telltc
|
||||
List the values of all the terminal capabilities (see
|
||||
.Xr termcap 5 ) .
|
||||
.It Ic settc Ar cap Ar val
|
||||
Set the terminal capability
|
||||
.Ar cap
|
||||
to
|
||||
.Ar val ,
|
||||
as defined in
|
||||
.Xr termcap 5 .
|
||||
No sanity checking is done.
|
||||
.It Ic setty Xo
|
||||
.Op Fl a
|
||||
.Op Fl d
|
||||
.Op Fl q
|
||||
.Op Fl x
|
||||
.Op Ar +mode
|
||||
.Op Ar -mode
|
||||
.Op Ar mode
|
||||
.Op Ar char=c
|
||||
.Xc
|
||||
Control which tty modes that
|
||||
.Nm
|
||||
won't allow the user to change.
|
||||
.Fl d ,
|
||||
.Fl q
|
||||
or
|
||||
.Fl x
|
||||
tells
|
||||
.Ic setty
|
||||
to act on the
|
||||
.Sq edit ,
|
||||
.Sq quote
|
||||
or
|
||||
.Sq execute
|
||||
set of tty modes respectively; defaulting to
|
||||
.Fl x .
|
||||
.Pp
|
||||
Without other arguments,
|
||||
.Ic setty
|
||||
lists the modes in the chosen set which are fixed on
|
||||
.Po
|
||||
.Sq +mode
|
||||
.Pc
|
||||
or off
|
||||
.Po
|
||||
.Sq -mode
|
||||
.Pc .
|
||||
.Fl a
|
||||
lists all tty modes in the chosen set regardless of the setting.
|
||||
With
|
||||
.Ar +mode ,
|
||||
.Ar -mode
|
||||
or
|
||||
.Ar mode ,
|
||||
fixes
|
||||
.Ar mode
|
||||
on or off or removes control of
|
||||
.Ar mode
|
||||
in the chosen set.
|
||||
.Pp
|
||||
.Ic Setty
|
||||
can also be used to set tty characters to particular values using
|
||||
.Ar char=value .
|
||||
If
|
||||
.Ar value
|
||||
is empty
|
||||
then the character is set to
|
||||
.Dv _POSIX_VDISABLE .
|
||||
.El
|
||||
.Sh EDITOR COMMANDS
|
||||
The following editor commands are available for use in key bindings:
|
||||
.\" Section automatically generated with makelist
|
||||
.Bl -tag -width 4n
|
||||
.It Ic vi-paste-next
|
||||
Vi paste previous deletion to the right of the cursor.
|
||||
.It Ic vi-paste-prev
|
||||
Vi paste previous deletion to the left of the cursor.
|
||||
.It Ic vi-prev-space-word
|
||||
Vi move to the previous space delimited word.
|
||||
.It Ic vi-prev-word
|
||||
Vi move to the previous word.
|
||||
.It Ic vi-next-space-word
|
||||
Vi move to the next space delimited word.
|
||||
.It Ic vi-next-word
|
||||
Vi move to the next word.
|
||||
.It Ic vi-change-case
|
||||
Vi change case of character under the cursor and advance one character.
|
||||
.It Ic vi-change-meta
|
||||
Vi change prefix command.
|
||||
.It Ic vi-insert-at-bol
|
||||
Vi enter insert mode at the beginning of line.
|
||||
.It Ic vi-replace-char
|
||||
Vi replace character under the cursor with the next character typed.
|
||||
.It Ic vi-replace-mode
|
||||
Vi enter replace mode.
|
||||
.It Ic vi-substitute-char
|
||||
Vi replace character under the cursor and enter insert mode.
|
||||
.It Ic vi-substitute-line
|
||||
Vi substitute entire line.
|
||||
.It Ic vi-change-to-eol
|
||||
Vi change to end of line.
|
||||
.It Ic vi-insert
|
||||
Vi enter insert mode.
|
||||
.It Ic vi-add
|
||||
Vi enter insert mode after the cursor.
|
||||
.It Ic vi-add-at-eol
|
||||
Vi enter insert mode at end of line.
|
||||
.It Ic vi-delete-meta
|
||||
Vi delete prefix command.
|
||||
.It Ic vi-end-word
|
||||
Vi move to the end of the current space delimited word.
|
||||
.It Ic vi-to-end-word
|
||||
Vi move to the end of the current word.
|
||||
.It Ic vi-undo
|
||||
Vi undo last change.
|
||||
.It Ic vi-command-mode
|
||||
Vi enter command mode (use alternative key bindings).
|
||||
.It Ic vi-zero
|
||||
Vi move to the beginning of line.
|
||||
.It Ic vi-delete-prev-char
|
||||
Vi move to previous character (backspace).
|
||||
.It Ic vi-list-or-eof
|
||||
Vi list choices for completion or indicate end of file if empty line.
|
||||
.It Ic vi-kill-line-prev
|
||||
Vi cut from beginning of line to cursor.
|
||||
.It Ic vi-search-prev
|
||||
Vi search history previous.
|
||||
.It Ic vi-search-next
|
||||
Vi search history next.
|
||||
.It Ic vi-repeat-search-next
|
||||
Vi repeat current search in the same search direction.
|
||||
.It Ic vi-repeat-search-prev
|
||||
Vi repeat current search in the opposite search direction.
|
||||
.It Ic vi-next-char
|
||||
Vi move to the character specified next.
|
||||
.It Ic vi-prev-char
|
||||
Vi move to the character specified previous.
|
||||
.It Ic vi-to-next-char
|
||||
Vi move up to the character specified next.
|
||||
.It Ic vi-to-prev-char
|
||||
Vi move up to the character specified previous.
|
||||
.It Ic vi-repeat-next-char
|
||||
Vi repeat current character search in the same search direction.
|
||||
.It Ic vi-repeat-prev-char
|
||||
Vi repeat current character search in the opposite search direction.
|
||||
.It Ic em-delete-or-list
|
||||
Delete character under cursor or list completions if at end of line.
|
||||
.It Ic em-delete-next-word
|
||||
Cut from cursor to end of current word.
|
||||
.It Ic em-yank
|
||||
Paste cut buffer at cursor position.
|
||||
.It Ic em-kill-line
|
||||
Cut the entire line and save in cut buffer.
|
||||
.It Ic em-kill-region
|
||||
Cut area between mark and cursor and save in cut buffer.
|
||||
.It Ic em-copy-region
|
||||
Copy area between mark and cursor to cut buffer.
|
||||
.It Ic em-gosmacs-transpose
|
||||
Exchange the two characters before the cursor.
|
||||
.It Ic em-next-word
|
||||
Move next to end of current word.
|
||||
.It Ic em-upper-case
|
||||
Uppercase the characters from cursor to end of current word.
|
||||
.It Ic em-capitol-case
|
||||
Capitalize the characters from cursor to end of current word.
|
||||
.It Ic em-lower-case
|
||||
Lowercase the characters from cursor to end of current word.
|
||||
.It Ic em-set-mark
|
||||
Set the mark at cursor.
|
||||
.It Ic em-exchange-mark
|
||||
Exchange the cursor and mark.
|
||||
.It Ic em-universal-argument
|
||||
Universal argument (argument times 4).
|
||||
.It Ic em-meta-next
|
||||
Add 8th bit to next character typed.
|
||||
.It Ic em-toggle-overwrite
|
||||
Switch from insert to overwrite mode or vice versa.
|
||||
.It Ic em-copy-prev-word
|
||||
Copy current word to cursor.
|
||||
.It Ic em-inc-search-next
|
||||
Emacs incremental next search.
|
||||
.It Ic em-inc-search-prev
|
||||
Emacs incremental reverse search.
|
||||
.It Ic ed-end-of-file
|
||||
Indicate end of file.
|
||||
.It Ic ed-insert
|
||||
Add character to the line.
|
||||
.It Ic ed-delete-prev-word
|
||||
Delete from beginning of current word to cursor.
|
||||
.It Ic ed-delete-next-char
|
||||
Delete character under cursor.
|
||||
.It Ic ed-kill-line
|
||||
Cut to the end of line.
|
||||
.It Ic ed-move-to-end
|
||||
Move cursor to the end of line.
|
||||
.It Ic ed-move-to-beg
|
||||
Move cursor to the beginning of line.
|
||||
.It Ic ed-transpose-chars
|
||||
Exchange the character to the left of the cursor with the one under it.
|
||||
.It Ic ed-next-char
|
||||
Move to the right one character.
|
||||
.It Ic ed-prev-word
|
||||
Move to the beginning of the current word.
|
||||
.It Ic ed-prev-char
|
||||
Move to the left one character.
|
||||
.It Ic ed-quoted-insert
|
||||
Add the next character typed verbatim.
|
||||
.It Ic ed-digit
|
||||
Adds to argument or enters a digit.
|
||||
.It Ic ed-argument-digit
|
||||
Digit that starts argument.
|
||||
.It Ic ed-unassigned
|
||||
Indicates unbound character.
|
||||
.It Ic ed-tty-sigint
|
||||
Tty interrupt character.
|
||||
.It Ic ed-tty-dsusp
|
||||
Tty delayed suspend character.
|
||||
.It Ic ed-tty-flush-output
|
||||
Tty flush output characters.
|
||||
.It Ic ed-tty-sigquit
|
||||
Tty quit character.
|
||||
.It Ic ed-tty-sigtstp
|
||||
Tty suspend character.
|
||||
.It Ic ed-tty-stop-output
|
||||
Tty disallow output characters.
|
||||
.It Ic ed-tty-start-output
|
||||
Tty allow output characters.
|
||||
.It Ic ed-newline
|
||||
Execute command.
|
||||
.It Ic ed-delete-prev-char
|
||||
Delete the character to the left of the cursor.
|
||||
.It Ic ed-clear-screen
|
||||
Clear screen leaving current line at the top.
|
||||
.It Ic ed-redisplay
|
||||
Redisplay everything.
|
||||
.It Ic ed-start-over
|
||||
Erase current line and start from scratch.
|
||||
.It Ic ed-sequence-lead-in
|
||||
First character in a bound sequence.
|
||||
.It Ic ed-prev-history
|
||||
Move to the previous history line.
|
||||
.It Ic ed-next-history
|
||||
Move to the next history line.
|
||||
.It Ic ed-search-prev-history
|
||||
Search previous in history for a line matching the current.
|
||||
.It Ic ed-search-next-history
|
||||
Search next in history for a line matching the current.
|
||||
.It Ic ed-prev-line
|
||||
Move up one line.
|
||||
.It Ic ed-next-line
|
||||
Move down one line.
|
||||
.It Ic ed-command
|
||||
Editline extended command.
|
||||
.El
|
||||
.\" End of section automatically generated with makelist
|
||||
.Sh SEE ALSO
|
||||
.Xr editline 3 ,
|
||||
.Xr regex 3 ,
|
||||
.Xr termcap 5
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Nm editline
|
||||
library was written by Christos Zoulas,
|
||||
and this manual was written by Luke Mewburn,
|
||||
with some sections inspired by
|
||||
.Xr tcsh 1 .
|
521
libedit/el.c
Normal file
521
libedit/el.c
Normal file
@ -0,0 +1,521 @@
|
||||
/* $NetBSD: el.c,v 1.5 2005/06/09 16:48:57 lukem Exp $ */
|
||||
/* from NetBSD: el.c,v 1.39 2004/07/08 00:51:36 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* el.c: EditLine interface functions
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "el.h"
|
||||
|
||||
/* el_init():
|
||||
* Initialize editline and set default parameters.
|
||||
*/
|
||||
public EditLine *
|
||||
el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
|
||||
{
|
||||
|
||||
EditLine *el = (EditLine *) el_malloc(sizeof(EditLine));
|
||||
|
||||
if (el == NULL)
|
||||
return (NULL);
|
||||
|
||||
memset(el, 0, sizeof(EditLine));
|
||||
|
||||
el->el_infd = fileno(fin);
|
||||
el->el_outfile = fout;
|
||||
el->el_errfile = ferr;
|
||||
if ((el->el_prog = el_strdup(prog)) == NULL) {
|
||||
el_free(el);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all the modules. Order is important!!!
|
||||
*/
|
||||
el->el_flags = 0;
|
||||
|
||||
if (term_init(el) == -1) {
|
||||
el_free(el->el_prog);
|
||||
el_free(el);
|
||||
return NULL;
|
||||
}
|
||||
(void) key_init(el);
|
||||
(void) map_init(el);
|
||||
if (tty_init(el) == -1)
|
||||
el->el_flags |= NO_TTY;
|
||||
(void) ch_init(el);
|
||||
(void) search_init(el);
|
||||
(void) hist_init(el);
|
||||
(void) prompt_init(el);
|
||||
(void) sig_init(el);
|
||||
(void) read_init(el);
|
||||
|
||||
return (el);
|
||||
}
|
||||
|
||||
|
||||
/* el_end():
|
||||
* Clean up.
|
||||
*/
|
||||
public void
|
||||
el_end(EditLine *el)
|
||||
{
|
||||
|
||||
if (el == NULL)
|
||||
return;
|
||||
|
||||
el_reset(el);
|
||||
|
||||
term_end(el);
|
||||
key_end(el);
|
||||
map_end(el);
|
||||
tty_end(el);
|
||||
ch_end(el);
|
||||
search_end(el);
|
||||
hist_end(el);
|
||||
prompt_end(el);
|
||||
sig_end(el);
|
||||
|
||||
el_free((ptr_t) el->el_prog);
|
||||
el_free((ptr_t) el);
|
||||
}
|
||||
|
||||
|
||||
/* el_reset():
|
||||
* Reset the tty and the parser
|
||||
*/
|
||||
public void
|
||||
el_reset(EditLine *el)
|
||||
{
|
||||
|
||||
tty_cookedmode(el);
|
||||
ch_reset(el); /* XXX: Do we want that? */
|
||||
}
|
||||
|
||||
|
||||
/* el_set():
|
||||
* set the editline parameters
|
||||
*/
|
||||
public int
|
||||
el_set(EditLine *el, int op, ...)
|
||||
{
|
||||
va_list va;
|
||||
int rv = 0;
|
||||
|
||||
if (el == NULL)
|
||||
return (-1);
|
||||
va_start(va, op);
|
||||
|
||||
switch (op) {
|
||||
case EL_PROMPT:
|
||||
case EL_RPROMPT:
|
||||
rv = prompt_set(el, va_arg(va, el_pfunc_t), op);
|
||||
break;
|
||||
|
||||
case EL_TERMINAL:
|
||||
rv = term_set(el, va_arg(va, char *));
|
||||
break;
|
||||
|
||||
case EL_EDITOR:
|
||||
rv = map_set_editor(el, va_arg(va, char *));
|
||||
break;
|
||||
|
||||
case EL_SIGNAL:
|
||||
if (va_arg(va, int))
|
||||
el->el_flags |= HANDLE_SIGNALS;
|
||||
else
|
||||
el->el_flags &= ~HANDLE_SIGNALS;
|
||||
break;
|
||||
|
||||
case EL_BIND:
|
||||
case EL_TELLTC:
|
||||
case EL_SETTC:
|
||||
case EL_ECHOTC:
|
||||
case EL_SETTY:
|
||||
{
|
||||
const char *argv[20];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < 20; i++)
|
||||
if ((argv[i] = va_arg(va, char *)) == NULL)
|
||||
break;
|
||||
|
||||
switch (op) {
|
||||
case EL_BIND:
|
||||
argv[0] = "bind";
|
||||
rv = map_bind(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_TELLTC:
|
||||
argv[0] = "telltc";
|
||||
rv = term_telltc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTC:
|
||||
argv[0] = "settc";
|
||||
rv = term_settc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_ECHOTC:
|
||||
argv[0] = "echotc";
|
||||
rv = term_echotc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTY:
|
||||
argv[0] = "setty";
|
||||
rv = tty_stty(el, i, argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_ADDFN:
|
||||
{
|
||||
char *name = va_arg(va, char *);
|
||||
char *help = va_arg(va, char *);
|
||||
el_func_t func = va_arg(va, el_func_t);
|
||||
|
||||
rv = map_addfunc(el, name, help, func);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_HIST:
|
||||
{
|
||||
hist_fun_t func = va_arg(va, hist_fun_t);
|
||||
ptr_t ptr = va_arg(va, char *);
|
||||
|
||||
rv = hist_set(el, func, ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_EDITMODE:
|
||||
if (va_arg(va, int))
|
||||
el->el_flags &= ~EDIT_DISABLED;
|
||||
else
|
||||
el->el_flags |= EDIT_DISABLED;
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_GETCFN:
|
||||
{
|
||||
el_rfunc_t rc = va_arg(va, el_rfunc_t);
|
||||
rv = el_read_setfn(el, rc);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_CLIENTDATA:
|
||||
el->el_data = va_arg(va, void *);
|
||||
break;
|
||||
|
||||
case EL_UNBUFFERED:
|
||||
rv = va_arg(va, int);
|
||||
if (rv && !(el->el_flags & UNBUFFERED)) {
|
||||
el->el_flags |= UNBUFFERED;
|
||||
read_prepare(el);
|
||||
} else if (!rv && (el->el_flags & UNBUFFERED)) {
|
||||
el->el_flags &= ~UNBUFFERED;
|
||||
read_finish(el);
|
||||
}
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_PREP_TERM:
|
||||
rv = va_arg(va, int);
|
||||
if (rv)
|
||||
(void) tty_rawmode(el);
|
||||
else
|
||||
(void) tty_cookedmode(el);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(va);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
/* el_get():
|
||||
* retrieve the editline parameters
|
||||
*/
|
||||
public int
|
||||
el_get(EditLine *el, int op, void *ret)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (el == NULL || ret == NULL)
|
||||
return (-1);
|
||||
switch (op) {
|
||||
case EL_PROMPT:
|
||||
case EL_RPROMPT:
|
||||
rv = prompt_get(el, (void *) &ret, op);
|
||||
break;
|
||||
|
||||
case EL_EDITOR:
|
||||
rv = map_get_editor(el, (void *) &ret);
|
||||
break;
|
||||
|
||||
case EL_SIGNAL:
|
||||
*((int *) ret) = (el->el_flags & HANDLE_SIGNALS);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_EDITMODE:
|
||||
*((int *) ret) = (!(el->el_flags & EDIT_DISABLED));
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_TERMINAL:
|
||||
term_get(el, (const char **)ret);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
#if 0 /* XXX */
|
||||
case EL_BIND:
|
||||
case EL_TELLTC:
|
||||
case EL_SETTC:
|
||||
case EL_ECHOTC:
|
||||
case EL_SETTY:
|
||||
{
|
||||
const char *argv[20];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
|
||||
if ((argv[i] = va_arg(va, char *)) == NULL)
|
||||
break;
|
||||
|
||||
switch (op) {
|
||||
case EL_BIND:
|
||||
argv[0] = "bind";
|
||||
rv = map_bind(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_TELLTC:
|
||||
argv[0] = "telltc";
|
||||
rv = term_telltc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTC:
|
||||
argv[0] = "settc";
|
||||
rv = term_settc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_ECHOTC:
|
||||
argv[0] = "echotc";
|
||||
rv = term_echotc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTY:
|
||||
argv[0] = "setty";
|
||||
rv = tty_stty(el, i, argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
EL_ABORT((el->errfile, "Bad op %d\n", op));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_ADDFN:
|
||||
{
|
||||
char *name = va_arg(va, char *);
|
||||
char *help = va_arg(va, char *);
|
||||
el_func_t func = va_arg(va, el_func_t);
|
||||
|
||||
rv = map_addfunc(el, name, help, func);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_HIST:
|
||||
{
|
||||
hist_fun_t func = va_arg(va, hist_fun_t);
|
||||
ptr_t ptr = va_arg(va, char *);
|
||||
rv = hist_set(el, func, ptr);
|
||||
}
|
||||
break;
|
||||
#endif /* XXX */
|
||||
|
||||
case EL_GETCFN:
|
||||
*((el_rfunc_t *)ret) = el_read_getfn(el);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_CLIENTDATA:
|
||||
*((void **)ret) = el->el_data;
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_UNBUFFERED:
|
||||
*((int *) ret) = (!(el->el_flags & UNBUFFERED));
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
}
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
/* el_line():
|
||||
* Return editing info
|
||||
*/
|
||||
public const LineInfo *
|
||||
el_line(EditLine *el)
|
||||
{
|
||||
|
||||
return (const LineInfo *) (void *) &el->el_line;
|
||||
}
|
||||
|
||||
|
||||
/* el_source():
|
||||
* Source a file
|
||||
*/
|
||||
public int
|
||||
el_source(EditLine *el, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
char *ptr;
|
||||
|
||||
fp = NULL;
|
||||
if (fname == NULL) {
|
||||
static const char elpath[] = "/.editrc";
|
||||
char path[MAXPATHLEN];
|
||||
|
||||
if ((ptr = getenv("HOME")) == NULL)
|
||||
return (-1);
|
||||
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
|
||||
return (-1);
|
||||
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
|
||||
return (-1);
|
||||
fname = path;
|
||||
}
|
||||
if (fp == NULL)
|
||||
fp = fopen(fname, "r");
|
||||
if (fp == NULL)
|
||||
return (-1);
|
||||
|
||||
while ((ptr = fgetln(fp, &len)) != NULL) {
|
||||
if (len > 0 && ptr[len - 1] == '\n')
|
||||
--len;
|
||||
ptr[len] = '\0';
|
||||
if (parse_line(el, ptr) == -1) {
|
||||
(void) fclose(fp);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
(void) fclose(fp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* el_resize():
|
||||
* Called from program when terminal is resized
|
||||
*/
|
||||
public void
|
||||
el_resize(EditLine *el)
|
||||
{
|
||||
int lins, cols;
|
||||
sigset_t oset, nset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
(void) sigaddset(&nset, SIGWINCH);
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
/* get the correct window size */
|
||||
if (term_get_size(el, &lins, &cols))
|
||||
term_change_size(el, lins, cols);
|
||||
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* el_beep():
|
||||
* Called from the program to beep
|
||||
*/
|
||||
public void
|
||||
el_beep(EditLine *el)
|
||||
{
|
||||
|
||||
term_beep(el);
|
||||
}
|
||||
|
||||
|
||||
/* el_editmode()
|
||||
* Set the state of EDIT_DISABLED from the `edit' command.
|
||||
*/
|
||||
protected int
|
||||
/*ARGSUSED*/
|
||||
el_editmode(EditLine *el, int argc, const char **argv)
|
||||
{
|
||||
const char *how;
|
||||
|
||||
if (argv == NULL || argc != 2 || argv[1] == NULL)
|
||||
return (-1);
|
||||
|
||||
how = argv[1];
|
||||
if (strcmp(how, "on") == 0) {
|
||||
el->el_flags &= ~EDIT_DISABLED;
|
||||
tty_rawmode(el);
|
||||
} else if (strcmp(how, "off") == 0) {
|
||||
tty_cookedmode(el);
|
||||
el->el_flags |= EDIT_DISABLED;
|
||||
}
|
||||
else {
|
||||
(void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
150
libedit/el.h
Normal file
150
libedit/el.h
Normal file
@ -0,0 +1,150 @@
|
||||
/* $NetBSD: el.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: el.h,v 1.16 2003/10/18 23:48:42 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)el.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.h: Internal structures.
|
||||
*/
|
||||
#ifndef _h_el
|
||||
#define _h_el
|
||||
/*
|
||||
* Local defaults
|
||||
*/
|
||||
#define KSHVI
|
||||
#define VIDEFAULT
|
||||
#define ANCHOR
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define EL_BUFSIZ 1024 /* Maximum line size */
|
||||
|
||||
#define HANDLE_SIGNALS 0x01
|
||||
#define NO_TTY 0x02
|
||||
#define EDIT_DISABLED 0x04
|
||||
#define UNBUFFERED 0x08
|
||||
|
||||
typedef int bool_t; /* True or not */
|
||||
|
||||
typedef unsigned char el_action_t; /* Index to command array */
|
||||
|
||||
typedef struct coord_t { /* Position on the screen */
|
||||
int h;
|
||||
int v;
|
||||
} coord_t;
|
||||
|
||||
typedef struct el_line_t {
|
||||
char *buffer; /* Input line */
|
||||
char *cursor; /* Cursor position */
|
||||
char *lastchar; /* Last character */
|
||||
const char *limit; /* Max position */
|
||||
} el_line_t;
|
||||
|
||||
/*
|
||||
* Editor state
|
||||
*/
|
||||
typedef struct el_state_t {
|
||||
int inputmode; /* What mode are we in? */
|
||||
int doingarg; /* Are we getting an argument? */
|
||||
int argument; /* Numeric argument */
|
||||
int metanext; /* Is the next char a meta char */
|
||||
el_action_t lastcmd; /* Previous command */
|
||||
el_action_t thiscmd; /* this command */
|
||||
char thisch; /* char that generated it */
|
||||
} el_state_t;
|
||||
|
||||
/*
|
||||
* Until we come up with something better...
|
||||
*/
|
||||
#define el_strdup(a) strdup(a)
|
||||
#define el_malloc(a) malloc(a)
|
||||
#define el_realloc(a,b) realloc(a, b)
|
||||
#define el_free(a) free(a)
|
||||
|
||||
#include "tty.h"
|
||||
#include "prompt.h"
|
||||
#include "key.h"
|
||||
#include "term.h"
|
||||
#include "refresh.h"
|
||||
#include "chared.h"
|
||||
#include "common.h"
|
||||
#include "search.h"
|
||||
#include "hist.h"
|
||||
#include "map.h"
|
||||
#include "parse.h"
|
||||
#include "sig.h"
|
||||
#include "help.h"
|
||||
#include "read.h"
|
||||
|
||||
struct editline {
|
||||
char *el_prog; /* the program name */
|
||||
FILE *el_outfile; /* Stdio stuff */
|
||||
FILE *el_errfile; /* Stdio stuff */
|
||||
int el_infd; /* Input file descriptor */
|
||||
int el_flags; /* Various flags. */
|
||||
coord_t el_cursor; /* Cursor location */
|
||||
char **el_display; /* Real screen image = what is there */
|
||||
char **el_vdisplay; /* Virtual screen image = what we see */
|
||||
void *el_data; /* Client data */
|
||||
el_line_t el_line; /* The current line information */
|
||||
el_state_t el_state; /* Current editor state */
|
||||
el_term_t el_term; /* Terminal dependent stuff */
|
||||
el_tty_t el_tty; /* Tty dependent stuff */
|
||||
el_refresh_t el_refresh; /* Refresh stuff */
|
||||
el_prompt_t el_prompt; /* Prompt stuff */
|
||||
el_prompt_t el_rprompt; /* Prompt stuff */
|
||||
el_chared_t el_chared; /* Characted editor stuff */
|
||||
el_map_t el_map; /* Key mapping stuff */
|
||||
el_key_t el_key; /* Key binding stuff */
|
||||
el_history_t el_history; /* History stuff */
|
||||
el_search_t el_search; /* Search stuff */
|
||||
el_signal_t el_signal; /* Signal handling stuff */
|
||||
el_read_t el_read; /* Character reading stuff */
|
||||
};
|
||||
|
||||
protected int el_editmode(EditLine *, int, const char **);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define EL_ABORT(a) do { \
|
||||
fprintf(el->el_errfile, "%s, %d: ", \
|
||||
__FILE__, __LINE__); \
|
||||
fprintf a; \
|
||||
abort(); \
|
||||
} while( /*CONSTCOND*/0);
|
||||
#else
|
||||
#define EL_ABORT(a) abort()
|
||||
#endif
|
||||
#endif /* _h_el */
|
503
libedit/emacs.c
Normal file
503
libedit/emacs.c
Normal file
@ -0,0 +1,503 @@
|
||||
/* $NetBSD: emacs.c,v 1.5 2005/06/09 16:48:57 lukem Exp $ */
|
||||
/* from NetBSD: emacs.c,v 1.19 2004/10/28 21:14:52 dsl Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* emacs.c: Emacs functions
|
||||
*/
|
||||
#include "el.h"
|
||||
|
||||
/* em_delete_or_list():
|
||||
* Delete character under cursor or list completions if at end of line
|
||||
* [^D]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_or_list(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
/* if I'm at the end */
|
||||
if (el->el_line.cursor == el->el_line.buffer) {
|
||||
/* and the beginning */
|
||||
term_overwrite(el, STReof, 4); /* then do a EOF */
|
||||
term__flush();
|
||||
return (CC_EOF);
|
||||
} else {
|
||||
/*
|
||||
* Here we could list completions, but it is an
|
||||
* error right now
|
||||
*/
|
||||
term_beep(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (el->el_state.doingarg)
|
||||
c_delafter(el, el->el_state.argument);
|
||||
else
|
||||
c_delafter1(el);
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
/* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* em_delete_next_word():
|
||||
* Cut from cursor to end of current word
|
||||
* [M-d]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *p, *kp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
return (CC_ERROR);
|
||||
|
||||
cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
|
||||
/* save the text */
|
||||
*kp++ = *p;
|
||||
el->el_chared.c_kill.last = kp;
|
||||
|
||||
c_delafter(el, cp - el->el_line.cursor); /* delete after dot */
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
/* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_yank():
|
||||
* Paste cut buffer at cursor position
|
||||
* [^Y]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_yank(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
|
||||
return (CC_NORM);
|
||||
|
||||
if (el->el_line.lastchar +
|
||||
(el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
|
||||
el->el_line.limit)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.cursor;
|
||||
cp = el->el_line.cursor;
|
||||
|
||||
/* open the space, */
|
||||
c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
|
||||
/* copy the chars */
|
||||
for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
|
||||
*cp++ = *kp;
|
||||
|
||||
/* if an arg, cursor at beginning else cursor at end */
|
||||
if (el->el_state.argument == 1)
|
||||
el->el_line.cursor = cp;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_kill_line():
|
||||
* Cut the entire line and save in cut buffer
|
||||
* [^U]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
cp = el->el_line.buffer;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.lastchar)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
/* zap! -- delete all of it */
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_kill_region():
|
||||
* Cut area between mark and cursor and save in cut buffer
|
||||
* [^W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_region(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (!el->el_chared.c_kill.mark)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_chared.c_kill.mark)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
c_delafter(el, cp - el->el_line.cursor);
|
||||
} else { /* mark is before cursor */
|
||||
cp = el->el_chared.c_kill.mark;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.cursor)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
c_delbefore(el, cp - el->el_chared.c_kill.mark);
|
||||
el->el_line.cursor = el->el_chared.c_kill.mark;
|
||||
}
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_copy_region():
|
||||
* Copy area between mark and cursor to cut buffer
|
||||
* [M-W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_region(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (!el->el_chared.c_kill.mark)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_chared.c_kill.mark)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
} else {
|
||||
cp = el->el_chared.c_kill.mark;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.cursor)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
}
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_gosmacs_transpose():
|
||||
* Exchange the two characters before the cursor
|
||||
* Gosling emacs transpose chars [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
em_gosmacs_transpose(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
return (CC_REFRESH);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* em_next_word():
|
||||
* Move next to end of current word
|
||||
* [M-f]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_next_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor = c__next_word(el->el_line.cursor,
|
||||
el->el_line.lastchar,
|
||||
el->el_state.argument,
|
||||
ce__isword);
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* em_upper_case():
|
||||
* Uppercase the characters from cursor to end of current word
|
||||
* [M-u]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_upper_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++)
|
||||
if (islower((unsigned char)*cp))
|
||||
*cp = toupper((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_capitol_case():
|
||||
* Capitalize the characters from cursor to end of current word
|
||||
* [M-c]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++) {
|
||||
if (isalpha((unsigned char)*cp)) {
|
||||
if (islower((unsigned char)*cp))
|
||||
*cp = toupper((unsigned char)*cp);
|
||||
cp++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; cp < ep; cp++)
|
||||
if (isupper((unsigned char)*cp))
|
||||
*cp = tolower((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_lower_case():
|
||||
* Lowercase the characters from cursor to end of current word
|
||||
* [M-l]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_lower_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++)
|
||||
if (isupper((unsigned char)*cp))
|
||||
*cp = tolower((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_set_mark():
|
||||
* Set the mark at cursor
|
||||
* [^@]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_set_mark(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.cursor;
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_exchange_mark():
|
||||
* Exchange the cursor and mark
|
||||
* [^X^X]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
el->el_line.cursor = el->el_chared.c_kill.mark;
|
||||
el->el_chared.c_kill.mark = cp;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* em_universal_argument():
|
||||
* Universal argument (argument times 4)
|
||||
* [^U]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
|
||||
{ /* multiply current argument by 4 */
|
||||
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.doingarg = 1;
|
||||
el->el_state.argument *= 4;
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* em_meta_next():
|
||||
* Add 8th bit to next character typed
|
||||
* [<ESC>]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_meta_next(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.metanext = 1;
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* em_toggle_overwrite():
|
||||
* Switch from insert to overwrite mode or vice versa
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
|
||||
MODE_REPLACE : MODE_INSERT;
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_copy_prev_word():
|
||||
* Copy current word to cursor
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *oldc, *dp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
oldc = el->el_line.cursor;
|
||||
/* does a bounds check */
|
||||
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
c_insert(el, oldc - cp);
|
||||
for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
|
||||
*dp++ = *cp;
|
||||
|
||||
el->el_line.cursor = dp;/* put cursor at end */
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_inc_search_next():
|
||||
* Emacs incremental next search
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
return (ce_inc_search(el, ED_SEARCH_NEXT_HISTORY));
|
||||
}
|
||||
|
||||
|
||||
/* em_inc_search_prev():
|
||||
* Emacs incremental reverse search
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
|
||||
}
|
||||
|
||||
|
||||
/* em_delete_prev_char():
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg)
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
else
|
||||
c_delbefore1(el);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
529
libedit/filecomplete.c
Normal file
529
libedit/filecomplete.c
Normal file
@ -0,0 +1,529 @@
|
||||
/* $NetBSD: filecomplete.c,v 1.3 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: filecomplete.c,v 1.5 2005/05/18 22:34:41 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_VIS_H
|
||||
#include <vis.h>
|
||||
#else
|
||||
#include "np/vis.h"
|
||||
#endif
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
#include "el.h"
|
||||
#include "fcns.h" /* for EL_NUM_FCNS */
|
||||
#include "histedit.h"
|
||||
#include "filecomplete.h"
|
||||
|
||||
static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
|
||||
'>', '<', '=', ';', '|', '&', '{', '(', '\0' };
|
||||
|
||||
|
||||
/********************************/
|
||||
/* completion functions */
|
||||
|
||||
/*
|
||||
* does tilde expansion of strings of type ``~user/foo''
|
||||
* if ``user'' isn't valid user name or ``txt'' doesn't start
|
||||
* w/ '~', returns pointer to strdup()ed copy of ``txt''
|
||||
*
|
||||
* it's callers's responsibility to free() returned string
|
||||
*/
|
||||
char *
|
||||
tilde_expand(char *txt)
|
||||
{
|
||||
struct passwd pwres, *pass;
|
||||
char *temp;
|
||||
size_t len = 0;
|
||||
char pwbuf[1024];
|
||||
|
||||
if (txt[0] != '~')
|
||||
return (strdup(txt));
|
||||
|
||||
temp = strchr(txt + 1, '/');
|
||||
if (temp == NULL) {
|
||||
temp = strdup(txt + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
len = temp - txt + 1; /* text until string after slash */
|
||||
temp = malloc(len);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)strncpy(temp, txt + 1, len - 2);
|
||||
temp[len - 2] = '\0';
|
||||
}
|
||||
if (temp[0] == 0) {
|
||||
if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), &pass) != 0)
|
||||
pass = NULL;
|
||||
} else {
|
||||
if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0)
|
||||
pass = NULL;
|
||||
}
|
||||
free(temp); /* value no more needed */
|
||||
if (pass == NULL)
|
||||
return (strdup(txt));
|
||||
|
||||
/* update pointer txt to point at string immedially following */
|
||||
/* first slash */
|
||||
txt += len;
|
||||
|
||||
temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return first found file name starting by the ``text'' or NULL if no
|
||||
* such file can be found
|
||||
* value of ``state'' is ignored
|
||||
*
|
||||
* it's caller's responsibility to free returned string
|
||||
*/
|
||||
char *
|
||||
filename_completion_function(const char *text, int state)
|
||||
{
|
||||
static DIR *dir = NULL;
|
||||
static char *filename = NULL, *dirname = NULL, *dirpath = NULL;
|
||||
static size_t filename_len = 0;
|
||||
struct dirent *entry;
|
||||
char *temp;
|
||||
size_t len;
|
||||
|
||||
if (state == 0 || dir == NULL) {
|
||||
temp = strrchr(text, '/');
|
||||
if (temp) {
|
||||
char *nptr;
|
||||
temp++;
|
||||
nptr = realloc(filename, strlen(temp) + 1);
|
||||
if (nptr == NULL) {
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
filename = nptr;
|
||||
(void)strcpy(filename, temp);
|
||||
len = temp - text; /* including last slash */
|
||||
nptr = realloc(dirname, len + 1);
|
||||
if (nptr == NULL) {
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
dirname = nptr;
|
||||
(void)strncpy(dirname, text, len);
|
||||
dirname[len] = '\0';
|
||||
} else {
|
||||
if (*text == 0)
|
||||
filename = NULL;
|
||||
else {
|
||||
filename = strdup(text);
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
}
|
||||
dirname = NULL;
|
||||
}
|
||||
|
||||
if (dir != NULL) {
|
||||
(void)closedir(dir);
|
||||
dir = NULL;
|
||||
}
|
||||
|
||||
/* support for ``~user'' syntax */
|
||||
free(dirpath);
|
||||
|
||||
if (dirname == NULL && (dirname = strdup("./")) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (*dirname == '~')
|
||||
dirpath = tilde_expand(dirname);
|
||||
else
|
||||
dirpath = strdup(dirname);
|
||||
|
||||
if (dirpath == NULL)
|
||||
return NULL;
|
||||
|
||||
dir = opendir(dirpath);
|
||||
if (!dir)
|
||||
return (NULL); /* cannot open the directory */
|
||||
|
||||
/* will be used in cycle */
|
||||
filename_len = filename ? strlen(filename) : 0;
|
||||
}
|
||||
|
||||
/* find the match */
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
/* skip . and .. */
|
||||
if (entry->d_name[0] == '.' && (!entry->d_name[1]
|
||||
|| (entry->d_name[1] == '.' && !entry->d_name[2])))
|
||||
continue;
|
||||
if (filename_len == 0)
|
||||
break;
|
||||
/* otherwise, get first entry where first */
|
||||
/* filename_len characters are equal */
|
||||
if (entry->d_name[0] == filename[0]
|
||||
#if defined(__SVR4) || defined(__linux__)
|
||||
&& strlen(entry->d_name) >= filename_len
|
||||
#else
|
||||
&& entry->d_namlen >= filename_len
|
||||
#endif
|
||||
&& strncmp(entry->d_name, filename,
|
||||
filename_len) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry) { /* match found */
|
||||
struct stat stbuf;
|
||||
const char *isdir = "";
|
||||
|
||||
#if defined(__SVR4) || defined(__linux__)
|
||||
len = strlen(entry->d_name);
|
||||
#else
|
||||
len = entry->d_namlen;
|
||||
#endif
|
||||
temp = malloc(strlen(dirpath) + len + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)sprintf(temp, "%s%s", dirpath, entry->d_name); /* safe */
|
||||
|
||||
/* test, if it's directory */
|
||||
if (stat(temp, &stbuf) == 0 && S_ISDIR(stbuf.st_mode))
|
||||
isdir = "/";
|
||||
free(temp);
|
||||
temp = malloc(strlen(dirname) + len + 1 + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)sprintf(temp, "%s%s%s", dirname, entry->d_name, isdir);
|
||||
} else {
|
||||
(void)closedir(dir);
|
||||
dir = NULL;
|
||||
temp = NULL;
|
||||
}
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* returns list of completions for text given
|
||||
* non-static for readline.
|
||||
*/
|
||||
char ** completion_matches(const char *, char *(*)(const char *, int));
|
||||
char **
|
||||
completion_matches(const char *text, char *(*genfunc)(const char *, int))
|
||||
{
|
||||
char **match_list = NULL, *retstr, *prevstr;
|
||||
size_t match_list_len, max_equal, which, i;
|
||||
size_t matches;
|
||||
|
||||
matches = 0;
|
||||
match_list_len = 1;
|
||||
while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
|
||||
/* allow for list terminator here */
|
||||
if (matches + 3 >= match_list_len) {
|
||||
char **nmatch_list;
|
||||
while (matches + 3 >= match_list_len)
|
||||
match_list_len <<= 1;
|
||||
nmatch_list = realloc(match_list,
|
||||
match_list_len * sizeof(char *));
|
||||
if (nmatch_list == NULL) {
|
||||
free(match_list);
|
||||
return NULL;
|
||||
}
|
||||
match_list = nmatch_list;
|
||||
|
||||
}
|
||||
match_list[++matches] = retstr;
|
||||
}
|
||||
|
||||
if (!match_list)
|
||||
return NULL; /* nothing found */
|
||||
|
||||
/* find least denominator and insert it to match_list[0] */
|
||||
which = 2;
|
||||
prevstr = match_list[1];
|
||||
max_equal = strlen(prevstr);
|
||||
for (; which <= matches; which++) {
|
||||
for (i = 0; i < max_equal &&
|
||||
prevstr[i] == match_list[which][i]; i++)
|
||||
continue;
|
||||
max_equal = i;
|
||||
}
|
||||
|
||||
retstr = malloc(max_equal + 1);
|
||||
if (retstr == NULL) {
|
||||
free(match_list);
|
||||
return NULL;
|
||||
}
|
||||
(void)strncpy(retstr, match_list[1], max_equal);
|
||||
retstr[max_equal] = '\0';
|
||||
match_list[0] = retstr;
|
||||
|
||||
/* add NULL as last pointer to the array */
|
||||
match_list[matches + 1] = (char *) NULL;
|
||||
|
||||
return (match_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort function for qsort(). Just wrapper around strcasecmp().
|
||||
*/
|
||||
static int
|
||||
_fn_qsort_string_compare(const void *i1, const void *i2)
|
||||
{
|
||||
const char *s1 = ((const char * const *)i1)[0];
|
||||
const char *s2 = ((const char * const *)i2)[0];
|
||||
|
||||
return strcasecmp(s1, s2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display list of strings in columnar format on readline's output stream.
|
||||
* 'matches' is list of strings, 'len' is number of strings in 'matches',
|
||||
* 'max' is maximum length of string in 'matches'.
|
||||
*/
|
||||
void
|
||||
fn_display_match_list (EditLine *el, char **matches, int len, int max)
|
||||
{
|
||||
int i, idx, limit, count;
|
||||
int screenwidth = el->el_term.t_size.h;
|
||||
|
||||
/*
|
||||
* Find out how many entries can be put on one line, count
|
||||
* with two spaces between strings.
|
||||
*/
|
||||
limit = screenwidth / (max + 2);
|
||||
if (limit == 0)
|
||||
limit = 1;
|
||||
|
||||
/* how many lines of output */
|
||||
count = len / limit;
|
||||
if (count * limit < len)
|
||||
count++;
|
||||
|
||||
/* Sort the items if they are not already sorted. */
|
||||
qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
|
||||
_fn_qsort_string_compare);
|
||||
|
||||
idx = 1;
|
||||
for(; count > 0; count--) {
|
||||
for(i = 0; i < limit && matches[idx]; i++, idx++)
|
||||
(void)fprintf(el->el_outfile, "%-*s ", max,
|
||||
matches[idx]);
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Complete the word at or before point,
|
||||
* 'what_to_do' says what to do with the completion.
|
||||
* \t means do standard completion.
|
||||
* `?' means list the possible completions.
|
||||
* `*' means insert all of the possible completions.
|
||||
* `!' means to do standard completion, and list all possible completions if
|
||||
* there is more than one.
|
||||
*
|
||||
* Note: '*' support is not implemented
|
||||
* '!' could never be invoked
|
||||
*/
|
||||
int
|
||||
fn_complete(EditLine *el,
|
||||
char *(*complet_func)(const char *, int),
|
||||
char **(*attempted_completion_function)(const char *, int, int),
|
||||
const char *word_break, const char *special_prefixes,
|
||||
char append_character, int query_items,
|
||||
int *completion_type, int *over, int *point, int *end)
|
||||
{
|
||||
const LineInfo *li;
|
||||
char *temp, **matches;
|
||||
const char *ctemp;
|
||||
size_t len;
|
||||
int what_to_do = '\t';
|
||||
|
||||
if (el->el_state.lastcmd == el->el_state.thiscmd)
|
||||
what_to_do = '?';
|
||||
|
||||
/* readline's rl_complete() has to be told what we did... */
|
||||
if (completion_type != NULL)
|
||||
*completion_type = what_to_do;
|
||||
|
||||
if (!complet_func)
|
||||
complet_func = filename_completion_function;
|
||||
|
||||
/* We now look backwards for the start of a filename/variable word */
|
||||
li = el_line(el);
|
||||
ctemp = (const char *) li->cursor;
|
||||
while (ctemp > li->buffer
|
||||
&& !strchr(word_break, ctemp[-1])
|
||||
&& (!special_prefixes || !strchr(special_prefixes, ctemp[-1]) ) )
|
||||
ctemp--;
|
||||
|
||||
len = li->cursor - ctemp;
|
||||
temp = alloca(len + 1);
|
||||
(void)strncpy(temp, ctemp, len);
|
||||
temp[len] = '\0';
|
||||
|
||||
/* these can be used by function called in completion_matches() */
|
||||
/* or (*attempted_completion_function)() */
|
||||
if (point != 0)
|
||||
*point = li->cursor - li->buffer;
|
||||
if (end != NULL)
|
||||
*end = li->lastchar - li->buffer;
|
||||
|
||||
if (attempted_completion_function) {
|
||||
int cur_off = li->cursor - li->buffer;
|
||||
matches = (*attempted_completion_function) (temp,
|
||||
(int)(cur_off - len), cur_off);
|
||||
} else
|
||||
matches = 0;
|
||||
if (!attempted_completion_function ||
|
||||
(over != NULL && *over && !matches))
|
||||
matches = completion_matches(temp, complet_func);
|
||||
|
||||
if (over != NULL)
|
||||
*over = 0;
|
||||
|
||||
if (matches) {
|
||||
int i, retval = CC_REFRESH;
|
||||
int matches_num, maxlen, match_len, match_display=1;
|
||||
|
||||
/*
|
||||
* Only replace the completed string with common part of
|
||||
* possible matches if there is possible completion.
|
||||
*/
|
||||
if (matches[0][0] != '\0') {
|
||||
el_deletestr(el, (int) len);
|
||||
el_insertstr(el, matches[0]);
|
||||
}
|
||||
|
||||
if (what_to_do == '?')
|
||||
goto display_matches;
|
||||
|
||||
if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
|
||||
/*
|
||||
* We found exact match. Add a space after
|
||||
* it, unless we do filename completion and the
|
||||
* object is a directory.
|
||||
*/
|
||||
size_t alen = strlen(matches[0]);
|
||||
if ((complet_func != filename_completion_function
|
||||
|| (alen > 0 && (matches[0])[alen - 1] != '/'))
|
||||
&& append_character) {
|
||||
char buf[2];
|
||||
buf[0] = append_character;
|
||||
buf[1] = '\0';
|
||||
el_insertstr(el, buf);
|
||||
}
|
||||
} else if (what_to_do == '!') {
|
||||
display_matches:
|
||||
/*
|
||||
* More than one match and requested to list possible
|
||||
* matches.
|
||||
*/
|
||||
|
||||
for(i=1, maxlen=0; matches[i]; i++) {
|
||||
match_len = strlen(matches[i]);
|
||||
if (match_len > maxlen)
|
||||
maxlen = match_len;
|
||||
}
|
||||
matches_num = i - 1;
|
||||
|
||||
/* newline to get on next line from command line */
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
|
||||
/*
|
||||
* If there are too many items, ask user for display
|
||||
* confirmation.
|
||||
*/
|
||||
if (matches_num > query_items) {
|
||||
(void)fprintf(el->el_outfile,
|
||||
"Display all %d possibilities? (y or n) ",
|
||||
matches_num);
|
||||
(void)fflush(el->el_outfile);
|
||||
if (getc(stdin) != 'y')
|
||||
match_display = 0;
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
}
|
||||
|
||||
if (match_display)
|
||||
fn_display_match_list(el, matches, matches_num,
|
||||
maxlen);
|
||||
retval = CC_REDISPLAY;
|
||||
} else if (matches[0][0]) {
|
||||
/*
|
||||
* There was some common match, but the name was
|
||||
* not complete enough. Next tab will print possible
|
||||
* completions.
|
||||
*/
|
||||
el_beep(el);
|
||||
} else {
|
||||
/* lcd is not a valid object - further specification */
|
||||
/* is needed */
|
||||
el_beep(el);
|
||||
retval = CC_NORM;
|
||||
}
|
||||
|
||||
/* free elements of array and the array itself */
|
||||
for (i = 0; matches[i]; i++)
|
||||
free(matches[i]);
|
||||
free(matches), matches = NULL;
|
||||
|
||||
return (retval);
|
||||
}
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
/*
|
||||
* el-compatible wrapper around rl_complete; needed for key binding
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
unsigned char
|
||||
_el_fn_complete(EditLine *el, int ch __attribute__((__unused__)))
|
||||
{
|
||||
return (unsigned char)fn_complete(el, NULL, NULL,
|
||||
break_chars, NULL, ' ', 100,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
45
libedit/filecomplete.h
Normal file
45
libedit/filecomplete.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* $NetBSD: filecomplete.h,v 1.2 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: filecomplete.h,v 1.2 2005/05/07 16:28:32 dsl Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _FILECOMPLETE_H_
|
||||
#define _FILECOMPLETE_H_
|
||||
|
||||
int fn_complete(EditLine *,
|
||||
char *(*)(const char *, int),
|
||||
char **(*)(const char *, int, int),
|
||||
const char *, const char *, char, int,
|
||||
int *, int *, int *, int *);
|
||||
|
||||
void fn_display_match_list(EditLine *, char **, int, int);
|
||||
char *tilde_expand(char *txt);
|
||||
char *filename_completion_function(const char *, int);
|
||||
|
||||
#endif
|
205
libedit/hist.c
Normal file
205
libedit/hist.c
Normal file
@ -0,0 +1,205 @@
|
||||
/* $NetBSD: hist.c,v 1.5 2005/06/09 16:48:57 lukem Exp $ */
|
||||
/* from NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
/* hist_init():
|
||||
* Initialization function.
|
||||
*/
|
||||
protected int
|
||||
hist_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_history.fun = NULL;
|
||||
el->el_history.ref = NULL;
|
||||
el->el_history.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
el->el_history.sz = EL_BUFSIZ;
|
||||
if (el->el_history.buf == NULL)
|
||||
return (-1);
|
||||
el->el_history.last = el->el_history.buf;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* hist_end():
|
||||
* clean up history;
|
||||
*/
|
||||
protected void
|
||||
hist_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_history.buf);
|
||||
el->el_history.buf = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* hist_set():
|
||||
* Set new history interface
|
||||
*/
|
||||
protected int
|
||||
hist_set(EditLine *el, hist_fun_t fun, ptr_t ptr)
|
||||
{
|
||||
|
||||
el->el_history.ref = ptr;
|
||||
el->el_history.fun = fun;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* hist_get():
|
||||
* Get a history line and update it in the buffer.
|
||||
* eventno tells us the event to get.
|
||||
*/
|
||||
protected el_action_t
|
||||
hist_get(EditLine *el)
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
|
||||
if (el->el_history.eventno == 0) { /* if really the current line */
|
||||
(void) strncpy(el->el_line.buffer, el->el_history.buf,
|
||||
el->el_history.sz);
|
||||
el->el_line.lastchar = el->el_line.buffer +
|
||||
(el->el_history.last - el->el_history.buf);
|
||||
|
||||
#ifdef KSHVI
|
||||
if (el->el_map.type == MAP_VI)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
else
|
||||
#endif /* KSHVI */
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
for (h = 1; h < el->el_history.eventno; h++)
|
||||
if ((hp = HIST_NEXT(el)) == NULL) {
|
||||
el->el_history.eventno = h;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
(void) strlcpy(el->el_line.buffer, hp,
|
||||
(size_t)(el->el_line.limit - el->el_line.buffer));
|
||||
el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer);
|
||||
|
||||
if (el->el_line.lastchar > el->el_line.buffer
|
||||
&& el->el_line.lastchar[-1] == '\n')
|
||||
el->el_line.lastchar--;
|
||||
if (el->el_line.lastchar > el->el_line.buffer
|
||||
&& el->el_line.lastchar[-1] == ' ')
|
||||
el->el_line.lastchar--;
|
||||
#ifdef KSHVI
|
||||
if (el->el_map.type == MAP_VI)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
else
|
||||
#endif /* KSHVI */
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* hist_command()
|
||||
* process a history command
|
||||
*/
|
||||
protected int
|
||||
hist_command(EditLine *el, int argc, const char **argv)
|
||||
{
|
||||
const char *str;
|
||||
int num;
|
||||
HistEvent ev;
|
||||
|
||||
if (el->el_history.ref == NULL)
|
||||
return (-1);
|
||||
|
||||
if (argc == 1 || strcmp(argv[1], "list") == 0) {
|
||||
/* List history entries */
|
||||
|
||||
for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
|
||||
(void) fprintf(el->el_outfile, "%d %s",
|
||||
el->el_history.ev.num, str);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (argc != 3)
|
||||
return (-1);
|
||||
|
||||
num = (int)strtol(argv[2], NULL, 0);
|
||||
|
||||
if (strcmp(argv[1], "size") == 0)
|
||||
return history(el->el_history.ref, &ev, H_SETSIZE, num);
|
||||
|
||||
if (strcmp(argv[1], "unique") == 0)
|
||||
return history(el->el_history.ref, &ev, H_SETUNIQUE, num);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* hist_enlargebuf()
|
||||
* Enlarge history buffer to specified value. Called from el_enlargebufs().
|
||||
* Return 0 for failure, 1 for success.
|
||||
*/
|
||||
protected int
|
||||
/*ARGSUSED*/
|
||||
hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz)
|
||||
{
|
||||
char *newbuf;
|
||||
|
||||
newbuf = realloc(el->el_history.buf, newsz);
|
||||
if (!newbuf)
|
||||
return 0;
|
||||
|
||||
(void) memset(&newbuf[oldsz], '\0', newsz - oldsz);
|
||||
|
||||
el->el_history.last = newbuf +
|
||||
(el->el_history.last - el->el_history.buf);
|
||||
el->el_history.buf = newbuf;
|
||||
el->el_history.sz = newsz;
|
||||
|
||||
return 1;
|
||||
}
|
77
libedit/hist.h
Normal file
77
libedit/hist.h
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: hist.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)hist.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.hist.c: History functions
|
||||
*/
|
||||
#ifndef _h_el_hist
|
||||
#define _h_el_hist
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef int (*hist_fun_t)(ptr_t, HistEvent *, int, ...);
|
||||
|
||||
typedef struct el_history_t {
|
||||
char *buf; /* The history buffer */
|
||||
size_t sz; /* Size of history buffer */
|
||||
char *last; /* The last character */
|
||||
int eventno; /* Event we are looking for */
|
||||
ptr_t ref; /* Argument for history fcns */
|
||||
hist_fun_t fun; /* Event access */
|
||||
HistEvent ev; /* Event cookie */
|
||||
} el_history_t;
|
||||
|
||||
#define HIST_FUN(el, fn, arg) \
|
||||
((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \
|
||||
fn, arg)) == -1) ? NULL : (el)->el_history.ev.str)
|
||||
|
||||
#define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL)
|
||||
#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)
|
||||
#define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL)
|
||||
#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)
|
||||
#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)
|
||||
#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
|
||||
#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
|
||||
|
||||
protected int hist_init(EditLine *);
|
||||
protected void hist_end(EditLine *);
|
||||
protected el_action_t hist_get(EditLine *);
|
||||
protected int hist_set(EditLine *, hist_fun_t, ptr_t);
|
||||
protected int hist_command(EditLine *, int, const char **);
|
||||
protected int hist_enlargebuf(EditLine *, size_t, size_t);
|
||||
|
||||
#endif /* _h_el_hist */
|
216
libedit/histedit.h
Normal file
216
libedit/histedit.h
Normal file
@ -0,0 +1,216 @@
|
||||
/* $NetBSD: histedit.h,v 1.3 2005/05/31 02:07:02 lukem Exp $ */
|
||||
/* from NetBSD: histedit.h,v 1.26 2005/05/07 16:01:25 dsl Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)histedit.h 8.2 (Berkeley) 1/3/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* histedit.h: Line editor and history interface.
|
||||
*/
|
||||
#ifndef _HISTEDIT_H_
|
||||
#define _HISTEDIT_H_
|
||||
|
||||
#define LIBEDIT_MAJOR 2
|
||||
#define LIBEDIT_MINOR 9
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* ==== Editing ====
|
||||
*/
|
||||
|
||||
typedef struct editline EditLine;
|
||||
|
||||
/*
|
||||
* For user-defined function interface
|
||||
*/
|
||||
typedef struct lineinfo {
|
||||
const char *buffer;
|
||||
const char *cursor;
|
||||
const char *lastchar;
|
||||
} LineInfo;
|
||||
|
||||
/*
|
||||
* EditLine editor function return codes.
|
||||
* For user-defined function interface
|
||||
*/
|
||||
#define CC_NORM 0
|
||||
#define CC_NEWLINE 1
|
||||
#define CC_EOF 2
|
||||
#define CC_ARGHACK 3
|
||||
#define CC_REFRESH 4
|
||||
#define CC_CURSOR 5
|
||||
#define CC_ERROR 6
|
||||
#define CC_FATAL 7
|
||||
#define CC_REDISPLAY 8
|
||||
#define CC_REFRESH_BEEP 9
|
||||
|
||||
/*
|
||||
* Initialization, cleanup, and resetting
|
||||
*/
|
||||
EditLine *el_init(const char *, FILE *, FILE *, FILE *);
|
||||
void el_end(EditLine *);
|
||||
void el_reset(EditLine *);
|
||||
|
||||
/*
|
||||
* Get a line, a character or push a string back in the input queue
|
||||
*/
|
||||
const char *el_gets(EditLine *, int *);
|
||||
int el_getc(EditLine *, char *);
|
||||
void el_push(EditLine *, char *);
|
||||
|
||||
/*
|
||||
* Beep!
|
||||
*/
|
||||
void el_beep(EditLine *);
|
||||
|
||||
/*
|
||||
* High level function internals control
|
||||
* Parses argc, argv array and executes builtin editline commands
|
||||
*/
|
||||
int el_parse(EditLine *, int, const char **);
|
||||
|
||||
/*
|
||||
* Low level editline access functions
|
||||
*/
|
||||
int el_set(EditLine *, int, ...);
|
||||
int el_get(EditLine *, int, void *);
|
||||
unsigned char _el_fn_complete(EditLine *, int);
|
||||
|
||||
/*
|
||||
* el_set/el_get parameters
|
||||
*/
|
||||
#define EL_PROMPT 0 /* , el_pfunc_t); */
|
||||
#define EL_TERMINAL 1 /* , const char *); */
|
||||
#define EL_EDITOR 2 /* , const char *); */
|
||||
#define EL_SIGNAL 3 /* , int); */
|
||||
#define EL_BIND 4 /* , const char *, ..., NULL); */
|
||||
#define EL_TELLTC 5 /* , const char *, ..., NULL); */
|
||||
#define EL_SETTC 6 /* , const char *, ..., NULL); */
|
||||
#define EL_ECHOTC 7 /* , const char *, ..., NULL); */
|
||||
#define EL_SETTY 8 /* , const char *, ..., NULL); */
|
||||
#define EL_ADDFN 9 /* , const char *, const char * */
|
||||
/* , el_func_t); */
|
||||
#define EL_HIST 10 /* , hist_fun_t, const char *); */
|
||||
#define EL_EDITMODE 11 /* , int); */
|
||||
#define EL_RPROMPT 12 /* , el_pfunc_t); */
|
||||
#define EL_GETCFN 13 /* , el_rfunc_t); */
|
||||
#define EL_CLIENTDATA 14 /* , void *); */
|
||||
#define EL_UNBUFFERED 15 /* , int); */
|
||||
#define EL_PREP_TERM 16 /* , int); */
|
||||
|
||||
#define EL_BUILTIN_GETCFN (NULL)
|
||||
|
||||
/*
|
||||
* Source named file or $PWD/.editrc or $HOME/.editrc
|
||||
*/
|
||||
int el_source(EditLine *, const char *);
|
||||
|
||||
/*
|
||||
* Must be called when the terminal changes size; If EL_SIGNAL
|
||||
* is set this is done automatically otherwise it is the responsibility
|
||||
* of the application
|
||||
*/
|
||||
void el_resize(EditLine *);
|
||||
|
||||
/*
|
||||
* User-defined function interface.
|
||||
*/
|
||||
const LineInfo *el_line(EditLine *);
|
||||
int el_insertstr(EditLine *, const char *);
|
||||
void el_deletestr(EditLine *, int);
|
||||
|
||||
|
||||
/*
|
||||
* ==== History ====
|
||||
*/
|
||||
|
||||
typedef struct history History;
|
||||
|
||||
typedef struct HistEvent {
|
||||
int num;
|
||||
const char *str;
|
||||
} HistEvent;
|
||||
|
||||
/*
|
||||
* History access functions.
|
||||
*/
|
||||
History * history_init(void);
|
||||
void history_end(History *);
|
||||
|
||||
int history(History *, HistEvent *, int, ...);
|
||||
|
||||
#define H_FUNC 0 /* , UTSL */
|
||||
#define H_SETSIZE 1 /* , const int); */
|
||||
#define H_GETSIZE 2 /* , void); */
|
||||
#define H_FIRST 3 /* , void); */
|
||||
#define H_LAST 4 /* , void); */
|
||||
#define H_PREV 5 /* , void); */
|
||||
#define H_NEXT 6 /* , void); */
|
||||
#define H_CURR 8 /* , const int); */
|
||||
#define H_SET 7 /* , int); */
|
||||
#define H_ADD 9 /* , const char *); */
|
||||
#define H_ENTER 10 /* , const char *); */
|
||||
#define H_APPEND 11 /* , const char *); */
|
||||
#define H_END 12 /* , void); */
|
||||
#define H_NEXT_STR 13 /* , const char *); */
|
||||
#define H_PREV_STR 14 /* , const char *); */
|
||||
#define H_NEXT_EVENT 15 /* , const int); */
|
||||
#define H_PREV_EVENT 16 /* , const int); */
|
||||
#define H_LOAD 17 /* , const char *); */
|
||||
#define H_SAVE 18 /* , const char *); */
|
||||
#define H_CLEAR 19 /* , void); */
|
||||
#define H_SETUNIQUE 20 /* , int); */
|
||||
#define H_GETUNIQUE 21 /* , void); */
|
||||
|
||||
|
||||
/*
|
||||
* ==== Tokenization ====
|
||||
*/
|
||||
|
||||
typedef struct tokenizer Tokenizer;
|
||||
|
||||
/*
|
||||
* String tokenization functions, using simplified sh(1) quoting rules
|
||||
*/
|
||||
Tokenizer *tok_init(const char *);
|
||||
void tok_end(Tokenizer *);
|
||||
void tok_reset(Tokenizer *);
|
||||
int tok_line(Tokenizer *, const LineInfo *,
|
||||
int *, const char ***, int *, int *);
|
||||
int tok_str(Tokenizer *, const char *,
|
||||
int *, const char ***);
|
||||
|
||||
#endif /* _HISTEDIT_H_ */
|
947
libedit/history.c
Normal file
947
libedit/history.c
Normal file
@ -0,0 +1,947 @@
|
||||
/* $NetBSD: history.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: history.c,v 1.28 2004/11/27 18:31:45 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static const char hist_cookie[] = "_HiStOrY_V2_\n";
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef int (*history_gfun_t)(ptr_t, HistEvent *);
|
||||
typedef int (*history_efun_t)(ptr_t, HistEvent *, const char *);
|
||||
typedef void (*history_vfun_t)(ptr_t, HistEvent *);
|
||||
typedef int (*history_sfun_t)(ptr_t, HistEvent *, const int);
|
||||
|
||||
struct history {
|
||||
ptr_t h_ref; /* Argument for history fcns */
|
||||
int h_ent; /* Last entry point for history */
|
||||
history_gfun_t h_first; /* Get the first element */
|
||||
history_gfun_t h_next; /* Get the next element */
|
||||
history_gfun_t h_last; /* Get the last element */
|
||||
history_gfun_t h_prev; /* Get the previous element */
|
||||
history_gfun_t h_curr; /* Get the current element */
|
||||
history_sfun_t h_set; /* Set the current element */
|
||||
history_vfun_t h_clear; /* Clear the history list */
|
||||
history_efun_t h_enter; /* Add an element */
|
||||
history_efun_t h_add; /* Append to an element */
|
||||
};
|
||||
|
||||
#define HNEXT(h, ev) (*(h)->h_next)((h)->h_ref, ev)
|
||||
#define HFIRST(h, ev) (*(h)->h_first)((h)->h_ref, ev)
|
||||
#define HPREV(h, ev) (*(h)->h_prev)((h)->h_ref, ev)
|
||||
#define HLAST(h, ev) (*(h)->h_last)((h)->h_ref, ev)
|
||||
#define HCURR(h, ev) (*(h)->h_curr)((h)->h_ref, ev)
|
||||
#define HSET(h, ev, n) (*(h)->h_set)((h)->h_ref, ev, n)
|
||||
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
|
||||
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
|
||||
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
|
||||
|
||||
#define h_strdup(a) strdup(a)
|
||||
#define h_malloc(a) malloc(a)
|
||||
#define h_realloc(a, b) realloc((a), (b))
|
||||
#define h_free(a) free(a)
|
||||
|
||||
typedef struct {
|
||||
int num;
|
||||
char *str;
|
||||
} HistEventPrivate;
|
||||
|
||||
|
||||
|
||||
private int history_setsize(History *, HistEvent *, int);
|
||||
private int history_getsize(History *, HistEvent *);
|
||||
private int history_setunique(History *, HistEvent *, int);
|
||||
private int history_getunique(History *, HistEvent *);
|
||||
private int history_set_fun(History *, History *);
|
||||
private int history_load(History *, const char *);
|
||||
private int history_save(History *, const char *);
|
||||
private int history_prev_event(History *, HistEvent *, int);
|
||||
private int history_next_event(History *, HistEvent *, int);
|
||||
private int history_next_string(History *, HistEvent *, const char *);
|
||||
private int history_prev_string(History *, HistEvent *, const char *);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/*
|
||||
* Builtin- history implementation
|
||||
*/
|
||||
typedef struct hentry_t {
|
||||
HistEvent ev; /* What we return */
|
||||
struct hentry_t *next; /* Next entry */
|
||||
struct hentry_t *prev; /* Previous entry */
|
||||
} hentry_t;
|
||||
|
||||
typedef struct history_t {
|
||||
hentry_t list; /* Fake list header element */
|
||||
hentry_t *cursor; /* Current element in the list */
|
||||
int max; /* Maximum number of events */
|
||||
int cur; /* Current number of events */
|
||||
int eventid; /* For generation of unique event id */
|
||||
int flags; /* History flags */
|
||||
#define H_UNIQUE 1 /* Store only unique elements */
|
||||
} history_t;
|
||||
|
||||
private int history_def_first(ptr_t, HistEvent *);
|
||||
private int history_def_last(ptr_t, HistEvent *);
|
||||
private int history_def_next(ptr_t, HistEvent *);
|
||||
private int history_def_prev(ptr_t, HistEvent *);
|
||||
private int history_def_curr(ptr_t, HistEvent *);
|
||||
private int history_def_set(ptr_t, HistEvent *, const int n);
|
||||
private int history_def_enter(ptr_t, HistEvent *, const char *);
|
||||
private int history_def_add(ptr_t, HistEvent *, const char *);
|
||||
private int history_def_init(ptr_t *, HistEvent *, int);
|
||||
private void history_def_clear(ptr_t, HistEvent *);
|
||||
private int history_def_insert(history_t *, HistEvent *, const char *);
|
||||
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
|
||||
|
||||
#define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
|
||||
#define history_def_getsize(p) (((history_t *)p)->cur)
|
||||
#define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0)
|
||||
#define history_def_setunique(p, uni) \
|
||||
if (uni) \
|
||||
(((history_t *)p)->flags) |= H_UNIQUE; \
|
||||
else \
|
||||
(((history_t *)p)->flags) &= ~H_UNIQUE
|
||||
|
||||
#define he_strerror(code) he_errlist[code]
|
||||
#define he_seterrev(evp, code) {\
|
||||
evp->num = code;\
|
||||
evp->str = he_strerror(code);\
|
||||
}
|
||||
|
||||
/* error messages */
|
||||
static const char *const he_errlist[] = {
|
||||
"OK",
|
||||
"unknown error",
|
||||
"malloc() failed",
|
||||
"first event not found",
|
||||
"last event not found",
|
||||
"empty list",
|
||||
"no next event",
|
||||
"no previous event",
|
||||
"current event is invalid",
|
||||
"event not found",
|
||||
"can't read history from file",
|
||||
"can't write history",
|
||||
"required parameter(s) not supplied",
|
||||
"history size negative",
|
||||
"function not allowed with other history-functions-set the default",
|
||||
"bad parameters"
|
||||
};
|
||||
/* error codes */
|
||||
#define _HE_OK 0
|
||||
#define _HE_UNKNOWN 1
|
||||
#define _HE_MALLOC_FAILED 2
|
||||
#define _HE_FIRST_NOTFOUND 3
|
||||
#define _HE_LAST_NOTFOUND 4
|
||||
#define _HE_EMPTY_LIST 5
|
||||
#define _HE_END_REACHED 6
|
||||
#define _HE_START_REACHED 7
|
||||
#define _HE_CURR_INVALID 8
|
||||
#define _HE_NOT_FOUND 9
|
||||
#define _HE_HIST_READ 10
|
||||
#define _HE_HIST_WRITE 11
|
||||
#define _HE_PARAM_MISSING 12
|
||||
#define _HE_SIZE_NEGATIVE 13
|
||||
#define _HE_NOT_ALLOWED 14
|
||||
#define _HE_BAD_PARAM 15
|
||||
|
||||
/* history_def_first():
|
||||
* Default function to return the first event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_first(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
h->cursor = h->list.next;
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev, _HE_FIRST_NOTFOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_last():
|
||||
* Default function to return the last event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_last(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
h->cursor = h->list.prev;
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev, _HE_LAST_NOTFOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_next():
|
||||
* Default function to return the next event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_next(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev, _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (h->cursor->next == &h->list) {
|
||||
he_seterrev(ev, _HE_END_REACHED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
h->cursor = h->cursor->next;
|
||||
*ev = h->cursor->ev;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_prev():
|
||||
* Default function to return the previous event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_prev(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev,
|
||||
(h->cur > 0) ? _HE_END_REACHED : _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (h->cursor->prev == &h->list) {
|
||||
he_seterrev(ev, _HE_START_REACHED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
h->cursor = h->cursor->prev;
|
||||
*ev = h->cursor->ev;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_curr():
|
||||
* Default function to return the current event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_curr(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev,
|
||||
(h->cur > 0) ? _HE_CURR_INVALID : _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_set():
|
||||
* Default function to set the current event in the history to the
|
||||
* given one.
|
||||
*/
|
||||
private int
|
||||
history_def_set(ptr_t p, HistEvent *ev, const int n)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cur == 0) {
|
||||
he_seterrev(ev, _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
if (h->cursor == &h->list || h->cursor->ev.num != n) {
|
||||
for (h->cursor = h->list.next; h->cursor != &h->list;
|
||||
h->cursor = h->cursor->next)
|
||||
if (h->cursor->ev.num == n)
|
||||
break;
|
||||
}
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_add():
|
||||
* Append string to element
|
||||
*/
|
||||
private int
|
||||
history_def_add(ptr_t p, HistEvent *ev, const char *str)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
size_t len;
|
||||
char *s;
|
||||
HistEventPrivate *evp = (void *)&h->cursor->ev;
|
||||
|
||||
if (h->cursor == &h->list)
|
||||
return (history_def_enter(p, ev, str));
|
||||
len = strlen(evp->str) + strlen(str) + 1;
|
||||
s = (char *) h_malloc(len);
|
||||
if (s == NULL) {
|
||||
he_seterrev(ev, _HE_MALLOC_FAILED);
|
||||
return (-1);
|
||||
}
|
||||
(void) strlcpy(s, h->cursor->ev.str, len);
|
||||
(void) strlcat(s, str, len);
|
||||
h_free((ptr_t)evp->str);
|
||||
evp->str = s;
|
||||
*ev = h->cursor->ev;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_delete():
|
||||
* Delete element hp of the h list
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private void
|
||||
history_def_delete(history_t *h,
|
||||
HistEvent *ev __attribute__((__unused__)), hentry_t *hp)
|
||||
{
|
||||
HistEventPrivate *evp = (void *)&hp->ev;
|
||||
if (hp == &h->list)
|
||||
abort();
|
||||
hp->prev->next = hp->next;
|
||||
hp->next->prev = hp->prev;
|
||||
h_free((ptr_t) evp->str);
|
||||
h_free(hp);
|
||||
h->cur--;
|
||||
}
|
||||
|
||||
|
||||
/* history_def_insert():
|
||||
* Insert element with string str in the h list
|
||||
*/
|
||||
private int
|
||||
history_def_insert(history_t *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
|
||||
h->cursor = (hentry_t *) h_malloc(sizeof(hentry_t));
|
||||
if (h->cursor == NULL)
|
||||
goto oomem;
|
||||
if ((h->cursor->ev.str = h_strdup(str)) == NULL) {
|
||||
h_free((ptr_t)h->cursor);
|
||||
goto oomem;
|
||||
}
|
||||
h->cursor->ev.num = ++h->eventid;
|
||||
h->cursor->next = h->list.next;
|
||||
h->cursor->prev = &h->list;
|
||||
h->list.next->prev = h->cursor;
|
||||
h->list.next = h->cursor;
|
||||
h->cur++;
|
||||
|
||||
*ev = h->cursor->ev;
|
||||
return (0);
|
||||
oomem:
|
||||
he_seterrev(ev, _HE_MALLOC_FAILED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_enter():
|
||||
* Default function to enter an item in the history
|
||||
*/
|
||||
private int
|
||||
history_def_enter(ptr_t p, HistEvent *ev, const char *str)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list &&
|
||||
strcmp(h->list.next->ev.str, str) == 0)
|
||||
return (0);
|
||||
|
||||
if (history_def_insert(h, ev, str) == -1)
|
||||
return (-1); /* error, keep error message */
|
||||
|
||||
/*
|
||||
* Always keep at least one entry.
|
||||
* This way we don't have to check for the empty list.
|
||||
*/
|
||||
while (h->cur > h->max && h->cur > 0)
|
||||
history_def_delete(h, ev, h->list.prev);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_init():
|
||||
* Default history initialization function
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private int
|
||||
history_def_init(ptr_t *p, HistEvent *ev __attribute__((__unused__)), int n)
|
||||
{
|
||||
history_t *h = (history_t *) h_malloc(sizeof(history_t));
|
||||
if (h == NULL)
|
||||
return -1;
|
||||
|
||||
if (n <= 0)
|
||||
n = 0;
|
||||
h->eventid = 0;
|
||||
h->cur = 0;
|
||||
h->max = n;
|
||||
h->list.next = h->list.prev = &h->list;
|
||||
h->list.ev.str = NULL;
|
||||
h->list.ev.num = 0;
|
||||
h->cursor = &h->list;
|
||||
h->flags = 0;
|
||||
*p = (ptr_t) h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* history_def_clear():
|
||||
* Default history cleanup function
|
||||
*/
|
||||
private void
|
||||
history_def_clear(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
while (h->list.prev != &h->list)
|
||||
history_def_delete(h, ev, h->list.prev);
|
||||
h->eventid = 0;
|
||||
h->cur = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* history_init():
|
||||
* Initialization function.
|
||||
*/
|
||||
public History *
|
||||
history_init(void)
|
||||
{
|
||||
HistEvent ev;
|
||||
History *h = (History *) h_malloc(sizeof(History));
|
||||
if (h == NULL)
|
||||
return NULL;
|
||||
|
||||
if (history_def_init(&h->h_ref, &ev, 0) == -1) {
|
||||
h_free((ptr_t)h);
|
||||
return NULL;
|
||||
}
|
||||
h->h_ent = -1;
|
||||
h->h_next = history_def_next;
|
||||
h->h_first = history_def_first;
|
||||
h->h_last = history_def_last;
|
||||
h->h_prev = history_def_prev;
|
||||
h->h_curr = history_def_curr;
|
||||
h->h_set = history_def_set;
|
||||
h->h_clear = history_def_clear;
|
||||
h->h_enter = history_def_enter;
|
||||
h->h_add = history_def_add;
|
||||
|
||||
return (h);
|
||||
}
|
||||
|
||||
|
||||
/* history_end():
|
||||
* clean up history;
|
||||
*/
|
||||
public void
|
||||
history_end(History *h)
|
||||
{
|
||||
HistEvent ev;
|
||||
|
||||
if (h->h_next == history_def_next)
|
||||
history_def_clear(h->h_ref, &ev);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* history_setsize():
|
||||
* Set history number of events
|
||||
*/
|
||||
private int
|
||||
history_setsize(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
if (num < 0) {
|
||||
he_seterrev(ev, _HE_BAD_PARAM);
|
||||
return (-1);
|
||||
}
|
||||
history_def_setsize(h->h_ref, num);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_getsize():
|
||||
* Get number of events currently in history
|
||||
*/
|
||||
private int
|
||||
history_getsize(History *h, HistEvent *ev)
|
||||
{
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
ev->num = history_def_getsize(h->h_ref);
|
||||
if (ev->num < -1) {
|
||||
he_seterrev(ev, _HE_SIZE_NEGATIVE);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_setunique():
|
||||
* Set if adjacent equal events should not be entered in history.
|
||||
*/
|
||||
private int
|
||||
history_setunique(History *h, HistEvent *ev, int uni)
|
||||
{
|
||||
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
history_def_setunique(h->h_ref, uni);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_getunique():
|
||||
* Get if adjacent equal events should not be entered in history.
|
||||
*/
|
||||
private int
|
||||
history_getunique(History *h, HistEvent *ev)
|
||||
{
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
ev->num = history_def_getunique(h->h_ref);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_set_fun():
|
||||
* Set history functions
|
||||
*/
|
||||
private int
|
||||
history_set_fun(History *h, History *nh)
|
||||
{
|
||||
HistEvent ev;
|
||||
|
||||
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
|
||||
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
|
||||
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
|
||||
nh->h_ref == NULL) {
|
||||
if (h->h_next != history_def_next) {
|
||||
history_def_init(&h->h_ref, &ev, 0);
|
||||
h->h_first = history_def_first;
|
||||
h->h_next = history_def_next;
|
||||
h->h_last = history_def_last;
|
||||
h->h_prev = history_def_prev;
|
||||
h->h_curr = history_def_curr;
|
||||
h->h_set = history_def_set;
|
||||
h->h_clear = history_def_clear;
|
||||
h->h_enter = history_def_enter;
|
||||
h->h_add = history_def_add;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
if (h->h_next == history_def_next)
|
||||
history_def_clear(h->h_ref, &ev);
|
||||
|
||||
h->h_ent = -1;
|
||||
h->h_first = nh->h_first;
|
||||
h->h_next = nh->h_next;
|
||||
h->h_last = nh->h_last;
|
||||
h->h_prev = nh->h_prev;
|
||||
h->h_curr = nh->h_curr;
|
||||
h->h_set = nh->h_set;
|
||||
h->h_clear = nh->h_clear;
|
||||
h->h_enter = nh->h_enter;
|
||||
h->h_add = nh->h_add;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_load():
|
||||
* History load function
|
||||
*/
|
||||
private int
|
||||
history_load(History *h, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
size_t sz, max_size;
|
||||
char *ptr;
|
||||
int i = -1;
|
||||
HistEvent ev;
|
||||
|
||||
if ((fp = fopen(fname, "r")) == NULL)
|
||||
return (i);
|
||||
|
||||
if ((line = fgetln(fp, &sz)) == NULL)
|
||||
goto done;
|
||||
|
||||
if (strncmp(line, hist_cookie, sz) != 0)
|
||||
goto done;
|
||||
|
||||
ptr = h_malloc(max_size = 1024);
|
||||
if (ptr == NULL)
|
||||
goto done;
|
||||
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
|
||||
char c = line[sz];
|
||||
|
||||
if (sz != 0 && line[sz - 1] == '\n')
|
||||
line[--sz] = '\0';
|
||||
else
|
||||
line[sz] = '\0';
|
||||
|
||||
if (max_size < sz) {
|
||||
char *nptr;
|
||||
max_size = (sz + 1024) & ~1023;
|
||||
nptr = h_realloc(ptr, max_size);
|
||||
if (nptr == NULL) {
|
||||
i = -1;
|
||||
goto oomem;
|
||||
}
|
||||
ptr = nptr;
|
||||
}
|
||||
(void) strunvis(ptr, line);
|
||||
line[sz] = c;
|
||||
if (HENTER(h, &ev, ptr) == -1) {
|
||||
h_free((ptr_t)ptr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
oomem:
|
||||
h_free((ptr_t)ptr);
|
||||
done:
|
||||
(void) fclose(fp);
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
/* history_save():
|
||||
* History save function
|
||||
*/
|
||||
private int
|
||||
history_save(History *h, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
HistEvent ev;
|
||||
int i = -1, retval;
|
||||
size_t len, max_size;
|
||||
char *ptr;
|
||||
|
||||
if ((fp = fopen(fname, "w")) == NULL)
|
||||
return (-1);
|
||||
|
||||
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
|
||||
goto done;
|
||||
if (fputs(hist_cookie, fp) == EOF)
|
||||
goto done;
|
||||
ptr = h_malloc(max_size = 1024);
|
||||
if (ptr == NULL)
|
||||
goto done;
|
||||
for (i = 0, retval = HLAST(h, &ev);
|
||||
retval != -1;
|
||||
retval = HPREV(h, &ev), i++) {
|
||||
len = strlen(ev.str) * 4;
|
||||
if (len >= max_size) {
|
||||
char *nptr;
|
||||
max_size = (len + 1024) & ~1023;
|
||||
nptr = h_realloc(ptr, max_size);
|
||||
if (nptr == NULL) {
|
||||
i = -1;
|
||||
goto oomem;
|
||||
}
|
||||
ptr = nptr;
|
||||
}
|
||||
(void) strvis(ptr, ev.str, VIS_WHITE);
|
||||
(void) fprintf(fp, "%s\n", ptr);
|
||||
}
|
||||
oomem:
|
||||
h_free((ptr_t)ptr);
|
||||
done:
|
||||
(void) fclose(fp);
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
/* history_prev_event():
|
||||
* Find the previous event, with number given
|
||||
*/
|
||||
private int
|
||||
history_prev_event(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
|
||||
if (ev->num == num)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_next_event():
|
||||
* Find the next event, with number given
|
||||
*/
|
||||
private int
|
||||
history_next_event(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
|
||||
if (ev->num == num)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_prev_string():
|
||||
* Find the previous event beginning with string
|
||||
*/
|
||||
private int
|
||||
history_prev_string(History *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
|
||||
if (strncmp(str, ev->str, len) == 0)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_next_string():
|
||||
* Find the next event beginning with string
|
||||
*/
|
||||
private int
|
||||
history_next_string(History *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
|
||||
if (strncmp(str, ev->str, len) == 0)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history():
|
||||
* User interface to history functions.
|
||||
*/
|
||||
int
|
||||
history(History *h, HistEvent *ev, int fun, ...)
|
||||
{
|
||||
va_list va;
|
||||
const char *str;
|
||||
int retval;
|
||||
|
||||
va_start(va, fun);
|
||||
|
||||
he_seterrev(ev, _HE_OK);
|
||||
|
||||
switch (fun) {
|
||||
case H_GETSIZE:
|
||||
retval = history_getsize(h, ev);
|
||||
break;
|
||||
|
||||
case H_SETSIZE:
|
||||
retval = history_setsize(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_GETUNIQUE:
|
||||
retval = history_getunique(h, ev);
|
||||
break;
|
||||
|
||||
case H_SETUNIQUE:
|
||||
retval = history_setunique(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_ADD:
|
||||
str = va_arg(va, const char *);
|
||||
retval = HADD(h, ev, str);
|
||||
break;
|
||||
|
||||
case H_ENTER:
|
||||
str = va_arg(va, const char *);
|
||||
if ((retval = HENTER(h, ev, str)) != -1)
|
||||
h->h_ent = ev->num;
|
||||
break;
|
||||
|
||||
case H_APPEND:
|
||||
str = va_arg(va, const char *);
|
||||
if ((retval = HSET(h, ev, h->h_ent)) != -1)
|
||||
retval = HADD(h, ev, str);
|
||||
break;
|
||||
|
||||
case H_FIRST:
|
||||
retval = HFIRST(h, ev);
|
||||
break;
|
||||
|
||||
case H_NEXT:
|
||||
retval = HNEXT(h, ev);
|
||||
break;
|
||||
|
||||
case H_LAST:
|
||||
retval = HLAST(h, ev);
|
||||
break;
|
||||
|
||||
case H_PREV:
|
||||
retval = HPREV(h, ev);
|
||||
break;
|
||||
|
||||
case H_CURR:
|
||||
retval = HCURR(h, ev);
|
||||
break;
|
||||
|
||||
case H_SET:
|
||||
retval = HSET(h, ev, va_arg(va, const int));
|
||||
break;
|
||||
|
||||
case H_CLEAR:
|
||||
HCLEAR(h, ev);
|
||||
retval = 0;
|
||||
break;
|
||||
|
||||
case H_LOAD:
|
||||
retval = history_load(h, va_arg(va, const char *));
|
||||
if (retval == -1)
|
||||
he_seterrev(ev, _HE_HIST_READ);
|
||||
break;
|
||||
|
||||
case H_SAVE:
|
||||
retval = history_save(h, va_arg(va, const char *));
|
||||
if (retval == -1)
|
||||
he_seterrev(ev, _HE_HIST_WRITE);
|
||||
break;
|
||||
|
||||
case H_PREV_EVENT:
|
||||
retval = history_prev_event(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_NEXT_EVENT:
|
||||
retval = history_next_event(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_PREV_STR:
|
||||
retval = history_prev_string(h, ev, va_arg(va, const char *));
|
||||
break;
|
||||
|
||||
case H_NEXT_STR:
|
||||
retval = history_next_string(h, ev, va_arg(va, const char *));
|
||||
break;
|
||||
|
||||
case H_FUNC:
|
||||
{
|
||||
History hf;
|
||||
|
||||
hf.h_ref = va_arg(va, ptr_t);
|
||||
h->h_ent = -1;
|
||||
hf.h_first = va_arg(va, history_gfun_t);
|
||||
hf.h_next = va_arg(va, history_gfun_t);
|
||||
hf.h_last = va_arg(va, history_gfun_t);
|
||||
hf.h_prev = va_arg(va, history_gfun_t);
|
||||
hf.h_curr = va_arg(va, history_gfun_t);
|
||||
hf.h_set = va_arg(va, history_sfun_t);
|
||||
hf.h_clear = va_arg(va, history_vfun_t);
|
||||
hf.h_enter = va_arg(va, history_efun_t);
|
||||
hf.h_add = va_arg(va, history_efun_t);
|
||||
|
||||
if ((retval = history_set_fun(h, &hf)) == -1)
|
||||
he_seterrev(ev, _HE_PARAM_MISSING);
|
||||
break;
|
||||
}
|
||||
|
||||
case H_END:
|
||||
history_end(h);
|
||||
retval = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = -1;
|
||||
he_seterrev(ev, _HE_UNKNOWN);
|
||||
break;
|
||||
}
|
||||
va_end(va);
|
||||
return (retval);
|
||||
}
|
679
libedit/key.c
Normal file
679
libedit/key.c
Normal file
@ -0,0 +1,679 @@
|
||||
/* $NetBSD: key.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: key.c,v 1.15 2003/10/18 23:48:42 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* key.c: This module contains the procedures for maintaining
|
||||
* the extended-key map.
|
||||
*
|
||||
* An extended-key (key) is a sequence of keystrokes introduced
|
||||
* with an sequence introducer and consisting of an arbitrary
|
||||
* number of characters. This module maintains a map (the el->el_key.map)
|
||||
* to convert these extended-key sequences into input strs
|
||||
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
|
||||
*
|
||||
* Warning:
|
||||
* If key is a substr of some other keys, then the longer
|
||||
* keys are lost!! That is, if the keys "abcd" and "abcef"
|
||||
* are in el->el_key.map, adding the key "abc" will cause the first two
|
||||
* definitions to be lost.
|
||||
*
|
||||
* Restrictions:
|
||||
* -------------
|
||||
* 1) It is not possible to have one key that is a
|
||||
* substr of another.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
/*
|
||||
* The Nodes of the el->el_key.map. The el->el_key.map is a linked list
|
||||
* of these node elements
|
||||
*/
|
||||
struct key_node_t {
|
||||
char ch; /* single character of key */
|
||||
int type; /* node type */
|
||||
key_value_t val; /* command code or pointer to str, */
|
||||
/* if this is a leaf */
|
||||
struct key_node_t *next; /* ptr to next char of this key */
|
||||
struct key_node_t *sibling; /* ptr to another key with same prefix*/
|
||||
};
|
||||
|
||||
private int node_trav(EditLine *, key_node_t *, char *,
|
||||
key_value_t *);
|
||||
private int node__try(EditLine *, key_node_t *, const char *,
|
||||
key_value_t *, int);
|
||||
private key_node_t *node__get(int);
|
||||
private void node__put(EditLine *, key_node_t *);
|
||||
private int node__delete(EditLine *, key_node_t **, const char *);
|
||||
private int node_lookup(EditLine *, const char *, key_node_t *,
|
||||
int);
|
||||
private int node_enum(EditLine *, key_node_t *, int);
|
||||
private int key__decode_char(char *, int, int);
|
||||
|
||||
#define KEY_BUFSIZ EL_BUFSIZ
|
||||
|
||||
|
||||
/* key_init():
|
||||
* Initialize the key maps
|
||||
*/
|
||||
protected int
|
||||
key_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_key.buf = (char *) el_malloc(KEY_BUFSIZ);
|
||||
if (el->el_key.buf == NULL)
|
||||
return (-1);
|
||||
el->el_key.map = NULL;
|
||||
key_reset(el);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* key_end():
|
||||
* Free the key maps
|
||||
*/
|
||||
protected void
|
||||
key_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_key.buf);
|
||||
el->el_key.buf = NULL;
|
||||
/* XXX: provide a function to clear the keys */
|
||||
el->el_key.map = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* key_map_cmd():
|
||||
* Associate cmd with a key value
|
||||
*/
|
||||
protected key_value_t *
|
||||
key_map_cmd(EditLine *el, int cmd)
|
||||
{
|
||||
|
||||
el->el_key.val.cmd = (el_action_t) cmd;
|
||||
return (&el->el_key.val);
|
||||
}
|
||||
|
||||
|
||||
/* key_map_str():
|
||||
* Associate str with a key value
|
||||
*/
|
||||
protected key_value_t *
|
||||
key_map_str(EditLine *el, char *str)
|
||||
{
|
||||
|
||||
el->el_key.val.str = str;
|
||||
return (&el->el_key.val);
|
||||
}
|
||||
|
||||
|
||||
/* key_reset():
|
||||
* Takes all nodes on el->el_key.map and puts them on free list. Then
|
||||
* initializes el->el_key.map with arrow keys
|
||||
* [Always bind the ansi arrow keys?]
|
||||
*/
|
||||
protected void
|
||||
key_reset(EditLine *el)
|
||||
{
|
||||
|
||||
node__put(el, el->el_key.map);
|
||||
el->el_key.map = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* key_get():
|
||||
* Calls the recursive function with entry point el->el_key.map
|
||||
* Looks up *ch in map and then reads characters until a
|
||||
* complete match is found or a mismatch occurs. Returns the
|
||||
* type of the match found (XK_STR, XK_CMD, or XK_EXE).
|
||||
* Returns NULL in val.str and XK_STR for no match.
|
||||
* The last character read is returned in *ch.
|
||||
*/
|
||||
protected int
|
||||
key_get(EditLine *el, char *ch, key_value_t *val)
|
||||
{
|
||||
|
||||
return (node_trav(el, el->el_key.map, ch, val));
|
||||
}
|
||||
|
||||
|
||||
/* key_add():
|
||||
* Adds key to the el->el_key.map and associates the value in val with it.
|
||||
* If key is already is in el->el_key.map, the new code is applied to the
|
||||
* existing key. Ntype specifies if code is a command, an
|
||||
* out str or a unix command.
|
||||
*/
|
||||
protected void
|
||||
key_add(EditLine *el, const char *key, key_value_t *val, int ntype)
|
||||
{
|
||||
|
||||
if (key[0] == '\0') {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_add: Null extended-key not allowed.\n");
|
||||
return;
|
||||
}
|
||||
if (ntype == XK_CMD && val->cmd == ED_SEQUENCE_LEAD_IN) {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_add: sequence-lead-in command not allowed\n");
|
||||
return;
|
||||
}
|
||||
if (el->el_key.map == NULL)
|
||||
/* tree is initially empty. Set up new node to match key[0] */
|
||||
el->el_key.map = node__get(key[0]);
|
||||
/* it is properly initialized */
|
||||
|
||||
/* Now recurse through el->el_key.map */
|
||||
(void) node__try(el, el->el_key.map, key, val, ntype);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* key_clear():
|
||||
*
|
||||
*/
|
||||
protected void
|
||||
key_clear(EditLine *el, el_action_t *map, const char *in)
|
||||
{
|
||||
|
||||
if ((map[(unsigned char)*in] == ED_SEQUENCE_LEAD_IN) &&
|
||||
((map == el->el_map.key &&
|
||||
el->el_map.alt[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN) ||
|
||||
(map == el->el_map.alt &&
|
||||
el->el_map.key[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN)))
|
||||
(void) key_delete(el, in);
|
||||
}
|
||||
|
||||
|
||||
/* key_delete():
|
||||
* Delete the key and all longer keys staring with key, if
|
||||
* they exists.
|
||||
*/
|
||||
protected int
|
||||
key_delete(EditLine *el, const char *key)
|
||||
{
|
||||
|
||||
if (key[0] == '\0') {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_delete: Null extended-key not allowed.\n");
|
||||
return (-1);
|
||||
}
|
||||
if (el->el_key.map == NULL)
|
||||
return (0);
|
||||
|
||||
(void) node__delete(el, &el->el_key.map, key);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* key_print():
|
||||
* Print the binding associated with key key.
|
||||
* Print entire el->el_key.map if null
|
||||
*/
|
||||
protected void
|
||||
key_print(EditLine *el, const char *key)
|
||||
{
|
||||
|
||||
/* do nothing if el->el_key.map is empty and null key specified */
|
||||
if (el->el_key.map == NULL && *key == 0)
|
||||
return;
|
||||
|
||||
el->el_key.buf[0] = '"';
|
||||
if (node_lookup(el, key, el->el_key.map, 1) <= -1)
|
||||
/* key is not bound */
|
||||
(void) fprintf(el->el_errfile, "Unbound extended key \"%s\"\n",
|
||||
key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* node_trav():
|
||||
* recursively traverses node in tree until match or mismatch is
|
||||
* found. May read in more characters.
|
||||
*/
|
||||
private int
|
||||
node_trav(EditLine *el, key_node_t *ptr, char *ch, key_value_t *val)
|
||||
{
|
||||
|
||||
if (ptr->ch == *ch) {
|
||||
/* match found */
|
||||
if (ptr->next) {
|
||||
/* key not complete so get next char */
|
||||
if (el_getc(el, ch) != 1) { /* if EOF or error */
|
||||
val->cmd = ED_END_OF_FILE;
|
||||
return (XK_CMD);
|
||||
/* PWP: Pretend we just read an end-of-file */
|
||||
}
|
||||
return (node_trav(el, ptr->next, ch, val));
|
||||
} else {
|
||||
*val = ptr->val;
|
||||
if (ptr->type != XK_CMD)
|
||||
*ch = '\0';
|
||||
return (ptr->type);
|
||||
}
|
||||
} else {
|
||||
/* no match found here */
|
||||
if (ptr->sibling) {
|
||||
/* try next sibling */
|
||||
return (node_trav(el, ptr->sibling, ch, val));
|
||||
} else {
|
||||
/* no next sibling -- mismatch */
|
||||
val->str = NULL;
|
||||
return (XK_STR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node__try():
|
||||
* Find a node that matches *str or allocate a new one
|
||||
*/
|
||||
private int
|
||||
node__try(EditLine *el, key_node_t *ptr, const char *str, key_value_t *val, int ntype)
|
||||
{
|
||||
|
||||
if (ptr->ch != *str) {
|
||||
key_node_t *xm;
|
||||
|
||||
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
|
||||
if (xm->sibling->ch == *str)
|
||||
break;
|
||||
if (xm->sibling == NULL)
|
||||
xm->sibling = node__get(*str); /* setup new node */
|
||||
ptr = xm->sibling;
|
||||
}
|
||||
if (*++str == '\0') {
|
||||
/* we're there */
|
||||
if (ptr->next != NULL) {
|
||||
node__put(el, ptr->next);
|
||||
/* lose longer keys with this prefix */
|
||||
ptr->next = NULL;
|
||||
}
|
||||
switch (ptr->type) {
|
||||
case XK_CMD:
|
||||
case XK_NOD:
|
||||
break;
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
if (ptr->val.str)
|
||||
el_free((ptr_t) ptr->val.str);
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n",
|
||||
ptr->type));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ptr->type = ntype) {
|
||||
case XK_CMD:
|
||||
ptr->val = *val;
|
||||
break;
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
if ((ptr->val.str = el_strdup(val->str)) == NULL)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* still more chars to go */
|
||||
if (ptr->next == NULL)
|
||||
ptr->next = node__get(*str); /* setup new node */
|
||||
(void) node__try(el, ptr->next, str, val, ntype);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* node__delete():
|
||||
* Delete node that matches str
|
||||
*/
|
||||
private int
|
||||
node__delete(EditLine *el, key_node_t **inptr, const char *str)
|
||||
{
|
||||
key_node_t *ptr;
|
||||
key_node_t *prev_ptr = NULL;
|
||||
|
||||
ptr = *inptr;
|
||||
|
||||
if (ptr->ch != *str) {
|
||||
key_node_t *xm;
|
||||
|
||||
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
|
||||
if (xm->sibling->ch == *str)
|
||||
break;
|
||||
if (xm->sibling == NULL)
|
||||
return (0);
|
||||
prev_ptr = xm;
|
||||
ptr = xm->sibling;
|
||||
}
|
||||
if (*++str == '\0') {
|
||||
/* we're there */
|
||||
if (prev_ptr == NULL)
|
||||
*inptr = ptr->sibling;
|
||||
else
|
||||
prev_ptr->sibling = ptr->sibling;
|
||||
ptr->sibling = NULL;
|
||||
node__put(el, ptr);
|
||||
return (1);
|
||||
} else if (ptr->next != NULL &&
|
||||
node__delete(el, &ptr->next, str) == 1) {
|
||||
if (ptr->next != NULL)
|
||||
return (0);
|
||||
if (prev_ptr == NULL)
|
||||
*inptr = ptr->sibling;
|
||||
else
|
||||
prev_ptr->sibling = ptr->sibling;
|
||||
ptr->sibling = NULL;
|
||||
node__put(el, ptr);
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node__put():
|
||||
* Puts a tree of nodes onto free list using free(3).
|
||||
*/
|
||||
private void
|
||||
node__put(EditLine *el, key_node_t *ptr)
|
||||
{
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
if (ptr->next != NULL) {
|
||||
node__put(el, ptr->next);
|
||||
ptr->next = NULL;
|
||||
}
|
||||
node__put(el, ptr->sibling);
|
||||
|
||||
switch (ptr->type) {
|
||||
case XK_CMD:
|
||||
case XK_NOD:
|
||||
break;
|
||||
case XK_EXE:
|
||||
case XK_STR:
|
||||
if (ptr->val.str != NULL)
|
||||
el_free((ptr_t) ptr->val.str);
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ptr->type));
|
||||
break;
|
||||
}
|
||||
el_free((ptr_t) ptr);
|
||||
}
|
||||
|
||||
|
||||
/* node__get():
|
||||
* Returns pointer to an key_node_t for ch.
|
||||
*/
|
||||
private key_node_t *
|
||||
node__get(int ch)
|
||||
{
|
||||
key_node_t *ptr;
|
||||
|
||||
ptr = (key_node_t *) el_malloc((size_t) sizeof(key_node_t));
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
ptr->ch = ch;
|
||||
ptr->type = XK_NOD;
|
||||
ptr->val.str = NULL;
|
||||
ptr->next = NULL;
|
||||
ptr->sibling = NULL;
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* node_lookup():
|
||||
* look for the str starting at node ptr.
|
||||
* Print if last node
|
||||
*/
|
||||
private int
|
||||
node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
|
||||
{
|
||||
int ncnt;
|
||||
|
||||
if (ptr == NULL)
|
||||
return (-1); /* cannot have null ptr */
|
||||
|
||||
if (*str == 0) {
|
||||
/* no more chars in str. node_enum from here. */
|
||||
(void) node_enum(el, ptr, cnt);
|
||||
return (0);
|
||||
} else {
|
||||
/* If match put this char into el->el_key.buf. Recurse */
|
||||
if (ptr->ch == *str) {
|
||||
/* match found */
|
||||
ncnt = key__decode_char(el->el_key.buf, cnt,
|
||||
(unsigned char) ptr->ch);
|
||||
if (ptr->next != NULL)
|
||||
/* not yet at leaf */
|
||||
return (node_lookup(el, str + 1, ptr->next,
|
||||
ncnt + 1));
|
||||
else {
|
||||
/* next node is null so key should be complete */
|
||||
if (str[1] == 0) {
|
||||
el->el_key.buf[ncnt + 1] = '"';
|
||||
el->el_key.buf[ncnt + 2] = '\0';
|
||||
key_kprint(el, el->el_key.buf,
|
||||
&ptr->val, ptr->type);
|
||||
return (0);
|
||||
} else
|
||||
return (-1);
|
||||
/* mismatch -- str still has chars */
|
||||
}
|
||||
} else {
|
||||
/* no match found try sibling */
|
||||
if (ptr->sibling)
|
||||
return (node_lookup(el, str, ptr->sibling,
|
||||
cnt));
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node_enum():
|
||||
* Traverse the node printing the characters it is bound in buffer
|
||||
*/
|
||||
private int
|
||||
node_enum(EditLine *el, key_node_t *ptr, int cnt)
|
||||
{
|
||||
int ncnt;
|
||||
|
||||
if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */
|
||||
el->el_key.buf[++cnt] = '"';
|
||||
el->el_key.buf[++cnt] = '\0';
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Some extended keys too long for internal print buffer");
|
||||
(void) fprintf(el->el_errfile, " \"%s...\"\n", el->el_key.buf);
|
||||
return (0);
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"node_enum: BUG!! Null ptr passed\n!");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
/* put this char at end of str */
|
||||
ncnt = key__decode_char(el->el_key.buf, cnt, (unsigned char) ptr->ch);
|
||||
if (ptr->next == NULL) {
|
||||
/* print this key and function */
|
||||
el->el_key.buf[ncnt + 1] = '"';
|
||||
el->el_key.buf[ncnt + 2] = '\0';
|
||||
key_kprint(el, el->el_key.buf, &ptr->val, ptr->type);
|
||||
} else
|
||||
(void) node_enum(el, ptr->next, ncnt + 1);
|
||||
|
||||
/* go to sibling if there is one */
|
||||
if (ptr->sibling)
|
||||
(void) node_enum(el, ptr->sibling, cnt);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* key_kprint():
|
||||
* Print the specified key and its associated
|
||||
* function specified by val
|
||||
*/
|
||||
protected void
|
||||
key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
|
||||
{
|
||||
el_bindings_t *fp;
|
||||
char unparsbuf[EL_BUFSIZ];
|
||||
static const char fmt[] = "%-15s-> %s\n";
|
||||
|
||||
if (val != NULL)
|
||||
switch (ntype) {
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
(void) fprintf(el->el_outfile, fmt, key,
|
||||
key__decode_str(val->str, unparsbuf,
|
||||
ntype == XK_STR ? "\"\"" : "[]"));
|
||||
break;
|
||||
case XK_CMD:
|
||||
for (fp = el->el_map.help; fp->name; fp++)
|
||||
if (val->cmd == fp->func) {
|
||||
(void) fprintf(el->el_outfile, fmt,
|
||||
key, fp->name);
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG_KEY
|
||||
if (fp->name == NULL)
|
||||
(void) fprintf(el->el_outfile,
|
||||
"BUG! Command not found.\n");
|
||||
#endif
|
||||
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
|
||||
break;
|
||||
}
|
||||
else
|
||||
(void) fprintf(el->el_outfile, fmt, key, "no input");
|
||||
}
|
||||
|
||||
|
||||
/* key__decode_char():
|
||||
* Put a printable form of char in buf.
|
||||
*/
|
||||
private int
|
||||
key__decode_char(char *buf, int cnt, int ch)
|
||||
{
|
||||
if (ch == 0) {
|
||||
buf[cnt++] = '^';
|
||||
buf[cnt] = '@';
|
||||
return (cnt);
|
||||
}
|
||||
if (iscntrl(ch)) {
|
||||
buf[cnt++] = '^';
|
||||
if (ch == '\177')
|
||||
buf[cnt] = '?';
|
||||
else
|
||||
buf[cnt] = ch | 0100;
|
||||
} else if (ch == '^') {
|
||||
buf[cnt++] = '\\';
|
||||
buf[cnt] = '^';
|
||||
} else if (ch == '\\') {
|
||||
buf[cnt++] = '\\';
|
||||
buf[cnt] = '\\';
|
||||
} else if (ch == ' ' || (isprint(ch) && !isspace(ch))) {
|
||||
buf[cnt] = ch;
|
||||
} else {
|
||||
buf[cnt++] = '\\';
|
||||
buf[cnt++] = (((unsigned int) ch >> 6) & 7) + '0';
|
||||
buf[cnt++] = (((unsigned int) ch >> 3) & 7) + '0';
|
||||
buf[cnt] = (ch & 7) + '0';
|
||||
}
|
||||
return (cnt);
|
||||
}
|
||||
|
||||
|
||||
/* key__decode_str():
|
||||
* Make a printable version of the ey
|
||||
*/
|
||||
protected char *
|
||||
key__decode_str(const char *str, char *buf, const char *sep)
|
||||
{
|
||||
char *b;
|
||||
const char *p;
|
||||
|
||||
b = buf;
|
||||
if (sep[0] != '\0')
|
||||
*b++ = sep[0];
|
||||
if (*str == 0) {
|
||||
*b++ = '^';
|
||||
*b++ = '@';
|
||||
if (sep[0] != '\0' && sep[1] != '\0')
|
||||
*b++ = sep[1];
|
||||
*b++ = 0;
|
||||
return (buf);
|
||||
}
|
||||
for (p = str; *p != 0; p++) {
|
||||
if (iscntrl((unsigned char) *p)) {
|
||||
*b++ = '^';
|
||||
if (*p == '\177')
|
||||
*b++ = '?';
|
||||
else
|
||||
*b++ = *p | 0100;
|
||||
} else if (*p == '^' || *p == '\\') {
|
||||
*b++ = '\\';
|
||||
*b++ = *p;
|
||||
} else if (*p == ' ' || (isprint((unsigned char) *p) &&
|
||||
!isspace((unsigned char) *p))) {
|
||||
*b++ = *p;
|
||||
} else {
|
||||
*b++ = '\\';
|
||||
*b++ = (((unsigned int) *p >> 6) & 7) + '0';
|
||||
*b++ = (((unsigned int) *p >> 3) & 7) + '0';
|
||||
*b++ = (*p & 7) + '0';
|
||||
}
|
||||
}
|
||||
if (sep[0] != '\0' && sep[1] != '\0')
|
||||
*b++ = sep[1];
|
||||
*b++ = 0;
|
||||
return (buf); /* should check for overflow */
|
||||
}
|
80
libedit/key.h
Normal file
80
libedit/key.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* $NetBSD: key.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: key.h,v 1.8 2003/08/07 16:44:32 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)key.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.key.h: Key macro header
|
||||
*/
|
||||
#ifndef _h_el_key
|
||||
#define _h_el_key
|
||||
|
||||
typedef union key_value_t {
|
||||
el_action_t cmd; /* If it is a command the # */
|
||||
char *str; /* If it is a string... */
|
||||
} key_value_t;
|
||||
|
||||
typedef struct key_node_t key_node_t;
|
||||
|
||||
typedef struct el_key_t {
|
||||
char *buf; /* Key print buffer */
|
||||
key_node_t *map; /* Key map */
|
||||
key_value_t val; /* Local conversion buffer */
|
||||
} el_key_t;
|
||||
|
||||
#define XK_CMD 0
|
||||
#define XK_STR 1
|
||||
#define XK_NOD 2
|
||||
#define XK_EXE 3
|
||||
|
||||
#undef key_end
|
||||
#undef key_clear
|
||||
#undef key_print
|
||||
|
||||
protected int key_init(EditLine *);
|
||||
protected void key_end(EditLine *);
|
||||
protected key_value_t *key_map_cmd(EditLine *, int);
|
||||
protected key_value_t *key_map_str(EditLine *, char *);
|
||||
protected void key_reset(EditLine *);
|
||||
protected int key_get(EditLine *, char *, key_value_t *);
|
||||
protected void key_add(EditLine *, const char *, key_value_t *, int);
|
||||
protected void key_clear(EditLine *, el_action_t *, const char *);
|
||||
protected int key_delete(EditLine *, const char *);
|
||||
protected void key_print(EditLine *, const char *);
|
||||
protected void key_kprint(EditLine *, const char *, key_value_t *,
|
||||
int);
|
||||
protected char *key__decode_str(const char *, char *, const char *);
|
||||
|
||||
#endif /* _h_el_key */
|
259
libedit/makelist.in
Executable file
259
libedit/makelist.in
Executable file
@ -0,0 +1,259 @@
|
||||
#!/bin/sh -
|
||||
# @configure_input@
|
||||
#
|
||||
# $NetBSD: makelist.in,v 1.2 2005/01/05 04:40:05 lukem Exp $
|
||||
#
|
||||
# Copyright (c) 1992, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to Berkeley by
|
||||
# Christos Zoulas of Cornell University.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# @(#)makelist 5.3 (Berkeley) 6/4/93
|
||||
|
||||
# makelist.sh: Automatically generate header files...
|
||||
|
||||
AWK=@AWK@
|
||||
USAGE="Usage: $0 -h|-e|-fc|-fh|-bc|-bh|-m <filenames>"
|
||||
|
||||
LC_ALL="C"
|
||||
export LC_ALL
|
||||
|
||||
if [ "x$1" = "x" ]
|
||||
then
|
||||
echo $USAGE 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FLAG="$1"
|
||||
shift
|
||||
|
||||
FILES="$@"
|
||||
|
||||
case $FLAG in
|
||||
|
||||
# generate foo.h file from foo.c
|
||||
#
|
||||
-h)
|
||||
set - `echo $FILES | sed -e 's/\\./_/g'`
|
||||
hdr="_h_`basename $1`"
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'");
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
#
|
||||
# XXX: need a space between name and prototype so that -fc and -fh
|
||||
# parsing is much easier
|
||||
#
|
||||
printf("protected el_action_t\t%s (EditLine *, int);\n", name);
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("#endif /* %s */\n", "'$hdr'");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate help.c from various .c files
|
||||
#
|
||||
-bc)
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"sys.h\"\n#include \"el.h\"\n");
|
||||
printf("private const struct el_bindings_t el_func_help[] = {\n");
|
||||
low = "abcdefghijklmnopqrstuvwxyz_";
|
||||
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
for (i = 1; i <= length(low); i++)
|
||||
tr[substr(low, i, 1)] = substr(high, i, 1);
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
uname = "";
|
||||
fname = "";
|
||||
for (i = 1; i <= length(name); i++) {
|
||||
s = substr(name, i, 1);
|
||||
uname = uname tr[s];
|
||||
if (s == "_")
|
||||
s = "-";
|
||||
fname = fname s;
|
||||
}
|
||||
|
||||
printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ",");
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
/^ \*/ {
|
||||
if (ok) {
|
||||
printf(" \"");
|
||||
for (i = 2; i < NF; i++)
|
||||
printf("%s ", $i);
|
||||
printf("%s\" },\n", $i);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf(" { NULL, 0, NULL }\n");
|
||||
printf("};\n");
|
||||
printf("\nprotected const el_bindings_t* help__get()");
|
||||
printf("{ return el_func_help; }\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate help.h from various .c files
|
||||
#
|
||||
-bh)
|
||||
$AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef _h_help_c\n#define _h_help_c\n");
|
||||
printf("protected const el_bindings_t *help__get(void);\n");
|
||||
printf("#endif /* _h_help_c */\n");
|
||||
}' /dev/null
|
||||
;;
|
||||
|
||||
# generate fcns.h from various .h files
|
||||
#
|
||||
-fh)
|
||||
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
|
||||
sort | tr '[a-z]' '[A-Z]' | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n");
|
||||
count = 0;
|
||||
}
|
||||
{
|
||||
printf("#define\t%-30.30s\t%3d\n", $1, count++);
|
||||
}
|
||||
END {
|
||||
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
|
||||
|
||||
printf("typedef el_action_t (*el_func_t)(EditLine *, int);");
|
||||
printf("\nprotected const el_func_t* func__get(void);\n");
|
||||
printf("#endif /* _h_fcns_c */\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate fcns.c from various .h files
|
||||
#
|
||||
-fc)
|
||||
cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"sys.h\"\n#include \"el.h\"\n");
|
||||
printf("private const el_func_t el_func[] = {");
|
||||
maxlen = 80;
|
||||
needn = 1;
|
||||
len = 0;
|
||||
}
|
||||
{
|
||||
clen = 25 + 2;
|
||||
len += clen;
|
||||
if (len >= maxlen)
|
||||
needn = 1;
|
||||
if (needn) {
|
||||
printf("\n ");
|
||||
needn = 0;
|
||||
len = 4 + clen;
|
||||
}
|
||||
s = $1 ",";
|
||||
printf("%-26.26s ", s);
|
||||
}
|
||||
END {
|
||||
printf("\n};\n");
|
||||
printf("\nprotected const el_func_t* func__get() { return el_func; }\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate editline.c from various .c files
|
||||
#
|
||||
-e)
|
||||
echo "$FILES" | tr ' ' '\012' | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#define protected static\n");
|
||||
printf("#define SCCSID\n");
|
||||
}
|
||||
{
|
||||
printf("#include \"%s\"\n", $1);
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate man page fragment from various .c files
|
||||
#
|
||||
-m)
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf(".\\\" Section automatically generated with makelist\n");
|
||||
printf(".Bl -tag -width 4n\n");
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
fname = "";
|
||||
for (i = 1; i <= length(name); i++) {
|
||||
s = substr(name, i, 1);
|
||||
if (s == "_")
|
||||
s = "-";
|
||||
fname = fname s;
|
||||
}
|
||||
|
||||
printf(".It Ic %s\n", fname);
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
/^ \*/ {
|
||||
if (ok) {
|
||||
for (i = 2; i < NF; i++)
|
||||
printf("%s ", $i);
|
||||
printf("%s.\n", $i);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf(".El\n");
|
||||
printf(".\\\" End of section automatically generated with makelist\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $USAGE 1>&2
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
1409
libedit/map.c
Normal file
1409
libedit/map.c
Normal file
File diff suppressed because it is too large
Load Diff
76
libedit/map.h
Normal file
76
libedit/map.h
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: map.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)map.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.map.h: Editor maps
|
||||
*/
|
||||
#ifndef _h_el_map
|
||||
#define _h_el_map
|
||||
|
||||
typedef struct el_bindings_t { /* for the "bind" shell command */
|
||||
const char *name; /* function name for bind command */
|
||||
int func; /* function numeric value */
|
||||
const char *description; /* description of function */
|
||||
} el_bindings_t;
|
||||
|
||||
|
||||
typedef struct el_map_t {
|
||||
el_action_t *alt; /* The current alternate key map */
|
||||
el_action_t *key; /* The current normal key map */
|
||||
el_action_t *current; /* The keymap we are using */
|
||||
const el_action_t *emacs; /* The default emacs key map */
|
||||
const el_action_t *vic; /* The vi command mode key map */
|
||||
const el_action_t *vii; /* The vi insert mode key map */
|
||||
int type; /* Emacs or vi */
|
||||
el_bindings_t *help; /* The help for the editor functions */
|
||||
el_func_t *func; /* List of available functions */
|
||||
int nfunc; /* The number of functions/help items */
|
||||
} el_map_t;
|
||||
|
||||
#define MAP_EMACS 0
|
||||
#define MAP_VI 1
|
||||
|
||||
protected int map_bind(EditLine *, int, const char **);
|
||||
protected int map_init(EditLine *);
|
||||
protected void map_end(EditLine *);
|
||||
protected void map_init_vi(EditLine *);
|
||||
protected void map_init_emacs(EditLine *);
|
||||
protected int map_set_editor(EditLine *, char *);
|
||||
protected int map_get_editor(EditLine *, const char **);
|
||||
protected int map_addfunc(EditLine *, const char *, const char *, el_func_t);
|
||||
|
||||
#endif /* _h_el_map */
|
258
libedit/parse.c
Normal file
258
libedit/parse.c
Normal file
@ -0,0 +1,258 @@
|
||||
/* $NetBSD: parse.c,v 1.6 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* parse.c: parse an editline extended command
|
||||
*
|
||||
* commands are:
|
||||
*
|
||||
* bind
|
||||
* echotc
|
||||
* edit
|
||||
* gettc
|
||||
* history
|
||||
* settc
|
||||
* setty
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
private const struct {
|
||||
const char *name;
|
||||
int (*func)(EditLine *, int, const char **);
|
||||
} cmds[] = {
|
||||
{ "bind", map_bind },
|
||||
{ "echotc", term_echotc },
|
||||
{ "edit", el_editmode },
|
||||
{ "history", hist_command },
|
||||
{ "telltc", term_telltc },
|
||||
{ "settc", term_settc },
|
||||
{ "setty", tty_stty },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* parse_line():
|
||||
* Parse a line and dispatch it
|
||||
*/
|
||||
protected int
|
||||
parse_line(EditLine *el, const char *line)
|
||||
{
|
||||
const char **argv;
|
||||
int argc;
|
||||
Tokenizer *tok;
|
||||
|
||||
tok = tok_init(NULL);
|
||||
tok_str(tok, line, &argc, &argv);
|
||||
argc = el_parse(el, argc, argv);
|
||||
tok_end(tok);
|
||||
return (argc);
|
||||
}
|
||||
|
||||
|
||||
/* el_parse():
|
||||
* Command dispatcher
|
||||
*/
|
||||
public int
|
||||
el_parse(EditLine *el, int argc, const char *argv[])
|
||||
{
|
||||
const char *ptr;
|
||||
int i;
|
||||
|
||||
if (argc < 1)
|
||||
return (-1);
|
||||
ptr = strchr(argv[0], ':');
|
||||
if (ptr != NULL) {
|
||||
char *tprog;
|
||||
size_t l;
|
||||
|
||||
if (ptr == argv[0])
|
||||
return (0);
|
||||
l = ptr - argv[0] - 1;
|
||||
tprog = (char *) el_malloc(l + 1);
|
||||
if (tprog == NULL)
|
||||
return (0);
|
||||
(void) strncpy(tprog, argv[0], l);
|
||||
tprog[l] = '\0';
|
||||
ptr++;
|
||||
l = el_match(el->el_prog, tprog);
|
||||
el_free(tprog);
|
||||
if (!l)
|
||||
return (0);
|
||||
} else
|
||||
ptr = argv[0];
|
||||
|
||||
for (i = 0; cmds[i].name != NULL; i++)
|
||||
if (strcmp(cmds[i].name, ptr) == 0) {
|
||||
i = (*cmds[i].func) (el, argc, argv);
|
||||
return (-i);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* parse__escape():
|
||||
* Parse a string of the form ^<char> \<odigit> \<char> and return
|
||||
* the appropriate character or -1 if the escape is not valid
|
||||
*/
|
||||
protected int
|
||||
parse__escape(const char **ptr)
|
||||
{
|
||||
const char *p;
|
||||
int c;
|
||||
|
||||
p = *ptr;
|
||||
|
||||
if (p[1] == 0)
|
||||
return (-1);
|
||||
|
||||
if (*p == '\\') {
|
||||
p++;
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
c = '\007'; /* Bell */
|
||||
break;
|
||||
case 'b':
|
||||
c = '\010'; /* Backspace */
|
||||
break;
|
||||
case 't':
|
||||
c = '\011'; /* Horizontal Tab */
|
||||
break;
|
||||
case 'n':
|
||||
c = '\012'; /* New Line */
|
||||
break;
|
||||
case 'v':
|
||||
c = '\013'; /* Vertical Tab */
|
||||
break;
|
||||
case 'f':
|
||||
c = '\014'; /* Form Feed */
|
||||
break;
|
||||
case 'r':
|
||||
c = '\015'; /* Carriage Return */
|
||||
break;
|
||||
case 'e':
|
||||
c = '\033'; /* Escape */
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
{
|
||||
int cnt, ch;
|
||||
|
||||
for (cnt = 0, c = 0; cnt < 3; cnt++) {
|
||||
ch = *p++;
|
||||
if (ch < '0' || ch > '7') {
|
||||
p--;
|
||||
break;
|
||||
}
|
||||
c = (c << 3) | (ch - '0');
|
||||
}
|
||||
if ((c & 0xffffff00) != 0)
|
||||
return (-1);
|
||||
--p;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
c = *p;
|
||||
break;
|
||||
}
|
||||
} else if (*p == '^') {
|
||||
p++;
|
||||
c = (*p == '?') ? '\177' : (*p & 0237);
|
||||
} else
|
||||
c = *p;
|
||||
*ptr = ++p;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* parse__string():
|
||||
* Parse the escapes from in and put the raw string out
|
||||
*/
|
||||
protected char *
|
||||
parse__string(char *out, const char *in)
|
||||
{
|
||||
char *rv = out;
|
||||
int n;
|
||||
|
||||
for (;;)
|
||||
switch (*in) {
|
||||
case '\0':
|
||||
*out = '\0';
|
||||
return (rv);
|
||||
|
||||
case '\\':
|
||||
case '^':
|
||||
if ((n = parse__escape(&in)) == -1)
|
||||
return (NULL);
|
||||
*out++ = n;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (in[1] == '-' && in[2] != '\0') {
|
||||
*out++ = '\033';
|
||||
in += 2;
|
||||
break;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
default:
|
||||
*out++ = *in++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* parse_cmd():
|
||||
* Return the command number for the command string given
|
||||
* or -1 if one is not found
|
||||
*/
|
||||
protected int
|
||||
parse_cmd(EditLine *el, const char *cmd)
|
||||
{
|
||||
el_bindings_t *b;
|
||||
|
||||
for (b = el->el_map.help; b->name != NULL; b++)
|
||||
if (strcmp(b->name, cmd) == 0)
|
||||
return (b->func);
|
||||
return (-1);
|
||||
}
|
49
libedit/parse.h
Normal file
49
libedit/parse.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* $NetBSD: parse.h,v 1.3 2005/05/31 02:07:02 lukem Exp $ */
|
||||
/* from NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)parse.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.parse.h: Parser functions
|
||||
*/
|
||||
#ifndef _h_el_parse
|
||||
#define _h_el_parse
|
||||
|
||||
protected int parse_line(EditLine *, const char *);
|
||||
protected int parse__escape(const char **);
|
||||
protected char *parse__string(char *, const char *);
|
||||
protected int parse_cmd(EditLine *, const char *);
|
||||
|
||||
#endif /* _h_el_parse */
|
165
libedit/prompt.c
Normal file
165
libedit/prompt.c
Normal file
@ -0,0 +1,165 @@
|
||||
/* $NetBSD: prompt.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* prompt.c: Prompt printing functions
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "el.h"
|
||||
|
||||
private char *prompt_default(EditLine *);
|
||||
private char *prompt_default_r(EditLine *);
|
||||
|
||||
/* prompt_default():
|
||||
* Just a default prompt, in case the user did not provide one
|
||||
*/
|
||||
private char *
|
||||
/*ARGSUSED*/
|
||||
prompt_default(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
static char a[3] = {'?', ' ', '\0'};
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_default_r():
|
||||
* Just a default rprompt, in case the user did not provide one
|
||||
*/
|
||||
private char *
|
||||
/*ARGSUSED*/
|
||||
prompt_default_r(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
static char a[1] = {'\0'};
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_print():
|
||||
* Print the prompt and update the prompt position.
|
||||
* We use an array of integers in case we want to pass
|
||||
* literal escape sequences in the prompt and we want a
|
||||
* bit to flag them
|
||||
*/
|
||||
protected void
|
||||
prompt_print(EditLine *el, int op)
|
||||
{
|
||||
el_prompt_t *elp;
|
||||
char *p;
|
||||
|
||||
if (op == EL_PROMPT)
|
||||
elp = &el->el_prompt;
|
||||
else
|
||||
elp = &el->el_rprompt;
|
||||
p = (elp->p_func) (el);
|
||||
while (*p)
|
||||
re_putc(el, *p++, 1);
|
||||
|
||||
elp->p_pos.v = el->el_refresh.r_cursor.v;
|
||||
elp->p_pos.h = el->el_refresh.r_cursor.h;
|
||||
}
|
||||
|
||||
|
||||
/* prompt_init():
|
||||
* Initialize the prompt stuff
|
||||
*/
|
||||
protected int
|
||||
prompt_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_prompt.p_func = prompt_default;
|
||||
el->el_prompt.p_pos.v = 0;
|
||||
el->el_prompt.p_pos.h = 0;
|
||||
el->el_rprompt.p_func = prompt_default_r;
|
||||
el->el_rprompt.p_pos.v = 0;
|
||||
el->el_rprompt.p_pos.h = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_end():
|
||||
* Clean up the prompt stuff
|
||||
*/
|
||||
protected void
|
||||
/*ARGSUSED*/
|
||||
prompt_end(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* prompt_set():
|
||||
* Install a prompt printing function
|
||||
*/
|
||||
protected int
|
||||
prompt_set(EditLine *el, el_pfunc_t prf, int op)
|
||||
{
|
||||
el_prompt_t *p;
|
||||
|
||||
if (op == EL_PROMPT)
|
||||
p = &el->el_prompt;
|
||||
else
|
||||
p = &el->el_rprompt;
|
||||
if (prf == NULL) {
|
||||
if (op == EL_PROMPT)
|
||||
p->p_func = prompt_default;
|
||||
else
|
||||
p->p_func = prompt_default_r;
|
||||
} else
|
||||
p->p_func = prf;
|
||||
p->p_pos.v = 0;
|
||||
p->p_pos.h = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_get():
|
||||
* Retrieve the prompt printing function
|
||||
*/
|
||||
protected int
|
||||
prompt_get(EditLine *el, el_pfunc_t *prf, int op)
|
||||
{
|
||||
|
||||
if (prf == NULL)
|
||||
return (-1);
|
||||
if (op == EL_PROMPT)
|
||||
*prf = el->el_prompt.p_func;
|
||||
else
|
||||
*prf = el->el_rprompt.p_func;
|
||||
return (0);
|
||||
}
|
59
libedit/prompt.h
Normal file
59
libedit/prompt.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* $NetBSD: prompt.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)prompt.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.prompt.h: Prompt printing stuff
|
||||
*/
|
||||
#ifndef _h_el_prompt
|
||||
#define _h_el_prompt
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef char * (*el_pfunc_t)(EditLine*);
|
||||
|
||||
typedef struct el_prompt_t {
|
||||
el_pfunc_t p_func; /* Function to return the prompt */
|
||||
coord_t p_pos; /* position in the line after prompt */
|
||||
} el_prompt_t;
|
||||
|
||||
protected void prompt_print(EditLine *, int);
|
||||
protected int prompt_set(EditLine *, el_pfunc_t, int);
|
||||
protected int prompt_get(EditLine *, el_pfunc_t *, int);
|
||||
protected int prompt_init(EditLine *);
|
||||
protected void prompt_end(EditLine *);
|
||||
|
||||
#endif /* _h_el_prompt */
|
607
libedit/read.c
Normal file
607
libedit/read.c
Normal file
@ -0,0 +1,607 @@
|
||||
/* $NetBSD: read.c,v 1.7 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: read.c,v 1.35 2005/03/09 23:55:02 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* read.c: Clean this junk up! This is horrible code.
|
||||
* Terminal read functions
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
#define OKCMD -1
|
||||
|
||||
private int read__fixio(int, int);
|
||||
private int read_preread(EditLine *);
|
||||
private int read_char(EditLine *, char *);
|
||||
private int read_getcmd(EditLine *, el_action_t *, char *);
|
||||
|
||||
/* read_init():
|
||||
* Initialize the read stuff
|
||||
*/
|
||||
protected int
|
||||
read_init(EditLine *el)
|
||||
{
|
||||
/* builtin read_char */
|
||||
el->el_read.read_char = read_char;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* el_read_setfn():
|
||||
* Set the read char function to the one provided.
|
||||
* If it is set to EL_BUILTIN_GETCFN, then reset to the builtin one.
|
||||
*/
|
||||
protected int
|
||||
el_read_setfn(EditLine *el, el_rfunc_t rc)
|
||||
{
|
||||
el->el_read.read_char = (rc == EL_BUILTIN_GETCFN) ? read_char : rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* el_read_getfn():
|
||||
* return the current read char function, or EL_BUILTIN_GETCFN
|
||||
* if it is the default one
|
||||
*/
|
||||
protected el_rfunc_t
|
||||
el_read_getfn(EditLine *el)
|
||||
{
|
||||
return (el->el_read.read_char == read_char) ?
|
||||
EL_BUILTIN_GETCFN : el->el_read.read_char;
|
||||
}
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_EDIT
|
||||
private void
|
||||
read_debug(EditLine *el)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
(void) fprintf(el->el_errfile, "cursor > lastchar\r\n");
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
(void) fprintf(el->el_errfile, "cursor < buffer\r\n");
|
||||
if (el->el_line.cursor > el->el_line.limit)
|
||||
(void) fprintf(el->el_errfile, "cursor > limit\r\n");
|
||||
if (el->el_line.lastchar > el->el_line.limit)
|
||||
(void) fprintf(el->el_errfile, "lastchar > limit\r\n");
|
||||
if (el->el_line.limit != &el->el_line.buffer[EL_BUFSIZ - 2])
|
||||
(void) fprintf(el->el_errfile, "limit != &buffer[EL_BUFSIZ-2]\r\n");
|
||||
}
|
||||
#endif /* DEBUG_EDIT */
|
||||
|
||||
|
||||
/* read__fixio():
|
||||
* Try to recover from a read error
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private int
|
||||
read__fixio(int fd __attribute__((__unused__)), int e)
|
||||
{
|
||||
|
||||
switch (e) {
|
||||
case -1: /* Make sure that the code is reachable */
|
||||
|
||||
#ifdef EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
#ifndef TRY_AGAIN
|
||||
#define TRY_AGAIN
|
||||
#endif
|
||||
#endif /* EWOULDBLOCK */
|
||||
|
||||
#if defined(POSIX) && defined(EAGAIN)
|
||||
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
#ifndef TRY_AGAIN
|
||||
#define TRY_AGAIN
|
||||
#endif
|
||||
#endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */
|
||||
#endif /* POSIX && EAGAIN */
|
||||
|
||||
e = 0;
|
||||
#ifdef TRY_AGAIN
|
||||
#if defined(F_SETFL) && defined(O_NDELAY)
|
||||
if ((e = fcntl(fd, F_GETFL, 0)) == -1)
|
||||
return (-1);
|
||||
|
||||
if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1)
|
||||
return (-1);
|
||||
else
|
||||
e = 1;
|
||||
#endif /* F_SETFL && O_NDELAY */
|
||||
|
||||
#ifdef FIONBIO
|
||||
{
|
||||
int zero = 0;
|
||||
|
||||
if (ioctl(fd, FIONBIO, (ioctl_t) & zero) == -1)
|
||||
return (-1);
|
||||
else
|
||||
e = 1;
|
||||
}
|
||||
#endif /* FIONBIO */
|
||||
|
||||
#endif /* TRY_AGAIN */
|
||||
return (e ? 0 : -1);
|
||||
|
||||
case EINTR:
|
||||
return (0);
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* read_preread():
|
||||
* Try to read the stuff in the input queue;
|
||||
*/
|
||||
private int
|
||||
read_preread(EditLine *el)
|
||||
{
|
||||
int chrs = 0;
|
||||
|
||||
if (el->el_tty.t_mode == ED_IO)
|
||||
return (0);
|
||||
|
||||
#ifdef FIONREAD
|
||||
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
|
||||
if (chrs > 0) {
|
||||
char buf[EL_BUFSIZ];
|
||||
|
||||
chrs = read(el->el_infd, buf,
|
||||
(size_t) MIN(chrs, EL_BUFSIZ - 1));
|
||||
if (chrs > 0) {
|
||||
buf[chrs] = '\0';
|
||||
el_push(el, buf);
|
||||
}
|
||||
}
|
||||
#endif /* FIONREAD */
|
||||
|
||||
return (chrs > 0);
|
||||
}
|
||||
|
||||
|
||||
/* el_push():
|
||||
* Push a macro
|
||||
*/
|
||||
public void
|
||||
el_push(EditLine *el, char *str)
|
||||
{
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
|
||||
if (str != NULL && ma->level + 1 < EL_MAXMACRO) {
|
||||
ma->level++;
|
||||
if ((ma->macro[ma->level] = el_strdup(str)) != NULL)
|
||||
return;
|
||||
ma->level--;
|
||||
}
|
||||
term_beep(el);
|
||||
term__flush();
|
||||
}
|
||||
|
||||
|
||||
/* read_getcmd():
|
||||
* Return next command from the input stream.
|
||||
*/
|
||||
private int
|
||||
read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch)
|
||||
{
|
||||
el_action_t cmd;
|
||||
int num;
|
||||
|
||||
do {
|
||||
if ((num = el_getc(el, ch)) != 1) /* if EOF or error */
|
||||
return (num);
|
||||
|
||||
#ifdef KANJI
|
||||
if ((*ch & 0200)) {
|
||||
el->el_state.metanext = 0;
|
||||
cmd = CcViMap[' '];
|
||||
break;
|
||||
} else
|
||||
#endif /* KANJI */
|
||||
|
||||
if (el->el_state.metanext) {
|
||||
el->el_state.metanext = 0;
|
||||
*ch |= 0200;
|
||||
}
|
||||
cmd = el->el_map.current[(unsigned char) *ch];
|
||||
if (cmd == ED_SEQUENCE_LEAD_IN) {
|
||||
key_value_t val;
|
||||
switch (key_get(el, ch, &val)) {
|
||||
case XK_CMD:
|
||||
cmd = val.cmd;
|
||||
break;
|
||||
case XK_STR:
|
||||
el_push(el, val.str);
|
||||
break;
|
||||
#ifdef notyet
|
||||
case XK_EXE:
|
||||
/* XXX: In the future to run a user function */
|
||||
RunCommand(val.str);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type \n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (el->el_map.alt == NULL)
|
||||
el->el_map.current = el->el_map.key;
|
||||
} while (cmd == ED_SEQUENCE_LEAD_IN);
|
||||
*cmdnum = cmd;
|
||||
return (OKCMD);
|
||||
}
|
||||
|
||||
|
||||
/* read_char():
|
||||
* Read a character from the tty.
|
||||
*/
|
||||
private int
|
||||
read_char(EditLine *el, char *cp)
|
||||
{
|
||||
int num_read;
|
||||
int tried = 0;
|
||||
|
||||
while ((num_read = read(el->el_infd, cp, 1)) == -1)
|
||||
if (!tried && read__fixio(el->el_infd, errno) == 0)
|
||||
tried = 1;
|
||||
else {
|
||||
*cp = '\0';
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (num_read);
|
||||
}
|
||||
|
||||
|
||||
/* el_getc():
|
||||
* Read a character
|
||||
*/
|
||||
public int
|
||||
el_getc(EditLine *el, char *cp)
|
||||
{
|
||||
int num_read;
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
|
||||
term__flush();
|
||||
for (;;) {
|
||||
if (ma->level < 0) {
|
||||
if (!read_preread(el))
|
||||
break;
|
||||
}
|
||||
if (ma->level < 0)
|
||||
break;
|
||||
|
||||
if (ma->macro[ma->level][ma->offset] == '\0') {
|
||||
el_free(ma->macro[ma->level--]);
|
||||
ma->offset = 0;
|
||||
continue;
|
||||
}
|
||||
*cp = ma->macro[ma->level][ma->offset++] & 0377;
|
||||
if (ma->macro[ma->level][ma->offset] == '\0') {
|
||||
/* Needed for QuoteMode On */
|
||||
el_free(ma->macro[ma->level--]);
|
||||
ma->offset = 0;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Turning raw mode on\n");
|
||||
#endif /* DEBUG_READ */
|
||||
if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */
|
||||
return (0);
|
||||
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Reading a character\n");
|
||||
#endif /* DEBUG_READ */
|
||||
num_read = (*el->el_read.read_char)(el, cp);
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Got it %c\n", *cp);
|
||||
#endif /* DEBUG_READ */
|
||||
return (num_read);
|
||||
}
|
||||
|
||||
protected void
|
||||
read_prepare(EditLine *el)
|
||||
{
|
||||
if (el->el_flags & HANDLE_SIGNALS)
|
||||
sig_set(el);
|
||||
if (el->el_flags & NO_TTY)
|
||||
return;
|
||||
if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
|
||||
tty_rawmode(el);
|
||||
|
||||
/* This is relatively cheap, and things go terribly wrong if
|
||||
we have the wrong size. */
|
||||
el_resize(el);
|
||||
re_clear_display(el); /* reset the display stuff */
|
||||
ch_reset(el);
|
||||
re_refresh(el); /* print the prompt */
|
||||
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
term__flush();
|
||||
}
|
||||
|
||||
protected void
|
||||
read_finish(EditLine *el)
|
||||
{
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
(void) tty_cookedmode(el);
|
||||
if (el->el_flags & HANDLE_SIGNALS)
|
||||
sig_clr(el);
|
||||
}
|
||||
|
||||
public const char *
|
||||
el_gets(EditLine *el, int *nread)
|
||||
{
|
||||
int retval;
|
||||
el_action_t cmdnum = 0;
|
||||
int num; /* how many chars we have read at NL */
|
||||
char ch;
|
||||
int crlf = 0;
|
||||
#ifdef FIONREAD
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
#endif /* FIONREAD */
|
||||
|
||||
if (el->el_flags & NO_TTY) {
|
||||
char *cp = el->el_line.buffer;
|
||||
size_t idx;
|
||||
|
||||
while ((*el->el_read.read_char)(el, cp) == 1) {
|
||||
/* make sure there is space for next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (cp - el->el_line.buffer);
|
||||
if (!ch_enlargebufs(el, 2))
|
||||
break;
|
||||
cp = &el->el_line.buffer[idx];
|
||||
}
|
||||
cp++;
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
if (cp[-1] == '\r' || cp[-1] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar = cp;
|
||||
*cp = '\0';
|
||||
if (nread)
|
||||
*nread = el->el_line.cursor - el->el_line.buffer;
|
||||
return (el->el_line.buffer);
|
||||
}
|
||||
|
||||
|
||||
#ifdef FIONREAD
|
||||
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
|
||||
long chrs = 0;
|
||||
|
||||
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
|
||||
if (chrs == 0) {
|
||||
if (tty_rawmode(el) < 0) {
|
||||
if (nread)
|
||||
*nread = 0;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* FIONREAD */
|
||||
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
read_prepare(el);
|
||||
|
||||
if (el->el_flags & EDIT_DISABLED) {
|
||||
char *cp;
|
||||
size_t idx;
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
cp = el->el_line.buffer;
|
||||
else
|
||||
cp = el->el_line.lastchar;
|
||||
|
||||
term__flush();
|
||||
|
||||
while ((*el->el_read.read_char)(el, cp) == 1) {
|
||||
/* make sure there is space next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (cp - el->el_line.buffer);
|
||||
if (!ch_enlargebufs(el, 2))
|
||||
break;
|
||||
cp = &el->el_line.buffer[idx];
|
||||
}
|
||||
if (*cp == 4) /* ought to be stty eof */
|
||||
break;
|
||||
cp++;
|
||||
crlf = cp[-1] == '\r' || cp[-1] == '\n';
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
if (crlf)
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar = cp;
|
||||
*cp = '\0';
|
||||
if (nread)
|
||||
*nread = el->el_line.cursor - el->el_line.buffer;
|
||||
return (el->el_line.buffer);
|
||||
}
|
||||
|
||||
for (num = OKCMD; num == OKCMD;) { /* while still editing this
|
||||
* line */
|
||||
#ifdef DEBUG_EDIT
|
||||
read_debug(el);
|
||||
#endif /* DEBUG_EDIT */
|
||||
/* if EOF or error */
|
||||
if ((num = read_getcmd(el, &cmdnum, &ch)) != OKCMD) {
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Returning from el_gets %d\n", num);
|
||||
#endif /* DEBUG_READ */
|
||||
break;
|
||||
}
|
||||
if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"ERROR: illegal command from key 0%o\r\n", ch);
|
||||
#endif /* DEBUG_EDIT */
|
||||
continue; /* try again */
|
||||
}
|
||||
/* now do the real command */
|
||||
#ifdef DEBUG_READ
|
||||
{
|
||||
el_bindings_t *b;
|
||||
for (b = el->el_map.help; b->name; b++)
|
||||
if (b->func == cmdnum)
|
||||
break;
|
||||
if (b->name)
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Executing %s\n", b->name);
|
||||
else
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Error command = %d\n", cmdnum);
|
||||
}
|
||||
#endif /* DEBUG_READ */
|
||||
/* vi redo needs these way down the levels... */
|
||||
el->el_state.thiscmd = cmdnum;
|
||||
el->el_state.thisch = ch;
|
||||
if (el->el_map.type == MAP_VI &&
|
||||
el->el_map.current == el->el_map.key &&
|
||||
el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) {
|
||||
if (cmdnum == VI_DELETE_PREV_CHAR &&
|
||||
el->el_chared.c_redo.pos != el->el_chared.c_redo.buf
|
||||
&& isprint((unsigned char)el->el_chared.c_redo.pos[-1]))
|
||||
el->el_chared.c_redo.pos--;
|
||||
else
|
||||
*el->el_chared.c_redo.pos++ = ch;
|
||||
}
|
||||
retval = (*el->el_map.func[cmdnum]) (el, ch);
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Returned state %d\n", retval );
|
||||
#endif /* DEBUG_READ */
|
||||
|
||||
/* save the last command here */
|
||||
el->el_state.lastcmd = cmdnum;
|
||||
|
||||
/* use any return value */
|
||||
switch (retval) {
|
||||
case CC_CURSOR:
|
||||
re_refresh_cursor(el);
|
||||
break;
|
||||
|
||||
case CC_REDISPLAY:
|
||||
re_clear_lines(el);
|
||||
re_clear_display(el);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case CC_REFRESH:
|
||||
re_refresh(el);
|
||||
break;
|
||||
|
||||
case CC_REFRESH_BEEP:
|
||||
re_refresh(el);
|
||||
term_beep(el);
|
||||
break;
|
||||
|
||||
case CC_NORM: /* normal char */
|
||||
break;
|
||||
|
||||
case CC_ARGHACK: /* Suggested by Rich Salz */
|
||||
/* <rsalz@pineapple.bbn.com> */
|
||||
continue; /* keep going... */
|
||||
|
||||
case CC_EOF: /* end of file typed */
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
num = 0;
|
||||
else if (num == -1) {
|
||||
*el->el_line.lastchar++ = CONTROL('d');
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
num = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case CC_NEWLINE: /* normal end of line */
|
||||
num = el->el_line.lastchar - el->el_line.buffer;
|
||||
break;
|
||||
|
||||
case CC_FATAL: /* fatal error, reset to known state */
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"*** editor fatal ERROR ***\r\n\n");
|
||||
#endif /* DEBUG_READ */
|
||||
/* put (real) cursor in a known place */
|
||||
re_clear_display(el); /* reset the display stuff */
|
||||
ch_reset(el); /* reset the input pointers */
|
||||
re_refresh(el); /* print the prompt again */
|
||||
break;
|
||||
|
||||
case CC_ERROR:
|
||||
default: /* functions we don't know about */
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"*** editor ERROR ***\r\n\n");
|
||||
#endif /* DEBUG_READ */
|
||||
term_beep(el);
|
||||
term__flush();
|
||||
break;
|
||||
}
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
}
|
||||
|
||||
term__flush(); /* flush any buffered output */
|
||||
/* make sure the tty is set up correctly */
|
||||
if ((el->el_flags & UNBUFFERED) == 0) {
|
||||
read_finish(el);
|
||||
if (nread)
|
||||
*nread = num;
|
||||
} else {
|
||||
if (nread)
|
||||
*nread = el->el_line.lastchar - el->el_line.buffer;
|
||||
}
|
||||
return (num ? el->el_line.buffer : NULL);
|
||||
}
|
51
libedit/read.h
Normal file
51
libedit/read.h
Normal file
@ -0,0 +1,51 @@
|
||||
/* $NetBSD: read.h,v 1.3 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: read.h,v 1.4 2004/02/27 14:52:18 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Anthony Mallet.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.read.h: Character reading functions
|
||||
*/
|
||||
#ifndef _h_el_read
|
||||
#define _h_el_read
|
||||
|
||||
typedef int (*el_rfunc_t)(EditLine *, char *);
|
||||
|
||||
typedef struct el_read_t {
|
||||
el_rfunc_t read_char; /* Function to read a character */
|
||||
} el_read_t;
|
||||
|
||||
protected int read_init(EditLine *);
|
||||
protected void read_prepare(EditLine *);
|
||||
protected void read_finish(EditLine *);
|
||||
protected int el_read_setfn(EditLine *, el_rfunc_t);
|
||||
protected el_rfunc_t el_read_getfn(EditLine *);
|
||||
|
||||
#endif /* _h_el_read */
|
1720
libedit/readline.c
Normal file
1720
libedit/readline.c
Normal file
File diff suppressed because it is too large
Load Diff
188
libedit/readline/readline.h
Normal file
188
libedit/readline/readline.h
Normal file
@ -0,0 +1,188 @@
|
||||
/* $NetBSD: readline.h,v 1.4 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: readline.h,v 1.14 2005/05/27 11:35:07 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _READLINE_H_
|
||||
#define _READLINE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* list of readline stuff supported by editline library's readline wrapper */
|
||||
|
||||
/* typedefs */
|
||||
typedef int Function(const char *, int);
|
||||
typedef void VFunction(void);
|
||||
typedef void VCPFunction(char *);
|
||||
typedef char *CPFunction(const char *, int);
|
||||
typedef char **CPPFunction(const char *, int, int);
|
||||
|
||||
typedef struct _hist_entry {
|
||||
const char *line;
|
||||
const char *data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
#define ISFUNC 0
|
||||
#define ISKMAP 1
|
||||
#define ISMACR 2
|
||||
Function *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
#define KEYMAP_SIZE 256
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
#define control_character_threshold 0x20
|
||||
#define control_character_bit 0x40
|
||||
|
||||
#ifndef CTRL
|
||||
#include <sys/ioctl.h>
|
||||
#if !defined(__sun__) && !defined(__hpux__)
|
||||
#include <sys/ttydefaults.h>
|
||||
#endif
|
||||
#ifndef CTRL
|
||||
#define CTRL(c) ((c) & 037)
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNCTRL
|
||||
#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
|
||||
#endif
|
||||
|
||||
#define RUBOUT 0x7f
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
|
||||
/* global variables used by readline enabled applications */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern const char *rl_library_version;
|
||||
extern char *rl_readline_name;
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
extern char *rl_line_buffer;
|
||||
extern int rl_point, rl_end;
|
||||
extern int history_base, history_length;
|
||||
extern int max_input_history;
|
||||
extern char *rl_basic_word_break_characters;
|
||||
extern char *rl_completer_word_break_characters;
|
||||
extern char *rl_completer_quote_characters;
|
||||
extern Function *rl_completion_entry_function;
|
||||
extern CPPFunction *rl_attempted_completion_function;
|
||||
extern int rl_attempted_completion_over;
|
||||
extern int rl_completion_type;
|
||||
extern int rl_completion_query_items;
|
||||
extern char *rl_special_prefixes;
|
||||
extern int rl_completion_append_character;
|
||||
extern int rl_inhibit_completion;
|
||||
extern Function *rl_pre_input_hook;
|
||||
extern Function *rl_startup_hook;
|
||||
extern char *rl_terminal_name;
|
||||
extern int rl_already_prompted;
|
||||
extern char *rl_prompt;
|
||||
/*
|
||||
* The following is not implemented
|
||||
*/
|
||||
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
|
||||
emacs_meta_keymap,
|
||||
emacs_ctlx_keymap;
|
||||
extern int rl_filename_completion_desired;
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
extern Function *rl_getc_function;
|
||||
extern VFunction *rl_redisplay_function;
|
||||
extern VFunction *rl_completion_display_matches_hook;
|
||||
extern VFunction *rl_prep_term_function;
|
||||
extern VFunction *rl_deprep_term_function;
|
||||
|
||||
/* supported functions */
|
||||
char *readline(const char *);
|
||||
int rl_initialize(void);
|
||||
|
||||
void using_history(void);
|
||||
int add_history(const char *);
|
||||
void clear_history(void);
|
||||
void stifle_history(int);
|
||||
int unstifle_history(void);
|
||||
int history_is_stifled(void);
|
||||
int where_history(void);
|
||||
HIST_ENTRY *current_history(void);
|
||||
HIST_ENTRY *history_get(int);
|
||||
int history_total_bytes(void);
|
||||
int history_set_pos(int);
|
||||
HIST_ENTRY *previous_history(void);
|
||||
HIST_ENTRY *next_history(void);
|
||||
int history_search(const char *, int);
|
||||
int history_search_prefix(const char *, int);
|
||||
int history_search_pos(const char *, int, int);
|
||||
int read_history(const char *);
|
||||
int write_history(const char *);
|
||||
int history_expand(char *, char **);
|
||||
char **history_tokenize(const char *);
|
||||
const char *get_history_event(const char *, int *, int);
|
||||
char *history_arg_extract(int, int, const char *);
|
||||
|
||||
char *tilde_expand(char *);
|
||||
char *filename_completion_function(const char *, int);
|
||||
char *username_completion_function(const char *, int);
|
||||
int rl_complete(int, int);
|
||||
int rl_read_key(void);
|
||||
char **completion_matches(const char *, CPFunction *);
|
||||
void rl_display_match_list(char **, int, int);
|
||||
|
||||
int rl_insert(int, int);
|
||||
void rl_reset_terminal(const char *);
|
||||
int rl_bind_key(int, int (*)(int, int));
|
||||
int rl_newline(int, int);
|
||||
void rl_callback_read_char(void);
|
||||
void rl_callback_handler_install(const char *, VCPFunction *);
|
||||
void rl_callback_handler_remove(void);
|
||||
void rl_redisplay(void);
|
||||
int rl_get_previous_history(int, int);
|
||||
void rl_prep_terminal(int);
|
||||
void rl_deprep_terminal(void);
|
||||
int rl_read_init_file(const char *);
|
||||
int rl_parse_and_bind(const char *);
|
||||
int rl_variable_bind(const char *, const char *);
|
||||
void rl_stuff_char(int);
|
||||
int rl_add_defun(const char *, Function *, int);
|
||||
|
||||
/*
|
||||
* The following are not implemented
|
||||
*/
|
||||
Keymap rl_get_keymap(void);
|
||||
Keymap rl_make_bare_keymap(void);
|
||||
int rl_generic_bind(int, const char *, const char *, Keymap);
|
||||
int rl_bind_key_in_map(int, Function *, Keymap);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _READLINE_H_ */
|
1112
libedit/refresh.c
Normal file
1112
libedit/refresh.c
Normal file
File diff suppressed because it is too large
Load Diff
60
libedit/refresh.h
Normal file
60
libedit/refresh.h
Normal file
@ -0,0 +1,60 @@
|
||||
/* $NetBSD: refresh.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: refresh.h,v 1.5 2003/08/07 16:44:33 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)refresh.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.refresh.h: Screen refresh functions
|
||||
*/
|
||||
#ifndef _h_el_refresh
|
||||
#define _h_el_refresh
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct {
|
||||
coord_t r_cursor; /* Refresh cursor position */
|
||||
int r_oldcv; /* Vertical locations */
|
||||
int r_newcv;
|
||||
} el_refresh_t;
|
||||
|
||||
protected void re_putc(EditLine *, int, int);
|
||||
protected void re_clear_lines(EditLine *);
|
||||
protected void re_clear_display(EditLine *);
|
||||
protected void re_refresh(EditLine *);
|
||||
protected void re_refresh_cursor(EditLine *);
|
||||
protected void re_fastaddc(EditLine *);
|
||||
protected void re_goto_bottom(EditLine *);
|
||||
|
||||
#endif /* _h_el_refresh */
|
623
libedit/search.c
Normal file
623
libedit/search.c
Normal file
@ -0,0 +1,623 @@
|
||||
/* $NetBSD: search.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: search.c,v 1.20 2004/11/04 01:16:03 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* search.c: History and character search functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
/*
|
||||
* Adjust cursor in vi mode to include the character under it
|
||||
*/
|
||||
#define EL_CURSOR(el) \
|
||||
((el)->el_line.cursor + (((el)->el_map.type == MAP_VI) && \
|
||||
((el)->el_map.current == (el)->el_map.alt)))
|
||||
|
||||
/* search_init():
|
||||
* Initialize the search stuff
|
||||
*/
|
||||
protected int
|
||||
search_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_search.patbuf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_search.patbuf == NULL)
|
||||
return (-1);
|
||||
el->el_search.patlen = 0;
|
||||
el->el_search.patdir = -1;
|
||||
el->el_search.chacha = '\0';
|
||||
el->el_search.chadir = CHAR_FWD;
|
||||
el->el_search.chatflg = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* search_end():
|
||||
* Initialize the search stuff
|
||||
*/
|
||||
protected void
|
||||
search_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_search.patbuf);
|
||||
el->el_search.patbuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef REGEXP
|
||||
/* regerror():
|
||||
* Handle regular expression errors
|
||||
*/
|
||||
public void
|
||||
/*ARGSUSED*/
|
||||
regerror(const char *msg)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* el_match():
|
||||
* Return if string matches pattern
|
||||
*/
|
||||
protected int
|
||||
el_match(const char *str, const char *pat)
|
||||
{
|
||||
#if defined (REGEX)
|
||||
regex_t re;
|
||||
int rv;
|
||||
#elif defined (REGEXP)
|
||||
regexp *rp;
|
||||
int rv;
|
||||
#else
|
||||
extern char *re_comp(const char *);
|
||||
extern int re_exec(const char *);
|
||||
#endif
|
||||
|
||||
if (strstr(str, pat) != NULL)
|
||||
return (1);
|
||||
|
||||
#if defined(REGEX)
|
||||
if (regcomp(&re, pat, 0) == 0) {
|
||||
rv = regexec(&re, str, 0, NULL, 0) == 0;
|
||||
regfree(&re);
|
||||
} else {
|
||||
rv = 0;
|
||||
}
|
||||
return (rv);
|
||||
#elif defined(REGEXP)
|
||||
if ((re = regcomp(pat)) != NULL) {
|
||||
rv = regexec(re, str);
|
||||
free((ptr_t) re);
|
||||
} else {
|
||||
rv = 0;
|
||||
}
|
||||
return (rv);
|
||||
#else
|
||||
if (re_comp(pat) != NULL)
|
||||
return (0);
|
||||
else
|
||||
return (re_exec(str) == 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* c_hmatch():
|
||||
* return True if the pattern matches the prefix
|
||||
*/
|
||||
protected int
|
||||
c_hmatch(EditLine *el, const char *str)
|
||||
{
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "match `%s' with `%s'\n",
|
||||
el->el_search.patbuf, str);
|
||||
#endif /* SDEBUG */
|
||||
|
||||
return (el_match(str, el->el_search.patbuf));
|
||||
}
|
||||
|
||||
|
||||
/* c_setpat():
|
||||
* Set the history seatch pattern
|
||||
*/
|
||||
protected void
|
||||
c_setpat(EditLine *el)
|
||||
{
|
||||
if (el->el_state.lastcmd != ED_SEARCH_PREV_HISTORY &&
|
||||
el->el_state.lastcmd != ED_SEARCH_NEXT_HISTORY) {
|
||||
el->el_search.patlen = EL_CURSOR(el) - el->el_line.buffer;
|
||||
if (el->el_search.patlen >= EL_BUFSIZ)
|
||||
el->el_search.patlen = EL_BUFSIZ - 1;
|
||||
if (el->el_search.patlen != 0) {
|
||||
(void) strncpy(el->el_search.patbuf, el->el_line.buffer,
|
||||
el->el_search.patlen);
|
||||
el->el_search.patbuf[el->el_search.patlen] = '\0';
|
||||
} else
|
||||
el->el_search.patlen = strlen(el->el_search.patbuf);
|
||||
}
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "\neventno = %d\n",
|
||||
el->el_history.eventno);
|
||||
(void) fprintf(el->el_errfile, "patlen = %d\n", el->el_search.patlen);
|
||||
(void) fprintf(el->el_errfile, "patbuf = \"%s\"\n",
|
||||
el->el_search.patbuf);
|
||||
(void) fprintf(el->el_errfile, "cursor %d lastchar %d\n",
|
||||
EL_CURSOR(el) - el->el_line.buffer,
|
||||
el->el_line.lastchar - el->el_line.buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* ce_inc_search():
|
||||
* Emacs incremental search
|
||||
*/
|
||||
protected el_action_t
|
||||
ce_inc_search(EditLine *el, int dir)
|
||||
{
|
||||
static const char STRfwd[] = {'f', 'w', 'd', '\0'},
|
||||
STRbck[] = {'b', 'c', 'k', '\0'};
|
||||
static char pchar = ':';/* ':' = normal, '?' = failed */
|
||||
static char endcmd[2] = {'\0', '\0'};
|
||||
char ch, *ocursor = el->el_line.cursor, oldpchar = pchar;
|
||||
const char *cp;
|
||||
|
||||
el_action_t ret = CC_NORM;
|
||||
|
||||
int ohisteventno = el->el_history.eventno;
|
||||
int oldpatlen = el->el_search.patlen;
|
||||
int newdir = dir;
|
||||
int done, redo;
|
||||
|
||||
if (el->el_line.lastchar + sizeof(STRfwd) / sizeof(char) + 2 +
|
||||
el->el_search.patlen >= el->el_line.limit)
|
||||
return (CC_ERROR);
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (el->el_search.patlen == 0) { /* first round */
|
||||
pchar = ':';
|
||||
#ifdef ANCHOR
|
||||
#define LEN 2
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '*';
|
||||
#else
|
||||
#define LEN 0
|
||||
#endif
|
||||
}
|
||||
done = redo = 0;
|
||||
*el->el_line.lastchar++ = '\n';
|
||||
for (cp = (newdir == ED_SEARCH_PREV_HISTORY) ? STRbck : STRfwd;
|
||||
*cp; *el->el_line.lastchar++ = *cp++)
|
||||
continue;
|
||||
*el->el_line.lastchar++ = pchar;
|
||||
for (cp = &el->el_search.patbuf[LEN];
|
||||
cp < &el->el_search.patbuf[el->el_search.patlen];
|
||||
*el->el_line.lastchar++ = *cp++)
|
||||
continue;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
|
||||
if (el_getc(el, &ch) != 1)
|
||||
return (ed_end_of_file(el, 0));
|
||||
|
||||
switch (el->el_map.current[(unsigned char) ch]) {
|
||||
case ED_INSERT:
|
||||
case ED_DIGIT:
|
||||
if (el->el_search.patlen >= EL_BUFSIZ - LEN)
|
||||
term_beep(el);
|
||||
else {
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
ch;
|
||||
*el->el_line.lastchar++ = ch;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
}
|
||||
break;
|
||||
|
||||
case EM_INC_SEARCH_NEXT:
|
||||
newdir = ED_SEARCH_NEXT_HISTORY;
|
||||
redo++;
|
||||
break;
|
||||
|
||||
case EM_INC_SEARCH_PREV:
|
||||
newdir = ED_SEARCH_PREV_HISTORY;
|
||||
redo++;
|
||||
break;
|
||||
|
||||
case EM_DELETE_PREV_CHAR:
|
||||
case ED_DELETE_PREV_CHAR:
|
||||
if (el->el_search.patlen > LEN)
|
||||
done++;
|
||||
else
|
||||
term_beep(el);
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (ch) {
|
||||
case 0007: /* ^G: Abort */
|
||||
ret = CC_ERROR;
|
||||
done++;
|
||||
break;
|
||||
|
||||
case 0027: /* ^W: Append word */
|
||||
/* No can do if globbing characters in pattern */
|
||||
for (cp = &el->el_search.patbuf[LEN];; cp++)
|
||||
if (cp >= &el->el_search.patbuf[
|
||||
el->el_search.patlen]) {
|
||||
el->el_line.cursor +=
|
||||
el->el_search.patlen - LEN - 1;
|
||||
cp = c__next_word(el->el_line.cursor,
|
||||
el->el_line.lastchar, 1,
|
||||
ce__isword);
|
||||
while (el->el_line.cursor < cp &&
|
||||
*el->el_line.cursor != '\n') {
|
||||
if (el->el_search.patlen >=
|
||||
EL_BUFSIZ - LEN) {
|
||||
term_beep(el);
|
||||
break;
|
||||
}
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
*el->el_line.cursor;
|
||||
*el->el_line.lastchar++ =
|
||||
*el->el_line.cursor++;
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
break;
|
||||
} else if (isglob(*cp)) {
|
||||
term_beep(el);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Terminate and execute cmd */
|
||||
endcmd[0] = ch;
|
||||
el_push(el, endcmd);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 0033: /* ESC: Terminate */
|
||||
ret = CC_REFRESH;
|
||||
done++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while (el->el_line.lastchar > el->el_line.buffer &&
|
||||
*el->el_line.lastchar != '\n')
|
||||
*el->el_line.lastchar-- = '\0';
|
||||
*el->el_line.lastchar = '\0';
|
||||
|
||||
if (!done) {
|
||||
|
||||
/* Can't search if unmatched '[' */
|
||||
for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
|
||||
ch = ']';
|
||||
cp >= &el->el_search.patbuf[LEN];
|
||||
cp--)
|
||||
if (*cp == '[' || *cp == ']') {
|
||||
ch = *cp;
|
||||
break;
|
||||
}
|
||||
if (el->el_search.patlen > LEN && ch != '[') {
|
||||
if (redo && newdir == dir) {
|
||||
if (pchar == '?') { /* wrap around */
|
||||
el->el_history.eventno =
|
||||
newdir == ED_SEARCH_PREV_HISTORY ? 0 : 0x7fffffff;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
/* el->el_history.event
|
||||
* no was fixed by
|
||||
* first call */
|
||||
(void) hist_get(el);
|
||||
el->el_line.cursor = newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
el->el_line.lastchar :
|
||||
el->el_line.buffer;
|
||||
} else
|
||||
el->el_line.cursor +=
|
||||
newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
-1 : 1;
|
||||
}
|
||||
#ifdef ANCHOR
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
'.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
'*';
|
||||
#endif
|
||||
el->el_search.patbuf[el->el_search.patlen] =
|
||||
'\0';
|
||||
if (el->el_line.cursor < el->el_line.buffer ||
|
||||
el->el_line.cursor > el->el_line.lastchar ||
|
||||
(ret = ce_search_line(el, newdir))
|
||||
== CC_ERROR) {
|
||||
/* avoid c_setpat */
|
||||
el->el_state.lastcmd =
|
||||
(el_action_t) newdir;
|
||||
ret = newdir == ED_SEARCH_PREV_HISTORY ?
|
||||
ed_search_prev_history(el, 0) :
|
||||
ed_search_next_history(el, 0);
|
||||
if (ret != CC_ERROR) {
|
||||
el->el_line.cursor = newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
el->el_line.lastchar :
|
||||
el->el_line.buffer;
|
||||
(void) ce_search_line(el,
|
||||
newdir);
|
||||
}
|
||||
}
|
||||
el->el_search.patlen -= LEN;
|
||||
el->el_search.patbuf[el->el_search.patlen] =
|
||||
'\0';
|
||||
if (ret == CC_ERROR) {
|
||||
term_beep(el);
|
||||
if (el->el_history.eventno !=
|
||||
ohisteventno) {
|
||||
el->el_history.eventno =
|
||||
ohisteventno;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
pchar = '?';
|
||||
} else {
|
||||
pchar = ':';
|
||||
}
|
||||
}
|
||||
ret = ce_inc_search(el, newdir);
|
||||
|
||||
if (ret == CC_ERROR && pchar == '?' && oldpchar == ':')
|
||||
/*
|
||||
* break abort of failed search at last
|
||||
* non-failed
|
||||
*/
|
||||
ret = CC_NORM;
|
||||
|
||||
}
|
||||
if (ret == CC_NORM || (ret == CC_ERROR && oldpatlen == 0)) {
|
||||
/* restore on normal return or error exit */
|
||||
pchar = oldpchar;
|
||||
el->el_search.patlen = oldpatlen;
|
||||
if (el->el_history.eventno != ohisteventno) {
|
||||
el->el_history.eventno = ohisteventno;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
if (ret == CC_ERROR)
|
||||
re_refresh(el);
|
||||
}
|
||||
if (done || ret != CC_NORM)
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_search():
|
||||
* Vi search.
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_search(EditLine *el, int dir)
|
||||
{
|
||||
char ch;
|
||||
char tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
||||
#ifdef ANCHOR
|
||||
tmpbuf[0] = '.';
|
||||
tmpbuf[1] = '*';
|
||||
#endif
|
||||
tmplen = LEN;
|
||||
|
||||
el->el_search.patdir = dir;
|
||||
|
||||
tmplen = c_gets(el, &tmpbuf[LEN],
|
||||
dir == ED_SEARCH_PREV_HISTORY ? "\n/" : "\n?" );
|
||||
if (tmplen == -1)
|
||||
return CC_REFRESH;
|
||||
|
||||
tmplen += LEN;
|
||||
ch = tmpbuf[tmplen];
|
||||
tmpbuf[tmplen] = '\0';
|
||||
|
||||
if (tmplen == LEN) {
|
||||
/*
|
||||
* Use the old pattern, but wild-card it.
|
||||
*/
|
||||
if (el->el_search.patlen == 0) {
|
||||
re_refresh(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
#ifdef ANCHOR
|
||||
if (el->el_search.patbuf[0] != '.' &&
|
||||
el->el_search.patbuf[0] != '*') {
|
||||
(void) strncpy(tmpbuf, el->el_search.patbuf,
|
||||
sizeof(tmpbuf) - 1);
|
||||
el->el_search.patbuf[0] = '.';
|
||||
el->el_search.patbuf[1] = '*';
|
||||
(void) strncpy(&el->el_search.patbuf[2], tmpbuf,
|
||||
EL_BUFSIZ - 3);
|
||||
el->el_search.patlen++;
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '*';
|
||||
el->el_search.patbuf[el->el_search.patlen] = '\0';
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ANCHOR
|
||||
tmpbuf[tmplen++] = '.';
|
||||
tmpbuf[tmplen++] = '*';
|
||||
#endif
|
||||
tmpbuf[tmplen] = '\0';
|
||||
(void) strncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1);
|
||||
el->el_search.patlen = tmplen;
|
||||
}
|
||||
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
|
||||
el->el_line.cursor = el->el_line.lastchar = el->el_line.buffer;
|
||||
if ((dir == ED_SEARCH_PREV_HISTORY ? ed_search_prev_history(el, 0) :
|
||||
ed_search_next_history(el, 0)) == CC_ERROR) {
|
||||
re_refresh(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
if (ch == 0033) {
|
||||
re_refresh(el);
|
||||
return ed_newline(el, 0);
|
||||
}
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ce_search_line():
|
||||
* Look for a pattern inside a line
|
||||
*/
|
||||
protected el_action_t
|
||||
ce_search_line(EditLine *el, int dir)
|
||||
{
|
||||
char *cp = el->el_line.cursor;
|
||||
char *pattern = el->el_search.patbuf;
|
||||
char oc, *ocp;
|
||||
#ifdef ANCHOR
|
||||
ocp = &pattern[1];
|
||||
oc = *ocp;
|
||||
*ocp = '^';
|
||||
#else
|
||||
ocp = pattern;
|
||||
oc = *ocp;
|
||||
#endif
|
||||
|
||||
if (dir == ED_SEARCH_PREV_HISTORY) {
|
||||
for (; cp >= el->el_line.buffer; cp--) {
|
||||
if (el_match(cp, ocp)) {
|
||||
*ocp = oc;
|
||||
el->el_line.cursor = cp;
|
||||
return (CC_NORM);
|
||||
}
|
||||
}
|
||||
*ocp = oc;
|
||||
return (CC_ERROR);
|
||||
} else {
|
||||
for (; *cp != '\0' && cp < el->el_line.limit; cp++) {
|
||||
if (el_match(cp, ocp)) {
|
||||
*ocp = oc;
|
||||
el->el_line.cursor = cp;
|
||||
return (CC_NORM);
|
||||
}
|
||||
}
|
||||
*ocp = oc;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_repeat_srch():
|
||||
* Vi repeat search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_repeat_srch(EditLine *el, int c)
|
||||
{
|
||||
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "dir %d patlen %d patbuf %s\n",
|
||||
c, el->el_search.patlen, el->el_search.patbuf);
|
||||
#endif
|
||||
|
||||
el->el_state.lastcmd = (el_action_t) c; /* Hack to stop c_setpat */
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
|
||||
switch (c) {
|
||||
case ED_SEARCH_NEXT_HISTORY:
|
||||
return (ed_search_next_history(el, 0));
|
||||
case ED_SEARCH_PREV_HISTORY:
|
||||
return (ed_search_prev_history(el, 0));
|
||||
default:
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_csearch():
|
||||
* Vi character search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_csearch(EditLine *el, int direction, int ch, int count, int tflag)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (ch == 0)
|
||||
return CC_ERROR;
|
||||
|
||||
if (ch == -1) {
|
||||
char c;
|
||||
if (el_getc(el, &c) != 1)
|
||||
return ed_end_of_file(el, 0);
|
||||
ch = c;
|
||||
}
|
||||
|
||||
/* Save for ';' and ',' commands */
|
||||
el->el_search.chacha = ch;
|
||||
el->el_search.chadir = direction;
|
||||
el->el_search.chatflg = tflag;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
while (count--) {
|
||||
if (*cp == ch)
|
||||
cp += direction;
|
||||
for (;;cp += direction) {
|
||||
if (cp >= el->el_line.lastchar)
|
||||
return CC_ERROR;
|
||||
if (cp < el->el_line.buffer)
|
||||
return CC_ERROR;
|
||||
if (*cp == ch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tflag)
|
||||
cp -= direction;
|
||||
|
||||
el->el_line.cursor = cp;
|
||||
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
if (direction > 0)
|
||||
el->el_line.cursor++;
|
||||
cv_delfini(el);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
return CC_CURSOR;
|
||||
}
|
67
libedit/search.h
Normal file
67
libedit/search.h
Normal file
@ -0,0 +1,67 @@
|
||||
/* $NetBSD: search.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: search.h,v 1.8 2003/10/18 23:27:36 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)search.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.search.h: Line and history searching utilities
|
||||
*/
|
||||
#ifndef _h_el_search
|
||||
#define _h_el_search
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct el_search_t {
|
||||
char *patbuf; /* The pattern buffer */
|
||||
size_t patlen; /* Length of the pattern buffer */
|
||||
int patdir; /* Direction of the last search */
|
||||
int chadir; /* Character search direction */
|
||||
char chacha; /* Character we are looking for */
|
||||
char chatflg; /* 0 if f, 1 if t */
|
||||
} el_search_t;
|
||||
|
||||
|
||||
protected int el_match(const char *, const char *);
|
||||
protected int search_init(EditLine *);
|
||||
protected void search_end(EditLine *);
|
||||
protected int c_hmatch(EditLine *, const char *);
|
||||
protected void c_setpat(EditLine *);
|
||||
protected el_action_t ce_inc_search(EditLine *, int);
|
||||
protected el_action_t cv_search(EditLine *, int);
|
||||
protected el_action_t ce_search_line(EditLine *, int);
|
||||
protected el_action_t cv_repeat_srch(EditLine *, int);
|
||||
protected el_action_t cv_csearch(EditLine *, int, int, int, int);
|
||||
|
||||
#endif /* _h_el_search */
|
191
libedit/sig.c
Normal file
191
libedit/sig.c
Normal file
@ -0,0 +1,191 @@
|
||||
/* $NetBSD: sig.c,v 1.6 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: sig.c,v 1.11 2003/08/07 16:44:33 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* sig.c: Signal handling stuff.
|
||||
* our policy is to trap all signals, set a good state
|
||||
* and pass the ball to our caller.
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "src/progressbar.h" /* for xsignal_restart() */
|
||||
|
||||
private EditLine *sel = NULL;
|
||||
|
||||
private const int sighdl[] = {
|
||||
#define _DO(a) (a),
|
||||
ALLSIGS
|
||||
#undef _DO
|
||||
- 1
|
||||
};
|
||||
|
||||
private void sig_handler(int);
|
||||
|
||||
/* sig_handler():
|
||||
* This is the handler called for all signals
|
||||
* XXX: we cannot pass any data so we just store the old editline
|
||||
* state in a private variable
|
||||
*/
|
||||
private void
|
||||
sig_handler(int signo)
|
||||
{
|
||||
int i;
|
||||
sigset_t nset, oset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
(void) sigaddset(&nset, signo);
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
switch (signo) {
|
||||
case SIGCONT:
|
||||
tty_rawmode(sel);
|
||||
if (ed_redisplay(sel, 0) == CC_REFRESH)
|
||||
re_refresh(sel);
|
||||
term__flush();
|
||||
break;
|
||||
|
||||
case SIGWINCH:
|
||||
el_resize(sel);
|
||||
break;
|
||||
|
||||
default:
|
||||
tty_cookedmode(sel);
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; sighdl[i] != -1; i++)
|
||||
if (signo == sighdl[i])
|
||||
break;
|
||||
|
||||
(void) xsignal_restart(signo, sel->el_signal[i], 1);
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
(void) kill(0, signo);
|
||||
}
|
||||
|
||||
|
||||
/* sig_init():
|
||||
* Initialize all signal stuff
|
||||
*/
|
||||
protected int
|
||||
sig_init(EditLine *el)
|
||||
{
|
||||
int i;
|
||||
sigset_t nset, oset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
#define _DO(a) (void) sigaddset(&nset, a);
|
||||
ALLSIGS
|
||||
#undef _DO
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
#define SIGSIZE (sizeof(sighdl) / sizeof(sighdl[0]) * sizeof(el_signalhandler_t))
|
||||
|
||||
el->el_signal = (el_signalhandler_t *) el_malloc(SIGSIZE);
|
||||
if (el->el_signal == NULL)
|
||||
return (-1);
|
||||
for (i = 0; sighdl[i] != -1; i++)
|
||||
el->el_signal[i] = SIG_ERR;
|
||||
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* sig_end():
|
||||
* Clear all signal stuff
|
||||
*/
|
||||
protected void
|
||||
sig_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_signal);
|
||||
el->el_signal = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* sig_set():
|
||||
* set all the signal handlers
|
||||
*/
|
||||
protected void
|
||||
sig_set(EditLine *el)
|
||||
{
|
||||
int i;
|
||||
sigset_t nset, oset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
#define _DO(a) (void) sigaddset(&nset, a);
|
||||
ALLSIGS
|
||||
#undef _DO
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
for (i = 0; sighdl[i] != -1; i++) {
|
||||
el_signalhandler_t s;
|
||||
/* This could happen if we get interrupted */
|
||||
if ((s = xsignal_restart(sighdl[i], sig_handler, 1)) != sig_handler)
|
||||
el->el_signal[i] = s;
|
||||
}
|
||||
sel = el;
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* sig_clr():
|
||||
* clear all the signal handlers
|
||||
*/
|
||||
protected void
|
||||
sig_clr(EditLine *el)
|
||||
{
|
||||
int i;
|
||||
sigset_t nset, oset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
#define _DO(a) (void) sigaddset(&nset, a);
|
||||
ALLSIGS
|
||||
#undef _DO
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
for (i = 0; sighdl[i] != -1; i++)
|
||||
if (el->el_signal[i] != SIG_ERR)
|
||||
(void) xsignal_restart(sighdl[i], el->el_signal[i], 1);
|
||||
|
||||
sel = NULL; /* we are going to die if the handler is
|
||||
* called */
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
}
|
70
libedit/sig.h
Normal file
70
libedit/sig.h
Normal file
@ -0,0 +1,70 @@
|
||||
/* $NetBSD: sig.h,v 1.2 2005/05/11 01:17:39 lukem Exp $ */
|
||||
/* from NetBSD: sig.h,v 1.5 2003/08/07 16:44:33 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)sig.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.sig.h: Signal handling functions
|
||||
*/
|
||||
#ifndef _h_el_sig
|
||||
#define _h_el_sig
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
/*
|
||||
* Define here all the signals we are going to handle
|
||||
* The _DO macro is used to iterate in the source code
|
||||
*/
|
||||
#define ALLSIGS \
|
||||
_DO(SIGINT) \
|
||||
_DO(SIGTSTP) \
|
||||
_DO(SIGSTOP) \
|
||||
_DO(SIGQUIT) \
|
||||
_DO(SIGHUP) \
|
||||
_DO(SIGTERM) \
|
||||
_DO(SIGCONT) \
|
||||
_DO(SIGWINCH)
|
||||
|
||||
typedef void (*el_signalhandler_t)(int);
|
||||
typedef el_signalhandler_t *el_signal_t;
|
||||
|
||||
protected void sig_end(EditLine*);
|
||||
protected int sig_init(EditLine*);
|
||||
protected void sig_set(EditLine*);
|
||||
protected void sig_clr(EditLine*);
|
||||
|
||||
#endif /* _h_el_sig */
|
146
libedit/sys.h
Normal file
146
libedit/sys.h
Normal file
@ -0,0 +1,146 @@
|
||||
/* $NetBSD: sys.h,v 1.4 2005/05/27 04:58:05 lukem Exp $ */
|
||||
/* from NetBSD: sys.h,v 1.9 2004/01/17 17:57:40 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)sys.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* sys.h: Put all the stupid compiler and system dependencies here...
|
||||
*/
|
||||
#ifndef _h_sys
|
||||
#define _h_sys
|
||||
|
||||
#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(A)
|
||||
#endif
|
||||
|
||||
#if __not_for_tnftp
|
||||
#ifndef __BEGIN_DECLS
|
||||
# ifdef __cplusplus
|
||||
# define __BEGIN_DECLS extern "C" {
|
||||
# define __END_DECLS }
|
||||
# else
|
||||
# define __BEGIN_DECLS
|
||||
# define __END_DECLS
|
||||
# endif
|
||||
#endif
|
||||
#endif /* __not_for_tnftp */
|
||||
|
||||
#ifndef public
|
||||
# define public /* Externally visible functions/variables */
|
||||
#endif
|
||||
|
||||
#ifndef private
|
||||
# define private static /* Always hidden internals */
|
||||
#endif
|
||||
|
||||
#ifndef protected
|
||||
# define protected /* Redefined from elsewhere to "static" */
|
||||
/* When we want to hide everything */
|
||||
#endif
|
||||
|
||||
#ifndef _PTR_T
|
||||
# define _PTR_T
|
||||
typedef void *ptr_t;
|
||||
#endif
|
||||
|
||||
#ifndef _IOCTL_T
|
||||
# define _IOCTL_T
|
||||
typedef void *ioctl_t;
|
||||
#endif
|
||||
|
||||
#if __not_for_tnftp
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef HAVE_STRLCAT
|
||||
#define strlcat libedit_strlcat
|
||||
size_t strlcat(char *dst, const char *src, size_t size);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
#define strlcpy libedit_strlcpy
|
||||
size_t strlcpy(char *dst, const char *src, size_t size);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FGETLN
|
||||
#define fgetln libedit_fgetln
|
||||
char *fgetln(FILE *fp, size_t *len);
|
||||
#endif
|
||||
|
||||
#define REGEX /* Use POSIX.2 regular expression functions */
|
||||
#undef REGEXP /* Use UNIX V8 regular expression functions */
|
||||
#endif /* __not_for_tnftp */
|
||||
|
||||
#ifdef notdef
|
||||
# undef REGEX
|
||||
# undef REGEXP
|
||||
# include <malloc.h>
|
||||
# ifdef __GNUC__
|
||||
/*
|
||||
* Broken hdrs.
|
||||
*/
|
||||
extern int tgetent(const char *bp, char *name);
|
||||
extern int tgetflag(const char *id);
|
||||
extern int tgetnum(const char *id);
|
||||
extern char *tgetstr(const char *id, char **area);
|
||||
extern char *tgoto(const char *cap, int col, int row);
|
||||
extern int tputs(const char *str, int affcnt, int (*putc)(int));
|
||||
extern char *getenv(const char *);
|
||||
extern int fprintf(FILE *, const char *, ...);
|
||||
extern int sigsetmask(int);
|
||||
extern int sigblock(int);
|
||||
extern int fputc(int, FILE *);
|
||||
extern int fgetc(FILE *);
|
||||
extern int fflush(FILE *);
|
||||
extern int tolower(int);
|
||||
extern int toupper(int);
|
||||
extern int errno, sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
extern void perror(const char *);
|
||||
# include <string.h>
|
||||
# define strerror(e) sys_errlist[e]
|
||||
# endif
|
||||
# ifdef SABER
|
||||
extern ptr_t memcpy(ptr_t, const ptr_t, size_t);
|
||||
extern ptr_t memset(ptr_t, int, size_t);
|
||||
# endif
|
||||
extern char *fgetline(FILE *, int *);
|
||||
#endif
|
||||
|
||||
#if HAVE_REGEX_H
|
||||
# include <regex.h>
|
||||
# define REGEX
|
||||
#endif
|
||||
|
||||
#endif /* _h_sys */
|
1576
libedit/term.c
Normal file
1576
libedit/term.c
Normal file
File diff suppressed because it is too large
Load Diff
124
libedit/term.h
Normal file
124
libedit/term.h
Normal file
@ -0,0 +1,124 @@
|
||||
/* $NetBSD: term.h,v 1.3 2005/05/31 02:07:02 lukem Exp $ */
|
||||
/* from NetBSD: term.h,v 1.16 2005/03/15 00:10:40 christos Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)term.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.term.h: Termcap header
|
||||
*/
|
||||
#ifndef _h_el_term
|
||||
#define _h_el_term
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct { /* Symbolic function key bindings */
|
||||
const char *name; /* name of the key */
|
||||
int key; /* Index in termcap table */
|
||||
key_value_t fun; /* Function bound to it */
|
||||
int type; /* Type of function */
|
||||
} fkey_t;
|
||||
|
||||
typedef struct {
|
||||
const char *t_name; /* the terminal name */
|
||||
coord_t t_size; /* # lines and cols */
|
||||
int t_flags;
|
||||
#define TERM_CAN_INSERT 0x001 /* Has insert cap */
|
||||
#define TERM_CAN_DELETE 0x002 /* Has delete cap */
|
||||
#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */
|
||||
#define TERM_CAN_TAB 0x008 /* Can use tabs */
|
||||
#define TERM_CAN_ME 0x010 /* Can turn all attrs. */
|
||||
#define TERM_CAN_UP 0x020 /* Can move up */
|
||||
#define TERM_HAS_META 0x040 /* Has a meta key */
|
||||
#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */
|
||||
#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */
|
||||
char *t_buf; /* Termcap buffer */
|
||||
int t_loc; /* location used */
|
||||
char **t_str; /* termcap strings */
|
||||
int *t_val; /* termcap values */
|
||||
char *t_cap; /* Termcap buffer */
|
||||
fkey_t *t_fkey; /* Array of keys */
|
||||
} el_term_t;
|
||||
|
||||
/*
|
||||
* fKey indexes
|
||||
*/
|
||||
#define A_K_DN 0
|
||||
#define A_K_UP 1
|
||||
#define A_K_LT 2
|
||||
#define A_K_RT 3
|
||||
#define A_K_HO 4
|
||||
#define A_K_EN 5
|
||||
#define A_K_NKEYS 6
|
||||
|
||||
protected void term_move_to_line(EditLine *, int);
|
||||
protected void term_move_to_char(EditLine *, int);
|
||||
protected void term_clear_EOL(EditLine *, int);
|
||||
protected void term_overwrite(EditLine *, const char *, int);
|
||||
protected void term_insertwrite(EditLine *, char *, int);
|
||||
protected void term_deletechars(EditLine *, int);
|
||||
protected void term_clear_screen(EditLine *);
|
||||
protected void term_beep(EditLine *);
|
||||
protected int term_change_size(EditLine *, int, int);
|
||||
protected int term_get_size(EditLine *, int *, int *);
|
||||
protected int term_init(EditLine *);
|
||||
protected void term_bind_arrow(EditLine *);
|
||||
protected void term_print_arrow(EditLine *, const char *);
|
||||
protected int term_clear_arrow(EditLine *, const char *);
|
||||
protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
|
||||
protected void term_end(EditLine *);
|
||||
protected void term_get(EditLine *, const char **);
|
||||
protected int term_set(EditLine *, const char *);
|
||||
protected int term_settc(EditLine *, int, const char **);
|
||||
protected int term_telltc(EditLine *, int, const char **);
|
||||
protected int term_echotc(EditLine *, int, const char **);
|
||||
protected int term__putc(int);
|
||||
protected void term__flush(void);
|
||||
|
||||
/*
|
||||
* Easy access macros
|
||||
*/
|
||||
#define EL_FLAGS (el)->el_term.t_flags
|
||||
|
||||
#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT)
|
||||
#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE)
|
||||
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
|
||||
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
|
||||
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
|
||||
#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP)
|
||||
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
|
||||
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
|
||||
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
|
||||
|
||||
#endif /* _h_el_term */
|
442
libedit/tokenizer.c
Normal file
442
libedit/tokenizer.c
Normal file
@ -0,0 +1,442 @@
|
||||
/* $NetBSD: tokenizer.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */
|
||||
/* from NetBSD: tokenizer.c,v 1.14 2003/12/05 13:37:48 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
#include "sys.h"
|
||||
|
||||
/*
|
||||
* tokenize.c: Bourne shell like tokenizer
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "histedit.h"
|
||||
|
||||
typedef enum {
|
||||
Q_none, Q_single, Q_double, Q_one, Q_doubleone
|
||||
} quote_t;
|
||||
|
||||
#define IFS "\t \n"
|
||||
|
||||
#define TOK_KEEP 1
|
||||
#define TOK_EAT 2
|
||||
|
||||
#define WINCR 20
|
||||
#define AINCR 10
|
||||
|
||||
#define tok_strdup(a) strdup(a)
|
||||
#define tok_malloc(a) malloc(a)
|
||||
#define tok_free(a) free(a)
|
||||
#define tok_realloc(a, b) realloc(a, b)
|
||||
|
||||
|
||||
struct tokenizer {
|
||||
char *ifs; /* In field separator */
|
||||
int argc, amax; /* Current and maximum number of args */
|
||||
char **argv; /* Argument list */
|
||||
char *wptr, *wmax; /* Space and limit on the word buffer */
|
||||
char *wstart; /* Beginning of next word */
|
||||
char *wspace; /* Space of word buffer */
|
||||
quote_t quote; /* Quoting state */
|
||||
int flags; /* flags; */
|
||||
};
|
||||
|
||||
|
||||
private void tok_finish(Tokenizer *);
|
||||
|
||||
|
||||
/* tok_finish():
|
||||
* Finish a word in the tokenizer.
|
||||
*/
|
||||
private void
|
||||
tok_finish(Tokenizer *tok)
|
||||
{
|
||||
|
||||
*tok->wptr = '\0';
|
||||
if ((tok->flags & TOK_KEEP) || tok->wptr != tok->wstart) {
|
||||
tok->argv[tok->argc++] = tok->wstart;
|
||||
tok->argv[tok->argc] = NULL;
|
||||
tok->wstart = ++tok->wptr;
|
||||
}
|
||||
tok->flags &= ~TOK_KEEP;
|
||||
}
|
||||
|
||||
|
||||
/* tok_init():
|
||||
* Initialize the tokenizer
|
||||
*/
|
||||
public Tokenizer *
|
||||
tok_init(const char *ifs)
|
||||
{
|
||||
Tokenizer *tok = (Tokenizer *) tok_malloc(sizeof(Tokenizer));
|
||||
|
||||
if (tok == NULL)
|
||||
return NULL;
|
||||
tok->ifs = tok_strdup(ifs ? ifs : IFS);
|
||||
if (tok->ifs == NULL) {
|
||||
tok_free((ptr_t)tok);
|
||||
return NULL;
|
||||
}
|
||||
tok->argc = 0;
|
||||
tok->amax = AINCR;
|
||||
tok->argv = (char **) tok_malloc(sizeof(char *) * tok->amax);
|
||||
if (tok->argv == NULL) {
|
||||
tok_free((ptr_t)tok->ifs);
|
||||
tok_free((ptr_t)tok);
|
||||
return NULL;
|
||||
}
|
||||
tok->argv[0] = NULL;
|
||||
tok->wspace = (char *) tok_malloc(WINCR);
|
||||
if (tok->wspace == NULL) {
|
||||
tok_free((ptr_t)tok->argv);
|
||||
tok_free((ptr_t)tok->ifs);
|
||||
tok_free((ptr_t)tok);
|
||||
return NULL;
|
||||
}
|
||||
tok->wmax = tok->wspace + WINCR;
|
||||
tok->wstart = tok->wspace;
|
||||
tok->wptr = tok->wspace;
|
||||
tok->flags = 0;
|
||||
tok->quote = Q_none;
|
||||
|
||||
return (tok);
|
||||
}
|
||||
|
||||
|
||||
/* tok_reset():
|
||||
* Reset the tokenizer
|
||||
*/
|
||||
public void
|
||||
tok_reset(Tokenizer *tok)
|
||||
{
|
||||
|
||||
tok->argc = 0;
|
||||
tok->wstart = tok->wspace;
|
||||
tok->wptr = tok->wspace;
|
||||
tok->flags = 0;
|
||||
tok->quote = Q_none;
|
||||
}
|
||||
|
||||
|
||||
/* tok_end():
|
||||
* Clean up
|
||||
*/
|
||||
public void
|
||||
tok_end(Tokenizer *tok)
|
||||
{
|
||||
|
||||
tok_free((ptr_t) tok->ifs);
|
||||
tok_free((ptr_t) tok->wspace);
|
||||
tok_free((ptr_t) tok->argv);
|
||||
tok_free((ptr_t) tok);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* tok_line():
|
||||
* Bourne shell (sh(1)) like tokenizing
|
||||
* Arguments:
|
||||
* tok current tokenizer state (setup with tok_init())
|
||||
* line line to parse
|
||||
* Returns:
|
||||
* -1 Internal error
|
||||
* 3 Quoted return
|
||||
* 2 Unmatched double quote
|
||||
* 1 Unmatched single quote
|
||||
* 0 Ok
|
||||
* Modifies (if return value is 0):
|
||||
* argc number of arguments
|
||||
* argv argument array
|
||||
* cursorc if !NULL, argv element containing cursor
|
||||
* cursorv if !NULL, offset in argv[cursorc] of cursor
|
||||
*/
|
||||
public int
|
||||
tok_line(Tokenizer *tok, const LineInfo *line,
|
||||
int *argc, const char ***argv, int *cursorc, int *cursoro)
|
||||
{
|
||||
const char *ptr;
|
||||
int cc, co;
|
||||
|
||||
cc = co = -1;
|
||||
ptr = line->buffer;
|
||||
for (ptr = line->buffer; ;ptr++) {
|
||||
if (ptr >= line->lastchar)
|
||||
ptr = "";
|
||||
if (ptr == line->cursor) {
|
||||
cc = tok->argc;
|
||||
co = tok->wptr - tok->wstart;
|
||||
}
|
||||
switch (*ptr) {
|
||||
case '\'':
|
||||
tok->flags |= TOK_KEEP;
|
||||
tok->flags &= ~TOK_EAT;
|
||||
switch (tok->quote) {
|
||||
case Q_none:
|
||||
tok->quote = Q_single; /* Enter single quote
|
||||
* mode */
|
||||
break;
|
||||
|
||||
case Q_single: /* Exit single quote mode */
|
||||
tok->quote = Q_none;
|
||||
break;
|
||||
|
||||
case Q_one: /* Quote this ' */
|
||||
tok->quote = Q_none;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_double: /* Stay in double quote mode */
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_doubleone: /* Quote this ' */
|
||||
tok->quote = Q_double;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case '"':
|
||||
tok->flags &= ~TOK_EAT;
|
||||
tok->flags |= TOK_KEEP;
|
||||
switch (tok->quote) {
|
||||
case Q_none: /* Enter double quote mode */
|
||||
tok->quote = Q_double;
|
||||
break;
|
||||
|
||||
case Q_double: /* Exit double quote mode */
|
||||
tok->quote = Q_none;
|
||||
break;
|
||||
|
||||
case Q_one: /* Quote this " */
|
||||
tok->quote = Q_none;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_single: /* Stay in single quote mode */
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_doubleone: /* Quote this " */
|
||||
tok->quote = Q_double;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
tok->flags |= TOK_KEEP;
|
||||
tok->flags &= ~TOK_EAT;
|
||||
switch (tok->quote) {
|
||||
case Q_none: /* Quote next character */
|
||||
tok->quote = Q_one;
|
||||
break;
|
||||
|
||||
case Q_double: /* Quote next character */
|
||||
tok->quote = Q_doubleone;
|
||||
break;
|
||||
|
||||
case Q_one: /* Quote this, restore state */
|
||||
*tok->wptr++ = *ptr;
|
||||
tok->quote = Q_none;
|
||||
break;
|
||||
|
||||
case Q_single: /* Stay in single quote mode */
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_doubleone: /* Quote this \ */
|
||||
tok->quote = Q_double;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
tok->flags &= ~TOK_EAT;
|
||||
switch (tok->quote) {
|
||||
case Q_none:
|
||||
goto tok_line_outok;
|
||||
|
||||
case Q_single:
|
||||
case Q_double:
|
||||
*tok->wptr++ = *ptr; /* Add the return */
|
||||
break;
|
||||
|
||||
case Q_doubleone: /* Back to double, eat the '\n' */
|
||||
tok->flags |= TOK_EAT;
|
||||
tok->quote = Q_double;
|
||||
break;
|
||||
|
||||
case Q_one: /* No quote, more eat the '\n' */
|
||||
tok->flags |= TOK_EAT;
|
||||
tok->quote = Q_none;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
switch (tok->quote) {
|
||||
case Q_none:
|
||||
/* Finish word and return */
|
||||
if (tok->flags & TOK_EAT) {
|
||||
tok->flags &= ~TOK_EAT;
|
||||
return (3);
|
||||
}
|
||||
goto tok_line_outok;
|
||||
|
||||
case Q_single:
|
||||
return (1);
|
||||
|
||||
case Q_double:
|
||||
return (2);
|
||||
|
||||
case Q_doubleone:
|
||||
tok->quote = Q_double;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_one:
|
||||
tok->quote = Q_none;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
tok->flags &= ~TOK_EAT;
|
||||
switch (tok->quote) {
|
||||
case Q_none:
|
||||
if (strchr(tok->ifs, *ptr) != NULL)
|
||||
tok_finish(tok);
|
||||
else
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_single:
|
||||
case Q_double:
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
|
||||
case Q_doubleone:
|
||||
*tok->wptr++ = '\\';
|
||||
tok->quote = Q_double;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
case Q_one:
|
||||
tok->quote = Q_none;
|
||||
*tok->wptr++ = *ptr;
|
||||
break;
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (tok->wptr >= tok->wmax - 4) {
|
||||
size_t size = tok->wmax - tok->wspace + WINCR;
|
||||
char *s = (char *) tok_realloc(tok->wspace, size);
|
||||
if (s == NULL)
|
||||
return (-1);
|
||||
|
||||
if (s != tok->wspace) {
|
||||
int i;
|
||||
for (i = 0; i < tok->argc; i++) {
|
||||
tok->argv[i] =
|
||||
(tok->argv[i] - tok->wspace) + s;
|
||||
}
|
||||
tok->wptr = (tok->wptr - tok->wspace) + s;
|
||||
tok->wstart = (tok->wstart - tok->wspace) + s;
|
||||
tok->wspace = s;
|
||||
}
|
||||
tok->wmax = s + size;
|
||||
}
|
||||
if (tok->argc >= tok->amax - 4) {
|
||||
char **p;
|
||||
tok->amax += AINCR;
|
||||
p = (char **) tok_realloc(tok->argv,
|
||||
tok->amax * sizeof(char *));
|
||||
if (p == NULL)
|
||||
return (-1);
|
||||
tok->argv = p;
|
||||
}
|
||||
}
|
||||
tok_line_outok:
|
||||
if (cc == -1 && co == -1) {
|
||||
cc = tok->argc;
|
||||
co = tok->wptr - tok->wstart;
|
||||
}
|
||||
if (cursorc != NULL)
|
||||
*cursorc = cc;
|
||||
if (cursoro != NULL)
|
||||
*cursoro = co;
|
||||
tok_finish(tok);
|
||||
*argv = (const char **)tok->argv;
|
||||
*argc = tok->argc;
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* tok_str():
|
||||
* Simpler version of tok_line, taking a NUL terminated line
|
||||
* and splitting into words, ignoring cursor state.
|
||||
*/
|
||||
public int
|
||||
tok_str(Tokenizer *tok, const char *line, int *argc, const char ***argv)
|
||||
{
|
||||
LineInfo li;
|
||||
|
||||
memset(&li, 0, sizeof(li));
|
||||
li.buffer = line;
|
||||
li.cursor = li.lastchar = strchr(line, '\0');
|
||||
return (tok_line(tok, &li, argc, argv, NULL, NULL));
|
||||
}
|
1300
libedit/tty.c
Normal file
1300
libedit/tty.c
Normal file
File diff suppressed because it is too large
Load Diff
481
libedit/tty.h
Normal file
481
libedit/tty.h
Normal file
@ -0,0 +1,481 @@
|
||||
/* $NetBSD: tty.h,v 1.3 2005/06/01 11:42:24 lukem Exp $ */
|
||||
/* from NetBSD: tty.h,v 1.10 2003/08/07 16:44:34 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)tty.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.tty.h: Local terminal header
|
||||
*/
|
||||
#ifndef _h_el_tty
|
||||
#define _h_el_tty
|
||||
|
||||
#include "histedit.h"
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Define our own since everyone gets it wrong! */
|
||||
#define CONTROL(A) ((A) & 037)
|
||||
|
||||
/*
|
||||
* Aix compatible names
|
||||
*/
|
||||
# if defined(VWERSE) && !defined(VWERASE)
|
||||
# define VWERASE VWERSE
|
||||
# endif /* VWERSE && !VWERASE */
|
||||
|
||||
# if defined(VDISCRD) && !defined(VDISCARD)
|
||||
# define VDISCARD VDISCRD
|
||||
# endif /* VDISCRD && !VDISCARD */
|
||||
|
||||
# if defined(VFLUSHO) && !defined(VDISCARD)
|
||||
# define VDISCARD VFLUSHO
|
||||
# endif /* VFLUSHO && VDISCARD */
|
||||
|
||||
# if defined(VSTRT) && !defined(VSTART)
|
||||
# define VSTART VSTRT
|
||||
# endif /* VSTRT && ! VSTART */
|
||||
|
||||
# if defined(VSTAT) && !defined(VSTATUS)
|
||||
# define VSTATUS VSTAT
|
||||
# endif /* VSTAT && ! VSTATUS */
|
||||
|
||||
# ifndef ONLRET
|
||||
# define ONLRET 0
|
||||
# endif /* ONLRET */
|
||||
|
||||
# ifndef TAB3
|
||||
# ifdef OXTABS
|
||||
# define TAB3 OXTABS
|
||||
# else
|
||||
# define TAB3 0
|
||||
# endif /* OXTABS */
|
||||
# endif /* !TAB3 */
|
||||
|
||||
# if defined(OXTABS) && !defined(XTABS)
|
||||
# define XTABS OXTABS
|
||||
# endif /* OXTABS && !XTABS */
|
||||
|
||||
# ifndef ONLCR
|
||||
# define ONLCR 0
|
||||
# endif /* ONLCR */
|
||||
|
||||
# ifndef IEXTEN
|
||||
# define IEXTEN 0
|
||||
# endif /* IEXTEN */
|
||||
|
||||
# ifndef ECHOCTL
|
||||
# define ECHOCTL 0
|
||||
# endif /* ECHOCTL */
|
||||
|
||||
# ifndef PARENB
|
||||
# define PARENB 0
|
||||
# endif /* PARENB */
|
||||
|
||||
# ifndef EXTPROC
|
||||
# define EXTPROC 0
|
||||
# endif /* EXTPROC */
|
||||
|
||||
# ifndef FLUSHO
|
||||
# define FLUSHO 0
|
||||
# endif /* FLUSHO */
|
||||
|
||||
|
||||
# if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
|
||||
# define _POSIX_VDISABLE VDISABLE
|
||||
# endif /* VDISABLE && ! _POSIX_VDISABLE */
|
||||
|
||||
/*
|
||||
* Work around ISC's definition of IEXTEN which is
|
||||
* XCASE!
|
||||
*/
|
||||
# ifdef ISC
|
||||
# if defined(IEXTEN) && defined(XCASE)
|
||||
# if IEXTEN == XCASE
|
||||
# undef IEXTEN
|
||||
# define IEXTEN 0
|
||||
# endif /* IEXTEN == XCASE */
|
||||
# endif /* IEXTEN && XCASE */
|
||||
# if defined(IEXTEN) && !defined(XCASE)
|
||||
# define XCASE IEXTEN
|
||||
# undef IEXTEN
|
||||
# define IEXTEN 0
|
||||
# endif /* IEXTEN && !XCASE */
|
||||
# endif /* ISC */
|
||||
|
||||
/*
|
||||
* Work around convex weirdness where turning off IEXTEN makes us
|
||||
* lose all postprocessing!
|
||||
*/
|
||||
#if defined(convex) || defined(__convex__)
|
||||
# if defined(IEXTEN) && IEXTEN != 0
|
||||
# undef IEXTEN
|
||||
# define IEXTEN 0
|
||||
# endif /* IEXTEN != 0 */
|
||||
#endif /* convex || __convex__ */
|
||||
|
||||
/*
|
||||
* So that we don't lose job control.
|
||||
*/
|
||||
#ifdef __SVR4
|
||||
# undef CSWTCH
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_VDISABLE
|
||||
# define _POSIX_VDISABLE ((unsigned char) -1)
|
||||
#endif /* _POSIX_VDISABLE */
|
||||
|
||||
#if !defined(CREPRINT) && defined(CRPRNT)
|
||||
# define CREPRINT CRPRNT
|
||||
#endif /* !CREPRINT && CRPRNT */
|
||||
#if !defined(CDISCARD) && defined(CFLUSH)
|
||||
# define CDISCARD CFLUSH
|
||||
#endif /* !CDISCARD && CFLUSH */
|
||||
|
||||
#ifndef CINTR
|
||||
# define CINTR CONTROL('c')
|
||||
#endif /* CINTR */
|
||||
#ifndef CQUIT
|
||||
# define CQUIT 034 /* ^\ */
|
||||
#endif /* CQUIT */
|
||||
#ifndef CERASE
|
||||
# define CERASE 0177 /* ^? */
|
||||
#endif /* CERASE */
|
||||
#ifndef CKILL
|
||||
# define CKILL CONTROL('u')
|
||||
#endif /* CKILL */
|
||||
#ifndef CEOF
|
||||
# define CEOF CONTROL('d')
|
||||
#endif /* CEOF */
|
||||
#ifndef CEOL
|
||||
# define CEOL _POSIX_VDISABLE
|
||||
#endif /* CEOL */
|
||||
#ifndef CEOL2
|
||||
# define CEOL2 _POSIX_VDISABLE
|
||||
#endif /* CEOL2 */
|
||||
#ifndef CSWTCH
|
||||
# define CSWTCH _POSIX_VDISABLE
|
||||
#endif /* CSWTCH */
|
||||
#ifndef CDSWTCH
|
||||
# define CDSWTCH _POSIX_VDISABLE
|
||||
#endif /* CDSWTCH */
|
||||
#ifndef CERASE2
|
||||
# define CERASE2 _POSIX_VDISABLE
|
||||
#endif /* CERASE2 */
|
||||
#ifndef CSTART
|
||||
# define CSTART CONTROL('q')
|
||||
#endif /* CSTART */
|
||||
#ifndef CSTOP
|
||||
# define CSTOP CONTROL('s')
|
||||
#endif /* CSTOP */
|
||||
#ifndef CSUSP
|
||||
# define CSUSP CONTROL('z')
|
||||
#endif /* CSUSP */
|
||||
#ifndef CDSUSP
|
||||
# define CDSUSP CONTROL('y')
|
||||
#endif /* CDSUSP */
|
||||
|
||||
#ifdef hpux
|
||||
|
||||
# ifndef CREPRINT
|
||||
# define CREPRINT _POSIX_VDISABLE
|
||||
# endif /* CREPRINT */
|
||||
# ifndef CDISCARD
|
||||
# define CDISCARD _POSIX_VDISABLE
|
||||
# endif /* CDISCARD */
|
||||
# ifndef CLNEXT
|
||||
# define CLNEXT _POSIX_VDISABLE
|
||||
# endif /* CLNEXT */
|
||||
# ifndef CWERASE
|
||||
# define CWERASE _POSIX_VDISABLE
|
||||
# endif /* CWERASE */
|
||||
|
||||
#else /* !hpux */
|
||||
|
||||
# ifndef CREPRINT
|
||||
# define CREPRINT CONTROL('r')
|
||||
# endif /* CREPRINT */
|
||||
# ifndef CDISCARD
|
||||
# define CDISCARD CONTROL('o')
|
||||
# endif /* CDISCARD */
|
||||
# ifndef CLNEXT
|
||||
# define CLNEXT CONTROL('v')
|
||||
# endif /* CLNEXT */
|
||||
# ifndef CWERASE
|
||||
# define CWERASE CONTROL('w')
|
||||
# endif /* CWERASE */
|
||||
|
||||
#endif /* hpux */
|
||||
|
||||
#ifndef CSTATUS
|
||||
# define CSTATUS CONTROL('t')
|
||||
#endif /* CSTATUS */
|
||||
#ifndef CPAGE
|
||||
# define CPAGE ' '
|
||||
#endif /* CPAGE */
|
||||
#ifndef CPGOFF
|
||||
# define CPGOFF CONTROL('m')
|
||||
#endif /* CPGOFF */
|
||||
#ifndef CKILL2
|
||||
# define CKILL2 _POSIX_VDISABLE
|
||||
#endif /* CKILL2 */
|
||||
#ifndef CBRK
|
||||
# ifndef masscomp
|
||||
# define CBRK 0377
|
||||
# else
|
||||
# define CBRK '\0'
|
||||
# endif /* masscomp */
|
||||
#endif /* CBRK */
|
||||
#ifndef CMIN
|
||||
# define CMIN CEOF
|
||||
#endif /* CMIN */
|
||||
#ifndef CTIME
|
||||
# define CTIME CEOL
|
||||
#endif /* CTIME */
|
||||
|
||||
/*
|
||||
* Fix for sun inconsistency. On termio VSUSP and the rest of the
|
||||
* ttychars > NCC are defined. So we undefine them.
|
||||
*/
|
||||
#if defined(TERMIO) || defined(POSIX)
|
||||
# if defined(POSIX) && defined(NCCS)
|
||||
# define NUMCC NCCS
|
||||
# else
|
||||
# ifdef NCC
|
||||
# define NUMCC NCC
|
||||
# endif /* NCC */
|
||||
# endif /* POSIX && NCCS */
|
||||
# ifdef NUMCC
|
||||
# ifdef VINTR
|
||||
# if NUMCC <= VINTR
|
||||
# undef VINTR
|
||||
# endif /* NUMCC <= VINTR */
|
||||
# endif /* VINTR */
|
||||
# ifdef VQUIT
|
||||
# if NUMCC <= VQUIT
|
||||
# undef VQUIT
|
||||
# endif /* NUMCC <= VQUIT */
|
||||
# endif /* VQUIT */
|
||||
# ifdef VERASE
|
||||
# if NUMCC <= VERASE
|
||||
# undef VERASE
|
||||
# endif /* NUMCC <= VERASE */
|
||||
# endif /* VERASE */
|
||||
# ifdef VKILL
|
||||
# if NUMCC <= VKILL
|
||||
# undef VKILL
|
||||
# endif /* NUMCC <= VKILL */
|
||||
# endif /* VKILL */
|
||||
# ifdef VEOF
|
||||
# if NUMCC <= VEOF
|
||||
# undef VEOF
|
||||
# endif /* NUMCC <= VEOF */
|
||||
# endif /* VEOF */
|
||||
# ifdef VEOL
|
||||
# if NUMCC <= VEOL
|
||||
# undef VEOL
|
||||
# endif /* NUMCC <= VEOL */
|
||||
# endif /* VEOL */
|
||||
# ifdef VEOL2
|
||||
# if NUMCC <= VEOL2
|
||||
# undef VEOL2
|
||||
# endif /* NUMCC <= VEOL2 */
|
||||
# endif /* VEOL2 */
|
||||
# ifdef VSWTCH
|
||||
# if NUMCC <= VSWTCH
|
||||
# undef VSWTCH
|
||||
# endif /* NUMCC <= VSWTCH */
|
||||
# endif /* VSWTCH */
|
||||
# ifdef VDSWTCH
|
||||
# if NUMCC <= VDSWTCH
|
||||
# undef VDSWTCH
|
||||
# endif /* NUMCC <= VDSWTCH */
|
||||
# endif /* VDSWTCH */
|
||||
# ifdef VERASE2
|
||||
# if NUMCC <= VERASE2
|
||||
# undef VERASE2
|
||||
# endif /* NUMCC <= VERASE2 */
|
||||
# endif /* VERASE2 */
|
||||
# ifdef VSTART
|
||||
# if NUMCC <= VSTART
|
||||
# undef VSTART
|
||||
# endif /* NUMCC <= VSTART */
|
||||
# endif /* VSTART */
|
||||
# ifdef VSTOP
|
||||
# if NUMCC <= VSTOP
|
||||
# undef VSTOP
|
||||
# endif /* NUMCC <= VSTOP */
|
||||
# endif /* VSTOP */
|
||||
# ifdef VWERASE
|
||||
# if NUMCC <= VWERASE
|
||||
# undef VWERASE
|
||||
# endif /* NUMCC <= VWERASE */
|
||||
# endif /* VWERASE */
|
||||
# ifdef VSUSP
|
||||
# if NUMCC <= VSUSP
|
||||
# undef VSUSP
|
||||
# endif /* NUMCC <= VSUSP */
|
||||
# endif /* VSUSP */
|
||||
# ifdef VDSUSP
|
||||
# if NUMCC <= VDSUSP
|
||||
# undef VDSUSP
|
||||
# endif /* NUMCC <= VDSUSP */
|
||||
# endif /* VDSUSP */
|
||||
# ifdef VREPRINT
|
||||
# if NUMCC <= VREPRINT
|
||||
# undef VREPRINT
|
||||
# endif /* NUMCC <= VREPRINT */
|
||||
# endif /* VREPRINT */
|
||||
# ifdef VDISCARD
|
||||
# if NUMCC <= VDISCARD
|
||||
# undef VDISCARD
|
||||
# endif /* NUMCC <= VDISCARD */
|
||||
# endif /* VDISCARD */
|
||||
# ifdef VLNEXT
|
||||
# if NUMCC <= VLNEXT
|
||||
# undef VLNEXT
|
||||
# endif /* NUMCC <= VLNEXT */
|
||||
# endif /* VLNEXT */
|
||||
# ifdef VSTATUS
|
||||
# if NUMCC <= VSTATUS
|
||||
# undef VSTATUS
|
||||
# endif /* NUMCC <= VSTATUS */
|
||||
# endif /* VSTATUS */
|
||||
# ifdef VPAGE
|
||||
# if NUMCC <= VPAGE
|
||||
# undef VPAGE
|
||||
# endif /* NUMCC <= VPAGE */
|
||||
# endif /* VPAGE */
|
||||
# ifdef VPGOFF
|
||||
# if NUMCC <= VPGOFF
|
||||
# undef VPGOFF
|
||||
# endif /* NUMCC <= VPGOFF */
|
||||
# endif /* VPGOFF */
|
||||
# ifdef VKILL2
|
||||
# if NUMCC <= VKILL2
|
||||
# undef VKILL2
|
||||
# endif /* NUMCC <= VKILL2 */
|
||||
# endif /* VKILL2 */
|
||||
# ifdef VBRK
|
||||
# if NUMCC <= VBRK
|
||||
# undef VBRK
|
||||
# endif /* NUMCC <= VBRK */
|
||||
# endif /* VBRK */
|
||||
# ifdef VMIN
|
||||
# if NUMCC <= VMIN
|
||||
# undef VMIN
|
||||
# endif /* NUMCC <= VMIN */
|
||||
# endif /* VMIN */
|
||||
# ifdef VTIME
|
||||
# if NUMCC <= VTIME
|
||||
# undef VTIME
|
||||
# endif /* NUMCC <= VTIME */
|
||||
# endif /* VTIME */
|
||||
# endif /* NUMCC */
|
||||
#endif /* !POSIX */
|
||||
|
||||
#define C_INTR 0
|
||||
#define C_QUIT 1
|
||||
#define C_ERASE 2
|
||||
#define C_KILL 3
|
||||
#define C_EOF 4
|
||||
#define C_EOL 5
|
||||
#define C_EOL2 6
|
||||
#define C_SWTCH 7
|
||||
#define C_DSWTCH 8
|
||||
#define C_ERASE2 9
|
||||
#define C_START 10
|
||||
#define C_STOP 11
|
||||
#define C_WERASE 12
|
||||
#define C_SUSP 13
|
||||
#define C_DSUSP 14
|
||||
#define C_REPRINT 15
|
||||
#define C_DISCARD 16
|
||||
#define C_LNEXT 17
|
||||
#define C_STATUS 18
|
||||
#define C_PAGE 19
|
||||
#define C_PGOFF 20
|
||||
#define C_KILL2 21
|
||||
#define C_BRK 22
|
||||
#define C_MIN 23
|
||||
#define C_TIME 24
|
||||
#define C_NCC 25
|
||||
#define C_SH(A) (1 << (A))
|
||||
|
||||
/*
|
||||
* Terminal dependend data structures
|
||||
*/
|
||||
#define EX_IO 0 /* while we are executing */
|
||||
#define ED_IO 1 /* while we are editing */
|
||||
#define TS_IO 2 /* new mode from terminal */
|
||||
#define QU_IO 2 /* used only for quoted chars */
|
||||
#define NN_IO 3 /* The number of entries */
|
||||
|
||||
#define MD_INP 0
|
||||
#define MD_OUT 1
|
||||
#define MD_CTL 2
|
||||
#define MD_LIN 3
|
||||
#define MD_CHAR 4
|
||||
#define MD_NN 5
|
||||
|
||||
typedef struct {
|
||||
const char *t_name;
|
||||
unsigned int t_setmask;
|
||||
unsigned int t_clrmask;
|
||||
} ttyperm_t[NN_IO][MD_NN];
|
||||
|
||||
typedef unsigned char ttychar_t[NN_IO][C_NCC];
|
||||
|
||||
protected int tty_init(EditLine *);
|
||||
protected void tty_end(EditLine *);
|
||||
protected int tty_stty(EditLine *, int, const char **);
|
||||
protected int tty_rawmode(EditLine *);
|
||||
protected int tty_cookedmode(EditLine *);
|
||||
protected int tty_quotemode(EditLine *);
|
||||
protected int tty_noquotemode(EditLine *);
|
||||
protected void tty_bind_char(EditLine *, int);
|
||||
|
||||
typedef struct {
|
||||
ttyperm_t t_t;
|
||||
ttychar_t t_c;
|
||||
struct termios t_ex, t_ed, t_ts;
|
||||
int t_tabs;
|
||||
int t_eight;
|
||||
speed_t t_speed;
|
||||
int t_mode;
|
||||
unsigned char t_vdisable;
|
||||
} el_tty_t;
|
||||
|
||||
|
||||
#endif /* _h_el_tty */
|
1115
libedit/vi.c
Normal file
1115
libedit/vi.c
Normal file
File diff suppressed because it is too large
Load Diff
18
libnetbsd/Makefile.am
Normal file
18
libnetbsd/Makefile.am
Normal file
@ -0,0 +1,18 @@
|
||||
## $NetBSD: Makefile.am,v 1.2 2010/01/04 06:24:20 lukem Exp $
|
||||
|
||||
noinst_LTLIBRARIES = libnetbsd.la
|
||||
|
||||
libnetbsd_la_SOURCES =
|
||||
|
||||
|
||||
CPPFLAGS = \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)
|
||||
|
||||
libnetbsd_la_LIBADD = $(LTLIBOBJS)
|
||||
|
||||
EXTRA_DIST = \
|
||||
fseeko.c \
|
||||
ftpglob.h \
|
||||
ftpvis.h
|
521
libnetbsd/Makefile.in
Normal file
521
libnetbsd/Makefile.in
Normal file
@ -0,0 +1,521 @@
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = libnetbsd
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in dirname.c \
|
||||
err.c fgetln.c getaddrinfo.c getnameinfo.c glob.c inet_ntop.c \
|
||||
inet_pton.c mkstemp.c setprogname.c sl_init.c snprintf.c \
|
||||
strdup.c strerror.c strlcat.c strlcpy.c strptime.c strsep.c \
|
||||
strtoll.c strunvis.c strvis.c timegm.c usleep.c utimes.c
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/tnftp_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
LTLIBRARIES = $(noinst_LTLIBRARIES)
|
||||
libnetbsd_la_DEPENDENCIES = $(LTLIBOBJS)
|
||||
am_libnetbsd_la_OBJECTS =
|
||||
libnetbsd_la_OBJECTS = $(am_libnetbsd_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/buildaux/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_$(V))
|
||||
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
AM_V_at = $(am__v_at_$(V))
|
||||
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_at_0 = @
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_$(V))
|
||||
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
AM_V_GEN = $(am__v_GEN_$(V))
|
||||
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
SOURCES = $(libnetbsd_la_SOURCES)
|
||||
DIST_SOURCES = $(libnetbsd_la_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)
|
||||
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
noinst_LTLIBRARIES = libnetbsd.la
|
||||
libnetbsd_la_SOURCES =
|
||||
libnetbsd_la_LIBADD = $(LTLIBOBJS)
|
||||
EXTRA_DIST = \
|
||||
fseeko.c \
|
||||
ftpglob.h \
|
||||
ftpvis.h
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libnetbsd/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign libnetbsd/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
clean-noinstLTLIBRARIES:
|
||||
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
|
||||
@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libnetbsd.la: $(libnetbsd_la_OBJECTS) $(libnetbsd_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(LINK) $(libnetbsd_la_OBJECTS) $(libnetbsd_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dirname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/err.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fgetln.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getaddrinfo.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getnameinfo.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/glob.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_ntop.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/inet_pton.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mkstemp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setprogname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sl_init.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/snprintf.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strdup.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strerror.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strptime.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoll.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strunvis.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strvis.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/timegm.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/usleep.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/utimes.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
installdirs:
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf $(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf $(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libtool clean-noinstLTLIBRARIES ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags uninstall uninstall-am
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
77
libnetbsd/dirname.c
Normal file
77
libnetbsd/dirname.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: dirname.c,v 1.2 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: dirname.c,v 1.7 2002/10/17 11:36:39 tron Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Klaus Klein and Jason R. Thorpe.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
char *
|
||||
dirname(path)
|
||||
char *path;
|
||||
{
|
||||
static char singledot[] = ".";
|
||||
static char result[PATH_MAX];
|
||||
char *lastp;
|
||||
size_t len;
|
||||
|
||||
/*
|
||||
* If `path' is a null pointer or points to an empty string,
|
||||
* return a pointer to the string ".".
|
||||
*/
|
||||
if ((path == NULL) || (*path == '\0'))
|
||||
return (singledot);
|
||||
|
||||
/* Strip trailing slashes, if any. */
|
||||
lastp = path + strlen(path) - 1;
|
||||
while (lastp != path && *lastp == '/')
|
||||
lastp--;
|
||||
|
||||
/* Terminate path at the last occurence of '/'. */
|
||||
do {
|
||||
if (*lastp == '/') {
|
||||
/* Strip trailing slashes, if any. */
|
||||
while (lastp != path && *lastp == '/')
|
||||
lastp--;
|
||||
|
||||
/* ...and copy the result into the result buffer. */
|
||||
len = (lastp - path) + 1 /* last char */;
|
||||
if (len > (PATH_MAX - 1))
|
||||
len = PATH_MAX - 1;
|
||||
|
||||
memcpy(result, path, len);
|
||||
result[len] = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
} while (--lastp >= path);
|
||||
|
||||
/* No /'s found, return a pointer to the string ".". */
|
||||
return (singledot);
|
||||
}
|
92
libnetbsd/err.c
Normal file
92
libnetbsd/err.c
Normal file
@ -0,0 +1,92 @@
|
||||
/* $NetBSD: err.c,v 1.4 2005/05/11 01:01:56 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997-2000 Luke Mewburn <lukem@NetBSD.org>.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
void
|
||||
err(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int sverrno;
|
||||
|
||||
sverrno = errno;
|
||||
(void)fprintf(stderr, "%s: ", getprogname());
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL) {
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ": ");
|
||||
}
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "%s\n", strerror(sverrno));
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
errx(int eval, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
(void)fprintf(stderr, "%s: ", getprogname());
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
warn(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int sverrno;
|
||||
|
||||
sverrno = errno;
|
||||
(void)fprintf(stderr, "%s: ", getprogname());
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL) {
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
(void)fprintf(stderr, ": ");
|
||||
}
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "%s\n", strerror(sverrno));
|
||||
}
|
||||
|
||||
void
|
||||
warnx(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
(void)fprintf(stderr, "%s: ", getprogname());
|
||||
va_start(ap, fmt);
|
||||
if (fmt != NULL)
|
||||
(void)vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
(void)fprintf(stderr, "\n");
|
||||
}
|
77
libnetbsd/fgetln.c
Normal file
77
libnetbsd/fgetln.c
Normal file
@ -0,0 +1,77 @@
|
||||
/* $NetBSD: fgetln.c,v 1.4 2008/04/29 08:13:38 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
char *
|
||||
fgetln(fp, len)
|
||||
FILE *fp;
|
||||
size_t *len;
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t bufsiz = 0;
|
||||
char *ptr;
|
||||
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsiz = BUFSIZ;
|
||||
if ((buf = malloc(bufsiz)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buf, bufsiz, fp) == NULL)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||
char *nbuf = realloc(buf, nbufsiz);
|
||||
|
||||
if (nbuf == NULL) {
|
||||
int oerrno = errno;
|
||||
free(buf);
|
||||
errno = oerrno;
|
||||
buf = NULL;
|
||||
return NULL;
|
||||
} else
|
||||
buf = nbuf;
|
||||
|
||||
*len = bufsiz;
|
||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL)
|
||||
return buf;
|
||||
|
||||
bufsiz = nbufsiz;
|
||||
}
|
||||
|
||||
*len = (ptr - buf) + 1;
|
||||
return buf;
|
||||
}
|
||||
|
40
libnetbsd/fseeko.c
Normal file
40
libnetbsd/fseeko.c
Normal file
@ -0,0 +1,40 @@
|
||||
/* $NetBSD: fseeko.c,v 1.4 2005/05/11 01:01:56 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002 Luke Mewburn <lukem@NetBSD.org>.
|
||||
* 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. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
int
|
||||
fseeko(FILE *stream, off_t offset, int whence)
|
||||
{
|
||||
if (offset > (off_t)LONG_MAX) {
|
||||
errno = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
return (fseek(stream, (long) offset, whence));
|
||||
}
|
95
libnetbsd/ftpglob.h
Normal file
95
libnetbsd/ftpglob.h
Normal file
@ -0,0 +1,95 @@
|
||||
/* $NetBSD: ftpglob.h,v 1.4 2007/07/22 11:41:57 lukem Exp $ */
|
||||
/* from NetBSD: glob.h,v 1.21 2006/03/26 18:11:22 christos Exp */
|
||||
|
||||
/*
|
||||
* 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. 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_
|
||||
|
||||
#ifndef __gl_size_t
|
||||
#define __gl_size_t size_t
|
||||
#endif
|
||||
#ifndef __gl_stat_t
|
||||
#define __gl_stat_t struct stat
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
__gl_size_t gl_pathc; /* Count of total paths so far. */
|
||||
__gl_size_t gl_matchc; /* Count of paths matching pattern. */
|
||||
__gl_size_t 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)(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)(void *);
|
||||
struct dirent *(*gl_readdir)(void *);
|
||||
void *(*gl_opendir)(const char *);
|
||||
int (*gl_lstat)(const char *, __gl_stat_t *);
|
||||
int (*gl_stat)(const char *, __gl_stat_t *);
|
||||
} 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_NOESCAPE 0x1000 /* Disable backslash escaping. */
|
||||
|
||||
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
|
||||
#define GLOB_ABORTED (-2) /* Unignored error. */
|
||||
#define GLOB_NOMATCH (-3) /* No match, and GLOB_NOCHECK was not set. */
|
||||
#define GLOB_NOSYS (-4) /* Implementation does not support function. */
|
||||
|
||||
#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_LIMIT 0x0400 /* Limit memory used by matches to ARG_MAX */
|
||||
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
|
||||
#define GLOB_QUOTE 0 /* source compatibility */
|
||||
|
||||
#define GLOB_ABEND GLOB_ABORTED /* source compatibility */
|
||||
|
||||
int glob(const char *, int, int (*)(const char *, int), glob_t *);
|
||||
void globfree(glob_t *);
|
||||
|
||||
#endif /* !_GLOB_H_ */
|
84
libnetbsd/ftpvis.h
Normal file
84
libnetbsd/ftpvis.h
Normal file
@ -0,0 +1,84 @@
|
||||
/* $NetBSD: ftpvis.h,v 1.3 2005/05/16 13:25:48 lukem Exp $ */
|
||||
/* from NetBSD: vis.h,v 1.15 2005/02/03 04:39:32 perry Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* 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. 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.
|
||||
*
|
||||
* @(#)vis.h 8.1 (Berkeley) 6/2/93
|
||||
*/
|
||||
|
||||
#ifndef _VIS_H_
|
||||
#define _VIS_H_
|
||||
|
||||
/*
|
||||
* to select alternate encoding format
|
||||
*/
|
||||
#define VIS_OCTAL 0x01 /* use octal \ddd format */
|
||||
#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */
|
||||
|
||||
/*
|
||||
* to alter set of characters encoded (default is to encode all
|
||||
* non-graphic except space, tab, and newline).
|
||||
*/
|
||||
#define VIS_SP 0x04 /* also encode space */
|
||||
#define VIS_TAB 0x08 /* also encode tab */
|
||||
#define VIS_NL 0x10 /* also encode newline */
|
||||
#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL)
|
||||
#define VIS_SAFE 0x20 /* only encode "unsafe" characters */
|
||||
|
||||
/*
|
||||
* other
|
||||
*/
|
||||
#define VIS_NOSLASH 0x40 /* inhibit printing '\' */
|
||||
#define VIS_HTTPSTYLE 0x80 /* http-style escape % HEX HEX */
|
||||
|
||||
/*
|
||||
* unvis return codes
|
||||
*/
|
||||
#define UNVIS_VALID 1 /* character valid */
|
||||
#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */
|
||||
#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */
|
||||
#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */
|
||||
#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */
|
||||
|
||||
/*
|
||||
* unvis flags
|
||||
*/
|
||||
#define UNVIS_END 1 /* no more characters */
|
||||
|
||||
char *vis(char *, int, int, int);
|
||||
char *svis(char *, int, int, int, const char *);
|
||||
int strvis(char *, const char *, int);
|
||||
int strsvis(char *, const char *, int, const char *);
|
||||
int strvisx(char *, const char *, size_t, int);
|
||||
int strsvisx(char *, const char *, size_t, int, const char *);
|
||||
int strunvis(char *, const char *);
|
||||
int strunvisx(char *, const char *, int);
|
||||
int unvis(char *, int, int *, int);
|
||||
|
||||
#endif /* !_VIS_H_ */
|
1097
libnetbsd/getaddrinfo.c
Normal file
1097
libnetbsd/getaddrinfo.c
Normal file
File diff suppressed because it is too large
Load Diff
347
libnetbsd/getnameinfo.c
Normal file
347
libnetbsd/getnameinfo.c
Normal file
@ -0,0 +1,347 @@
|
||||
/* $NetBSD: getnameinfo.c,v 1.6 2007/07/22 05:19:01 lukem Exp $ */
|
||||
/* from ? */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
* 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. Neither the name of the project 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 PROJECT 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 PROJECT 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Issues to be discussed:
|
||||
* - Thread safe-ness must be checked
|
||||
* - Return values. There seems to be no standard for return value (RFC2553)
|
||||
* but INRIA implementation returns EAI_xxx defined for getaddrinfo().
|
||||
* - RFC2553 says that we should raise error on short buffer. X/Open says
|
||||
* we need to truncate the result. We obey RFC2553 (and X/Open should be
|
||||
* modified).
|
||||
* - What is "local" in NI_FQDN?
|
||||
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
|
||||
* - (KAME extension) NI_WITHSCOPEID when called with global address,
|
||||
* and sin6_scope_id filled
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#define SUCCESS 0
|
||||
#define ANY 0
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
static struct afd {
|
||||
int a_af;
|
||||
int a_addrlen;
|
||||
int a_socklen;
|
||||
int a_off;
|
||||
} afdl [] = {
|
||||
#ifdef INET6
|
||||
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
|
||||
offsetof(struct sockaddr_in6, sin6_addr)},
|
||||
#endif
|
||||
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
|
||||
offsetof(struct sockaddr_in, sin_addr)},
|
||||
{0, 0, 0},
|
||||
};
|
||||
|
||||
struct sockinet {
|
||||
unsigned char si_len;
|
||||
unsigned char si_family;
|
||||
unsigned short si_port;
|
||||
};
|
||||
|
||||
#ifdef INET6
|
||||
static int ip6_parsenumeric(const struct sockaddr *, const char *, char *,
|
||||
size_t, int);
|
||||
static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int);
|
||||
#endif
|
||||
|
||||
#define ENI_NOSOCKET EAI_FAIL /*XXX*/
|
||||
#define ENI_NOSERVNAME EAI_NONAME
|
||||
#define ENI_NOHOSTNAME EAI_NONAME
|
||||
#define ENI_MEMORY EAI_MEMORY
|
||||
#define ENI_SYSTEM EAI_SYSTEM
|
||||
#define ENI_FAMILY EAI_FAMILY
|
||||
#define ENI_SALEN EAI_FAMILY
|
||||
|
||||
int
|
||||
getnameinfo(const struct sockaddr *sa, socklen_t salen,
|
||||
char *host, size_t hostlen, char *serv, size_t servlen, int flags)
|
||||
{
|
||||
struct afd *afd;
|
||||
struct servent *sp;
|
||||
struct hostent *hp;
|
||||
unsigned short port;
|
||||
int family, i;
|
||||
const char *addr;
|
||||
unsigned int v4a;
|
||||
char numserv[512];
|
||||
char numaddr[512];
|
||||
|
||||
if (sa == NULL)
|
||||
return ENI_NOSOCKET;
|
||||
|
||||
#if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
|
||||
if (sa->sa_len != salen)
|
||||
return ENI_SALEN;
|
||||
#endif
|
||||
|
||||
family = sa->sa_family;
|
||||
for (i = 0; afdl[i].a_af; i++)
|
||||
if (afdl[i].a_af == family) {
|
||||
afd = &afdl[i];
|
||||
goto found;
|
||||
}
|
||||
return ENI_FAMILY;
|
||||
|
||||
found:
|
||||
if (salen != afd->a_socklen)
|
||||
return ENI_SALEN;
|
||||
|
||||
/* network byte order */
|
||||
port = ((const struct sockinet *)sa)->si_port;
|
||||
addr = (const char *)sa + afd->a_off;
|
||||
|
||||
if (serv == NULL || servlen == 0) {
|
||||
/*
|
||||
* do nothing in this case.
|
||||
* in case you are wondering if "&&" is more correct than
|
||||
* "||" here: RFC2553 says that serv == NULL OR servlen == 0
|
||||
* means that the caller does not want the result.
|
||||
*/
|
||||
} else {
|
||||
if (flags & NI_NUMERICSERV)
|
||||
sp = NULL;
|
||||
else {
|
||||
sp = getservbyport(port,
|
||||
(flags & NI_DGRAM) ? "udp" : "tcp");
|
||||
}
|
||||
if (sp) {
|
||||
if (strlen(sp->s_name) > servlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(serv, sp->s_name);
|
||||
} else {
|
||||
snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
|
||||
if (strlen(numserv) > servlen)
|
||||
return ENI_MEMORY;
|
||||
strcpy(serv, numserv);
|
||||
}
|
||||
}
|
||||
|
||||
switch (sa->sa_family) {
|
||||
case AF_INET:
|
||||
v4a = (unsigned int)
|
||||
ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
|
||||
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
|
||||
flags |= NI_NUMERICHOST;
|
||||
v4a >>= IN_CLASSA_NSHIFT;
|
||||
if (v4a == 0)
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
const struct sockaddr_in6 *sin6;
|
||||
sin6 = (const struct sockaddr_in6 *)sa;
|
||||
switch (sin6->sin6_addr.s6_addr[0]) {
|
||||
case 0x00:
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
|
||||
;
|
||||
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
|
||||
;
|
||||
else
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
default:
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
|
||||
flags |= NI_NUMERICHOST;
|
||||
}
|
||||
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
|
||||
flags |= NI_NUMERICHOST;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if (host == NULL || hostlen == 0) {
|
||||
/*
|
||||
* do nothing in this case.
|
||||
* in case you are wondering if "&&" is more correct than
|
||||
* "||" here: RFC2553 says that host == NULL OR hostlen == 0
|
||||
* means that the caller does not want the result.
|
||||
*/
|
||||
} else if (flags & NI_NUMERICHOST) {
|
||||
int numaddrlen;
|
||||
|
||||
/* NUMERICHOST and NAMEREQD conflicts with each other */
|
||||
if (flags & NI_NAMEREQD)
|
||||
return ENI_NOHOSTNAME;
|
||||
|
||||
switch(afd->a_af) {
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = ip6_parsenumeric(sa, addr, host,
|
||||
hostlen, flags)) != 0)
|
||||
return(error);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
|
||||
== NULL)
|
||||
return ENI_SYSTEM;
|
||||
numaddrlen = strlen(numaddr);
|
||||
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
|
||||
return ENI_MEMORY;
|
||||
strcpy(host, numaddr);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
|
||||
|
||||
if (hp) {
|
||||
#if 0
|
||||
/*
|
||||
* commented out, since "for local host" is not
|
||||
* implemented here - see RFC2553 p30
|
||||
*/
|
||||
if (flags & NI_NOFQDN) {
|
||||
char *p;
|
||||
p = strchr(hp->h_name, '.');
|
||||
if (p)
|
||||
*p = '\0';
|
||||
}
|
||||
#endif
|
||||
if (strlen(hp->h_name) > hostlen) {
|
||||
return ENI_MEMORY;
|
||||
}
|
||||
strcpy(host, hp->h_name);
|
||||
} else {
|
||||
if (flags & NI_NAMEREQD)
|
||||
return ENI_NOHOSTNAME;
|
||||
switch(afd->a_af) {
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = ip6_parsenumeric(sa, addr, host,
|
||||
hostlen,
|
||||
flags)) != 0)
|
||||
return(error);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
if (inet_ntop(afd->a_af, addr, host,
|
||||
hostlen) == NULL)
|
||||
return ENI_SYSTEM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
static int
|
||||
ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host,
|
||||
size_t hostlen, int flags)
|
||||
{
|
||||
int numaddrlen;
|
||||
char numaddr[512];
|
||||
|
||||
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr))
|
||||
== NULL)
|
||||
return ENI_SYSTEM;
|
||||
|
||||
numaddrlen = strlen(numaddr);
|
||||
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
|
||||
return ENI_MEMORY;
|
||||
strcpy(host, numaddr);
|
||||
|
||||
#ifdef NI_WITHSCOPEID
|
||||
if (((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
|
||||
if (flags & NI_WITHSCOPEID)
|
||||
{
|
||||
char scopebuf[MAXHOSTNAMELEN];
|
||||
int scopelen;
|
||||
|
||||
/* ip6_sa2str never fails */
|
||||
scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa,
|
||||
scopebuf, sizeof(scopebuf),
|
||||
0);
|
||||
if (scopelen + 1 + numaddrlen + 1 > hostlen)
|
||||
return ENI_MEMORY;
|
||||
/*
|
||||
* construct <numeric-addr><delim><scopeid>
|
||||
*/
|
||||
memcpy(host + numaddrlen + 1, scopebuf,
|
||||
scopelen);
|
||||
host[numaddrlen] = SCOPE_DELIMITER;
|
||||
host[numaddrlen + 1 + scopelen] = '\0';
|
||||
}
|
||||
}
|
||||
#endif /* NI_WITHSCOPEID */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
static int
|
||||
ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags)
|
||||
{
|
||||
unsigned int ifindex = (unsigned int)sa6->sin6_scope_id;
|
||||
const struct in6_addr *a6 = &sa6->sin6_addr;
|
||||
|
||||
#ifdef notyet
|
||||
if (flags & NI_NUMERICSCOPE) {
|
||||
return(snprintf(buf, bufsiz, "%d", sa6->sin6_scope_id));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* XXXLUKEM: some systems (MacOS X) don't have IF_NAMESIZE
|
||||
* or if_indextoname()
|
||||
*/
|
||||
#if 0
|
||||
/* if_indextoname() does not take buffer size. not a good api... */
|
||||
if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) &&
|
||||
bufsiz >= IF_NAMESIZE) {
|
||||
char *p = if_indextoname(ifindex, buf);
|
||||
if (p) {
|
||||
return(strlen(p));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* last resort */
|
||||
return(snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id));
|
||||
}
|
||||
#endif /* INET6 */
|
888
libnetbsd/glob.c
Normal file
888
libnetbsd/glob.c
Normal file
@ -0,0 +1,888 @@
|
||||
/* $NetBSD: glob.c,v 1.8 2010/01/05 09:08:29 lukem Exp $ */
|
||||
/* from NetBSD: glob.c,v 1.16 2006/03/26 18:11:22 christos Exp */
|
||||
|
||||
/*
|
||||
* 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. 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(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_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 "tnftp.h"
|
||||
|
||||
#if !defined(ARG_MAX)
|
||||
#define ARG_MAX sysconf(_SC_ARG_MAX)
|
||||
#endif
|
||||
|
||||
#undef TILDE /* XXX: AIX 4.1.5 has this in <sys/ioctl.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 USE_8BIT_CHARS
|
||||
|
||||
#define M_QUOTE 0x8000
|
||||
#define M_PROTECT 0x4000
|
||||
#define M_MASK 0xffff
|
||||
#define M_ASCII 0x00ff
|
||||
|
||||
typedef unsigned short Char;
|
||||
|
||||
#else
|
||||
|
||||
#define M_QUOTE (Char)0x80
|
||||
#define M_PROTECT (Char)0x40
|
||||
#define M_MASK (Char)0xff
|
||||
#define M_ASCII (Char)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(const void *, const void *);
|
||||
static int g_Ctoc(const Char *, char *, size_t);
|
||||
static int g_lstat(Char *, __gl_stat_t *, glob_t *);
|
||||
static DIR *g_opendir(Char *, glob_t *);
|
||||
static Char *g_strchr(const Char *, int);
|
||||
static int g_stat(Char *, __gl_stat_t *, glob_t *);
|
||||
static int glob0(const Char *, glob_t *);
|
||||
static int glob1(Char *, glob_t *, size_t *);
|
||||
static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
|
||||
static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *,
|
||||
size_t *);
|
||||
static int globextend(const Char *, glob_t *, size_t *);
|
||||
static const Char *globtilde(const Char *, Char *, size_t, glob_t *);
|
||||
static int globexp1(const Char *, glob_t *);
|
||||
static int globexp2(const Char *, const Char *, glob_t *, int *);
|
||||
static int match(Char *, Char *, Char *);
|
||||
#ifdef DEBUG
|
||||
static void qprintf(const char *, Char *);
|
||||
#endif
|
||||
|
||||
int
|
||||
glob(const char *pattern, int flags, int (*errfunc)(const char *, int),
|
||||
glob_t *pglob)
|
||||
{
|
||||
const unsigned char *patnext;
|
||||
int c;
|
||||
Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
|
||||
|
||||
patnext = (const unsigned 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_NOESCAPE) {
|
||||
while (bufnext < bufend && (c = *patnext++) != EOS)
|
||||
*bufnext++ = c;
|
||||
} else {
|
||||
/* 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;
|
||||
}
|
||||
*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(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(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(const Char *ptr, const Char *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) {
|
||||
/*
|
||||
* we use `pattern', not `patbuf' here so that that
|
||||
* unbalanced braces are passed to the match
|
||||
*/
|
||||
*rv = glob0(pattern, 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(const Char *pattern, Char *patbuf, size_t patsize, glob_t *pglob)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
const char *h;
|
||||
const Char *p;
|
||||
Char *b;
|
||||
char *d;
|
||||
Char *pend = &patbuf[patsize / sizeof(Char)];
|
||||
|
||||
pend--;
|
||||
|
||||
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
|
||||
return pattern;
|
||||
|
||||
/* Copy up to the end of the string or / */
|
||||
for (p = pattern + 1, d = (char *)(void *)patbuf;
|
||||
d < (char *)(void *)pend && *p && *p != SLASH;
|
||||
*d++ = *p++)
|
||||
continue;
|
||||
|
||||
if (d == (char *)(void *)pend)
|
||||
return NULL;
|
||||
|
||||
*d = EOS;
|
||||
d = (char *)(void *)patbuf;
|
||||
|
||||
if (*d == 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(d)) == NULL)
|
||||
return pattern;
|
||||
else
|
||||
h = pwd->pw_dir;
|
||||
}
|
||||
|
||||
/* Copy the home directory */
|
||||
for (b = patbuf; b < pend && *h; *b++ = *h++)
|
||||
continue;
|
||||
|
||||
if (b == pend)
|
||||
return NULL;
|
||||
|
||||
/* Append the rest of the pattern */
|
||||
while (b < pend && (*b++ = *p++) != EOS)
|
||||
continue;
|
||||
|
||||
if (b == pend)
|
||||
return NULL;
|
||||
|
||||
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(const Char *pattern, glob_t *pglob)
|
||||
{
|
||||
const Char *qpatnext;
|
||||
int c, error;
|
||||
__gl_size_t oldpathc;
|
||||
Char *bufnext, patbuf[MAXPATHLEN+1];
|
||||
size_t limit = 0;
|
||||
|
||||
if ((qpatnext = globtilde(pattern, patbuf, sizeof(patbuf),
|
||||
pglob)) == NULL)
|
||||
return GLOB_ABEND;
|
||||
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(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 ((error = glob1(patbuf, pglob, &limit)) != 0)
|
||||
return(error);
|
||||
|
||||
if (pglob->gl_pathc == oldpathc) {
|
||||
/*
|
||||
* 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_flags & GLOB_NOCHECK) ||
|
||||
((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR))
|
||||
== GLOB_NOMAGIC)) {
|
||||
return globextend(pattern, pglob, &limit);
|
||||
} else {
|
||||
return (GLOB_NOMATCH);
|
||||
}
|
||||
} else if (!(pglob->gl_flags & GLOB_NOSORT)) {
|
||||
qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
|
||||
(size_t)pglob->gl_pathc - oldpathc, sizeof(char *),
|
||||
compare);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
compare(const void *p, const void *q)
|
||||
{
|
||||
|
||||
return(strcoll(*(const char * const *)p, *(const char * const *)q));
|
||||
}
|
||||
|
||||
static int
|
||||
glob1(Char *pattern, glob_t *pglob, size_t *limit)
|
||||
{
|
||||
Char pathbuf[MAXPATHLEN+1];
|
||||
|
||||
/* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
|
||||
if (*pattern == EOS)
|
||||
return(0);
|
||||
/*
|
||||
* we save one character so that we can use ptr >= limit,
|
||||
* in the general case when we are appending non nul chars only.
|
||||
*/
|
||||
return(glob2(pathbuf, pathbuf,
|
||||
pathbuf + (sizeof(pathbuf) / sizeof(*pathbuf)) - 1,
|
||||
pattern,
|
||||
pglob, limit));
|
||||
}
|
||||
|
||||
/*
|
||||
* 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(Char *pathbuf, Char *pathend, Char *pathlim,
|
||||
Char *pattern, glob_t *pglob, size_t *limit)
|
||||
{
|
||||
__gl_stat_t 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) ||
|
||||
(S_ISLNK(sb.st_mode) &&
|
||||
(g_stat(pathbuf, &sb, pglob) == 0) &&
|
||||
S_ISDIR(sb.st_mode)))) {
|
||||
if (pathend >= pathlim)
|
||||
return (GLOB_ABORTED);
|
||||
*pathend++ = SEP;
|
||||
*pathend = EOS;
|
||||
}
|
||||
++pglob->gl_matchc;
|
||||
return(globextend(pathbuf, pglob, limit));
|
||||
}
|
||||
|
||||
/* Find end of next segment, copy tentatively to pathend. */
|
||||
q = pathend;
|
||||
p = pattern;
|
||||
while (*p != EOS && *p != SEP) {
|
||||
if (ismeta(*p))
|
||||
anymeta = 1;
|
||||
if (q >= pathlim)
|
||||
return GLOB_ABORTED;
|
||||
*q++ = *p++;
|
||||
}
|
||||
|
||||
if (!anymeta) { /* No expansion, do next segment. */
|
||||
pathend = q;
|
||||
pattern = p;
|
||||
while (*pattern == SEP) {
|
||||
if (pathend >= pathlim)
|
||||
return GLOB_ABORTED;
|
||||
*pathend++ = *pattern++;
|
||||
}
|
||||
} else /* Need expansion, recurse. */
|
||||
return(glob3(pathbuf, pathend, pathlim, pattern, p,
|
||||
pglob, limit));
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
static int
|
||||
glob3(Char *pathbuf, Char *pathend, Char *pathlim,
|
||||
Char *pattern, Char *restpattern, glob_t *pglob, size_t *limit)
|
||||
{
|
||||
struct dirent *dp;
|
||||
DIR *dirp;
|
||||
int error;
|
||||
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)(void *);
|
||||
|
||||
*pathend = EOS;
|
||||
errno = 0;
|
||||
|
||||
if ((dirp = g_opendir(pathbuf, pglob)) == NULL) {
|
||||
if (pglob->gl_errfunc) {
|
||||
if (g_Ctoc(pathbuf, buf, sizeof(buf)))
|
||||
return (GLOB_ABORTED);
|
||||
if (pglob->gl_errfunc(buf, errno) ||
|
||||
pglob->gl_flags & GLOB_ERR)
|
||||
return (GLOB_ABORTED);
|
||||
}
|
||||
/*
|
||||
* Posix/XOpen: glob should return when it encounters a
|
||||
* directory that it cannot open or read
|
||||
* XXX: Should we ignore ENOTDIR and ENOENT though?
|
||||
* I think that Posix had in mind EPERM...
|
||||
*/
|
||||
if (pglob->gl_flags & GLOB_ERR)
|
||||
return (GLOB_ABORTED);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
||||
/* Search directory for matching names. */
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
readdirfunc = pglob->gl_readdir;
|
||||
else
|
||||
readdirfunc = (struct dirent *(*)(void *)) readdir;
|
||||
while ((dp = (*readdirfunc)(dirp)) != NULL) {
|
||||
unsigned char *sc;
|
||||
Char *dc;
|
||||
|
||||
/* Initial DOT must be matched literally. */
|
||||
if (dp->d_name[0] == DOT && *pattern != DOT)
|
||||
continue;
|
||||
/*
|
||||
* The resulting string contains EOS, so we can
|
||||
* use the pathlim character, if it is the nul
|
||||
*/
|
||||
for (sc = (unsigned char *) dp->d_name, dc = pathend;
|
||||
dc <= pathlim && (*dc++ = *sc++) != EOS;)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Have we filled the buffer without seeing EOS?
|
||||
*/
|
||||
if (dc > pathlim && *pathlim != EOS) {
|
||||
/*
|
||||
* Abort when requested by caller, otherwise
|
||||
* reset pathend back to last SEP and continue
|
||||
* with next dir entry.
|
||||
*/
|
||||
if (pglob->gl_flags & GLOB_ERR) {
|
||||
error = GLOB_ABORTED;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
*pathend = EOS;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match(pathend, pattern, restpattern)) {
|
||||
*pathend = EOS;
|
||||
continue;
|
||||
}
|
||||
error = glob2(pathbuf, --dc, pathlim, restpattern, pglob, limit);
|
||||
if (error)
|
||||
break;
|
||||
}
|
||||
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
(*pglob->gl_closedir)(dirp);
|
||||
else
|
||||
closedir(dirp);
|
||||
|
||||
/*
|
||||
* Again Posix X/Open issue with regards to error handling.
|
||||
*/
|
||||
if ((error || errno) && (pglob->gl_flags & GLOB_ERR))
|
||||
return (GLOB_ABORTED);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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(const Char *path, glob_t *pglob, size_t *limit)
|
||||
{
|
||||
char **pathv;
|
||||
size_t i, newsize, len;
|
||||
char *copy;
|
||||
const Char *p;
|
||||
|
||||
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
|
||||
pathv = pglob->gl_pathv ? realloc(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 + 1; --i > 0; )
|
||||
*--pathv = NULL;
|
||||
}
|
||||
pglob->gl_pathv = pathv;
|
||||
|
||||
for (p = path; *p++;)
|
||||
continue;
|
||||
len = (size_t)(p - path);
|
||||
*limit += len;
|
||||
if ((copy = malloc(len)) != NULL) {
|
||||
if (g_Ctoc(path, copy, len)) {
|
||||
free(copy);
|
||||
return(GLOB_ABORTED);
|
||||
}
|
||||
pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
|
||||
}
|
||||
pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
|
||||
|
||||
if ((pglob->gl_flags & GLOB_LIMIT) && (newsize + *limit) >= ARG_MAX) {
|
||||
errno = 0;
|
||||
return(GLOB_NOSPACE);
|
||||
}
|
||||
|
||||
return(copy == NULL ? GLOB_NOSPACE : 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pattern matching function for filenames. Each occurrence of the *
|
||||
* pattern causes a recursion level.
|
||||
*/
|
||||
static int
|
||||
match(Char *name, Char *pat, Char *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(glob_t *pglob)
|
||||
{
|
||||
size_t i;
|
||||
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);
|
||||
pglob->gl_pathv = NULL;
|
||||
pglob->gl_pathc = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static DIR *
|
||||
g_opendir(Char *str, glob_t *pglob)
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
if (!*str)
|
||||
(void)strlcpy(buf, ".", sizeof(buf));
|
||||
else {
|
||||
if (g_Ctoc(str, buf, sizeof(buf)))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_opendir)(buf));
|
||||
|
||||
return(opendir(buf));
|
||||
}
|
||||
|
||||
static int
|
||||
g_lstat(Char *fn, __gl_stat_t *sb, glob_t *pglob)
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
if (g_Ctoc(fn, buf, sizeof(buf)))
|
||||
return -1;
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_lstat)(buf, sb));
|
||||
return(lstat(buf, sb));
|
||||
}
|
||||
|
||||
static int
|
||||
g_stat(Char *fn, __gl_stat_t *sb, glob_t *pglob)
|
||||
{
|
||||
char buf[MAXPATHLEN];
|
||||
|
||||
if (g_Ctoc(fn, buf, sizeof(buf)))
|
||||
return -1;
|
||||
if (pglob->gl_flags & GLOB_ALTDIRFUNC)
|
||||
return((*pglob->gl_stat)(buf, sb));
|
||||
return(stat(buf, sb));
|
||||
}
|
||||
|
||||
static Char *
|
||||
g_strchr(const Char *str, int ch)
|
||||
{
|
||||
do {
|
||||
if (*str == ch)
|
||||
/* LINTED this is libc's definition! */
|
||||
return (Char *)str;
|
||||
} while (*str++);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
g_Ctoc(const Char *str, char *buf, size_t len)
|
||||
{
|
||||
char *dc;
|
||||
|
||||
if (len == 0)
|
||||
return 1;
|
||||
|
||||
for (dc = buf; len && (*dc++ = *str++) != EOS; len--)
|
||||
continue;
|
||||
|
||||
return len == 0;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
static void
|
||||
qprintf(const char *str, Char *s)
|
||||
{
|
||||
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
|
211
libnetbsd/inet_ntop.c
Normal file
211
libnetbsd/inet_ntop.c
Normal file
@ -0,0 +1,211 @@
|
||||
/* $NetBSD: inet_ntop.c,v 1.10 2007/07/23 11:45:51 lukem Exp $ */
|
||||
/* from NetBSD: inet_ntop.c,v 1.3 2006/05/10 21:53:15 mrg Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996-1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#if defined(HAVE_ARPA_NAMESER_H)
|
||||
# include <arpa/nameser.h>
|
||||
#endif
|
||||
#if !defined(NS_INADDRSZ)
|
||||
# define NS_INADDRSZ 4
|
||||
#endif
|
||||
#if !defined(NS_IN6ADDRSZ)
|
||||
# define NS_IN6ADDRSZ 16
|
||||
#endif
|
||||
#if !defined(NS_INT16SZ)
|
||||
# define NS_INT16SZ 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static const char *inet_ntop4(const unsigned char *src, char *dst, socklen_t size);
|
||||
#ifdef INET6
|
||||
static const char *inet_ntop6(const unsigned char *src, char *dst, socklen_t size);
|
||||
#endif /* INET6 */
|
||||
|
||||
/* char *
|
||||
* inet_ntop(af, src, dst, size)
|
||||
* convert a network format address to presentation format.
|
||||
* return:
|
||||
* pointer to presentation format address (`dst'), or NULL (see errno).
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
const char *
|
||||
inet_ntop(int af, const void *src, char *dst, socklen_t size)
|
||||
{
|
||||
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_ntop4(src, dst, size));
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
return (inet_ntop6(src, dst, size));
|
||||
#endif /* INET6 */
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return (NULL);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* const char *
|
||||
* inet_ntop4(src, dst, size)
|
||||
* format an IPv4 address, more or less like inet_ntoa()
|
||||
* return:
|
||||
* `dst' (as a const)
|
||||
* notes:
|
||||
* (1) uses no statics
|
||||
* (2) takes a unsigned char* not an in_addr as input
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop4(const unsigned char *src, char *dst, socklen_t size)
|
||||
{
|
||||
char tmp[sizeof "255.255.255.255"];
|
||||
int l;
|
||||
|
||||
l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u",
|
||||
src[0], src[1], src[2], src[3]);
|
||||
if (l <= 0 || (socklen_t) l >= size) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
return (dst);
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
/* const char *
|
||||
* inet_ntop6(src, dst, size)
|
||||
* convert IPv6 binary address into presentation (printable) format
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static const char *
|
||||
inet_ntop6(const unsigned char *src, char *dst, socklen_t size)
|
||||
{
|
||||
/*
|
||||
* Note that int32_t and int16_t need only be "at least" large enough
|
||||
* to contain a value of the specified size. On some systems, like
|
||||
* Crays, there is no such thing as an integer variable with 16 bits.
|
||||
* Keep this in mind if you think this function should have been coded
|
||||
* to use pointer overlays. All the world's not a VAX.
|
||||
*/
|
||||
char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
|
||||
char *tp, *ep;
|
||||
struct { int base, len; } best, cur;
|
||||
unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
|
||||
int i;
|
||||
int advance;
|
||||
|
||||
/*
|
||||
* Preprocess:
|
||||
* Copy the input (bytewise) array into a wordwise array.
|
||||
* Find the longest run of 0x00's in src[] for :: shorthanding.
|
||||
*/
|
||||
memset(words, '\0', sizeof words);
|
||||
for (i = 0; i < NS_IN6ADDRSZ; i++)
|
||||
words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
|
||||
best.base = -1;
|
||||
cur.base = -1;
|
||||
best.len = -1; /* XXX gcc */
|
||||
cur.len = -1; /* XXX gcc */
|
||||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
|
||||
if (words[i] == 0) {
|
||||
if (cur.base == -1)
|
||||
cur.base = i, cur.len = 1;
|
||||
else
|
||||
cur.len++;
|
||||
} else {
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
cur.base = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cur.base != -1) {
|
||||
if (best.base == -1 || cur.len > best.len)
|
||||
best = cur;
|
||||
}
|
||||
if (best.base != -1 && best.len < 2)
|
||||
best.base = -1;
|
||||
|
||||
/*
|
||||
* Format the result.
|
||||
*/
|
||||
tp = tmp;
|
||||
ep = tmp + sizeof(tmp);
|
||||
for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
|
||||
/* Are we inside the best run of 0x00's? */
|
||||
if (best.base != -1 && i >= best.base &&
|
||||
i < (best.base + best.len)) {
|
||||
if (i == best.base)
|
||||
*tp++ = ':';
|
||||
continue;
|
||||
}
|
||||
/* Are we following an initial run of 0x00s or any real hex? */
|
||||
if (i != 0) {
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = ':';
|
||||
}
|
||||
/* Is this address an encapsulated IPv4? */
|
||||
if (i == 6 && best.base == 0 &&
|
||||
(best.len == 6 ||
|
||||
(best.len == 7 && words[7] != 0x0001) ||
|
||||
(best.len == 5 && words[5] == 0xffff))) {
|
||||
if (!inet_ntop4(src+12, tp, (socklen_t)(ep - tp)))
|
||||
return (NULL);
|
||||
tp += strlen(tp);
|
||||
break;
|
||||
}
|
||||
advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]);
|
||||
if (advance <= 0 || advance >= ep - tp)
|
||||
return (NULL);
|
||||
tp += advance;
|
||||
}
|
||||
/* Was it a trailing run of 0x00's? */
|
||||
if (best.base != -1 && (best.base + best.len) ==
|
||||
(NS_IN6ADDRSZ / NS_INT16SZ)) {
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = ':';
|
||||
}
|
||||
if (tp + 1 >= ep)
|
||||
return (NULL);
|
||||
*tp++ = '\0';
|
||||
|
||||
/*
|
||||
* Check for overflow, copy, and we're done.
|
||||
*/
|
||||
if ((size_t)(tp - tmp) > size) {
|
||||
errno = ENOSPC;
|
||||
return (NULL);
|
||||
}
|
||||
strlcpy(dst, tmp, size);
|
||||
return (dst);
|
||||
}
|
||||
#endif /* INET6 */
|
292
libnetbsd/inet_pton.c
Normal file
292
libnetbsd/inet_pton.c
Normal file
@ -0,0 +1,292 @@
|
||||
/* $NetBSD: inet_pton.c,v 1.9 2007/07/23 11:45:52 lukem Exp $ */
|
||||
/* from NetBSD: inet_pton.c,v 1.3 2006/09/26 05:59:18 lukem Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
|
||||
* Copyright (c) 1996,1999 by Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
||||
* OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#if defined(HAVE_ARPA_NAMESER_H)
|
||||
# include <arpa/nameser.h>
|
||||
#endif
|
||||
#if !defined(NS_INADDRSZ)
|
||||
# define NS_INADDRSZ 4
|
||||
#endif
|
||||
#if !defined(NS_IN6ADDRSZ)
|
||||
# define NS_IN6ADDRSZ 16
|
||||
#endif
|
||||
#if !defined(NS_INT16SZ)
|
||||
# define NS_INT16SZ 2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* WARNING: Don't even consider trying to compile this on a system where
|
||||
* sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
|
||||
*/
|
||||
|
||||
static int inet_pton4(const char *src, unsigned char *dst, int pton);
|
||||
#ifdef INET6
|
||||
static int inet_pton6(const char *src, unsigned char *dst);
|
||||
#endif /* INET6 */
|
||||
|
||||
/* int
|
||||
* inet_pton(af, src, dst)
|
||||
* convert from presentation format (which usually means ASCII printable)
|
||||
* to network format (which is usually some kind of binary format).
|
||||
* return:
|
||||
* 1 if the address was valid for the specified address family
|
||||
* 0 if the address wasn't valid (`dst' is untouched in this case)
|
||||
* -1 if some other error occurred (`dst' is untouched in this case, too)
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
int
|
||||
inet_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
|
||||
switch (af) {
|
||||
case AF_INET:
|
||||
return (inet_pton4(src, dst, 1));
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
return (inet_pton6(src, dst));
|
||||
#endif /* INET6 */
|
||||
default:
|
||||
errno = EAFNOSUPPORT;
|
||||
return (-1);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/* int
|
||||
* inet_pton4(src, dst, pton)
|
||||
* when last arg is 0: inet_aton(). with hexadecimal, octal and shorthand.
|
||||
* when last arg is 1: inet_pton(). decimal dotted-quad only.
|
||||
* return:
|
||||
* 1 if `src' is a valid input, else 0.
|
||||
* notice:
|
||||
* does not touch `dst' unless it's returning 1.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton4(const char *src, unsigned char *dst, int pton)
|
||||
{
|
||||
uint32_t val;
|
||||
unsigned int digit, base;
|
||||
int n;
|
||||
unsigned char c;
|
||||
unsigned int parts[4];
|
||||
register unsigned int *pp = parts;
|
||||
|
||||
c = *src;
|
||||
for (;;) {
|
||||
/*
|
||||
* Collect number up to ``.''.
|
||||
* Values are specified as for C:
|
||||
* 0x=hex, 0=octal, isdigit=decimal.
|
||||
*/
|
||||
if (!isdigit(c))
|
||||
return (0);
|
||||
val = 0; base = 10;
|
||||
if (c == '0') {
|
||||
c = *++src;
|
||||
if (c == 'x' || c == 'X')
|
||||
base = 16, c = *++src;
|
||||
else if (isdigit(c) && c != '9')
|
||||
base = 8;
|
||||
}
|
||||
/* inet_pton() takes decimal only */
|
||||
if (pton && base != 10)
|
||||
return (0);
|
||||
for (;;) {
|
||||
if (isdigit(c)) {
|
||||
digit = c - '0';
|
||||
if (digit >= base)
|
||||
break;
|
||||
val = (val * base) + digit;
|
||||
c = *++src;
|
||||
} else if (base == 16 && isxdigit(c)) {
|
||||
digit = c + 10 - (islower(c) ? 'a' : 'A');
|
||||
if (digit >= 16)
|
||||
break;
|
||||
val = (val << 4) | digit;
|
||||
c = *++src;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
if (c == '.') {
|
||||
/*
|
||||
* Internet format:
|
||||
* a.b.c.d
|
||||
* a.b.c (with c treated as 16 bits)
|
||||
* a.b (with b treated as 24 bits)
|
||||
* a (with a treated as 32 bits)
|
||||
*/
|
||||
if (pp >= parts + 3)
|
||||
return (0);
|
||||
*pp++ = val;
|
||||
c = *++src;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
/*
|
||||
* Check for trailing characters.
|
||||
*/
|
||||
if (c != '\0' && !isspace(c))
|
||||
return (0);
|
||||
/*
|
||||
* Concoct the address according to
|
||||
* the number of parts specified.
|
||||
*/
|
||||
n = pp - parts + 1;
|
||||
/* inet_pton() takes dotted-quad only. it does not take shorthand. */
|
||||
if (pton && n != 4)
|
||||
return (0);
|
||||
switch (n) {
|
||||
|
||||
case 0:
|
||||
return (0); /* initial nondigit */
|
||||
|
||||
case 1: /* a -- 32 bits */
|
||||
break;
|
||||
|
||||
case 2: /* a.b -- 8.24 bits */
|
||||
if (parts[0] > 0xff || val > 0xffffff)
|
||||
return (0);
|
||||
val |= parts[0] << 24;
|
||||
break;
|
||||
|
||||
case 3: /* a.b.c -- 8.8.16 bits */
|
||||
if ((parts[0] | parts[1]) > 0xff || val > 0xffff)
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16);
|
||||
break;
|
||||
|
||||
case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
||||
if ((parts[0] | parts[1] | parts[2] | val) > 0xff)
|
||||
return (0);
|
||||
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
||||
break;
|
||||
}
|
||||
if (dst) {
|
||||
val = htonl(val);
|
||||
memcpy(dst, &val, NS_INADDRSZ);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef INET6
|
||||
/* int
|
||||
* inet_pton6(src, dst)
|
||||
* convert presentation level address to network order binary form.
|
||||
* return:
|
||||
* 1 if `src' is a valid [RFC1884 2.2] address, else 0.
|
||||
* notice:
|
||||
* (1) does not touch `dst' unless it's returning 1.
|
||||
* (2) :: in a full address is silently ignored.
|
||||
* credit:
|
||||
* inspired by Mark Andrews.
|
||||
* author:
|
||||
* Paul Vixie, 1996.
|
||||
*/
|
||||
static int
|
||||
inet_pton6(const char *src, unsigned char *dst)
|
||||
{
|
||||
static const char xdigits_l[] = "0123456789abcdef",
|
||||
xdigits_u[] = "0123456789ABCDEF";
|
||||
unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
|
||||
const char *xdigits, *curtok;
|
||||
int ch, saw_xdigit;
|
||||
unsigned int val;
|
||||
|
||||
memset((tp = tmp), '\0', NS_IN6ADDRSZ);
|
||||
endp = tp + NS_IN6ADDRSZ;
|
||||
colonp = NULL;
|
||||
/* Leading :: requires some special handling. */
|
||||
if (*src == ':')
|
||||
if (*++src != ':')
|
||||
return (0);
|
||||
curtok = src;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
while ((ch = *src++) != '\0') {
|
||||
const char *pch;
|
||||
|
||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
||||
pch = strchr((xdigits = xdigits_u), ch);
|
||||
if (pch != NULL) {
|
||||
val <<= 4;
|
||||
val |= (pch - xdigits);
|
||||
if (val > 0xffff)
|
||||
return (0);
|
||||
saw_xdigit = 1;
|
||||
continue;
|
||||
}
|
||||
if (ch == ':') {
|
||||
curtok = src;
|
||||
if (!saw_xdigit) {
|
||||
if (colonp)
|
||||
return (0);
|
||||
colonp = tp;
|
||||
continue;
|
||||
} else if (*src == '\0')
|
||||
return (0);
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
saw_xdigit = 0;
|
||||
val = 0;
|
||||
continue;
|
||||
}
|
||||
if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
|
||||
inet_pton4(curtok, tp, 1) > 0) {
|
||||
tp += NS_INADDRSZ;
|
||||
saw_xdigit = 0;
|
||||
break; /* '\0' was seen by inet_pton4(). */
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
if (saw_xdigit) {
|
||||
if (tp + NS_INT16SZ > endp)
|
||||
return (0);
|
||||
*tp++ = (unsigned char) (val >> 8) & 0xff;
|
||||
*tp++ = (unsigned char) val & 0xff;
|
||||
}
|
||||
if (colonp != NULL) {
|
||||
/*
|
||||
* Since some memmove()'s erroneously fail to handle
|
||||
* overlapping regions, we'll do the shift by hand.
|
||||
*/
|
||||
const int n = tp - colonp;
|
||||
int i;
|
||||
|
||||
if (tp == endp)
|
||||
return (0);
|
||||
for (i = 1; i <= n; i++) {
|
||||
endp[- i] = colonp[n - i];
|
||||
colonp[n - i] = 0;
|
||||
}
|
||||
tp = endp;
|
||||
}
|
||||
if (tp != endp)
|
||||
return (0);
|
||||
memcpy(dst, tmp, NS_IN6ADDRSZ);
|
||||
return (1);
|
||||
}
|
||||
#endif /* INET6 */
|
123
libnetbsd/mkstemp.c
Normal file
123
libnetbsd/mkstemp.c
Normal file
@ -0,0 +1,123 @@
|
||||
/* $NetBSD: mkstemp.c,v 1.5 2005/06/01 11:48:49 lukem Exp $ */
|
||||
/* from NetBSD: gettemp.c,v 1.13 2003/12/05 00:57:36 uebayasi Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1987, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
int
|
||||
mkstemp(char *path)
|
||||
{
|
||||
char *start, *trv;
|
||||
struct stat sbuf;
|
||||
unsigned int pid;
|
||||
int fd;
|
||||
|
||||
/* To guarantee multiple calls generate unique names even if
|
||||
the file is not created. 676 different possibilities with 7
|
||||
or more X's, 26 with 6 or less. */
|
||||
static char xtra[2] = "aa";
|
||||
int xcnt = 0;
|
||||
|
||||
pid = getpid();
|
||||
|
||||
/* Move to end of path and count trailing X's. */
|
||||
for (trv = path; *trv; ++trv)
|
||||
if (*trv == 'X')
|
||||
xcnt++;
|
||||
else
|
||||
xcnt = 0;
|
||||
|
||||
/* Use at least one from xtra. Use 2 if more than 6 X's. */
|
||||
if (*(trv - 1) == 'X')
|
||||
*--trv = xtra[0];
|
||||
if (xcnt > 6 && *(trv - 1) == 'X')
|
||||
*--trv = xtra[1];
|
||||
|
||||
/* Set remaining X's to pid digits with 0's to the left. */
|
||||
while (*--trv == 'X') {
|
||||
*trv = (pid % 10) + '0';
|
||||
pid /= 10;
|
||||
}
|
||||
|
||||
/* update xtra for next call. */
|
||||
if (xtra[0] != 'z')
|
||||
xtra[0]++;
|
||||
else {
|
||||
xtra[0] = 'a';
|
||||
if (xtra[1] != 'z')
|
||||
xtra[1]++;
|
||||
else
|
||||
xtra[1] = 'a';
|
||||
}
|
||||
|
||||
/*
|
||||
* check the target directory; if you have six X's and it
|
||||
* doesn't exist this runs for a *very* long time.
|
||||
*/
|
||||
for (start = trv + 1;; --trv) {
|
||||
if (trv <= path)
|
||||
break;
|
||||
if (*trv == '/') {
|
||||
*trv = '\0';
|
||||
if (stat(path, &sbuf))
|
||||
return (-1);
|
||||
if (!S_ISDIR(sbuf.st_mode)) {
|
||||
errno = ENOTDIR;
|
||||
return (-1);
|
||||
}
|
||||
*trv = '/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if ((fd = open(path, O_CREAT | O_EXCL | O_RDWR, 0600)) >= 0)
|
||||
return (fd);
|
||||
if (errno != EEXIST)
|
||||
return (-1);
|
||||
|
||||
/* tricky little algorithm for backward compatibility */
|
||||
for (trv = start;;) {
|
||||
if (!*trv)
|
||||
return (-1);
|
||||
if (*trv == 'z')
|
||||
*trv++ = 'a';
|
||||
else {
|
||||
if (isdigit((unsigned char)*trv))
|
||||
*trv = 'a';
|
||||
else
|
||||
++*trv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
51
libnetbsd/setprogname.c
Normal file
51
libnetbsd/setprogname.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* $NetBSD: setprogname.c,v 1.4 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: setprogname.c,v 1.3 2002/01/31 19:21:58 tv Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Todd Vierling.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
static const char *__progname = "<unset_progname>";
|
||||
|
||||
void
|
||||
setprogname(const char *progname)
|
||||
{
|
||||
__progname = strrchr(progname, '/');
|
||||
if (__progname == NULL)
|
||||
__progname = progname;
|
||||
else
|
||||
__progname++;
|
||||
}
|
||||
|
||||
const char *
|
||||
getprogname(void)
|
||||
{
|
||||
return __progname;
|
||||
}
|
114
libnetbsd/sl_init.c
Normal file
114
libnetbsd/sl_init.c
Normal file
@ -0,0 +1,114 @@
|
||||
/* $NetBSD: sl_init.c,v 1.5 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: stringlist.c,v 1.10 2000/01/25 16:24:40 enami Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1994, 1999 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#define _SL_CHUNKSIZE 20
|
||||
|
||||
/*
|
||||
* sl_init(): Initialize a string list
|
||||
*/
|
||||
StringList *
|
||||
sl_init(void)
|
||||
{
|
||||
StringList *sl;
|
||||
|
||||
sl = malloc(sizeof(StringList));
|
||||
if (sl == NULL)
|
||||
return (NULL);
|
||||
|
||||
sl->sl_cur = 0;
|
||||
sl->sl_max = _SL_CHUNKSIZE;
|
||||
sl->sl_str = malloc(sl->sl_max * sizeof(char *));
|
||||
if (sl->sl_str == NULL) {
|
||||
free(sl);
|
||||
sl = NULL;
|
||||
}
|
||||
return (sl);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* sl_add(): Add an item to the string list
|
||||
*/
|
||||
int
|
||||
sl_add(StringList *sl, char *name)
|
||||
{
|
||||
if (sl->sl_cur == sl->sl_max - 1) {
|
||||
char **new;
|
||||
|
||||
new = (char **)realloc(sl->sl_str,
|
||||
(sl->sl_max + _SL_CHUNKSIZE) * sizeof(char *));
|
||||
if (new == NULL)
|
||||
return (-1);
|
||||
sl->sl_max += _SL_CHUNKSIZE;
|
||||
sl->sl_str = new;
|
||||
}
|
||||
sl->sl_str[sl->sl_cur++] = name;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* sl_free(): Free a stringlist
|
||||
*/
|
||||
void
|
||||
sl_free(StringList *sl, int all)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (sl == NULL)
|
||||
return;
|
||||
if (sl->sl_str) {
|
||||
if (all)
|
||||
for (i = 0; i < sl->sl_cur; i++)
|
||||
free(sl->sl_str[i]);
|
||||
free(sl->sl_str);
|
||||
}
|
||||
free(sl);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* sl_find(): Find a name in the string list
|
||||
*/
|
||||
char *
|
||||
sl_find(StringList *sl, char *name)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sl->sl_cur; i++)
|
||||
if (strcmp(sl->sl_str[i], name) == 0)
|
||||
return (sl->sl_str[i]);
|
||||
|
||||
return (NULL);
|
||||
}
|
788
libnetbsd/snprintf.c
Normal file
788
libnetbsd/snprintf.c
Normal file
@ -0,0 +1,788 @@
|
||||
/* $NetBSD: snprintf.c,v 1.6 2007/07/22 05:19:02 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright Patrick Powell 1995
|
||||
* This code is based on code written by Patrick Powell (papowell@astart.com)
|
||||
* It may be used for any purpose as long as this notice remains intact
|
||||
* on all source code distributions
|
||||
*/
|
||||
|
||||
/**************************************************************
|
||||
* Original:
|
||||
* Patrick Powell Tue Apr 11 09:48:21 PDT 1995
|
||||
* A bombproof version of doprnt (dopr) included.
|
||||
* Sigh. This sort of thing is always nasty do deal with. Note that
|
||||
* the version here does not include floating point...
|
||||
*
|
||||
* snprintf() is used instead of sprintf() as it does limit checks
|
||||
* for string length. This covers a nasty loophole.
|
||||
*
|
||||
* The other functions are there to prevent NULL pointers from
|
||||
* causing nast effects.
|
||||
*
|
||||
* More Recently:
|
||||
* Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43
|
||||
* This was ugly. It is still ugly. I opted out of floating point
|
||||
* numbers, but the formatter understands just about everything
|
||||
* from the normal C string format, at least as far as I can tell from
|
||||
* the Solaris 2.5 printf(3S) man page.
|
||||
*
|
||||
* Brandon Long <blong@fiction.net> 10/22/97 for mutt 0.87.1
|
||||
* Ok, added some minimal floating point support, which means this
|
||||
* probably requires libm on most operating systems. Don't yet
|
||||
* support the exponent (e,E) and sigfig (g,G). Also, fmtint()
|
||||
* was pretty badly broken, it just wasn't being exercised in ways
|
||||
* which showed it, so that's been fixed. Also, formated the code
|
||||
* to mutt conventions, and removed dead code left over from the
|
||||
* original. Also, there is now a builtin-test, just compile with:
|
||||
* gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
|
||||
* and run snprintf for results.
|
||||
*
|
||||
* Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
|
||||
* The PGP code was using unsigned hexadecimal formats.
|
||||
* Unfortunately, unsigned formats simply didn't work.
|
||||
*
|
||||
* Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
|
||||
* The original code assumed that both snprintf() and vsnprintf() were
|
||||
* missing. Some systems only have snprintf() but not vsnprintf(), so
|
||||
* the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
|
||||
*
|
||||
* Andrew Tridgell (tridge@samba.org) Oct 1998
|
||||
* fixed handling of %.0f
|
||||
* added test for HAVE_LONG_DOUBLE
|
||||
*
|
||||
* Luke Mewburn <lukem@NetBSD.org>, Thu Sep 30 23:28:21 EST 1999
|
||||
* cleaned up formatting, autoconf tests
|
||||
* added long long support
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
|
||||
#if defined(HAVE_LONG_DOUBLE)
|
||||
#define LDOUBLE long double
|
||||
#else
|
||||
#define LDOUBLE double
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LONG_LONG_INT)
|
||||
#define LLONG long long
|
||||
#else
|
||||
#define LLONG long
|
||||
#endif
|
||||
|
||||
static void dopr(char *buffer, size_t maxlen, size_t *retlen,
|
||||
const char *format, va_list args);
|
||||
static void fmtstr(char *buffer, size_t * currlen, size_t maxlen,
|
||||
char *value, int min, int max, int flags);
|
||||
static void fmtint(char *buffer, size_t * currlen, size_t maxlen,
|
||||
LLONG value, int base, int min, int max, int flags);
|
||||
static void fmtfp(char *buffer, size_t * currlen, size_t maxlen,
|
||||
LDOUBLE fvalue, int min, int max, int flags);
|
||||
static void dopr_outch(char *buffer, size_t * currlen, size_t maxlen, int c);
|
||||
|
||||
/*
|
||||
* dopr(): poor man's version of doprintf
|
||||
*/
|
||||
|
||||
/* format read states */
|
||||
#define DP_S_DEFAULT 0
|
||||
#define DP_S_FLAGS 1
|
||||
#define DP_S_MIN 2
|
||||
#define DP_S_DOT 3
|
||||
#define DP_S_MAX 4
|
||||
#define DP_S_MOD 5
|
||||
#define DP_S_CONV 6
|
||||
#define DP_S_DONE 7
|
||||
|
||||
/* format flags - Bits */
|
||||
#define DP_F_MINUS (1 << 0)
|
||||
#define DP_F_PLUS (1 << 1)
|
||||
#define DP_F_SPACE (1 << 2)
|
||||
#define DP_F_NUM (1 << 3)
|
||||
#define DP_F_ZERO (1 << 4)
|
||||
#define DP_F_UP (1 << 5)
|
||||
#define DP_F_UNSIGNED (1 << 6)
|
||||
|
||||
/* Conversion Flags */
|
||||
#define DP_C_SHORT 1
|
||||
#define DP_C_LONG 2
|
||||
#define DP_C_LDOUBLE 3
|
||||
#define DP_C_LLONG 4
|
||||
|
||||
#define char_to_int(p) (p - '0')
|
||||
|
||||
static void
|
||||
dopr(char *buffer, size_t maxlen, size_t *retlen, const char *format,
|
||||
va_list args)
|
||||
{
|
||||
char ch;
|
||||
LLONG value;
|
||||
LDOUBLE fvalue;
|
||||
char *strvalue;
|
||||
int min;
|
||||
int max;
|
||||
int state;
|
||||
int flags;
|
||||
int cflags;
|
||||
size_t currlen;
|
||||
|
||||
state = DP_S_DEFAULT;
|
||||
flags = currlen = cflags = min = 0;
|
||||
max = -1;
|
||||
ch = *format++;
|
||||
|
||||
while (state != DP_S_DONE) {
|
||||
if ((ch == '\0') || (currlen >= maxlen))
|
||||
state = DP_S_DONE;
|
||||
|
||||
switch (state) {
|
||||
case DP_S_DEFAULT:
|
||||
if (ch == '%')
|
||||
state = DP_S_FLAGS;
|
||||
else
|
||||
dopr_outch(buffer, &currlen, maxlen, ch);
|
||||
ch = *format++;
|
||||
break;
|
||||
case DP_S_FLAGS:
|
||||
switch (ch) {
|
||||
case '-':
|
||||
flags |= DP_F_MINUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '+':
|
||||
flags |= DP_F_PLUS;
|
||||
ch = *format++;
|
||||
break;
|
||||
case ' ':
|
||||
flags |= DP_F_SPACE;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '#':
|
||||
flags |= DP_F_NUM;
|
||||
ch = *format++;
|
||||
break;
|
||||
case '0':
|
||||
flags |= DP_F_ZERO;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
state = DP_S_MIN;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case DP_S_MIN:
|
||||
if (isdigit((unsigned char) ch)) {
|
||||
min = 10 * min + char_to_int(ch);
|
||||
ch = *format++;
|
||||
} else if (ch == '*') {
|
||||
min = va_arg(args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_DOT;
|
||||
} else
|
||||
state = DP_S_DOT;
|
||||
break;
|
||||
case DP_S_DOT:
|
||||
if (ch == '.') {
|
||||
state = DP_S_MAX;
|
||||
ch = *format++;
|
||||
} else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MAX:
|
||||
if (isdigit((unsigned char) ch)) {
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
max = 10 * max + char_to_int(ch);
|
||||
ch = *format++;
|
||||
} else if (ch == '*') {
|
||||
max = va_arg(args, int);
|
||||
ch = *format++;
|
||||
state = DP_S_MOD;
|
||||
} else
|
||||
state = DP_S_MOD;
|
||||
break;
|
||||
case DP_S_MOD:
|
||||
switch (ch) {
|
||||
case 'h':
|
||||
cflags = DP_C_SHORT;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'l':
|
||||
if (*format == 'l') {
|
||||
cflags = DP_C_LLONG;
|
||||
format++;
|
||||
} else
|
||||
cflags = DP_C_LONG;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'q':
|
||||
cflags = DP_C_LLONG;
|
||||
ch = *format++;
|
||||
break;
|
||||
case 'L':
|
||||
cflags = DP_C_LDOUBLE;
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
state = DP_S_CONV;
|
||||
break;
|
||||
case DP_S_CONV:
|
||||
switch (ch) {
|
||||
case 'd':
|
||||
case 'i':
|
||||
switch (cflags) {
|
||||
case DP_C_SHORT:
|
||||
value = va_arg(args, int);
|
||||
break;
|
||||
case DP_C_LONG:
|
||||
value = va_arg(args, long int);
|
||||
break;
|
||||
case DP_C_LLONG:
|
||||
value = va_arg(args, LLONG);
|
||||
break;
|
||||
default:
|
||||
value = va_arg(args, int);
|
||||
break;
|
||||
}
|
||||
fmtint(buffer, &currlen, maxlen, value, 10,
|
||||
min, max, flags);
|
||||
break;
|
||||
case 'X':
|
||||
flags |= DP_F_UP;
|
||||
/* FALLTHROUGH */
|
||||
case 'x':
|
||||
case 'o':
|
||||
case 'u':
|
||||
flags |= DP_F_UNSIGNED;
|
||||
switch (cflags) {
|
||||
case DP_C_SHORT:
|
||||
value = va_arg(args, unsigned int);
|
||||
break;
|
||||
case DP_C_LONG:
|
||||
value = (LLONG) va_arg(args,
|
||||
unsigned long int);
|
||||
break;
|
||||
case DP_C_LLONG:
|
||||
value = va_arg(args, unsigned LLONG);
|
||||
break;
|
||||
default:
|
||||
value = (LLONG) va_arg(args,
|
||||
unsigned int);
|
||||
break;
|
||||
}
|
||||
fmtint(buffer, &currlen, maxlen, value,
|
||||
ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
|
||||
min, max, flags);
|
||||
break;
|
||||
case 'f':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg(args, LDOUBLE);
|
||||
else
|
||||
fvalue = va_arg(args, double);
|
||||
/* um, floating point? */
|
||||
fmtfp(buffer, &currlen, maxlen, fvalue, min,
|
||||
max, flags);
|
||||
break;
|
||||
case 'E':
|
||||
flags |= DP_F_UP;
|
||||
case 'e':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg(args, LDOUBLE);
|
||||
else
|
||||
fvalue = va_arg(args, double);
|
||||
break;
|
||||
case 'G':
|
||||
flags |= DP_F_UP;
|
||||
case 'g':
|
||||
if (cflags == DP_C_LDOUBLE)
|
||||
fvalue = va_arg(args, LDOUBLE);
|
||||
else
|
||||
fvalue = va_arg(args, double);
|
||||
break;
|
||||
case 'c':
|
||||
dopr_outch(buffer, &currlen, maxlen,
|
||||
va_arg(args, int));
|
||||
break;
|
||||
case 's':
|
||||
strvalue = va_arg(args, char *);
|
||||
if (max < 0)
|
||||
max = maxlen; /* ie, no max */
|
||||
fmtstr(buffer, &currlen, maxlen, strvalue,
|
||||
min, max, flags);
|
||||
break;
|
||||
case 'p':
|
||||
value = (long)va_arg(args, void *);
|
||||
fmtint(buffer, &currlen, maxlen,
|
||||
value, 16, min, max, flags);
|
||||
break;
|
||||
case 'n':
|
||||
/* XXX */
|
||||
if (cflags == DP_C_SHORT) {
|
||||
short int *num;
|
||||
num = va_arg(args, short int *);
|
||||
*num = currlen;
|
||||
} else if (cflags == DP_C_LONG) { /* XXX */
|
||||
long int *num;
|
||||
num = va_arg(args, long int *);
|
||||
*num = (long int) currlen;
|
||||
} else if (cflags == DP_C_LLONG) { /* XXX */
|
||||
LLONG *num;
|
||||
num = va_arg(args, LLONG *);
|
||||
*num = (LLONG) currlen;
|
||||
} else {
|
||||
int *num;
|
||||
num = va_arg(args, int *);
|
||||
*num = currlen;
|
||||
}
|
||||
break;
|
||||
case '%':
|
||||
dopr_outch(buffer, &currlen, maxlen, ch);
|
||||
break;
|
||||
case 'w':
|
||||
/* not supported yet, treat as next char */
|
||||
ch = *format++;
|
||||
break;
|
||||
default:
|
||||
/* Unknown, skip */
|
||||
break;
|
||||
}
|
||||
ch = *format++;
|
||||
state = DP_S_DEFAULT;
|
||||
flags = cflags = min = 0;
|
||||
max = -1;
|
||||
break;
|
||||
case DP_S_DONE:
|
||||
break;
|
||||
default:
|
||||
/* hmm? */
|
||||
break; /* some picky compilers need this */
|
||||
}
|
||||
}
|
||||
if (currlen >= maxlen - 1)
|
||||
currlen = maxlen - 1;
|
||||
buffer[currlen] = '\0';
|
||||
*retlen = currlen;
|
||||
}
|
||||
|
||||
static void
|
||||
fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value,
|
||||
int min, int max, int flags)
|
||||
{
|
||||
int padlen, strln; /* amount to pad */
|
||||
int cnt = 0;
|
||||
|
||||
if (value == 0) {
|
||||
value = "<NULL>";
|
||||
}
|
||||
for (strln = 0; value[strln]; ++strln)
|
||||
; /* strlen */
|
||||
padlen = min - strln;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justify */
|
||||
|
||||
while ((padlen > 0) && (cnt < max)) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
++cnt;
|
||||
}
|
||||
while (*value && (cnt < max)) {
|
||||
dopr_outch(buffer, currlen, maxlen, *value++);
|
||||
++cnt;
|
||||
}
|
||||
while ((padlen < 0) && (cnt < max)) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
++cnt;
|
||||
}
|
||||
}
|
||||
/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
|
||||
|
||||
static void
|
||||
fmtint(char *buffer, size_t *currlen, size_t maxlen, LLONG value, int base,
|
||||
int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
unsigned LLONG uvalue;
|
||||
char convert[20];
|
||||
int place = 0;
|
||||
int spadlen = 0; /* amount to space pad */
|
||||
int zpadlen = 0; /* amount to zero pad */
|
||||
int caps = 0;
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
uvalue = value;
|
||||
|
||||
if (!(flags & DP_F_UNSIGNED)) {
|
||||
if (value < 0) {
|
||||
signvalue = '-';
|
||||
uvalue = -value;
|
||||
} else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
}
|
||||
if (flags & DP_F_UP)
|
||||
caps = 1; /* Should characters be upper case? */
|
||||
|
||||
do {
|
||||
convert[place++] =
|
||||
(caps ? "0123456789ABCDEF" : "0123456789abcdef")
|
||||
[uvalue % (unsigned) base];
|
||||
uvalue = (uvalue / (unsigned) base);
|
||||
} while (uvalue && (place < 20));
|
||||
if (place == 20)
|
||||
place--;
|
||||
convert[place] = 0;
|
||||
|
||||
zpadlen = max - place;
|
||||
spadlen = min - MAX(max, place) - (signvalue ? 1 : 0);
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (spadlen < 0)
|
||||
spadlen = 0;
|
||||
if (flags & DP_F_ZERO) {
|
||||
zpadlen = MAX(zpadlen, spadlen);
|
||||
spadlen = 0;
|
||||
}
|
||||
if (flags & DP_F_MINUS)
|
||||
spadlen = -spadlen; /* Left Justifty */
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
|
||||
zpadlen, spadlen, min, max, place);
|
||||
#endif
|
||||
|
||||
/* Spaces */
|
||||
while (spadlen > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
--spadlen;
|
||||
}
|
||||
|
||||
/* Sign */
|
||||
if (signvalue)
|
||||
dopr_outch(buffer, currlen, maxlen, signvalue);
|
||||
|
||||
/* Zeros */
|
||||
if (zpadlen > 0) {
|
||||
while (zpadlen > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
}
|
||||
/* Digits */
|
||||
while (place > 0)
|
||||
dopr_outch(buffer, currlen, maxlen, convert[--place]);
|
||||
|
||||
/* Left Justified spaces */
|
||||
while (spadlen < 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
++spadlen;
|
||||
}
|
||||
}
|
||||
|
||||
static LDOUBLE
|
||||
abs_val(LDOUBLE value)
|
||||
{
|
||||
LDOUBLE result = value;
|
||||
|
||||
if (value < 0)
|
||||
result = -value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static LDOUBLE
|
||||
pow10(int exp)
|
||||
{
|
||||
LDOUBLE result = 1;
|
||||
|
||||
while (exp) {
|
||||
result *= 10;
|
||||
exp--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static long
|
||||
round(LDOUBLE value)
|
||||
{
|
||||
long intpart;
|
||||
|
||||
intpart = (long) value;
|
||||
value = value - intpart;
|
||||
if (value >= 0.5)
|
||||
intpart++;
|
||||
|
||||
return intpart;
|
||||
}
|
||||
|
||||
static void
|
||||
fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue,
|
||||
int min, int max, int flags)
|
||||
{
|
||||
int signvalue = 0;
|
||||
LDOUBLE ufvalue;
|
||||
char iconvert[20];
|
||||
char fconvert[20];
|
||||
int iplace = 0;
|
||||
int fplace = 0;
|
||||
int padlen = 0; /* amount to pad */
|
||||
int zpadlen = 0;
|
||||
int caps = 0;
|
||||
long intpart;
|
||||
long fracpart;
|
||||
|
||||
/* AIX manpage says the default is 0, but Solaris says the default is
|
||||
* 6, and sprintf on AIX defaults to 6 */
|
||||
if (max < 0)
|
||||
max = 6;
|
||||
|
||||
ufvalue = abs_val(fvalue);
|
||||
|
||||
if (fvalue < 0)
|
||||
signvalue = '-';
|
||||
else if (flags & DP_F_PLUS) /* Do a sign (+/i) */
|
||||
signvalue = '+';
|
||||
else if (flags & DP_F_SPACE)
|
||||
signvalue = ' ';
|
||||
|
||||
#if 0
|
||||
if (flags & DP_F_UP)
|
||||
caps = 1; /* Should characters be upper case? */
|
||||
#endif
|
||||
|
||||
intpart = (long) ufvalue;
|
||||
|
||||
/* Sorry, we only support 9 digits past the decimal because of our
|
||||
* conversion method */
|
||||
if (max > 9)
|
||||
max = 9;
|
||||
|
||||
/* We "cheat" by converting the fractional part to integer by
|
||||
* multiplying by a factor of 10 */
|
||||
fracpart = round((pow10(max)) * (ufvalue - intpart));
|
||||
|
||||
if (fracpart >= pow10(max)) {
|
||||
intpart++;
|
||||
fracpart -= pow10(max);
|
||||
}
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
printf("fmtfp: %g %d.%d min=%d max=%d\n",
|
||||
(double) fvalue, intpart, fracpart, min, max);
|
||||
#endif
|
||||
|
||||
/* Convert integer part */
|
||||
do {
|
||||
iconvert[iplace++] =
|
||||
(caps ? "0123456789ABCDEF"
|
||||
: "0123456789abcdef")[intpart % 10];
|
||||
intpart = (intpart / 10);
|
||||
} while (intpart && (iplace < 20));
|
||||
if (iplace == 20)
|
||||
iplace--;
|
||||
iconvert[iplace] = 0;
|
||||
|
||||
/* Convert fractional part */
|
||||
do {
|
||||
fconvert[fplace++] =
|
||||
(caps ? "0123456789ABCDEF"
|
||||
: "0123456789abcdef")[fracpart % 10];
|
||||
fracpart = (fracpart / 10);
|
||||
} while (fracpart && (fplace < 20));
|
||||
if (fplace == 20)
|
||||
fplace--;
|
||||
fconvert[fplace] = 0;
|
||||
|
||||
/* -1 for decimal point, another -1 if we are printing a sign */
|
||||
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
|
||||
zpadlen = max - fplace;
|
||||
if (zpadlen < 0)
|
||||
zpadlen = 0;
|
||||
if (padlen < 0)
|
||||
padlen = 0;
|
||||
if (flags & DP_F_MINUS)
|
||||
padlen = -padlen; /* Left Justifty */
|
||||
|
||||
if ((flags & DP_F_ZERO) && (padlen > 0)) {
|
||||
if (signvalue) {
|
||||
dopr_outch(buffer, currlen, maxlen, signvalue);
|
||||
--padlen;
|
||||
signvalue = 0;
|
||||
}
|
||||
while (padlen > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, '0');
|
||||
--padlen;
|
||||
}
|
||||
}
|
||||
while (padlen > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
--padlen;
|
||||
}
|
||||
if (signvalue)
|
||||
dopr_outch(buffer, currlen, maxlen, signvalue);
|
||||
|
||||
while (iplace > 0)
|
||||
dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
|
||||
|
||||
|
||||
#ifdef DEBUG_SNPRINTF
|
||||
printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Decimal point. This should probably use locale to find the correct
|
||||
* char to print out.
|
||||
*/
|
||||
if (max > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, '.');
|
||||
|
||||
while (fplace > 0)
|
||||
dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
|
||||
}
|
||||
while (zpadlen > 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, '0');
|
||||
--zpadlen;
|
||||
}
|
||||
|
||||
while (padlen < 0) {
|
||||
dopr_outch(buffer, currlen, maxlen, ' ');
|
||||
++padlen;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dopr_outch(char *buffer, size_t *currlen, size_t maxlen, int c)
|
||||
{
|
||||
if (*currlen < maxlen)
|
||||
buffer[(*currlen)++] = (char)c;
|
||||
}
|
||||
|
||||
int
|
||||
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
|
||||
{
|
||||
size_t retlen;
|
||||
|
||||
str[0] = 0;
|
||||
dopr(str, count, &retlen, fmt, args);
|
||||
return (retlen);
|
||||
}
|
||||
|
||||
/* VARARGS3 */
|
||||
int
|
||||
snprintf(char *str, size_t count, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv;
|
||||
|
||||
va_start(ap, fmt);
|
||||
rv = vsnprintf(str, count, fmt, ap);
|
||||
va_end(ap);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
#ifdef TEST_SNPRINTF
|
||||
#ifndef LONG_STRING
|
||||
#define LONG_STRING 1024
|
||||
#endif
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char buf1[LONG_STRING];
|
||||
char buf2[LONG_STRING];
|
||||
char *fp_fmt[] = {
|
||||
"%-1.5f",
|
||||
"%1.5f",
|
||||
"%123.9f",
|
||||
"%10.5f",
|
||||
"% 10.5f",
|
||||
"%+22.9f",
|
||||
"%+4.9f",
|
||||
"%01.3f",
|
||||
"%4f",
|
||||
"%3.1f",
|
||||
"%3.2f",
|
||||
"%.0f",
|
||||
"%.1f",
|
||||
NULL
|
||||
};
|
||||
double fp_nums[] = {
|
||||
-1.5, 134.21, 91340.2, 341.1234, 0203.9,
|
||||
0.96, 0.996, 0.9996, 1.996, 4.136,
|
||||
0
|
||||
};
|
||||
char *int_fmt[] = {
|
||||
"%-1.5d",
|
||||
"%1.5d",
|
||||
"%123.9d",
|
||||
"%5.5d",
|
||||
"%10.5d",
|
||||
"% 10.5d",
|
||||
"%+22.33d",
|
||||
"%01.3d",
|
||||
"%4d",
|
||||
#if defined(HAVE_LONG_LONG_INT)
|
||||
"%12lld",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
LLONG int_nums[] = {
|
||||
-1, 134, 91340, 341, 0203,
|
||||
4294967290,
|
||||
4294967297,
|
||||
0
|
||||
};
|
||||
int x, y;
|
||||
int fail = 0;
|
||||
int num = 0;
|
||||
int len;
|
||||
|
||||
printf("Testing snprintf format codes against system sprintf...\n");
|
||||
|
||||
for (x = 0; fp_fmt[x] != NULL; x++) {
|
||||
printf("testing %s\n", fp_fmt[x]);
|
||||
for (y = 0; fp_nums[y] != 0; y++) {
|
||||
snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
|
||||
sprintf(buf2, fp_fmt[x], fp_nums[y]);
|
||||
if (strcmp(buf1, buf2)) {
|
||||
printf("snprintf doesn't match Format: %s\n",
|
||||
fp_fmt[x]);
|
||||
printf("\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; int_fmt[x] != NULL; x++) {
|
||||
printf("testing %s\n", int_fmt[x]);
|
||||
for (y = 0; int_nums[y] != 0; y++) {
|
||||
len = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
|
||||
printf("got %d >%s< (%d)\n", len, buf1, (int)strlen(buf1));
|
||||
sprintf(buf2, int_fmt[x], int_nums[y]);
|
||||
if (strcmp(buf1, buf2)) {
|
||||
printf("snprintf doesn't match Format: %s\n",
|
||||
int_fmt[x]);
|
||||
printf("\tsnprintf = %s\n\tsprintf = %s\n",
|
||||
buf1, buf2);
|
||||
fail++;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
printf("%d tests failed out of %d.\n", fail, num);
|
||||
exit(0);
|
||||
}
|
||||
#endif /* TEST_SNPRINTF */
|
46
libnetbsd/strdup.c
Normal file
46
libnetbsd/strdup.c
Normal file
@ -0,0 +1,46 @@
|
||||
/* $NetBSD: strdup.c,v 1.4 2005/05/16 06:40:04 lukem Exp $ */
|
||||
/* from NetBSD: strdup.c,v 1.13 2003/08/07 16:43:50 agc Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
char *
|
||||
strdup(const char *str)
|
||||
{
|
||||
size_t len;
|
||||
char *copy;
|
||||
|
||||
len = strlen(str) + 1;
|
||||
if (!(copy = malloc(len)))
|
||||
return (NULL);
|
||||
memcpy(copy, str, len);
|
||||
return (copy);
|
||||
}
|
19
libnetbsd/strerror.c
Normal file
19
libnetbsd/strerror.c
Normal file
@ -0,0 +1,19 @@
|
||||
/* $NetBSD: strerror.c,v 1.3 2005/05/11 01:01:56 lukem Exp $ */
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
char *
|
||||
strerror(int n)
|
||||
{
|
||||
static char msg[] = "Unknown error (1234567890)";
|
||||
|
||||
extern int sys_nerr;
|
||||
extern char *sys_errlist[];
|
||||
|
||||
if (n >= sys_nerr) {
|
||||
snprintf(msg, sizeof(msg), "Unknown error (%d)", n);
|
||||
return(msg);
|
||||
} else {
|
||||
return(sys_errlist[n]);
|
||||
}
|
||||
}
|
56
libnetbsd/strlcat.c
Normal file
56
libnetbsd/strlcat.c
Normal file
@ -0,0 +1,56 @@
|
||||
/* $NetBSD: strlcat.c,v 1.4 2005/05/16 06:55:48 lukem Exp $ */
|
||||
/* from NetBSD: strlcat.c,v 1.16 2003/10/27 00:12:42 lukem Exp */
|
||||
/* from OpenBSD: strlcat.c,v 1.10 2003/04/12 21:56:39 millert Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
|
||||
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
||||
* If retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
52
libnetbsd/strlcpy.c
Normal file
52
libnetbsd/strlcpy.c
Normal file
@ -0,0 +1,52 @@
|
||||
/* $NetBSD: strlcpy.c,v 1.4 2005/05/16 06:58:06 lukem Exp $ */
|
||||
/* from NetBSD: strlcpy.c,v 1.14 2003/10/27 00:12:42 lukem Exp */
|
||||
/* from OpenBSD: strlcpy.c,v 1.7 2003/04/12 21:56:39 millert Exp */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND TODD C. MILLER DISCLAIMS ALL
|
||||
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL TODD C. MILLER BE LIABLE
|
||||
* FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
char *d = dst;
|
||||
const char *s = src;
|
||||
size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
388
libnetbsd/strptime.c
Normal file
388
libnetbsd/strptime.c
Normal file
@ -0,0 +1,388 @@
|
||||
/* $NetBSD: strptime.c,v 1.5 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: strptime.c,v 1.18 1999/04/29 02:58:30 tv Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code was contributed to The NetBSD Foundation by Klaus Klein.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* We do not implement alternate representations. However, we always
|
||||
* check whether a given modifier is allowed for a certain conversion.
|
||||
*/
|
||||
#define ALT_E 0x01
|
||||
#define ALT_O 0x02
|
||||
#define LEGAL_ALT(x) { if (alt_format & ~(x)) return (0); }
|
||||
|
||||
|
||||
static int conv_num(const char **, int *, int, int);
|
||||
|
||||
static const char *day[7] = {
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
|
||||
"Friday", "Saturday"
|
||||
};
|
||||
static const char *abday[7] = {
|
||||
"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
|
||||
};
|
||||
static const char *mon[12] = {
|
||||
"January", "February", "March", "April", "May", "June", "July",
|
||||
"August", "September", "October", "November", "December"
|
||||
};
|
||||
static const char *abmon[12] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
||||
};
|
||||
static const char *am_pm[2] = {
|
||||
"AM", "PM"
|
||||
};
|
||||
|
||||
|
||||
char *
|
||||
strptime(const char *buf, const char *fmt, struct tm *tm)
|
||||
{
|
||||
char c;
|
||||
const char *bp;
|
||||
size_t len = 0;
|
||||
int alt_format, i, split_year = 0;
|
||||
|
||||
bp = buf;
|
||||
|
||||
while ((c = *fmt) != '\0') {
|
||||
/* Clear `alternate' modifier prior to new conversion. */
|
||||
alt_format = 0;
|
||||
|
||||
/* Eat up white-space. */
|
||||
if (isspace(c)) {
|
||||
while (isspace(*bp))
|
||||
bp++;
|
||||
|
||||
fmt++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((c = *fmt++) != '%')
|
||||
goto literal;
|
||||
|
||||
|
||||
again: switch (c = *fmt++) {
|
||||
case '%': /* "%%" is converted to "%". */
|
||||
literal:
|
||||
if (c != *bp++)
|
||||
return (0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* "Alternative" modifiers. Just set the appropriate flag
|
||||
* and start over again.
|
||||
*/
|
||||
case 'E': /* "%E?" alternative conversion modifier. */
|
||||
LEGAL_ALT(0);
|
||||
alt_format |= ALT_E;
|
||||
goto again;
|
||||
|
||||
case 'O': /* "%O?" alternative conversion modifier. */
|
||||
LEGAL_ALT(0);
|
||||
alt_format |= ALT_O;
|
||||
goto again;
|
||||
|
||||
/*
|
||||
* "Complex" conversion rules, implemented through recursion.
|
||||
*/
|
||||
case 'c': /* Date and time, using the locale's format. */
|
||||
LEGAL_ALT(ALT_E);
|
||||
if (!(bp = strptime(bp, "%x %X", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'D': /* The date as "%m/%d/%y". */
|
||||
LEGAL_ALT(0);
|
||||
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'R': /* The time as "%H:%M". */
|
||||
LEGAL_ALT(0);
|
||||
if (!(bp = strptime(bp, "%H:%M", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'r': /* The time in 12-hour clock representation. */
|
||||
LEGAL_ALT(0);
|
||||
if (!(bp = strptime(bp, "%I:%M:%S %p", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'T': /* The time as "%H:%M:%S". */
|
||||
LEGAL_ALT(0);
|
||||
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'X': /* The time, using the locale's format. */
|
||||
LEGAL_ALT(ALT_E);
|
||||
if (!(bp = strptime(bp, "%H:%M:%S", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'x': /* The date, using the locale's format. */
|
||||
LEGAL_ALT(ALT_E);
|
||||
if (!(bp = strptime(bp, "%m/%d/%y", tm)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
/*
|
||||
* "Elementary" conversion rules.
|
||||
*/
|
||||
case 'A': /* The day of week, using the locale's form. */
|
||||
case 'a':
|
||||
LEGAL_ALT(0);
|
||||
for (i = 0; i < 7; i++) {
|
||||
/* Full name. */
|
||||
len = strlen(day[i]);
|
||||
if (strncasecmp(day[i], bp, len) == 0)
|
||||
break;
|
||||
|
||||
/* Abbreviated name. */
|
||||
len = strlen(abday[i]);
|
||||
if (strncasecmp(abday[i], bp, len) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Nothing matched. */
|
||||
if (i == 7)
|
||||
return (0);
|
||||
|
||||
tm->tm_wday = i;
|
||||
bp += len;
|
||||
break;
|
||||
|
||||
case 'B': /* The month, using the locale's form. */
|
||||
case 'b':
|
||||
case 'h':
|
||||
LEGAL_ALT(0);
|
||||
for (i = 0; i < 12; i++) {
|
||||
/* Full name. */
|
||||
len = strlen(mon[i]);
|
||||
if (strncasecmp(mon[i], bp, len) == 0)
|
||||
break;
|
||||
|
||||
/* Abbreviated name. */
|
||||
len = strlen(abmon[i]);
|
||||
if (strncasecmp(abmon[i], bp, len) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* Nothing matched. */
|
||||
if (i == 12)
|
||||
return (0);
|
||||
|
||||
tm->tm_mon = i;
|
||||
bp += len;
|
||||
break;
|
||||
|
||||
case 'C': /* The century number. */
|
||||
LEGAL_ALT(ALT_E);
|
||||
if (!(conv_num(&bp, &i, 0, 99)))
|
||||
return (0);
|
||||
|
||||
if (split_year) {
|
||||
tm->tm_year = (tm->tm_year % 100) + (i * 100);
|
||||
} else {
|
||||
tm->tm_year = i * 100;
|
||||
split_year = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd': /* The day of month. */
|
||||
case 'e':
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_mday, 1, 31)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'k': /* The hour (24-hour clock representation). */
|
||||
LEGAL_ALT(0);
|
||||
/* FALLTHROUGH */
|
||||
case 'H':
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_hour, 0, 23)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'l': /* The hour (12-hour clock representation). */
|
||||
LEGAL_ALT(0);
|
||||
/* FALLTHROUGH */
|
||||
case 'I':
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_hour, 1, 12)))
|
||||
return (0);
|
||||
if (tm->tm_hour == 12)
|
||||
tm->tm_hour = 0;
|
||||
break;
|
||||
|
||||
case 'j': /* The day of year. */
|
||||
LEGAL_ALT(0);
|
||||
if (!(conv_num(&bp, &i, 1, 366)))
|
||||
return (0);
|
||||
tm->tm_yday = i - 1;
|
||||
break;
|
||||
|
||||
case 'M': /* The minute. */
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_min, 0, 59)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'm': /* The month. */
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &i, 1, 12)))
|
||||
return (0);
|
||||
tm->tm_mon = i - 1;
|
||||
break;
|
||||
|
||||
case 'p': /* The locale's equivalent of AM/PM. */
|
||||
LEGAL_ALT(0);
|
||||
/* AM? */
|
||||
len = strlen(am_pm[0]);
|
||||
if (strncasecmp(am_pm[0], bp, len) == 0) {
|
||||
if (tm->tm_hour > 11)
|
||||
return (0);
|
||||
|
||||
bp += len;
|
||||
break;
|
||||
}
|
||||
|
||||
/* PM? */
|
||||
len = strlen(am_pm[1]);
|
||||
if (strncasecmp(am_pm[1], bp, len) == 0) {
|
||||
if (tm->tm_hour > 11)
|
||||
return (0);
|
||||
|
||||
tm->tm_hour += 12;
|
||||
bp += len;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Nothing matched. */
|
||||
return (0);
|
||||
|
||||
case 'S': /* The seconds. */
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_sec, 0, 61)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'U': /* The week of year, beginning on sunday. */
|
||||
case 'W': /* The week of year, beginning on monday. */
|
||||
LEGAL_ALT(ALT_O);
|
||||
/*
|
||||
* XXX This is bogus, as we can not assume any valid
|
||||
* information present in the tm structure at this
|
||||
* point to calculate a real value, so just check the
|
||||
* range for now.
|
||||
*/
|
||||
if (!(conv_num(&bp, &i, 0, 53)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'w': /* The day of week, beginning on sunday. */
|
||||
LEGAL_ALT(ALT_O);
|
||||
if (!(conv_num(&bp, &tm->tm_wday, 0, 6)))
|
||||
return (0);
|
||||
break;
|
||||
|
||||
case 'Y': /* The year. */
|
||||
LEGAL_ALT(ALT_E);
|
||||
if (!(conv_num(&bp, &i, 0, 9999)))
|
||||
return (0);
|
||||
|
||||
tm->tm_year = i - TM_YEAR_BASE;
|
||||
break;
|
||||
|
||||
case 'y': /* The year within 100 years of the epoch. */
|
||||
LEGAL_ALT(ALT_E | ALT_O);
|
||||
if (!(conv_num(&bp, &i, 0, 99)))
|
||||
return (0);
|
||||
|
||||
if (split_year) {
|
||||
tm->tm_year = ((tm->tm_year / 100) * 100) + i;
|
||||
break;
|
||||
}
|
||||
split_year = 1;
|
||||
if (i <= 68)
|
||||
tm->tm_year = i + 2000 - TM_YEAR_BASE;
|
||||
else
|
||||
tm->tm_year = i + 1900 - TM_YEAR_BASE;
|
||||
break;
|
||||
|
||||
/*
|
||||
* Miscellaneous conversions.
|
||||
*/
|
||||
case 'n': /* Any kind of white-space. */
|
||||
case 't':
|
||||
LEGAL_ALT(0);
|
||||
while (isspace(*bp))
|
||||
bp++;
|
||||
break;
|
||||
|
||||
|
||||
default: /* Unknown/unsupported conversion. */
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* LINTED functional specification */
|
||||
return ((char *)bp);
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
conv_num(const char **buf, int *dest, int llim, int ulim)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
/* The limit also determines the number of valid digits. */
|
||||
int rulim = ulim;
|
||||
|
||||
if (**buf < '0' || **buf > '9')
|
||||
return (0);
|
||||
|
||||
do {
|
||||
result *= 10;
|
||||
result += *(*buf)++ - '0';
|
||||
rulim /= 10;
|
||||
} while ((result * 10 <= ulim) && rulim && **buf >= '0' && **buf <= '9');
|
||||
|
||||
if (result < llim || result > ulim)
|
||||
return (0);
|
||||
|
||||
*dest = result;
|
||||
return (1);
|
||||
}
|
71
libnetbsd/strsep.c
Normal file
71
libnetbsd/strsep.c
Normal file
@ -0,0 +1,71 @@
|
||||
/* $NetBSD: strsep.c,v 1.4 2005/05/16 08:51:51 lukem Exp $ */
|
||||
/* from NetBSD: strsep.c,v 1.14 2003/08/07 16:43:52 agc Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* Get next token from string *stringp, where tokens are possibly-empty
|
||||
* strings separated by characters from delim.
|
||||
*
|
||||
* Writes NULs into the string at *stringp to end tokens.
|
||||
* delim need not remain constant from call to call.
|
||||
* On return, *stringp points past the last NUL written (if there might
|
||||
* be further tokens), or is NULL (if there are definitely no more tokens).
|
||||
*
|
||||
* If *stringp is NULL, strsep returns NULL.
|
||||
*/
|
||||
char *
|
||||
strsep(char **stringp, const char *delim)
|
||||
{
|
||||
char *s;
|
||||
const char *spanp;
|
||||
int c, sc;
|
||||
char *tok;
|
||||
|
||||
if ((s = *stringp) == NULL)
|
||||
return (NULL);
|
||||
for (tok = s;;) {
|
||||
c = *s++;
|
||||
spanp = delim;
|
||||
do {
|
||||
if ((sc = *spanp++) == c) {
|
||||
if (c == 0)
|
||||
s = NULL;
|
||||
else
|
||||
s[-1] = 0;
|
||||
*stringp = s;
|
||||
return (tok);
|
||||
}
|
||||
} while (sc != 0);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
148
libnetbsd/strtoll.c
Normal file
148
libnetbsd/strtoll.c
Normal file
@ -0,0 +1,148 @@
|
||||
/* $NetBSD: strtoll.c,v 1.4 2005/05/16 11:27:58 lukem Exp $ */
|
||||
/* from NetBSD: strtoll.c,v 1.6 2003/10/27 00:12:42 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* Convert a string to a long long integer.
|
||||
*
|
||||
* Ignores `locale' stuff. Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
long long int
|
||||
strtoll(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s;
|
||||
/* LONGLONG */
|
||||
long long int acc, cutoff;
|
||||
int c;
|
||||
int neg, any, cutlim;
|
||||
|
||||
/* endptr may be NULL */
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* This outrageous construct just to shut up a GCC warning. */
|
||||
(void) &acc; (void) &cutoff;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
s = nptr;
|
||||
do {
|
||||
c = (unsigned char) *s++;
|
||||
} while (isspace(c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == '+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X')) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
|
||||
/*
|
||||
* Compute the cutoff value between legal numbers and illegal
|
||||
* numbers. That is the largest legal value, divided by the
|
||||
* base. An input number that is greater than this value, if
|
||||
* followed by a legal input character, is too big. One that
|
||||
* is equal to this value may be valid or not; the limit
|
||||
* between valid and invalid numbers is then based on the last
|
||||
* digit. For instance, if the range for long longs is
|
||||
* [-9223372036854775808..9223372036854775807] and the input base
|
||||
* is 10, cutoff will be set to 922337203685477580 and cutlim to
|
||||
* either 7 (neg==0) or 8 (neg==1), meaning that if we have
|
||||
* accumulated a value > 922337203685477580, or equal but the
|
||||
* next digit is > 7 (or 8), the number is too big, and we will
|
||||
* return a range error.
|
||||
*
|
||||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
cutoff = neg ? LLONG_MIN : LLONG_MAX;
|
||||
cutlim = (int)(cutoff % base);
|
||||
cutoff /= base;
|
||||
if (neg) {
|
||||
if (cutlim > 0) {
|
||||
cutlim -= base;
|
||||
cutoff += 1;
|
||||
}
|
||||
cutlim = -cutlim;
|
||||
}
|
||||
for (acc = 0, any = 0;; c = (unsigned char) *s++) {
|
||||
if (isdigit(c))
|
||||
c -= '0';
|
||||
else if (isalpha(c))
|
||||
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
|
||||
else
|
||||
break;
|
||||
if (c >= base)
|
||||
break;
|
||||
if (any < 0)
|
||||
continue;
|
||||
if (neg) {
|
||||
if (acc < cutoff || (acc == cutoff && c > cutlim)) {
|
||||
any = -1;
|
||||
acc = LLONG_MIN;
|
||||
errno = ERANGE;
|
||||
} else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc -= c;
|
||||
}
|
||||
} else {
|
||||
if (acc > cutoff || (acc == cutoff && c > cutlim)) {
|
||||
any = -1;
|
||||
acc = LLONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else {
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (endptr != 0)
|
||||
/* LINTED interface specification */
|
||||
*endptr = (char *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
272
libnetbsd/strunvis.c
Normal file
272
libnetbsd/strunvis.c
Normal file
@ -0,0 +1,272 @@
|
||||
/* $NetBSD: strunvis.c,v 1.5 2005/06/01 11:48:49 lukem Exp $ */
|
||||
/* from NetBSD: unvis.c,v 1.27 2005/05/16 11:42:04 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1989, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* decode driven by state machine
|
||||
*/
|
||||
#define S_GROUND 0 /* haven't seen escape char */
|
||||
#define S_START 1 /* start decoding special sequence */
|
||||
#define S_META 2 /* metachar started (M) */
|
||||
#define S_META1 3 /* metachar more, regular char (-) */
|
||||
#define S_CTRL 4 /* control char started (^) */
|
||||
#define S_OCTAL2 5 /* octal digit 2 */
|
||||
#define S_OCTAL3 6 /* octal digit 3 */
|
||||
#define S_HEX1 7 /* hex digit */
|
||||
#define S_HEX2 8 /* hex digit 2 */
|
||||
|
||||
#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
|
||||
#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10))
|
||||
|
||||
/*
|
||||
* unvis - decode characters previously encoded by vis
|
||||
*/
|
||||
int
|
||||
unvis(char *cp, int c, int *astate, int flag)
|
||||
{
|
||||
unsigned char uc = (unsigned char)c;
|
||||
|
||||
if (flag & UNVIS_END) {
|
||||
if (*astate == S_OCTAL2 || *astate == S_OCTAL3
|
||||
|| *astate == S_HEX2) {
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
}
|
||||
return (*astate == S_GROUND ? UNVIS_NOCHAR : UNVIS_SYNBAD);
|
||||
}
|
||||
|
||||
switch (*astate) {
|
||||
|
||||
case S_GROUND:
|
||||
*cp = 0;
|
||||
if (c == '\\') {
|
||||
*astate = S_START;
|
||||
return (0);
|
||||
}
|
||||
if ((flag & VIS_HTTPSTYLE) && c == '%') {
|
||||
*astate = S_HEX1;
|
||||
return (0);
|
||||
}
|
||||
*cp = c;
|
||||
return (UNVIS_VALID);
|
||||
|
||||
case S_START:
|
||||
switch(c) {
|
||||
case '\\':
|
||||
*cp = c;
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case '0': case '1': case '2': case '3':
|
||||
case '4': case '5': case '6': case '7':
|
||||
*cp = (c - '0');
|
||||
*astate = S_OCTAL2;
|
||||
return (0);
|
||||
case 'M':
|
||||
*cp = (char)0200;
|
||||
*astate = S_META;
|
||||
return (0);
|
||||
case '^':
|
||||
*astate = S_CTRL;
|
||||
return (0);
|
||||
case 'n':
|
||||
*cp = '\n';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'r':
|
||||
*cp = '\r';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'b':
|
||||
*cp = '\b';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'a':
|
||||
*cp = '\007';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'v':
|
||||
*cp = '\v';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 't':
|
||||
*cp = '\t';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'f':
|
||||
*cp = '\f';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 's':
|
||||
*cp = ' ';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case 'E':
|
||||
*cp = '\033';
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
case '\n':
|
||||
/*
|
||||
* hidden newline
|
||||
*/
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_NOCHAR);
|
||||
case '$':
|
||||
/*
|
||||
* hidden marker
|
||||
*/
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_NOCHAR);
|
||||
}
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_SYNBAD);
|
||||
|
||||
case S_META:
|
||||
if (c == '-')
|
||||
*astate = S_META1;
|
||||
else if (c == '^')
|
||||
*astate = S_CTRL;
|
||||
else {
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_SYNBAD);
|
||||
}
|
||||
return (0);
|
||||
|
||||
case S_META1:
|
||||
*astate = S_GROUND;
|
||||
*cp |= c;
|
||||
return (UNVIS_VALID);
|
||||
|
||||
case S_CTRL:
|
||||
if (c == '?')
|
||||
*cp |= 0177;
|
||||
else
|
||||
*cp |= c & 037;
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALID);
|
||||
|
||||
case S_OCTAL2: /* second possible octal digit */
|
||||
if (isoctal(uc)) {
|
||||
/*
|
||||
* yes - and maybe a third
|
||||
*/
|
||||
*cp = (*cp << 3) + (c - '0');
|
||||
*astate = S_OCTAL3;
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* no - done with current sequence, push back passed char
|
||||
*/
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALIDPUSH);
|
||||
|
||||
case S_OCTAL3: /* third possible octal digit */
|
||||
*astate = S_GROUND;
|
||||
if (isoctal(uc)) {
|
||||
*cp = (*cp << 3) + (c - '0');
|
||||
return (UNVIS_VALID);
|
||||
}
|
||||
/*
|
||||
* we were done, push back passed char
|
||||
*/
|
||||
return (UNVIS_VALIDPUSH);
|
||||
|
||||
case S_HEX1:
|
||||
if (isxdigit(uc)) {
|
||||
*cp = xtod(uc);
|
||||
*astate = S_HEX2;
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
* no - done with current sequence, push back passed char
|
||||
*/
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_VALIDPUSH);
|
||||
|
||||
case S_HEX2:
|
||||
*astate = S_GROUND;
|
||||
if (isxdigit(uc)) {
|
||||
*cp = xtod(uc) | (*cp << 4);
|
||||
return (UNVIS_VALID);
|
||||
}
|
||||
return (UNVIS_VALIDPUSH);
|
||||
|
||||
default:
|
||||
/*
|
||||
* decoder in unknown state - (probably uninitialized)
|
||||
*/
|
||||
*astate = S_GROUND;
|
||||
return (UNVIS_SYNBAD);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* strunvis - decode src into dst
|
||||
*
|
||||
* Number of chars decoded into dst is returned, -1 on error.
|
||||
* Dst is null terminated.
|
||||
*/
|
||||
|
||||
int
|
||||
strunvisx(char *dst, const char *src, int flag)
|
||||
{
|
||||
char c;
|
||||
char *start = dst;
|
||||
int state = 0;
|
||||
|
||||
while ((c = *src++) != '\0') {
|
||||
again:
|
||||
switch (unvis(dst, c, &state, flag)) {
|
||||
case UNVIS_VALID:
|
||||
dst++;
|
||||
break;
|
||||
case UNVIS_VALIDPUSH:
|
||||
dst++;
|
||||
goto again;
|
||||
case 0:
|
||||
case UNVIS_NOCHAR:
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (unvis(dst, c, &state, UNVIS_END) == UNVIS_VALID)
|
||||
dst++;
|
||||
*dst = '\0';
|
||||
return (dst - start);
|
||||
}
|
||||
|
||||
int
|
||||
strunvis(char *dst, const char *src)
|
||||
{
|
||||
return strunvisx(dst, src, 0);
|
||||
}
|
346
libnetbsd/strvis.c
Normal file
346
libnetbsd/strvis.c
Normal file
@ -0,0 +1,346 @@
|
||||
/* $NetBSD: strvis.c,v 1.9 2008/04/29 08:13:38 martin Exp $ */
|
||||
/* from NetBSD: vis.c,v 1.33 2005/05/28 13:11:14 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1989, 1993
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2005 The NetBSD Foundation, Inc.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#undef BELL
|
||||
#define BELL '\a'
|
||||
|
||||
#define isoctal(c) (((unsigned char)(c)) >= '0' && ((unsigned char)(c)) <= '7')
|
||||
#define iswhite(c) (c == ' ' || c == '\t' || c == '\n')
|
||||
#define issafe(c) (c == '\b' || c == BELL || c == '\r')
|
||||
#define xtoa(c) "0123456789abcdef"[c]
|
||||
|
||||
#define MAXEXTRAS 5
|
||||
|
||||
|
||||
#define MAKEEXTRALIST(flag, extra, orig) \
|
||||
do { \
|
||||
const char *o = orig; \
|
||||
char *e; \
|
||||
while (*o++) \
|
||||
continue; \
|
||||
extra = malloc((size_t)((o - orig) + MAXEXTRAS)); \
|
||||
if (!extra) break; \
|
||||
for (o = orig, e = extra; (*e++ = *o++) != '\0';) \
|
||||
continue; \
|
||||
e--; \
|
||||
if (flag & VIS_SP) *e++ = ' '; \
|
||||
if (flag & VIS_TAB) *e++ = '\t'; \
|
||||
if (flag & VIS_NL) *e++ = '\n'; \
|
||||
if ((flag & VIS_NOSLASH) == 0) *e++ = '\\'; \
|
||||
*e = '\0'; \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
|
||||
/*
|
||||
* This is HVIS, the macro of vis used to HTTP style (RFC 1808)
|
||||
*/
|
||||
#define HVIS(dst, c, flag, nextc, extra) \
|
||||
do \
|
||||
if (!isascii(c) || !isalnum(c) || strchr("$-_.+!*'(),", c) != NULL) { \
|
||||
*dst++ = '%'; \
|
||||
*dst++ = xtoa(((unsigned int)c >> 4) & 0xf); \
|
||||
*dst++ = xtoa((unsigned int)c & 0xf); \
|
||||
} else { \
|
||||
SVIS(dst, c, flag, nextc, extra); \
|
||||
} \
|
||||
while (/*CONSTCOND*/0)
|
||||
|
||||
/*
|
||||
* This is SVIS, the central macro of vis.
|
||||
* dst: Pointer to the destination buffer
|
||||
* c: Character to encode
|
||||
* flag: Flag word
|
||||
* nextc: The character following 'c'
|
||||
* extra: Pointer to the list of extra characters to be
|
||||
* backslash-protected.
|
||||
*/
|
||||
#define SVIS(dst, c, flag, nextc, extra) \
|
||||
do { \
|
||||
int isextra; \
|
||||
isextra = strchr(extra, c) != NULL; \
|
||||
if (!isextra && isascii(c) && (isgraph(c) || iswhite(c) || \
|
||||
((flag & VIS_SAFE) && issafe(c)))) { \
|
||||
*dst++ = c; \
|
||||
break; \
|
||||
} \
|
||||
if (flag & VIS_CSTYLE) { \
|
||||
switch (c) { \
|
||||
case '\n': \
|
||||
*dst++ = '\\'; *dst++ = 'n'; \
|
||||
continue; \
|
||||
case '\r': \
|
||||
*dst++ = '\\'; *dst++ = 'r'; \
|
||||
continue; \
|
||||
case '\b': \
|
||||
*dst++ = '\\'; *dst++ = 'b'; \
|
||||
continue; \
|
||||
case BELL: \
|
||||
*dst++ = '\\'; *dst++ = 'a'; \
|
||||
continue; \
|
||||
case '\v': \
|
||||
*dst++ = '\\'; *dst++ = 'v'; \
|
||||
continue; \
|
||||
case '\t': \
|
||||
*dst++ = '\\'; *dst++ = 't'; \
|
||||
continue; \
|
||||
case '\f': \
|
||||
*dst++ = '\\'; *dst++ = 'f'; \
|
||||
continue; \
|
||||
case ' ': \
|
||||
*dst++ = '\\'; *dst++ = 's'; \
|
||||
continue; \
|
||||
case '\0': \
|
||||
*dst++ = '\\'; *dst++ = '0'; \
|
||||
if (isoctal(nextc)) { \
|
||||
*dst++ = '0'; \
|
||||
*dst++ = '0'; \
|
||||
} \
|
||||
continue; \
|
||||
default: \
|
||||
if (isgraph(c)) { \
|
||||
*dst++ = '\\'; *dst++ = c; \
|
||||
continue; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) { \
|
||||
*dst++ = '\\'; \
|
||||
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 6) & 03) + '0'; \
|
||||
*dst++ = (unsigned char)(((uint32_t)(unsigned char)c >> 3) & 07) + '0'; \
|
||||
*dst++ = (c & 07) + '0'; \
|
||||
} else { \
|
||||
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\'; \
|
||||
if (c & 0200) { \
|
||||
c &= 0177; *dst++ = 'M'; \
|
||||
} \
|
||||
if (iscntrl(c)) { \
|
||||
*dst++ = '^'; \
|
||||
if (c == 0177) \
|
||||
*dst++ = '?'; \
|
||||
else \
|
||||
*dst++ = c + '@'; \
|
||||
} else { \
|
||||
*dst++ = '-'; *dst++ = c; \
|
||||
} \
|
||||
} \
|
||||
} while (/*CONSTCOND*/0)
|
||||
|
||||
|
||||
/*
|
||||
* svis - visually encode characters, also encoding the characters
|
||||
* pointed to by `extra'
|
||||
*/
|
||||
char *
|
||||
svis(char *dst, int c, int flag, int nextc, const char *extra)
|
||||
{
|
||||
char *nextra = NULL;
|
||||
|
||||
MAKEEXTRALIST(flag, nextra, extra);
|
||||
if (!nextra) {
|
||||
*dst = '\0'; /* can't create nextra, return "" */
|
||||
return dst;
|
||||
}
|
||||
if (flag & VIS_HTTPSTYLE)
|
||||
HVIS(dst, c, flag, nextc, nextra);
|
||||
else
|
||||
SVIS(dst, c, flag, nextc, nextra);
|
||||
free(nextra);
|
||||
*dst = '\0';
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* strsvis, strsvisx - visually encode characters from src into dst
|
||||
*
|
||||
* Extra is a pointer to a \0-terminated list of characters to
|
||||
* be encoded, too. These functions are useful e. g. to
|
||||
* encode strings in such a way so that they are not interpreted
|
||||
* by a shell.
|
||||
*
|
||||
* Dst must be 4 times the size of src to account for possible
|
||||
* expansion. The length of dst, not including the trailing NULL,
|
||||
* is returned.
|
||||
*
|
||||
* Strsvisx encodes exactly len bytes from src into dst.
|
||||
* This is useful for encoding a block of data.
|
||||
*/
|
||||
int
|
||||
strsvis(char *dst, const char *csrc, int flag, const char *extra)
|
||||
{
|
||||
int c;
|
||||
char *start;
|
||||
char *nextra = NULL;
|
||||
const unsigned char *src = (const unsigned char *)csrc;
|
||||
|
||||
MAKEEXTRALIST(flag, nextra, extra);
|
||||
if (!nextra) {
|
||||
*dst = '\0'; /* can't create nextra, return "" */
|
||||
return 0;
|
||||
}
|
||||
if (flag & VIS_HTTPSTYLE) {
|
||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
||||
HVIS(dst, c, flag, *src, nextra);
|
||||
} else {
|
||||
for (start = dst; (c = *src++) != '\0'; /* empty */)
|
||||
SVIS(dst, c, flag, *src, nextra);
|
||||
}
|
||||
free(nextra);
|
||||
*dst = '\0';
|
||||
return (dst - start);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strsvisx(char *dst, const char *csrc, size_t len, int flag, const char *extra)
|
||||
{
|
||||
unsigned char c;
|
||||
char *start;
|
||||
char *nextra = NULL;
|
||||
const unsigned char *src = (const unsigned char *)csrc;
|
||||
|
||||
MAKEEXTRALIST(flag, nextra, extra);
|
||||
if (! nextra) {
|
||||
*dst = '\0'; /* can't create nextra, return "" */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flag & VIS_HTTPSTYLE) {
|
||||
for (start = dst; len > 0; len--) {
|
||||
c = *src++;
|
||||
HVIS(dst, c, flag, len ? *src : '\0', nextra);
|
||||
}
|
||||
} else {
|
||||
for (start = dst; len > 0; len--) {
|
||||
c = *src++;
|
||||
SVIS(dst, c, flag, len ? *src : '\0', nextra);
|
||||
}
|
||||
}
|
||||
free(nextra);
|
||||
*dst = '\0';
|
||||
return (dst - start);
|
||||
}
|
||||
|
||||
/*
|
||||
* vis - visually encode characters
|
||||
*/
|
||||
char *
|
||||
vis(char *dst, int c, int flag, int nextc)
|
||||
{
|
||||
char *extra = NULL;
|
||||
unsigned char uc = (unsigned char)c;
|
||||
|
||||
MAKEEXTRALIST(flag, extra, "");
|
||||
if (! extra) {
|
||||
*dst = '\0'; /* can't create extra, return "" */
|
||||
return dst;
|
||||
}
|
||||
if (flag & VIS_HTTPSTYLE)
|
||||
HVIS(dst, uc, flag, nextc, extra);
|
||||
else
|
||||
SVIS(dst, uc, flag, nextc, extra);
|
||||
free(extra);
|
||||
*dst = '\0';
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* strvis, strvisx - visually encode characters from src into dst
|
||||
*
|
||||
* Dst must be 4 times the size of src to account for possible
|
||||
* expansion. The length of dst, not including the trailing NULL,
|
||||
* is returned.
|
||||
*
|
||||
* Strvisx encodes exactly len bytes from src into dst.
|
||||
* This is useful for encoding a block of data.
|
||||
*/
|
||||
int
|
||||
strvis(char *dst, const char *src, int flag)
|
||||
{
|
||||
char *extra = NULL;
|
||||
int rv;
|
||||
|
||||
MAKEEXTRALIST(flag, extra, "");
|
||||
if (!extra) {
|
||||
*dst = '\0'; /* can't create extra, return "" */
|
||||
return 0;
|
||||
}
|
||||
rv = strsvis(dst, src, flag, extra);
|
||||
free(extra);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
strvisx(char *dst, const char *src, size_t len, int flag)
|
||||
{
|
||||
char *extra = NULL;
|
||||
int rv;
|
||||
|
||||
MAKEEXTRALIST(flag, extra, "");
|
||||
if (!extra) {
|
||||
*dst = '\0'; /* can't create extra, return "" */
|
||||
return 0;
|
||||
}
|
||||
rv = strsvisx(dst, src, len, flag, extra);
|
||||
free(extra);
|
||||
return rv;
|
||||
}
|
120
libnetbsd/timegm.c
Normal file
120
libnetbsd/timegm.c
Normal file
@ -0,0 +1,120 @@
|
||||
/* $NetBSD: timegm.c,v 1.3 2005/05/11 01:01:56 lukem Exp $ */
|
||||
/* from ? */
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
/*
|
||||
* UTC version of mktime(3)
|
||||
*/
|
||||
|
||||
/*
|
||||
* This code is not portable, but works on most Unix-like systems.
|
||||
* If the local timezone has no summer time, using mktime(3) function
|
||||
* and adjusting offset would be usable (adjusting leap seconds
|
||||
* is still required, though), but the assumption is not always true.
|
||||
*
|
||||
* Anyway, no portable and correct implementation of UTC to time_t
|
||||
* conversion exists....
|
||||
*/
|
||||
|
||||
static time_t
|
||||
sub_mkgmt(struct tm *tm)
|
||||
{
|
||||
int y, nleapdays;
|
||||
time_t t;
|
||||
/* days before the month */
|
||||
static const unsigned short moff[12] = {
|
||||
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
|
||||
};
|
||||
|
||||
/*
|
||||
* XXX: This code assumes the given time to be normalized.
|
||||
* Normalizing here is impossible in case the given time is a leap
|
||||
* second but the local time library is ignorant of leap seconds.
|
||||
*/
|
||||
|
||||
/* minimal sanity checking not to access outside of the array */
|
||||
if ((unsigned) tm->tm_mon >= 12)
|
||||
return (time_t) -1;
|
||||
if (tm->tm_year < EPOCH_YEAR - TM_YEAR_BASE)
|
||||
return (time_t) -1;
|
||||
|
||||
y = tm->tm_year + TM_YEAR_BASE - (tm->tm_mon < 2);
|
||||
nleapdays = y / 4 - y / 100 + y / 400 -
|
||||
((EPOCH_YEAR-1) / 4 - (EPOCH_YEAR-1) / 100 + (EPOCH_YEAR-1) / 400);
|
||||
t = ((((time_t) (tm->tm_year - (EPOCH_YEAR - TM_YEAR_BASE)) * 365 +
|
||||
moff[tm->tm_mon] + tm->tm_mday - 1 + nleapdays) * 24 +
|
||||
tm->tm_hour) * 60 + tm->tm_min) * 60 + tm->tm_sec;
|
||||
|
||||
return (t < 0 ? (time_t) -1 : t);
|
||||
}
|
||||
|
||||
time_t
|
||||
timegm(struct tm *tm)
|
||||
{
|
||||
time_t t, t2;
|
||||
struct tm *tm2;
|
||||
int sec;
|
||||
|
||||
/* Do the first guess. */
|
||||
if ((t = sub_mkgmt(tm)) == (time_t) -1)
|
||||
return (time_t) -1;
|
||||
|
||||
/* save value in case *tm is overwritten by gmtime() */
|
||||
sec = tm->tm_sec;
|
||||
|
||||
tm2 = gmtime(&t);
|
||||
if ((t2 = sub_mkgmt(tm2)) == (time_t) -1)
|
||||
return (time_t) -1;
|
||||
|
||||
if (t2 < t || tm2->tm_sec != sec) {
|
||||
/*
|
||||
* Adjust for leap seconds.
|
||||
*
|
||||
* real time_t time
|
||||
* |
|
||||
* tm
|
||||
* / ... (a) first sub_mkgmt() conversion
|
||||
* t
|
||||
* |
|
||||
* tm2
|
||||
* / ... (b) second sub_mkgmt() conversion
|
||||
* t2
|
||||
* --->time
|
||||
*/
|
||||
/*
|
||||
* Do the second guess, assuming (a) and (b) are almost equal.
|
||||
*/
|
||||
t += t - t2;
|
||||
tm2 = gmtime(&t);
|
||||
|
||||
/*
|
||||
* Either (a) or (b), may include one or two extra
|
||||
* leap seconds. Try t, t + 2, t - 2, t + 1, and t - 1.
|
||||
*/
|
||||
if (tm2->tm_sec == sec
|
||||
|| (t += 2, tm2 = gmtime(&t), tm2->tm_sec == sec)
|
||||
|| (t -= 4, tm2 = gmtime(&t), tm2->tm_sec == sec)
|
||||
|| (t += 3, tm2 = gmtime(&t), tm2->tm_sec == sec)
|
||||
|| (t -= 2, tm2 = gmtime(&t), tm2->tm_sec == sec))
|
||||
; /* found */
|
||||
else {
|
||||
/*
|
||||
* Not found.
|
||||
*/
|
||||
if (sec >= 60)
|
||||
/*
|
||||
* The given time is a leap second
|
||||
* (sec 60 or 61), but the time library
|
||||
* is ignorant of the leap second.
|
||||
*/
|
||||
; /* treat sec 60 as 59,
|
||||
sec 61 as 0 of the next minute */
|
||||
else
|
||||
/* The given time may not be normalized. */
|
||||
t++; /* restore t */
|
||||
}
|
||||
}
|
||||
|
||||
return (t < 0 ? (time_t) -1 : t);
|
||||
}
|
48
libnetbsd/usleep.c
Normal file
48
libnetbsd/usleep.c
Normal file
@ -0,0 +1,48 @@
|
||||
/* $NetBSD: usleep.c,v 1.7 2008/04/29 08:13:38 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999,2000,2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Luke Mewburn.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
int
|
||||
usleep(unsigned int usec)
|
||||
{
|
||||
#if defined(HAVE_POLL)
|
||||
return (poll(NULL, 0, usec / 1000));
|
||||
#elif defined(HAVE_SELECT)
|
||||
struct timeval tv;
|
||||
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = usec;
|
||||
return (select(1, NULL, NULL, NULL, &tv));
|
||||
#else
|
||||
# error no way to implement usleep
|
||||
#endif
|
||||
}
|
51
libnetbsd/utimes.c
Normal file
51
libnetbsd/utimes.c
Normal file
@ -0,0 +1,51 @@
|
||||
/* $NetBSD: utimes.c,v 1.4 2008/04/29 08:13:38 martin Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2004 The NetBSD Foundation, Inc.
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Your OS is old, eh?
|
||||
* Emulate utimes(2) using utime(2), but losing sub-second granularity.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <utime.h>
|
||||
|
||||
int
|
||||
utimes(const char *path, const struct timeval *times)
|
||||
{
|
||||
if (times != NULL) {
|
||||
struct utimbuf ut;
|
||||
|
||||
ut.actime = times[0].tv_sec;
|
||||
ut.modtime = times[1].tv_sec;
|
||||
|
||||
return (utime(path, &ut));
|
||||
}
|
||||
|
||||
return (utime(path, NULL));
|
||||
}
|
403
lukemftp.h
403
lukemftp.h
@ -1,403 +0,0 @@
|
||||
/* $Id: lukemftp.h,v 1.43 2002/06/10 08:13:01 lukem Exp $ */
|
||||
|
||||
#define FTP_PRODUCT "lukemftp"
|
||||
#define FTP_VERSION "1.6-beta2"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
|
||||
#include <arpa/ftp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <netdb.h>
|
||||
#include <pwd.h>
|
||||
#include <setjmp.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if HAVE_POLL
|
||||
# if HAVE_POLL_H
|
||||
# include <poll.h>
|
||||
# elif HAVE_SYS_POLL_H
|
||||
# include <sys/poll.h>
|
||||
# endif
|
||||
#elif HAVE_SELECT
|
||||
# define USE_SELECT
|
||||
#else
|
||||
# error "no poll() or select() found"
|
||||
#endif
|
||||
|
||||
#if HAVE_DIRENT_H
|
||||
# include <dirent.h>
|
||||
#else
|
||||
# define dirent direct
|
||||
# if HAVE_SYS_NDIR_H
|
||||
# include <sys/ndir.h>
|
||||
# endif
|
||||
# if HAVE_SYS_DIR_H
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if HAVE_NDIR_H
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if TIME_WITH_SYS_TIME
|
||||
# include <sys/time.h>
|
||||
# include <time.h>
|
||||
#else
|
||||
# if HAVE_SYS_TIME_H
|
||||
# include <sys/time.h>
|
||||
# else
|
||||
# include <time.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if HAVE_ERR_H
|
||||
# include <err.h>
|
||||
#endif
|
||||
|
||||
#if USE_GLOB_H /* not set by configure; used by other build systems */
|
||||
# include <glob.h>
|
||||
#else
|
||||
# include "ftpglob.h"
|
||||
#endif
|
||||
|
||||
#if HAVE_PATHS_H
|
||||
# include <paths.h>
|
||||
#endif
|
||||
#ifndef _PATH_BSHELL
|
||||
#define _PATH_BSHELL "/bin/sh"
|
||||
#endif
|
||||
#ifndef _PATH_TMP
|
||||
#define _PATH_TMP "/tmp/"
|
||||
#endif
|
||||
|
||||
typedef struct _stringlist {
|
||||
char **sl_str;
|
||||
size_t sl_max;
|
||||
size_t sl_cur;
|
||||
} StringList;
|
||||
|
||||
StringList *sl_init(void);
|
||||
int sl_add(StringList *, char *);
|
||||
void sl_free(StringList *, int);
|
||||
char *sl_find(StringList *, char *);
|
||||
|
||||
#if HAVE_TERMCAP_H
|
||||
# include <termcap.h>
|
||||
#else
|
||||
int tgetent(char *, const char *);
|
||||
char *tgetstr(const char *, char **);
|
||||
int tgetflag(const char *);
|
||||
int tgetnum(const char *);
|
||||
char *tgoto(const char *, int, int);
|
||||
void tputs(const char *, int, int (*)(int));
|
||||
#endif
|
||||
|
||||
#if HAVE_UTIL_H
|
||||
# include <util.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_LIBUTIL_H
|
||||
# include <libutil.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_VIS_H
|
||||
# include <vis.h>
|
||||
#else
|
||||
# include "ftpvis.h"
|
||||
#endif
|
||||
|
||||
#if ! HAVE_IN_PORT_T
|
||||
typedef unsigned short in_port_t;
|
||||
#endif
|
||||
|
||||
#if ! HAVE_SA_FAMILY_T
|
||||
typedef unsigned short sa_family_t;
|
||||
#endif
|
||||
|
||||
#if ! HAVE_SOCKLEN_T
|
||||
typedef unsigned int socklen_t;
|
||||
#endif
|
||||
|
||||
#if HAVE_AF_INET6 && HAVE_SOCKADDR_IN6
|
||||
# define INET6
|
||||
#endif
|
||||
|
||||
|
||||
#if ! HAVE_RFC2553_NETDB
|
||||
|
||||
/* RFC 2553 */
|
||||
#undef EAI_ADDRFAMILY
|
||||
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
||||
#undef EAI_AGAIN
|
||||
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
||||
#undef EAI_BADFLAGS
|
||||
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
||||
#undef EAI_FAIL
|
||||
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
||||
#undef EAI_FAMILY
|
||||
#define EAI_FAMILY 5 /* ai_family not supported */
|
||||
#undef EAI_MEMORY
|
||||
#define EAI_MEMORY 6 /* memory allocation failure */
|
||||
#undef EAI_NODATA
|
||||
#define EAI_NODATA 7 /* no address associated with hostname */
|
||||
#undef EAI_NONAME
|
||||
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
||||
#undef EAI_SERVICE
|
||||
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
||||
#undef EAI_SOCKTYPE
|
||||
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||
#undef EAI_SYSTEM
|
||||
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||
|
||||
/* KAME extensions? */
|
||||
#undef EAI_BADHINTS
|
||||
#define EAI_BADHINTS 12
|
||||
#undef EAI_PROTOCOL
|
||||
#define EAI_PROTOCOL 13
|
||||
#undef EAI_MAX
|
||||
#define EAI_MAX 14
|
||||
|
||||
/* RFC 2553 */
|
||||
#undef NI_MAXHOST
|
||||
#define NI_MAXHOST 1025
|
||||
#undef NI_MAXSERV
|
||||
#define NI_MAXSERV 32
|
||||
|
||||
#undef NI_NOFQDN
|
||||
#define NI_NOFQDN 0x00000001
|
||||
#undef NI_NUMERICHOST
|
||||
#define NI_NUMERICHOST 0x00000002
|
||||
#undef NI_NAMEREQD
|
||||
#define NI_NAMEREQD 0x00000004
|
||||
#undef NI_NUMERICSERV
|
||||
#define NI_NUMERICSERV 0x00000008
|
||||
#undef NI_DGRAM
|
||||
#define NI_DGRAM 0x00000010
|
||||
|
||||
/* RFC 2553 */
|
||||
#undef AI_PASSIVE
|
||||
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
||||
#undef AI_CANONNAME
|
||||
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
||||
|
||||
/* KAME extensions ? */
|
||||
#undef AI_NUMERICHOST
|
||||
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
||||
#undef AI_MASK
|
||||
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||
|
||||
/* RFC 2553 */
|
||||
#undef AI_ALL
|
||||
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||
#undef AI_V4MAPPED_CFG
|
||||
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||
#undef AI_ADDRCONFIG
|
||||
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
||||
#undef AI_V4MAPPED
|
||||
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
||||
|
||||
#endif /* ! HAVE_RFC2553_NETDB */
|
||||
|
||||
|
||||
#if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
|
||||
|
||||
struct addrinfo {
|
||||
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
|
||||
int ai_family; /* PF_xxx */
|
||||
int ai_socktype; /* SOCK_xxx */
|
||||
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||
size_t ai_addrlen; /* length of ai_addr */
|
||||
char *ai_canonname; /* canonical name for hostname */
|
||||
struct sockaddr *ai_addr; /* binary address */
|
||||
struct addrinfo *ai_next; /* next structure in linked list */
|
||||
};
|
||||
|
||||
int getaddrinfo(const char *, const char *,
|
||||
const struct addrinfo *, struct addrinfo **);
|
||||
int getnameinfo(const struct sockaddr *, socklen_t, char *,
|
||||
size_t, char *, size_t, int);
|
||||
void freeaddrinfo(struct addrinfo *);
|
||||
char *gai_strerror(int);
|
||||
|
||||
#endif /* ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO */
|
||||
|
||||
|
||||
#if ! HAVE_D_NAMLEN
|
||||
# define DIRENT_MISSING_D_NAMLEN
|
||||
#endif
|
||||
|
||||
#if ! HAVE_H_ERRNO_D
|
||||
extern int h_errno;
|
||||
#endif
|
||||
#define HAVE_H_ERRNO 1 /* XXX: an assumption for now... */
|
||||
|
||||
#if ! HAVE_FCLOSE_D
|
||||
int fclose(FILE *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_GETPASS_D
|
||||
char *getpass(const char *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_OPTARG_D
|
||||
extern char *optarg;
|
||||
#endif
|
||||
|
||||
#if ! HAVE_OPTIND_D
|
||||
extern int optind;
|
||||
#endif
|
||||
|
||||
#if ! HAVE_PCLOSE_D
|
||||
int pclose(FILE *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_ERR
|
||||
void err(int, const char *, ...);
|
||||
void errx(int, const char *, ...);
|
||||
void warn(const char *, ...);
|
||||
void warnx(const char *, ...);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_FGETLN
|
||||
char *fgetln(FILE *, size_t *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_FSEEKO
|
||||
int fseeko(FILE *, off_t, int);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_FPARSELN
|
||||
# define FPARSELN_UNESCESC 0x01
|
||||
# define FPARSELN_UNESCCONT 0x02
|
||||
# define FPARSELN_UNESCCOMM 0x04
|
||||
# define FPARSELN_UNESCREST 0x08
|
||||
# define FPARSELN_UNESCALL 0x0f
|
||||
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_INET_NTOP
|
||||
const char *inet_ntop(int, const void *, char *, size_t);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_INET_PTON
|
||||
int inet_pton(int, const char *, void *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_MKSTEMP
|
||||
int mkstemp(char *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_SETPROGNAME
|
||||
const char *getprogname(void);
|
||||
void setprogname(const char *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_SNPRINTF
|
||||
int snprintf(char *, size_t, const char *, ...);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRDUP
|
||||
char *strdup(const char *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRERROR
|
||||
char *strerror(int);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRPTIME || ! HAVE_STRPTIME_D
|
||||
char *strptime(const char *, const char *, struct tm *);
|
||||
#endif
|
||||
|
||||
#if HAVE_QUAD_SUPPORT
|
||||
# if ! HAVE_STRTOLL && HAVE_LONG_LONG
|
||||
long long strtoll(const char *, char **, int);
|
||||
# if ! defined(QUAD_MIN)
|
||||
# define QUAD_MIN (-0x7fffffffffffffffL-1)
|
||||
# endif
|
||||
# if ! defined(QUAD_MAX)
|
||||
# define QUAD_MAX (0x7fffffffffffffffL)
|
||||
# endif
|
||||
# endif
|
||||
#else /* ! HAVE_QUAD_SUPPORT */
|
||||
# define NO_LONG_LONG 1
|
||||
#endif /* ! HAVE_QUAD_SUPPORT */
|
||||
|
||||
#if ! HAVE_TIMEGM
|
||||
time_t timegm(struct tm *);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_HSTRERROR
|
||||
char *strerror(int);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRLCAT
|
||||
size_t strlcat(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRLCPY
|
||||
size_t strlcpy(char *, const char *, size_t);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_STRSEP
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
#if ! HAVE_MEMMOVE
|
||||
# define memmove(a,b,c) bcopy((b),(a),(c))
|
||||
/* XXX: add others #defines for borken systems? */
|
||||
#endif
|
||||
|
||||
#if HAVE_GETPASSPHRASE
|
||||
# define getpass getpassphrase
|
||||
#endif
|
||||
|
||||
#if ! defined(MIN)
|
||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
#if ! defined(MAX)
|
||||
# define MAX(a, b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
#if ! defined(timersub)
|
||||
# define timersub(tvp, uvp, vvp) \
|
||||
do { \
|
||||
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||
if ((vvp)->tv_usec < 0) { \
|
||||
(vvp)->tv_sec--; \
|
||||
(vvp)->tv_usec += 1000000; \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#if ! defined(S_ISLNK)
|
||||
# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
|
||||
#define EPOCH_YEAR 1970
|
||||
#define SECSPERHOUR 3600
|
||||
#define SECSPERDAY 86400
|
||||
#define TM_YEAR_BASE 1900
|
28
src/Makefile
28
src/Makefile
@ -1,28 +0,0 @@
|
||||
# $NetBSD: Makefile,v 1.30 2005/02/11 15:13:28 jmc Exp $
|
||||
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
PROG= ftp
|
||||
SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
|
||||
progressbar.c ruserpass.c util.c
|
||||
|
||||
# Uncomment the following to provide defaults for gate-ftp operation
|
||||
#
|
||||
#CPPFLAGS+=-DGATE_SERVER=\"ftp-gw.host\" # -DGATE_PORT=21
|
||||
|
||||
.if defined(SMALLPROG)
|
||||
CPPFLAGS+=-DNO_EDITCOMPLETE -DNO_ABOUT -DNO_AUTH -DNO_HELP -DNO_STATUS
|
||||
.else
|
||||
LDADD+= -ledit -ltermcap
|
||||
DPADD+= ${LIBEDIT} ${LIBTERMCAP}
|
||||
.endif
|
||||
|
||||
.if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
|
||||
CPPFLAGS+= -DINET6
|
||||
.endif
|
||||
|
||||
cmds.o fetch.o: version.h
|
||||
main.o: ftp_var.h
|
||||
|
||||
.include <bsd.prog.mk>
|
52
src/Makefile.am
Normal file
52
src/Makefile.am
Normal file
@ -0,0 +1,52 @@
|
||||
## $NetBSD: Makefile.am,v 1.2 2010/01/04 06:24:20 lukem Exp $
|
||||
|
||||
bin_PROGRAMS = tnftp
|
||||
|
||||
tnftp_SOURCES = \
|
||||
cmds.c \
|
||||
cmdtab.c \
|
||||
complete.c \
|
||||
domacro.c \
|
||||
fetch.c \
|
||||
ftp.c \
|
||||
main.c \
|
||||
progressbar.c \
|
||||
ruserpass.c \
|
||||
util.c
|
||||
|
||||
tnftp_CPPFLAGS = \
|
||||
-DHAVE_TNFTPD_H=1 \
|
||||
-D_DEFAULT_CONFDIR=\"${sysconfdir}\" \
|
||||
-I$(srcdir) \
|
||||
-I$(top_srcdir)/libnetbsd \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)
|
||||
|
||||
tnftp_LDADD = \
|
||||
../libnetbsd/libnetbsd.la
|
||||
|
||||
|
||||
if USE_LIBEDIT
|
||||
tnftp_CPPFLAGS += \
|
||||
-I$(top_srcdir)/libedit
|
||||
|
||||
tnftp_LDADD += \
|
||||
../libedit/libedit.la
|
||||
endif
|
||||
|
||||
|
||||
man1_MANS = \
|
||||
tnftp.1
|
||||
|
||||
tnftp.1: ftp.1
|
||||
cp $(srcdir)/ftp.1 tnftp.1
|
||||
|
||||
CLEANFILES = \
|
||||
tnftp.1
|
||||
|
||||
EXTRA_DIST = \
|
||||
extern.h \
|
||||
ftp.1 \
|
||||
ftp_var.h \
|
||||
progressbar.h \
|
||||
version.h
|
828
src/Makefile.in
828
src/Makefile.in
@ -1,43 +1,809 @@
|
||||
#
|
||||
# $Id: Makefile.in,v 1.8 2000/08/08 07:04:27 lukem Exp $
|
||||
#
|
||||
# Makefile.in generated by automake 1.11 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
SHELL = /bin/sh
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
prefix = @prefix@
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
bin_PROGRAMS = tnftp$(EXEEXT)
|
||||
@USE_LIBEDIT_TRUE@am__append_1 = \
|
||||
@USE_LIBEDIT_TRUE@ -I$(top_srcdir)/libedit
|
||||
|
||||
@USE_LIBEDIT_TRUE@am__append_2 = \
|
||||
@USE_LIBEDIT_TRUE@ ../libedit/libedit.la
|
||||
|
||||
subdir = src
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/tnftp_config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am_tnftp_OBJECTS = tnftp-cmds.$(OBJEXT) tnftp-cmdtab.$(OBJEXT) \
|
||||
tnftp-complete.$(OBJEXT) tnftp-domacro.$(OBJEXT) \
|
||||
tnftp-fetch.$(OBJEXT) tnftp-ftp.$(OBJEXT) tnftp-main.$(OBJEXT) \
|
||||
tnftp-progressbar.$(OBJEXT) tnftp-ruserpass.$(OBJEXT) \
|
||||
tnftp-util.$(OBJEXT)
|
||||
tnftp_OBJECTS = $(am_tnftp_OBJECTS)
|
||||
tnftp_DEPENDENCIES = ../libnetbsd/libnetbsd.la $(am__append_2)
|
||||
AM_V_lt = $(am__v_lt_$(V))
|
||||
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_lt_0 = --silent
|
||||
DEFAULT_INCLUDES =
|
||||
depcomp = $(SHELL) $(top_srcdir)/buildaux/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
AM_V_CC = $(am__v_CC_$(V))
|
||||
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CC_0 = @echo " CC " $@;
|
||||
AM_V_at = $(am__v_at_$(V))
|
||||
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_at_0 = @
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
AM_V_CCLD = $(am__v_CCLD_$(V))
|
||||
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
AM_V_GEN = $(am__v_GEN_$(V))
|
||||
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
|
||||
am__v_GEN_0 = @echo " GEN " $@;
|
||||
SOURCES = $(tnftp_SOURCES)
|
||||
DIST_SOURCES = $(tnftp_SOURCES)
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
|
||||
am__install_max = 40
|
||||
am__nobase_strip_setup = \
|
||||
srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
|
||||
am__nobase_strip = \
|
||||
for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
|
||||
am__nobase_list = $(am__nobase_strip_setup); \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
|
||||
$(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
|
||||
if (++n[$$2] == $(am__install_max)) \
|
||||
{ print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
|
||||
END { for (dir in files) print dir, files[dir] }'
|
||||
am__base_list = \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
|
||||
sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
|
||||
man1dir = $(mandir)/man1
|
||||
NROFF = nroff
|
||||
MANS = $(man1_MANS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMTAR = @AMTAR@
|
||||
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
mandir = @mandir@
|
||||
transform = @program_transform_name@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
tnftp_SOURCES = \
|
||||
cmds.c \
|
||||
cmdtab.c \
|
||||
complete.c \
|
||||
domacro.c \
|
||||
fetch.c \
|
||||
ftp.c \
|
||||
main.c \
|
||||
progressbar.c \
|
||||
ruserpass.c \
|
||||
util.c
|
||||
|
||||
mandircat1 = ${mandir}/cat1
|
||||
tnftp_CPPFLAGS = -DHAVE_TNFTPD_H=1 \
|
||||
-D_DEFAULT_CONFDIR=\"${sysconfdir}\" -I$(srcdir) \
|
||||
-I$(top_srcdir)/libnetbsd -I$(top_srcdir) -I$(top_builddir) \
|
||||
$(am__append_1)
|
||||
tnftp_LDADD = ../libnetbsd/libnetbsd.la $(am__append_2)
|
||||
man1_MANS = \
|
||||
tnftp.1
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CFLAGS@
|
||||
LIBS = @LIBS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
CLEANFILES = \
|
||||
tnftp.1
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
EXTRA_DIST = \
|
||||
extern.h \
|
||||
ftp.1 \
|
||||
ftp_var.h \
|
||||
progressbar.h \
|
||||
version.h
|
||||
|
||||
PROG = ftp
|
||||
OBJS = cmds.o cmdtab.o complete.o domacro.o fetch.o ftp.o main.o \
|
||||
ruserpass.o util.o
|
||||
all: all-am
|
||||
|
||||
all: ${PROG}
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
install: all
|
||||
-mkdir -p ${bindir}
|
||||
${INSTALL} -m 555 ${PROG} ${bindir}/`echo ${PROG}|sed '$(transform)'`
|
||||
-mkdir -p ${mandircat1}
|
||||
${INSTALL} -m 444 ${srcdir}/${PROG}.cat1 ${mandircat1}/`echo ${PROG}|sed '$(transform)'`.1
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
${PROG}: ${OBJS} @LIBDEPENDS@
|
||||
${CC} ${CFLAGS} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
|
||||
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p || test -f $$p1; \
|
||||
then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
clean:
|
||||
rm -f core ${PROG} ${OBJS}
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' `; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(bindir)" && rm -f $$files
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
clean-binPROGRAMS:
|
||||
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
tnftp$(EXEEXT): $(tnftp_OBJECTS) $(tnftp_DEPENDENCIES)
|
||||
@rm -f tnftp$(EXEEXT)
|
||||
$(AM_V_CCLD)$(LINK) $(tnftp_OBJECTS) $(tnftp_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-cmds.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-cmdtab.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-complete.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-domacro.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-fetch.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-ftp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-progressbar.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-ruserpass.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tnftp-util.Po@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
tnftp-cmds.o: cmds.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-cmds.o -MD -MP -MF $(DEPDIR)/tnftp-cmds.Tpo -c -o tnftp-cmds.o `test -f 'cmds.c' || echo '$(srcdir)/'`cmds.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-cmds.Tpo $(DEPDIR)/tnftp-cmds.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cmds.c' object='tnftp-cmds.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-cmds.o `test -f 'cmds.c' || echo '$(srcdir)/'`cmds.c
|
||||
|
||||
tnftp-cmds.obj: cmds.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-cmds.obj -MD -MP -MF $(DEPDIR)/tnftp-cmds.Tpo -c -o tnftp-cmds.obj `if test -f 'cmds.c'; then $(CYGPATH_W) 'cmds.c'; else $(CYGPATH_W) '$(srcdir)/cmds.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-cmds.Tpo $(DEPDIR)/tnftp-cmds.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cmds.c' object='tnftp-cmds.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-cmds.obj `if test -f 'cmds.c'; then $(CYGPATH_W) 'cmds.c'; else $(CYGPATH_W) '$(srcdir)/cmds.c'; fi`
|
||||
|
||||
tnftp-cmdtab.o: cmdtab.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-cmdtab.o -MD -MP -MF $(DEPDIR)/tnftp-cmdtab.Tpo -c -o tnftp-cmdtab.o `test -f 'cmdtab.c' || echo '$(srcdir)/'`cmdtab.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-cmdtab.Tpo $(DEPDIR)/tnftp-cmdtab.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cmdtab.c' object='tnftp-cmdtab.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-cmdtab.o `test -f 'cmdtab.c' || echo '$(srcdir)/'`cmdtab.c
|
||||
|
||||
tnftp-cmdtab.obj: cmdtab.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-cmdtab.obj -MD -MP -MF $(DEPDIR)/tnftp-cmdtab.Tpo -c -o tnftp-cmdtab.obj `if test -f 'cmdtab.c'; then $(CYGPATH_W) 'cmdtab.c'; else $(CYGPATH_W) '$(srcdir)/cmdtab.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-cmdtab.Tpo $(DEPDIR)/tnftp-cmdtab.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cmdtab.c' object='tnftp-cmdtab.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-cmdtab.obj `if test -f 'cmdtab.c'; then $(CYGPATH_W) 'cmdtab.c'; else $(CYGPATH_W) '$(srcdir)/cmdtab.c'; fi`
|
||||
|
||||
tnftp-complete.o: complete.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-complete.o -MD -MP -MF $(DEPDIR)/tnftp-complete.Tpo -c -o tnftp-complete.o `test -f 'complete.c' || echo '$(srcdir)/'`complete.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-complete.Tpo $(DEPDIR)/tnftp-complete.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='complete.c' object='tnftp-complete.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-complete.o `test -f 'complete.c' || echo '$(srcdir)/'`complete.c
|
||||
|
||||
tnftp-complete.obj: complete.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-complete.obj -MD -MP -MF $(DEPDIR)/tnftp-complete.Tpo -c -o tnftp-complete.obj `if test -f 'complete.c'; then $(CYGPATH_W) 'complete.c'; else $(CYGPATH_W) '$(srcdir)/complete.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-complete.Tpo $(DEPDIR)/tnftp-complete.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='complete.c' object='tnftp-complete.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-complete.obj `if test -f 'complete.c'; then $(CYGPATH_W) 'complete.c'; else $(CYGPATH_W) '$(srcdir)/complete.c'; fi`
|
||||
|
||||
tnftp-domacro.o: domacro.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-domacro.o -MD -MP -MF $(DEPDIR)/tnftp-domacro.Tpo -c -o tnftp-domacro.o `test -f 'domacro.c' || echo '$(srcdir)/'`domacro.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-domacro.Tpo $(DEPDIR)/tnftp-domacro.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='domacro.c' object='tnftp-domacro.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-domacro.o `test -f 'domacro.c' || echo '$(srcdir)/'`domacro.c
|
||||
|
||||
tnftp-domacro.obj: domacro.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-domacro.obj -MD -MP -MF $(DEPDIR)/tnftp-domacro.Tpo -c -o tnftp-domacro.obj `if test -f 'domacro.c'; then $(CYGPATH_W) 'domacro.c'; else $(CYGPATH_W) '$(srcdir)/domacro.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-domacro.Tpo $(DEPDIR)/tnftp-domacro.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='domacro.c' object='tnftp-domacro.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-domacro.obj `if test -f 'domacro.c'; then $(CYGPATH_W) 'domacro.c'; else $(CYGPATH_W) '$(srcdir)/domacro.c'; fi`
|
||||
|
||||
tnftp-fetch.o: fetch.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-fetch.o -MD -MP -MF $(DEPDIR)/tnftp-fetch.Tpo -c -o tnftp-fetch.o `test -f 'fetch.c' || echo '$(srcdir)/'`fetch.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-fetch.Tpo $(DEPDIR)/tnftp-fetch.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fetch.c' object='tnftp-fetch.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-fetch.o `test -f 'fetch.c' || echo '$(srcdir)/'`fetch.c
|
||||
|
||||
tnftp-fetch.obj: fetch.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-fetch.obj -MD -MP -MF $(DEPDIR)/tnftp-fetch.Tpo -c -o tnftp-fetch.obj `if test -f 'fetch.c'; then $(CYGPATH_W) 'fetch.c'; else $(CYGPATH_W) '$(srcdir)/fetch.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-fetch.Tpo $(DEPDIR)/tnftp-fetch.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='fetch.c' object='tnftp-fetch.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-fetch.obj `if test -f 'fetch.c'; then $(CYGPATH_W) 'fetch.c'; else $(CYGPATH_W) '$(srcdir)/fetch.c'; fi`
|
||||
|
||||
tnftp-ftp.o: ftp.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-ftp.o -MD -MP -MF $(DEPDIR)/tnftp-ftp.Tpo -c -o tnftp-ftp.o `test -f 'ftp.c' || echo '$(srcdir)/'`ftp.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-ftp.Tpo $(DEPDIR)/tnftp-ftp.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ftp.c' object='tnftp-ftp.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-ftp.o `test -f 'ftp.c' || echo '$(srcdir)/'`ftp.c
|
||||
|
||||
tnftp-ftp.obj: ftp.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-ftp.obj -MD -MP -MF $(DEPDIR)/tnftp-ftp.Tpo -c -o tnftp-ftp.obj `if test -f 'ftp.c'; then $(CYGPATH_W) 'ftp.c'; else $(CYGPATH_W) '$(srcdir)/ftp.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-ftp.Tpo $(DEPDIR)/tnftp-ftp.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ftp.c' object='tnftp-ftp.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-ftp.obj `if test -f 'ftp.c'; then $(CYGPATH_W) 'ftp.c'; else $(CYGPATH_W) '$(srcdir)/ftp.c'; fi`
|
||||
|
||||
tnftp-main.o: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-main.o -MD -MP -MF $(DEPDIR)/tnftp-main.Tpo -c -o tnftp-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-main.Tpo $(DEPDIR)/tnftp-main.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='tnftp-main.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
|
||||
|
||||
tnftp-main.obj: main.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-main.obj -MD -MP -MF $(DEPDIR)/tnftp-main.Tpo -c -o tnftp-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-main.Tpo $(DEPDIR)/tnftp-main.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='tnftp-main.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
|
||||
|
||||
tnftp-progressbar.o: progressbar.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-progressbar.o -MD -MP -MF $(DEPDIR)/tnftp-progressbar.Tpo -c -o tnftp-progressbar.o `test -f 'progressbar.c' || echo '$(srcdir)/'`progressbar.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-progressbar.Tpo $(DEPDIR)/tnftp-progressbar.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='progressbar.c' object='tnftp-progressbar.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-progressbar.o `test -f 'progressbar.c' || echo '$(srcdir)/'`progressbar.c
|
||||
|
||||
tnftp-progressbar.obj: progressbar.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-progressbar.obj -MD -MP -MF $(DEPDIR)/tnftp-progressbar.Tpo -c -o tnftp-progressbar.obj `if test -f 'progressbar.c'; then $(CYGPATH_W) 'progressbar.c'; else $(CYGPATH_W) '$(srcdir)/progressbar.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-progressbar.Tpo $(DEPDIR)/tnftp-progressbar.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='progressbar.c' object='tnftp-progressbar.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-progressbar.obj `if test -f 'progressbar.c'; then $(CYGPATH_W) 'progressbar.c'; else $(CYGPATH_W) '$(srcdir)/progressbar.c'; fi`
|
||||
|
||||
tnftp-ruserpass.o: ruserpass.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-ruserpass.o -MD -MP -MF $(DEPDIR)/tnftp-ruserpass.Tpo -c -o tnftp-ruserpass.o `test -f 'ruserpass.c' || echo '$(srcdir)/'`ruserpass.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-ruserpass.Tpo $(DEPDIR)/tnftp-ruserpass.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ruserpass.c' object='tnftp-ruserpass.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-ruserpass.o `test -f 'ruserpass.c' || echo '$(srcdir)/'`ruserpass.c
|
||||
|
||||
tnftp-ruserpass.obj: ruserpass.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-ruserpass.obj -MD -MP -MF $(DEPDIR)/tnftp-ruserpass.Tpo -c -o tnftp-ruserpass.obj `if test -f 'ruserpass.c'; then $(CYGPATH_W) 'ruserpass.c'; else $(CYGPATH_W) '$(srcdir)/ruserpass.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-ruserpass.Tpo $(DEPDIR)/tnftp-ruserpass.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ruserpass.c' object='tnftp-ruserpass.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-ruserpass.obj `if test -f 'ruserpass.c'; then $(CYGPATH_W) 'ruserpass.c'; else $(CYGPATH_W) '$(srcdir)/ruserpass.c'; fi`
|
||||
|
||||
tnftp-util.o: util.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-util.o -MD -MP -MF $(DEPDIR)/tnftp-util.Tpo -c -o tnftp-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-util.Tpo $(DEPDIR)/tnftp-util.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='tnftp-util.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-util.o `test -f 'util.c' || echo '$(srcdir)/'`util.c
|
||||
|
||||
tnftp-util.obj: util.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tnftp-util.obj -MD -MP -MF $(DEPDIR)/tnftp-util.Tpo -c -o tnftp-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/tnftp-util.Tpo $(DEPDIR)/tnftp-util.Po
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='util.c' object='tnftp-util.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(tnftp_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tnftp-util.obj `if test -f 'util.c'; then $(CYGPATH_W) 'util.c'; else $(CYGPATH_W) '$(srcdir)/util.c'; fi`
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
install-man1: $(man1_MANS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
|
||||
@list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
|
||||
{ for i in $$list; do echo "$$i"; done; \
|
||||
} | while read p; do \
|
||||
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
|
||||
echo "$$d$$p"; echo "$$p"; \
|
||||
done | \
|
||||
sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
|
||||
sed 'N;N;s,\n, ,g' | { \
|
||||
list=; while read file base inst; do \
|
||||
if test "$$base" = "$$inst"; then list="$$list $$file"; else \
|
||||
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
|
||||
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
|
||||
fi; \
|
||||
done; \
|
||||
for i in $$list; do echo "$$i"; done | $(am__base_list) | \
|
||||
while read files; do \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
|
||||
$(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
|
||||
done; }
|
||||
|
||||
uninstall-man1:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(man1_MANS)'; test -n "$(man1dir)" || exit 0; \
|
||||
files=`{ for i in $$list; do echo "$$i"; done; \
|
||||
} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
|
||||
-e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
|
||||
test -z "$$files" || { \
|
||||
echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@list='$(MANS)'; if test -n "$$list"; then \
|
||||
list=`for p in $$list; do \
|
||||
if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
|
||||
if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
|
||||
if test -n "$$list" && \
|
||||
grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
|
||||
echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
|
||||
grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \
|
||||
echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \
|
||||
echo " typically \`make maintainer-clean' will remove them" >&2; \
|
||||
exit 1; \
|
||||
else :; fi; \
|
||||
else :; fi
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS) $(MANS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-man
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-binPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man: install-man1
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS uninstall-man
|
||||
|
||||
uninstall-man: uninstall-man1
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
||||
clean-generic clean-libtool ctags distclean distclean-compile \
|
||||
distclean-generic distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-binPROGRAMS install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-man1 install-pdf install-pdf-am install-ps \
|
||||
install-ps-am install-strip installcheck installcheck-am \
|
||||
installdirs maintainer-clean maintainer-clean-generic \
|
||||
mostlyclean mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
|
||||
uninstall-am uninstall-binPROGRAMS uninstall-man \
|
||||
uninstall-man1
|
||||
|
||||
|
||||
tnftp.1: ftp.1
|
||||
cp $(srcdir)/ftp.1 tnftp.1
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
502
src/cmds.c
502
src/cmds.c
File diff suppressed because it is too large
Load Diff
29
src/cmdtab.c
29
src/cmdtab.c
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp $ */
|
||||
/* $NetBSD: cmdtab.c,v 1.11 2009/05/20 12:53:47 lukem Exp $ */
|
||||
/* from NetBSD: cmdtab.c,v 1.51 2009/04/12 10:18:52 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1996-2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -15,13 +16,6 @@
|
||||
* 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 NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@ -65,16 +59,23 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#if 0 /* tnftp */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp $");
|
||||
__RCSID(" NetBSD: cmdtab.c,v 1.51 2009/04/12 10:18:52 lukem Exp ");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#endif /* tnftp */
|
||||
|
||||
#include "ftp_var.h"
|
||||
|
||||
/*
|
||||
@ -100,7 +101,9 @@ HSTR deletehelp[] = "delete remote file";
|
||||
HSTR disconhelp[] = "terminate ftp session";
|
||||
HSTR domachelp[] = "execute macro";
|
||||
HSTR edithelp[] = "toggle command line editing";
|
||||
HSTR epsvhelp[] = "toggle use of EPSV/EPRT on both IPv4 and IPV6 ftp";
|
||||
HSTR epsv4help[] = "toggle use of EPSV/EPRT on IPv4 ftp";
|
||||
HSTR epsv6help[] = "toggle use of EPSV/EPRT on IPv6 ftp";
|
||||
HSTR feathelp[] = "show FEATures supported by remote system";
|
||||
HSTR formhelp[] = "set file transfer format";
|
||||
HSTR gatehelp[] = "toggle gate-ftp; specify host[:port] to change proxy";
|
||||
@ -211,7 +214,9 @@ struct cmd cmdtab[] = {
|
||||
{ "dir", H(lshelp), 1, 1, 1, CMPL(rl) ls },
|
||||
{ "disconnect", H(disconhelp), 0, 1, 1, CMPL0 disconnect },
|
||||
{ "edit", H(edithelp), 0, 0, 0, CMPL0 setedit },
|
||||
{ "epsv", H(epsvhelp), 0, 0, 0, CMPL0 setepsv },
|
||||
{ "epsv4", H(epsv4help), 0, 0, 0, CMPL0 setepsv4 },
|
||||
{ "epsv6", H(epsv6help), 0, 0, 0, CMPL0 setepsv6 },
|
||||
{ "exit", H(quithelp), 0, 0, 0, CMPL0 quit },
|
||||
{ "features", H(feathelp), 0, 1, 1, CMPL0 feat },
|
||||
{ "fget", H(fgethelp), 1, 1, 1, CMPL(l) fget },
|
||||
@ -294,7 +299,7 @@ struct cmd cmdtab[] = {
|
||||
{ "verbose", H(verbosehelp), 0, 0, 0, CMPL0 setverbose },
|
||||
{ "xferbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
|
||||
{ "?", H(helphelp), 0, 0, 1, CMPL(C) help },
|
||||
{ 0 },
|
||||
{ NULL, NULL, 0, 0, 0, CMPL0 NULL },
|
||||
};
|
||||
|
||||
struct option optiontab[] = {
|
||||
@ -305,5 +310,5 @@ struct option optiontab[] = {
|
||||
{ "pager", NULL },
|
||||
{ "prompt", NULL },
|
||||
{ "rprompt", NULL },
|
||||
{ 0 },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
@ -1,7 +1,8 @@
|
||||
/* $NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp $ */
|
||||
/* $NetBSD: complete.c,v 1.10 2009/05/20 12:53:47 lukem Exp $ */
|
||||
/* from NetBSD: complete.c,v 1.46 2009/04/12 10:18:52 lukem Exp */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
||||
* Copyright (c) 1997-2009 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
@ -15,13 +16,6 @@
|
||||
* 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 NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
@ -36,9 +30,13 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "tnftp.h"
|
||||
|
||||
#if 0 /* tnftp */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp $");
|
||||
__RCSID(" NetBSD: complete.c,v 1.46 2009/04/12 10:18:52 lukem Exp ");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
@ -54,6 +52,8 @@ __RCSID("$NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp $");
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#endif /* tnftp */
|
||||
|
||||
#include "ftp_var.h"
|
||||
|
||||
#ifndef NO_EDITCOMPLETE
|
||||
@ -68,7 +68,7 @@ static unsigned char complete_remote (char *, int);
|
||||
static int
|
||||
comparstr(const void *a, const void *b)
|
||||
{
|
||||
return (strcmp(*(const char **)a, *(const char **)b));
|
||||
return (strcmp(*(const char * const *)a, *(const char * const *)b));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -87,7 +87,7 @@ complete_ambiguous(char *word, int list, StringList *words)
|
||||
{
|
||||
char insertstr[MAXPATHLEN];
|
||||
char *lastmatch, *p;
|
||||
int i, j;
|
||||
size_t i, j;
|
||||
size_t matchlen, wordlen;
|
||||
|
||||
wordlen = strlen(word);
|
||||
@ -143,14 +143,14 @@ complete_command(char *word, int list)
|
||||
size_t wordlen;
|
||||
unsigned char rv;
|
||||
|
||||
words = xsl_init();
|
||||
words = ftp_sl_init();
|
||||
wordlen = strlen(word);
|
||||
|
||||
for (c = cmdtab; c->c_name != NULL; c++) {
|
||||
if (wordlen > strlen(c->c_name))
|
||||
continue;
|
||||
if (strncmp(word, c->c_name, wordlen) == 0)
|
||||
xsl_add(words, c->c_name);
|
||||
ftp_sl_add(words, ftp_strdup(c->c_name));
|
||||
}
|
||||
|
||||
rv = complete_ambiguous(word, list, words);
|
||||
@ -158,7 +158,7 @@ complete_command(char *word, int list)
|
||||
if (el_insertstr(el, " ") == -1)
|
||||
rv = CC_ERROR;
|
||||
}
|
||||
sl_free(words, 0);
|
||||
sl_free(words, 1);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
@ -200,7 +200,7 @@ complete_local(char *word, int list)
|
||||
if ((dd = opendir(dir)) == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
words = xsl_init();
|
||||
words = ftp_sl_init();
|
||||
len = strlen(file);
|
||||
|
||||
for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
|
||||
@ -217,8 +217,8 @@ complete_local(char *word, int list)
|
||||
if (strncmp(file, dp->d_name, len) == 0) {
|
||||
char *tcp;
|
||||
|
||||
tcp = xstrdup(dp->d_name);
|
||||
xsl_add(words, tcp);
|
||||
tcp = ftp_strdup(dp->d_name);
|
||||
ftp_sl_add(words, tcp);
|
||||
}
|
||||
}
|
||||
closedir(dd);
|
||||
@ -255,14 +255,14 @@ complete_option(char *word, int list)
|
||||
size_t wordlen;
|
||||
unsigned char rv;
|
||||
|
||||
words = xsl_init();
|
||||
words = ftp_sl_init();
|
||||
wordlen = strlen(word);
|
||||
|
||||
for (o = optiontab; o->name != NULL; o++) {
|
||||
if (wordlen > strlen(o->name))
|
||||
continue;
|
||||
if (strncmp(word, o->name, wordlen) == 0)
|
||||
xsl_add(words, o->name);
|
||||
ftp_sl_add(words, ftp_strdup(o->name));
|
||||
}
|
||||
|
||||
rv = complete_ambiguous(word, list, words);
|
||||
@ -270,7 +270,7 @@ complete_option(char *word, int list)
|
||||
if (el_insertstr(el, " ") == -1)
|
||||
rv = CC_ERROR;
|
||||
}
|
||||
sl_free(words, 0);
|
||||
sl_free(words, 1);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
@ -285,10 +285,13 @@ complete_remote(char *word, int list)
|
||||
StringList *words;
|
||||
char dir[MAXPATHLEN];
|
||||
char *file, *cp;
|
||||
int i;
|
||||
size_t i;
|
||||
unsigned char rv;
|
||||
char cmdbuf[MAX_C_NAME];
|
||||
char *dummyargv[3] = { NULL, NULL, NULL };
|
||||
|
||||
char *dummyargv[] = { "complete", NULL, NULL };
|
||||
(void)strlcpy(cmdbuf, "complete", sizeof(cmdbuf));
|
||||
dummyargv[0] = cmdbuf;
|
||||
dummyargv[1] = dir;
|
||||
|
||||
if ((file = strrchr(word, '/')) == NULL) {
|
||||
@ -304,11 +307,11 @@ complete_remote(char *word, int list)
|
||||
|
||||
if (dirchange || dirlist == NULL ||
|
||||
strcmp(dir, lastdir) != 0) { /* dir not cached */
|
||||
char *emesg;
|
||||
const char *emesg;
|
||||
|
||||
if (dirlist != NULL)
|
||||
sl_free(dirlist, 1);
|
||||
dirlist = xsl_init();
|
||||
dirlist = ftp_sl_init();
|
||||
|
||||
mflag = 1;
|
||||
emesg = NULL;
|
||||
@ -326,8 +329,8 @@ complete_remote(char *word, int list)
|
||||
tcp++;
|
||||
else
|
||||
tcp = cp;
|
||||
tcp = xstrdup(tcp);
|
||||
xsl_add(dirlist, tcp);
|
||||
tcp = ftp_strdup(tcp);
|
||||
ftp_sl_add(dirlist, tcp);
|
||||
}
|
||||
if (emesg != NULL) {
|
||||
fprintf(ttyout, "\n%s\n", emesg);
|
||||
@ -337,13 +340,13 @@ complete_remote(char *word, int list)
|
||||
dirchange = 0;
|
||||
}
|
||||
|
||||
words = xsl_init();
|
||||
words = ftp_sl_init();
|
||||
for (i = 0; i < dirlist->sl_cur; i++) {
|
||||
cp = dirlist->sl_str[i];
|
||||
if (strlen(file) > strlen(cp))
|
||||
continue;
|
||||
if (strncmp(file, cp, strlen(file)) == 0)
|
||||
xsl_add(words, cp);
|
||||
ftp_sl_add(words, cp);
|
||||
}
|
||||
rv = complete_ambiguous(file, list, words);
|
||||
sl_free(words, 0);
|
||||
@ -354,17 +357,17 @@ complete_remote(char *word, int list)
|
||||
* Generic complete routine
|
||||
*/
|
||||
unsigned char
|
||||
complete(EditLine *el, int ch)
|
||||
complete(EditLine *cel, int ch)
|
||||
{
|
||||
static char word[FTPBUFLEN];
|
||||
static int lastc_argc, lastc_argo;
|
||||
static size_t lastc_argc, lastc_argo;
|
||||
|
||||
struct cmd *c;
|
||||
const LineInfo *lf;
|
||||
int celems, dolist, cmpltype;
|
||||
size_t len;
|
||||
int dolist, cmpltype;
|
||||
size_t celems, len;
|
||||
|
||||
lf = el_line(el);
|
||||
lf = el_line(cel);
|
||||
len = lf->lastchar - lf->buffer;
|
||||
if (len >= sizeof(line))
|
||||
return (CC_ERROR);
|
||||
@ -383,7 +386,7 @@ complete(EditLine *el, int ch)
|
||||
&& strncmp(word, margv[cursor_argc] ? margv[cursor_argc] : "",
|
||||
cursor_argo) == 0)
|
||||
dolist = 1;
|
||||
else if (cursor_argc < margc)
|
||||
else if (cursor_argc < (size_t)margc)
|
||||
(void)strlcpy(word, margv[cursor_argc], cursor_argo + 1);
|
||||
word[cursor_argo] = '\0';
|
||||
|
||||
@ -426,7 +429,8 @@ complete(EditLine *el, int ch)
|
||||
}
|
||||
return (complete_remote(word, dolist));
|
||||
default:
|
||||
errx(1, "unknown complete type `%c'", cmpltype);
|
||||
errx(1, "complete: unknown complete type `%c'",
|
||||
cmpltype);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
/* NOTREACHED */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user