diff options
Diffstat (limited to 'crypto/heimdal/lib/editline')
-rw-r--r-- | crypto/heimdal/lib/editline/ChangeLog | 98 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/Makefile.am | 54 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/Makefile.in | 715 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/README | 45 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/complete.c | 243 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/edit_compat.c | 118 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/editline.3 | 175 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/editline.c | 1376 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/editline.cat3 | 198 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/editline.h | 64 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/roken_rename.h | 61 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/sysunix.c | 92 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/testit.c | 38 | ||||
-rw-r--r-- | crypto/heimdal/lib/editline/unix.h | 22 |
14 files changed, 3299 insertions, 0 deletions
diff --git a/crypto/heimdal/lib/editline/ChangeLog b/crypto/heimdal/lib/editline/ChangeLog new file mode 100644 index 0000000..be78368 --- /dev/null +++ b/crypto/heimdal/lib/editline/ChangeLog @@ -0,0 +1,98 @@ +2000-11-15 Assar Westerlund <assar@sics.se> + + * Makefile.am: make libeditline and libel_compat into libtool + libraries but always make them static + +2000-03-01 Assar Westerlund <assar@sics.se> + + * edit_compat.c (readline): be more liberal in what we accept from + el_gets. if count == 0 -> interpret it as EOF. also copy the + string first and then cut of the newline, it's cleaner + +1999-12-23 Assar Westerlund <assar@sics.se> + + * editline.c (TTYinfo): add fallback if we fail to find "le" in + termcap. + +1999-08-06 Assar Westerlund <assar@sics.se> + + * editline.c (TTYinfo): copy backspace string to avoid referencing + into a local variable. + +1999-08-04 Assar Westerlund <assar@sics.se> + + * Makefile.am: don't run testit in `make check' + +1999-04-11 Assar Westerlund <assar@sics.se> + + * Makefile.am: don't run testit as a check + +Sat Apr 10 23:01:18 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * complete.c (rl_complete_filename): return if there were no + matches + +Thu Apr 8 15:08:25 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * Makefile.in: snprintf + + * roken_rename.h: add snprintf, asprintf + + * Makefile.am: build testit + + * complete.c: nuke NEW, DISPOSE, RENEW, and COPYFROMTO macros; + (rl_complete): call rl_list_possib instead of doing the same + + * editline.h: nuke NEW, DISPOSE, RENEW, and COPYFROMTO macros + + * editline.c: nuke NEW, DISPOSE, RENEW, and COPYFROMTO macros + + * sysunix.c: add some whitespace + +Thu Mar 18 11:22:55 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * Makefile.am: include Makefile.am.common + +Tue Mar 16 17:10:34 1999 Johan Danielsson <joda@hella.pdc.kth.se> + + * editline.c: remove protos for read/write + +Sat Mar 13 22:23:22 1999 Assar Westerlund <assar@sics.se> + + * <roken.h>: add + +Sun Nov 22 10:40:28 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (WFLAGS): set + +Tue Sep 29 02:09:15 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (LIB_DEPS): add LIB_tgetent + +Thu Jul 2 15:10:08 1998 Johan Danielsson <joda@blubb.pdc.kth.se> + + * edit_compat.c: support for newer libedit + +Tue Jun 30 17:18:09 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (distclean): don't remove roken_rename.h + +Fri May 29 19:03:38 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (strdup.c): remove dependency + +Mon May 25 05:25:16 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in (clean): try to remove shared library debris + +Sun Apr 19 09:53:46 1998 Assar Westerlund <assar@sics.se> + + * Makefile.in: add symlink magic for linux + +Sat Feb 7 07:24:30 1998 Assar Westerlund <assar@sics.se> + + * editline.h: add prototypes + +Tue Feb 3 10:24:22 1998 Johan Danielsson <joda@emma.pdc.kth.se> + + * editline.c: If read returns EINTR, try again. diff --git a/crypto/heimdal/lib/editline/Makefile.am b/crypto/heimdal/lib/editline/Makefile.am new file mode 100644 index 0000000..49e4885 --- /dev/null +++ b/crypto/heimdal/lib/editline/Makefile.am @@ -0,0 +1,54 @@ +# $Id: Makefile.am,v 1.12 2000/11/14 23:22:29 assar Exp $ + +include $(top_srcdir)/Makefile.am.common + +if do_roken_rename +IS = -DROKEN_RENAME +ES = snprintf.c strdup.c +endif + +INCLUDES += $(IS) + +man_MANS = editline.3 + +lib_LTLIBRARIES = libeditline.la +if el_compat +noinst_LTLIBRARIES = libel_compat.la +else +noinst_LTLIBRARIES = +endif + +noinst_PROGRAMS = testit + +CHECK_LOCAL = + +testit_LDADD = \ + libeditline.la \ + $(LIB_tgetent) \ + $(LIB_roken) + +include_HEADERS = editline.h + +libeditline_la_SOURCES = \ + complete.c \ + editline.c \ + sysunix.c \ + editline.h \ + roken_rename.h \ + unix.h \ + $(EXTRA_SOURCE) + +libeditline_la_LDFLAGS = -static + +EXTRA_SOURCE = $(ES) + +libel_compat_la_SOURCES = edit_compat.c + +libel_compat_la_LDFLAGS = -static + +EXTRA_DIST = $(man_MANS) + +snprintf.c: + $(LN_S) $(srcdir)/../roken/snprintf.c . +strdup.c: + $(LN_S) $(srcdir)/../roken/strdup.c . diff --git a/crypto/heimdal/lib/editline/Makefile.in b/crypto/heimdal/lib/editline/Makefile.in new file mode 100644 index 0000000..4a06487 --- /dev/null +++ b/crypto/heimdal/lib/editline/Makefile.in @@ -0,0 +1,715 @@ +# Makefile.in generated automatically by automake 1.4b from Makefile.am + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# 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. + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : + +@SET_MAKE@ +host_alias = @host_alias@ +host_triplet = @host@ +AIX_EXTRA_KAFS = @AIX_EXTRA_KAFS@ +AMDEP = @AMDEP@ +AMTAR = @AMTAR@ +AS = @AS@ +AWK = @AWK@ +CANONICAL_HOST = @CANONICAL_HOST@ +CATMAN = @CATMAN@ +CATMANEXT = @CATMANEXT@ +CC = @CC@ +CPP = @CPP@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +DBLIB = @DBLIB@ +DEPDIR = @DEPDIR@ +DIR_des = @DIR_des@ +DIR_roken = @DIR_roken@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +EXTRA_LIB45 = @EXTRA_LIB45@ +GROFF = @GROFF@ +INCLUDES_roken = @INCLUDES_roken@ +INCLUDE_ = @INCLUDE_@ +LEX = @LEX@ +LIBOBJS = @LIBOBJS@ +LIBTOOL = @LIBTOOL@ +LIB_ = @LIB_@ +LIB_AUTH_SUBDIRS = @LIB_AUTH_SUBDIRS@ +LIB_des = @LIB_des@ +LIB_des_appl = @LIB_des_appl@ +LIB_kdb = @LIB_kdb@ +LIB_otp = @LIB_otp@ +LIB_roken = @LIB_roken@ +LIB_security = @LIB_security@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +NEED_WRITEAUTH_FALSE = @NEED_WRITEAUTH_FALSE@ +NEED_WRITEAUTH_TRUE = @NEED_WRITEAUTH_TRUE@ +NROFF = @NROFF@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +STRIP = @STRIP@ +VERSION = @VERSION@ +VOID_RETSIGTYPE = @VOID_RETSIGTYPE@ +WFLAGS = @WFLAGS@ +WFLAGS_NOIMPLICITINT = @WFLAGS_NOIMPLICITINT@ +WFLAGS_NOUNUSED = @WFLAGS_NOUNUSED@ +YACC = @YACC@ +dpagaix_CFLAGS = @dpagaix_CFLAGS@ +dpagaix_LDADD = @dpagaix_LDADD@ +install_sh = @install_sh@ + +# $Id: Makefile.am,v 1.12 2000/11/14 23:22:29 assar Exp $ + + +# $Id: Makefile.am.common,v 1.3 1999/04/01 14:58:43 joda Exp $ + + +# $Id: Makefile.am.common,v 1.26 2001/05/21 13:27:48 joda Exp $ + + +AUTOMAKE_OPTIONS = foreign no-dependencies + +SUFFIXES = .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x + +INCLUDES = -I$(top_builddir)/include $(INCLUDES_roken) $(IS) + +AM_CFLAGS = $(WFLAGS) + +CP = cp + +COMPILE_ET = $(top_builddir)/lib/com_err/compile_et + +buildinclude = $(top_builddir)/include + +LIB_XauReadAuth = @LIB_XauReadAuth@ +LIB_crypt = @LIB_crypt@ +LIB_dbm_firstkey = @LIB_dbm_firstkey@ +LIB_dbopen = @LIB_dbopen@ +LIB_dlopen = @LIB_dlopen@ +LIB_dn_expand = @LIB_dn_expand@ +LIB_el_init = @LIB_el_init@ +LIB_getattr = @LIB_getattr@ +LIB_gethostbyname = @LIB_gethostbyname@ +LIB_getpwent_r = @LIB_getpwent_r@ +LIB_getpwnam_r = @LIB_getpwnam_r@ +LIB_getsockopt = @LIB_getsockopt@ +LIB_logout = @LIB_logout@ +LIB_logwtmp = @LIB_logwtmp@ +LIB_odm_initialize = @LIB_odm_initialize@ +LIB_pidfile = @LIB_pidfile@ +LIB_readline = @LIB_readline@ +LIB_res_search = @LIB_res_search@ +LIB_setpcred = @LIB_setpcred@ +LIB_setsockopt = @LIB_setsockopt@ +LIB_socket = @LIB_socket@ +LIB_syslog = @LIB_syslog@ +LIB_tgetent = @LIB_tgetent@ + +LIBS = @LIBS@ + +HESIODLIB = @HESIODLIB@ +HESIODINCLUDE = @HESIODINCLUDE@ +INCLUDE_hesiod = @INCLUDE_hesiod@ +LIB_hesiod = @LIB_hesiod@ + +INCLUDE_krb4 = @INCLUDE_krb4@ +LIB_krb4 = @LIB_krb4@ + +INCLUDE_openldap = @INCLUDE_openldap@ +LIB_openldap = @LIB_openldap@ + +INCLUDE_readline = @INCLUDE_readline@ + +LEXLIB = @LEXLIB@ + +NROFF_MAN = groff -mandoc -Tascii + +@KRB4_TRUE@LIB_kafs = @KRB4_TRUE@$(top_builddir)/lib/kafs/libkafs.la $(AIX_EXTRA_KAFS) + +@KRB5_TRUE@LIB_krb5 = @KRB5_TRUE@$(top_builddir)/lib/krb5/libkrb5.la \ +@KRB5_TRUE@ $(top_builddir)/lib/asn1/libasn1.la +@KRB5_TRUE@LIB_gssapi = @KRB5_TRUE@$(top_builddir)/lib/gssapi/libgssapi.la + +@DCE_TRUE@LIB_kdfs = @DCE_TRUE@$(top_builddir)/lib/kdfs/libkdfs.la + +CHECK_LOCAL = + +@do_roken_rename_TRUE@IS = @do_roken_rename_TRUE@-DROKEN_RENAME +@do_roken_rename_TRUE@ES = @do_roken_rename_TRUE@snprintf.c strdup.c + +man_MANS = editline.3 + +lib_LTLIBRARIES = libeditline.la +@el_compat_TRUE@noinst_LTLIBRARIES = @el_compat_TRUE@libel_compat.la +@el_compat_FALSE@noinst_LTLIBRARIES = + +noinst_PROGRAMS = testit + +testit_LDADD = \ + libeditline.la \ + $(LIB_tgetent) \ + $(LIB_roken) + + +include_HEADERS = editline.h + +libeditline_la_SOURCES = \ + complete.c \ + editline.c \ + sysunix.c \ + editline.h \ + roken_rename.h \ + unix.h \ + $(EXTRA_SOURCE) + + +libeditline_la_LDFLAGS = -static + +EXTRA_SOURCE = $(ES) + +libel_compat_la_SOURCES = edit_compat.c + +libel_compat_la_LDFLAGS = -static + +EXTRA_DIST = $(man_MANS) +subdir = lib/editline +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../../include/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I../../include +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +X_CFLAGS = @X_CFLAGS@ +X_LIBS = @X_LIBS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +libeditline_la_LIBADD = +@do_roken_rename_FALSE@am_libeditline_la_OBJECTS = complete.lo \ +@do_roken_rename_FALSE@editline.lo sysunix.lo +@do_roken_rename_TRUE@am_libeditline_la_OBJECTS = complete.lo \ +@do_roken_rename_TRUE@editline.lo sysunix.lo snprintf.lo strdup.lo +libeditline_la_OBJECTS = $(am_libeditline_la_OBJECTS) +libel_compat_la_LIBADD = +am_libel_compat_la_OBJECTS = edit_compat.lo +libel_compat_la_OBJECTS = $(am_libel_compat_la_OBJECTS) +noinst_PROGRAMS = testit$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) + +testit_SOURCES = testit.c +testit_OBJECTS = testit.$(OBJEXT) +testit_DEPENDENCIES = libeditline.la +testit_LDFLAGS = +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CFLAGS = @CFLAGS@ +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DIST_SOURCES = $(libeditline_la_SOURCES) $(libel_compat_la_SOURCES) \ +testit.c +man3dir = $(mandir)/man3 +MANS = $(man_MANS) +HEADERS = $(include_HEADERS) + +depcomp = +DIST_COMMON = README $(include_HEADERS) ChangeLog Makefile.am \ +Makefile.in + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +GZIP_ENV = --best +SOURCES = $(libeditline_la_SOURCES) $(libel_compat_la_SOURCES) testit.c +OBJECTS = $(am_libeditline_la_OBJECTS) $(am_libel_compat_la_OBJECTS) testit.$(OBJEXT) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .et .h .1 .3 .5 .8 .cat1 .cat3 .cat5 .cat8 .x .c .lo .o .obj +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) $(top_srcdir)/Makefile.am.common $(top_srcdir)/cf/Makefile.am.common + cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/editline/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +mostlyclean-noinstLTLIBRARIES: + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + +distclean-noinstLTLIBRARIES: + +maintainer-clean-noinstLTLIBRARIES: + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libeditline.la: $(libeditline_la_OBJECTS) $(libeditline_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libeditline_la_LDFLAGS) $(libeditline_la_OBJECTS) $(libeditline_la_LIBADD) $(LIBS) + +libel_compat.la: $(libel_compat_la_OBJECTS) $(libel_compat_la_DEPENDENCIES) + $(LINK) $(libel_compat_la_LDFLAGS) $(libel_compat_la_OBJECTS) $(libel_compat_la_LIBADD) $(LIBS) + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +testit$(EXEEXT): $(testit_OBJECTS) $(testit_DEPENDENCIES) + @rm -f testit$(EXEEXT) + $(LINK) $(testit_LDFLAGS) $(testit_OBJECTS) $(testit_LDADD) $(LIBS) +.c.o: + $(COMPILE) -c $< +.c.obj: + $(COMPILE) -c `cygpath -w $<` +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +install-man3: + $(mkinstalldirs) $(DESTDIR)$(man3dir) + @list='$(man3_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.3*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \ + done + +uninstall-man3: + @list='$(man3_MANS)'; \ + l2='$(man_MANS)'; for i in $$l2; do \ + case "$$i" in \ + *.3*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man3dir)/$$inst"; \ + rm -f $(DESTDIR)$(man3dir)/$$inst; \ + done +install-man: $(MANS) + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-man3 +uninstall-man: + @$(NORMAL_UNINSTALL) + $(MAKE) $(AM_MAKEFLAGS) uninstall-man3 + +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(includedir) + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/$$f; \ + done + +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(include_HEADERS)'; for p in $$list; do \ + f="`echo $$p | sed -e 's|^.*/||'`"; \ + echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ + rm -f $(DESTDIR)$(includedir)/$$f; \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(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; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(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; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $$here + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-local +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: install-libLTLIBRARIES + @$(NORMAL_INSTALL) + $(MAKE) $(AM_MAKEFLAGS) install-exec-hook +install-exec: install-exec-am + +install-data-am: install-man install-includeHEADERS install-data-local +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: uninstall-libLTLIBRARIES uninstall-man \ + uninstall-includeHEADERS +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(MANS) $(HEADERS) all-local +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(mandir)/man3 \ + $(DESTDIR)$(includedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + -rm -f Makefile.in +mostlyclean-am: mostlyclean-libLTLIBRARIES \ + mostlyclean-noinstLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-noinstPROGRAMS \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-libLTLIBRARIES clean-noinstLTLIBRARIES clean-compile \ + clean-libtool clean-noinstPROGRAMS clean-tags \ + clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-libLTLIBRARIES distclean-noinstLTLIBRARIES \ + distclean-compile distclean-libtool \ + distclean-noinstPROGRAMS distclean-tags \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-noinstLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-noinstPROGRAMS maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES \ +mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \ +clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool mostlyclean-noinstPROGRAMS \ +distclean-noinstPROGRAMS clean-noinstPROGRAMS \ +maintainer-clean-noinstPROGRAMS install-man3 uninstall-man3 install-man \ +uninstall-man uninstall-includeHEADERS install-includeHEADERS tags \ +mostlyclean-tags distclean-tags clean-tags maintainer-clean-tags \ +distdir info-am info dvi-am dvi check-local check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-local install-data-am install-data install-am install \ +uninstall-am uninstall all-local all-redirect all-am all install-strip \ +installdirs mostlyclean-generic distclean-generic clean-generic \ +maintainer-clean-generic clean mostlyclean distclean maintainer-clean + + +install-suid-programs: + @foo='$(bin_SUIDS)'; \ + for file in $$foo; do \ + x=$(DESTDIR)$(bindir)/$$file; \ + if chown 0:0 $$x && chmod u+s $$x; then :; else \ + echo "*"; \ + echo "* Failed to install $$x setuid root"; \ + echo "*"; \ + fi; done + +install-exec-hook: install-suid-programs + +install-build-headers:: $(include_HEADERS) $(build_HEADERZ) + @foo='$(include_HEADERS) $(build_HEADERZ)'; \ + for f in $$foo; do \ + f=`basename $$f`; \ + if test -f "$(srcdir)/$$f"; then file="$(srcdir)/$$f"; \ + else file="$$f"; fi; \ + if cmp -s $$file $(buildinclude)/$$f 2> /dev/null ; then \ + : ; else \ + echo " $(CP) $$file $(buildinclude)/$$f"; \ + $(CP) $$file $(buildinclude)/$$f; \ + fi ; \ + done + +all-local: install-build-headers +#NROFF_MAN = nroff -man +.1.cat1: + $(NROFF_MAN) $< > $@ +.3.cat3: + $(NROFF_MAN) $< > $@ +.5.cat5: + $(NROFF_MAN) $< > $@ +.8.cat8: + $(NROFF_MAN) $< > $@ + +dist-cat1-mans: + @foo='$(man1_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.1) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat1/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat3-mans: + @foo='$(man3_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.3) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat3/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat5-mans: + @foo='$(man5_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.5) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat5/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-cat8-mans: + @foo='$(man8_MANS)'; \ + bar='$(man_MANS)'; \ + for i in $$bar; do \ + case $$i in \ + *.8) foo="$$foo $$i";; \ + esac; done ;\ + for i in $$foo; do \ + x=`echo $$i | sed 's/\.[^.]*$$/.cat8/'`; \ + echo "$(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x"; \ + $(NROFF_MAN) $(srcdir)/$$i > $(distdir)/$$x; \ + done + +dist-hook: dist-cat1-mans dist-cat3-mans dist-cat5-mans dist-cat8-mans + +install-cat-mans: + $(SHELL) $(top_srcdir)/cf/install-catman.sh "$(INSTALL_DATA)" "$(mkinstalldirs)" "$(srcdir)" "$(DESTDIR)$(mandir)" '$(CATMANEXT)' $(man_MANS) $(man1_MANS) $(man3_MANS) $(man5_MANS) $(man8_MANS) + +install-data-local: install-cat-mans + +.et.h: + $(COMPILE_ET) $< +.et.c: + $(COMPILE_ET) $< + +.x.c: + @cmp -s $< $@ 2> /dev/null || cp $< $@ + +check-local:: + @foo='$(CHECK_LOCAL)'; \ + if test "$$foo"; then \ + failed=0; all=0; \ + for i in $$foo; do \ + all=`expr $$all + 1`; \ + if ./$$i --version > /dev/null 2>&1; then \ + echo "PASS: $$i"; \ + else \ + echo "FAIL: $$i"; \ + failed=`expr $$failed + 1`; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="$$failed of $$all tests failed"; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +snprintf.c: + $(LN_S) $(srcdir)/../roken/snprintf.c . +strdup.c: + $(LN_S) $(srcdir)/../roken/strdup.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: diff --git a/crypto/heimdal/lib/editline/README b/crypto/heimdal/lib/editline/README new file mode 100644 index 0000000..829db99 --- /dev/null +++ b/crypto/heimdal/lib/editline/README @@ -0,0 +1,45 @@ +$Revision: 1.1 $ + +This is a line-editing library. It can be linked into almost any +program to provide command-line editing and recall. + +It is call-compatible with the FSF readline library, but it is a +fraction of the size (and offers fewer features). It does not use +standard I/O. It is distributed under a "C News-like" copyright. + +Configuration is done in the Makefile. Type "make testit" to get +a small slow shell for testing. + +An earlier version was distributed with Byron's rc. Principal +changes over that version include: + Faster. + Is eight-bit clean (thanks to brendan@cs.widener.edu) + Written in K&R C, but ANSI compliant (gcc all warnings) + Propagates EOF properly; rc trip test now passes + Doesn't need or use or provide memmove. + More robust + Calling sequence changed to be compatible with readline. + Test program, new manpage, better configuration + More system-independant; includes Unix and OS-9 support. + +Enjoy, + Rich $alz + <rsalz@osf.org> + + Copyright 1992 Simmule Turner and Rich Salz. All rights reserved. + + This software is not subject to any license of the American Telephone + and Telegraph Company or of the Regents of the University of California. + + Permission is granted to anyone to use this software for any purpose on + any computer system, and to alter it and redistribute it freely, subject + to the following restrictions: + 1. The authors are not responsible for the consequences of use of this + software, no matter how awful, even if they arise from flaws in it. + 2. The origin of this software must not be misrepresented, either by + explicit claim or by omission. Since few users ever read sources, + credits must appear in the documentation. + 3. Altered versions must be plainly marked as such, and must not be + misrepresented as being the original software. Since few users + ever read sources, credits must appear in the documentation. + 4. This notice may not be removed or altered. diff --git a/crypto/heimdal/lib/editline/complete.c b/crypto/heimdal/lib/editline/complete.c new file mode 100644 index 0000000..d2a311d --- /dev/null +++ b/crypto/heimdal/lib/editline/complete.c @@ -0,0 +1,243 @@ +/* Copyright 1992 Simmule Turner and Rich Salz. All rights reserved. + * + * This software is not subject to any license of the American Telephone + * and Telegraph Company or of the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on + * any computer system, and to alter it and redistribute it freely, subject + * to the following restrictions: + * 1. The authors are not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits must appear in the documentation. + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits must appear in the documentation. + * 4. This notice may not be removed or altered. + */ + +/* +** History and file completion functions for editline library. +*/ +#include <config.h> +#include "editline.h" + +RCSID("$Id: complete.c,v 1.5 1999/04/10 21:01:16 joda Exp $"); + +/* +** strcmp-like sorting predicate for qsort. +*/ +static int +compare(const void *p1, const void *p2) +{ + const char **v1; + const char **v2; + + v1 = (const char **)p1; + v2 = (const char **)p2; + return strcmp(*v1, *v2); +} + +/* +** Fill in *avp with an array of names that match file, up to its length. +** Ignore . and .. . +*/ +static int +FindMatches(char *dir, char *file, char ***avp) +{ + char **av; + char **new; + char *p; + DIR *dp; + DIRENTRY *ep; + size_t ac; + size_t len; + + if ((dp = opendir(dir)) == NULL) + return 0; + + av = NULL; + ac = 0; + len = strlen(file); + while ((ep = readdir(dp)) != NULL) { + p = ep->d_name; + if (p[0] == '.' && (p[1] == '\0' || (p[1] == '.' && p[2] == '\0'))) + continue; + if (len && strncmp(p, file, len) != 0) + continue; + + if ((ac % MEM_INC) == 0) { + if ((new = malloc(sizeof(char*) * (ac + MEM_INC))) == NULL) + break; + if (ac) { + memcpy(new, av, ac * sizeof (char **)); + free(av); + } + *avp = av = new; + } + + if ((av[ac] = strdup(p)) == NULL) { + if (ac == 0) + free(av); + break; + } + ac++; + } + + /* Clean up and return. */ + (void)closedir(dp); + if (ac) + qsort(av, ac, sizeof (char **), compare); + return ac; +} + +/* +** Split a pathname into allocated directory and trailing filename parts. +*/ +static int SplitPath(char *path, char **dirpart, char **filepart) +{ + static char DOT[] = "."; + char *dpart; + char *fpart; + + if ((fpart = strrchr(path, '/')) == NULL) { + if ((dpart = strdup(DOT)) == NULL) + return -1; + if ((fpart = strdup(path)) == NULL) { + free(dpart); + return -1; + } + } + else { + if ((dpart = strdup(path)) == NULL) + return -1; + dpart[fpart - path] = '\0'; + if ((fpart = strdup(++fpart)) == NULL) { + free(dpart); + return -1; + } + } + *dirpart = dpart; + *filepart = fpart; + return 0; +} + +/* +** Attempt to complete the pathname, returning an allocated copy. +** Fill in *unique if we completed it, or set it to 0 if ambiguous. +*/ + +static char * +rl_complete_filename(char *pathname, int *unique) +{ + char **av; + char *new; + char *p; + size_t ac; + size_t end; + size_t i; + size_t j; + size_t len; + char *s; + + ac = rl_list_possib(pathname, &av); + if(ac == 0) + return NULL; + + s = strrchr(pathname, '/'); + if(s == NULL) + len = strlen(pathname); + else + len = strlen(s + 1); + + p = NULL; + if (ac == 1) { + /* Exactly one match -- finish it off. */ + *unique = 1; + j = strlen(av[0]) - len + 2; + if ((p = malloc(j + 1)) != NULL) { + memcpy(p, av[0] + len, j); + asprintf(&new, "%s%s", pathname, p); + if(new != NULL) { + rl_add_slash(new, p); + free(new); + } + } + } + else { + *unique = 0; + if (len) { + /* Find largest matching substring. */ + for (i = len, end = strlen(av[0]); i < end; i++) + for (j = 1; j < ac; j++) + if (av[0][i] != av[j][i]) + goto breakout; + breakout: + if (i > len) { + j = i - len + 1; + if ((p = malloc(j)) != NULL) { + memcpy(p, av[0] + len, j); + p[j - 1] = '\0'; + } + } + } + } + + /* Clean up and return. */ + for (i = 0; i < ac; i++) + free(av[i]); + free(av); + return p; +} + +static rl_complete_func_t complete_func = rl_complete_filename; + +char * +rl_complete(char *pathname, int *unique) +{ + return (*complete_func)(pathname, unique); +} + +rl_complete_func_t +rl_set_complete_func(rl_complete_func_t func) +{ + rl_complete_func_t old = complete_func; + complete_func = func; + return old; +} + + +/* +** Return all possible completions. +*/ +static int +rl_list_possib_filename(char *pathname, char ***avp) +{ + char *dir; + char *file; + int ac; + + if (SplitPath(pathname, &dir, &file) < 0) + return 0; + ac = FindMatches(dir, file, avp); + free(dir); + free(file); + return ac; +} + +static rl_list_possib_func_t list_possib_func = rl_list_possib_filename; + +int +rl_list_possib(char *pathname, char ***avp) +{ + return (*list_possib_func)(pathname, avp); +} + +rl_list_possib_func_t +rl_set_list_possib_func(rl_list_possib_func_t func) +{ + rl_list_possib_func_t old = list_possib_func; + list_possib_func = func; + return old; +} diff --git a/crypto/heimdal/lib/editline/edit_compat.c b/crypto/heimdal/lib/editline/edit_compat.c new file mode 100644 index 0000000..9b1863e --- /dev/null +++ b/crypto/heimdal/lib/editline/edit_compat.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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 Institute 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 INSTITUTE 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 INSTITUTE 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 <config.h> +#include <stdio.h> +#include <string.h> +#include <histedit.h> + +RCSID("$Id: edit_compat.c,v 1.8 2000/03/01 20:53:05 assar Exp $"); + +void +rl_reset_terminal(char *p) +{ +} + +void +rl_initialize() +{ +} + +static const char *pr; +static const char* ret_prompt(EditLine *e) +{ + return pr; +} + +static History *h; + +#ifdef H_SETSIZE +#define EL_INIT_FOUR 1 +#else +#ifdef H_SETMAXSIZE +/* backwards compatibility */ +#define H_SETSIZE H_SETMAXSIZE +#endif +#endif + +char * +readline(const char* prompt) +{ + static EditLine *e; +#ifdef H_SETSIZE + HistEvent ev; +#endif + int count; + const char *str; + + if(e == NULL){ +#ifdef EL_INIT_FOUR + e = el_init("", stdin, stdout, stderr); +#else + e = el_init("", stdin, stdout); +#endif + el_set(e, EL_PROMPT, ret_prompt); + h = history_init(); +#ifdef H_SETSIZE + history(h, &ev, H_SETSIZE, 25); +#else + history(h, H_EVENT, 25); +#endif + el_set(e, EL_HIST, history, h); + el_set(e, EL_EDITOR, "emacs"); /* XXX? */ + } + pr = prompt ? prompt : ""; + str = el_gets(e, &count); + if (str && count > 0) { + char *ret = strdup (str); + + if (ret == NULL) + return NULL; + + if (ret[strlen(ret) - 1] == '\n') + ret[strlen(ret) - 1] = '\0'; + return ret; + } + return NULL; +} + +void +add_history(char *p) +{ +#ifdef H_SETSIZE + HistEvent ev; + history(h, &ev, H_ENTER, p); +#else + history(h, H_ENTER, p); +#endif +} diff --git a/crypto/heimdal/lib/editline/editline.3 b/crypto/heimdal/lib/editline/editline.3 new file mode 100644 index 0000000..6e30a09 --- /dev/null +++ b/crypto/heimdal/lib/editline/editline.3 @@ -0,0 +1,175 @@ +.\" $Revision: 1.2 $ +.TH EDITLINE 3 +.SH NAME +editline \- command-line editing library with history +.SH SYNOPSIS +.nf +.B "char *" +.B "readline(prompt)" +.B " char *prompt;" + +.B "void" +.B "add_history(line)" +.B " char *line;" +.fi +.SH DESCRIPTION +.I Editline +is a library that provides an line-editing interface with text recall. +It is intended to be compatible with the +.I readline +library provided by the Free Software Foundation, but much smaller. +The bulk of this manual page describes the user interface. +.PP +The +.I readline +routine returns a line of text with the trailing newline removed. +The data is returned in a buffer allocated with +.IR malloc (3), +so the space should be released with +.IR free (3) +when the calling program is done with it. +Before accepting input from the user, the specified +.I prompt +is displayed on the terminal. +.PP +The +.I add_history +routine makes a copy of the specified +.I line +and adds it to the internal history list. +.SS "User Interface" +A program that uses this library provides a simple emacs-like editing +interface to its users. +A line may be edited before it is sent to the calling program by typing either +control characters or escape sequences. +A control character, shown as a caret followed by a letter, is typed by +holding down the ``control'' key while the letter is typed. +For example, ``^A'' is a control-A. +An escape sequence is entered by typing the ``escape'' key followed by one or +more characters. +The escape key is abbreviated as ``ESC.'' +Note that unlike control keys, case matters in escape sequences; ``ESC\ F'' +is not the same as ``ESC\ f''. +.PP +An editing command may be typed anywhere on the line, not just at the +beginning. +In addition, a return may also be typed anywhere on the line, not just at +the end. +.PP +Most editing commands may be given a repeat count, +.IR n , +where +.I n +is a number. +To enter a repeat count, type the escape key, the number, and then +the command to execute. +For example, ``ESC\ 4\ ^f'' moves forward four characters. +If a command may be given a repeat count then the text ``[n]'' is given at the +end of its description. +.PP +The following control characters are accepted: +.RS +.nf +.ta \w'ESC DEL 'u +^A Move to the beginning of the line +^B Move left (backwards) [n] +^D Delete character [n] +^E Move to end of line +^F Move right (forwards) [n] +^G Ring the bell +^H Delete character before cursor (backspace key) [n] +^I Complete filename (tab key); see below +^J Done with line (return key) +^K Kill to end of line (or column [n]) +^L Redisplay line +^M Done with line (alternate return key) +^N Get next line from history [n] +^P Get previous line from history [n] +^R Search backward (forward if [n]) through history for text; +\& must start line if text begins with an uparrow +^T Transpose characters +^V Insert next character, even if it is an edit command +^W Wipe to the mark +^X^X Exchange current location and mark +^Y Yank back last killed text +^[ Start an escape sequence (escape key) +^]c Move forward to next character ``c'' +^? Delete character before cursor (delete key) [n] +.fi +.RE +.PP +The following escape sequences are provided. +.RS +.nf +.ta \w'ESC DEL 'u +ESC\ ^H Delete previous word (backspace key) [n] +ESC\ DEL Delete previous word (delete key) [n] +ESC\ SP Set the mark (space key); see ^X^X and ^Y above +ESC\ \. Get the last (or [n]'th) word from previous line +ESC\ ? Show possible completions; see below +ESC\ < Move to start of history +ESC\ > Move to end of history +ESC\ b Move backward a word [n] +ESC\ d Delete word under cursor [n] +ESC\ f Move forward a word [n] +ESC\ l Make word lowercase [n] +ESC\ u Make word uppercase [n] +ESC\ y Yank back last killed text +ESC\ v Show library version +ESC\ w Make area up to mark yankable +ESC\ nn Set repeat count to the number nn +ESC\ C Read from environment variable ``_C_'', where C is +\& an uppercase letter +.fi +.RE +.PP +The +.I editline +library has a small macro facility. +If you type the escape key followed by an uppercase letter, +.IR C , +then the contents of the environment variable +.I _C_ +are read in as if you had typed them at the keyboard. +For example, if the variable +.I _L_ +contains the following: +.RS +^A^Kecho '^V^[[H^V^[[2J'^M +.RE +Then typing ``ESC L'' will move to the beginning of the line, kill the +entire line, enter the echo command needed to clear the terminal (if your +terminal is like a VT-100), and send the line back to the shell. +.PP +The +.I editline +library also does filename completion. +Suppose the root directory has the following files in it: +.RS +.nf +.ta \w'core 'u +bin vmunix +core vmunix.old +.fi +.RE +If you type ``rm\ /v'' and then the tab key. +.I Editline +will then finish off as much of the name as possible by adding ``munix''. +Because the name is not unique, it will then beep. +If you type the escape key and a question mark, it will display the +two choices. +If you then type a period and a tab, the library will finish off the filename +for you: +.RS +.nf +.RI "rm /v[TAB]" munix .TAB old +.fi +.RE +The tab key is shown by ``[TAB]'' and the automatically-entered text +is shown in italics. +.SH "BUGS AND LIMITATIONS" +Cannot handle lines more than 80 columns. +.SH AUTHORS +Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy> +and Rich $alz <rsalz@osf.org>. +Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>. diff --git a/crypto/heimdal/lib/editline/editline.c b/crypto/heimdal/lib/editline/editline.c new file mode 100644 index 0000000..43dd58a --- /dev/null +++ b/crypto/heimdal/lib/editline/editline.c @@ -0,0 +1,1376 @@ +/* Copyright 1992 Simmule Turner and Rich Salz. All rights reserved. + * + * This software is not subject to any license of the American Telephone + * and Telegraph Company or of the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on + * any computer system, and to alter it and redistribute it freely, subject + * to the following restrictions: + * 1. The authors are not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits must appear in the documentation. + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits must appear in the documentation. + * 4. This notice may not be removed or altered. + */ + +/* +** Main editing routines for editline library. +*/ +#include <config.h> +#include "editline.h" +#include <ctype.h> +#include <errno.h> + +RCSID("$Id: editline.c,v 1.9 1999/12/23 21:27:00 assar Exp $"); + +/* +** Manifest constants. +*/ +#define SCREEN_WIDTH 80 +#define SCREEN_ROWS 24 +#define NO_ARG (-1) +#define DEL 127 +#define CTL(x) ((x) & 0x1F) +#define ISCTL(x) ((x) && (x) < ' ') +#define UNCTL(x) ((x) + 64) +#define META(x) ((x) | 0x80) +#define ISMETA(x) ((x) & 0x80) +#define UNMETA(x) ((x) & 0x7F) +#if !defined(HIST_SIZE) +#define HIST_SIZE 20 +#endif /* !defined(HIST_SIZE) */ + +/* +** Command status codes. +*/ +typedef enum _STATUS { + CSdone, CSeof, CSmove, CSdispatch, CSstay +} STATUS; + +/* +** The type of case-changing to perform. +*/ +typedef enum _CASE { + TOupper, TOlower +} CASE; + +/* +** Key to command mapping. +*/ +typedef struct _KEYMAP { + unsigned char Key; + STATUS (*Function)(); +} KEYMAP; + +/* +** Command history structure. +*/ +typedef struct _HISTORY { + int Size; + int Pos; + unsigned char *Lines[HIST_SIZE]; +} HISTORY; + +/* +** Globals. +*/ +int rl_eof; +int rl_erase; +int rl_intr; +int rl_kill; + +static unsigned char NIL[] = ""; +static const unsigned char *Input = NIL; +static unsigned char *Line; +static const char *Prompt; +static unsigned char *Yanked; +static char *Screen; +static char NEWLINE[]= CRLF; +static HISTORY H; +int rl_quit; +static int Repeat; +static int End; +static int Mark; +static int OldPoint; +static int Point; +static int PushBack; +static int Pushed; +static KEYMAP Map[33]; +static KEYMAP MetaMap[16]; +static size_t Length; +static size_t ScreenCount; +static size_t ScreenSize; +static char *backspace; +static int TTYwidth; +static int TTYrows; + +/* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */ +int rl_meta_chars = 1; + +/* +** Declarations. +*/ +static unsigned char *editinput(void); +char *tgetstr(const char*, char**); +int tgetent(char*, const char*); +int tgetnum(const char*); + +/* +** TTY input/output functions. +*/ + +static void +TTYflush() +{ + if (ScreenCount) { + write(1, Screen, ScreenCount); + ScreenCount = 0; + } +} + +static void +TTYput(unsigned char c) +{ + Screen[ScreenCount] = c; + if (++ScreenCount >= ScreenSize - 1) { + ScreenSize += SCREEN_INC; + Screen = realloc(Screen, ScreenSize); + } +} + +static void +TTYputs(const char *p) +{ + while (*p) + TTYput(*p++); +} + +static void +TTYshow(unsigned char c) +{ + if (c == DEL) { + TTYput('^'); + TTYput('?'); + } + else if (ISCTL(c)) { + TTYput('^'); + TTYput(UNCTL(c)); + } + else if (rl_meta_chars && ISMETA(c)) { + TTYput('M'); + TTYput('-'); + TTYput(UNMETA(c)); + } + else + TTYput(c); +} + +static void +TTYstring(unsigned char *p) +{ + while (*p) + TTYshow(*p++); +} + +static int +TTYget() +{ + char c; + int e; + + TTYflush(); + if (Pushed) { + Pushed = 0; + return PushBack; + } + if (*Input) + return *Input++; + do { + e = read(0, &c, 1); + } while(e < 0 && errno == EINTR); + if(e == 1) + return c; + return EOF; +} + +static void +TTYback(void) +{ + if (backspace) + TTYputs(backspace); + else + TTYput('\b'); +} + +static void +TTYbackn(int n) +{ + while (--n >= 0) + TTYback(); +} + +static void +TTYinfo() +{ + static int init; + char *term; + char buff[2048]; + char *bp; + char *tmp; +#if defined(TIOCGWINSZ) + struct winsize W; +#endif /* defined(TIOCGWINSZ) */ + + if (init) { +#if defined(TIOCGWINSZ) + /* Perhaps we got resized. */ + if (ioctl(0, TIOCGWINSZ, &W) >= 0 + && W.ws_col > 0 && W.ws_row > 0) { + TTYwidth = (int)W.ws_col; + TTYrows = (int)W.ws_row; + } +#endif /* defined(TIOCGWINSZ) */ + return; + } + init++; + + TTYwidth = TTYrows = 0; + bp = &buff[0]; + if ((term = getenv("TERM")) == NULL) + term = "dumb"; + if (tgetent(buff, term) < 0) { + TTYwidth = SCREEN_WIDTH; + TTYrows = SCREEN_ROWS; + return; + } + tmp = tgetstr("le", &bp); + if (tmp != NULL) + backspace = strdup(tmp); + else + backspace = "\b"; + TTYwidth = tgetnum("co"); + TTYrows = tgetnum("li"); + +#if defined(TIOCGWINSZ) + if (ioctl(0, TIOCGWINSZ, &W) >= 0) { + TTYwidth = (int)W.ws_col; + TTYrows = (int)W.ws_row; + } +#endif /* defined(TIOCGWINSZ) */ + + if (TTYwidth <= 0 || TTYrows <= 0) { + TTYwidth = SCREEN_WIDTH; + TTYrows = SCREEN_ROWS; + } +} + + +/* +** Print an array of words in columns. +*/ +static void +columns(int ac, unsigned char **av) +{ + unsigned char *p; + int i; + int j; + int k; + int len; + int skip; + int longest; + int cols; + + /* Find longest name, determine column count from that. */ + for (longest = 0, i = 0; i < ac; i++) + if ((j = strlen((char *)av[i])) > longest) + longest = j; + cols = TTYwidth / (longest + 3); + + TTYputs(NEWLINE); + for (skip = ac / cols + 1, i = 0; i < skip; i++) { + for (j = i; j < ac; j += skip) { + for (p = av[j], len = strlen((char *)p), k = len; --k >= 0; p++) + TTYput(*p); + if (j + skip < ac) + while (++len < longest + 3) + TTYput(' '); + } + TTYputs(NEWLINE); + } +} + +static void +reposition() +{ + int i; + unsigned char *p; + + TTYput('\r'); + TTYputs(Prompt); + for (i = Point, p = Line; --i >= 0; p++) + TTYshow(*p); +} + +static void +left(STATUS Change) +{ + TTYback(); + if (Point) { + if (ISCTL(Line[Point - 1])) + TTYback(); + else if (rl_meta_chars && ISMETA(Line[Point - 1])) { + TTYback(); + TTYback(); + } + } + if (Change == CSmove) + Point--; +} + +static void +right(STATUS Change) +{ + TTYshow(Line[Point]); + if (Change == CSmove) + Point++; +} + +static STATUS +ring_bell() +{ + TTYput('\07'); + TTYflush(); + return CSstay; +} + +static STATUS +do_macro(unsigned char c) +{ + unsigned char name[4]; + + name[0] = '_'; + name[1] = c; + name[2] = '_'; + name[3] = '\0'; + + if ((Input = (unsigned char *)getenv((char *)name)) == NULL) { + Input = NIL; + return ring_bell(); + } + return CSstay; +} + +static STATUS +do_forward(STATUS move) +{ + int i; + unsigned char *p; + + i = 0; + do { + p = &Line[Point]; + for ( ; Point < End && (*p == ' ' || !isalnum(*p)); Point++, p++) + if (move == CSmove) + right(CSstay); + + for (; Point < End && isalnum(*p); Point++, p++) + if (move == CSmove) + right(CSstay); + + if (Point == End) + break; + } while (++i < Repeat); + + return CSstay; +} + +static STATUS +do_case(CASE type) +{ + int i; + int end; + int count; + unsigned char *p; + + do_forward(CSstay); + if (OldPoint != Point) { + if ((count = Point - OldPoint) < 0) + count = -count; + Point = OldPoint; + if ((end = Point + count) > End) + end = End; + for (i = Point, p = &Line[i]; i < end; i++, p++) { + if (type == TOupper) { + if (islower(*p)) + *p = toupper(*p); + } + else if (isupper(*p)) + *p = tolower(*p); + right(CSmove); + } + } + return CSstay; +} + +static STATUS +case_down_word() +{ + return do_case(TOlower); +} + +static STATUS +case_up_word() +{ + return do_case(TOupper); +} + +static void +ceol() +{ + int extras; + int i; + unsigned char *p; + + for (extras = 0, i = Point, p = &Line[i]; i <= End; i++, p++) { + TTYput(' '); + if (ISCTL(*p)) { + TTYput(' '); + extras++; + } + else if (rl_meta_chars && ISMETA(*p)) { + TTYput(' '); + TTYput(' '); + extras += 2; + } + } + + for (i += extras; i > Point; i--) + TTYback(); +} + +static void +clear_line() +{ + Point = -strlen(Prompt); + TTYput('\r'); + ceol(); + Point = 0; + End = 0; + Line[0] = '\0'; +} + +static STATUS +insert_string(unsigned char *p) +{ + size_t len; + int i; + unsigned char *new; + unsigned char *q; + + len = strlen((char *)p); + if (End + len >= Length) { + if ((new = malloc(sizeof(unsigned char) * (Length + len + MEM_INC))) == NULL) + return CSstay; + if (Length) { + memcpy(new, Line, Length); + free(Line); + } + Line = new; + Length += len + MEM_INC; + } + + for (q = &Line[Point], i = End - Point; --i >= 0; ) + q[len + i] = q[i]; + memcpy(&Line[Point], p, len); + End += len; + Line[End] = '\0'; + TTYstring(&Line[Point]); + Point += len; + + return Point == End ? CSstay : CSmove; +} + + +static unsigned char * +next_hist() +{ + return H.Pos >= H.Size - 1 ? NULL : H.Lines[++H.Pos]; +} + +static unsigned char * +prev_hist() +{ + return H.Pos == 0 ? NULL : H.Lines[--H.Pos]; +} + +static STATUS +do_insert_hist(unsigned char *p) +{ + if (p == NULL) + return ring_bell(); + Point = 0; + reposition(); + ceol(); + End = 0; + return insert_string(p); +} + +static STATUS +do_hist(unsigned char *(*move)()) +{ + unsigned char *p; + int i; + + i = 0; + do { + if ((p = (*move)()) == NULL) + return ring_bell(); + } while (++i < Repeat); + return do_insert_hist(p); +} + +static STATUS +h_next() +{ + return do_hist(next_hist); +} + +static STATUS +h_prev() +{ + return do_hist(prev_hist); +} + +static STATUS +h_first() +{ + return do_insert_hist(H.Lines[H.Pos = 0]); +} + +static STATUS +h_last() +{ + return do_insert_hist(H.Lines[H.Pos = H.Size - 1]); +} + +/* +** Return zero if pat appears as a substring in text. +*/ +static int +substrcmp(char *text, char *pat, int len) +{ + unsigned char c; + + if ((c = *pat) == '\0') + return *text == '\0'; + for ( ; *text; text++) + if (*text == c && strncmp(text, pat, len) == 0) + return 0; + return 1; +} + +static unsigned char * +search_hist(unsigned char *search, unsigned char *(*move)()) +{ + static unsigned char *old_search; + int len; + int pos; + int (*match)(); + char *pat; + + /* Save or get remembered search pattern. */ + if (search && *search) { + if (old_search) + free(old_search); + old_search = (unsigned char *)strdup((char *)search); + } + else { + if (old_search == NULL || *old_search == '\0') + return NULL; + search = old_search; + } + + /* Set up pattern-finder. */ + if (*search == '^') { + match = strncmp; + pat = (char *)(search + 1); + } + else { + match = substrcmp; + pat = (char *)search; + } + len = strlen(pat); + + for (pos = H.Pos; (*move)() != NULL; ) + if ((*match)((char *)H.Lines[H.Pos], pat, len) == 0) + return H.Lines[H.Pos]; + H.Pos = pos; + return NULL; +} + +static STATUS +h_search() +{ + static int Searching; + const char *old_prompt; + unsigned char *(*move)(); + unsigned char *p; + + if (Searching) + return ring_bell(); + Searching = 1; + + clear_line(); + old_prompt = Prompt; + Prompt = "Search: "; + TTYputs(Prompt); + move = Repeat == NO_ARG ? prev_hist : next_hist; + p = search_hist(editinput(), move); + clear_line(); + Prompt = old_prompt; + TTYputs(Prompt); + + Searching = 0; + return do_insert_hist(p); +} + +static STATUS +fd_char() +{ + int i; + + i = 0; + do { + if (Point >= End) + break; + right(CSmove); + } while (++i < Repeat); + return CSstay; +} + +static void +save_yank(int begin, int i) +{ + if (Yanked) { + free(Yanked); + Yanked = NULL; + } + + if (i < 1) + return; + + if ((Yanked = malloc(sizeof(unsigned char) * (i + 1))) != NULL) { + memcpy(Yanked, &Line[begin], i); + Yanked[i+1] = '\0'; + } +} + +static STATUS +delete_string(int count) +{ + int i; + unsigned char *p; + + if (count <= 0 || End == Point) + return ring_bell(); + + if (count == 1 && Point == End - 1) { + /* Optimize common case of delete at end of line. */ + End--; + p = &Line[Point]; + i = 1; + TTYput(' '); + if (ISCTL(*p)) { + i = 2; + TTYput(' '); + } + else if (rl_meta_chars && ISMETA(*p)) { + i = 3; + TTYput(' '); + TTYput(' '); + } + TTYbackn(i); + *p = '\0'; + return CSmove; + } + if (Point + count > End && (count = End - Point) <= 0) + return CSstay; + + if (count > 1) + save_yank(Point, count); + + for (p = &Line[Point], i = End - (Point + count) + 1; --i >= 0; p++) + p[0] = p[count]; + ceol(); + End -= count; + TTYstring(&Line[Point]); + return CSmove; +} + +static STATUS +bk_char() +{ + int i; + + i = 0; + do { + if (Point == 0) + break; + left(CSmove); + } while (++i < Repeat); + + return CSstay; +} + +static STATUS +bk_del_char() +{ + int i; + + i = 0; + do { + if (Point == 0) + break; + left(CSmove); + } while (++i < Repeat); + + return delete_string(i); +} + +static STATUS +redisplay() +{ + TTYputs(NEWLINE); + TTYputs(Prompt); + TTYstring(Line); + return CSmove; +} + +static STATUS +kill_line() +{ + int i; + + if (Repeat != NO_ARG) { + if (Repeat < Point) { + i = Point; + Point = Repeat; + reposition(); + delete_string(i - Point); + } + else if (Repeat > Point) { + right(CSmove); + delete_string(Repeat - Point - 1); + } + return CSmove; + } + + save_yank(Point, End - Point); + Line[Point] = '\0'; + ceol(); + End = Point; + return CSstay; +} + +static STATUS +insert_char(int c) +{ + STATUS s; + unsigned char buff[2]; + unsigned char *p; + unsigned char *q; + int i; + + if (Repeat == NO_ARG || Repeat < 2) { + buff[0] = c; + buff[1] = '\0'; + return insert_string(buff); + } + + if ((p = malloc(Repeat + 1)) == NULL) + return CSstay; + for (i = Repeat, q = p; --i >= 0; ) + *q++ = c; + *q = '\0'; + Repeat = 0; + s = insert_string(p); + free(p); + return s; +} + +static STATUS +meta() +{ + unsigned int c; + KEYMAP *kp; + + if ((c = TTYget()) == EOF) + return CSeof; + /* Also include VT-100 arrows. */ + if (c == '[' || c == 'O') + switch (c = TTYget()) { + default: return ring_bell(); + case EOF: return CSeof; + case 'A': return h_prev(); + case 'B': return h_next(); + case 'C': return fd_char(); + case 'D': return bk_char(); + } + + if (isdigit(c)) { + for (Repeat = c - '0'; (c = TTYget()) != EOF && isdigit(c); ) + Repeat = Repeat * 10 + c - '0'; + Pushed = 1; + PushBack = c; + return CSstay; + } + + if (isupper(c)) + return do_macro(c); + for (OldPoint = Point, kp = MetaMap; kp->Function; kp++) + if (kp->Key == c) + return (*kp->Function)(); + + return ring_bell(); +} + +static STATUS +emacs(unsigned int c) +{ + STATUS s; + KEYMAP *kp; + + if (ISMETA(c)) { + Pushed = 1; + PushBack = UNMETA(c); + return meta(); + } + for (kp = Map; kp->Function; kp++) + if (kp->Key == c) + break; + s = kp->Function ? (*kp->Function)() : insert_char((int)c); + if (!Pushed) + /* No pushback means no repeat count; hacky, but true. */ + Repeat = NO_ARG; + return s; +} + +static STATUS +TTYspecial(unsigned int c) +{ + if (ISMETA(c)) + return CSdispatch; + + if (c == rl_erase || c == DEL) + return bk_del_char(); + if (c == rl_kill) { + if (Point != 0) { + Point = 0; + reposition(); + } + Repeat = NO_ARG; + return kill_line(); + } + if (c == rl_intr || c == rl_quit) { + Point = End = 0; + Line[0] = '\0'; + return redisplay(); + } + if (c == rl_eof && Point == 0 && End == 0) + return CSeof; + + return CSdispatch; +} + +static unsigned char * +editinput() +{ + unsigned int c; + + Repeat = NO_ARG; + OldPoint = Point = Mark = End = 0; + Line[0] = '\0'; + + while ((c = TTYget()) != EOF) + switch (TTYspecial(c)) { + case CSdone: + return Line; + case CSeof: + return NULL; + case CSmove: + reposition(); + break; + case CSdispatch: + switch (emacs(c)) { + case CSdone: + return Line; + case CSeof: + return NULL; + case CSmove: + reposition(); + break; + case CSdispatch: + case CSstay: + break; + } + break; + case CSstay: + break; + } + return NULL; +} + +static void +hist_add(unsigned char *p) +{ + int i; + + if ((p = (unsigned char *)strdup((char *)p)) == NULL) + return; + if (H.Size < HIST_SIZE) + H.Lines[H.Size++] = p; + else { + free(H.Lines[0]); + for (i = 0; i < HIST_SIZE - 1; i++) + H.Lines[i] = H.Lines[i + 1]; + H.Lines[i] = p; + } + H.Pos = H.Size - 1; +} + +/* +** For compatibility with FSF readline. +*/ +/* ARGSUSED0 */ +void +rl_reset_terminal(char *p) +{ +} + +void +rl_initialize(void) +{ +} + +char * +readline(const char* prompt) +{ + unsigned char *line; + + if (Line == NULL) { + Length = MEM_INC; + if ((Line = malloc(Length)) == NULL) + return NULL; + } + + TTYinfo(); + rl_ttyset(0); + hist_add(NIL); + ScreenSize = SCREEN_INC; + Screen = malloc(ScreenSize); + Prompt = prompt ? prompt : (char *)NIL; + TTYputs(Prompt); + if ((line = editinput()) != NULL) { + line = (unsigned char *)strdup((char *)line); + TTYputs(NEWLINE); + TTYflush(); + } + rl_ttyset(1); + free(Screen); + free(H.Lines[--H.Size]); + return (char *)line; +} + +void +add_history(char *p) +{ + if (p == NULL || *p == '\0') + return; + +#if defined(UNIQUE_HISTORY) + if (H.Pos && strcmp(p, H.Lines[H.Pos - 1]) == 0) + return; +#endif /* defined(UNIQUE_HISTORY) */ + hist_add((unsigned char *)p); +} + + +static STATUS +beg_line() +{ + if (Point) { + Point = 0; + return CSmove; + } + return CSstay; +} + +static STATUS +del_char() +{ + return delete_string(Repeat == NO_ARG ? 1 : Repeat); +} + +static STATUS +end_line() +{ + if (Point != End) { + Point = End; + return CSmove; + } + return CSstay; +} + +/* +** Move back to the beginning of the current word and return an +** allocated copy of it. +*/ +static unsigned char * +find_word() +{ + static char SEPS[] = "#;&|^$=`'{}()<>\n\t "; + unsigned char *p; + unsigned char *new; + size_t len; + + for (p = &Line[Point]; p > Line && strchr(SEPS, (char)p[-1]) == NULL; p--) + continue; + len = Point - (p - Line) + 1; + if ((new = malloc(len)) == NULL) + return NULL; + memcpy(new, p, len); + new[len - 1] = '\0'; + return new; +} + +static STATUS +c_complete() +{ + unsigned char *p; + unsigned char *word; + int unique; + STATUS s; + + word = find_word(); + p = (unsigned char *)rl_complete((char *)word, &unique); + if (word) + free(word); + if (p && *p) { + s = insert_string(p); + if (!unique) + ring_bell(); + free(p); + return s; + } + return ring_bell(); +} + +static STATUS +c_possible() +{ + unsigned char **av; + unsigned char *word; + int ac; + + word = find_word(); + ac = rl_list_possib((char *)word, (char ***)&av); + if (word) + free(word); + if (ac) { + columns(ac, av); + while (--ac >= 0) + free(av[ac]); + free(av); + return CSmove; + } + return ring_bell(); +} + +static STATUS +accept_line() +{ + Line[End] = '\0'; + return CSdone; +} + +static STATUS +transpose() +{ + unsigned char c; + + if (Point) { + if (Point == End) + left(CSmove); + c = Line[Point - 1]; + left(CSstay); + Line[Point - 1] = Line[Point]; + TTYshow(Line[Point - 1]); + Line[Point++] = c; + TTYshow(c); + } + return CSstay; +} + +static STATUS +quote() +{ + unsigned int c; + + return (c = TTYget()) == EOF ? CSeof : insert_char((int)c); +} + +static STATUS +wipe() +{ + int i; + + if (Mark > End) + return ring_bell(); + + if (Point > Mark) { + i = Point; + Point = Mark; + Mark = i; + reposition(); + } + + return delete_string(Mark - Point); +} + +static STATUS +mk_set() +{ + Mark = Point; + return CSstay; +} + +static STATUS +exchange() +{ + unsigned int c; + + if ((c = TTYget()) != CTL('X')) + return c == EOF ? CSeof : ring_bell(); + + if ((c = Mark) <= End) { + Mark = Point; + Point = c; + return CSmove; + } + return CSstay; +} + +static STATUS +yank() +{ + if (Yanked && *Yanked) + return insert_string(Yanked); + return CSstay; +} + +static STATUS +copy_region() +{ + if (Mark > End) + return ring_bell(); + + if (Point > Mark) + save_yank(Mark, Point - Mark); + else + save_yank(Point, Mark - Point); + + return CSstay; +} + +static STATUS +move_to_char() +{ + unsigned int c; + int i; + unsigned char *p; + + if ((c = TTYget()) == EOF) + return CSeof; + for (i = Point + 1, p = &Line[i]; i < End; i++, p++) + if (*p == c) { + Point = i; + return CSmove; + } + return CSstay; +} + +static STATUS +fd_word() +{ + return do_forward(CSmove); +} + +static STATUS +fd_kill_word() +{ + int i; + + do_forward(CSstay); + if (OldPoint != Point) { + i = Point - OldPoint; + Point = OldPoint; + return delete_string(i); + } + return CSstay; +} + +static STATUS +bk_word() +{ + int i; + unsigned char *p; + + i = 0; + do { + for (p = &Line[Point]; p > Line && !isalnum(p[-1]); p--) + left(CSmove); + + for (; p > Line && p[-1] != ' ' && isalnum(p[-1]); p--) + left(CSmove); + + if (Point == 0) + break; + } while (++i < Repeat); + + return CSstay; +} + +static STATUS +bk_kill_word() +{ + bk_word(); + if (OldPoint != Point) + return delete_string(OldPoint - Point); + return CSstay; +} + +static int +argify(unsigned char *line, unsigned char ***avp) +{ + unsigned char *c; + unsigned char **p; + unsigned char **new; + int ac; + int i; + + i = MEM_INC; + if ((*avp = p = malloc(sizeof(unsigned char*) * i))== NULL) + return 0; + + for (c = line; isspace(*c); c++) + continue; + if (*c == '\n' || *c == '\0') + return 0; + + for (ac = 0, p[ac++] = c; *c && *c != '\n'; ) { + if (isspace(*c)) { + *c++ = '\0'; + if (*c && *c != '\n') { + if (ac + 1 == i) { + new = malloc(sizeof(unsigned char*) * (i + MEM_INC)); + if (new == NULL) { + p[ac] = NULL; + return ac; + } + memcpy(new, p, i * sizeof (char **)); + i += MEM_INC; + free(p); + *avp = p = new; + } + p[ac++] = c; + } + } + else + c++; + } + *c = '\0'; + p[ac] = NULL; + return ac; +} + +static STATUS +last_argument() +{ + unsigned char **av; + unsigned char *p; + STATUS s; + int ac; + + if (H.Size == 1 || (p = H.Lines[H.Size - 2]) == NULL) + return ring_bell(); + + if ((p = (unsigned char *)strdup((char *)p)) == NULL) + return CSstay; + ac = argify(p, &av); + + if (Repeat != NO_ARG) + s = Repeat < ac ? insert_string(av[Repeat]) : ring_bell(); + else + s = ac ? insert_string(av[ac - 1]) : CSstay; + + if (ac) + free(av); + free(p); + return s; +} + +static KEYMAP Map[33] = { + { CTL('@'), ring_bell }, + { CTL('A'), beg_line }, + { CTL('B'), bk_char }, + { CTL('D'), del_char }, + { CTL('E'), end_line }, + { CTL('F'), fd_char }, + { CTL('G'), ring_bell }, + { CTL('H'), bk_del_char }, + { CTL('I'), c_complete }, + { CTL('J'), accept_line }, + { CTL('K'), kill_line }, + { CTL('L'), redisplay }, + { CTL('M'), accept_line }, + { CTL('N'), h_next }, + { CTL('O'), ring_bell }, + { CTL('P'), h_prev }, + { CTL('Q'), ring_bell }, + { CTL('R'), h_search }, + { CTL('S'), ring_bell }, + { CTL('T'), transpose }, + { CTL('U'), ring_bell }, + { CTL('V'), quote }, + { CTL('W'), wipe }, + { CTL('X'), exchange }, + { CTL('Y'), yank }, + { CTL('Z'), ring_bell }, + { CTL('['), meta }, + { CTL(']'), move_to_char }, + { CTL('^'), ring_bell }, + { CTL('_'), ring_bell }, + { 0, NULL } +}; + +static KEYMAP MetaMap[16]= { + { CTL('H'), bk_kill_word }, + { DEL, bk_kill_word }, + { ' ', mk_set }, + { '.', last_argument }, + { '<', h_first }, + { '>', h_last }, + { '?', c_possible }, + { 'b', bk_word }, + { 'd', fd_kill_word }, + { 'f', fd_word }, + { 'l', case_down_word }, + { 'u', case_up_word }, + { 'y', yank }, + { 'w', copy_region }, + { 0, NULL } +}; diff --git a/crypto/heimdal/lib/editline/editline.cat3 b/crypto/heimdal/lib/editline/editline.cat3 new file mode 100644 index 0000000..6e7e63e --- /dev/null +++ b/crypto/heimdal/lib/editline/editline.cat3 @@ -0,0 +1,198 @@ + + + +EDITLINE(3) EDITLINE(3) + + + +NAME + editline - command-line editing library with history + +SYNOPSIS + cchhaarr ** + rreeaaddlliinnee((pprroommpptt)) + cchhaarr **pprroommpptt;; + + vvooiidd + aadddd__hhiissttoorryy((lliinnee)) + cchhaarr **lliinnee;; + +DESCRIPTION + _E_d_i_t_l_i_n_e is a library that provides an line-editing interface with text + recall. It is intended to be compatible with the _r_e_a_d_l_i_n_e library provided + by the Free Software Foundation, but much smaller. The bulk of this manual + page describes the user interface. + + The _r_e_a_d_l_i_n_e routine returns a line of text with the trailing newline + removed. The data is returned in a buffer allocated with _m_a_l_l_o_c(3), so the + space should be released with _f_r_e_e(3) when the calling program is done with + it. Before accepting input from the user, the specified _p_r_o_m_p_t is dis- + played on the terminal. + + The _a_d_d___h_i_s_t_o_r_y routine makes a copy of the specified _l_i_n_e and adds it to + the internal history list. + + User Interface + + A program that uses this library provides a simple emacs-like editing + interface to its users. A line may be edited before it is sent to the + calling program by typing either control characters or escape sequences. A + control character, shown as a caret followed by a letter, is typed by hold- + ing down the ``control'' key while the letter is typed. For example, + ``^A'' is a control-A. An escape sequence is entered by typing the + ``escape'' key followed by one or more characters. The escape key is + abbreviated as ``ESC.'' Note that unlike control keys, case matters in + escape sequences; ``ESC F'' is not the same as ``ESC f''. + + An editing command may be typed anywhere on the line, not just at the + beginning. In addition, a return may also be typed anywhere on the line, + not just at the end. + + Most editing commands may be given a repeat count, _n, where _n is a number. + To enter a repeat count, type the escape key, the number, and then the com- + mand to execute. For example, ``ESC 4 ^f'' moves forward four characters. + If a command may be given a repeat count then the text ``[n]'' is given at + the end of its description. + + The following control characters are accepted: + ^A Move to the beginning of the line + ^B Move left (backwards) [n] + ^D Delete character [n] + ^E Move to end of line + ^F Move right (forwards) [n] + ^G Ring the bell + ^H Delete character before cursor (backspace key) [n] + ^I Complete filename (tab key); see below + ^J Done with line (return key) + ^K Kill to end of line (or column [n]) + ^L Redisplay line + ^M Done with line (alternate return key) + ^N Get next line from history [n] + ^P Get previous line from history [n] + ^R Search backward (forward if [n]) through history for text; + must start line if text begins with an uparrow + ^T Transpose characters + ^V Insert next character, even if it is an edit command + ^W Wipe to the mark + ^X^X Exchange current location and mark + ^Y Yank back last killed text + ^[ Start an escape sequence (escape key) + ^]c Move forward to next character ``c'' + ^? Delete character before cursor (delete key) [n] + + The following escape sequences are provided. + ESC ^H Delete previous word (backspace key) [n] + ESC DEL Delete previous word (delete key) [n] + ESC SP Set the mark (space key); see ^X^X and ^Y above + ESC . Get the last (or [n]'th) word from previous line + ESC ? Show possible completions; see below + ESC < Move to start of history + ESC > Move to end of history + ESC b Move backward a word [n] + ESC d Delete word under cursor [n] + ESC f Move forward a word [n] + ESC l Make word lowercase [n] + ESC u Make word uppercase [n] + ESC y Yank back last killed text + ESC v Show library version + ESC w Make area up to mark yankable + ESC nn Set repeat count to the number nn + ESC C Read from environment variable ``_C_'', where C is + an uppercase letter + + The _e_d_i_t_l_i_n_e library has a small macro facility. If you type the escape + key followed by an uppercase letter, _C, then the contents of the environ- + ment variable ___C__ are read in as if you had typed them at the keyboard. + For example, if the variable ___L__ contains the following: + ^A^Kecho '^V^[[H^V^[[2J'^M + Then typing ``ESC L'' will move to the beginning of the line, kill the + entire line, enter the echo command needed to clear the terminal (if your + terminal is like a VT-100), and send the line back to the shell. + + The _e_d_i_t_l_i_n_e library also does filename completion. Suppose the root + directory has the following files in it: + bin vmunix + core vmunix.old + If you type ``rm /v'' and then the tab key. _E_d_i_t_l_i_n_e will then finish off + as much of the name as possible by adding ``munix''. Because the name is + not unique, it will then beep. If you type the escape key and a question + mark, it will display the two choices. If you then type a period and a + tab, the library will finish off the filename for you: + rm /v[TAB]_m_u_n_i_x.TAB_o_l_d + The tab key is shown by ``[TAB]'' and the automatically-entered text is + shown in italics. + + + +BUGS AND LIMITATIONS + Cannot handle lines more than 80 columns. + + + + +AUTHORS + Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy> and Rich $alz + <rsalz@osf.org>. Original manual page by DaviD W. Sanderson + <dws@ssec.wisc.edu>. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crypto/heimdal/lib/editline/editline.h b/crypto/heimdal/lib/editline/editline.h new file mode 100644 index 0000000..a948ddc --- /dev/null +++ b/crypto/heimdal/lib/editline/editline.h @@ -0,0 +1,64 @@ +/* $Revision: 1.4 $ +** +** Internal header file for editline library. +*/ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define CRLF "\r\n" + +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif + +#ifdef HAVE_DIRENT_H +#include <dirent.h> +typedef struct dirent DIRENTRY; +#else +#include <sys/dir.h> +typedef struct direct DIRENTRY; +#endif + +#include <roken.h> + +#if !defined(S_ISDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif /* !defined(S_ISDIR) */ + +typedef unsigned char CHAR; + +#define MEM_INC 64 +#define SCREEN_INC 256 + +/* +** Variables and routines internal to this package. +*/ +extern int rl_eof; +extern int rl_erase; +extern int rl_intr; +extern int rl_kill; +extern int rl_quit; + +typedef char* (*rl_complete_func_t)(char*, int*); + +typedef int (*rl_list_possib_func_t)(char*, char***); + +void add_history (char*); +char* readline (const char* prompt); +void rl_add_slash (char*, char*); +char* rl_complete (char*, int*); +void rl_initialize (void); +int rl_list_possib (char*, char***); +void rl_reset_terminal (char*); +void rl_ttyset (int); +rl_complete_func_t rl_set_complete_func (rl_complete_func_t); +rl_list_possib_func_t rl_set_list_possib_func (rl_list_possib_func_t); + diff --git a/crypto/heimdal/lib/editline/roken_rename.h b/crypto/heimdal/lib/editline/roken_rename.h new file mode 100644 index 0000000..9ea278d --- /dev/null +++ b/crypto/heimdal/lib/editline/roken_rename.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * 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 Institute 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 INSTITUTE 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 INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* $Id: roken_rename.h,v 1.4 1999/12/02 16:58:39 joda Exp $ */ + +#ifndef __roken_rename_h__ +#define __roken_rename_h__ + +#ifndef HAVE_STRDUP +#define strdup _editline_strdup +#endif +#ifndef HAVE_SNPRINTF +#define snprintf _editline_snprintf +#endif +#ifndef HAVE_VSNPRINTF +#define vsnprintf _editline_vsnprintf +#endif +#ifndef HAVE_ASPRINTF +#define asprintf _editline_asprintf +#endif +#ifndef HAVE_ASNPRINTF +#define asnprintf _editline_asnprintf +#endif +#ifndef HAVE_VASPRINTF +#define vasprintf _editline_vasprintf +#endif +#ifndef HAVE_VASNPRINTF +#define vasnprintf _editline_vasnprintf +#endif + +#endif /* __roken_rename_h__ */ diff --git a/crypto/heimdal/lib/editline/sysunix.c b/crypto/heimdal/lib/editline/sysunix.c new file mode 100644 index 0000000..bcd6def --- /dev/null +++ b/crypto/heimdal/lib/editline/sysunix.c @@ -0,0 +1,92 @@ +/* Copyright 1992 Simmule Turner and Rich Salz. All rights reserved. + * + * This software is not subject to any license of the American Telephone + * and Telegraph Company or of the Regents of the University of California. + * + * Permission is granted to anyone to use this software for any purpose on + * any computer system, and to alter it and redistribute it freely, subject + * to the following restrictions: + * 1. The authors are not responsible for the consequences of use of this + * software, no matter how awful, even if they arise from flaws in it. + * 2. The origin of this software must not be misrepresented, either by + * explicit claim or by omission. Since few users ever read sources, + * credits must appear in the documentation. + * 3. Altered versions must be plainly marked as such, and must not be + * misrepresented as being the original software. Since few users + * ever read sources, credits must appear in the documentation. + * 4. This notice may not be removed or altered. + */ + +/* +** Unix system-dependant routines for editline library. +*/ +#include <config.h> +#include "editline.h" + +#ifdef HAVE_TERMIOS_H +#include <termios.h> +#else +#include <sgtty.h> +#endif + +RCSID("$Id: sysunix.c,v 1.4 1999/04/08 13:08:24 joda Exp $"); + +#ifdef HAVE_TERMIOS_H + +void +rl_ttyset(int Reset) +{ + static struct termios old; + struct termios new; + + if (Reset == 0) { + tcgetattr(0, &old); + rl_erase = old.c_cc[VERASE]; + rl_kill = old.c_cc[VKILL]; + rl_eof = old.c_cc[VEOF]; + rl_intr = old.c_cc[VINTR]; + rl_quit = old.c_cc[VQUIT]; + + new = old; + new.c_cc[VINTR] = -1; + new.c_cc[VQUIT] = -1; + new.c_lflag &= ~(ECHO | ICANON); + new.c_iflag &= ~(ISTRIP | INPCK); + new.c_cc[VMIN] = 1; + new.c_cc[VTIME] = 0; + tcsetattr(0, TCSANOW, &new); + } + else + tcsetattr(0, TCSANOW, &old); +} + +#else /* !HAVE_TERMIOS_H */ + +void +rl_ttyset(int Reset) +{ + static struct sgttyb old; + struct sgttyb new; + + if (Reset == 0) { + ioctl(0, TIOCGETP, &old); + rl_erase = old.sg_erase; + rl_kill = old.sg_kill; + new = old; + new.sg_flags &= ~(ECHO | ICANON); + new.sg_flags &= ~(ISTRIP | INPCK); + ioctl(0, TIOCSETP, &new); + } else { + ioctl(0, TIOCSETP, &old); + } +} +#endif /* HAVE_TERMIOS_H */ + +void +rl_add_slash(char *path, char *p) +{ + struct stat Sb; + + if (stat(path, &Sb) >= 0) + strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " "); +} diff --git a/crypto/heimdal/lib/editline/testit.c b/crypto/heimdal/lib/editline/testit.c new file mode 100644 index 0000000..4635e36 --- /dev/null +++ b/crypto/heimdal/lib/editline/testit.c @@ -0,0 +1,38 @@ +/* $Revision: 1.2 $ +** +** A "micro-shell" to test editline library. +** If given any arguments, commands aren't executed. +*/ +#if defined(HAVE_CONFIG_H) +#include <config.h> +#endif +#include <stdio.h> +#include <stdlib.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif + +#include "editline.h" + +int +main(int ac, char **av) +{ + char *p; + int doit; + + doit = ac == 1; + while ((p = readline("testit> ")) != NULL) { + (void)printf("\t\t\t|%s|\n", p); + if (doit) + if (strncmp(p, "cd ", 3) == 0) { + if (chdir(&p[3]) < 0) + perror(&p[3]); + } else if (system(p) != 0) { + perror(p); + } + add_history(p); + free(p); + } + exit(0); + /* NOTREACHED */ +} diff --git a/crypto/heimdal/lib/editline/unix.h b/crypto/heimdal/lib/editline/unix.h new file mode 100644 index 0000000..fe6beed --- /dev/null +++ b/crypto/heimdal/lib/editline/unix.h @@ -0,0 +1,22 @@ +/* $Revision: 1.1 $ +** +** Editline system header file for Unix. +*/ + +#define CRLF "\r\n" +#define FORWARD STATIC + +#include <sys/types.h> +#include <sys/stat.h> + +#if defined(USE_DIRENT) +#include <dirent.h> +typedef struct dirent DIRENTRY; +#else +#include <sys/dir.h> +typedef struct direct DIRENTRY; +#endif /* defined(USE_DIRENT) */ + +#if !defined(S_ISDIR) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif /* !defined(S_ISDIR) */ |