aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses')
-rw-r--r--contrib/ncurses/ncurses/Makefile.in248
-rw-r--r--contrib/ncurses/ncurses/README2
-rw-r--r--contrib/ncurses/ncurses/SigAction.h117
-rw-r--r--contrib/ncurses/ncurses/base/MKkeyname.awk74
-rwxr-xr-xcontrib/ncurses/ncurses/base/MKlib_gen.sh254
-rw-r--r--contrib/ncurses/ncurses/base/MKunctrl.awk67
-rw-r--r--contrib/ncurses/ncurses/base/README7
-rw-r--r--contrib/ncurses/ncurses/base/define_key.c59
-rw-r--r--contrib/ncurses/ncurses/base/keybound.c45
-rw-r--r--contrib/ncurses/ncurses/base/keyok.c72
-rw-r--r--contrib/ncurses/ncurses/base/lib_addch.c293
-rw-r--r--contrib/ncurses/ncurses/base/lib_addstr.c103
-rw-r--r--contrib/ncurses/ncurses/base/lib_beep.c73
-rw-r--r--contrib/ncurses/ncurses/base/lib_bkgd.c86
-rw-r--r--contrib/ncurses/ncurses/base/lib_box.c110
-rw-r--r--contrib/ncurses/ncurses/base/lib_chgat.c62
-rw-r--r--contrib/ncurses/ncurses/base/lib_clear.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_clearok.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_clrbot.c75
-rw-r--r--contrib/ncurses/ncurses/base/lib_clreol.c91
-rw-r--r--contrib/ncurses/ncurses/base/lib_color.c429
-rw-r--r--contrib/ncurses/ncurses/base/lib_colorset.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_delch.c68
-rw-r--r--contrib/ncurses/ncurses/base/lib_delwin.c72
-rw-r--r--contrib/ncurses/ncurses/base/lib_dft_fgbg.c60
-rw-r--r--contrib/ncurses/ncurses/base/lib_echo.c60
-rw-r--r--contrib/ncurses/ncurses/base/lib_endwin.c61
-rw-r--r--contrib/ncurses/ncurses/base/lib_erase.c73
-rw-r--r--contrib/ncurses/ncurses/base/lib_flash.c73
-rw-r--r--contrib/ncurses/ncurses/base/lib_freeall.c134
-rw-r--r--contrib/ncurses/ncurses/base/lib_getch.c414
-rw-r--r--contrib/ncurses/ncurses/base/lib_getstr.c192
-rw-r--r--contrib/ncurses/ncurses/base/lib_hline.c76
-rw-r--r--contrib/ncurses/ncurses/base/lib_immedok.c54
-rw-r--r--contrib/ncurses/ncurses/base/lib_inchstr.c62
-rw-r--r--contrib/ncurses/ncurses/base/lib_initscr.c78
-rw-r--r--contrib/ncurses/ncurses/base/lib_insch.c67
-rw-r--r--contrib/ncurses/ncurses/base/lib_insdel.c62
-rw-r--r--contrib/ncurses/ncurses/base/lib_insstr.c81
-rw-r--r--contrib/ncurses/ncurses/base/lib_instr.c73
-rw-r--r--contrib/ncurses/ncurses/base/lib_isendwin.c51
-rw-r--r--contrib/ncurses/ncurses/base/lib_leaveok.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_mouse.c964
-rw-r--r--contrib/ncurses/ncurses/base/lib_move.c63
-rw-r--r--contrib/ncurses/ncurses/base/lib_mvwin.c109
-rw-r--r--contrib/ncurses/ncurses/base/lib_newterm.c206
-rw-r--r--contrib/ncurses/ncurses/base/lib_newwin.c271
-rw-r--r--contrib/ncurses/ncurses/base/lib_nl.c79
-rw-r--r--contrib/ncurses/ncurses/base/lib_overlay.c161
-rw-r--r--contrib/ncurses/ncurses/base/lib_pad.c280
-rw-r--r--contrib/ncurses/ncurses/base/lib_printw.c110
-rw-r--r--contrib/ncurses/ncurses/base/lib_redrawln.c69
-rw-r--r--contrib/ncurses/ncurses/base/lib_refresh.c183
-rw-r--r--contrib/ncurses/ncurses/base/lib_restart.c90
-rw-r--r--contrib/ncurses/ncurses/base/lib_scanw.c111
-rw-r--r--contrib/ncurses/ncurses/base/lib_screen.c198
-rw-r--r--contrib/ncurses/ncurses/base/lib_scroll.c118
-rw-r--r--contrib/ncurses/ncurses/base/lib_scrollok.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_scrreg.c62
-rw-r--r--contrib/ncurses/ncurses/base/lib_set_term.c315
-rw-r--r--contrib/ncurses/ncurses/base/lib_slk.c214
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatr_set.c56
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatrof.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatron.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkatrset.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkattr.c54
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkclear.c62
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkcolor.c54
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkinit.c51
-rw-r--r--contrib/ncurses/ncurses/base/lib_slklab.c51
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkrefr.c126
-rw-r--r--contrib/ncurses/ncurses/base/lib_slkset.c95
-rw-r--r--contrib/ncurses/ncurses/base/lib_slktouch.c53
-rw-r--r--contrib/ncurses/ncurses/base/lib_touch.c87
-rw-r--r--contrib/ncurses/ncurses/base/lib_ungetch.c74
-rw-r--r--contrib/ncurses/ncurses/base/lib_vline.c77
-rw-r--r--contrib/ncurses/ncurses/base/lib_wattroff.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_wattron.c55
-rw-r--r--contrib/ncurses/ncurses/base/lib_winch.c52
-rw-r--r--contrib/ncurses/ncurses/base/lib_window.c221
-rw-r--r--contrib/ncurses/ncurses/base/memmove.c63
-rw-r--r--contrib/ncurses/ncurses/base/nc_panel.c41
-rw-r--r--contrib/ncurses/ncurses/base/resizeterm.c121
-rw-r--r--contrib/ncurses/ncurses/base/safe_sprintf.c243
-rw-r--r--contrib/ncurses/ncurses/base/sigaction.c106
-rw-r--r--contrib/ncurses/ncurses/base/tries.c138
-rw-r--r--contrib/ncurses/ncurses/base/vsscanf.c47
-rw-r--r--contrib/ncurses/ncurses/base/wresize.c166
-rw-r--r--contrib/ncurses/ncurses/curses.priv.h791
-rw-r--r--contrib/ncurses/ncurses/fifo_defs.h59
-rw-r--r--contrib/ncurses/ncurses/llib-lncurses2868
-rw-r--r--contrib/ncurses/ncurses/modules186
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKcaptab.awk70
-rwxr-xr-xcontrib/ncurses/ncurses/tinfo/MKfallback.sh75
-rw-r--r--contrib/ncurses/ncurses/tinfo/MKnames.awk98
-rw-r--r--contrib/ncurses/ncurses/tinfo/README8
-rw-r--r--contrib/ncurses/ncurses/tinfo/access.c55
-rw-r--r--contrib/ncurses/ncurses/tinfo/add_tries.c124
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_entry.c225
-rw-r--r--contrib/ncurses/ncurses/tinfo/alloc_ttype.c461
-rw-r--r--contrib/ncurses/ncurses/tinfo/captoinfo.c807
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_error.c132
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_expand.c189
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_hash.c325
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_parse.c490
-rw-r--r--contrib/ncurses/ncurses/tinfo/comp_scan.c756
-rw-r--r--contrib/ncurses/ncurses/tinfo/doalloc.c74
-rw-r--r--contrib/ncurses/ncurses/tinfo/free_ttype.c72
-rw-r--r--contrib/ncurses/ncurses/tinfo/getenv_num.c56
-rw-r--r--contrib/ncurses/ncurses/tinfo/home_terminfo.c62
-rw-r--r--contrib/ncurses/ncurses/tinfo/init_keytry.c67
-rw-r--r--contrib/ncurses/ncurses/tinfo/keys.list158
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_acs.c139
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_baudrate.c178
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_cur_term.c70
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_data.c84
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_has_cap.c63
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_kernel.c130
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_longname.c58
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_napms.c90
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_options.c261
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_print.c96
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_raw.c233
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_setup.c422
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termcap.c198
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_termname.c46
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ti.c101
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tparm.c585
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_tputs.c243
-rw-r--r--contrib/ncurses/ncurses/tinfo/lib_ttyflags.c163
-rw-r--r--contrib/ncurses/ncurses/tinfo/make_keys.c131
-rw-r--r--contrib/ncurses/ncurses/tinfo/name_match.c96
-rw-r--r--contrib/ncurses/ncurses/tinfo/parse_entry.c1047
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_entry.c482
-rw-r--r--contrib/ncurses/ncurses/tinfo/read_termcap.c1116
-rw-r--r--contrib/ncurses/ncurses/tinfo/setbuf.c144
-rw-r--r--contrib/ncurses/ncurses/tinfo/write_entry.c557
-rw-r--r--contrib/ncurses/ncurses/trace/README5
-rw-r--r--contrib/ncurses/ncurses/trace/lib_trace.c200
-rw-r--r--contrib/ncurses/ncurses/trace/lib_traceatr.c218
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracebits.c225
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracechr.c69
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracedmp.c128
-rw-r--r--contrib/ncurses/ncurses/trace/lib_tracemse.c95
-rw-r--r--contrib/ncurses/ncurses/trace/trace_buf.c80
-rw-r--r--contrib/ncurses/ncurses/trace/trace_tries.c74
-rw-r--r--contrib/ncurses/ncurses/trace/trace_xnames.c74
-rwxr-xr-xcontrib/ncurses/ncurses/tty/MKexpanded.sh103
-rw-r--r--contrib/ncurses/ncurses/tty/hardscroll.c328
-rw-r--r--contrib/ncurses/ncurses/tty/hashmap.c567
-rw-r--r--contrib/ncurses/ncurses/tty/lib_mvcur.c1242
-rw-r--r--contrib/ncurses/ncurses/tty/lib_tstp.c361
-rw-r--r--contrib/ncurses/ncurses/tty/lib_twait.c221
-rw-r--r--contrib/ncurses/ncurses/tty/lib_vidattr.c278
-rw-r--r--contrib/ncurses/ncurses/tty/tty_display.h146
-rw-r--r--contrib/ncurses/ncurses/tty/tty_input.h61
-rw-r--r--contrib/ncurses/ncurses/tty/tty_update.c1738
157 files changed, 31427 insertions, 0 deletions
diff --git a/contrib/ncurses/ncurses/Makefile.in b/contrib/ncurses/ncurses/Makefile.in
new file mode 100644
index 000000000000..655022004e55
--- /dev/null
+++ b/contrib/ncurses/ncurses/Makefile.in
@@ -0,0 +1,248 @@
+# $Id: Makefile.in,v 1.62 1999/02/18 11:58:20 tom Exp $
+##############################################################################
+# Copyright (c) 1998 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
+#
+# Makefile for ncurses source code.
+#
+# This makes the following:
+# programs
+# includes
+# libraries (normal/debug/profile/shared)
+#
+# The variable 'srcdir' refers to the source-distribution, and can be set with
+# the configure script by "--srcdir=DIR".
+#
+# The rules are organized to produce the libraries for the configured models,
+# and the programs with the configured default model.
+
+# turn off _all_ suffix rules; we'll generate our own
+.SUFFIXES:
+
+SHELL = /bin/sh
+THIS = Makefile
+
+x = @PROG_EXT@
+
+CF_MFLAGS = @cf_cv_makeflags@
+@SET_MAKE@
+
+MODEL = @DFT_LWR_MODEL@
+INSTALL_PREFIX = @INSTALL_PREFIX@
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+libdir = @libdir@
+includedir = @includedir@
+datadir = @datadir@
+
+ticdir = $(datadir)/terminfo
+
+INSTALL = @INSTALL@
+INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
+INSTALL_DATA = @INSTALL_DATA@
+
+AR = @AR@
+AR_OPTS = @AR_OPTS@
+AWK = @AWK@
+LD = @LD@
+LN_S = @LN_S@
+
+CC = @CC@
+CPP = @CPP@
+CFLAGS = @CFLAGS@
+
+INCDIR = $(srcdir)/../include
+CPPFLAGS = -I../ncurses -I$(srcdir) @CPPFLAGS@ \
+ -DHAVE_CONFIG_H -DTERMINFO=\"$(ticdir)\"
+
+CCFLAGS = $(CPPFLAGS) $(CFLAGS)
+
+HOSTCC = @BUILD_CC@
+HOSTCCFLAGS = @CFLAGS@ $(CPPFLAGS)
+HOSTLDFLAGS = @LDFLAGS@ @LIBS@
+
+CFLAGS_NORMAL = $(CCFLAGS)
+CFLAGS_DEBUG = $(CCFLAGS) @CC_G_OPT@ -DTRACE
+CFLAGS_PROFILE = $(CCFLAGS) -pg
+CFLAGS_SHARED = $(CCFLAGS) @CC_SHARED_OPTS@
+
+CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@)
+
+LINK = $(CC)
+LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
+
+SHLIB_DIRS = -L../lib -L$(libdir)
+SHLIB_LIST = $(SHLIB_DIRS) @SHLIB_LIST@
+TINFO_LIST = $(SHLIB_DIRS) @TINFO_LIST@
+
+MK_SHARED_LIB = @MK_SHARED_LIB@
+
+REL_VERSION = @cf_cv_rel_version@
+ABI_VERSION = @cf_cv_abi_version@
+
+RANLIB = @RANLIB@
+
+LIBRARIES = @LIBS_TO_MAKE@
+
+LINT = @LINT@
+LINT_OPTS = @LINT_OPTS@
+LINT_LIBS = -lncurses @LIBS@
+
+FALLBACK_LIST = @FALLBACK_LIST@
+
+AUTO_SRC = \
+ ../include/nomacros.h \
+ ./comp_captab.c \
+ ./expanded.c \
+ ./fallback.c \
+ init_keytry.h \
+ ./lib_keyname.c \
+ ./lib_gen.c \
+ ./codes.c \
+ ./names.c \
+ ./unctrl.c
+
+TEST_DEPS = @LIB_PREFIX@ncurses@DFT_DEP_SUFFIX@
+TEST_ARGS = -L../lib -lncurses@DFT_ARG_SUFFIX@
+TEST_LDFLAGS = @LD_MODEL@ $(TEST_ARGS) @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ @LDFLAGS@
+
+TEST_PROGS = \
+ captoinfo$x \
+ hardscroll$x \
+ hashmap$x \
+ lib_mvcur$x
+
+base = $(srcdir)/base
+serial = $(srcdir)/tty
+tinfo = $(srcdir)/tinfo
+trace = $(srcdir)/trace
+
+################################################################################
+all :: $(AUTO_SRC) ../lib $(LIBRARIES)
+
+sources: $(AUTO_SRC)
+
+$(INSTALL_PREFIX)$(libdir) :
+ $(srcdir)/../mkinstalldirs $@
+
+../lib : ; mkdir $@
+
+./fallback.c : $(tinfo)/MKfallback.sh
+ sh $(tinfo)/MKfallback.sh $(FALLBACK_LIST) >$@
+
+./lib_gen.c : $(base)/MKlib_gen.sh ../include/curses.h
+ sh $(base)/MKlib_gen.sh "$(CPP)" "$(AWK)" <../include/curses.h >$@
+
+../include/nomacros.h : $(base)/MKlib_gen.sh ../include/curses.h
+ sh $(base)/MKlib_gen.sh "$(CPP)" "$(AWK)" <../include/curses.h | \
+ fgrep undef >$@
+
+init_keytry.h: make_keys$x $(tinfo)/keys.list
+ ./make_keys $(tinfo)/keys.list > $@
+
+make_keys$x : \
+ $(tinfo)/make_keys.c \
+ ./names.c
+ $(HOSTCC) -o $@ $(HOSTCCFLAGS) $(tinfo)/make_keys.c $(HOSTLDFLAGS)
+
+make_hash$x : \
+ $(tinfo)/comp_hash.c \
+ ../include/hashsize.h
+ $(HOSTCC) -o $@ $(HOSTCCFLAGS) -DMAIN_PROGRAM $(tinfo)/comp_hash.c $(HOSTLDFLAGS)
+
+./expanded.c : $(serial)/MKexpanded.sh
+ sh $(serial)/MKexpanded.sh "$(CPP)" $(CPPFLAGS) > $@
+
+./comp_captab.c: \
+ make_hash$x \
+ ../include/hashsize.h \
+ $(tinfo)/MKcaptab.awk
+ sh $(tinfo)/MKcaptab.awk $(AWK) $(srcdir)/../include/Caps > $@
+
+./lib_keyname.c: $(tinfo)/keys.list $(base)/MKkeyname.awk
+ $(AWK) -f $(base)/MKkeyname.awk $(tinfo)/keys.list > $@
+
+./names.c ./codes.c: $(tinfo)/MKnames.awk
+ $(AWK) -f $(tinfo)/MKnames.awk $(srcdir)/../include/Caps
+ cat namehdr boolnames boolfnames numnames numfnames strnames strfnames nameftr >./names.c
+ cat namehdr boolcodes numcodes strcodes codeftr >./codes.c
+ -rm -f namehdr nameftr codeftr boolnames boolfnames boolcodes numnames numfnames numcodes strnames strfnames strcodes
+
+./unctrl.c: $(base)/MKunctrl.awk
+ echo | $(AWK) -f $(base)/MKunctrl.awk >$@
+
+tags:
+ ctags *.[ch]
+
+TAGS:
+ etags *.[ch]
+
+mostlyclean ::
+ -rm -f core tags TAGS *~ *.ln *.atac trace
+ -rm -f $(TEST_PROGS)
+
+clean :: mostlyclean
+ -rm -f $(AUTO_SRC)
+ -rm -f make_keys
+ -rm -f make_hash
+
+distclean :: clean
+ -rm -f Makefile
+
+realclean :: distclean
+
+# These rules are used to allow "make -n" to work on a clean directory-tree
+../include/hashsize.h \
+../include/parametrized.h \
+../include/term.h :
+ cd ../include; $(MAKE) $(CF_MFLAGS)
+
+# These rules build test-programs for the modules that have test-drivers
+test_progs : $(TEST_PROGS)
+
+captoinfo$x : $(tinfo)/captoinfo.c $(TEST_DEPS)
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DMAIN $(tinfo)/captoinfo.c $(TEST_LDFLAGS)
+
+hardscroll$x : $(serial)/hardscroll.c $(TEST_DEPS)
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DSCROLLDEBUG $(serial)/hardscroll.c $(TEST_LDFLAGS)
+
+hashmap$x : $(serial)/hashmap.c $(TEST_DEPS)
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DHASHDEBUG $(serial)/hashmap.c $(TEST_LDFLAGS)
+
+lib_mvcur$x : $(serial)/lib_mvcur.c $(TEST_DEPS) \
+ ../@DFT_OBJ_SUBDIR@/dump_entry.o
+ @ECHO_LINK@ $(CC) -o $@ $(CFLAGS_DEFAULT) -DNCURSES_TEST -I$(serial)/../../progs $(serial)/lib_mvcur.c ../@DFT_OBJ_SUBDIR@/dump_entry.o $(TEST_LDFLAGS)
+
+../@DFT_OBJ_SUBDIR@/dump_entry.o:
+ cd ../progs && $(MAKE) ../@DFT_OBJ_SUBDIR@/dump_entry.o
+
+###############################################################################
+# The remainder of this file is automatically generated during configuration
+###############################################################################
diff --git a/contrib/ncurses/ncurses/README b/contrib/ncurses/ncurses/README
new file mode 100644
index 000000000000..aade721a2e6e
--- /dev/null
+++ b/contrib/ncurses/ncurses/README
@@ -0,0 +1,2 @@
+For discussion of the package internals, see hackguide.html in the misc
+directory.
diff --git a/contrib/ncurses/ncurses/SigAction.h b/contrib/ncurses/ncurses/SigAction.h
new file mode 100644
index 000000000000..9b5a31a85a2f
--- /dev/null
+++ b/contrib/ncurses/ncurses/SigAction.h
@@ -0,0 +1,117 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * $Id: SigAction.h,v 1.5 1999/06/19 23:00:54 tom Exp $
+ *
+ * This file exists to handle non-POSIX systems which don't have <unistd.h>,
+ * and usually no sigaction() nor <termios.h>
+ */
+
+#ifndef _SIGACTION_H
+#define _SIGACTION_H
+
+#ifndef HAVE_SIGACTION
+#define HAVE_SIGACTION 0
+#endif
+
+#ifndef HAVE_SIGVEC
+#define HAVE_SIGVEC 0
+#endif
+
+#if HAVE_SIGACTION
+
+#if !HAVE_TYPE_SIGACTION
+typedef struct sigaction sigaction_t;
+#endif
+
+#else /* !HAVE_SIGACTION */
+
+#if HAVE_SIGVEC
+
+#if HAVE_LIBC_H
+#include <libc.h>
+#endif
+
+#undef SIG_BLOCK
+#define SIG_BLOCK 00
+
+#undef SIG_UNBLOCK
+#define SIG_UNBLOCK 01
+
+#undef SIG_SETMASK
+#define SIG_SETMASK 02
+
+ /*
+ * <bsd/signal.h> is in the Linux 1.2.8 + gcc 2.7.0 configuration,
+ * and is useful for testing this header file.
+ */
+#if HAVE_BSD_SIGNAL_H
+#include <bsd/signal.h>
+#endif
+
+typedef struct sigvec sigaction_t;
+
+#define sigset_t _nc_sigset_t
+typedef unsigned long sigset_t;
+
+#undef sa_mask
+#define sa_mask sv_mask
+#undef sa_handler
+#define sa_handler sv_handler
+#undef sa_flags
+#define sa_flags sv_flags
+
+#undef sigaction
+#define sigaction _nc_sigaction
+#undef sigprocmask
+#define sigprocmask _nc_sigprocmask
+#undef sigemptyset
+#define sigemptyset _nc_sigemptyset
+#undef sigsuspend
+#define sigsuspend _nc_sigsuspend
+#undef sigdelset
+#define sigdelset _nc_sigdelset
+#undef sigaddset
+#define sigaddset _nc_sigaddset
+
+extern int sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact);
+extern int sigprocmask (int how, sigset_t *mask, sigset_t *omask);
+extern int sigemptyset (sigset_t *mask);
+extern int sigsuspend (sigset_t *mask);
+extern int sigdelset (sigset_t *mask, int sig);
+extern int sigaddset (sigset_t *mask, int sig);
+
+#endif /* HAVE_SIGVEC */
+#endif /* HAVE_SIGACTION */
+#endif /* !defined(_SIGACTION_H) */
diff --git a/contrib/ncurses/ncurses/base/MKkeyname.awk b/contrib/ncurses/ncurses/base/MKkeyname.awk
new file mode 100644
index 000000000000..aaeb4743cdfe
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/MKkeyname.awk
@@ -0,0 +1,74 @@
+# $Id: MKkeyname.awk,v 1.17 1999/02/18 11:18:06 tom Exp $
+##############################################################################
+# Copyright (c) 1999 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+BEGIN {
+ print "/* generated by MKkeyname.awk */"
+ print ""
+ print "#include <ncurses_cfg.h>"
+ print "#include <stdlib.h>"
+ print "#include <string.h>"
+ print "#include <curses.h>"
+ print "#include <tic.h>"
+ print ""
+ print "const struct kn _nc_key_names[] = {"
+}
+
+/^[^#]/ {
+ printf "\t{ \"%s\", %s },\n", $1, $1;
+ }
+
+END {
+ printf "\t{ 0, 0 }};\n"
+ print ""
+ print "NCURSES_CONST char *keyname(int c)"
+ print "{"
+ print "int i;"
+ print "static char name[20];"
+ print "char *p;"
+ print ""
+ print "\tfor (i = 0; _nc_key_names[i].name != 0; i++)"
+ print "\t\tif (_nc_key_names[i].code == c)"
+ print "\t\t\treturn (NCURSES_CONST char *)_nc_key_names[i].name;"
+ print "\tif (c >= 256) return \"UNKNOWN KEY\";"
+ print "\tp = name;"
+ print "\tif (c >= 128) {"
+ print "\t\tstrcpy(p, \"M-\");"
+ print "\t\tp += 2;"
+ print "\t\tc -= 128;"
+ print "\t}"
+ print "\tif (c < 0)"
+ print "\t\tsprintf(p, \"%d\", c);"
+ print "\telse if (c < 32)"
+ print "\t\tsprintf(p, \"^%c\", c + '@');"
+ print "\telse if (c == 127)"
+ print "\t\tstrcpy(p, \"^?\");"
+ print "\telse"
+ print "\t\tsprintf(p, \"%c\", c);"
+ print "\treturn (NCURSES_CONST char *)name;"
+ print "}"
+}
diff --git a/contrib/ncurses/ncurses/base/MKlib_gen.sh b/contrib/ncurses/ncurses/base/MKlib_gen.sh
new file mode 100755
index 000000000000..0a29c6085f62
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/MKlib_gen.sh
@@ -0,0 +1,254 @@
+#!/bin/sh
+#
+# MKlib_gen.sh -- generate sources from curses.h macro definitions
+#
+# ($Id: MKlib_gen.sh,v 1.11 1998/01/17 14:16:52 Juan.Jose.Garcia.Ripoll Exp $)
+#
+# The XSI Curses standard requires all curses entry points to exist as
+# functions, even though many definitions would normally be shadowed
+# by macros. Rather than hand-hack all that code, we actually
+# generate functions from the macros.
+#
+# This script accepts a file of prototypes on standard input. It discards
+# any that don't have a `generated' comment attached. It then parses each
+# prototype (relying on the fact that none of the macros take function
+# pointer or array arguments) and generates C source from it.
+#
+# Here is what the pipeline stages are doing:
+#
+# 1. sed: extract prototypes of generated functions
+# 2. sed: decorate prototypes with generated arguments a1. a2,...z
+# 3. awk: generate the calls with args matching the formals
+# 4. sed: prefix function names in prototypes so the preprocessor won't expand
+# them.
+# 5. cpp: macro-expand the file so the macro calls turn into C calls
+# 6. awk: strip the expansion junk off the front and add the new header
+# 7. sed: squeeze spaces, strip off gen_ prefix, create needed #undef
+#
+
+preprocessor="$1 -I../include"
+AWK="$2"
+ED1=sed1$$.sed
+ED2=sed2$$.sed
+ED3=sed3$$.sed
+AW1=awk1$$.awk
+TMP=gen$$.c
+trap "rm -f $ED1 $ED2 $ED3 $AW1 $TMP" 0 1 2 5 15
+
+(cat <<EOF
+#include <ncurses_cfg.h>
+#include <curses.h>
+
+DECLARATIONS
+
+EOF
+cat >$ED1 <<EOF1
+/^extern.*generated/{
+ h
+ s/^.*generated:\([^ *]*\).*/P_#if_USE_\1_SUPPORT/p
+ g
+ s/^extern \([^;]*\);.*/\1/p
+ g
+ s/^.*generated:\([^ *]*\).*/P_#endif/p
+}
+EOF1
+
+cat >$ED2 <<EOF2
+/^P_/b nc
+/(void)/b nc
+ s/,/ a1% /
+ s/,/ a2% /
+ s/,/ a3% /
+ s/,/ a4% /
+ s/,/ a5% /
+ s/,/ a6% /
+ s/,/ a7% /
+ s/,/ a8% /
+ s/,/ a9% /
+ s/,/ a10% /
+ s/,/ a11% /
+ s/,/ a12% /
+ s/,/ a13% /
+ s/,/ a14% /
+ s/,/ a15% /
+ s/*/ * /g
+ s/%/ , /g
+ s/)/ z)/
+:nc
+ /(/s// ( /
+ s/)/ )/
+EOF2
+
+cat >$ED3 <<EOF3
+/^P_/{
+ s/^P_#if_/#if /
+ s/^P_//
+ b done
+}
+ s/ */ /g
+ s/ */ /g
+ s/ ,/,/g
+ s/ )/)/g
+ s/ gen_/ /
+ s/^M_/#undef /
+ /^%%/s// /
+:done
+EOF3
+
+cat >$AW1 <<\EOF1
+BEGIN {
+ skip=0;
+ }
+ /^P_#if/ {
+ print "\n"
+ print $0
+ skip=0;
+ }
+ /^P_#endif/ {
+ print $0
+ skip=1;
+ }
+ $0 !~ /^P_/ {
+ if (skip)
+ print "\n"
+ skip=1;
+
+ print "M_" $2
+ print $0;
+ print "{";
+ argcount = 1;
+ if (NF == 5 && $4 == "void")
+ argcount = 0;
+ if (argcount != 0) {
+ for (i = 1; i <= NF; i++)
+ if ($i == ",")
+ argcount++;
+ }
+
+ # suppress trace-code for functions that we cannot do properly here,
+ # since they return data.
+ dotrace = 1;
+ if ($2 == "innstr")
+ dotrace = 0;
+
+ call = "%%T((T_CALLED(\""
+ args = ""
+ comma = ""
+ num = 0;
+ pointer = 0;
+ argtype = ""
+ for (i = 1; i <= NF; i++) {
+ ch = $i;
+ if ( ch == "*" )
+ pointer = 1;
+ else if ( ch == "va_list" )
+ pointer = 1;
+ else if ( ch == "char" )
+ argtype = "char";
+ else if ( ch == "int" )
+ argtype = "int";
+ else if ( ch == "short" )
+ argtype = "short";
+ else if ( ch == "chtype" )
+ argtype = "chtype";
+ else if ( ch == "attr_t" || ch == "NCURSES_ATTR_T" )
+ argtype = "attr";
+
+ if ( ch == "," || ch == ")" ) {
+ if (pointer) {
+ if ( argtype == "char" ) {
+ call = call "%s"
+ comma = comma "_nc_visbuf2(" num ","
+ pointer = 0;
+ } else
+ call = call "%p"
+ } else if (argcount != 0) {
+ if ( argtype == "int" || argtype == "short" ) {
+ call = call "%d"
+ argtype = ""
+ } else if ( argtype != "" ) {
+ call = call "%s"
+ comma = comma "_trace" argtype "2(" num ","
+ } else {
+ call = call "%#lx"
+ comma = comma "(long)"
+ }
+ }
+ if (ch == ",")
+ args = args comma "a" ++num;
+ else if (argcount != 0)
+ args = args comma "z"
+ call = call ch
+ if (pointer == 0 && argcount != 0 && argtype != "" )
+ args = args ")"
+ if (args != "")
+ comma = ", "
+ pointer = 0;
+ argtype = ""
+ }
+ if ( i == 2 || ch == "(" )
+ call = call ch
+ }
+ call = call "\")"
+ if (args != "")
+ call = call ", " args
+ call = call ")); "
+
+ if (dotrace)
+ printf "%s", call
+
+ if (match($0, "^void"))
+ call = ""
+ else if (dotrace)
+ call = "returnCode( ";
+ else
+ call = "%%return ";
+
+ call = call $2 "(";
+ for (i = 1; i < argcount; i++)
+ call = call "a" i ", ";
+ if (argcount != 0)
+ call = call "z";
+ if (!match($0, "^void"))
+ call = call ") ";
+ if (dotrace)
+ call = call ")";
+ print call ";"
+
+ if (match($0, "^void"))
+ print "%%returnVoid;"
+ print "}";
+}
+EOF1
+
+sed -n -f $ED1 | sed -f $ED2 \
+| $AWK -f $AW1 ) \
+| sed \
+ -e '/^\([a-z_][a-z_]*\) /s//\1 gen_/' >$TMP
+ $preprocessor $TMP 2>/dev/null \
+| $AWK '
+BEGIN {
+ print "/*"
+ print " * DO NOT EDIT THIS FILE BY HAND!"
+ print " * It is generated by MKlib_gen.sh."
+ print " *"
+ print " * This is a file of trivial functions generated from macro"
+ print " * definitions in curses.h to satisfy the XSI Curses requirement"
+ print " * that every macro also exist as a callable function."
+ print " *"
+ print " * It will never be linked unless you call one of the entry"
+ print " * points with its normal macro definition disabled. In that"
+ print " * case, if you have no shared libraries, it will indirectly"
+ print " * pull most of the rest of the library into your link image."
+ print " */"
+ print "#include <curses.priv.h>"
+ print ""
+ }
+/^DECLARATIONS/ {start = 1; next;}
+ {if (start) print $0;}
+' \
+| sed -f $ED3 \
+| sed \
+ -e 's/^.*T_CALLED.*returnCode( \([a-z].*) \));/ return \1;/' \
+ -e 's/^.*T_CALLED.*returnCode( \((wmove.*) \));/ return \1;/'
+
diff --git a/contrib/ncurses/ncurses/base/MKunctrl.awk b/contrib/ncurses/ncurses/base/MKunctrl.awk
new file mode 100644
index 000000000000..0f4419242a99
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/MKunctrl.awk
@@ -0,0 +1,67 @@
+# $Id: MKunctrl.awk,v 1.6 1998/06/06 18:18:07 tom Exp $
+##############################################################################
+# Copyright (c) 1998 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1997
+#
+
+BEGIN {
+ print "/* generated by MKunctrl.awk */"
+ print ""
+ print "#include <curses.priv.h>"
+ print ""
+ print "#undef unctrl"
+ print ""
+ }
+END {
+ print "NCURSES_CONST char *unctrl(register chtype ch)"
+ print "{"
+ printf "static const char* const table[] = {"
+ for ( ch = 0; ch < 256; ch++ ) {
+ gap = ","
+ if ((ch % 8) == 0)
+ printf "\n "
+ if (ch < 32) {
+ printf "\"^\\%03o\"", ch + 64
+ } else if (ch == 127) {
+ printf "\"^?\""
+ } else {
+ printf "\"\\%03o\"", ch
+ gap = gap " "
+ }
+ if (ch == 255)
+ gap = "\n"
+ else if (((ch + 1) % 8) != 0)
+ gap = gap " "
+ printf "%s", gap
+ }
+ print "};"
+ print ""
+ print "\treturn (NCURSES_CONST char *)table[TextOf(ch)];"
+ print "}"
+ }
diff --git a/contrib/ncurses/ncurses/base/README b/contrib/ncurses/ncurses/base/README
new file mode 100644
index 000000000000..ffa16963e9e3
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/README
@@ -0,0 +1,7 @@
+-- $Id: README,v 1.1 1998/11/14 22:58:22 tom Exp $
+
+The functions in this directory are the generic (not device-specific) modules
+of ncurses.
+
+As a rule, these modules should not depend directly on term.h references and
+associated terminfo function and variables.
diff --git a/contrib/ncurses/ncurses/base/define_key.c b/contrib/ncurses/ncurses/base/define_key.c
new file mode 100644
index 000000000000..52dc6927bd55
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/define_key.c
@@ -0,0 +1,59 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: define_key.c,v 1.4 1999/02/21 13:03:55 tom Exp $")
+
+int
+define_key(char *str, int keycode)
+{
+ int code = ERR;
+
+ T((T_CALLED("define_key(%s,%d)"), _nc_visbuf(str), keycode));
+ if (keycode > 0) {
+ if (str != 0) {
+ define_key(str, 0);
+ } else if (has_key(keycode)) {
+ while (_nc_remove_key(&(SP->_keytry), keycode))
+ code = OK;
+ }
+ if (str != 0) {
+ (void) _nc_add_to_try(&(SP->_keytry), str, keycode);
+ code = OK;
+ }
+ } else {
+ while (_nc_remove_string(&(SP->_keytry), str))
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/keybound.c b/contrib/ncurses/ncurses/base/keybound.c
new file mode 100644
index 000000000000..c9aa02292118
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/keybound.c
@@ -0,0 +1,45 @@
+/****************************************************************************
+ * Copyright (c) 1999 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: keybound.c,v 1.1 1999/02/19 11:55:56 tom Exp $")
+
+/*
+ * Returns the count'th string definition which is associated with the
+ * given keycode. The result is malloc'd, must be freed by the caller.
+ */
+
+char *keybound(int code, int count)
+{
+ return _nc_expand_try(SP->_key_ok, code, &count, 0);
+}
diff --git a/contrib/ncurses/ncurses/base/keyok.c b/contrib/ncurses/ncurses/base/keyok.c
new file mode 100644
index 000000000000..a1385769781f
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/keyok.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: keyok.c,v 1.3 1999/02/19 11:29:48 tom Exp $")
+
+/*
+ * Enable (or disable) ncurses' interpretation of a keycode by adding (or
+ * removing) the corresponding 'tries' entry.
+ *
+ * Do this by storing a second tree of tries, which records the disabled keys.
+ * The simplest way to copy is to make a function that returns the string (with
+ * nulls set to 0200), then use that to reinsert the string into the
+ * corresponding tree.
+ */
+
+int keyok(int c, bool flag)
+{
+ int code = ERR;
+ int count = 0;
+ char *s;
+
+ T((T_CALLED("keyok(%d,%d)"), c, flag));
+ if (flag) {
+ while ((s = _nc_expand_try(SP->_key_ok, c, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_key_ok), c)) {
+ _nc_add_to_try(&(SP->_keytry), s, c);
+ free(s);
+ code = OK;
+ count = 0;
+ }
+ } else {
+ while ((s = _nc_expand_try(SP->_keytry, c, &count, 0)) != 0
+ && _nc_remove_key(&(SP->_keytry), c)) {
+ _nc_add_to_try(&(SP->_key_ok), s, c);
+ free(s);
+ code = OK;
+ count = 0;
+ }
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_addch.c b/contrib/ncurses/ncurses/base/lib_addch.c
new file mode 100644
index 000000000000..101d75ef29a9
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_addch.c
@@ -0,0 +1,293 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_addch.c
+**
+** The routine waddch().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_addch.c,v 1.42 1999/07/24 20:01:05 tom Exp $")
+
+/*
+ * Ugly microtweaking alert. Everything from here to end of module is
+ * likely to be speed-critical -- profiling data sure says it is!
+ * Most of the important screen-painting functions are shells around
+ * waddch(). So we make every effort to reduce function-call overhead
+ * by inlining stuff, even at the cost of making wrapped copies for
+ * export. Also we supply some internal versions that don't call the
+ * window sync hook, for use by string-put functions.
+ */
+
+/* Return bit mask for clearing color pair number if given ch has color */
+#define COLOR_MASK(ch) (~(chtype)((ch)&A_COLOR?A_COLOR:0))
+
+static inline chtype render_char(WINDOW *win, chtype ch)
+/* compute a rendition of the given char correct for the current context */
+{
+ chtype a = win->_attrs;
+
+ if (ch == ' ')
+ {
+ /* color in attrs has precedence over bkgd */
+ ch = a | (win->_bkgd & COLOR_MASK(a));
+ }
+ else
+ {
+ /* color in attrs has precedence over bkgd */
+ a |= (win->_bkgd & A_ATTRIBUTES) & COLOR_MASK(a);
+ /* color in ch has precedence */
+ ch |= (a & COLOR_MASK(ch));
+ }
+
+ TR(TRACE_VIRTPUT, ("bkg = %lx, attrs = %lx -> ch = %lx", win->_bkgd,
+ win->_attrs, ch));
+
+ return(ch);
+}
+
+chtype _nc_background(WINDOW *win)
+/* make render_char() visible while still allowing us to inline it below */
+{
+ return (win->_bkgd);
+}
+
+chtype _nc_render(WINDOW *win, chtype ch)
+/* make render_char() visible while still allowing us to inline it below */
+{
+ return render_char(win, ch);
+}
+
+/* check if position is legal; if not, return error */
+#ifndef NDEBUG /* treat this like an assertion */
+#define CHECK_POSITION(win, x, y) \
+ if (y > win->_maxy \
+ || x > win->_maxx \
+ || y < 0 \
+ || x < 0) { \
+ TR(TRACE_VIRTPUT, ("Alert! Win=%p _curx = %d, _cury = %d " \
+ "(_maxx = %d, _maxy = %d)", win, x, y, \
+ win->_maxx, win->_maxy)); \
+ return(ERR); \
+ }
+#else
+#define CHECK_POSITION(win, x, y) /* nothing */
+#endif
+
+static inline
+int waddch_literal(WINDOW *win, chtype ch)
+{
+ int x;
+ struct ldat *line;
+
+ x = win->_curx;
+
+ CHECK_POSITION(win, x, win->_cury);
+
+ /*
+ * If we're trying to add a character at the lower-right corner more
+ * than once, fail. (Moving the cursor will clear the flag).
+ */
+ if (win->_flags & _WRAPPED) {
+ if (x >= win->_maxx)
+ return (ERR);
+ win->_flags &= ~_WRAPPED;
+ }
+
+ ch = render_char(win, ch);
+ TR(TRACE_VIRTPUT, ("win attr = %s", _traceattr(win->_attrs)));
+
+ line = win->_line+win->_cury;
+
+ CHANGED_CELL(line,x);
+
+ line->text[x++] = ch;
+
+ TR(TRACE_VIRTPUT, ("(%d, %d) = %s", win->_cury, x, _tracechtype(ch)));
+ if (x > win->_maxx) {
+ /*
+ * The _WRAPPED flag is useful only for telling an application
+ * that we've just wrapped the cursor. We don't do anything
+ * with this flag except set it when wrapping, and clear it
+ * whenever we move the cursor. If we try to wrap at the
+ * lower-right corner of a window, we cannot move the cursor
+ * (since that wouldn't be legal). So we return an error
+ * (which is what SVr4 does). Unlike SVr4, we can successfully
+ * add a character to the lower-right corner.
+ */
+ win->_flags |= _WRAPPED;
+ if (++win->_cury > win->_regbottom) {
+ win->_cury = win->_regbottom;
+ win->_curx = win->_maxx;
+ if (!win->_scroll)
+ return (ERR);
+ scroll(win);
+ }
+ win->_curx = 0;
+ return (OK);
+ }
+ win->_curx = x;
+ return OK;
+}
+
+static inline
+int waddch_nosync(WINDOW *win, const chtype ch)
+/* the workhorse function -- add a character to the given window */
+{
+ int x, y;
+ int t = 0;
+ const char *s = 0;
+
+ if ((ch & A_ALTCHARSET)
+ || ((t = TextOf(ch)) > 127)
+ || ((s = unctrl(t))[1] == 0))
+ return waddch_literal(win, ch);
+
+ x = win->_curx;
+ y = win->_cury;
+
+ switch (t) {
+ case '\t':
+ x += (TABSIZE-(x%TABSIZE));
+
+ /*
+ * Space-fill the tab on the bottom line so that we'll get the
+ * "correct" cursor position.
+ */
+ if ((! win->_scroll && (y == win->_regbottom))
+ || (x <= win->_maxx)) {
+ chtype blank = (' ' | AttrOf(ch));
+ while (win->_curx < x) {
+ if (waddch_literal(win, blank) == ERR)
+ return(ERR);
+ }
+ break;
+ } else {
+ wclrtoeol(win);
+ win->_flags |= _WRAPPED;
+ if (++y > win->_regbottom) {
+ x = win->_maxx;
+ y--;
+ if (win->_scroll) {
+ scroll(win);
+ x = 0;
+ }
+ } else {
+ x = 0;
+ }
+ }
+ break;
+ case '\n':
+ wclrtoeol(win);
+ if (++y > win->_regbottom) {
+ y--;
+ if (win->_scroll)
+ scroll(win);
+ else
+ return (ERR);
+ }
+ /* FALLTHRU */
+ case '\r':
+ x = 0;
+ win->_flags &= ~_WRAPPED;
+ break;
+ case '\b':
+ if (x == 0)
+ return (OK);
+ x--;
+ win->_flags &= ~_WRAPPED;
+ break;
+ default:
+ while (*s)
+ if (waddch_literal(win, (*s++)|AttrOf(ch)) == ERR)
+ return ERR;
+ return(OK);
+ }
+
+ win->_curx = x;
+ win->_cury = y;
+
+ return(OK);
+}
+
+int _nc_waddch_nosync(WINDOW *win, const chtype c)
+/* export copy of waddch_nosync() so the string-put functions can use it */
+{
+ return(waddch_nosync(win, c));
+}
+
+/*
+ * The versions below call _nc_synhook(). We wanted to avoid this in the
+ * version exported for string puts; they'll call _nc_synchook once at end
+ * of run.
+ */
+
+/* These are actual entry points */
+
+int waddch(WINDOW *win, const chtype ch)
+{
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("waddch(%p, %s)"), win, _tracechtype(ch)));
+
+ if (win && (waddch_nosync(win, ch) != ERR))
+ {
+ _nc_synchook(win);
+ code = OK;
+ }
+
+ TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
+ return(code);
+}
+
+int wechochar(WINDOW *win, const chtype ch)
+{
+ int code = ERR;
+
+ TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_CALLED("wechochar(%p, %s)"), win, _tracechtype(ch)));
+
+ if (win && (waddch_nosync(win, ch) != ERR))
+ {
+ bool save_immed = win->_immed;
+ win->_immed = TRUE;
+ _nc_synchook(win);
+ win->_immed = save_immed;
+ code = OK;
+ }
+ TR(TRACE_VIRTPUT|TRACE_CCALLS, (T_RETURN("%d"), code));
+ return(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_addstr.c b/contrib/ncurses/ncurses/base/lib_addstr.c
new file mode 100644
index 000000000000..9ac55e42aba7
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_addstr.c
@@ -0,0 +1,103 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_addstr.c
+*
+** The routines waddnstr(), waddchnstr().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_addstr.c,v 1.16 1998/06/28 00:38:29 tom Exp $")
+
+int
+waddnstr(WINDOW *win, const char *const astr, int n)
+{
+unsigned const char *str = (unsigned const char *)astr;
+int code = ERR;
+
+ T((T_CALLED("waddnstr(%p,%s,%d)"), win, _nc_visbuf(astr), n));
+
+ if (win && (str != 0)) {
+ T(("... current %s", _traceattr(win->_attrs)));
+ TR(TRACE_VIRTPUT, ("str is not null"));
+ code = OK;
+ if (n < 0)
+ n = (int)strlen(astr);
+
+ while((n-- > 0) && (*str != '\0')) {
+ TR(TRACE_VIRTPUT, ("*str = %#x", *str));
+ if (_nc_waddch_nosync(win, (chtype)*str++) == ERR) {
+ code = ERR;
+ break;
+ }
+ }
+ _nc_synchook(win);
+ }
+ TR(TRACE_VIRTPUT, ("waddnstr returns %d", code));
+ returnCode(code);
+}
+
+int
+waddchnstr(WINDOW *win, const chtype *const astr, int n)
+{
+short y = win->_cury;
+short x = win->_curx;
+int code = OK;
+struct ldat *line;
+
+ T((T_CALLED("waddchnstr(%p,%p,%d)"), win, astr, n));
+
+ if (!win)
+ returnCode(ERR);
+
+ if (n < 0) {
+ const chtype *str;
+ n = 0;
+ for (str=(const chtype *)astr; *str!=0; str++)
+ n++;
+ }
+ if (n > win->_maxx - x + 1)
+ n = win->_maxx - x + 1;
+ if (n == 0)
+ returnCode(code);
+
+ line = &(win->_line[y]);
+ memcpy(line->text+x, astr, n*sizeof(*astr));
+ CHANGED_RANGE(line, x, x+n-1);
+
+ _nc_synchook(win);
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_beep.c b/contrib/ncurses/ncurses/base/lib_beep.c
new file mode 100644
index 000000000000..9b89496608da
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_beep.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * beep.c
+ *
+ * The routine beep().
+ *
+ */
+
+#include <curses.priv.h>
+#include <term.h> /* beep, flash */
+
+MODULE_ID("$Id: lib_beep.c,v 1.6 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $")
+
+/*
+ * beep()
+ *
+ * Sound the current terminal's audible bell if it has one. If not,
+ * flash the screen if possible.
+ *
+ */
+
+int beep(void)
+{
+ int res = ERR;
+
+ T((T_CALLED("beep()")));
+
+ /* FIXME: should make sure that we are not in altchar mode */
+ if (bell) {
+ TPUTS_TRACE("bell");
+ res = putp(bell);
+ fflush(SP->_ofp);
+ } else if (flash_screen) {
+ TPUTS_TRACE("flash_screen");
+ res = putp(flash_screen);
+ fflush(SP->_ofp);
+ }
+
+ returnCode(res);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_bkgd.c b/contrib/ncurses/ncurses/base/lib_bkgd.c
new file mode 100644
index 000000000000..410ee0580433
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_bkgd.c
@@ -0,0 +1,86 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_bkgd.c,v 1.12 1998/02/11 12:13:54 tom Exp $")
+
+void wbkgdset(WINDOW *win, chtype ch)
+{
+ T((T_CALLED("wbkgdset(%p,%s)"), win, _tracechtype(ch)));
+
+ if (win) {
+ chtype off = AttrOf(win->_bkgd);
+ chtype on = AttrOf(ch);
+
+ toggle_attr_off(win->_attrs,off);
+ toggle_attr_on (win->_attrs,on);
+
+ if (TextOf(ch)==0)
+ ch |= BLANK;
+ win->_bkgd = ch;
+ }
+ returnVoid;
+}
+
+int wbkgd(WINDOW *win, const chtype ch)
+{
+ int code = ERR;
+ int x, y;
+ chtype new_bkgd = ch;
+
+ T((T_CALLED("wbkgd(%p,%s)"), win, _tracechtype(new_bkgd)));
+
+ if (win) {
+ chtype old_bkgd = getbkgd(win);
+
+ wbkgdset(win, new_bkgd);
+ wattrset(win, AttrOf(win->_bkgd));
+
+ for (y = 0; y <= win->_maxy; y++) {
+ for (x = 0; x <= win->_maxx; x++) {
+ if (win->_line[y].text[x] == old_bkgd)
+ win->_line[y].text[x] = win->_bkgd;
+ else
+ win->_line[y].text[x] =
+ _nc_render(win,(A_ALTCHARSET &
+ AttrOf(win->_line[y].text[x]))
+ | TextOf(win->_line[y].text[x]));
+ }
+ }
+ touchwin(win);
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_box.c b/contrib/ncurses/ncurses/base/lib_box.c
new file mode 100644
index 000000000000..bcd96416f954
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_box.c
@@ -0,0 +1,110 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_box.c
+**
+** The routine wborder().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_box.c,v 1.10 1998/02/11 12:13:56 tom Exp $")
+
+int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
+ chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
+{
+short i;
+short endx, endy;
+
+ T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
+ win,
+ _tracechtype2(1,ls),
+ _tracechtype2(2,rs),
+ _tracechtype2(3,ts),
+ _tracechtype2(4,bs),
+ _tracechtype2(5,tl),
+ _tracechtype2(6,tr),
+ _tracechtype2(7,bl),
+ _tracechtype2(8,br)));
+
+ if (!win)
+ returnCode(ERR);
+
+ if (ls == 0) ls = ACS_VLINE;
+ if (rs == 0) rs = ACS_VLINE;
+ if (ts == 0) ts = ACS_HLINE;
+ if (bs == 0) bs = ACS_HLINE;
+ if (tl == 0) tl = ACS_ULCORNER;
+ if (tr == 0) tr = ACS_URCORNER;
+ if (bl == 0) bl = ACS_LLCORNER;
+ if (br == 0) br = ACS_LRCORNER;
+
+ ls = _nc_render(win, ls);
+ rs = _nc_render(win, rs);
+ ts = _nc_render(win, ts);
+ bs = _nc_render(win, bs);
+ tl = _nc_render(win, tl);
+ tr = _nc_render(win, tr);
+ bl = _nc_render(win, bl);
+ br = _nc_render(win, br);
+
+ T(("using %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx, %#lx", ls, rs, ts, bs, tl, tr, bl, br));
+
+ endx = win->_maxx;
+ endy = win->_maxy;
+
+ for (i = 0; i <= endx; i++) {
+ win->_line[0].text[i] = ts;
+ win->_line[endy].text[i] = bs;
+ }
+ win->_line[endy].firstchar = win->_line[0].firstchar = 0;
+ win->_line[endy].lastchar = win->_line[0].lastchar = endx;
+
+ for (i = 0; i <= endy; i++) {
+ win->_line[i].text[0] = ls;
+ win->_line[i].text[endx] = rs;
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = endx;
+ }
+ win->_line[0].text[0] = tl;
+ win->_line[0].text[endx] = tr;
+ win->_line[endy].text[0] = bl;
+ win->_line[endy].text[endx] = br;
+
+ _nc_synchook(win);
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_chgat.c b/contrib/ncurses/ncurses/base/lib_chgat.c
new file mode 100644
index 000000000000..7690ae4a2af3
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_chgat.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_chgat.c
+**
+** The routine wchgat().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_chgat.c,v 1.2 1998/02/11 12:14:00 tom Exp $")
+
+int wchgat(WINDOW *win, int n, attr_t attr, short color, const void *opts GCC_UNUSED)
+{
+ int i;
+
+ T((T_CALLED("wchgat(%p,%d,%s,%d)"), win, n, _traceattr(attr), color));
+
+ if (win) {
+ toggle_attr_on(attr,COLOR_PAIR(color));
+
+ for (i = win->_curx; i <= win->_maxx && (n == -1 || (n-- > 0)); i++)
+ win->_line[win->_cury].text[i]
+ = TextOf(win->_line[win->_cury].text[i]) | attr;
+
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_clear.c b/contrib/ncurses/ncurses/base/lib_clear.c
new file mode 100644
index 000000000000..9c07cf0890e4
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_clear.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_clear.c
+**
+** The routine wclear().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_clear.c,v 1.5 1998/02/11 12:13:53 tom Exp $")
+
+int wclear(WINDOW *win)
+{
+int code = ERR;
+
+ T((T_CALLED("wclear(%p)"), win));
+
+ if ((code = werase(win))!=ERR)
+ win->_clear = TRUE;
+
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_clearok.c b/contrib/ncurses/ncurses/base/lib_clearok.c
new file mode 100644
index 000000000000..cc904b1d7dc7
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_clearok.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_clearok.c
+**
+** The routine clearok.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_clearok.c,v 1.2 1998/02/11 12:14:00 tom Exp $")
+
+int clearok(WINDOW *win, bool flag)
+{
+ T((T_CALLED("clearok(%p,%d)"), win, flag));
+
+ if (win) {
+ win->_clear = flag;
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_clrbot.c b/contrib/ncurses/ncurses/base/lib_clrbot.c
new file mode 100644
index 000000000000..cec34161acef
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_clrbot.c
@@ -0,0 +1,75 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_clrbot.c
+**
+** The routine wclrtobot().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_clrbot.c,v 1.14 1998/06/28 00:36:26 tom Exp $")
+
+int wclrtobot(WINDOW *win)
+{
+int code = ERR;
+
+ T((T_CALLED("wclrtobot(%p)"), win));
+
+ if (win) {
+ short y;
+ short startx = win->_curx;
+ chtype blank = _nc_background(win);
+
+ T(("clearing from y = %d to y = %d with maxx = %d", win->_cury, win->_maxy, win->_maxx));
+
+ for (y = win->_cury; y <= win->_maxy; y++) {
+ struct ldat *line = &(win->_line[y]);
+ chtype *ptr = &(line->text[startx]);
+ chtype *end = &(line->text[win->_maxx]);
+
+ CHANGED_TO_EOL(line, startx, win->_maxx);
+
+ while (ptr <= end)
+ *ptr++ = blank;
+
+ startx = 0;
+ }
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
+
diff --git a/contrib/ncurses/ncurses/base/lib_clreol.c b/contrib/ncurses/ncurses/base/lib_clreol.c
new file mode 100644
index 000000000000..0c7522278e38
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_clreol.c
@@ -0,0 +1,91 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_clreol.c
+**
+** The routine wclrtoeol().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_clreol.c,v 1.15 1998/06/28 00:32:20 tom Exp $")
+
+int wclrtoeol(WINDOW *win)
+{
+int code = ERR;
+
+ T((T_CALLED("wclrtoeol(%p)"), win));
+
+ if (win) {
+ chtype blank;
+ chtype *ptr, *end;
+ struct ldat *line;
+ short y = win->_cury;
+ short x = win->_curx;
+
+ /*
+ * If we have just wrapped the cursor, the clear applies to the
+ * new line, unless we are at the lower right corner.
+ */
+ if (win->_flags & _WRAPPED
+ && y < win->_maxy) {
+ win->_flags &= ~_WRAPPED;
+ }
+
+ /*
+ * There's no point in clearing if we're not on a legal
+ * position, either.
+ */
+ if (win->_flags & _WRAPPED
+ || y > win->_maxy
+ || x > win->_maxx)
+ returnCode(ERR);
+
+ blank = _nc_background(win);
+ line = &win->_line[y];
+ CHANGED_TO_EOL(line, x, win->_maxx);
+
+ ptr = &(line->text[x]);
+ end = &(line->text[win->_maxx]);
+
+ while (ptr <= end)
+ *ptr++ = blank;
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_color.c b/contrib/ncurses/ncurses/base/lib_color.c
new file mode 100644
index 000000000000..cdc943adc6ee
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_color.c
@@ -0,0 +1,429 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/* lib_color.c
+ *
+ * Handles color emulation of SYS V curses
+ *
+ */
+
+#include <curses.priv.h>
+
+#include <term.h>
+
+MODULE_ID("$Id: lib_color.c,v 1.35 1999/03/15 01:45:14 Alexander.V.Lukyanov Exp $")
+
+/*
+ * These should be screen structure members. They need to be globals for
+ * hystorical reasons. So we assign them in start_color() and also in
+ * set_term()'s screen-switching logic.
+ */
+int COLOR_PAIRS;
+int COLORS;
+
+/*
+ * Given a RGB range of 0..1000, we'll normally set the individual values
+ * to about 2/3 of the maximum, leaving full-range for bold/bright colors.
+ */
+#define RGB_ON 680
+#define RGB_OFF 0
+
+static const color_t cga_palette[] =
+{
+ /* R G B */
+ {RGB_OFF, RGB_OFF, RGB_OFF}, /* COLOR_BLACK */
+ {RGB_ON, RGB_OFF, RGB_OFF}, /* COLOR_RED */
+ {RGB_OFF, RGB_ON, RGB_OFF}, /* COLOR_GREEN */
+ {RGB_ON, RGB_ON, RGB_OFF}, /* COLOR_YELLOW */
+ {RGB_OFF, RGB_OFF, RGB_ON}, /* COLOR_BLUE */
+ {RGB_ON, RGB_OFF, RGB_ON}, /* COLOR_MAGENTA */
+ {RGB_OFF, RGB_ON, RGB_ON}, /* COLOR_CYAN */
+ {RGB_ON, RGB_ON, RGB_ON}, /* COLOR_WHITE */
+};
+static const color_t hls_palette[] =
+{
+ /* H L S */
+ {0, 0, 0}, /* COLOR_BLACK */
+ {120, 50, 100}, /* COLOR_RED */
+ {240, 50, 100}, /* COLOR_GREEN */
+ {180, 50, 100}, /* COLOR_YELLOW */
+ {330, 50, 100}, /* COLOR_BLUE */
+ {60, 50, 100}, /* COLOR_MAGENTA */
+ {300, 50, 100}, /* COLOR_CYAN */
+ {0, 50, 100}, /* COLOR_WHITE */
+};
+
+/*
+ * SVr4 curses is known to interchange color codes (1,4) and (3,6), possibly
+ * to maintain compatibility with a pre-ANSI scheme. The same scheme is
+ * also used in the FreeBSD syscons.
+ */
+static int toggled_colors(int c)
+{
+ if (c < 16) {
+ static const int table[] =
+ { 0, 4, 2, 6, 1, 5, 3, 7,
+ 8, 12, 10, 14, 9, 13, 11, 15};
+ c = table[c];
+ }
+ return c;
+}
+
+static void set_background_color(int bg, int (*outc)(int))
+{
+ if (set_a_background)
+ {
+ TPUTS_TRACE("set_a_background");
+ tputs(tparm(set_a_background, bg), 1, outc);
+ }
+ else
+ {
+ TPUTS_TRACE("set_background");
+ tputs(tparm(set_background, toggled_colors(bg)), 1, outc);
+ }
+}
+
+static void set_foreground_color(int fg, int (*outc)(int))
+{
+ if (set_a_foreground)
+ {
+ TPUTS_TRACE("set_a_foreground");
+ tputs(tparm(set_a_foreground, fg), 1, outc);
+ }
+ else
+ {
+ TPUTS_TRACE("set_foreground");
+ tputs(tparm(set_foreground, toggled_colors(fg)), 1, outc);
+ }
+}
+
+static bool set_original_colors(void)
+{
+ if (orig_pair != 0) {
+ TPUTS_TRACE("orig_pair");
+ putp(orig_pair);
+ return TRUE;
+ }
+ else if (orig_colors != NULL)
+ {
+ TPUTS_TRACE("orig_colors");
+ putp(orig_colors);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int start_color(void)
+{
+ T((T_CALLED("start_color()")));
+
+ if (set_original_colors() != TRUE)
+ {
+ set_foreground_color(COLOR_WHITE, _nc_outch);
+ set_background_color(COLOR_BLACK, _nc_outch);
+ }
+
+ if (max_pairs != -1)
+ COLOR_PAIRS = SP->_pair_count = max_pairs;
+ else
+ returnCode(ERR);
+ if ((SP->_color_pairs = typeCalloc(unsigned short, max_pairs)) == 0)
+ returnCode(ERR);
+ SP->_color_pairs[0] = PAIR_OF(COLOR_WHITE, COLOR_BLACK);
+ if (max_colors != -1)
+ COLORS = SP->_color_count = max_colors;
+ else
+ returnCode(ERR);
+ SP->_coloron = 1;
+
+ if ((SP->_color_table = typeMalloc(color_t, COLORS)) == 0)
+ returnCode(ERR);
+ if (hue_lightness_saturation)
+ memcpy(SP->_color_table, hls_palette, sizeof(color_t) * COLORS);
+ else
+ memcpy(SP->_color_table, cga_palette, sizeof(color_t) * COLORS);
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d", COLORS, COLOR_PAIRS));
+
+ returnCode(OK);
+}
+
+/* This function was originally written by Daniel Weaver <danw@znyx.com> */
+static void rgb2hls(short r, short g, short b, short *h, short *l, short *s)
+/* convert RGB to HLS system */
+{
+ short min, max, t;
+
+ if ((min = g < r ? g : r) > b) min = b;
+ if ((max = g > r ? g : r) < b) max = b;
+
+ /* calculate lightness */
+ *l = (min + max) / 20;
+
+ if (min == max) /* black, white and all shades of gray */
+ {
+ *h = 0;
+ *s = 0;
+ return;
+ }
+
+ /* calculate saturation */
+ if (*l < 50)
+ *s = ((max - min) * 100) / (max + min);
+ else *s = ((max - min) * 100) / (2000 - max - min);
+
+ /* calculate hue */
+ if (r == max)
+ t = 120 + ((g - b) * 60) / (max - min);
+ else
+ if (g == max)
+ t = 240 + ((b - r) * 60) / (max - min);
+ else
+ t = 360 + ((r - g) * 60) / (max - min);
+
+ *h = t % 360;
+}
+
+/*
+ * Extension (1997/1/18) - Allow negative f/b values to set default color
+ * values.
+ */
+int init_pair(short pair, short f, short b)
+{
+ unsigned result;
+
+ T((T_CALLED("init_pair(%d,%d,%d)"), pair, f, b));
+
+ if ((pair < 1) || (pair >= COLOR_PAIRS))
+ returnCode(ERR);
+ if (SP->_default_color)
+ {
+ if (f < 0)
+ f = C_MASK;
+ if (b < 0)
+ b = C_MASK;
+ if (f >= COLORS && f != C_MASK)
+ returnCode(ERR);
+ if (b >= COLORS && b != C_MASK)
+ returnCode(ERR);
+ }
+ else
+ if ((f < 0) || (f >= COLORS)
+ || (b < 0) || (b >= COLORS))
+ returnCode(ERR);
+
+ /*
+ * When a pair's content is changed, replace its colors (if pair was
+ * initialized before a screen update is performed replacing original
+ * pair colors with the new ones).
+ */
+ result = PAIR_OF(f,b);
+ if (SP->_color_pairs[pair] != 0
+ && SP->_color_pairs[pair] != result) {
+ int y, x;
+ attr_t z = COLOR_PAIR(pair);
+
+ for (y = 0; y <= curscr->_maxy; y++) {
+ struct ldat *ptr = &(curscr->_line[y]);
+ bool changed = FALSE;
+ for (x = 0; x <= curscr->_maxx; x++) {
+ if ((ptr->text[x] & A_COLOR) == z) {
+ /* Set the old cell to zero to ensure it will be
+ updated on the next doupdate() */
+ ptr->text[x] = 0;
+ CHANGED_CELL(ptr,x);
+ changed = TRUE;
+ }
+ }
+ if (changed)
+ _nc_make_oldhash(y);
+ }
+ }
+ SP->_color_pairs[pair] = result;
+
+ if (initialize_pair)
+ {
+ const color_t *tp = hue_lightness_saturation ? hls_palette : cga_palette;
+
+ T(("initializing pair: pair = %d, fg=(%d,%d,%d), bg=(%d,%d,%d)",
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+
+ if (initialize_pair)
+ {
+ TPUTS_TRACE("initialize_pair");
+ putp(tparm(initialize_pair,
+ pair,
+ tp[f].red, tp[f].green, tp[f].blue,
+ tp[b].red, tp[b].green, tp[b].blue));
+ }
+ }
+
+ returnCode(OK);
+}
+
+int init_color(short color, short r, short g, short b)
+{
+ T((T_CALLED("init_color(%d,%d,%d,%d)"), color, r, g, b));
+
+ if (initialize_color == NULL)
+ returnCode(ERR);
+
+ if (color < 0 || color >= COLORS)
+ returnCode(ERR);
+ if (r < 0 || r > 1000 || g < 0 || g > 1000 || b < 0 || b > 1000)
+ returnCode(ERR);
+
+ if (hue_lightness_saturation)
+ rgb2hls(r, g, b,
+ &SP->_color_table[color].red,
+ &SP->_color_table[color].green,
+ &SP->_color_table[color].blue);
+ else
+ {
+ SP->_color_table[color].red = r;
+ SP->_color_table[color].green = g;
+ SP->_color_table[color].blue = b;
+ }
+
+ if (initialize_color)
+ {
+ TPUTS_TRACE("initialize_color");
+ putp(tparm(initialize_color, color, r, g, b));
+ }
+ returnCode(OK);
+}
+
+bool can_change_color(void)
+{
+ T((T_CALLED("can_change_color()")));
+ returnCode ((can_change != 0) ? TRUE : FALSE);
+}
+
+bool has_colors(void)
+{
+ T((T_CALLED("has_colors()")));
+ returnCode (((max_colors != -1) && (max_pairs != -1)
+ && (((set_foreground != NULL)
+ && (set_background != NULL))
+ || ((set_a_foreground != NULL)
+ && (set_a_background != NULL))
+ || set_color_pair)) ? TRUE : FALSE);
+}
+
+int color_content(short color, short *r, short *g, short *b)
+{
+ T((T_CALLED("color_content(%d,%p,%p,%p)"), color, r, g, b));
+ if (color < 0 || color > COLORS)
+ returnCode(ERR);
+
+ if (r) *r = SP->_color_table[color].red;
+ if (g) *g = SP->_color_table[color].green;
+ if (b) *b = SP->_color_table[color].blue;
+ returnCode(OK);
+}
+
+int pair_content(short pair, short *f, short *b)
+{
+ T((T_CALLED("pair_content(%d,%p,%p)"), pair, f, b));
+
+ if ((pair < 0) || (pair > COLOR_PAIRS))
+ returnCode(ERR);
+ if (f) *f = ((SP->_color_pairs[pair] >> C_SHIFT) & C_MASK);
+ if (b) *b = (SP->_color_pairs[pair] & C_MASK);
+
+ returnCode(OK);
+}
+
+void _nc_do_color(int pair, bool reverse, int (*outc)(int))
+{
+ short fg, bg;
+
+ if (pair == 0)
+ {
+ if (orig_pair)
+ {
+ TPUTS_TRACE("orig_pair");
+ tputs(orig_pair, 1, outc);
+ }
+ else if (set_color_pair)
+ {
+ TPUTS_TRACE("set_color_pair");
+ tputs(tparm(set_color_pair, pair), 1, outc);
+ }
+ else
+ {
+ set_foreground_color(COLOR_WHITE, outc);
+ set_background_color(COLOR_BLACK, outc);
+ }
+ }
+ else
+ {
+ if (set_color_pair)
+ {
+ TPUTS_TRACE("set_color_pair");
+ tputs(tparm(set_color_pair, pair), 1, outc);
+ }
+ else
+ {
+ pair_content(pair, &fg, &bg);
+ if (reverse) {
+ short xx = fg;
+ fg = bg;
+ bg = xx;
+ }
+
+ T(("setting colors: pair = %d, fg = %d, bg = %d", pair, fg, bg));
+
+ if (fg == C_MASK || bg == C_MASK)
+ {
+ if (set_original_colors() != TRUE)
+ {
+ if (fg == C_MASK)
+ set_foreground_color(COLOR_WHITE, outc);
+ if (bg == C_MASK)
+ set_background_color(COLOR_BLACK, outc);
+ }
+ }
+ if (fg != C_MASK)
+ {
+ set_foreground_color(fg, outc);
+ }
+ if (bg != C_MASK)
+ {
+ set_background_color(bg, outc);
+ }
+ }
+ }
+}
diff --git a/contrib/ncurses/ncurses/base/lib_colorset.c b/contrib/ncurses/ncurses/base/lib_colorset.c
new file mode 100644
index 000000000000..d9fc5c28dc01
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_colorset.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ ****************************************************************************/
+
+/*
+** lib_colorset.c
+**
+** The routine wcolor_set().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_colorset.c,v 1.5 1999/05/16 17:13:43 juergen Exp $")
+
+int wcolor_set(WINDOW *win, short color_pair_number, void *opts)
+{
+ T((T_CALLED("wcolor_set(%p,%d)"), win, color_pair_number));
+ if (win && !opts && (color_pair_number >= 0) && (color_pair_number < COLOR_PAIRS)) {
+ T(("... current %ld", (long) PAIR_NUMBER(win->_attrs)));
+ toggle_attr_on(win->_attrs,COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
+
+
diff --git a/contrib/ncurses/ncurses/base/lib_delch.c b/contrib/ncurses/ncurses/base/lib_delch.c
new file mode 100644
index 000000000000..0169d31ac6d5
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_delch.c
@@ -0,0 +1,68 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_delch.c
+**
+** The routine wdelch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_delch.c,v 1.8 1998/06/28 00:28:17 tom Exp $")
+
+int wdelch(WINDOW *win)
+{
+int code = ERR;
+
+ T((T_CALLED("wdelch(%p)"), win));
+
+ if (win) {
+ chtype blank = _nc_background(win);
+ struct ldat *line = &(win->_line[win->_cury]);
+ chtype *end = &(line->text[win->_maxx]);
+ chtype *temp2 = &(line->text[win->_curx + 1]);
+ chtype *temp1 = temp2 - 1;
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 < end)
+ *temp1++ = *temp2++;
+
+ *temp1 = blank;
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_delwin.c b/contrib/ncurses/ncurses/base/lib_delwin.c
new file mode 100644
index 000000000000..7bab0c77b02b
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_delwin.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_delwin.c
+**
+** The routine delwin().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_delwin.c,v 1.9 1998/02/11 12:13:53 tom Exp $")
+
+static bool have_children(WINDOW *win)
+{
+ WINDOWLIST *p;
+ for (p = _nc_windows; p != 0; p = p->next) {
+ if (p->win->_flags & _SUBWIN
+ && p->win->_parent == win)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int delwin(WINDOW *win)
+{
+ T((T_CALLED("delwin(%p)"), win));
+
+ if (win == 0
+ || have_children(win))
+ returnCode(ERR);
+
+ if (win->_flags & _SUBWIN)
+ touchwin(win->_parent);
+ else if (curscr != 0)
+ touchwin(curscr);
+
+ _nc_freewin(win);
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_dft_fgbg.c b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
new file mode 100644
index 000000000000..a2dfbd218f74
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_dft_fgbg.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_dft_fgbg.c,v 1.3 1998/02/11 12:13:54 tom Exp $")
+
+/*
+ * Modify the behavior of color-pair 0 so that the library doesn't assume that
+ * it is black on white. This is an extension to XSI curses.
+ *
+ * Invoke this function after 'start_color()'.
+ */
+int
+use_default_colors(void)
+{
+ T((T_CALLED("use_default_colors()")));
+
+ if (!SP->_coloron)
+ returnCode(ERR);
+
+ if (!orig_pair && !orig_colors)
+ returnCode(ERR);
+
+ if (initialize_pair) /* don't know how to handle this */
+ returnCode(ERR);
+
+ SP->_default_color = TRUE;
+ SP->_color_pairs[0] = PAIR_OF(C_MASK, C_MASK);
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_echo.c b/contrib/ncurses/ncurses/base/lib_echo.c
new file mode 100644
index 000000000000..4ccf97ff64c0
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_echo.c
@@ -0,0 +1,60 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * echo.c
+ *
+ * Routines:
+ * echo()
+ * noecho()
+ *
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_echo.c,v 1.3 1998/10/12 13:15:33 Alexander.V.Lukyanov Exp $")
+
+int echo(void)
+{
+ T((T_CALLED("echo()")));
+ SP->_echo = TRUE;
+ returnCode(OK);
+}
+
+int noecho(void)
+{
+ T((T_CALLED("noecho()")));
+ SP->_echo = FALSE;
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_endwin.c b/contrib/ncurses/ncurses/base/lib_endwin.c
new file mode 100644
index 000000000000..31b6e516cc1d
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_endwin.c
@@ -0,0 +1,61 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_endwin.c
+**
+** The routine endwin().
+**
+*/
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_endwin.c,v 1.17 1999/06/12 23:01:46 tom Exp $")
+
+int
+endwin(void)
+{
+ T((T_CALLED("endwin()")));
+
+ if (SP) {
+ SP->_endwin = TRUE;
+ SP->_mouse_wrap(SP);
+ _nc_screen_wrap();
+ _nc_mvcur_wrap(); /* wrap up cursor addressing */
+ returnCode(reset_shell_mode());
+ }
+
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_erase.c b/contrib/ncurses/ncurses/base/lib_erase.c
new file mode 100644
index 000000000000..1e4237bf8056
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_erase.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_erase.c
+**
+** The routine werase().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_erase.c,v 1.11 1998/02/11 12:13:54 tom Exp $")
+
+int werase(WINDOW *win)
+{
+int code = ERR;
+int y;
+chtype blank;
+chtype *sp, *end, *start;
+
+ T((T_CALLED("werase(%p)"), win));
+
+ if (win) {
+ blank = _nc_background(win);
+ for (y = 0; y <= win->_maxy; y++) {
+ start = win->_line[y].text;
+ end = &start[win->_maxx];
+
+ for (sp = start; sp <= end; sp++)
+ *sp = blank;
+
+ win->_line[y].firstchar = 0;
+ win->_line[y].lastchar = win->_maxx;
+ }
+ win->_curx = win->_cury = 0;
+ win->_flags &= ~_WRAPPED;
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_flash.c b/contrib/ncurses/ncurses/base/lib_flash.c
new file mode 100644
index 000000000000..faf381f3a645
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_flash.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * flash.c
+ *
+ * The routine flash().
+ *
+ */
+
+#include <curses.priv.h>
+#include <term.h> /* beep, flash */
+
+MODULE_ID("$Id: lib_flash.c,v 1.3 1998/06/29 19:34:16 Alexander.V.Lukyanov Exp $")
+
+/*
+ * flash()
+ *
+ * Flash the current terminal's screen if possible. If not,
+ * sound the audible bell if one exists.
+ *
+ */
+
+int flash(void)
+{
+ int res = ERR;
+
+ T((T_CALLED("flash()")));
+
+ /* FIXME: should make sure that we are not in altchar mode */
+ if (flash_screen) {
+ TPUTS_TRACE("flash_screen");
+ res = putp(flash_screen);
+ fflush(SP->_ofp);
+ } else if (bell) {
+ TPUTS_TRACE("bell");
+ res = putp(bell);
+ fflush(SP->_ofp);
+ }
+
+ returnCode(res);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_freeall.c b/contrib/ncurses/ncurses/base/lib_freeall.c
new file mode 100644
index 000000000000..e9a11ac36f26
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_freeall.c
@@ -0,0 +1,134 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <term_entry.h>
+
+#if HAVE_NC_FREEALL
+
+#if HAVE_LIBDBMALLOC
+extern int malloc_errfd; /* FIXME */
+#endif
+
+MODULE_ID("$Id: lib_freeall.c,v 1.14 1999/04/03 23:17:06 tom Exp $")
+
+static void free_slk(SLK *p)
+{
+ if (p != 0) {
+ FreeIfNeeded(p->ent);
+ FreeIfNeeded(p->buffer);
+ free(p);
+ }
+}
+
+static void free_tries(struct tries *p)
+{
+ struct tries *q;
+
+ while (p != 0) {
+ q = p->sibling;
+ if (p->child != 0)
+ free_tries(p->child);
+ free(p);
+ p = q;
+ }
+}
+
+/*
+ * Free all ncurses data. This is used for testing only (there's no practical
+ * use for it as an extension).
+ */
+void _nc_freeall(void)
+{
+ WINDOWLIST *p, *q;
+
+#if NO_LEAKS
+ _nc_free_tparm();
+#endif
+ while (_nc_windows != 0) {
+ /* Delete only windows that're not a parent */
+ for (p = _nc_windows; p != 0; p = p->next) {
+ bool found = FALSE;
+
+ for (q = _nc_windows; q != 0; q = q->next) {
+ if ((p != q)
+ && (q->win->_flags & _SUBWIN)
+ && (p->win == q->win->_parent)) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ delwin(p->win);
+ break;
+ }
+ }
+ }
+
+ if (SP != 0) {
+ free_tries (SP->_keytry);
+ free_tries (SP->_key_ok);
+ free_slk(SP->_slk);
+ FreeIfNeeded(SP->_color_pairs);
+ FreeIfNeeded(SP->_color_table);
+ /* it won't free buffer anyway */
+/* _nc_set_buffer(SP->_ofp, FALSE);*/
+#if !BROKEN_LINKER
+ FreeAndNull(SP);
+#endif
+ }
+
+ if (cur_term != 0) {
+ _nc_free_termtype(&(cur_term->type));
+ free(cur_term);
+ }
+
+#ifdef TRACE
+ (void) _nc_trace_buf(-1, 0);
+#endif
+#if HAVE_LIBDBMALLOC
+ malloc_dump(malloc_errfd);
+#elif HAVE_LIBDMALLOC
+#elif HAVE_PURIFY
+ purify_all_inuse();
+#endif
+}
+
+void _nc_free_and_exit(int code)
+{
+ _nc_freeall();
+ exit(code);
+}
+#else
+void _nc_freeall(void) { }
+#endif
diff --git a/contrib/ncurses/ncurses/base/lib_getch.c b/contrib/ncurses/ncurses/base/lib_getch.c
new file mode 100644
index 000000000000..b740885b8166
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_getch.c
@@ -0,0 +1,414 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_getch.c
+**
+** The routine getch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_getch.c,v 1.43 1999/03/08 02:35:10 tom Exp $")
+
+#include <fifo_defs.h>
+
+int ESCDELAY = 1000; /* max interval betw. chars in funkeys, in millisecs */
+
+#ifdef USE_EMX_MOUSE
+# include <sys/select.h>
+static int
+kbd_mouse_read(unsigned char *p)
+{
+fd_set fdset;
+int nums = SP->_ifd+1;
+
+ for (;;) {
+ FD_ZERO(&fdset);
+ FD_SET(SP->_checkfd, &fdset);
+ if (SP->_mouse_fd >= 0) {
+ FD_SET(SP->_mouse_fd, &fdset);
+ if (SP->_mouse_fd > SP->_checkfd)
+ nums = SP->_mouse_fd+1;
+ }
+ if (select(nums, &fdset, NULL, NULL, NULL) >= 0) {
+ int n;
+
+ if (FD_ISSET(SP->_mouse_fd, &fdset)) /* Prefer mouse */
+ n = read(SP->_mouse_fd, p, 1);
+ else
+ n = read(SP->_ifd, p, 1);
+ return n;
+ }
+ if (errno != EINTR)
+ return -1;
+ }
+}
+#endif /* USE_EMX_MOUSE */
+
+static inline int fifo_peek(void)
+{
+ int ch = SP->_fifo[peek];
+ T(("peeking at %d", peek));
+
+ p_inc();
+ return ch;
+}
+
+
+static inline int fifo_pull(void)
+{
+int ch;
+ ch = SP->_fifo[head];
+ T(("pulling %d from %d", ch, head));
+
+ if (peek == head)
+ {
+ h_inc();
+ peek = head;
+ }
+ else
+ h_inc();
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+#endif
+ return ch;
+}
+
+static inline int fifo_push(void)
+{
+int n;
+unsigned int ch;
+
+ if (tail == -1) return ERR;
+
+#ifdef HIDE_EINTR
+again:
+ errno = 0;
+#endif
+
+#if USE_GPM_SUPPORT
+ if ((SP->_mouse_fd >= 0)
+ && (_nc_timed_wait(3, -1, (int *)0) & 2))
+ {
+ SP->_mouse_event(SP);
+ ch = KEY_MOUSE;
+ n = 1;
+ } else
+#endif
+ {
+ unsigned char c2=0;
+#ifdef USE_EMX_MOUSE
+ n = kbd_mouse_read(&c2);
+#else
+ n = read(SP->_ifd, &c2, 1);
+#endif
+ ch = c2 & 0xff;
+ }
+
+#ifdef HIDE_EINTR
+ /*
+ * Under System V curses with non-restarting signals, getch() returns
+ * with value ERR when a handled signal keeps it from completing.
+ * If signals restart system calls, OTOH, the signal is invisible
+ * except to its handler.
+ *
+ * We don't want this difference to show. This piece of code
+ * tries to make it look like we always have restarting signals.
+ */
+ if (n <= 0 && errno == EINTR)
+ goto again;
+#endif
+
+ if ((n == -1) || (n == 0))
+ {
+ T(("read(%d,&ch,1)=%d, errno=%d", SP->_ifd, n, errno));
+ return ERR;
+ }
+ T(("read %d characters", n));
+
+ SP->_fifo[tail] = ch;
+ SP->_fifohold = 0;
+ if (head == -1)
+ head = peek = tail;
+ t_inc();
+ T(("pushed %#x at %d", ch, tail));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+#endif
+ return ch;
+}
+
+static inline void fifo_clear(void)
+{
+int i;
+ for (i = 0; i < FIFO_SIZE; i++)
+ SP->_fifo[i] = 0;
+ head = -1; tail = peek = 0;
+}
+
+static int kgetch(WINDOW *);
+
+#define wgetch_should_refresh(win) (\
+ (is_wintouched(win) || (win->_flags & _HASMOVED)) \
+ && !(win->_flags & _ISPAD))
+
+int
+wgetch(WINDOW *win)
+{
+int ch;
+
+ T((T_CALLED("wgetch(%p)"), win));
+
+ if (!win)
+ returnCode(ERR);
+
+ if (cooked_key_in_fifo())
+ {
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
+
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
+ returnCode(ch);
+ }
+
+ /*
+ * Handle cooked mode. Grab a string from the screen,
+ * stuff its contents in the FIFO queue, and pop off
+ * the first character to return it.
+ */
+ if (head == -1 && !SP->_raw && !SP->_cbreak)
+ {
+ char buf[MAXCOLUMNS], *sp;
+
+ T(("filling queue in cooked mode"));
+
+ wgetnstr(win, buf, MAXCOLUMNS);
+
+ /* ungetch in reverse order */
+ ungetch('\n');
+ for (sp = buf+strlen(buf); sp>buf; sp--)
+ ungetch(sp[-1]);
+
+ returnCode(fifo_pull());
+ }
+
+ if (wgetch_should_refresh(win))
+ wrefresh(win);
+
+ if (!win->_notimeout && (win->_delay >= 0 || SP->_cbreak > 1))
+ {
+ int delay;
+
+ T(("timed delay in wgetch()"));
+ if (SP->_cbreak > 1)
+ delay = (SP->_cbreak - 1) * 100;
+ else
+ delay = win->_delay;
+
+ T(("delay is %d milliseconds", delay));
+
+ if (head == -1) /* fifo is empty */
+ if (!_nc_timed_wait(3, delay, (int *)0))
+ returnCode(ERR);
+ /* else go on to read data available */
+ }
+
+ if (win->_use_keypad)
+ {
+ /*
+ * This is tricky. We only want to get special-key
+ * events one at a time. But we want to accumulate
+ * mouse events until either (a) the mouse logic tells
+ * us it's picked up a complete gesture, or (b)
+ * there's a detectable time lapse after one.
+ *
+ * Note: if the mouse code starts failing to compose
+ * press/release events into clicks, you should probably
+ * increase the wait with mouseinterval().
+ */
+ int runcount = 0;
+
+ do {
+ ch = kgetch(win);
+ if (ch == KEY_MOUSE)
+ {
+ ++runcount;
+ if (SP->_mouse_inline(SP))
+ break;
+ }
+ } while
+ (ch == KEY_MOUSE
+ && (_nc_timed_wait(3, SP->_maxclick, (int *)0)
+ || !SP->_mouse_parse(runcount)));
+ if (runcount > 0 && ch != KEY_MOUSE)
+ {
+ /* mouse event sequence ended by keystroke, push it */
+ ungetch(ch);
+ ch = KEY_MOUSE;
+ }
+ } else {
+ if (head == -1)
+ fifo_push();
+ ch = fifo_pull();
+ }
+
+ if (ch == ERR)
+ {
+#if USE_SIZECHANGE
+ if(SP->_sig_winch)
+ {
+ _nc_update_screensize();
+ /* resizeterm can push KEY_RESIZE */
+ if(cooked_key_in_fifo())
+ {
+ ch = fifo_pull();
+ T(("wgetch returning (pre-cooked): %#x = %s", ch, _trace_key(ch));)
+ returnCode(ch);
+ }
+ }
+#endif
+ T(("wgetch returning ERR"));
+ returnCode(ERR);
+ }
+
+ /*
+ * Simulate ICRNL mode
+ */
+ if ((ch == '\r') && SP->_nl)
+ ch = '\n';
+
+ /* Strip 8th-bit if so desired. We do this only for characters that
+ * are in the range 128-255, to provide compatibility with terminals
+ * that display only 7-bit characters. Note that 'ch' may be a
+ * function key at this point, so we mustn't strip _those_.
+ */
+ if ((ch < KEY_MIN) && (ch & 0x80))
+ if (!SP->_use_meta)
+ ch &= 0x7f;
+
+ if (SP->_echo && ch < KEY_MIN && !(win->_flags & _ISPAD))
+ wechochar(win, (chtype)ch);
+
+ T(("wgetch returning : %#x = %s", ch, _trace_key(ch)));
+
+ returnCode(ch);
+}
+
+
+/*
+** int
+** kgetch()
+**
+** Get an input character, but take care of keypad sequences, returning
+** an appropriate code when one matches the input. After each character
+** is received, set an alarm call based on ESCDELAY. If no more of the
+** sequence is received by the time the alarm goes off, pass through
+** the sequence gotten so far.
+**
+** This function must be called when there is no cooked keys in queue.
+** (that is head==-1 || peek==head)
+**
+*/
+
+static int
+kgetch(WINDOW *win GCC_UNUSED)
+{
+struct tries *ptr;
+int ch = 0;
+int timeleft = ESCDELAY;
+
+ TR(TRACE_IEVENT, ("kgetch(%p) called", win));
+
+ ptr = SP->_keytry;
+
+ for(;;)
+ {
+ if (!raw_key_in_fifo())
+ {
+ if(fifo_push() == ERR)
+ {
+ peek = head; /* the keys stay uninterpreted */
+ return ERR;
+ }
+ }
+ ch = fifo_peek();
+ if (ch >= KEY_MIN)
+ {
+ peek = head;
+ /* assume the key is the last in fifo */
+ t_dec(); /* remove the key */
+ return ch;
+ }
+
+ TR(TRACE_IEVENT, ("ch: %s", _trace_key((unsigned char)ch)));
+ while ((ptr != NULL) && (ptr->ch != (unsigned char)ch))
+ ptr = ptr->sibling;
+#ifdef TRACE
+ if (ptr == NULL)
+ {TR(TRACE_IEVENT, ("ptr is null"));}
+ else
+ TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
+ ptr, ptr->ch, ptr->value));
+#endif /* TRACE */
+
+ if (ptr == NULL)
+ break;
+
+ if (ptr->value != 0) { /* sequence terminated */
+ TR(TRACE_IEVENT, ("end of sequence"));
+ if (peek == tail)
+ fifo_clear();
+ else
+ head = peek;
+ return(ptr->value);
+ }
+
+ ptr = ptr->child;
+
+ if (!raw_key_in_fifo())
+ {
+ TR(TRACE_IEVENT, ("waiting for rest of sequence"));
+ if (!_nc_timed_wait(3, timeleft, &timeleft)) {
+ TR(TRACE_IEVENT, ("ran out of time"));
+ break;
+ }
+ }
+ }
+ ch = fifo_pull();
+ peek = head;
+ return ch;
+}
diff --git a/contrib/ncurses/ncurses/base/lib_getstr.c b/contrib/ncurses/ncurses/base/lib_getstr.c
new file mode 100644
index 000000000000..485c6e35c8ff
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_getstr.c
@@ -0,0 +1,192 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_getstr.c
+**
+** The routine wgetstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: lib_getstr.c,v 1.20 1998/12/20 00:16:01 tom Exp $")
+
+/*
+ * This wipes out the last character, no matter whether it was a tab, control
+ * or other character, and handles reverse wraparound.
+ */
+static char *WipeOut(WINDOW *win, int y, int x, char *first, char *last, bool echoed)
+{
+ if (last > first) {
+ *--last = '\0';
+ if (echoed) {
+ int y1 = win->_cury;
+ int x1 = win->_curx;
+
+ wmove(win, y, x);
+ waddstr(win, first);
+ getyx(win, y, x);
+ while (win->_cury < y1
+ || (win->_cury == y1 && win->_curx < x1))
+ waddch(win, ' ');
+
+ wmove(win, y, x);
+ }
+ }
+ return last;
+}
+
+int wgetnstr(WINDOW *win, char *str, int maxlen)
+{
+TTY buf;
+bool oldnl, oldecho, oldraw, oldcbreak;
+char erasec;
+char killc;
+char *oldstr;
+int ch;
+int y, x;
+
+ T((T_CALLED("wgetnstr(%p,%p, %d)"), win, str, maxlen));
+
+ if (!win)
+ returnCode(ERR);
+
+ _nc_get_tty_mode(&buf);
+
+ oldnl = SP->_nl;
+ oldecho = SP->_echo;
+ oldraw = SP->_raw;
+ oldcbreak = SP->_cbreak;
+ nl();
+ noecho();
+ noraw();
+ cbreak();
+
+ erasec = erasechar();
+ killc = killchar();
+
+ oldstr = str;
+ getyx(win, y, x);
+
+ if (is_wintouched(win) || (win->_flags & _HASMOVED))
+ wrefresh(win);
+
+ while ((ch = wgetch(win)) != ERR) {
+ /*
+ * Some terminals (the Wyse-50 is the most common) generate
+ * a \n from the down-arrow key. With this logic, it's the
+ * user's choice whether to set kcud=\n for wgetch();
+ * terminating *getstr() with \n should work either way.
+ */
+ if (ch == '\n'
+ || ch == '\r'
+ || ch == KEY_DOWN
+ || ch == KEY_ENTER) {
+ if (oldecho == TRUE
+ && win->_cury == win->_maxy
+ && win->_scroll)
+ wechochar(win, '\n');
+ break;
+ }
+ if (ch == erasec || ch == KEY_LEFT || ch == KEY_BACKSPACE) {
+ if (str > oldstr) {
+ str = WipeOut(win, y, x, oldstr, str, oldecho);
+ }
+ } else if (ch == killc) {
+ while (str > oldstr) {
+ str = WipeOut(win, y, x, oldstr, str, oldecho);
+ }
+ } else if (ch >= KEY_MIN
+ || (maxlen >= 0 && str - oldstr >= maxlen)) {
+ beep();
+ } else {
+ *str++ = ch;
+ if (oldecho == TRUE) {
+ int oldy = win->_cury;
+ if (waddch(win, ch) == ERR) {
+ /*
+ * We can't really use the lower-right
+ * corner for input, since it'll mess
+ * up bookkeeping for erases.
+ */
+ win->_flags &= ~_WRAPPED;
+ waddch(win, ' ');
+ str = WipeOut(win, y, x, oldstr, str, oldecho);
+ continue;
+ } else if (win->_flags & _WRAPPED) {
+ /*
+ * If the last waddch forced a wrap &
+ * scroll, adjust our reference point
+ * for erasures.
+ */
+ if (win->_scroll
+ && oldy == win->_maxy
+ && win->_cury == win->_maxy) {
+ if (--y <= 0) {
+ y = 0;
+ }
+ }
+ win->_flags &= ~_WRAPPED;
+ }
+ wrefresh(win);
+ }
+ }
+ }
+
+ win->_curx = 0;
+ win->_flags &= ~_WRAPPED;
+ if (win->_cury < win->_maxy)
+ win->_cury++;
+ wrefresh(win);
+
+ /* Restore with a single I/O call, to fix minor asymmetry between
+ * raw/noraw, etc.
+ */
+ SP->_nl = oldnl;
+ SP->_echo = oldecho;
+ SP->_raw = oldraw;
+ SP->_cbreak = oldcbreak;
+
+ _nc_set_tty_mode(&buf);
+
+ *str = '\0';
+ if (ch == ERR)
+ returnCode(ERR);
+
+ T(("wgetnstr returns %s", _nc_visbuf(oldstr)));
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_hline.c b/contrib/ncurses/ncurses/base/lib_hline.c
new file mode 100644
index 000000000000..3b0a602eeee9
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_hline.c
@@ -0,0 +1,76 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_hline.c
+**
+** The routine whline().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_hline.c,v 1.4 1998/06/28 00:11:01 tom Exp $")
+
+int whline(WINDOW *win, chtype ch, int n)
+{
+int code = ERR;
+short start;
+short end;
+
+ T((T_CALLED("whline(%p,%s,%d)"), win, _tracechtype(ch), n));
+
+ if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
+
+ start = win->_curx;
+ end = start + n - 1;
+ if (end > win->_maxx)
+ end = win->_maxx;
+
+ CHANGED_RANGE(line, start, end);
+
+ if (ch == 0)
+ ch = ACS_HLINE;
+ ch = _nc_render(win, ch);
+
+ while ( end >= start) {
+ line->text[end] = ch;
+ end--;
+ }
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_immedok.c b/contrib/ncurses/ncurses/base/lib_immedok.c
new file mode 100644
index 000000000000..5590ec9f5406
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_immedok.c
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_immedok.c
+**
+** The routine immedok.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_immedok.c,v 1.2 1998/02/11 12:14:01 tom Exp $")
+
+void immedok(WINDOW *win, bool flag)
+{
+ T((T_CALLED("immedok(%p,%d)"), win, flag));
+
+ if (win)
+ win->_immed = flag;
+
+ returnVoid;
+}
diff --git a/contrib/ncurses/ncurses/base/lib_inchstr.c b/contrib/ncurses/ncurses/base/lib_inchstr.c
new file mode 100644
index 000000000000..4779ae09d75b
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_inchstr.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_inchstr.c
+**
+** The routine winchnstr().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_inchstr.c,v 1.7 1998/02/11 12:13:55 tom Exp $")
+
+int winchnstr(WINDOW *win, chtype *str, int n)
+{
+ int i = 0;
+
+ T((T_CALLED("winchnstr(%p,%p,%d)"), win, str, n));
+
+ if (!str)
+ returnCode(0);
+
+ if (win) {
+ for (; (n < 0 || (i < n)) && (win->_curx + i <= win->_maxx); i++)
+ str[i] = win->_line[win->_cury].text[win->_curx + i];
+ }
+ str[i] = (chtype)0;
+
+ returnCode(i);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_initscr.c b/contrib/ncurses/ncurses/base/lib_initscr.c
new file mode 100644
index 000000000000..9a89a077cd44
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_initscr.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_initscr.c
+**
+** The routines initscr(), and termname().
+**
+*/
+
+#include <curses.priv.h>
+#include <tic.h> /* for MAX_ALIAS */
+
+#if HAVE_SYS_TERMIO_H
+#include <sys/termio.h> /* needed for ISC */
+#endif
+
+MODULE_ID("$Id: lib_initscr.c,v 1.26 1998/12/19 23:10:09 tom Exp $")
+
+WINDOW *initscr(void)
+{
+static bool initialized = FALSE;
+NCURSES_CONST char *name;
+int value;
+
+ T((T_CALLED("initscr()")));
+ /* Portable applications must not call initscr() more than once */
+ if (!initialized) {
+ initialized = TRUE;
+
+ if ((name = getenv("TERM")) == 0
+ || *name == '\0')
+ name = "unknown";
+ if (newterm(name, stdout, stdin) == 0) {
+ fprintf(stderr, "Error opening terminal: %s.\n", name);
+ exit(EXIT_FAILURE);
+ }
+
+ /* allow user to set maximum escape delay from the environment */
+ if ((value = _nc_getenv_num("ESCDELAY")) >= 0) {
+ ESCDELAY = value;
+ }
+
+ /* def_shell_mode - done in newterm/_nc_setupscreen */
+ def_prog_mode();
+ }
+ returnWin(stdscr);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_insch.c b/contrib/ncurses/ncurses/base/lib_insch.c
new file mode 100644
index 000000000000..ccc5ff5d024d
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_insch.c
@@ -0,0 +1,67 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_insch.c
+**
+** The routine winsch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_insch.c,v 1.10 1998/06/28 00:26:52 tom Exp $")
+
+int winsch(WINDOW *win, chtype c)
+{
+int code = ERR;
+
+ T((T_CALLED("winsch(%p, %s)"), win, _tracechtype(c)));
+
+ if (win) {
+ struct ldat *line = &(win->_line[win->_cury]);
+ chtype *end = &(line->text[win->_curx]);
+ chtype *temp1 = &(line->text[win->_maxx]);
+ chtype *temp2 = temp1 - 1;
+
+ CHANGED_TO_EOL(line, win->_curx, win->_maxx);
+ while (temp1 > end)
+ *temp1-- = *temp2--;
+
+ *temp1 = _nc_render(win, c);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_insdel.c b/contrib/ncurses/ncurses/base/lib_insdel.c
new file mode 100644
index 000000000000..48e108de8d9b
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_insdel.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_insdel.c
+**
+** The routine winsdelln(win, n).
+** positive n insert n lines above current line
+** negative n delete n lines starting from current line
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_insdel.c,v 1.8 1998/02/11 12:13:55 tom Exp $")
+
+int
+winsdelln(WINDOW *win, int n)
+{
+int code = ERR;
+
+ T((T_CALLED("winsdel(%p,%d)"), win, n));
+
+ if (win) {
+ if (n != 0) {
+ _nc_scroll_window(win, -n, win->_cury, win->_maxy, _nc_background(win));
+ _nc_synchook(win);
+ }
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_insstr.c b/contrib/ncurses/ncurses/base/lib_insstr.c
new file mode 100644
index 000000000000..cba147318b8e
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_insstr.c
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_insstr.c
+**
+** The routine winsnstr().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_insstr.c,v 1.13 1999/03/14 00:27:21 tom Exp $")
+
+int winsnstr(WINDOW *win, const char *s, int n)
+{
+int code = ERR;
+short oy;
+short ox ;
+const unsigned char *str = (const unsigned char *)s;
+const unsigned char *cp;
+
+ T((T_CALLED("winsnstr(%p,%s,%d)"), win, _nc_visbuf(s), n));
+
+ if (win && str) {
+ oy = win->_cury; ox = win->_curx;
+ for (cp = str; *cp && (n <= 0 || (cp - str) < n); cp++) {
+ if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b')
+ _nc_waddch_nosync(win, (chtype)(*cp));
+ else if (is7bits(*cp) && iscntrl(*cp)) {
+ winsch(win, ' ' + (chtype)(*cp));
+ winsch(win, '^');
+ win->_curx += 2;
+ } else {
+ winsch(win, (chtype)(*cp));
+ win->_curx++;
+ }
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ }
+
+ win->_curx = ox;
+ win->_cury = oy;
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_instr.c b/contrib/ncurses/ncurses/base/lib_instr.c
new file mode 100644
index 000000000000..b3e1d030a4b6
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_instr.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_instr.c
+**
+** The routine winnstr().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_instr.c,v 1.8 1998/02/11 12:13:54 tom Exp $")
+
+int winnstr(WINDOW *win, char *str, int n)
+{
+ int i=0, row, col;
+
+ T((T_CALLED("winnstr(%p,%p,%d)"), win, str, n));
+
+ if (!str)
+ returnCode(0);
+
+ if (win) {
+ getyx(win, row, col);
+
+ if (n < 0)
+ n = win->_maxx - win->_curx + 1;
+
+ for (; i < n;) {
+ str[i++] = TextOf(win->_line[row].text[col]);
+ if (++col > win->_maxx) {
+ col = 0;
+ if (++row > win->_maxy)
+ break;
+ }
+ }
+ }
+ str[i] = '\0'; /* SVr4 does not seem to count the null */
+ returnCode(i);
+}
+
diff --git a/contrib/ncurses/ncurses/base/lib_isendwin.c b/contrib/ncurses/ncurses/base/lib_isendwin.c
new file mode 100644
index 000000000000..60015fca55b9
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_isendwin.c
@@ -0,0 +1,51 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_endwin.c
+**
+** The routine endwin().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_isendwin.c,v 1.4 1998/04/11 22:52:32 tom Exp $")
+
+bool isendwin(void)
+{
+ if (SP == NULL)
+ return FALSE;
+ return SP->_endwin;
+}
diff --git a/contrib/ncurses/ncurses/base/lib_leaveok.c b/contrib/ncurses/ncurses/base/lib_leaveok.c
new file mode 100644
index 000000000000..e83285d714f4
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_leaveok.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_leaveok.c
+**
+** The routine leaveok.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_leaveok.c,v 1.3 1998/03/21 22:54:20 jtc Exp $")
+
+int leaveok(WINDOW *win, bool flag)
+{
+ T((T_CALLED("leaveok(%p,%d)"), win, flag));
+
+ if (win) {
+ win->_leaveok = flag;
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_mouse.c b/contrib/ncurses/ncurses/base/lib_mouse.c
new file mode 100644
index 000000000000..0aefdf3d8219
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_mouse.c
@@ -0,0 +1,964 @@
+/****************************************************************************
+ * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * This module is intended to encapsulate ncurses's interface to pointing
+ * devices.
+ *
+ * The first method used is xterm's internal mouse-tracking facility.
+ * The second is Alessandro Rubini's GPM server.
+ *
+ * Notes for implementors of new mouse-interface methods:
+ *
+ * The code is logically split into a lower level that accepts event reports
+ * in a device-dependent format and an upper level that parses mouse gestures
+ * and filters events. The mediating data structure is a circular queue of
+ * MEVENT structures.
+ *
+ * Functionally, the lower level's job is to pick up primitive events and
+ * put them on the circular queue. This can happen in one of two ways:
+ * either (a) _nc_mouse_event() detects a series of incoming mouse reports
+ * and queues them, or (b) code in lib_getch.c detects the kmous prefix in
+ * the keyboard input stream and calls _nc_mouse_inline to queue up a series
+ * of adjacent mouse reports.
+ *
+ * In either case, _nc_mouse_parse() should be called after the series is
+ * accepted to parse the digested mouse reports (low-level MEVENTs) into
+ * a gesture (a high-level or composite MEVENT).
+ *
+ * Don't be too shy about adding new event types or modifiers, if you can find
+ * room for them in the 32-bit mask. The API is written so that users get
+ * feedback on which theoretical event types they won't see when they call
+ * mousemask. There's one bit per button (the RESERVED_EVENT bit) not being
+ * used yet, and a couple of bits open at the high end.
+ */
+
+#ifdef __EMX__
+# include "io.h"
+# include "fcntl.h"
+# define INCL_DOS
+# define INCL_VIO
+# define INCL_KBD
+# define INCL_MOU
+# define INCL_DOSPROCESS
+# include <os2.h> /* Need to include before the others */
+#endif
+
+#include <curses.priv.h>
+#include <term.h>
+
+#if USE_GPM_SUPPORT
+#ifndef LINT /* don't need this for llib-lncurses */
+#undef buttons /* term.h defines this, and gpm uses it! */
+#include <gpm.h>
+#include <linux/keyboard.h> /* defines KG_* macros */
+#endif
+#endif
+
+MODULE_ID("$Id: lib_mouse.c,v 1.44 1999/07/24 21:10:48 tom Exp $")
+
+#define MY_TRACE TRACE_ICALLS|TRACE_IEVENT
+
+#define INVALID_EVENT -1
+
+static int mousetype;
+#define M_XTERM -1 /* use xterm's mouse tracking? */
+#define M_NONE 0 /* no mouse device */
+#define M_GPM 1 /* use GPM */
+#define M_QNX 2 /* QNX mouse on console */
+#define M_QNX_TERM 3 /* QNX mouse on pterm/xterm (using qansi-m) */
+
+#if USE_GPM_SUPPORT
+#ifndef LINT
+static Gpm_Connect gpm_connect;
+#endif
+#endif
+
+static mmask_t eventmask; /* current event mask */
+
+static bool _nc_mouse_parse(int);
+static void _nc_mouse_resume(SCREEN *);
+static void _nc_mouse_wrap(SCREEN *);
+
+/* maintain a circular list of mouse events */
+
+/* The definition of the circular list size (EV_MAX), is in curses.priv.h, so
+ * wgetch() may refer to the size and call _nc_mouse_parse() before circular
+ * list overflow.
+ */
+static MEVENT events[EV_MAX]; /* hold the last mouse event seen */
+static MEVENT *eventp = events; /* next free slot in event queue */
+#define NEXT(ep) ((ep == events + EV_MAX - 1) ? events : ep + 1)
+#define PREV(ep) ((ep == events) ? events + EV_MAX - 1 : ep - 1)
+
+#ifdef TRACE
+static void _trace_slot(const char *tag)
+{
+ MEVENT *ep;
+
+ _tracef(tag);
+
+ for (ep = events; ep < events + EV_MAX; ep++)
+ _tracef("mouse event queue slot %ld = %s",
+ (long) (ep - events),
+ _tracemouse(ep));
+}
+#endif
+
+#ifdef USE_EMX_MOUSE
+
+# define TOP_ROW 0
+# define LEFT_COL 0
+
+static int mouse_wfd;
+static int mouse_thread;
+static int mouse_activated;
+static char mouse_buttons[] = { 0, 1, 3, 2};
+
+
+# define M_FD(sp) sp->_mouse_fd
+
+static void
+write_event(int down, int button, int x, int y)
+{
+ char buf[6];
+ unsigned long ignore;
+
+ strcpy(buf, key_mouse);
+ buf[3] = ' ' + (button - 1) + (down ? 0 : 0x40);
+ buf[4] = ' ' + x - LEFT_COL + 1;
+ buf[5] = ' ' + y - TOP_ROW + 1;
+ DosWrite(mouse_wfd, buf, 6, &ignore);
+}
+
+static void
+mouse_server(unsigned long ignored GCC_UNUSED)
+{
+ unsigned short fWait = MOU_WAIT;
+ /* NOPTRRECT mourt = { 0,0,24,79 }; */
+ MOUEVENTINFO mouev;
+ HMOU hmou;
+ unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;
+ int oldstate = 0;
+ char errmess[] = "Unexpected termination of mouse thread\r\n";
+ unsigned long ignore;
+
+ /* open the handle for the mouse */
+ if (MouOpen(NULL,&hmou) == 0) {
+
+ if (MouSetEventMask(&mask,hmou) == 0
+ && MouDrawPtr(hmou) == 0) {
+
+ for (;;) {
+ /* sit and wait on the event queue */
+ if (MouReadEventQue(&mouev,&fWait,hmou))
+ break;
+ if (!mouse_activated)
+ goto finish;
+
+ /*
+ * OS/2 numbers a 3-button mouse inconsistently from other
+ * platforms:
+ * 1 = left
+ * 2 = right
+ * 3 = middle.
+ */
+ if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
+ write_event(mouev.fs & MOUSE_BN1_DOWN,
+ mouse_buttons[1], mouev.col, mouev.row);
+ if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
+ write_event(mouev.fs & MOUSE_BN2_DOWN,
+ mouse_buttons[3], mouev.col, mouev.row);
+ if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
+ write_event(mouev.fs & MOUSE_BN3_DOWN,
+ mouse_buttons[2], mouev.col, mouev.row);
+
+ finish:
+ oldstate = mouev.fs;
+ }
+ }
+
+ DosWrite(2, errmess, strlen(errmess), &ignore);
+ MouClose(hmou);
+ }
+ DosExit(EXIT_THREAD, 0L );
+}
+static void
+server_state(const int state)
+{ /* It would be nice to implement pointer-off and stop looping... */
+ mouse_activated = state;
+}
+
+#endif
+
+static int initialized;
+
+static void _nc_mouse_init(void)
+/* initialize the mouse */
+{
+ int i;
+
+ if (initialized) {
+ return;
+ }
+ initialized = TRUE;
+
+ TR(MY_TRACE, ("_nc_mouse_init() called"));
+
+ for (i = 0; i < EV_MAX; i++)
+ events[i].id = INVALID_EVENT;
+
+ /* we know how to recognize mouse events under xterm */
+ if (key_mouse != 0
+ && getenv("DISPLAY") != 0)
+ mousetype = M_XTERM;
+
+#if USE_GPM_SUPPORT
+ else if (!strncmp(cur_term->type.term_names, "linux", 5))
+ {
+ /* GPM: initialize connection to gpm server */
+ gpm_connect.eventMask = GPM_DOWN|GPM_UP;
+ gpm_connect.defaultMask = ~(gpm_connect.eventMask|GPM_HARD);
+ gpm_connect.minMod = 0;
+ gpm_connect.maxMod = ~((1<<KG_SHIFT)|(1<<KG_SHIFTL)|(1<<KG_SHIFTR));
+ if (Gpm_Open (&gpm_connect, 0) >= 0) { /* returns the file-descriptor */
+ mousetype = M_GPM;
+ SP->_mouse_fd = gpm_fd;
+ }
+ }
+#endif
+
+ /* OS/2 VIO */
+#ifdef USE_EMX_MOUSE
+ if (!mouse_thread && mousetype != M_XTERM && key_mouse) {
+ int handles[2];
+ if (pipe(handles) < 0) {
+ perror("mouse pipe error");
+ } else {
+ int rc;
+
+ if (!mouse_buttons[0]) {
+ char *s = getenv("MOUSE_BUTTONS_123");
+
+ mouse_buttons[0] = 1;
+ if (s && strlen(s) >= 3) {
+ mouse_buttons[1] = s[0] - '0';
+ mouse_buttons[2] = s[1] - '0';
+ mouse_buttons[3] = s[2] - '0';
+ }
+ }
+ mouse_wfd = handles[1];
+ M_FD(SP) = handles[0];
+ /* Needed? */
+ setmode(handles[0], O_BINARY);
+ setmode(handles[1], O_BINARY);
+ /* Do not use CRT functions, we may single-threaded. */
+ rc = DosCreateThread((unsigned long*)&mouse_thread, mouse_server, 0, 0, 8192);
+ if (rc)
+ printf("mouse thread error %d=%#x", rc, rc);
+ else
+ mousetype = M_XTERM;
+ }
+ }
+#endif
+
+ T(("_nc_mouse_init() set mousetype to %d", mousetype));
+}
+
+static bool _nc_mouse_event(SCREEN *sp GCC_UNUSED)
+/* query to see if there is a pending mouse event */
+{
+#if USE_GPM_SUPPORT
+ /* GPM: query server for event, return TRUE if we find one */
+ Gpm_Event ev;
+
+ if (gpm_fd >= 0
+ && _nc_timed_wait(2, 0, (int *)0)
+ && Gpm_GetEvent(&ev) == 1)
+ {
+ eventp->id = 0; /* there's only one mouse... */
+
+ eventp->bstate = 0;
+ switch (ev.type & 0x0f)
+ {
+ case(GPM_DOWN):
+ if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_PRESSED;
+ if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_PRESSED;
+ if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_PRESSED;
+ break;
+ case(GPM_UP):
+ if (ev.buttons & GPM_B_LEFT) eventp->bstate |= BUTTON1_RELEASED;
+ if (ev.buttons & GPM_B_MIDDLE) eventp->bstate |= BUTTON2_RELEASED;
+ if (ev.buttons & GPM_B_RIGHT) eventp->bstate |= BUTTON3_RELEASED;
+ break;
+ default:
+ break;
+ }
+
+ eventp->x = ev.x - 1;
+ eventp->y = ev.y - 1;
+ eventp->z = 0;
+
+ /* bump the next-free pointer into the circular list */
+ eventp = NEXT(eventp);
+ return (TRUE);
+ }
+#endif
+
+ /* xterm: never have to query, mouse events are in the keyboard stream */
+ return(FALSE); /* no event waiting */
+}
+
+static bool _nc_mouse_inline(SCREEN *sp)
+/* mouse report received in the keyboard stream -- parse its info */
+{
+ TR(MY_TRACE, ("_nc_mouse_inline() called"));
+
+ if (mousetype == M_XTERM)
+ {
+ unsigned char kbuf[4];
+ MEVENT *prev;
+ size_t grabbed;
+ int res;
+
+ /* This code requires that your xterm entry contain the kmous
+ * capability and that it be set to the \E[M documented in the
+ * Xterm Control Sequences reference. This is how we
+ * arrange for mouse events to be reported via a KEY_MOUSE
+ * return value from wgetch(). After this value is received,
+ * _nc_mouse_inline() gets called and is immediately
+ * responsible for parsing the mouse status information
+ * following the prefix.
+ *
+ * The following quotes from the ctrlseqs.ms document in the
+ * X distribution, describing the X mouse tracking feature:
+ *
+ * Parameters for all mouse tracking escape sequences
+ * generated by xterm encode numeric parameters in a single
+ * character as value+040. For example, ! is 1.
+ *
+ * On button press or release, xterm sends ESC [ M CbCxCy.
+ * The low two bits of Cb encode button information: 0=MB1
+ * pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The
+ * upper bits encode what modifiers were down when the
+ * button was pressed and are added together. 4=Shift,
+ * 8=Meta, 16=Control. Cx and Cy are the x and y coordinates
+ * of the mouse event. The upper left corner is (1,1).
+ *
+ * (End quote) By the time we get here, we've eaten the
+ * key prefix. FYI, the loop below is necessary because
+ * mouse click info isn't guaranteed to present as a
+ * single clist item. It always does under Linux but often
+ * fails to under Solaris.
+ */
+ for (grabbed = 0; grabbed < 3; grabbed += res)
+ {
+
+ /* For VIO mouse we add extra bit 64 to disambiguate button-up. */
+#ifdef USE_EMX_MOUSE
+ res = read( M_FD(sp) >= 0 ? M_FD(sp) : sp->_ifd, &kbuf, 3);
+#else
+ res = read(sp->_ifd, kbuf + grabbed, 3-grabbed);
+#endif
+ if (res == -1)
+ break;
+ }
+ kbuf[3] = '\0';
+
+ TR(TRACE_IEVENT, ("_nc_mouse_inline sees the following xterm data: '%s'", kbuf));
+
+ eventp->id = 0; /* there's only one mouse... */
+
+ /* processing code goes here */
+ eventp->bstate = 0;
+ switch (kbuf[0] & 0x3)
+ {
+ case 0x0:
+ eventp->bstate = BUTTON1_PRESSED;
+#ifdef USE_EMX_MOUSE
+ if (kbuf[0] & 0x40)
+ eventp->bstate = BUTTON1_RELEASED;
+#endif
+ break;
+
+ case 0x1:
+ eventp->bstate = BUTTON2_PRESSED;
+#ifdef USE_EMX_MOUSE
+ if (kbuf[0] & 0x40)
+ eventp->bstate = BUTTON2_RELEASED;
+#endif
+ break;
+
+ case 0x2:
+ eventp->bstate = BUTTON3_PRESSED;
+#ifdef USE_EMX_MOUSE
+ if (kbuf[0] & 0x40)
+ eventp->bstate = BUTTON3_RELEASED;
+#endif
+ break;
+
+ case 0x3:
+ /*
+ * Release events aren't reported for individual buttons,
+ * just for the button set as a whole...
+ */
+ eventp->bstate =
+ (BUTTON1_RELEASED |
+ BUTTON2_RELEASED |
+ BUTTON3_RELEASED);
+ /*
+ * ...however, because there are no kinds of mouse events under
+ * xterm that can intervene between press and release, we can
+ * deduce which buttons were actually released by looking at the
+ * previous event.
+ */
+ prev = PREV(eventp);
+ if (!(prev->bstate & BUTTON1_PRESSED))
+ eventp->bstate &=~ BUTTON1_RELEASED;
+ if (!(prev->bstate & BUTTON2_PRESSED))
+ eventp->bstate &=~ BUTTON2_RELEASED;
+ if (!(prev->bstate & BUTTON3_PRESSED))
+ eventp->bstate &=~ BUTTON3_RELEASED;
+ break;
+ }
+
+ if (kbuf[0] & 4) {
+ eventp->bstate |= BUTTON_SHIFT;
+ }
+ if (kbuf[0] & 8) {
+ eventp->bstate |= BUTTON_ALT;
+ }
+ if (kbuf[0] & 16) {
+ eventp->bstate |= BUTTON_CTRL;
+ }
+
+ eventp->x = (kbuf[1] - ' ') - 1;
+ eventp->y = (kbuf[2] - ' ') - 1;
+ TR(MY_TRACE, ("_nc_mouse_inline: primitive mouse-event %s has slot %ld",
+ _tracemouse(eventp),
+ (long) (eventp - events)));
+
+ /* bump the next-free pointer into the circular list */
+ eventp = NEXT(eventp);
+#if 0 /* this return would be needed for QNX's mods to lib_getch.c */
+ return(TRUE);
+#endif
+ }
+
+ return(FALSE);
+}
+
+static void mouse_activate(bool on)
+{
+ if (!on && !initialized)
+ return;
+
+ _nc_mouse_init();
+
+ if (on) {
+
+ switch (mousetype) {
+ case M_XTERM:
+#ifdef NCURSES_EXT_FUNCS
+ keyok(KEY_MOUSE, on);
+#endif
+ TPUTS_TRACE("xterm mouse initialization");
+#ifdef USE_EMX_MOUSE
+ server_state(1);
+#else
+ putp("\033[?1000h");
+#endif
+ break;
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ SP->_mouse_fd = gpm_fd;
+ break;
+#endif
+ }
+ /* Make runtime binding to cut down on object size of applications that
+ * do not use the mouse (e.g., 'clear').
+ */
+ SP->_mouse_event = _nc_mouse_event;
+ SP->_mouse_inline = _nc_mouse_inline;
+ SP->_mouse_parse = _nc_mouse_parse;
+ SP->_mouse_resume = _nc_mouse_resume;
+ SP->_mouse_wrap = _nc_mouse_wrap;
+
+ } else {
+
+ switch (mousetype) {
+ case M_XTERM:
+ TPUTS_TRACE("xterm mouse deinitialization");
+#ifdef USE_EMX_MOUSE
+ server_state(0);
+#else
+ putp("\033[?1000l");
+#endif
+ break;
+#if USE_GPM_SUPPORT
+ case M_GPM:
+ break;
+#endif
+ }
+ }
+ (void) fflush(SP->_ofp);
+}
+
+/**************************************************************************
+ *
+ * Device-independent code
+ *
+ **************************************************************************/
+
+static bool _nc_mouse_parse(int runcount)
+/* parse a run of atomic mouse events into a gesture */
+{
+ MEVENT *ep, *runp, *next, *prev = PREV(eventp);
+ int n;
+ bool merge;
+
+ TR(MY_TRACE, ("_nc_mouse_parse(%d) called", runcount));
+
+ /*
+ * When we enter this routine, the event list next-free pointer
+ * points just past a run of mouse events that we know were separated
+ * in time by less than the critical click interval. The job of this
+ * routine is to collaps this run into a single higher-level event
+ * or gesture.
+ *
+ * We accomplish this in two passes. The first pass merges press/release
+ * pairs into click events. The second merges runs of click events into
+ * double or triple-click events.
+ *
+ * It's possible that the run may not resolve to a single event (for
+ * example, if the user quadruple-clicks). If so, leading events
+ * in the run are ignored.
+ *
+ * Note that this routine is independent of the format of the specific
+ * format of the pointing-device's reports. We can use it to parse
+ * gestures on anything that reports press/release events on a per-
+ * button basis, as long as the device-dependent mouse code puts stuff
+ * on the queue in MEVENT format.
+ */
+ if (runcount == 1)
+ {
+ TR(MY_TRACE, ("_nc_mouse_parse: returning simple mouse event %s at slot %ld",
+ _tracemouse(prev),
+ (long) (prev - events)));
+ return (prev->id >= 0)
+ ? ((prev->bstate & eventmask) ? TRUE : FALSE)
+ : FALSE;
+ }
+
+ /* find the start of the run */
+ runp = eventp;
+ for (n = runcount; n > 0; n--) {
+ runp = PREV(runp);
+ }
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT)
+ {
+ _trace_slot("before mouse press/release merge:");
+ _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ runcount);
+ }
+#endif /* TRACE */
+
+ /* first pass; merge press/release pairs */
+ do {
+ merge = FALSE;
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
+ {
+ if (ep->x == next->x && ep->y == next->y
+ && (ep->bstate & (BUTTON1_PRESSED|BUTTON2_PRESSED|BUTTON3_PRESSED))
+ && (!(ep->bstate & BUTTON1_PRESSED)
+ == !(next->bstate & BUTTON1_RELEASED))
+ && (!(ep->bstate & BUTTON2_PRESSED)
+ == !(next->bstate & BUTTON2_RELEASED))
+ && (!(ep->bstate & BUTTON3_PRESSED)
+ == !(next->bstate & BUTTON3_RELEASED))
+ )
+ {
+ if ((eventmask & BUTTON1_CLICKED)
+ && (ep->bstate & BUTTON1_PRESSED))
+ {
+ ep->bstate &=~ BUTTON1_PRESSED;
+ ep->bstate |= BUTTON1_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_CLICKED)
+ && (ep->bstate & BUTTON2_PRESSED))
+ {
+ ep->bstate &=~ BUTTON2_PRESSED;
+ ep->bstate |= BUTTON2_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_CLICKED)
+ && (ep->bstate & BUTTON3_PRESSED))
+ {
+ ep->bstate &=~ BUTTON3_PRESSED;
+ ep->bstate |= BUTTON3_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ next->id = INVALID_EVENT;
+ }
+ }
+ } while
+ (merge);
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT)
+ {
+ _trace_slot("before mouse click merge:");
+ _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ runcount);
+ }
+#endif /* TRACE */
+
+ /*
+ * Second pass; merge click runs. At this point, click events are
+ * each followed by one invalid event. We merge click events
+ * forward in the queue.
+ *
+ * NOTE: There is a problem with this design! If the application
+ * allows enough click events to pile up in the circular queue so
+ * they wrap around, it will cheerfully merge the newest forward
+ * into the oldest, creating a bogus doubleclick and confusing
+ * the queue-traversal logic rather badly. Generally this won't
+ * happen, because calling getmouse() marks old events invalid and
+ * ineligible for merges. The true solution to this problem would
+ * be to timestamp each MEVENT and perform the obvious sanity check,
+ * but the timer element would have to have sub-second resolution,
+ * which would get us into portability trouble.
+ */
+ do {
+ MEVENT *follower;
+
+ merge = FALSE;
+ for (ep = runp; next = NEXT(ep), next != eventp; ep = next)
+ if (ep->id != INVALID_EVENT)
+ {
+ if (next->id != INVALID_EVENT)
+ continue;
+ follower = NEXT(next);
+ if (follower->id == INVALID_EVENT)
+ continue;
+
+ /* merge click events forward */
+ if ((ep->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED))
+ && (follower->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
+ {
+ if ((eventmask & BUTTON1_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON1_CLICKED))
+ {
+ follower->bstate &=~ BUTTON1_CLICKED;
+ follower->bstate |= BUTTON1_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON2_CLICKED))
+ {
+ follower->bstate &=~ BUTTON2_CLICKED;
+ follower->bstate |= BUTTON2_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_DOUBLE_CLICKED)
+ && (follower->bstate & BUTTON3_CLICKED))
+ {
+ follower->bstate &=~ BUTTON3_CLICKED;
+ follower->bstate |= BUTTON3_DOUBLE_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ ep->id = INVALID_EVENT;
+ }
+
+ /* merge double-click events forward */
+ if ((ep->bstate &
+ (BUTTON1_DOUBLE_CLICKED
+ | BUTTON2_DOUBLE_CLICKED
+ | BUTTON3_DOUBLE_CLICKED))
+ && (follower->bstate &
+ (BUTTON1_CLICKED | BUTTON2_CLICKED | BUTTON3_CLICKED)))
+ {
+ if ((eventmask & BUTTON1_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON1_CLICKED))
+ {
+ follower->bstate &=~ BUTTON1_CLICKED;
+ follower->bstate |= BUTTON1_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON2_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON2_CLICKED))
+ {
+ follower->bstate &=~ BUTTON2_CLICKED;
+ follower->bstate |= BUTTON2_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if ((eventmask & BUTTON3_TRIPLE_CLICKED)
+ && (follower->bstate & BUTTON3_CLICKED))
+ {
+ follower->bstate &=~ BUTTON3_CLICKED;
+ follower->bstate |= BUTTON3_TRIPLE_CLICKED;
+ merge = TRUE;
+ }
+ if (merge)
+ ep->id = INVALID_EVENT;
+ }
+ }
+ } while
+ (merge);
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT)
+ {
+ _trace_slot("before mouse event queue compaction:");
+ _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ runcount);
+ }
+#endif /* TRACE */
+
+ /*
+ * Now try to throw away trailing events flagged invalid, or that
+ * don't match the current event mask.
+ */
+ for (; runcount; prev = PREV(eventp), runcount--)
+ if (prev->id == INVALID_EVENT || !(prev->bstate & eventmask)) {
+ eventp = prev;
+ }
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT)
+ {
+ _trace_slot("after mouse event queue compaction:");
+ _tracef("_nc_mouse_parse: run starts at %ld, ends at %ld, count %d",
+ (long) (runp - events),
+ (long) ((eventp - events) + (EV_MAX-1)) % EV_MAX,
+ runcount);
+ }
+ for (ep = runp; ep != eventp; ep = NEXT(ep))
+ if (ep->id != INVALID_EVENT)
+ TR(MY_TRACE, ("_nc_mouse_parse: returning composite mouse event %s at slot %ld",
+ _tracemouse(ep),
+ (long) (ep - events)));
+#endif /* TRACE */
+
+ /* after all this, do we have a valid event? */
+ return(PREV(eventp)->id != INVALID_EVENT);
+}
+
+static void _nc_mouse_wrap(SCREEN *sp GCC_UNUSED)
+/* release mouse -- called by endwin() before shellout/exit */
+{
+ TR(MY_TRACE, ("_nc_mouse_wrap() called"));
+
+ switch (mousetype) {
+ case M_XTERM:
+ if (eventmask)
+ mouse_activate(FALSE);
+ break;
+#if USE_GPM_SUPPORT
+ /* GPM: pass all mouse events to next client */
+ case M_GPM:
+ break;
+#endif
+ }
+}
+
+static void _nc_mouse_resume(SCREEN *sp GCC_UNUSED)
+/* re-connect to mouse -- called by doupdate() after shellout */
+{
+ TR(MY_TRACE, ("_nc_mouse_resume() called"));
+
+ /* xterm: re-enable reporting */
+ if (mousetype == M_XTERM && eventmask)
+ mouse_activate(TRUE);
+
+ /* GPM: reclaim our event set */
+}
+
+/**************************************************************************
+ *
+ * Mouse interface entry points for the API
+ *
+ **************************************************************************/
+
+int getmouse(MEVENT *aevent)
+/* grab a copy of the current mouse event */
+{
+ T((T_CALLED("getmouse(%p)"), aevent));
+
+ if (aevent && (mousetype != M_NONE))
+ {
+ /* compute the current-event pointer */
+ MEVENT *prev = PREV(eventp);
+
+ /* copy the event we find there */
+ *aevent = *prev;
+
+ TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
+ _tracemouse(prev),
+ (long) (prev - events)));
+
+ prev->id = INVALID_EVENT; /* so the queue slot becomes free */
+ returnCode(OK);
+ }
+ returnCode(ERR);
+}
+
+int ungetmouse(MEVENT *aevent)
+/* enqueue a synthesized mouse event to be seen by the next wgetch() */
+{
+ /* stick the given event in the next-free slot */
+ *eventp = *aevent;
+
+ /* bump the next-free pointer into the circular list */
+ eventp = NEXT(eventp);
+
+ /* push back the notification event on the keyboard queue */
+ return ungetch(KEY_MOUSE);
+}
+
+mmask_t mousemask(mmask_t newmask, mmask_t *oldmask)
+/* set the mouse event mask */
+{
+ mmask_t result = 0;
+
+ T((T_CALLED("mousemask(%#lx,%p)"), newmask, oldmask));
+
+ if (oldmask)
+ *oldmask = eventmask;
+
+ if (!newmask && !initialized)
+ returnCode(0);
+
+ _nc_mouse_init();
+ if ( mousetype != M_NONE )
+ {
+ eventmask = newmask &
+ (BUTTON_ALT | BUTTON_CTRL | BUTTON_SHIFT
+ | BUTTON1_PRESSED | BUTTON1_RELEASED | BUTTON1_CLICKED
+ | BUTTON1_DOUBLE_CLICKED | BUTTON1_TRIPLE_CLICKED
+ | BUTTON2_PRESSED | BUTTON2_RELEASED | BUTTON2_CLICKED
+ | BUTTON2_DOUBLE_CLICKED | BUTTON2_TRIPLE_CLICKED
+ | BUTTON3_PRESSED | BUTTON3_RELEASED | BUTTON3_CLICKED
+ | BUTTON3_DOUBLE_CLICKED | BUTTON3_TRIPLE_CLICKED);
+
+ mouse_activate(eventmask != 0);
+
+ result = eventmask;
+ }
+
+ returnCode(result);
+}
+
+bool wenclose(const WINDOW *win, int y, int x)
+/* check to see if given window encloses given screen location */
+{
+ if (win)
+ {
+ y -= win->_yoffset;
+ return ((win->_begy <= y &&
+ win->_begx <= x &&
+ (win->_begx + win->_maxx) >= x &&
+ (win->_begy + win->_maxy) >= y) ? TRUE : FALSE);
+ }
+ return FALSE;
+}
+
+int mouseinterval(int maxclick)
+/* set the maximum mouse interval within which to recognize a click */
+{
+ int oldval;
+
+ if (SP != 0) {
+ oldval = SP->_maxclick;
+ if (maxclick >= 0)
+ SP->_maxclick = maxclick;
+ } else {
+ oldval = DEFAULT_MAXCLICK;
+ }
+
+ return(oldval);
+}
+
+/* This may be used by other routines to ask for the existence of mouse
+ support */
+int _nc_has_mouse(void) {
+ return (mousetype==M_NONE ? 0:1);
+}
+
+bool wmouse_trafo(const WINDOW* win, int* pY, int* pX, bool to_screen)
+{
+ bool result = FALSE;
+
+ if (win && pY && pX)
+ {
+ int y = *pY; int x = *pX;
+
+ if (to_screen)
+ {
+ y += win->_begy + win->_yoffset;
+ x += win->_begx;
+ if (wenclose(win,y,x))
+ result = TRUE;
+ }
+ else
+ {
+ if (wenclose(win,y,x))
+ {
+ y -= (win->_begy + win->_yoffset);
+ x -= win->_begx;
+ result = TRUE;
+ }
+ }
+ if (result)
+ {
+ *pX = x;
+ *pY = y;
+ }
+ }
+ return(result);
+}
+
+/* lib_mouse.c ends here */
diff --git a/contrib/ncurses/ncurses/base/lib_move.c b/contrib/ncurses/ncurses/base/lib_move.c
new file mode 100644
index 000000000000..6f5bddff33ea
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_move.c
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_move.c
+**
+** The routine wmove().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_move.c,v 1.8 1998/02/11 12:13:53 tom Exp $")
+
+int
+wmove(WINDOW *win, int y, int x)
+{
+ T((T_CALLED("wmove(%p,%d,%d)"), win, y, x));
+
+ if (win &&
+ x >= 0 && x <= win->_maxx &&
+ y >= 0 && y <= win->_maxy)
+ {
+ win->_curx = (short)x;
+ win->_cury = (short)y;
+
+ win->_flags &= ~_WRAPPED;
+ win->_flags |= _HASMOVED;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_mvwin.c b/contrib/ncurses/ncurses/base/lib_mvwin.c
new file mode 100644
index 000000000000..9774d9f58dfe
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_mvwin.c
@@ -0,0 +1,109 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_mvwin.c
+**
+** The routine mvwin().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_mvwin.c,v 1.7 1998/02/11 12:13:55 tom Exp $")
+
+int mvwin(WINDOW *win, int by, int bx)
+{
+ T((T_CALLED("mvwin(%p,%d,%d)"), win, by, bx));
+
+ if (!win || (win->_flags & _ISPAD))
+ returnCode(ERR);
+
+ /* Copying subwindows is allowed, but it is expensive... */
+ if (win->_flags & _SUBWIN) {
+ int err = ERR;
+ WINDOW *parent = win->_parent;
+ if (parent)
+ { /* Now comes the complicated and costly part, you should really
+ * try to avoid to move subwindows. Because a subwindow shares
+ * the text buffers with its parent, one can't do a simple
+ * memmove of the text buffers. One has to create a copy, then
+ * to relocate the subwindow and then to do a copy.
+ */
+ if ((by - parent->_begy == win->_pary) &&
+ (bx - parent->_begx == win->_parx))
+ err=OK; /* we don't actually move */
+ else {
+ WINDOW* clone = dupwin(win);
+ if (clone) {
+ /* now we have the clone, so relocate win */
+
+ werase(win); /* Erase the original place */
+ wbkgd(win,parent->_bkgd);/* fill with parents background */
+ wsyncup(win); /* Tell the parent(s) */
+
+ err = mvderwin(win,
+ by - parent->_begy,
+ bx - parent->_begx);
+ if (err!=ERR) {
+ err = copywin(clone,win,
+ 0, 0, 0, 0, win->_maxy, win->_maxx, 0);
+ if (ERR!=err)
+ wsyncup(win);
+ }
+ if (ERR==delwin(clone))
+ err=ERR;
+ }
+ }
+ }
+ returnCode(err);
+ }
+
+ if (by + win->_maxy > screen_lines - 1
+ || bx + win->_maxx > screen_columns - 1
+ || by < 0
+ || bx < 0)
+ returnCode(ERR);
+
+ /*
+ * Whether or not the window is moved, touch the window's contents so
+ * that a following call to 'wrefresh()' will paint the window at the
+ * new location. This ensures that if the caller has refreshed another
+ * window at the same location, that this one will be displayed.
+ */
+ win->_begy = by;
+ win->_begx = bx;
+ returnCode(touchwin(win));
+}
diff --git a/contrib/ncurses/ncurses/base/lib_newterm.c b/contrib/ncurses/ncurses/base/lib_newterm.c
new file mode 100644
index 000000000000..9a4919bf5292
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_newterm.c
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_newterm.c
+**
+** The newterm() function.
+**
+*/
+
+#include <curses.priv.h>
+
+#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#define _POSIX_SOURCE
+#endif
+
+#include <term.h> /* clear_screen, cup & friends, cur_term */
+
+MODULE_ID("$Id: lib_newterm.c,v 1.41 1999/07/24 20:07:48 tom Exp $")
+
+#ifndef ONLCR /* Allows compilation under the QNX 4.2 OS */
+#define ONLCR 0
+#endif
+
+/*
+ * SVr4/XSI Curses specify that hardware echo is turned off in initscr, and not
+ * restored during the curses session. The library simulates echo in software.
+ * (The behavior is unspecified if the application enables hardware echo).
+ *
+ * The newterm function also initializes terminal settings, and since initscr
+ * is supposed to behave as if it calls newterm, we do it here.
+ */
+static inline int _nc_initscr(void)
+{
+ /* for extended XPG4 conformance requires cbreak() at this point */
+ /* (SVr4 curses does this anyway) */
+ cbreak();
+
+#ifdef TERMIOS
+ cur_term->Nttyb.c_lflag &= ~(ECHO|ECHONL);
+ cur_term->Nttyb.c_iflag &= ~(ICRNL|INLCR|IGNCR);
+ cur_term->Nttyb.c_oflag &= ~(ONLCR);
+#else
+ cur_term->Nttyb.sg_flags &= ~(ECHO|CRMOD);
+#endif
+ return _nc_set_tty_mode(&cur_term->Nttyb);
+}
+
+/*
+ * filter() has to be called before either initscr() or newterm(), so there is
+ * apparently no way to make this flag apply to some terminals and not others,
+ * aside from possibly delaying a filter() call until some terminals have been
+ * initialized.
+ */
+static int filter_mode = FALSE;
+
+void filter(void)
+{
+ filter_mode = TRUE;
+}
+
+SCREEN * newterm(NCURSES_CONST char *name, FILE *ofp, FILE *ifp)
+{
+int errret;
+int slk_format = _nc_slk_format;
+SCREEN* current;
+#ifdef TRACE
+int t = _nc_getenv_num("NCURSES_TRACE");
+
+ if (t >= 0)
+ trace(t);
+#endif
+
+ T((T_CALLED("newterm(\"%s\",%p,%p)"), name, ofp, ifp));
+
+ /* this loads the capability entry, then sets LINES and COLS */
+ if (setupterm(name, fileno(ofp), &errret) == ERR)
+ return 0;
+
+ /* implement filter mode */
+ if (filter_mode) {
+ LINES = 1;
+
+ if (init_tabs != -1)
+ TABSIZE = init_tabs;
+ else
+ TABSIZE = 8;
+
+ T(("TABSIZE = %d", TABSIZE));
+
+ clear_screen = 0;
+ cursor_down = parm_down_cursor = 0;
+ cursor_address = 0;
+ cursor_up = parm_up_cursor = 0;
+ row_address = 0;
+
+ cursor_home = carriage_return;
+ }
+
+ /* If we must simulate soft labels, grab off the line to be used.
+ We assume that we must simulate, if it is none of the standard
+ formats (4-4 or 3-2-3) for which there may be some hardware
+ support. */
+ if (num_labels <= 0 || !SLK_STDFMT(slk_format))
+ if (slk_format)
+ {
+ if (ERR==_nc_ripoffline(-SLK_LINES(slk_format),
+ _nc_slk_initialize))
+ return 0;
+ }
+ /* this actually allocates the screen structure, and saves the
+ * original terminal settings.
+ */
+ current = SP;
+ _nc_set_screen(0);
+ if (_nc_setupscreen(LINES, COLS, ofp) == ERR) {
+ _nc_set_screen(current);
+ return 0;
+ }
+
+ /* if the terminal type has real soft labels, set those up */
+ if (slk_format && num_labels > 0 && SLK_STDFMT(slk_format))
+ _nc_slk_initialize(stdscr, COLS);
+
+ SP->_ifd = fileno(ifp);
+ SP->_checkfd = fileno(ifp);
+ typeahead(fileno(ifp));
+#ifdef TERMIOS
+ SP->_use_meta = ((cur_term->Ottyb.c_cflag & CSIZE) == CS8 &&
+ !(cur_term->Ottyb.c_iflag & ISTRIP));
+#else
+ SP->_use_meta = FALSE;
+#endif
+ SP->_endwin = FALSE;
+
+ /* Check whether we can optimize scrolling under dumb terminals in case
+ * we do not have any of these capabilities, scrolling optimization
+ * will be useless.
+ */
+ SP->_scrolling = ((scroll_forward && scroll_reverse) ||
+ ((parm_rindex || parm_insert_line || insert_line) &&
+ (parm_index || parm_delete_line || delete_line)));
+
+ baudrate(); /* sets a field in the SP structure */
+
+ SP->_keytry = 0;
+
+ /*
+ * Check for mismatched graphic-rendition capabilities. Most SVr4
+ * terminfo trees contain entries that have rmul or rmso equated to
+ * sgr0 (Solaris curses copes with those entries). We do this only for
+ * curses, since many termcap applications assume that smso/rmso and
+ * smul/rmul are paired, and will not function properly if we remove
+ * rmso or rmul. Curses applications shouldn't be looking at this
+ * detail.
+ */
+#define SGR0_TEST(mode) (mode != 0) && (exit_attribute_mode == 0 || strcmp(mode, exit_attribute_mode))
+ SP->_use_rmso = SGR0_TEST(exit_standout_mode);
+ SP->_use_rmul = SGR0_TEST(exit_underline_mode);
+
+ /* compute movement costs so we can do better move optimization */
+ _nc_mvcur_init();
+
+ /* initialize terminal to a sane state */
+ _nc_screen_init();
+
+ /* Initialize the terminal line settings. */
+ _nc_initscr();
+
+ _nc_signal_handler(TRUE);
+
+ T((T_RETURN("%p"), SP));
+ return(SP);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_newwin.c b/contrib/ncurses/ncurses/base/lib_newwin.c
new file mode 100644
index 000000000000..61c0eb3ed548
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_newwin.c
@@ -0,0 +1,271 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_newwin.c
+**
+** The routines newwin(), subwin() and their dependent
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_newwin.c,v 1.20 1998/05/23 23:21:32 Alexander.V.Lukyanov Exp $")
+
+void _nc_freewin(WINDOW *win)
+{
+WINDOWLIST *p, *q;
+int i;
+
+ if (win != 0) {
+ for (p = _nc_windows, q = 0; p != 0; q = p, p = p->next) {
+ if (p->win == win) {
+ if (q == 0)
+ _nc_windows = p->next;
+ else
+ q->next = p->next;
+ free(p);
+
+ if (! (win->_flags & _SUBWIN)) {
+ for (i = 0; i <= win->_maxy && win->_line[i].text; i++)
+ free(win->_line[i].text);
+ }
+ free(win->_line);
+ free(win);
+
+ if (win == curscr) curscr = 0;
+ if (win == stdscr) stdscr = 0;
+ if (win == newscr) newscr = 0;
+
+ T(("...deleted win=%p", win));
+ break;
+ }
+ }
+ }
+}
+
+WINDOW * newwin(int num_lines, int num_columns, int begy, int begx)
+{
+WINDOW *win;
+chtype *ptr;
+int i;
+
+ T((T_CALLED("newwin(%d,%d,%d,%d)"), num_lines, num_columns, begy, begx));
+
+ if (begy < 0 || begx < 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
+
+ if (num_lines == 0)
+ num_lines = SP->_lines_avail - begy;
+ if (num_columns == 0)
+ num_columns = screen_columns - begx;
+
+ if (num_columns + begx > SP->_columns || num_lines + begy > SP->_lines_avail)
+ returnWin(0);
+
+ if ((win = _nc_makenew(num_lines, num_columns, begy, begx, 0)) == 0)
+ returnWin(0);
+
+ for (i = 0; i < num_lines; i++) {
+ if ((win->_line[i].text = typeCalloc(chtype, (unsigned)num_columns)) == 0) {
+ _nc_freewin(win);
+ returnWin(0);
+ }
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + num_columns; )
+ *ptr++ = ' ';
+ }
+
+ T(("newwin: returned window is %p", win));
+
+ returnWin(win);
+}
+
+WINDOW * derwin(WINDOW *orig, int num_lines, int num_columns, int begy, int begx)
+{
+WINDOW *win;
+int i;
+int flags = _SUBWIN;
+
+ T((T_CALLED("derwin(%p,%d,%d,%d,%d)"), orig, num_lines, num_columns, begy, begx));
+
+ /*
+ ** make sure window fits inside the original one
+ */
+ if ( begy < 0 || begx < 0 || orig == 0 || num_lines < 0 || num_columns < 0)
+ returnWin(0);
+ if ( begy + num_lines > orig->_maxy + 1
+ || begx + num_columns > orig->_maxx + 1)
+ returnWin(0);
+
+ if (num_lines == 0)
+ num_lines = orig->_maxy + 1 - begy;
+
+ if (num_columns == 0)
+ num_columns = orig->_maxx + 1 - begx;
+
+ if (orig->_flags & _ISPAD)
+ flags |= _ISPAD;
+
+ if ((win = _nc_makenew(num_lines, num_columns, orig->_begy + begy, orig->_begx + begx, flags)) == 0)
+ returnWin(0);
+
+ win->_pary = begy;
+ win->_parx = begx;
+ win->_attrs = orig->_attrs;
+ win->_bkgd = orig->_bkgd;
+
+ for (i = 0; i < num_lines; i++)
+ win->_line[i].text = &orig->_line[begy++].text[begx];
+
+ win->_parent = orig;
+
+ T(("derwin: returned window is %p", win));
+
+ returnWin(win);
+}
+
+
+WINDOW *subwin(WINDOW *w, int l, int c, int y, int x)
+{
+ T((T_CALLED("subwin(%p, %d, %d, %d, %d)"), w, l, c, y, x));
+ T(("parent has begy = %d, begx = %d", w->_begy, w->_begx));
+
+ returnWin(derwin(w, l, c, y - w->_begy, x - w->_begx));
+}
+
+WINDOW *
+_nc_makenew(int num_lines, int num_columns, int begy, int begx, int flags)
+{
+int i;
+WINDOWLIST *wp;
+WINDOW *win;
+bool is_pad = (flags & _ISPAD);
+
+ T(("_nc_makenew(%d,%d,%d,%d)", num_lines, num_columns, begy, begx));
+
+ if (num_lines <= 0 || num_columns <= 0)
+ return 0;
+
+ if ((wp = typeCalloc(WINDOWLIST, 1)) == 0)
+ return 0;
+
+ if ((win = typeCalloc(WINDOW, 1)) == 0)
+ return 0;
+
+ if ((win->_line = typeCalloc(struct ldat, ((unsigned)num_lines))) == 0) {
+ free(win);
+ return 0;
+ }
+
+ win->_curx = 0;
+ win->_cury = 0;
+ win->_maxy = num_lines - 1;
+ win->_maxx = num_columns - 1;
+ win->_begy = begy;
+ win->_begx = begx;
+ win->_yoffset = SP->_topstolen;
+
+ win->_flags = flags;
+ win->_attrs = A_NORMAL;
+ win->_bkgd = BLANK;
+
+ win->_clear = is_pad ? FALSE : (num_lines == screen_lines && num_columns == screen_columns);
+ win->_idlok = FALSE;
+ win->_idcok = TRUE;
+ win->_scroll = FALSE;
+ win->_leaveok = FALSE;
+ win->_use_keypad = FALSE;
+ win->_delay = -1;
+ win->_immed = FALSE;
+ win->_sync = 0;
+ win->_parx = -1;
+ win->_pary = -1;
+ win->_parent = 0;
+
+ win->_regtop = 0;
+ win->_regbottom = num_lines - 1;
+
+ win->_pad._pad_y = -1;
+ win->_pad._pad_x = -1;
+ win->_pad._pad_top = -1;
+ win->_pad._pad_bottom = -1;
+ win->_pad._pad_left = -1;
+ win->_pad._pad_right = -1;
+
+ for (i = 0; i < num_lines; i++)
+ {
+ /*
+ * This used to do
+ *
+ * win->_line[i].firstchar = win->_line[i].lastchar = _NOCHANGE;
+ *
+ * which marks the whole window unchanged. That's how
+ * SVr1 curses did it, but SVr4 curses marks the whole new
+ * window changed.
+ *
+ * With the old SVr1-like code, say you have stdscr full of
+ * characters, then create a new window with newwin(),
+ * then do a printw(win, "foo ");, the trailing spaces are
+ * completely ignored by the following refreshes. So, you
+ * get "foojunkjunk" on the screen instead of "foo " as
+ * you actually intended.
+ *
+ * SVr4 doesn't do this. Instead the spaces are actually written.
+ * So that's how we want ncurses to behave.
+ */
+ win->_line[i].firstchar = 0;
+ win->_line[i].lastchar = num_columns-1;
+
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = i);
+ }
+
+ if (!is_pad && (begx + num_columns == screen_columns)) {
+ win->_flags |= _ENDLINE;
+
+ if (begx == 0 && num_lines == screen_lines && begy == 0)
+ win->_flags |= _FULLWIN;
+
+ if (begy + num_lines == screen_lines)
+ win->_flags |= _SCROLLWIN;
+ }
+
+ wp->next = _nc_windows;
+ wp->win = win;
+ _nc_windows = wp;
+
+ T((T_CREATE("window %p"), win));
+
+ return(win);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_nl.c b/contrib/ncurses/ncurses/base/lib_nl.c
new file mode 100644
index 000000000000..d5c426632f5d
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_nl.c
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * nl.c
+ *
+ * Routines:
+ * nl()
+ * nonl()
+ *
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_nl.c,v 1.3 1998/10/14 15:14:08 Alexander.V.Lukyanov Exp $")
+
+#ifdef __EMX__
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+int nl(void)
+{
+ T((T_CALLED("nl()")));
+
+ SP->_nl = TRUE;
+
+#ifdef __EMX__
+ fflush(SP->_ofp);
+ _fsetmode(SP->_ofp, "t");
+#endif
+
+ returnCode(OK);
+}
+
+int nonl(void)
+{
+ T((T_CALLED("nonl()")));
+
+ SP->_nl = FALSE;
+
+#ifdef __EMX__
+ fflush(SP->_ofp);
+ _fsetmode(SP->_ofp, "b");
+#endif
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_overlay.c b/contrib/ncurses/ncurses/base/lib_overlay.c
new file mode 100644
index 000000000000..db2dce1b79f6
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_overlay.c
@@ -0,0 +1,161 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_overlay.c
+**
+** The routines overlay(), copywin(), and overwrite().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_overlay.c,v 1.12 1998/02/11 12:13:59 tom Exp $")
+
+static int overlap(const WINDOW *const s, WINDOW *const d, int const flag)
+{
+int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
+
+ T(("overlap : sby %d, sbx %d, smy %d, smx %d, dby %d, dbx %d, dmy %d, dmx %d",
+ s->_begy, s->_begx, s->_maxy, s->_maxx,
+ d->_begy, d->_begx, d->_maxy, d->_maxx));
+
+ if (!s || !d)
+ returnCode(ERR);
+
+ sminrow = max(s->_begy, d->_begy) - s->_begy;
+ smincol = max(s->_begx, d->_begx) - s->_begx;
+ dminrow = max(s->_begy, d->_begy) - d->_begy;
+ dmincol = max(s->_begx, d->_begx) - d->_begx;
+ dmaxrow = min(s->_maxy+s->_begy, d->_maxy+d->_begy) - d->_begy;
+ dmaxcol = min(s->_maxx+s->_begx, d->_maxx+d->_begx) - d->_begx;
+
+ return(copywin(s, d,
+ sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol,
+ flag));
+}
+
+/*
+**
+** overlay(win1, win2)
+**
+**
+** overlay() writes the overlapping area of win1 behind win2
+** on win2 non-destructively.
+**
+**/
+
+int overlay(const WINDOW *win1, WINDOW *win2)
+{
+ T((T_CALLED("overlay(%p,%p)"), win1, win2));
+ returnCode(overlap(win1, win2, TRUE));
+}
+
+/*
+**
+** overwrite(win1, win2)
+**
+**
+** overwrite() writes the overlapping area of win1 behind win2
+** on win2 destructively.
+**
+**/
+
+int overwrite(const WINDOW *win1, WINDOW *win2)
+{
+ T((T_CALLED("overwrite(%p,%p)"), win1, win2));
+ returnCode(overlap(win1, win2, FALSE));
+}
+
+int copywin(const WINDOW *src, WINDOW *dst,
+ int sminrow, int smincol,
+ int dminrow, int dmincol, int dmaxrow, int dmaxcol,
+ int over)
+{
+int sx, sy, dx, dy;
+bool touched;
+chtype bk = AttrOf(dst->_bkgd);
+chtype mask = ~(chtype)((bk&A_COLOR) ? A_COLOR : 0);
+
+ T((T_CALLED("copywin(%p, %p, %d, %d, %d, %d, %d, %d, %d)"),
+ src, dst, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, over));
+
+ if (!src || !dst)
+ returnCode(ERR);
+
+ /* make sure rectangle exists in source */
+ if ((sminrow + dmaxrow - dminrow) > (src->_maxy + 1) ||
+ (smincol + dmaxcol - dmincol) > (src->_maxx + 1)) {
+ returnCode(ERR);
+ }
+
+ T(("rectangle exists in source"));
+
+ /* make sure rectangle fits in destination */
+ if (dmaxrow > dst->_maxy || dmaxcol > dst->_maxx) {
+ returnCode(ERR);
+ }
+
+ T(("rectangle fits in destination"));
+
+ for (dy = dminrow, sy = sminrow; dy <= dmaxrow; sy++, dy++) {
+ touched = FALSE;
+ for(dx=dmincol, sx=smincol; dx <= dmaxcol; sx++, dx++)
+ {
+ if (over)
+ {
+ if ((TextOf(src->_line[sy].text[sx]) != ' ') &&
+ (dst->_line[dy].text[dx]!=src->_line[sy].text[sx]))
+ {
+ dst->_line[dy].text[dx] =
+ (src->_line[sy].text[sx] & mask) | bk;
+ touched = TRUE;
+ }
+ }
+ else {
+ if (dst->_line[dy].text[dx] != src->_line[sy].text[sx])
+ {
+ dst->_line[dy].text[dx] = src->_line[sy].text[sx];
+ touched = TRUE;
+ }
+ }
+ }
+ if (touched)
+ {
+ touchline(dst,0,getmaxy(dst));
+ }
+ }
+ T(("finished copywin"));
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_pad.c b/contrib/ncurses/ncurses/base/lib_pad.c
new file mode 100644
index 000000000000..d4e341c05c75
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_pad.c
@@ -0,0 +1,280 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * lib_pad.c
+ * newpad -- create a new pad
+ * pnoutrefresh -- refresh a pad, no update
+ * pechochar -- add a char to a pad and refresh
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_pad.c,v 1.27 1998/06/28 00:10:16 tom Exp $")
+
+WINDOW *newpad(int l, int c)
+{
+WINDOW *win;
+chtype *ptr;
+int i;
+
+ T((T_CALLED("newpad(%d, %d)"), l, c));
+
+ if (l <= 0 || c <= 0)
+ returnWin(0);
+
+ if ((win = _nc_makenew(l,c,0,0,_ISPAD)) == NULL)
+ returnWin(0);
+
+ for (i = 0; i < l; i++) {
+ if_USE_SCROLL_HINTS(win->_line[i].oldindex = _NEWINDEX);
+ if ((win->_line[i].text = typeCalloc(chtype, ((size_t)c))) == 0) {
+ _nc_freewin(win);
+ returnWin(0);
+ }
+ for (ptr = win->_line[i].text; ptr < win->_line[i].text + c; )
+ *ptr++ = ' ';
+ }
+
+ returnWin(win);
+}
+
+WINDOW *subpad(WINDOW *orig, int l, int c, int begy, int begx)
+{
+WINDOW *win = (WINDOW *)0;
+
+ T((T_CALLED("subpad(%d, %d)"), l, c));
+
+ if (orig) {
+ if (!(orig->_flags & _ISPAD) || ((win = derwin(orig, l, c, begy, begx)) == NULL))
+ returnWin(0);
+ }
+ returnWin(win);
+}
+
+int prefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
+{
+ T((T_CALLED("prefresh()")));
+ if (pnoutrefresh(win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol) != ERR
+ && doupdate() != ERR) {
+ returnCode(OK);
+ }
+ returnCode(ERR);
+}
+
+int pnoutrefresh(WINDOW *win, int pminrow, int pmincol,
+ int sminrow, int smincol, int smaxrow, int smaxcol)
+{
+const int my_len = 2; /* parameterize the threshold for hardscroll */
+short i, j;
+short m, n;
+short pmaxrow;
+short pmaxcol;
+short displaced;
+bool wide;
+
+ T((T_CALLED("pnoutrefresh(%p, %d, %d, %d, %d, %d, %d)"),
+ win, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
+
+ if (win == 0)
+ returnCode(ERR);
+
+ if (!(win->_flags & _ISPAD))
+ returnCode(ERR);
+
+ /* negative values are interpreted as zero */
+ if (pminrow < 0) pminrow = 0;
+ if (pmincol < 0) pmincol = 0;
+ if (sminrow < 0) sminrow = 0;
+ if (smincol < 0) smincol = 0;
+
+ pmaxrow = pminrow + smaxrow - sminrow;
+ pmaxcol = pmincol + smaxcol - smincol;
+
+ T((" pminrow + smaxrow - sminrow %d, win->_maxy %d", pmaxrow, win->_maxy));
+ T((" pmincol + smaxcol - smincol %d, win->_maxx %d", pmaxcol, win->_maxx));
+
+ /*
+ * Trim the caller's screen size back to the actual limits.
+ */
+ if (pmaxrow > win->_maxy) {
+ smaxrow -= (pmaxrow - win->_maxy);
+ pmaxrow = pminrow + smaxrow - sminrow;
+ }
+ if (pmaxcol > win->_maxx) {
+ smaxcol -= (pmaxcol - win->_maxx);
+ pmaxcol = pmincol + smaxcol - smincol;
+ }
+
+ if (smaxrow > screen_lines
+ || smaxcol > screen_columns
+ || sminrow > smaxrow
+ || smincol > smaxcol)
+ returnCode(ERR);
+
+ T(("pad being refreshed"));
+
+ if (win->_pad._pad_y >= 0) {
+ displaced = pminrow - win->_pad._pad_y
+ -(sminrow - win->_pad._pad_top);
+ T(("pad being shifted by %d line(s)", displaced));
+ } else
+ displaced = 0;
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the pad to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the pad "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (smincol < my_len && smaxcol > (newscr->_maxx - my_len));
+
+ for (i = pminrow, m = sminrow + win->_yoffset;
+ i <= pmaxrow && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ for (j = pmincol, n = smincol; j <= pmaxcol; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline,n);
+ }
+ }
+
+#if USE_SCROLL_HINTS
+ if (wide) {
+ int nind = m + displaced;
+ if (oline->oldindex < 0
+ || nind < sminrow
+ || nind > smaxrow) {
+ nind = _NEWINDEX;
+ } else if (displaced) {
+ register struct ldat *pline = &curscr->_line[nind];
+ for (j = 0; j <= my_len; j++) {
+ int k = newscr->_maxx - j;
+ if (pline->text[j] != nline->text[j]
+ || pline->text[k] != nline->text[k]) {
+ nind = _NEWINDEX;
+ break;
+ }
+ }
+ }
+
+ nline->oldindex = nind;
+ }
+#endif /* USE_SCROLL_HINTS */
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
+
+ /*
+ * Clean up debris from scrolling or resizing the pad, so we do not
+ * accidentally pick up the index value during the next call to this
+ * procedure. The only rows that should have an index value are those
+ * that are displayed during this cycle.
+ */
+#if USE_SCROLL_HINTS
+ for (i = pminrow-1; (i >= 0) && (win->_line[i].oldindex >= 0); i--)
+ win->_line[i].oldindex = _NEWINDEX;
+ for (i = pmaxrow+1; (i <= win->_maxy) && (win->_line[i].oldindex >= 0); i++)
+ win->_line[i].oldindex = _NEWINDEX;
+#endif
+
+ win->_begx = smincol;
+ win->_begy = sminrow;
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ /*
+ * Use the pad's current position, if it will be visible.
+ * If not, don't do anything; it's not an error.
+ */
+ if (win->_leaveok == FALSE
+ && win->_cury >= pminrow
+ && win->_curx >= pmincol
+ && win->_cury <= pmaxrow
+ && win->_curx <= pmaxcol) {
+ newscr->_cury = win->_cury - pminrow + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx - pmincol + win->_begx;
+ }
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Update our cache of the line-numbers that we displayed from the pad.
+ * We will use this on subsequent calls to this function to derive
+ * values to stuff into 'oldindex[]' -- for scrolling optimization.
+ */
+ win->_pad._pad_y = pminrow;
+ win->_pad._pad_x = pmincol;
+ win->_pad._pad_top = sminrow;
+ win->_pad._pad_left = smincol;
+ win->_pad._pad_bottom = smaxrow;
+ win->_pad._pad_right = smaxcol;
+
+ returnCode(OK);
+}
+
+int pechochar(WINDOW *pad, const chtype ch)
+{
+ T((T_CALLED("pechochar(%p, %s)"), pad, _tracechtype(ch)));
+
+ if (pad == 0)
+ returnCode(ERR);
+
+ if (!(pad->_flags & _ISPAD))
+ returnCode(wechochar(pad,ch));
+
+ waddch(pad, ch);
+ prefresh(pad, pad->_pad._pad_y,
+ pad->_pad._pad_x,
+ pad->_pad._pad_top,
+ pad->_pad._pad_left,
+ pad->_pad._pad_bottom,
+ pad->_pad._pad_right);
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_printw.c b/contrib/ncurses/ncurses/base/lib_printw.c
new file mode 100644
index 000000000000..8d28f288d3c1
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_printw.c
@@ -0,0 +1,110 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+/*
+** lib_printw.c
+**
+** The routines printw(), wprintw() and friends.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_printw.c,v 1.7 1998/04/11 22:53:44 tom Exp $")
+
+int printw(NCURSES_CONST char *fmt, ...)
+{
+ va_list argp;
+ int code;
+
+ T(("printw(%s,...) called", _nc_visbuf(fmt)));
+
+ va_start(argp, fmt);
+ code = vwprintw(stdscr, fmt, argp);
+ va_end(argp);
+
+ return code;
+}
+
+int wprintw(WINDOW *win, NCURSES_CONST char *fmt, ...)
+{
+ va_list argp;
+ int code;
+
+ T(("wprintw(%p,%s,...) called", win, _nc_visbuf(fmt)));
+
+ va_start(argp, fmt);
+ code = vwprintw(win, fmt, argp);
+ va_end(argp);
+
+ return code;
+}
+
+int mvprintw(int y, int x, NCURSES_CONST char *fmt, ...)
+{
+ va_list argp;
+ int code = move(y, x);
+
+ if (code != ERR) {
+ va_start(argp, fmt);
+ code = vwprintw(stdscr, fmt, argp);
+ va_end(argp);
+ }
+ return code;
+}
+
+int mvwprintw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt, ...)
+{
+ va_list argp;
+ int code = wmove(win, y, x);
+
+ if (code != ERR) {
+ va_start(argp, fmt);
+ code = vwprintw(win, fmt, argp);
+ va_end(argp);
+ }
+ return code;
+}
+
+int vwprintw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
+{
+ char *buf = _nc_printf_string(fmt, argp);
+ int code = ERR;
+
+ if (buf != 0) {
+ code = waddstr(win, buf);
+#if USE_SAFE_SPRINTF
+ free(buf);
+#endif
+ }
+ return code;
+}
diff --git a/contrib/ncurses/ncurses/base/lib_redrawln.c b/contrib/ncurses/ncurses/base/lib_redrawln.c
new file mode 100644
index 000000000000..10fda917984e
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_redrawln.c
@@ -0,0 +1,69 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+/*
+ * lib_redrawln.c
+ *
+ * The routine wredrawln().
+ *
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_redrawln.c,v 1.7 1998/09/19 20:09:50 Alexander.V.Lukyanov Exp $")
+
+int wredrawln(WINDOW *win, int beg, int num)
+{
+ int i;
+ int end;
+ size_t len = (win->_maxx + 1) * sizeof(chtype);
+
+ T((T_CALLED("wredrawln(%p,%d,%d)"), win, beg, num));
+
+ if (beg < 0)
+ beg = 0;
+
+ if (touchline (win, beg, num) == ERR)
+ returnCode(ERR);
+
+ end = beg + num;
+ if (end > win->_maxy + 1)
+ end = win->_maxy + 1;
+
+ for (i = beg; i < end; i++)
+ {
+ memset (curscr->_line[i+win->_begy].text+win->_begx, 0, len);
+ _nc_make_oldhash(i+win->_begy);
+ }
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_refresh.c b/contrib/ncurses/ncurses/base/lib_refresh.c
new file mode 100644
index 000000000000..88e3b75a56a1
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_refresh.c
@@ -0,0 +1,183 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+ * lib_refresh.c
+ *
+ * The routines wrefresh() and wnoutrefresh().
+ *
+ */
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_refresh.c,v 1.24 1999/07/31 11:36:37 juergen Exp $")
+
+int wrefresh(WINDOW *win)
+{
+int code;
+
+ T((T_CALLED("wrefresh(%p)"), win));
+
+ if (win == curscr) {
+ curscr->_clear = TRUE;
+ code = doupdate();
+ } else if ((code = wnoutrefresh(win)) == OK) {
+ if (win->_clear)
+ newscr->_clear = TRUE;
+ code = doupdate();
+ /*
+ * Reset the clearok() flag in case it was set for the special
+ * case in hardscroll.c (if we don't reset it here, we'll get 2
+ * refreshes because the flag is copied from stdscr to newscr).
+ * Resetting the flag shouldn't do any harm, anyway.
+ */
+ win->_clear = FALSE;
+ }
+ returnCode(code);
+}
+
+int wnoutrefresh(WINDOW *win)
+{
+short limit_x;
+short i, j;
+short begx;
+short begy;
+short m, n;
+bool wide;
+
+ T((T_CALLED("wnoutrefresh(%p)"), win));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...win", win);
+#endif /* TRACE */
+
+ /*
+ * This function will break badly if we try to refresh a pad.
+ */
+ if ((win == 0)
+ || (win->_flags & _ISPAD))
+ returnCode(ERR);
+
+ /* put them here so "win == 0" won't break our code */
+ begx = win->_begx;
+ begy = win->_begy;
+
+ newscr->_bkgd = win->_bkgd;
+ newscr->_attrs = win->_attrs;
+
+ /* merge in change information from all subwindows of this window */
+ wsyncdown(win);
+
+ /*
+ * For pure efficiency, we'd want to transfer scrolling information
+ * from the window to newscr whenever the window is wide enough that
+ * its update will dominate the cost of the update for the horizontal
+ * band of newscr that it occupies. Unfortunately, this threshold
+ * tends to be complex to estimate, and in any case scrolling the
+ * whole band and rewriting the parts outside win's image would look
+ * really ugly. So. What we do is consider the window "wide" if it
+ * either (a) occupies the whole width of newscr, or (b) occupies
+ * all but at most one column on either vertical edge of the screen
+ * (this caters to fussy people who put boxes around full-screen
+ * windows). Note that changing this formula will not break any code,
+ * merely change the costs of various update cases.
+ */
+ wide = (begx <= 1 && win->_maxx >= (newscr->_maxx - 1));
+
+ win->_flags &= ~_HASMOVED;
+
+ /*
+ * Microtweaking alert! This double loop is one of the genuine
+ * hot spots in the code. Even gcc doesn't seem to do enough
+ * common-subexpression chunking to make it really tense,
+ * so we'll force the issue.
+ */
+
+ /* limit(n) */
+ limit_x = win->_maxx;
+ /* limit(j) */
+ if (limit_x > win->_maxx)
+ limit_x = win->_maxx;
+
+ for (i = 0, m = begy + win->_yoffset;
+ i <= win->_maxy && m <= newscr->_maxy;
+ i++, m++) {
+ register struct ldat *nline = &newscr->_line[m];
+ register struct ldat *oline = &win->_line[i];
+
+ if (oline->firstchar != _NOCHANGE) {
+ int last = oline->lastchar;
+
+ if (last > limit_x)
+ last = limit_x;
+
+ for (j = oline->firstchar, n = j + begx; j <= last; j++, n++) {
+ if (oline->text[j] != nline->text[n]) {
+ nline->text[n] = oline->text[j];
+ CHANGED_CELL(nline, n);
+ }
+ }
+
+ }
+
+#if USE_SCROLL_HINTS
+ if (wide) {
+ int oind = oline->oldindex;
+
+ nline->oldindex = (oind == _NEWINDEX) ? _NEWINDEX : begy + oind + win->_yoffset;
+ }
+#endif /* USE_SCROLL_HINTS */
+
+ oline->firstchar = oline->lastchar = _NOCHANGE;
+ if_USE_SCROLL_HINTS(oline->oldindex = i);
+ }
+
+ if (win->_clear) {
+ win->_clear = FALSE;
+ newscr->_clear = TRUE;
+ }
+
+ if (! win->_leaveok) {
+ newscr->_cury = win->_cury + win->_begy + win->_yoffset;
+ newscr->_curx = win->_curx + win->_begx;
+ }
+ newscr->_leaveok = win->_leaveok;
+
+#ifdef TRACE
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("newscr", newscr);
+#endif /* TRACE */
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_restart.c b/contrib/ncurses/ncurses/base/lib_restart.c
new file mode 100644
index 000000000000..de0182f42691
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_restart.c
@@ -0,0 +1,90 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * Terminfo-only terminal setup routines:
+ *
+ * int restartterm(const char *, int, int *)
+ * TERMINAL *set_curterm(TERMINAL *)
+ * int del_curterm(TERMINAL *)
+ */
+
+#include <curses.priv.h>
+
+#if defined(SVR4_TERMIO) && !defined(_POSIX_SOURCE)
+#define _POSIX_SOURCE
+#endif
+
+#include <term.h> /* lines, columns, cur_term */
+
+MODULE_ID("$Id: lib_restart.c,v 1.2 1999/07/24 20:10:04 tom Exp $")
+
+int restartterm(NCURSES_CONST char *termp, int filenum, int *errret)
+{
+int saveecho = SP->_echo;
+int savecbreak = SP->_cbreak;
+int saveraw = SP->_raw;
+int savenl = SP->_nl;
+
+ T((T_CALLED("restartterm(%s,%d,%p)"), termp, filenum, errret));
+
+ setupterm(termp, filenum, errret);
+
+ if (saveecho)
+ echo();
+ else
+ noecho();
+
+ if (savecbreak) {
+ cbreak();
+ noraw();
+ } else if (saveraw) {
+ nocbreak();
+ raw();
+ } else {
+ nocbreak();
+ noraw();
+ }
+ if (savenl)
+ nl();
+ else
+ nonl();
+
+ reset_prog_mode();
+
+#if USE_SIZECHANGE
+ _nc_update_screensize();
+#endif
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_scanw.c b/contrib/ncurses/ncurses/base/lib_scanw.c
new file mode 100644
index 000000000000..cc66613ff52f
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_scanw.c
@@ -0,0 +1,111 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_scanw.c
+**
+** The routines scanw(), wscanw() and friends.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_scanw.c,v 1.8 1998/04/11 22:54:18 tom Exp $")
+
+#if !HAVE_VSSCANF
+#if defined(__QNX__)
+extern int vsscanf(const char *str, const char *format, __va_list __arg);
+#else
+extern int vsscanf(const char *str, const char *format, ...);
+#endif
+#endif
+
+int vwscanw(WINDOW *win, NCURSES_CONST char *fmt, va_list argp)
+{
+char buf[BUFSIZ];
+
+ if (wgetnstr(win, buf, sizeof(buf)-1) == ERR)
+ return(ERR);
+
+ return(vsscanf(buf, fmt, argp));
+}
+
+int scanw(NCURSES_CONST char *fmt, ...)
+{
+int code;
+va_list ap;
+
+ T(("scanw(\"%s\",...) called", fmt));
+
+ va_start(ap, fmt);
+ code = vwscanw(stdscr, fmt, ap);
+ va_end(ap);
+ return (code);
+}
+
+int wscanw(WINDOW *win, NCURSES_CONST char *fmt, ...)
+{
+int code;
+va_list ap;
+
+ T(("wscanw(%p,\"%s\",...) called", win, fmt));
+
+ va_start(ap, fmt);
+ code = vwscanw(win, fmt, ap);
+ va_end(ap);
+ return (code);
+}
+
+int mvscanw(int y, int x, NCURSES_CONST char *fmt, ...)
+{
+int code;
+va_list ap;
+
+ va_start(ap, fmt);
+ code = (move(y, x) == OK) ? vwscanw(stdscr, fmt, ap) : ERR;
+ va_end(ap);
+ return (code);
+}
+
+int mvwscanw(WINDOW *win, int y, int x, NCURSES_CONST char *fmt, ...)
+{
+int code;
+va_list ap;
+
+ va_start(ap, fmt);
+ code = (wmove(win, y, x) == OK) ? vwscanw(win, fmt, ap) : ERR;
+ va_end(ap);
+ return (code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_screen.c b/contrib/ncurses/ncurses/base/lib_screen.c
new file mode 100644
index 000000000000..3038393c2266
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_screen.c
@@ -0,0 +1,198 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+#include <curses.priv.h>
+
+#include <sys/stat.h>
+#include <time.h>
+#include <term.h> /* exit_ca_mode, non_rev_rmcup */
+
+MODULE_ID("$Id: lib_screen.c,v 1.15 1999/07/24 20:05:29 tom Exp $")
+
+static time_t dumptime;
+
+WINDOW *getwin(FILE *filep)
+{
+ WINDOW tmp, *nwin;
+ int n;
+
+ T((T_CALLED("getwin(%p)"), filep));
+
+ (void) fread(&tmp, sizeof(WINDOW), 1, filep);
+ if (ferror(filep))
+ returnWin(0);
+
+ if ((nwin = newwin(tmp._maxy+1, tmp._maxx+1, 0, 0)) == 0)
+ returnWin(0);
+
+ /*
+ * We deliberately do not restore the _parx, _pary, or _parent
+ * fields, because the window hierarchy within which they
+ * made sense is probably gone.
+ */
+ nwin->_curx = tmp._curx;
+ nwin->_cury = tmp._cury;
+ nwin->_maxy = tmp._maxy;
+ nwin->_maxx = tmp._maxx;
+ nwin->_begy = tmp._begy;
+ nwin->_begx = tmp._begx;
+ nwin->_yoffset = tmp._yoffset;
+ nwin->_flags = tmp._flags & ~(_SUBWIN|_ISPAD);
+
+ nwin->_attrs = tmp._attrs;
+ nwin->_bkgd = tmp._bkgd;
+
+ nwin->_clear = tmp._clear;
+ nwin->_scroll = tmp._scroll;
+ nwin->_leaveok = tmp._leaveok;
+ nwin->_use_keypad = tmp._use_keypad;
+ nwin->_delay = tmp._delay;
+ nwin->_immed = tmp._immed;
+ nwin->_sync = tmp._sync;
+
+ nwin->_regtop = tmp._regtop;
+ nwin->_regbottom = tmp._regbottom;
+
+ for (n = 0; n < nwin->_maxy + 1; n++)
+ {
+ (void) fread(nwin->_line[n].text,
+ sizeof(chtype), (size_t)(nwin->_maxx + 1), filep);
+ if (ferror(filep))
+ {
+ delwin(nwin);
+ returnWin(0);
+ }
+ }
+ touchwin(nwin);
+
+ returnWin(nwin);
+}
+
+int putwin(WINDOW *win, FILE *filep)
+{
+ int code = ERR;
+ int n;
+
+ T((T_CALLED("putwin(%p,%p)"), win, filep));
+
+ if (win) {
+ (void) fwrite(win, sizeof(WINDOW), 1, filep);
+ if (ferror(filep))
+ returnCode(code);
+
+ for (n = 0; n < win->_maxy + 1; n++)
+ {
+ (void) fwrite(win->_line[n].text,
+ sizeof(chtype), (size_t)(win->_maxx + 1), filep);
+ if (ferror(filep))
+ returnCode(code);
+ }
+ code = OK;
+ }
+ returnCode(code);
+}
+
+int scr_restore(const char *file)
+{
+ FILE *fp = 0;
+
+ T((T_CALLED("scr_restore(%s)"), _nc_visbuf(file)));
+
+ if (_nc_access(file, R_OK) < 0
+ || (fp = fopen(file, "rb")) == 0)
+ returnCode(ERR);
+ else
+ {
+ delwin(newscr);
+ newscr = getwin(fp);
+ (void) fclose(fp);
+ returnCode(OK);
+ }
+}
+
+int scr_dump(const char *file)
+{
+ FILE *fp = 0;
+
+ T((T_CALLED("scr_dump(%s)"), _nc_visbuf(file)));
+
+ if (_nc_access(file, W_OK) < 0
+ || (fp = fopen(file, "wb")) == 0)
+ returnCode(ERR);
+ else
+ {
+ (void) putwin(newscr, fp);
+ (void) fclose(fp);
+ dumptime = time((time_t *)0);
+ returnCode(OK);
+ }
+}
+
+int scr_init(const char *file)
+{
+ FILE *fp = 0;
+ struct stat stb;
+
+ T((T_CALLED("scr_init(%s)"), _nc_visbuf(file)));
+
+ if (exit_ca_mode && non_rev_rmcup)
+ returnCode(ERR);
+
+ if (_nc_access(file, R_OK) < 0
+ || (fp = fopen(file, "rb")) == 0)
+ returnCode(ERR);
+ else if (fstat(STDOUT_FILENO, &stb) || stb.st_mtime > dumptime)
+ returnCode(ERR);
+ else
+ {
+ delwin(curscr);
+ curscr = getwin(fp);
+ (void) fclose(fp);
+ returnCode(OK);
+ }
+}
+
+int scr_set(const char *file)
+{
+ T((T_CALLED("scr_set(%s)"), _nc_visbuf(file)));
+
+ if (scr_init(file) == ERR)
+ returnCode(ERR);
+ else
+ {
+ delwin(newscr);
+ newscr = dupwin(curscr);
+ returnCode(OK);
+ }
+}
diff --git a/contrib/ncurses/ncurses/base/lib_scroll.c b/contrib/ncurses/ncurses/base/lib_scroll.c
new file mode 100644
index 000000000000..197bb221a07c
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_scroll.c
@@ -0,0 +1,118 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_scroll.c
+**
+** The routine wscrl(win, n).
+** positive n scroll the window up (ie. move lines down)
+** negative n scroll the window down (ie. move lines up)
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_scroll.c,v 1.16 1998/02/11 12:13:55 tom Exp $")
+
+void _nc_scroll_window(WINDOW *win, int const n, short const top, short const bottom, chtype blank)
+{
+int line, j;
+size_t to_copy = (size_t)(sizeof(chtype) * (win->_maxx + 1));
+
+ TR(TRACE_MOVE, ("_nc_scroll_window(%p, %d, %d, %d)", win, n, top,bottom));
+
+ /*
+ * This used to do a line-text pointer-shuffle instead of text copies.
+ * That (a) doesn't work when the window is derived and doesn't have
+ * its own storage, (b) doesn't save you a lot on modern machines
+ * anyway. Your typical memcpy implementations are coded in
+ * assembler using a tight BLT loop; for the size of copies we're
+ * talking here, the total execution time is dominated by the one-time
+ * setup cost. So there is no point in trying to be excessively
+ * clever -- esr.
+ */
+
+ /* shift n lines downwards */
+ if (n < 0) {
+ for (line = bottom; line >= top-n; line--) {
+ memcpy(win->_line[line].text,
+ win->_line[line+n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
+ }
+ for (line = top; line < top-n; line++) {
+ for (j = 0; j <= win->_maxx; j ++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
+ }
+ }
+
+ /* shift n lines upwards */
+ if (n > 0) {
+ for (line = top; line <= bottom-n; line++) {
+ memcpy(win->_line[line].text,
+ win->_line[line+n].text,
+ to_copy);
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = win->_line[line+n].oldindex);
+ }
+ for (line = bottom; line > bottom-n; line--) {
+ for (j = 0; j <= win->_maxx; j ++)
+ win->_line[line].text[j] = blank;
+ if_USE_SCROLL_HINTS(win->_line[line].oldindex = _NEWINDEX);
+ }
+ }
+ touchline(win, top, bottom-top+1);
+}
+
+int
+wscrl(WINDOW *win, int n)
+{
+ T((T_CALLED("wscrl(%p,%d)"), win, n));
+
+ if (!win || !win->_scroll)
+ returnCode(ERR);
+
+ if (n == 0)
+ returnCode(OK);
+
+ if ((n > (win->_regbottom - win->_regtop)) ||
+ (-n > (win->_regbottom - win->_regtop)))
+ returnCode(ERR);
+
+ _nc_scroll_window(win, n, win->_regtop, win->_regbottom, _nc_background(win));
+
+ _nc_synchook(win);
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_scrollok.c b/contrib/ncurses/ncurses/base/lib_scrollok.c
new file mode 100644
index 000000000000..f24eb8ebb0c6
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_scrollok.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+** lib_scrollok.c
+**
+** The routine scrollok.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_scrollok.c,v 1.2 1998/02/11 12:14:01 tom Exp $")
+
+int scrollok(WINDOW *win, bool flag)
+{
+ T((T_CALLED("scrollok(%p,%d)"), win, flag));
+
+ if (win) {
+ win->_scroll = flag;
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_scrreg.c b/contrib/ncurses/ncurses/base/lib_scrreg.c
new file mode 100644
index 000000000000..ddeab2498bfd
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_scrreg.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_scrreg.c
+**
+** The routine wsetscrreg().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_scrreg.c,v 1.7 1998/02/11 12:13:53 tom Exp $")
+
+int wsetscrreg(WINDOW *win, int top, int bottom)
+{
+ T((T_CALLED("wsetscrreg(%p,%d,%d)"), win, top, bottom));
+
+ if (win &&
+ top >= 0 && top <= win->_maxy &&
+ bottom >= 0 && bottom <= win->_maxy &&
+ bottom > top)
+ {
+ win->_regtop = (short)top;
+ win->_regbottom = (short)bottom;
+
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_set_term.c b/contrib/ncurses/ncurses/base/lib_set_term.c
new file mode 100644
index 000000000000..443236cf9cda
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_set_term.c
@@ -0,0 +1,315 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_set_term.c
+**
+** The routine set_term().
+**
+*/
+
+#include <curses.priv.h>
+
+#include <term.h> /* cur_term */
+
+MODULE_ID("$Id: lib_set_term.c,v 1.46 1999/07/24 20:05:49 tom Exp $")
+
+SCREEN * set_term(SCREEN *screenp)
+{
+SCREEN *oldSP;
+
+ T((T_CALLED("set_term(%p)"), screenp));
+
+ oldSP = SP;
+ _nc_set_screen(screenp);
+
+ set_curterm(SP->_term);
+ curscr = SP->_curscr;
+ newscr = SP->_newscr;
+ stdscr = SP->_stdscr;
+ COLORS = SP->_color_count;
+ COLOR_PAIRS = SP->_pair_count;
+ memcpy(acs_map, SP->_acs_map, sizeof(chtype)*ACS_LEN);
+
+ T((T_RETURN("%p"), oldSP));
+ return(oldSP);
+}
+
+static void _nc_free_keytry(struct tries *kt)
+{
+ if (kt != 0) {
+ _nc_free_keytry(kt->child);
+ _nc_free_keytry(kt->sibling);
+ free(kt);
+ }
+}
+
+/*
+ * Free the storage associated with the given SCREEN sp.
+ */
+void delscreen(SCREEN *sp)
+{
+ SCREEN **scan = &_nc_screen_chain;
+
+ T((T_CALLED("delscreen(%p)"), sp));
+
+ while(*scan)
+ {
+ if (*scan == sp)
+ {
+ *scan = sp->_next_screen;
+ break;
+ }
+ scan = &(*scan)->_next_screen;
+ }
+
+ _nc_freewin(sp->_curscr);
+ _nc_freewin(sp->_newscr);
+ _nc_freewin(sp->_stdscr);
+ _nc_free_keytry(sp->_keytry);
+ _nc_free_keytry(sp->_key_ok);
+
+ FreeIfNeeded(sp->_color_table);
+ FreeIfNeeded(sp->_color_pairs);
+
+ FreeIfNeeded(sp->oldhash);
+ FreeIfNeeded(sp->newhash);
+
+ del_curterm(sp->_term);
+
+ free(sp);
+
+ /*
+ * If this was the current screen, reset everything that the
+ * application might try to use (except cur_term, which may have
+ * multiple references in different screens).
+ */
+ if (sp == SP) {
+ curscr = 0;
+ newscr = 0;
+ stdscr = 0;
+ COLORS = 0;
+ COLOR_PAIRS = 0;
+ _nc_set_screen(0);
+ }
+ returnVoid;
+}
+
+static ripoff_t rippedoff[5];
+static ripoff_t *rsp = rippedoff;
+#define N_RIPS SIZEOF(rippedoff)
+
+static bool no_mouse_event (SCREEN *sp GCC_UNUSED) { return FALSE; }
+static bool no_mouse_inline(SCREEN *sp GCC_UNUSED) { return FALSE; }
+static bool no_mouse_parse (int code GCC_UNUSED) { return TRUE; }
+static void no_mouse_resume(SCREEN *sp GCC_UNUSED) { }
+static void no_mouse_wrap (SCREEN *sp GCC_UNUSED) { }
+
+int _nc_setupscreen(short slines, short const scolumns, FILE *output)
+/* OS-independent screen initializations */
+{
+int bottom_stolen = 0;
+size_t i;
+
+ assert(SP==0); /* has been reset in newterm() ! */
+ if (!_nc_alloc_screen())
+ return ERR;
+
+ SP->_next_screen = _nc_screen_chain;
+ _nc_screen_chain = SP;
+
+ _nc_set_buffer(output, TRUE);
+ SP->_term = cur_term;
+ SP->_lines = slines;
+ SP->_lines_avail = slines;
+ SP->_columns = scolumns;
+ SP->_cursrow = -1;
+ SP->_curscol = -1;
+ SP->_nl = TRUE;
+ SP->_raw = FALSE;
+ SP->_cbreak = 0;
+ SP->_echo = TRUE;
+ SP->_fifohead = -1;
+ SP->_endwin = TRUE;
+ SP->_ofp = output;
+ SP->_cursor = -1; /* cannot know real cursor shape */
+#ifdef NCURSES_NO_PADDING
+ SP->_no_padding = getenv("NCURSES_NO_PADDING") != 0;
+#endif
+
+ SP->_maxclick = DEFAULT_MAXCLICK;
+ SP->_mouse_event = no_mouse_event;
+ SP->_mouse_inline = no_mouse_inline;
+ SP->_mouse_parse = no_mouse_parse;
+ SP->_mouse_resume = no_mouse_resume;
+ SP->_mouse_wrap = no_mouse_wrap;
+ SP->_mouse_fd = -1;
+
+ /* initialize the panel hooks */
+ SP->_panelHook.top_panel = (struct panel*)0;
+ SP->_panelHook.bottom_panel = (struct panel*)0;
+ SP->_panelHook.stdscr_pseudo_panel = (struct panel*)0;
+
+ /*
+ * If we've no magic cookie support, we suppress attributes that xmc
+ * would affect, i.e., the attributes that affect the rendition of a
+ * space. Note that this impacts the alternate character set mapping
+ * as well.
+ */
+ if (magic_cookie_glitch > 0) {
+
+ SP->_xmc_triggers = termattrs() & (
+ A_ALTCHARSET |
+ A_BLINK |
+ A_BOLD |
+ A_REVERSE |
+ A_STANDOUT |
+ A_UNDERLINE
+ );
+ SP->_xmc_suppress = SP->_xmc_triggers & (chtype)~(A_BOLD);
+
+ T(("magic cookie attributes %s", _traceattr(SP->_xmc_suppress)));
+#if USE_XMC_SUPPORT
+ /*
+ * To keep this simple, suppress all of the optimization hooks
+ * except for clear_screen and the cursor addressing.
+ */
+ clr_eol = 0;
+ clr_eos = 0;
+ set_attributes = 0;
+#else
+ magic_cookie_glitch = -1;
+ acs_chars = 0;
+#endif
+ }
+ _nc_init_acs();
+ memcpy(SP->_acs_map, acs_map, sizeof(chtype)*ACS_LEN);
+
+ _nc_idcok = TRUE;
+ _nc_idlok = FALSE;
+
+ _nc_windows = 0; /* no windows yet */
+
+ SP->oldhash = 0;
+ SP->newhash = 0;
+
+ T(("creating newscr"));
+ if ((newscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
+
+ T(("creating curscr"));
+ if ((curscr = newwin(slines, scolumns, 0, 0)) == 0)
+ return ERR;
+
+ SP->_newscr = newscr;
+ SP->_curscr = curscr;
+#if USE_SIZECHANGE
+ SP->_resize = resizeterm;
+#endif
+
+ newscr->_clear = TRUE;
+ curscr->_clear = FALSE;
+
+ for (i=0, rsp = rippedoff; rsp->line && (i < N_RIPS); rsp++, i++) {
+ if (rsp->hook) {
+ WINDOW *w;
+ int count = (rsp->line < 0) ? -rsp->line : rsp->line;
+
+ if (rsp->line < 0) {
+ w = newwin(count,scolumns,SP->_lines_avail - count,0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ bottom_stolen += count;
+ }
+ else
+ return ERR;
+ } else {
+ w = newwin(count,scolumns, 0, 0);
+ if (w) {
+ rsp->w = w;
+ rsp->hook(w, scolumns);
+ SP->_topstolen += count;
+ }
+ else
+ return ERR;
+ }
+ SP->_lines_avail -= count;
+ }
+ rsp->line = 0;
+ }
+ /* reset the stack */
+ rsp = rippedoff;
+
+ T(("creating stdscr"));
+ assert ((SP->_lines_avail + SP->_topstolen + bottom_stolen) == slines);
+ if ((stdscr = newwin(LINES = SP->_lines_avail, scolumns, 0, 0)) == 0)
+ return ERR;
+ SP->_stdscr = stdscr;
+
+ def_shell_mode();
+ def_prog_mode();
+
+ return OK;
+}
+
+/* The internal implementation interprets line as the number of
+ lines to rip off from the top or bottom.
+ */
+int
+_nc_ripoffline(int line, int (*init)(WINDOW *,int))
+{
+ if (line == 0)
+ return(OK);
+
+ if (rsp >= rippedoff + N_RIPS)
+ return(ERR);
+
+ rsp->line = line;
+ rsp->hook = init;
+ rsp->w = 0;
+ rsp++;
+
+ return(OK);
+}
+
+int
+ripoffline(int line, int (*init)(WINDOW *, int))
+{
+ T((T_CALLED("ripoffline(%d,%p)"), line, init));
+
+ if (line == 0)
+ returnCode(OK);
+
+ returnCode(_nc_ripoffline ((line<0) ? -1 : 1, init));
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slk.c b/contrib/ncurses/ncurses/base/lib_slk.c
new file mode 100644
index 000000000000..9b9b09a4d064
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slk.c
@@ -0,0 +1,214 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slk.c
+ * Soft key routines.
+ */
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+#include <term.h> /* num_labels, label_*, plab_norm */
+
+MODULE_ID("$Id: lib_slk.c,v 1.16 1999/03/03 23:44:22 juergen Exp $")
+
+/*
+ * We'd like to move these into the screen context structure, but cannot,
+ * because slk_init() is called before initscr()/newterm().
+ */
+int _nc_slk_format; /* one more than format specified in slk_init() */
+
+/*
+ * Paint the info line for the PC style SLK emulation.
+ *
+ */
+static void
+slk_paint_info(WINDOW *win)
+{
+ if (win && SP->slk_format==4)
+ {
+ int i;
+
+ mvwhline (win,0,0,0,getmaxx(win));
+ wmove (win,0,0);
+
+ for (i = 0; i < SP->_slk->maxlab; i++) {
+ if (win && SP->slk_format==4)
+ {
+ mvwaddch(win,0,SP->_slk->ent[i].x,'F');
+ if (i<9)
+ waddch(win,'1'+i);
+ else
+ {
+ waddch(win,'1');
+ waddch(win,'0' + (i-9));
+ }
+ }
+ }
+ }
+}
+
+/*
+ * Initialize soft labels.
+ * Called from newterm()
+ */
+int
+_nc_slk_initialize(WINDOW *stwin, int cols)
+{
+int i, x;
+int res = OK;
+char *p;
+
+ T(("slk_initialize()"));
+
+ if (SP->_slk)
+ { /* we did this already, so simply return */
+ return(OK);
+ }
+ else
+ if ((SP->_slk = typeCalloc(SLK, 1)) == 0)
+ return(ERR);
+
+ SP->_slk->ent = NULL;
+ SP->_slk->buffer = NULL;
+ SP->_slk->attr = A_STANDOUT;
+
+ SP->_slk->maxlab = (num_labels > 0) ?
+ num_labels : MAX_SKEY(_nc_slk_format);
+ SP->_slk->maxlen = (num_labels > 0) ?
+ label_width * label_height : MAX_SKEY_LEN(_nc_slk_format);
+ SP->_slk->labcnt = (SP->_slk->maxlab < MAX_SKEY(_nc_slk_format)) ?
+ MAX_SKEY(_nc_slk_format) : SP->_slk->maxlab;
+
+ SP->_slk->ent = typeCalloc(slk_ent, SP->_slk->labcnt);
+ if (SP->_slk->ent == NULL)
+ goto exception;
+
+ p = SP->_slk->buffer = (char*) calloc(2*SP->_slk->labcnt,(1+SP->_slk->maxlen));
+ if (SP->_slk->buffer == NULL)
+ goto exception;
+
+ for (i = 0; i < SP->_slk->labcnt; i++) {
+ SP->_slk->ent[i].text = p;
+ p += (1 + SP->_slk->maxlen);
+ SP->_slk->ent[i].form_text = p;
+ p += (1 + SP->_slk->maxlen);
+ memset(SP->_slk->ent[i].form_text, ' ', (unsigned)(SP->_slk->maxlen));
+ SP->_slk->ent[i].visible = (i < SP->_slk->maxlab);
+ }
+ if (_nc_slk_format >= 3) /* PC style */
+ {
+ int gap = (cols - 3 * (3 + 4*SP->_slk->maxlen))/2;
+
+ if (gap < 1)
+ gap = 1;
+
+ for (i = x = 0; i < SP->_slk->maxlab; i++) {
+ SP->_slk->ent[i].x = x;
+ x += SP->_slk->maxlen;
+ x += (i==3 || i==7) ? gap : 1;
+ }
+ if (_nc_slk_format == 4)
+ slk_paint_info (stwin);
+ }
+ else {
+ if (_nc_slk_format == 2) { /* 4-4 */
+ int gap = cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 6;
+
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < SP->_slk->maxlab; i++) {
+ SP->_slk->ent[i].x = x;
+ x += SP->_slk->maxlen;
+ x += (i == 3) ? gap : 1;
+ }
+ }
+ else
+ {
+ if (_nc_slk_format == 1) { /* 1 -> 3-2-3 */
+ int gap = (cols - (SP->_slk->maxlab * SP->_slk->maxlen) - 5) / 2;
+
+ if (gap < 1)
+ gap = 1;
+ for (i = x = 0; i < SP->_slk->maxlab; i++) {
+ SP->_slk->ent[i].x = x;
+ x += SP->_slk->maxlen;
+ x += (i == 2 || i == 4) ? gap : 1;
+ }
+ }
+ else
+ goto exception;
+ }
+ }
+ SP->_slk->dirty = TRUE;
+ if ((SP->_slk->win = stwin) == NULL)
+ {
+ exception:
+ if (SP->_slk)
+ {
+ FreeIfNeeded(SP->_slk->buffer);
+ FreeIfNeeded(SP->_slk->ent);
+ free(SP->_slk);
+ SP->_slk = (SLK*)0;
+ res = (ERR);
+ }
+ }
+
+ /* We now reset the format so that the next newterm has again
+ * per default no SLK keys and may call slk_init again to
+ * define a new layout. (juergen 03-Mar-1999)
+ */
+ SP->slk_format = _nc_slk_format;
+ _nc_slk_format = 0;
+ return(res);
+}
+
+
+/*
+ * Restore the soft labels on the screen.
+ */
+int
+slk_restore(void)
+{
+ T((T_CALLED("slk_restore()")));
+
+ if (SP->_slk == NULL)
+ return(ERR);
+ SP->_slk->hidden = FALSE;
+ SP->_slk->dirty = TRUE;
+ /* we have to repaint info line eventually */
+ slk_paint_info(SP->_slk->win);
+
+ returnCode(slk_refresh());
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkatr_set.c b/contrib/ncurses/ncurses/base/lib_slkatr_set.c
new file mode 100644
index 000000000000..0695d186bb5d
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkatr_set.c
@@ -0,0 +1,56 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ ****************************************************************************/
+
+/*
+ * lib_slkatr_set.c
+ * Soft key routines.
+ * Set the labels attributes
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkatr_set.c,v 1.3 1999/05/16 17:13:59 juergen Exp $")
+
+int
+slk_attr_set(const attr_t attr, short color_pair_number, void* opts)
+{
+ T((T_CALLED("slk_attr_set(%s,%d)"), _traceattr(attr), color_pair_number));
+
+ if (SP!=0 && SP->_slk!=0 && !opts &&
+ color_pair_number>=0 && color_pair_number<COLOR_PAIRS)
+ {
+ SP->_slk->attr = attr;
+ toggle_attr_on(SP->_slk->attr,COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkatrof.c b/contrib/ncurses/ncurses/base/lib_slkatrof.c
new file mode 100644
index 000000000000..5e4f5f5593a3
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkatrof.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkatrof.c
+ * Soft key routines.
+ * Switch off labels attributes
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkatrof.c,v 1.4 1998/03/11 19:26:07 juergen Exp $")
+
+int
+slk_attroff(const chtype attr)
+{
+ T((T_CALLED("slk_attroff(%s)"), _traceattr(attr)));
+
+ if (SP!=0 && SP->_slk!=0)
+ {
+ toggle_attr_off(SP->_slk->attr,attr);
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkatron.c b/contrib/ncurses/ncurses/base/lib_slkatron.c
new file mode 100644
index 000000000000..a24886522cde
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkatron.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkatron.c
+ * Soft key routines.
+ * Switch on labels attributes
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkatron.c,v 1.4 1998/03/11 19:26:07 juergen Exp $")
+
+int
+slk_attron(const chtype attr)
+{
+ T((T_CALLED("slk_attron(%s)"), _traceattr(attr)));
+
+ if (SP!=0 && SP->_slk!=0)
+ {
+ toggle_attr_on(SP->_slk->attr,attr);
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkatrset.c b/contrib/ncurses/ncurses/base/lib_slkatrset.c
new file mode 100644
index 000000000000..391c7ffe8cb7
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkatrset.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkatrset.c
+ * Soft key routines.
+ * Set the labels attributes
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkatrset.c,v 1.4 1998/03/11 19:26:01 juergen Exp $")
+
+int
+slk_attrset(const chtype attr)
+{
+ T((T_CALLED("slk_attrset(%s)"), _traceattr(attr)));
+
+ if (SP!=0 && SP->_slk!=0)
+ {
+ SP->_slk->attr = attr;
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkattr.c b/contrib/ncurses/ncurses/base/lib_slkattr.c
new file mode 100644
index 000000000000..a13240324e51
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkattr.c
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkattr.c
+ * Soft key routines.
+ * Fetch the labels attributes
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkattr.c,v 1.3 1998/02/11 12:13:56 tom Exp $")
+
+attr_t
+slk_attr(void)
+{
+ T((T_CALLED("slk_attr()")));
+
+ if (SP!=0 && SP->_slk!=0)
+ {
+ returnAttr(SP->_slk->attr);
+ }
+ else
+ returnAttr(0);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkclear.c b/contrib/ncurses/ncurses/base/lib_slkclear.c
new file mode 100644
index 000000000000..ac6e414beaa2
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkclear.c
@@ -0,0 +1,62 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkclear.c
+ * Soft key routines.
+ * Remove soft labels from the screen.
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkclear.c,v 1.4 1999/03/03 23:44:22 juergen Exp $")
+
+int
+slk_clear(void)
+{
+ T((T_CALLED("slk_clear()")));
+
+ if (SP == NULL || SP->_slk == NULL)
+ returnCode(ERR);
+ SP->_slk->hidden = TRUE;
+ /* For simulated SLK's it's looks much more natural to
+ inherit those attributes from the standard screen */
+ SP->_slk->win->_bkgd = stdscr->_bkgd;
+ SP->_slk->win->_attrs = stdscr->_attrs;
+ if (SP->_slk->win == stdscr) {
+ returnCode(OK);
+ }
+ else {
+ werase(SP->_slk->win);
+ returnCode(wrefresh(SP->_slk->win));
+ }
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkcolor.c b/contrib/ncurses/ncurses/base/lib_slkcolor.c
new file mode 100644
index 000000000000..3728808f9b6c
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkcolor.c
@@ -0,0 +1,54 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1998 *
+ ****************************************************************************/
+
+/*
+ * lib_slkcolor.c
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkcolor.c,v 1.5 1999/05/16 17:14:13 juergen Exp $")
+
+int
+slk_color(short color_pair_number)
+{
+ T((T_CALLED("slk_color(%d)"), color_pair_number));
+
+ if (SP!=0 && SP->_slk!=0 &&
+ color_pair_number>=0 && color_pair_number<COLOR_PAIRS)
+ {
+ T(("... current %ld", (long) PAIR_NUMBER(SP->_slk->attr)));
+ toggle_attr_on(SP->_slk->attr,COLOR_PAIR(color_pair_number));
+ returnCode(OK);
+ }
+ else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkinit.c b/contrib/ncurses/ncurses/base/lib_slkinit.c
new file mode 100644
index 000000000000..708442604d91
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkinit.c
@@ -0,0 +1,51 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkinit.c
+ * Soft key routines.
+ * Initialize soft labels. Called by the user before initscr().
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slkinit.c,v 1.3 1998/02/11 12:13:56 tom Exp $")
+
+int
+slk_init(int format)
+{
+ T((T_CALLED("slk_init(%d)"), format));
+ if (format < 0 || format > 3)
+ returnCode(ERR);
+ _nc_slk_format = 1 + format;
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slklab.c b/contrib/ncurses/ncurses/base/lib_slklab.c
new file mode 100644
index 000000000000..03039ad696ca
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slklab.c
@@ -0,0 +1,51 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slklab.c
+ * Soft key routines.
+ * Fetch the label text.
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slklab.c,v 1.4 1998/02/11 12:13:54 tom Exp $")
+
+char*
+slk_label(int n)
+{
+ T((T_CALLED("slk_label(%d)"), n));
+
+ if (SP == NULL || SP->_slk == NULL || n < 1 || n > SP->_slk->labcnt)
+ returnPtr(0);
+ returnPtr(SP->_slk->ent[n-1].text);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkrefr.c b/contrib/ncurses/ncurses/base/lib_slkrefr.c
new file mode 100644
index 000000000000..ee3c91dbee67
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkrefr.c
@@ -0,0 +1,126 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkrefr.c
+ * Write SLK window to the (virtual) screen.
+ */
+#include <curses.priv.h>
+#include <term.h> /* num_labels, label_*, plab_norm */
+
+MODULE_ID("$Id: lib_slkrefr.c,v 1.8 1999/03/14 00:10:27 Alexander.V.Lukyanov Exp $")
+
+/*
+ * Write the soft labels to the soft-key window.
+ */
+static void
+slk_intern_refresh(SLK *slk)
+{
+int i;
+int fmt = SP->slk_format;
+
+ for (i = 0; i < slk->labcnt; i++) {
+ if (slk->dirty || slk->ent[i].dirty) {
+ if (slk->ent[i].visible) {
+ if (num_labels > 0 && SLK_STDFMT(fmt))
+ {
+ if (i < num_labels) {
+ TPUTS_TRACE("plab_norm");
+ putp(tparm(plab_norm, i+1, slk->ent[i].form_text));
+ }
+ }
+ else
+ {
+ wmove(slk->win,SLK_LINES(fmt)-1,slk->ent[i].x);
+ if (SP && SP->_slk)
+ wattrset(slk->win,SP->_slk->attr);
+ waddnstr(slk->win,slk->ent[i].form_text,
+ MAX_SKEY_LEN(fmt));
+ /* if we simulate SLK's, it's looking much more
+ natural to use the current ATTRIBUTE also
+ for the label window */
+ wattrset(slk->win,stdscr->_attrs);
+ }
+ }
+ slk->ent[i].dirty = FALSE;
+ }
+ }
+ slk->dirty = FALSE;
+
+ if (num_labels > 0) {
+ if (slk->hidden)
+ {
+ TPUTS_TRACE("label_off");
+ putp(label_off);
+ }
+ else
+ {
+ TPUTS_TRACE("label_on");
+ putp(label_on);
+ }
+ }
+}
+
+/*
+ * Refresh the soft labels.
+ */
+int
+slk_noutrefresh(void)
+{
+ T((T_CALLED("slk_noutrefresh()")));
+
+ if (SP == NULL || SP->_slk == NULL)
+ returnCode(ERR);
+ if (SP->_slk->hidden)
+ returnCode(OK);
+ slk_intern_refresh(SP->_slk);
+
+ returnCode(wnoutrefresh(SP->_slk->win));
+}
+
+/*
+ * Refresh the soft labels.
+ */
+int
+slk_refresh(void)
+{
+ T((T_CALLED("slk_refresh()")));
+
+ if (SP == NULL || SP->_slk == NULL)
+ returnCode(ERR);
+ if (SP->_slk->hidden)
+ returnCode(OK);
+ slk_intern_refresh(SP->_slk);
+
+ returnCode(wrefresh(SP->_slk->win));
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slkset.c b/contrib/ncurses/ncurses/base/lib_slkset.c
new file mode 100644
index 000000000000..27471add77fa
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slkset.c
@@ -0,0 +1,95 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slkset.c
+ * Set soft label text.
+ */
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_slkset.c,v 1.3 1998/02/11 12:13:56 tom Exp $")
+
+int
+slk_set(int i, const char *astr, int format)
+{
+SLK *slk = SP->_slk;
+size_t len;
+const char *str = astr;
+const char *p;
+
+ T((T_CALLED("slk_set(%d, \"%s\", %d)"), i, str, format));
+
+ if (slk == NULL || i < 1 || i > slk->labcnt || format < 0 || format > 2)
+ returnCode(ERR);
+ if (str == NULL)
+ str = "";
+
+ while (isspace(*str)) str++; /* skip over leading spaces */
+ p = str;
+ while (isprint(*p)) p++; /* The first non-print stops */
+
+ --i; /* Adjust numbering of labels */
+
+ len = (size_t)(p - str);
+ if (len > (unsigned)slk->maxlen)
+ len = slk->maxlen;
+ if (len==0)
+ slk->ent[i].text[0] = 0;
+ else
+ (void) strncpy(slk->ent[i].text, str, len);
+ memset(slk->ent[i].form_text,' ', (unsigned)slk->maxlen);
+ slk->ent[i].text[slk->maxlen] = 0;
+ /* len = strlen(slk->ent[i].text); */
+
+ switch(format) {
+ case 0: /* left-justified */
+ memcpy(slk->ent[i].form_text,
+ slk->ent[i].text,
+ len);
+ break;
+ case 1: /* centered */
+ memcpy(slk->ent[i].form_text+(slk->maxlen - len)/2,
+ slk->ent[i].text,
+ len);
+ break;
+ case 2: /* right-justified */
+ memcpy(slk->ent[i].form_text+ slk->maxlen - len,
+ slk->ent[i].text,
+ len);
+ break;
+ }
+ slk->ent[i].form_text[slk->maxlen] = 0;
+ slk->ent[i].dirty = TRUE;
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_slktouch.c b/contrib/ncurses/ncurses/base/lib_slktouch.c
new file mode 100644
index 000000000000..c2829aed0e18
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_slktouch.c
@@ -0,0 +1,53 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * lib_slktouch.c
+ * Soft key routines.
+ * Force the code to believe that the soft keys have been changed.
+ */
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_slktouch.c,v 1.3 1998/02/11 12:13:56 tom Exp $")
+
+int
+slk_touch(void)
+{
+ T((T_CALLED("slk_touch()")));
+
+ if (SP == NULL || SP->_slk == NULL)
+ returnCode(ERR);
+ SP->_slk->dirty = TRUE;
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_touch.c b/contrib/ncurses/ncurses/base/lib_touch.c
new file mode 100644
index 000000000000..7ce863d06f10
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_touch.c
@@ -0,0 +1,87 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_touch.c
+**
+** The routines untouchwin(),
+** wtouchln(),
+** is_linetouched()
+** is_wintouched().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_touch.c,v 1.6 1998/04/11 22:55:02 tom Exp $")
+
+bool is_linetouched(WINDOW *win, int line)
+{
+ T((T_CALLED("is_linetouched(%p,%d)"), win, line));
+
+ /* XSI doesn't define any error */
+ if (!win || (line > win->_maxy) || (line < 0))
+ returnCode(ERR);
+
+ returnCode(win->_line[line].firstchar != _NOCHANGE ? TRUE : FALSE);
+}
+
+bool is_wintouched(WINDOW *win)
+{
+int i;
+
+ T((T_CALLED("is_wintouched(%p)"), win));
+
+ if (win)
+ for (i = 0; i <= win->_maxy; i++)
+ if (win->_line[i].firstchar != _NOCHANGE)
+ returnCode(TRUE);
+ returnCode(FALSE);
+}
+
+int wtouchln(WINDOW *win, int y, int n, int changed)
+{
+int i;
+
+ T((T_CALLED("wtouchln(%p,%d,%d,%d)"), win, y, n, changed));
+
+ if (!win || (n<0) || (y<0) || (y>win->_maxy))
+ returnCode(ERR);
+
+ for (i = y; i < y+n; i++) {
+ if (i>win->_maxy) break;
+ win->_line[i].firstchar = changed ? 0 : _NOCHANGE;
+ win->_line[i].lastchar = changed ? win->_maxx : _NOCHANGE;
+ }
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_ungetch.c b/contrib/ncurses/ncurses/base/lib_ungetch.c
new file mode 100644
index 000000000000..5fdfb47d490f
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_ungetch.c
@@ -0,0 +1,74 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_ungetch.c
+**
+** The routine ungetch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_ungetch.c,v 1.2 1998/02/11 12:13:56 tom Exp $")
+
+#include <fifo_defs.h>
+
+#ifdef TRACE
+void _nc_fifo_dump(void)
+{
+int i;
+ T(("head = %d, tail = %d, peek = %d", head, tail, peek));
+ for (i = 0; i < 10; i++)
+ T(("char %d = %s", i, _trace_key(SP->_fifo[i])));
+}
+#endif /* TRACE */
+
+int ungetch(int ch)
+{
+ if (tail == -1)
+ return ERR;
+ if (head == -1) {
+ head = 0;
+ t_inc()
+ peek = tail; /* no raw keys */
+ } else
+ h_dec();
+
+ SP->_fifo[head] = ch;
+ T(("ungetch %#x ok", ch));
+#ifdef TRACE
+ if (_nc_tracing & TRACE_IEVENT) _nc_fifo_dump();
+#endif
+ return OK;
+}
diff --git a/contrib/ncurses/ncurses/base/lib_vline.c b/contrib/ncurses/ncurses/base/lib_vline.c
new file mode 100644
index 000000000000..007ef55cd3ba
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_vline.c
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+** lib_vline.c
+**
+** The routine wvline().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_vline.c,v 1.4 1998/06/28 00:10:12 tom Exp $")
+
+int wvline(WINDOW *win, chtype ch, int n)
+{
+int code = ERR;
+short row, col;
+short end;
+
+ T((T_CALLED("wvline(%p,%s,%d)"), win, _tracechtype(ch), n));
+
+ if (win) {
+ row = win->_cury;
+ col = win->_curx;
+ end = row + n - 1;
+ if (end > win->_maxy)
+ end = win->_maxy;
+
+ if (ch == 0)
+ ch = ACS_VLINE;
+ ch = _nc_render(win, ch);
+
+ while(end >= row) {
+ struct ldat *line = &(win->_line[end]);
+ line->text[col] = ch;
+ CHANGED_CELL(line, col);
+ end--;
+ }
+
+ _nc_synchook(win);
+ code = OK;
+ }
+ returnCode(code);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_wattroff.c b/contrib/ncurses/ncurses/base/lib_wattroff.c
new file mode 100644
index 000000000000..a6c9f0f1804e
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_wattroff.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_wattroff.c
+**
+** The routine wattr_off().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_wattroff.c,v 1.4 1998/05/10 12:02:11 tom Exp $")
+
+int wattr_off(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+{
+ T((T_CALLED("wattr_off(%p,%s)"), win, _traceattr(at)));
+ if (win) {
+ T(("... current %s", _traceattr(win->_attrs)));
+ toggle_attr_off(win->_attrs,at);
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_wattron.c b/contrib/ncurses/ncurses/base/lib_wattron.c
new file mode 100644
index 000000000000..a951c576fa44
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_wattron.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_wattron.c
+**
+** The routines wattr_on().
+**
+*/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: lib_wattron.c,v 1.4 1998/05/10 12:02:28 tom Exp $")
+
+int wattr_on(WINDOW *win, NCURSES_CONST attr_t at, void *opts GCC_UNUSED)
+{
+ T((T_CALLED("wattr_on(%p,%s)"), win, _traceattr(at)));
+ if (win) {
+ T(("... current %s", _traceattr(win->_attrs)));
+ toggle_attr_on(win->_attrs,at);
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
diff --git a/contrib/ncurses/ncurses/base/lib_winch.c b/contrib/ncurses/ncurses/base/lib_winch.c
new file mode 100644
index 000000000000..119c731ebe3b
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_winch.c
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ ****************************************************************************/
+
+/*
+** lib_winch.c
+**
+** The routine winch().
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_winch.c,v 1.1 1998/11/14 22:06:09 tom Exp $")
+
+chtype winch(WINDOW *win)
+{
+ T((T_CALLED("winch(%p)"), win));
+ if (win != 0) {
+ returnCode(win->_line[win->_cury].text[win->_curx]);
+ } else {
+ returnCode(0);
+ }
+}
diff --git a/contrib/ncurses/ncurses/base/lib_window.c b/contrib/ncurses/ncurses/base/lib_window.c
new file mode 100644
index 000000000000..5eae9b1a57fb
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/lib_window.c
@@ -0,0 +1,221 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+** lib_window.c
+**
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: lib_window.c,v 1.13 1998/06/28 00:10:59 tom Exp $")
+
+void _nc_synchook(WINDOW *win)
+/* hook to be called after each window change */
+{
+ if (win->_immed) wrefresh(win);
+ if (win->_sync) wsyncup(win);
+}
+
+int mvderwin(WINDOW *win, int y, int x)
+/* move a derived window */
+{
+ WINDOW *orig;
+ int i;
+
+ T((T_CALLED("mvderwin(%p,%d,%d)"), win, y, x));
+
+ if (win && (orig = win->_parent))
+ {
+ if (win->_parx==x && win->_pary==y)
+ returnCode(OK);
+ if (x<0 || y<0)
+ returnCode(ERR);
+ if ( (x+getmaxx(win) > getmaxx(orig)) ||
+ (y+getmaxy(win) > getmaxy(orig)) )
+ returnCode(ERR);
+ }
+ else
+ returnCode(ERR);
+ wsyncup(win);
+ win->_parx = x;
+ win->_pary = y;
+ for(i=0;i<getmaxy(win);i++)
+ win->_line[i].text = &(orig->_line[y++].text[x]);
+ returnCode(OK);
+}
+
+int syncok(WINDOW *win, bool bf)
+/* enable/disable automatic wsyncup() on each change to window */
+{
+ T((T_CALLED("syncok(%p,%d)"), win, bf));
+
+ if (win) {
+ win->_sync = bf;
+ returnCode(OK);
+ } else
+ returnCode(ERR);
+}
+
+void wsyncup(WINDOW *win)
+/* mark changed every cell in win's ancestors that is changed in win */
+/* Rewritten by J. Pfeifer, 1-Apr-96 (don't even think that...) */
+{
+ WINDOW *wp;
+
+ if (win && win->_parent)
+ for (wp = win; wp->_parent; wp = wp->_parent)
+ {
+ int y;
+ WINDOW *pp = wp->_parent;
+
+ assert((wp->_pary <= pp->_maxy) &&
+ ((wp->_pary+wp->_maxy) <= pp->_maxy));
+
+ for (y = 0; y <= wp->_maxy; y++)
+ {
+ int left = wp->_line[y].firstchar;
+ if (left >= 0) /* line is touched */
+ {
+ struct ldat *line = &(pp->_line[wp->_pary + y]);
+ /* left & right character in parent window coordinates */
+ int right = wp->_line[y].lastchar + wp->_parx;
+ left += wp->_parx;
+
+ CHANGED_RANGE(line, left, right);
+ }
+ }
+ }
+}
+
+void wsyncdown(WINDOW *win)
+/* mark changed every cell in win that is changed in any of its ancestors */
+/* Rewritten by J. Pfeifer, 1-Apr-96 (don't even think that...) */
+{
+ if (win && win->_parent)
+ {
+ WINDOW *pp = win->_parent;
+ int y;
+
+ /* This recursion guarantees, that the changes are propagated down-
+ wards from the root to our direct parent. */
+ wsyncdown(pp);
+
+ /* and now we only have to propagate the changes from our direct
+ parent, if there are any. */
+ assert((win->_pary <= pp->_maxy) &&
+ ((win->_pary + win->_maxy) <= pp->_maxy));
+
+ for (y = 0; y <= win->_maxy; y++)
+ {
+ if (pp->_line[win->_pary + y].firstchar >= 0) /* parent changed */
+ {
+ struct ldat *line = &(win->_line[y]);
+ /* left and right character in child coordinates */
+ int left = pp->_line[win->_pary + y].firstchar - win->_parx;
+ int right = pp->_line[win->_pary + y].lastchar - win->_parx;
+ /* The change maybe outside the childs range */
+ if (left<0)
+ left = 0;
+ if (right > win->_maxx)
+ right = win->_maxx;
+ CHANGED_RANGE(line, left, right);
+ }
+ }
+ }
+}
+
+void wcursyncup(WINDOW *win)
+/* sync the cursor in all derived windows to its value in the base window */
+{
+ WINDOW *wp;
+ for( wp = win; wp && wp->_parent; wp = wp->_parent ) {
+ wmove( wp->_parent, wp->_pary + wp->_cury, wp->_parx + wp->_curx );
+ }
+}
+
+WINDOW *dupwin(WINDOW *win)
+/* make an exact duplicate of the given window */
+{
+WINDOW *nwin;
+size_t linesize;
+int i;
+
+ T((T_CALLED("dupwin(%p)"), win));
+
+ if ((win==NULL) ||
+ ((nwin = newwin(win->_maxy + 1, win->_maxx + 1, win->_begy, win->_begx)) == NULL))
+ returnWin(0);
+
+ nwin->_curx = win->_curx;
+ nwin->_cury = win->_cury;
+ nwin->_maxy = win->_maxy;
+ nwin->_maxx = win->_maxx;
+ nwin->_begy = win->_begy;
+ nwin->_begx = win->_begx;
+ nwin->_yoffset = win->_yoffset;
+
+ nwin->_flags = win->_flags & ~_SUBWIN;
+ /* Due to the use of newwin(), the clone is not a subwindow.
+ * The text is really copied into the clone.
+ */
+
+ nwin->_attrs = win->_attrs;
+ nwin->_bkgd = win->_bkgd;
+
+ nwin->_clear = win->_clear;
+ nwin->_scroll = win->_scroll;
+ nwin->_leaveok = win->_leaveok;
+ nwin->_use_keypad = win->_use_keypad;
+ nwin->_delay = win->_delay;
+ nwin->_immed = win->_immed;
+ nwin->_sync = win->_sync;
+
+ nwin->_parx = 0;
+ nwin->_pary = 0;
+ nwin->_parent = (WINDOW*)0;
+ /* See above: the clone isn't a subwindow! */
+
+ nwin->_regtop = win->_regtop;
+ nwin->_regbottom = win->_regbottom;
+
+ linesize = (win->_maxx + 1) * sizeof(chtype);
+ for (i = 0; i <= nwin->_maxy; i++) {
+ memcpy(nwin->_line[i].text, win->_line[i].text, linesize);
+ nwin->_line[i].firstchar = win->_line[i].firstchar;
+ nwin->_line[i].lastchar = win->_line[i].lastchar;
+ }
+
+ returnWin(nwin);
+}
diff --git a/contrib/ncurses/ncurses/base/memmove.c b/contrib/ncurses/ncurses/base/memmove.c
new file mode 100644
index 000000000000..55a410632f98
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/memmove.c
@@ -0,0 +1,63 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: memmove.c,v 1.2 1999/02/27 19:55:57 tom Exp $")
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ ****************************************************************************/
+
+#if USE_MY_MEMMOVE
+#define DST ((char *)s1)
+#define SRC ((const char *)s2)
+void * _nc_memmove(void * s1, const void * s2, size_t n)
+{
+ if (n != 0) {
+ if ((DST+n > SRC) && (SRC+n > DST)) {
+ static char *bfr;
+ static size_t length;
+ register size_t j;
+ if (length < n) {
+ length = (n * 3) / 2;
+ bfr = typeRealloc(char,length,bfr);
+ }
+ for (j = 0; j < n; j++)
+ bfr[j] = SRC[j];
+ SRC = bfr;
+ }
+ while (n-- != 0)
+ DST[n] = SRC[n];
+ }
+ return s1;
+}
+#else
+extern void _nc_memmove(void); /* quiet's gcc warning */
+void _nc_memmove(void) { } /* nonempty for strict ANSI compilers */
+#endif /* USE_MY_MEMMOVE */
diff --git a/contrib/ncurses/ncurses/base/nc_panel.c b/contrib/ncurses/ncurses/base/nc_panel.c
new file mode 100644
index 000000000000..536aab385dfd
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/nc_panel.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: nc_panel.c,v 1.2 1998/02/11 12:13:56 tom Exp $")
+
+struct panelhook*
+_nc_panelhook(void)
+{
+ return (SP ? &(SP->_panelHook) : NULL);
+}
diff --git a/contrib/ncurses/ncurses/base/resizeterm.c b/contrib/ncurses/ncurses/base/resizeterm.c
new file mode 100644
index 000000000000..860355024cc3
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/resizeterm.c
@@ -0,0 +1,121 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ ****************************************************************************/
+
+/*
+ * This is an extension to the curses library. It provides callers with a hook
+ * into the NCURSES data to resize windows, primarily for use by programs
+ * running in an X Window terminal (e.g., xterm). I abstracted this module
+ * from my application library for NCURSES because it must be compiled with
+ * the private data structures -- T.Dickey 1995/7/4.
+ */
+
+#include <curses.priv.h>
+#include <term.h>
+
+MODULE_ID("$Id: resizeterm.c,v 1.7 1998/09/19 19:27:43 Alexander.V.Lukyanov Exp $")
+
+/*
+ * This function reallocates NCURSES window structures. It is invoked in
+ * response to a SIGWINCH interrupt. Other user-defined windows may also need
+ * to be reallocated.
+ *
+ * Because this performs memory allocation, it should not (in general) be
+ * invoked directly from the signal handler.
+ */
+int
+resizeterm(int ToLines, int ToCols)
+{
+ int stolen = screen_lines - SP->_lines_avail;
+ int bottom = screen_lines + SP->_topstolen - stolen;
+
+ T((T_CALLED("resizeterm(%d,%d) old(%d,%d)"),
+ ToLines, ToCols,
+ screen_lines, screen_columns));
+
+ SP->_sig_winch = FALSE;
+
+ if (ToLines != screen_lines
+ || ToCols != screen_columns) {
+ WINDOWLIST *wp;
+
+#if USE_SIGWINCH
+ ungetch(KEY_RESIZE); /* so application can know this */
+ clearok(curscr, TRUE); /* screen contents are unknown */
+#endif
+
+ for (wp = _nc_windows; wp != 0; wp = wp->next) {
+ WINDOW *win = wp->win;
+ int myLines = win->_maxy + 1;
+ int myCols = win->_maxx + 1;
+
+ /* pads aren't treated this way */
+ if (win->_flags & _ISPAD)
+ continue;
+
+ if (win->_begy >= bottom) {
+ win->_begy += (ToLines - screen_lines);
+ } else {
+ if (myLines == screen_lines - stolen
+ && ToLines != screen_lines)
+ myLines = ToLines - stolen;
+ else
+ if (myLines == screen_lines
+ && ToLines != screen_lines)
+ myLines = ToLines;
+ }
+
+ if (myCols == screen_columns
+ && ToCols != screen_columns)
+ myCols = ToCols;
+
+ if (wresize(win, myLines, myCols) != OK)
+ returnCode(ERR);
+ }
+
+ screen_lines = lines = ToLines;
+ screen_columns = columns = ToCols;
+
+ SP->_lines_avail = lines - stolen;
+
+ if (SP->oldhash) { FreeAndNull(SP->oldhash); }
+ if (SP->newhash) { FreeAndNull(SP->newhash); }
+ }
+
+ /*
+ * Always update LINES, to allow for call from lib_doupdate.c which
+ * needs to have the count adjusted by the stolen (ripped off) lines.
+ */
+ LINES = ToLines - stolen;
+ COLS = ToCols;
+
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/base/safe_sprintf.c b/contrib/ncurses/ncurses/base/safe_sprintf.c
new file mode 100644
index 000000000000..0809225cd94c
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/safe_sprintf.c
@@ -0,0 +1,243 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+#include <ctype.h>
+
+MODULE_ID("$Id: safe_sprintf.c,v 1.10 1999/02/27 19:56:37 tom Exp $")
+
+#if USE_SAFE_SPRINTF
+
+typedef enum { Flags, Width, Prec, Type, Format } PRINTF;
+
+#define VA_INTGR(type) ival = va_arg(ap, type)
+#define VA_FLOAT(type) fval = va_arg(ap, type)
+#define VA_POINT(type) pval = (void *)va_arg(ap, type)
+
+/*
+ * Scan a variable-argument list for printf to determine the number of
+ * characters that would be emitted.
+ */
+static int
+_nc_printf_length(const char *fmt, va_list ap)
+{
+ size_t length = BUFSIZ;
+ char *buffer;
+ char *format;
+ int len = 0;
+
+ if (fmt == 0 || *fmt == '\0')
+ return -1;
+ if ((format = typeMalloc(char, strlen(fmt)+1)) == 0)
+ return -1;
+ if ((buffer = typeMalloc(char, length)) == 0) {
+ free(format);
+ return -1;
+ }
+
+ while (*fmt != '\0') {
+ if (*fmt == '%') {
+ static char dummy[] = "";
+ PRINTF state = Flags;
+ char *pval = dummy; /* avoid const-cast */
+ double fval = 0.0;
+ int done = FALSE;
+ int ival = 0;
+ int prec = -1;
+ int type = 0;
+ int used = 0;
+ int width = -1;
+ size_t f = 0;
+
+ format[f++] = *fmt;
+ while (*++fmt != '\0' && len >= 0 && !done) {
+ format[f++] = *fmt;
+
+ if (isdigit(*fmt)) {
+ int num = *fmt - '0';
+ if (state == Flags && num != 0)
+ state = Width;
+ if (state == Width) {
+ if (width < 0)
+ width = 0;
+ width = (width * 10) + num;
+ } else if (state == Prec) {
+ if (prec < 0)
+ prec = 0;
+ prec = (prec * 10) + num;
+ }
+ } else if (*fmt == '*') {
+ VA_INTGR(int);
+ if (state == Flags)
+ state = Width;
+ if (state == Width) {
+ width = ival;
+ } else if (state == Prec) {
+ prec = ival;
+ }
+ sprintf(&format[--f], "%d", ival);
+ f = strlen(format);
+ } else if (isalpha(*fmt)) {
+ done = TRUE;
+ switch (*fmt) {
+ case 'Z': /* FALLTHRU */
+ case 'h': /* FALLTHRU */
+ case 'l': /* FALLTHRU */
+ case 'L': /* FALLTHRU */
+ done = FALSE;
+ type = *fmt;
+ break;
+ case 'i': /* FALLTHRU */
+ case 'd': /* FALLTHRU */
+ case 'u': /* FALLTHRU */
+ case 'x': /* FALLTHRU */
+ case 'X': /* FALLTHRU */
+ if (type == 'l')
+ VA_INTGR(long);
+ else if (type == 'Z')
+ VA_INTGR(size_t);
+ else
+ VA_INTGR(int);
+ used = 'i';
+ break;
+ case 'f': /* FALLTHRU */
+ case 'e': /* FALLTHRU */
+ case 'E': /* FALLTHRU */
+ case 'g': /* FALLTHRU */
+ case 'G': /* FALLTHRU */
+ if (type == 'L')
+ VA_FLOAT(long double);
+ else
+ VA_FLOAT(double);
+ used = 'f';
+ break;
+ case 'c':
+ VA_INTGR(int);
+ used = 'i';
+ break;
+ case 's':
+ VA_POINT(char *);
+ if (prec < 0)
+ prec = strlen(pval);
+ if (prec > (int)length) {
+ length = length + prec;
+ buffer = typeRealloc(char, length, buffer);
+ if (buffer == 0) {
+ free(format);
+ return -1;
+ }
+ }
+ used = 'p';
+ break;
+ case 'p':
+ VA_POINT(void *);
+ used = 'p';
+ break;
+ case 'n':
+ VA_POINT(int *);
+ used = 0;
+ break;
+ default:
+ break;
+ }
+ } else if (*fmt == '.') {
+ state = Prec;
+ } else if (*fmt == '%') {
+ done = TRUE;
+ used = 'p';
+ }
+ }
+ format[f] = '\0';
+ switch (used) {
+ case 'i':
+ sprintf(buffer, format, ival);
+ break;
+ case 'f':
+ sprintf(buffer, format, fval);
+ break;
+ default:
+ sprintf(buffer, format, pval);
+ break;
+ }
+ len += (int)strlen(buffer);
+ } else {
+ fmt++;
+ len++;
+ }
+ }
+
+ free(buffer);
+ free(format);
+ return len;
+}
+#endif
+
+/*
+ * Wrapper for vsprintf that allocates a buffer big enough to hold the result.
+ */
+char *
+_nc_printf_string(const char *fmt, va_list ap)
+{
+#if USE_SAFE_SPRINTF
+ char *buf = 0;
+ int len = _nc_printf_length(fmt, ap);
+
+ if (len > 0) {
+ if ((buf = typeMalloc(char, len+1)) == 0)
+ return(0);
+ vsprintf(buf, fmt, ap);
+ }
+#else
+ static int rows, cols;
+ static char *buf;
+ static size_t len;
+
+ if (screen_lines > rows || screen_columns > cols) {
+ if (screen_lines > rows) rows = screen_lines;
+ if (screen_columns > cols) cols = screen_columns;
+ len = (rows * (cols + 1)) + 1;
+ buf = typeRealloc(char, len, buf);
+ if (buf == 0) {
+ return(0);
+ }
+ }
+
+ if (buf != 0) {
+# if HAVE_VSNPRINTF
+ vsnprintf(buf, len, fmt, ap); /* GNU extension */
+# else
+ vsprintf(buf, fmt, ap); /* ANSI */
+# endif
+ }
+#endif
+ return buf;
+}
diff --git a/contrib/ncurses/ncurses/base/sigaction.c b/contrib/ncurses/ncurses/base/sigaction.c
new file mode 100644
index 000000000000..ab1e569fae6a
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/sigaction.c
@@ -0,0 +1,106 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <signal.h>
+#include <SigAction.h>
+
+/* This file provides sigaction() emulation using sigvec() */
+/* Use only if this is non POSIX system */
+
+#if !HAVE_SIGACTION && HAVE_SIGVEC
+
+MODULE_ID("$Id: sigaction.c,v 1.9 1999/06/19 23:05:16 tom Exp $")
+
+int
+sigaction (int sig, sigaction_t * sigact, sigaction_t * osigact)
+{
+ return sigvec(sig, sigact, osigact);
+}
+
+int
+sigemptyset (sigset_t * mask)
+{
+ *mask = 0;
+ return 0;
+}
+
+int
+sigprocmask (int mode, sigset_t * mask, sigset_t * omask)
+{
+ sigset_t current = sigsetmask(0);
+
+ if (omask) *omask = current;
+
+ if (mode==SIG_BLOCK)
+ current |= *mask;
+ else if (mode==SIG_UNBLOCK)
+ current &= ~*mask;
+ else if (mode==SIG_SETMASK)
+ current = *mask;
+
+ sigsetmask(current);
+ return 0;
+}
+
+int
+sigsuspend (sigset_t * mask)
+{
+ return sigpause (*mask);
+}
+
+int
+sigdelset (sigset_t * mask, int sig)
+{
+ *mask &= ~sigmask (sig);
+ return 0;
+}
+
+int
+sigaddset (sigset_t * mask, int sig)
+{
+ *mask |= sigmask (sig);
+ return 0;
+}
+
+int
+sigismember (sigset_t * mask, int sig)
+{
+ return (*mask & sigmask (sig)) != 0;
+}
+
+#else
+extern void _nc_sigaction(void); /* quiet's gcc warning */
+void _nc_sigaction(void) { } /* nonempty for strict ANSI compilers */
+#endif
diff --git a/contrib/ncurses/ncurses/base/tries.c b/contrib/ncurses/ncurses/base/tries.c
new file mode 100644
index 000000000000..3c396529d654
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/tries.c
@@ -0,0 +1,138 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1997 *
+ ****************************************************************************/
+
+/*
+** tries.c
+**
+** Functions to manage the tree of partial-completions for keycodes.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: tries.c,v 1.12 1999/03/01 23:23:59 tom Exp $")
+
+/*
+ * Expand a keycode into the string that it corresponds to, returning null if
+ * no match was found, otherwise allocating a string of the result.
+ */
+char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len)
+{
+ struct tries *ptr = tree;
+ char *result = 0;
+
+ if (code != 0) {
+ while (ptr != 0) {
+ if ((result = _nc_expand_try(ptr->child, code, count, len + 1)) != 0) {
+ break;
+ }
+ if (ptr->value == code) {
+ *count -= 1;
+ if (*count == -1) {
+ result = typeCalloc(char, len+2);
+ break;
+ }
+ }
+ ptr = ptr->sibling;
+ }
+ }
+ if (result != 0) {
+ if ((result[len] = ptr->ch) == 0)
+ *((unsigned char *)(result+len)) = 128;
+#ifdef TRACE
+ if (len == 0)
+ _tracef("expand_key %s %s", _trace_key(code), _nc_visbuf(result));
+#endif
+ }
+ return result;
+}
+
+/*
+ * Remove a code from the specified tree, freeing the unused nodes. Returns
+ * true if the code was found/removed.
+ */
+int _nc_remove_key(struct tries **tree, unsigned short code)
+{
+ T((T_CALLED("_nc_remove_key(%p,%d)"), tree, code));
+
+ if (code == 0)
+ returnCode(FALSE);
+
+ while (*tree != 0) {
+ if (_nc_remove_key(&(*tree)->child, code)) {
+ returnCode(TRUE);
+ }
+ if ((*tree)->value == code) {
+ if((*tree)->child) {
+ /* don't cut the whole sub-tree */
+ (*tree)->value = 0;
+ } else {
+ struct tries *to_free = *tree;
+ *tree = (*tree)->sibling;
+ free(to_free);
+ }
+ returnCode(TRUE);
+ }
+ tree = &(*tree)->sibling;
+ }
+ returnCode(FALSE);
+}
+
+/*
+ * Remove a string from the specified tree, freeing the unused nodes. Returns
+ * true if the string was found/removed.
+ */
+int _nc_remove_string(struct tries **tree, char *string)
+{
+ T((T_CALLED("_nc_remove_string(%p,%s)"), tree, _nc_visbuf(string)));
+
+ if (string == 0 || *string == 0)
+ returnCode(FALSE);
+
+ while (*tree != 0) {
+ if ((unsigned char)(*tree)->ch == (unsigned char)*string) {
+ if (string[1] != 0)
+ returnCode(_nc_remove_string(&(*tree)->child, string+1));
+ if((*tree)->child) {
+ /* don't cut the whole sub-tree */
+ (*tree)->value = 0;
+ } else {
+ struct tries *to_free = *tree;
+ *tree = (*tree)->sibling;
+ free(to_free);
+ }
+ returnCode(TRUE);
+ }
+ tree = &(*tree)->sibling;
+ }
+ returnCode(FALSE);
+}
diff --git a/contrib/ncurses/ncurses/base/vsscanf.c b/contrib/ncurses/ncurses/base/vsscanf.c
new file mode 100644
index 000000000000..ac2bf9f2e783
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/vsscanf.c
@@ -0,0 +1,47 @@
+/*
+ * This function is needed to support vwscanw
+ */
+
+#include <curses.priv.h>
+
+#if !HAVE_VSSCANF
+
+MODULE_ID("$Id: vsscanf.c,v 1.10 1996/12/21 14:24:06 tom Exp $")
+
+#if defined(_IOREAD) && defined(_NFILE)
+/*VARARGS2*/
+int vsscanf(const char *str, const char *format, va_list ap)
+{
+ /*
+ * This code should work on anything descended from AT&T SVr1.
+ */
+ FILE strbuf;
+
+ strbuf._flag = _IOREAD;
+ strbuf._ptr = strbuf._base = (unsigned char*)str;
+ strbuf._cnt = strlen(str);
+ strbuf._file = _NFILE;
+
+#if HAVE_VFSCANF
+ return(vfscanf(&strbuf, format, ap));
+#else
+ return(_doscan(&strbuf, format, ap));
+#endif
+}
+#else
+/*VARARGS2*/
+int vsscanf(const char *str, const char *format, va_list ap)
+{
+ /*
+ * You don't have a native vsscanf(3), and you don't have System-V
+ * compatible stdio internals. You're probably using a BSD
+ * older than 4.4 or a really old Linux. You lose. Upgrade
+ * to a current C library to win.
+ */
+ return -1; /* not implemented */
+}
+#endif
+#else
+extern void _nc_vsscanf(void); /* quiet's gcc warning */
+void _nc_vsscanf(void) { } /* nonempty for strict ANSI compilers */
+#endif /* !HAVE_VSSCANF */
diff --git a/contrib/ncurses/ncurses/base/wresize.c b/contrib/ncurses/ncurses/base/wresize.c
new file mode 100644
index 000000000000..1b91476cbfd3
--- /dev/null
+++ b/contrib/ncurses/ncurses/base/wresize.c
@@ -0,0 +1,166 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: wresize.c,v 1.12 1999/02/27 18:57:31 tom Exp $")
+
+/*
+ * Reallocate a curses WINDOW struct to either shrink or grow to the specified
+ * new lines/columns. If it grows, the new character cells are filled with
+ * blanks. The application is responsible for repainting the blank area.
+ */
+
+#define DOALLOC(p,t,n) typeRealloc(t, n, p)
+#define ld_ALLOC(p,n) DOALLOC(p,struct ldat,n)
+#define c_ALLOC(p,n) DOALLOC(p,chtype,n)
+
+int
+wresize(WINDOW *win, int ToLines, int ToCols)
+{
+ register int row;
+ int size_x, size_y;
+ struct ldat *pline;
+ chtype blank;
+
+#ifdef TRACE
+ T((T_CALLED("wresize(%p,%d,%d)"), win, ToLines, ToCols));
+ if (win) {
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...before", win);
+ }
+#endif
+
+ if (!win || --ToLines < 0 || --ToCols < 0)
+ returnCode(ERR);
+
+ size_x = win->_maxx;
+ size_y = win->_maxy;
+
+ if (ToLines == size_y
+ && ToCols == size_x)
+ returnCode(OK);
+
+ pline = (win->_flags & _SUBWIN) ? win->_parent->_line : 0;
+
+ /*
+ * If the number of lines has changed, adjust the size of the overall
+ * vector:
+ */
+ if (ToLines != size_y) {
+ if (! (win->_flags & _SUBWIN)) {
+ for (row = ToLines+1; row <= size_y; row++)
+ free((char *)(win->_line[row].text));
+ }
+
+ win->_line = ld_ALLOC(win->_line, ToLines+1);
+ if (win->_line == 0)
+ returnCode(ERR);
+
+ for (row = size_y+1; row <= ToLines; row++) {
+ win->_line[row].text = 0;
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ if ((win->_flags & _SUBWIN)) {
+ win->_line[row].text =
+ &pline[win->_begy + row].text[win->_begx];
+ }
+ }
+ }
+
+ /*
+ * Adjust the width of the columns:
+ */
+ blank = _nc_background(win);
+ for (row = 0; row <= ToLines; row++) {
+ chtype *s = win->_line[row].text;
+ int begin = (s == 0) ? 0 : size_x + 1;
+ int end = ToCols;
+
+ if_USE_SCROLL_HINTS(win->_line[row].oldindex = row);
+
+ if (ToCols != size_x || s == 0) {
+ if (! (win->_flags & _SUBWIN)) {
+ win->_line[row].text = s = c_ALLOC(s, ToCols+1);
+ if (win->_line[row].text == 0)
+ returnCode(ERR);
+ } else if (s == 0) {
+ win->_line[row].text = s =
+ &pline[win->_begy + row].text[win->_begx];
+ }
+
+ if (end >= begin) { /* growing */
+ if (win->_line[row].firstchar < begin)
+ win->_line[row].firstchar = begin;
+ win->_line[row].lastchar = ToCols;
+ do {
+ s[end] = blank;
+ } while (--end >= begin);
+ } else { /* shrinking */
+ win->_line[row].firstchar = 0;
+ win->_line[row].lastchar = ToCols;
+ }
+ }
+ }
+
+ /*
+ * Finally, adjust the parameters showing screen size and cursor
+ * position:
+ */
+ win->_maxx = ToCols;
+ win->_maxy = ToLines;
+
+ if (win->_regtop > win->_maxy)
+ win->_regtop = win->_maxy;
+ if (win->_regbottom > win->_maxy
+ || win->_regbottom == size_y)
+ win->_regbottom = win->_maxy;
+
+ if (win->_curx > win->_maxx)
+ win->_curx = win->_maxx;
+ if (win->_cury > win->_maxy)
+ win->_cury = win->_maxy;
+
+#ifdef TRACE
+ TR(TRACE_UPDATE, ("...beg (%d, %d), max(%d,%d), reg(%d,%d)",
+ win->_begy, win->_begx,
+ win->_maxy, win->_maxx,
+ win->_regtop, win->_regbottom));
+ if (_nc_tracing & TRACE_UPDATE)
+ _tracedump("...after:", win);
+#endif
+ returnCode(OK);
+}
diff --git a/contrib/ncurses/ncurses/curses.priv.h b/contrib/ncurses/ncurses/curses.priv.h
new file mode 100644
index 000000000000..02b81a4ccc93
--- /dev/null
+++ b/contrib/ncurses/ncurses/curses.priv.h
@@ -0,0 +1,791 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * $Id: curses.priv.h,v 1.142 1999/07/04 01:21:35 tom Exp $
+ *
+ * curses.priv.h
+ *
+ * Header file for curses library objects which are private to
+ * the library.
+ *
+ */
+
+#ifndef CURSES_PRIV_H
+#define CURSES_PRIV_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ncurses_cfg.h>
+
+#if USE_RCS_IDS
+#define MODULE_ID(id) static const char Ident[] = id;
+#else
+#define MODULE_ID(id) /*nothing*/
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_SYS_BSDTYPES_H
+#include <sys/bsdtypes.h> /* needed for ISC */
+#endif
+
+#if HAVE_LIMITS_H
+# include <limits.h>
+#elif HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#ifndef PATH_MAX
+# if defined(_POSIX_PATH_MAX)
+# define PATH_MAX _POSIX_PATH_MAX
+# elif defined(MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+# else
+# define PATH_MAX 255 /* the Posix minimum path-size */
+# endif
+#endif
+
+#include <assert.h>
+#include <stdio.h>
+
+#include <errno.h>
+
+#if DECL_ERRNO
+extern int errno;
+#endif
+
+#include <nc_panel.h>
+
+/* Some systems have a broken 'select()', but workable 'poll()'. Use that */
+#if HAVE_POLL && HAVE_SYS_STROPTS_H && HAVE_POLL_H
+#define USE_FUNC_POLL 1
+#else
+#define USE_FUNC_POLL 0
+#endif
+
+/* Alessandro Rubini's GPM (general-purpose mouse) */
+#if HAVE_LIBGPM && HAVE_GPM_H
+#define USE_GPM_SUPPORT 1
+#else
+#define USE_GPM_SUPPORT 0
+#endif
+
+/* QNX mouse support */
+#if defined(__QNX__) && !defined(__QNXNTO__)
+#define USE_QNX_MOUSE 1
+#else
+#define USE_QNX_MOUSE 0
+#endif
+
+/* EMX mouse support */
+#ifdef __EMX__
+#define USE_EMX_MOUSE
+#endif
+
+#define DEFAULT_MAXCLICK 166
+#define EV_MAX 8 /* size of mouse circular event queue */
+
+/*
+ * If we don't have signals to support it, don't add a sigwinch handler.
+ * In any case, resizing is an extended feature. Use it if we've got it.
+ */
+#ifndef NCURSES_EXT_FUNCS
+#undef HAVE_SIZECHANGE
+#endif
+
+#if HAVE_SIZECHANGE
+#define USE_SIZECHANGE 1
+#else
+#undef USE_SIGWINCH
+#endif
+
+/*
+ * Not all platforms have memmove; some have an equivalent bcopy. (Some may
+ * have neither).
+ */
+#if USE_OK_BCOPY
+#define memmove(d,s,n) bcopy(s,d,n)
+#elif USE_MY_MEMMOVE
+#define memmove(d,s,n) _nc_memmove(d,s,n)
+extern void * _nc_memmove(void *, const void *, size_t);
+#endif
+
+/*
+ * Scroll hints are useless when hashmap is used
+ */
+#if !USE_SCROLL_HINTS
+#if !USE_HASHMAP
+#define USE_SCROLL_HINTS 1
+#else
+#define USE_SCROLL_HINTS 0
+#endif
+#endif
+
+#if USE_SCROLL_HINTS
+#define if_USE_SCROLL_HINTS(stmt) stmt
+#else
+#define if_USE_SCROLL_HINTS(stmt) /*nothing*/
+#endif
+
+/*
+ * Note: ht/cbt expansion flakes out randomly under Linux 1.1.47, but only
+ * when we're throwing control codes at the screen at high volume. To see
+ * this, re-enable USE_HARD_TABS and run worm for a while. Other systems
+ * probably don't want to define this either due to uncertainties about tab
+ * delays and expansion in raw mode.
+ */
+
+struct tries {
+ struct tries *child; /* ptr to child. NULL if none */
+ struct tries *sibling; /* ptr to sibling. NULL if none */
+ unsigned char ch; /* character at this node */
+ unsigned short value; /* code of string so far. 0 if none. */
+};
+
+/*
+ * Definitions for color pairs
+ */
+#define C_SHIFT 8 /* we need more bits than there are colors */
+#define C_MASK ((1 << C_SHIFT) - 1)
+
+#define PAIR_OF(fg, bg) ((((fg) & C_MASK) << C_SHIFT) | ((bg) & C_MASK))
+
+/*
+ * Common/troublesome character definitions
+ */
+#define L_BRACE '{'
+#define R_BRACE '}'
+#define S_QUOTE '\''
+
+/*
+ * Structure for palette tables
+ */
+
+typedef struct
+{
+ short red, green, blue;
+}
+color_t;
+
+#define MAXCOLUMNS 135
+#define MAXLINES 66
+#define FIFO_SIZE MAXCOLUMNS+2 /* for nocbreak mode input */
+
+#define ACS_LEN 128
+
+#define WINDOWLIST struct _win_list
+
+#include <curses.h> /* we'll use -Ipath directive to get the right one! */
+
+/*
+ * Structure for soft labels.
+ */
+
+typedef struct
+{
+ char *text; /* text for the label */
+ char *form_text; /* formatted text (left/center/...) */
+ int x; /* x coordinate of this field */
+ char dirty; /* this label has changed */
+ char visible; /* field is visible */
+} slk_ent;
+
+typedef struct {
+ char dirty; /* all labels have changed */
+ char hidden; /* soft labels are hidden */
+ struct _win_st *win;
+ slk_ent *ent;
+ char* buffer; /* buffer for labels */
+ short maxlab; /* number of available labels */
+ short labcnt; /* number of allocated labels */
+ short maxlen; /* length of labels */
+ chtype attr; /* soft label attribute */
+} SLK;
+
+struct screen {
+ int _ifd; /* input file ptr for screen */
+ FILE *_ofp; /* output file ptr for screen */
+ char *_setbuf; /* buffered I/O for output */
+ int _buffered; /* setvbuf uses _setbuf data */
+ int _checkfd; /* filedesc for typeahead check */
+ struct term *_term; /* terminal type information */
+ short _lines; /* screen lines */
+ short _columns; /* screen columns */
+ short _lines_avail; /* lines available for stdscr */
+ short _topstolen; /* lines stolen from top */
+
+ WINDOW *_curscr; /* current screen */
+ WINDOW *_newscr; /* virtual screen to be updated to */
+ WINDOW *_stdscr; /* screen's full-window context */
+
+ struct tries *_keytry; /* "Try" for use with keypad mode */
+ struct tries *_key_ok; /* Disabled keys via keyok(,FALSE) */
+ int _tried; /* keypad mode was initialized */
+
+ unsigned int _fifo[FIFO_SIZE]; /* input push-back buffer */
+ short _fifohead, /* head of fifo queue */
+ _fifotail, /* tail of fifo queue */
+ _fifopeek, /* where to peek for next char */
+ _fifohold; /* set if breakout marked */
+
+ int _endwin; /* are we out of window mode? */
+ unsigned long _current_attr; /* terminal attribute current set */
+ int _coloron; /* is color enabled? */
+ int _cursor; /* visibility of the cursor */
+ int _cursrow; /* physical cursor row */
+ int _curscol; /* physical cursor column */
+ int _nl; /* True if NL -> CR/NL is on */
+ int _raw; /* True if in raw mode */
+ int _cbreak; /* 1 if in cbreak mode */
+ /* > 1 if in halfdelay mode */
+ int _echo; /* True if echo on */
+ int _use_meta; /* use the meta key? */
+ SLK *_slk; /* ptr to soft key struct / NULL */
+ int slk_format; /* selected format for this screen */
+ /* cursor movement costs; units are 10ths of milliseconds */
+#ifdef NCURSES_NO_PADDING
+ int _no_padding; /* flag to set if padding disabled */
+#endif
+ int _char_padding; /* cost of character put */
+ int _cr_cost; /* cost of (carriage_return) */
+ int _cup_cost; /* cost of (cursor_address) */
+ int _home_cost; /* cost of (cursor_home) */
+ int _ll_cost; /* cost of (cursor_to_ll) */
+#if USE_HARD_TABS
+ int _ht_cost; /* cost of (tab) */
+ int _cbt_cost; /* cost of (backtab) */
+#endif /* USE_HARD_TABS */
+ int _cub1_cost; /* cost of (cursor_left) */
+ int _cuf1_cost; /* cost of (cursor_right) */
+ int _cud1_cost; /* cost of (cursor_down) */
+ int _cuu1_cost; /* cost of (cursor_up) */
+ int _cub_cost; /* cost of (parm_cursor_left) */
+ int _cuf_cost; /* cost of (parm_cursor_right) */
+ int _cud_cost; /* cost of (parm_cursor_down) */
+ int _cuu_cost; /* cost of (parm_cursor_up) */
+ int _hpa_cost; /* cost of (column_address) */
+ int _vpa_cost; /* cost of (row_address) */
+ /* used in lib_doupdate.c, must be chars */
+ int _ed_cost; /* cost of (clr_eos) */
+ int _el_cost; /* cost of (clr_eol) */
+ int _el1_cost; /* cost of (clr_bol) */
+ int _dch1_cost; /* cost of (delete_character) */
+ int _ich1_cost; /* cost of (insert_character) */
+ int _dch_cost; /* cost of (parm_dch) */
+ int _ich_cost; /* cost of (parm_ich) */
+ int _ech_cost; /* cost of (erase_chars) */
+ int _rep_cost; /* cost of (repeat_char) */
+ int _hpa_ch_cost; /* cost of (column_address) */
+ int _cup_ch_cost; /* cost of (cursor_address) */
+ int _smir_cost; /* cost of (enter_insert_mode) */
+ int _rmir_cost; /* cost of (exit_insert_mode) */
+ int _ip_cost; /* cost of (insert_padding) */
+ /* used in lib_mvcur.c */
+ char * _address_cursor;
+ int _carriage_return_length;
+ int _cursor_home_length;
+ int _cursor_to_ll_length;
+ int _scrolling; /* 1 if terminal's smart enough to */
+
+ /* used in lib_color.c */
+ color_t *_color_table; /* screen's color palette */
+ int _color_count; /* count of colors in palette */
+ unsigned short *_color_pairs; /* screen's color pair list */
+ int _pair_count; /* count of color pairs */
+ int _default_color; /* use default colors */
+ chtype _xmc_suppress; /* attributes to suppress if xmc */
+ chtype _xmc_triggers; /* attributes to process if xmc */
+ chtype _acs_map[ACS_LEN];
+
+ /* used in lib_vidattr.c */
+ bool _use_rmso; /* true if we may use 'rmso' */
+ bool _use_rmul; /* true if we may use 'rmul' */
+
+ /*
+ * These data correspond to the state of the idcok() and idlok()
+ * functions. A caveat is in order here: the XSI and SVr4
+ * documentation specify that these functions apply to the window which
+ * is given as an argument. However, ncurses implements this logic
+ * only for the newscr/curscr update process, _not_ per-window.
+ */
+ bool _nc_sp_idlok;
+ bool _nc_sp_idcok;
+#define _nc_idlok SP->_nc_sp_idlok
+#define _nc_idcok SP->_nc_sp_idcok
+
+ /*
+ * These are the data that support the mouse interface.
+ */
+ int _maxclick;
+ bool (*_mouse_event) (SCREEN *);
+ bool (*_mouse_inline)(SCREEN *);
+ bool (*_mouse_parse) (int);
+ void (*_mouse_resume)(SCREEN *);
+ void (*_mouse_wrap) (SCREEN *);
+ int _mouse_fd; /* file-descriptor, if any */
+
+ /*
+ * This supports automatic resizing
+ */
+#if USE_SIZECHANGE
+ int (*_resize)(int,int);
+#endif
+
+ /*
+ * These are data that support the proper handling of the panel stack on an
+ * per screen basis.
+ */
+ struct panelhook _panelHook;
+ /*
+ * Linked-list of all windows, to support '_nc_resizeall()' and
+ * '_nc_freeall()'
+ */
+ WINDOWLIST *_nc_sp_windows;
+#define _nc_windows SP->_nc_sp_windows
+
+ bool _sig_winch;
+ SCREEN *_next_screen;
+
+ /* hashes for old and new lines */
+ unsigned long *oldhash, *newhash;
+};
+
+extern SCREEN *_nc_screen_chain;
+
+#ifdef NCURSES_NOMACROS
+#include <nomacros.h>
+#endif
+
+ WINDOWLIST {
+ WINDOWLIST *next;
+ WINDOW *win;
+};
+
+typedef struct {
+ int line; /* lines to take, < 0 => from bottom*/
+ int (*hook)(struct _win_st *, int); /* callback for user */
+ struct _win_st *w; /* maybe we need this for cleanup */
+} ripoff_t;
+
+/* The terminfo source is assumed to be 7-bit ASCII */
+#define is7bits(c) ((unsigned)(c) < 128)
+
+#ifndef min
+#define min(a,b) ((a) > (b) ? (b) : (a))
+#endif
+
+#ifndef max
+#define max(a,b) ((a) < (b) ? (b) : (a))
+#endif
+
+/* usually in <unistd.h> */
+#ifndef STDIN_FILENO
+#define STDIN_FILENO 0
+#endif
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS 0
+#endif
+
+#ifndef EXIT_FAILURE
+#define EXIT_FAILURE 1
+#endif
+
+#ifndef R_OK
+#define R_OK 4 /* Test for read permission. */
+#endif
+#ifndef W_OK
+#define W_OK 2 /* Test for write permission. */
+#endif
+#ifndef X_OK
+#define X_OK 1 /* Test for execute permission. */
+#endif
+#ifndef F_OK
+#define F_OK 0 /* Test for existence. */
+#endif
+
+#define TextOf(c) ((c) & (chtype)A_CHARTEXT)
+#define AttrOf(c) ((c) & (chtype)A_ATTRIBUTES)
+
+#define BLANK (' '|A_NORMAL)
+
+#define CHANGED -1
+
+#define CHANGED_CELL(line,col) \
+ if (line->firstchar == _NOCHANGE) \
+ line->firstchar = line->lastchar = col; \
+ else if ((col) < line->firstchar) \
+ line->firstchar = col; \
+ else if ((col) > line->lastchar) \
+ line->lastchar = col
+
+#define CHANGED_RANGE(line,start,end) \
+ if (line->firstchar == _NOCHANGE \
+ || line->firstchar > (start)) \
+ line->firstchar = start; \
+ if (line->lastchar == _NOCHANGE \
+ || line->lastchar < (end)) \
+ line->lastchar = end
+
+#define CHANGED_TO_EOL(line,start,end) \
+ if (line->firstchar == _NOCHANGE \
+ || line->firstchar > (start)) \
+ line->firstchar = start; \
+ line->lastchar = end
+
+#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
+#define typeMalloc(type,elts) (type *)malloc((elts)*sizeof(type))
+#define typeCalloc(type,elts) (type *)calloc((elts),sizeof(type))
+#define typeRealloc(type,elts,ptr) (type *)_nc_doalloc(ptr, (elts)*sizeof(type))
+#define FreeIfNeeded(p) if(p != 0) free(p)
+#define FreeAndNull(p) free(p); p = 0
+
+#include <nc_alloc.h>
+
+/*
+ * Prefixes for call/return points of library function traces. We use these to
+ * instrument the public functions so that the traces can be easily transformed
+ * into regression scripts.
+ */
+#define T_CALLED(fmt) "called " fmt
+#define T_CREATE(fmt) "create " fmt
+#define T_RETURN(fmt) "return " fmt
+
+#ifdef TRACE
+#define TR(n, a) if (_nc_tracing & (n)) _tracef a
+#define T(a) TR(TRACE_CALLS, a)
+#define TPUTS_TRACE(s) _nc_tputs_trace = s;
+#define TRACE_RETURN(value,type) return _nc_retrace_##type(value)
+#define returnAttr(code) TRACE_RETURN(code,attr_t)
+#define returnCode(code) TRACE_RETURN(code,int)
+#define returnPtr(code) TRACE_RETURN(code,ptr)
+#define returnVoid T((T_RETURN(""))); return
+#define returnWin(code) TRACE_RETURN(code,win)
+extern WINDOW * _nc_retrace_win(WINDOW *);
+extern attr_t _nc_retrace_attr_t(attr_t);
+extern char *_nc_retrace_ptr(char *);
+extern const char *_nc_tputs_trace;
+extern int _nc_retrace_int(int);
+extern long _nc_outchars;
+extern void _nc_fifo_dump(void);
+#else
+#define T(a)
+#define TR(n, a)
+#define TPUTS_TRACE(s)
+#define returnAttr(code) return code
+#define returnCode(code) return code
+#define returnPtr(code) return code
+#define returnVoid return
+#define returnWin(code) return code
+#endif
+
+extern unsigned _nc_tracing;
+extern const char *_nc_visbuf2(int, const char *);
+
+#define _trace_key(ch) ((ch > KEY_MIN) ? keyname(ch) : _tracechar((unsigned char)ch))
+
+#define ALL_BUT_COLOR ((chtype)~(A_COLOR))
+#define IGNORE_COLOR_OFF FALSE
+#define NONBLANK_ATTR (A_BOLD|A_DIM|A_BLINK)
+#define XMC_CHANGES(c) ((c) & SP->_xmc_suppress)
+
+
+#define toggle_attr_on(S,at) \
+ if (PAIR_NUMBER(at) > 0)\
+ (S) = ((S) & ALL_BUT_COLOR) | (at);\
+ else\
+ (S) |= (at);\
+ T(("new attribute is %s", _traceattr((S))))
+
+
+#define toggle_attr_off(S,at) \
+ if (IGNORE_COLOR_OFF == TRUE) {\
+ if (PAIR_NUMBER(at) == 0xff) /* turn off color */\
+ (S) &= ~(at);\
+ else /* leave color alone */\
+ (S) &= ~((at)&ALL_BUT_COLOR);\
+ } else {\
+ if (PAIR_NUMBER(at) > 0x00) /* turn off color */\
+ (S) &= ~(at|A_COLOR);\
+ else /* leave color alone */\
+ (S) &= ~(at);\
+ }\
+ T(("new attribute is %s", _traceattr((S))));
+
+#define DelCharCost(count) \
+ ((parm_dch != 0) \
+ ? SP->_dch_cost \
+ : ((delete_character != 0) \
+ ? (SP->_dch1_cost * count) \
+ : INFINITY))
+
+#define InsCharCost(count) \
+ ((parm_ich != 0) \
+ ? SP->_ich_cost \
+ : ((enter_insert_mode && exit_insert_mode) \
+ ? SP->_smir_cost + SP->_rmir_cost + (SP->_ip_cost * count) \
+ : ((insert_character != 0) \
+ ? (SP->_ich1_cost * count) \
+ : INFINITY)))
+
+#if USE_XMC_SUPPORT
+#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) { \
+ attr_t chg = SP->_current_attr; \
+ vidattr(AttrOf(c)); \
+ if (magic_cookie_glitch > 0 \
+ && XMC_CHANGES((chg ^ SP->_current_attr))) { \
+ T(("%s @%d before glitch %d,%d", \
+ __FILE__, __LINE__, \
+ SP->_cursrow, \
+ SP->_curscol)); \
+ _nc_do_xmc_glitch(chg); \
+ } \
+ }
+#else
+#define UpdateAttrs(c) if (SP->_current_attr != AttrOf(c)) \
+ vidattr(AttrOf(c));
+#endif
+
+/*
+ * Check whether the given character can be output by clearing commands. This
+ * includes test for being a space and not including any 'bad' attributes, such
+ * as A_REVERSE. All attribute flags which don't affect appearance of a space
+ * or can be output by clearing (A_COLOR in case of bce-terminal) are excluded.
+ */
+#define can_clear_with(ch) \
+ ((ch & ~(NONBLANK_ATTR|(back_color_erase ? A_COLOR:0))) == BLANK)
+
+#ifdef NCURSES_EXPANDED
+
+#undef toggle_attr_on
+#define toggle_attr_on(S,at) _nc_toggle_attr_on(&(S), at)
+extern void _nc_toggle_attr_on(attr_t *, attr_t);
+
+#undef toggle_attr_off
+#define toggle_attr_off(S,at) _nc_toggle_attr_off(&(S), at)
+extern void _nc_toggle_attr_off(attr_t *, attr_t);
+
+#undef can_clear_with
+#define can_clear_with(ch) _nc_can_clear_with(ch)
+extern int _nc_can_clear_with(chtype);
+
+#undef DelCharCost
+#define DelCharCost(count) _nc_DelCharCost(count)
+extern int _nc_DelCharCost(int);
+
+#undef InsCharCost
+#define InsCharCost(count) _nc_InsCharCost(count)
+extern int _nc_InsCharCost(int);
+
+#undef UpdateAttrs
+#define UpdateAttrs(c) _nc_UpdateAttrs(c)
+extern void _nc_UpdateAttrs(chtype);
+
+#else
+
+extern void _nc_expanded(void);
+
+#endif
+
+#if !HAVE_GETCWD
+#define getcwd(buf,len) getwd(buf)
+#endif
+
+/* doalloc.c */
+extern void *_nc_doalloc(void *, size_t);
+#if !HAVE_STRDUP
+#define strdup _nc_strdup
+extern char *_nc_strdup(const char *);
+#endif
+
+/* doupdate.c */
+#if USE_XMC_SUPPORT
+extern void _nc_do_xmc_glitch(attr_t);
+#endif
+
+/* hardscroll.c */
+#if defined(TRACE) || defined(SCROLLDEBUG) || defined(HASHDEBUG)
+extern void _nc_linedump(void);
+#endif
+
+/* lib_acs.c */
+extern void _nc_init_acs(void); /* corresponds to traditional 'init_acs()' */
+extern int _nc_msec_cost(const char *const, int); /* used by 'tack' program */
+
+/* lib_mvcur.c */
+#define INFINITY 1000000 /* cost: too high to use */
+
+extern void _nc_mvcur_init(void);
+extern void _nc_mvcur_resume(void);
+extern void _nc_mvcur_wrap(void);
+
+extern int _nc_scrolln(int, int, int, int);
+
+extern void _nc_screen_init(void);
+extern void _nc_screen_resume(void);
+extern void _nc_screen_wrap(void);
+
+#if !HAVE_STRSTR
+#define strstr _nc_strstr
+extern char *_nc_strstr(const char *, const char *);
+#endif
+
+/* lib_mouse.c */
+extern int _nc_has_mouse(void);
+
+/* safe_sprintf.c */
+extern char * _nc_printf_string(const char *fmt, va_list ap);
+
+/* tries.c */
+extern void _nc_add_to_try(struct tries **tree, char *str, unsigned short code);
+extern char *_nc_expand_try(struct tries *tree, unsigned short code, int *count, size_t len);
+extern int _nc_remove_key(struct tries **tree, unsigned short code);
+extern int _nc_remove_string(struct tries **tree, char *string);
+
+/* elsewhere ... */
+extern WINDOW *_nc_makenew(int, int, int, int, int);
+extern char *_nc_home_terminfo(void);
+extern char *_nc_trace_buf(int, size_t);
+extern chtype _nc_background(WINDOW *);
+extern chtype _nc_render(WINDOW *, chtype);
+extern int _nc_access(const char *, int);
+extern int _nc_baudrate(int);
+extern int _nc_getenv_num(const char *);
+extern int _nc_keypad(bool);
+extern int _nc_ospeed(int);
+extern int _nc_outch(int);
+extern int _nc_setupscreen(short, short const, FILE *);
+extern int _nc_timed_wait(int, int, int *);
+extern int _nc_waddch_nosync(WINDOW *, const chtype);
+extern void _nc_do_color(int, bool, int (*)(int));
+extern void _nc_freeall(void);
+extern void _nc_freewin(WINDOW *win);
+extern void _nc_hash_map(void);
+extern void _nc_init_keytry(void);
+extern void _nc_keep_tic_dir(const char *);
+extern void _nc_make_oldhash(int i);
+extern void _nc_outstr(const char *str);
+extern void _nc_scroll_oldhash(int n, int top, int bot);
+extern void _nc_scroll_optimize(void);
+extern void _nc_scroll_window(WINDOW *, int const, short const, short const, chtype);
+extern void _nc_set_buffer(FILE *ofp, bool buffered);
+extern void _nc_signal_handler(bool);
+extern void _nc_synchook(WINDOW *win);
+extern void _nc_trace_tries(struct tries *tree);
+
+#if USE_SIZECHANGE
+extern void _nc_update_screensize(void);
+#endif
+
+/* scroll indices */
+extern int *_nc_oldnums;
+
+#define USE_SETBUF_0 0
+
+#define NC_BUFFERED(flag) \
+ if ((SP->_buffered != 0) != flag) \
+ _nc_set_buffer(SP->_ofp, flag)
+
+/*
+ * On systems with a broken linker, define 'SP' as a function to force the
+ * linker to pull in the data-only module with 'SP'.
+ */
+#ifndef BROKEN_LINKER
+#define BROKEN_LINKER 0
+#endif
+
+#if BROKEN_LINKER
+#define SP _nc_screen()
+extern SCREEN *_nc_screen(void);
+extern int _nc_alloc_screen(void);
+extern void _nc_set_screen(SCREEN *);
+#else
+/* current screen is private data; avoid possible linking conflicts too */
+extern SCREEN *SP;
+#define _nc_alloc_screen() ((SP = typeCalloc(SCREEN, 1)) != 0)
+#define _nc_set_screen(sp) SP = sp
+#endif
+
+/*
+ * We don't want to use the lines or columns capabilities internally,
+ * because if the application is running multiple screens under
+ * X windows, it's quite possible they could all have type xterm
+ * but have different sizes! So...
+ */
+#define screen_lines SP->_lines
+#define screen_columns SP->_columns
+
+extern int _nc_slk_format; /* != 0 if slk_init() called */
+extern int _nc_slk_initialize(WINDOW *, int);
+
+/*
+ * Some constants related to SLK's
+ */
+#define MAX_SKEY_OLD 8 /* count of soft keys */
+#define MAX_SKEY_LEN_OLD 8 /* max length of soft key text */
+#define MAX_SKEY_PC 12 /* This is what most PC's have */
+#define MAX_SKEY_LEN_PC 5
+
+/* Macro to check whether or not we use a standard format */
+#define SLK_STDFMT(fmt) (fmt < 3)
+/* Macro to determine height of label window */
+#define SLK_LINES(fmt) (SLK_STDFMT(fmt) ? 1 : ((fmt) - 2))
+
+#define MAX_SKEY(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_OLD : MAX_SKEY_PC)
+#define MAX_SKEY_LEN(fmt) (SLK_STDFMT(fmt)? MAX_SKEY_LEN_OLD : MAX_SKEY_LEN_PC)
+
+extern int _nc_ripoffline(int line, int (*init)(WINDOW *,int));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CURSES_PRIV_H */
diff --git a/contrib/ncurses/ncurses/fifo_defs.h b/contrib/ncurses/ncurses/fifo_defs.h
new file mode 100644
index 000000000000..f4dd7be324f5
--- /dev/null
+++ b/contrib/ncurses/ncurses/fifo_defs.h
@@ -0,0 +1,59 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+/*
+ * Common macros for lib_getch.c, lib_ungetch.c
+ *
+ * $Id: fifo_defs.h,v 1.2 1998/02/11 12:13:56 tom Exp $
+ */
+
+#ifndef FIFO_DEFS_H
+#define FIFO_DEFS_H 1
+
+#define head SP->_fifohead
+#define tail SP->_fifotail
+/* peek points to next uninterpreted character */
+#define peek SP->_fifopeek
+
+#define h_inc() { head == FIFO_SIZE-1 ? head = 0 : head++; if (head == tail) head = -1, tail = 0;}
+#define h_dec() { head == 0 ? head = FIFO_SIZE-1 : head--; if (head == tail) tail = -1;}
+#define t_inc() { tail == FIFO_SIZE-1 ? tail = 0 : tail++; if (tail == head) tail = -1;}
+#define t_dec() { tail == 0 ? tail = FIFO_SIZE-1 : tail--; if (head == tail) fifo_clear();}
+#define p_inc() { peek == FIFO_SIZE-1 ? peek = 0 : peek++;}
+
+#define cooked_key_in_fifo() (head!=-1 && peek!=head)
+#define raw_key_in_fifo() (head!=-1 && peek!=tail)
+
+#undef HIDE_EINTR
+
+#endif /* FIFO_DEFS_H */
diff --git a/contrib/ncurses/ncurses/llib-lncurses b/contrib/ncurses/ncurses/llib-lncurses
new file mode 100644
index 000000000000..c30c6eb1cb9d
--- /dev/null
+++ b/contrib/ncurses/ncurses/llib-lncurses
@@ -0,0 +1,2868 @@
+/****************************************************************************
+ * Copyright (c) 1998,1999 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998,1999 *
+ ****************************************************************************/
+/* LINTLIBRARY */
+
+/* ./tty/hardscroll.c */
+
+#include <curses.priv.h>
+
+#undef _nc_oldnums
+int *_nc_oldnums;
+
+#undef _nc_scroll_optimize
+void _nc_scroll_optimize(void)
+ { /* void */ }
+
+/* ./tty/hashmap.c */
+
+#include <term.h>
+
+typedef struct
+{
+ unsigned long hashval;
+ int oldcount, newcount;
+ int oldindex, newindex;
+}
+ sym;
+
+#undef _nc_hash_map
+void _nc_hash_map(void)
+ { /* void */ }
+
+#undef _nc_make_oldhash
+void _nc_make_oldhash(
+ int i)
+ { /* void */ }
+
+#undef _nc_scroll_oldhash
+void _nc_scroll_oldhash(
+ int n,
+ int top,
+ int bot)
+ { /* void */ }
+
+/* ./base/lib_addch.c */
+
+#include <ctype.h>
+
+#undef _nc_background
+chtype _nc_background(
+ WINDOW *win)
+ { return(*(chtype *)0); }
+
+#undef _nc_render
+chtype _nc_render(
+ WINDOW *win,
+ chtype ch)
+ { return(*(chtype *)0); }
+
+#undef _nc_waddch_nosync
+int _nc_waddch_nosync(
+ WINDOW *win,
+ const chtype c)
+ { return(*(int *)0); }
+
+#undef waddch
+int waddch(
+ WINDOW *win,
+ const chtype ch)
+ { return(*(int *)0); }
+
+#undef wechochar
+int wechochar(
+ WINDOW *win,
+ const chtype ch)
+ { return(*(int *)0); }
+
+/* ./base/lib_addstr.c */
+
+#undef waddnstr
+int waddnstr(
+ WINDOW *win,
+ const char *const astr,
+ int n)
+ { return(*(int *)0); }
+
+#undef waddchnstr
+int waddchnstr(
+ WINDOW *win,
+ const chtype *const astr,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_beep.c */
+
+#undef beep
+int beep(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_bkgd.c */
+
+#undef wbkgdset
+void wbkgdset(
+ WINDOW *win,
+ chtype ch)
+ { /* void */ }
+
+#undef wbkgd
+int wbkgd(
+ WINDOW *win,
+ const chtype ch)
+ { return(*(int *)0); }
+
+/* ./base/lib_box.c */
+
+#undef wborder
+int wborder(
+ WINDOW *win,
+ chtype ls,
+ chtype rs,
+ chtype ts,
+ chtype bs,
+ chtype tl,
+ chtype tr,
+ chtype bl,
+ chtype br)
+ { return(*(int *)0); }
+
+/* ./base/lib_chgat.c */
+
+#undef wchgat
+int wchgat(
+ WINDOW *win,
+ int n,
+ attr_t attr,
+ short color,
+ const void *opts)
+ { return(*(int *)0); }
+
+/* ./base/lib_clear.c */
+
+#undef wclear
+int wclear(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_clearok.c */
+
+#undef clearok
+int clearok(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./base/lib_clrbot.c */
+
+#undef wclrtobot
+int wclrtobot(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_clreol.c */
+
+#undef wclrtoeol
+int wclrtoeol(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_color.c */
+
+#undef COLOR_PAIRS
+int COLOR_PAIRS;
+#undef COLORS
+int COLORS;
+
+#undef start_color
+int start_color(void)
+ { return(*(int *)0); }
+
+#undef init_pair
+int init_pair(
+ short pair,
+ short f,
+ short b)
+ { return(*(int *)0); }
+
+#undef init_color
+int init_color(
+ short color,
+ short r,
+ short g,
+ short b)
+ { return(*(int *)0); }
+
+#undef can_change_color
+bool can_change_color(void)
+ { return(*(bool *)0); }
+
+#undef has_colors
+bool has_colors(void)
+ { return(*(bool *)0); }
+
+#undef color_content
+int color_content(
+ short color,
+ short *r,
+ short *g,
+ short *b)
+ { return(*(int *)0); }
+
+#undef pair_content
+int pair_content(
+ short pair,
+ short *f,
+ short *b)
+ { return(*(int *)0); }
+
+#undef _nc_do_color
+void _nc_do_color(
+ int pair,
+ bool reverse,
+ int (*outc)(
+ int p1))
+ { /* void */ }
+
+/* ./base/lib_colorset.c */
+
+#undef wcolor_set
+int wcolor_set(
+ WINDOW *win,
+ short color_pair_number,
+ void *opts)
+ { return(*(int *)0); }
+
+/* ./base/lib_delch.c */
+
+#undef wdelch
+int wdelch(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_delwin.c */
+
+#undef delwin
+int delwin(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_echo.c */
+
+#undef echo
+int echo(void)
+ { return(*(int *)0); }
+
+#undef noecho
+int noecho(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_endwin.c */
+
+#undef endwin
+int endwin(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_erase.c */
+
+#undef werase
+int werase(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_flash.c */
+
+#undef flash
+int flash(void)
+ { return(*(int *)0); }
+
+/* ./lib_gen.c */
+
+#undef addch
+int addch(
+ const chtype z)
+ { return(*(int *)0); }
+
+#undef addchnstr
+int addchnstr(
+ const chtype *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef addchstr
+int addchstr(
+ const chtype *z)
+ { return(*(int *)0); }
+
+#undef addnstr
+int addnstr(
+ const char *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef addstr
+int addstr(
+ const char *z)
+ { return(*(int *)0); }
+
+#undef attroff
+int attroff(
+ NCURSES_ATTR_T z)
+ { return(*(int *)0); }
+
+#undef attron
+int attron(
+ NCURSES_ATTR_T z)
+ { return(*(int *)0); }
+
+#undef attrset
+int attrset(
+ NCURSES_ATTR_T z)
+ { return(*(int *)0); }
+
+#undef attr_get
+int attr_get(
+ attr_t *a1,
+ short *a2,
+ void *z)
+ { return(*(int *)0); }
+
+#undef attr_off
+int attr_off(
+ attr_t a1,
+ void *z)
+ { return(*(int *)0); }
+
+#undef attr_on
+int attr_on(
+ attr_t a1,
+ void *z)
+ { return(*(int *)0); }
+
+#undef attr_set
+int attr_set(
+ attr_t a1,
+ short a2,
+ void *z)
+ { return(*(int *)0); }
+
+#undef bkgd
+int bkgd(
+ chtype z)
+ { return(*(int *)0); }
+
+#undef bkgdset
+void bkgdset(
+ chtype z)
+ { /* void */ }
+
+#undef border
+int border(
+ chtype a1,
+ chtype a2,
+ chtype a3,
+ chtype a4,
+ chtype a5,
+ chtype a6,
+ chtype a7,
+ chtype z)
+ { return(*(int *)0); }
+
+#undef box
+int box(
+ WINDOW *a1,
+ chtype a2,
+ chtype z)
+ { return(*(int *)0); }
+
+#undef chgat
+int chgat(
+ int a1,
+ attr_t a2,
+ short a3,
+ const void *z)
+ { return(*(int *)0); }
+
+#undef clear
+int clear(void)
+ { return(*(int *)0); }
+
+#undef clrtobot
+int clrtobot(void)
+ { return(*(int *)0); }
+
+#undef clrtoeol
+int clrtoeol(void)
+ { return(*(int *)0); }
+
+#undef color_set
+int color_set(
+ short a1,
+ void *z)
+ { return(*(int *)0); }
+
+#undef COLOR_PAIR
+int COLOR_PAIR(
+ int z)
+ { return(*(int *)0); }
+
+#undef delch
+int delch(void)
+ { return(*(int *)0); }
+
+#undef deleteln
+int deleteln(void)
+ { return(*(int *)0); }
+
+#undef echochar
+int echochar(
+ const chtype z)
+ { return(*(int *)0); }
+
+#undef getbkgd
+chtype getbkgd(
+ WINDOW *z)
+ { return(*(chtype *)0); }
+
+#undef getch
+int getch(void)
+ { return(*(int *)0); }
+
+#undef getnstr
+int getnstr(
+ char *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef getstr
+int getstr(
+ char *z)
+ { return(*(int *)0); }
+
+#undef hline
+int hline(
+ chtype a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef inch
+chtype inch(void)
+ { return(*(chtype *)0); }
+
+#undef inchnstr
+int inchnstr(
+ chtype *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef inchstr
+int inchstr(
+ chtype *z)
+ { return(*(int *)0); }
+
+#undef innstr
+int innstr(
+ char *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef insch
+int insch(
+ chtype z)
+ { return(*(int *)0); }
+
+#undef insdelln
+int insdelln(
+ int z)
+ { return(*(int *)0); }
+
+#undef insertln
+int insertln(void)
+ { return(*(int *)0); }
+
+#undef insnstr
+int insnstr(
+ const char *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef insstr
+int insstr(
+ const char *z)
+ { return(*(int *)0); }
+
+#undef instr
+int instr(
+ char *z)
+ { return(*(int *)0); }
+
+#undef move
+int move(
+ int a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvaddch
+int mvaddch(
+ int a1,
+ int a2,
+ const chtype z)
+ { return(*(int *)0); }
+
+#undef mvaddchnstr
+int mvaddchnstr(
+ int a1,
+ int a2,
+ const chtype *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvaddchstr
+int mvaddchstr(
+ int a1,
+ int a2,
+ const chtype *z)
+ { return(*(int *)0); }
+
+#undef mvaddnstr
+int mvaddnstr(
+ int a1,
+ int a2,
+ const char *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvaddstr
+int mvaddstr(
+ int a1,
+ int a2,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef mvchgat
+int mvchgat(
+ int a1,
+ int a2,
+ int a3,
+ attr_t a4,
+ short a5,
+ const void *z)
+ { return(*(int *)0); }
+
+#undef mvdelch
+int mvdelch(
+ int a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvgetch
+int mvgetch(
+ int a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvgetnstr
+int mvgetnstr(
+ int a1,
+ int a2,
+ char *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvgetstr
+int mvgetstr(
+ int a1,
+ int a2,
+ char *z)
+ { return(*(int *)0); }
+
+#undef mvhline
+int mvhline(
+ int a1,
+ int a2,
+ chtype a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvinch
+chtype mvinch(
+ int a1,
+ int z)
+ { return(*(chtype *)0); }
+
+#undef mvinchnstr
+int mvinchnstr(
+ int a1,
+ int a2,
+ chtype *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvinchstr
+int mvinchstr(
+ int a1,
+ int a2,
+ chtype *z)
+ { return(*(int *)0); }
+
+#undef mvinnstr
+int mvinnstr(
+ int a1,
+ int a2,
+ char *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvinsch
+int mvinsch(
+ int a1,
+ int a2,
+ chtype z)
+ { return(*(int *)0); }
+
+#undef mvinsnstr
+int mvinsnstr(
+ int a1,
+ int a2,
+ const char *a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvinsstr
+int mvinsstr(
+ int a1,
+ int a2,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef mvinstr
+int mvinstr(
+ int a1,
+ int a2,
+ char *z)
+ { return(*(int *)0); }
+
+#undef mvvline
+int mvvline(
+ int a1,
+ int a2,
+ chtype a3,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwaddch
+int mvwaddch(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const chtype z)
+ { return(*(int *)0); }
+
+#undef mvwaddchnstr
+int mvwaddchnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const chtype *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwaddchstr
+int mvwaddchstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const chtype *z)
+ { return(*(int *)0); }
+
+#undef mvwaddnstr
+int mvwaddnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const char *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwaddstr
+int mvwaddstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef mvwchgat
+int mvwchgat(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ int a4,
+ attr_t a5,
+ short a6,
+ const void *z)
+ { return(*(int *)0); }
+
+#undef mvwdelch
+int mvwdelch(
+ WINDOW *a1,
+ int a2,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwgetch
+int mvwgetch(
+ WINDOW *a1,
+ int a2,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwgetnstr
+int mvwgetnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ char *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwgetstr
+int mvwgetstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ char *z)
+ { return(*(int *)0); }
+
+#undef mvwhline
+int mvwhline(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ chtype a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwinch
+chtype mvwinch(
+ WINDOW *a1,
+ int a2,
+ int z)
+ { return(*(chtype *)0); }
+
+#undef mvwinchnstr
+int mvwinchnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ chtype *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwinchstr
+int mvwinchstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ chtype *z)
+ { return(*(int *)0); }
+
+#undef mvwinnstr
+int mvwinnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ char *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwinsch
+int mvwinsch(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ chtype z)
+ { return(*(int *)0); }
+
+#undef mvwinsnstr
+int mvwinsnstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const char *a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef mvwinsstr
+int mvwinsstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef mvwinstr
+int mvwinstr(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ char *z)
+ { return(*(int *)0); }
+
+#undef mvwvline
+int mvwvline(
+ WINDOW *a1,
+ int a2,
+ int a3,
+ chtype a4,
+ int z)
+ { return(*(int *)0); }
+
+#undef PAIR_NUMBER
+int PAIR_NUMBER(
+ int z)
+ { return(*(int *)0); }
+
+#undef redrawwin
+int redrawwin(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef refresh
+int refresh(void)
+ { return(*(int *)0); }
+
+#undef scrl
+int scrl(
+ int z)
+ { return(*(int *)0); }
+
+#undef scroll
+int scroll(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef setscrreg
+int setscrreg(
+ int a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef standout
+int standout(void)
+ { return(*(int *)0); }
+
+#undef standend
+int standend(void)
+ { return(*(int *)0); }
+
+#undef timeout
+void timeout(
+ int z)
+ { /* void */ }
+
+#undef untouchwin
+int untouchwin(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef vline
+int vline(
+ chtype a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef vw_printw
+int vw_printw(
+ WINDOW *a1,
+ char *a2,
+ va_list z)
+ { return(*(int *)0); }
+
+#undef vw_scanw
+int vw_scanw(
+ WINDOW *a1,
+ char *a2,
+ va_list z)
+ { return(*(int *)0); }
+
+#undef waddchstr
+int waddchstr(
+ WINDOW *a1,
+ const chtype *z)
+ { return(*(int *)0); }
+
+#undef waddstr
+int waddstr(
+ WINDOW *a1,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef wattron
+int wattron(
+ WINDOW *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef wattroff
+int wattroff(
+ WINDOW *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef wattrset
+int wattrset(
+ WINDOW *a1,
+ int z)
+ { return(*(int *)0); }
+
+#undef wattr_get
+int wattr_get(
+ WINDOW *a1,
+ attr_t *a2,
+ short *a3,
+ void *z)
+ { return(*(int *)0); }
+
+#undef wattr_set
+int wattr_set(
+ WINDOW *a1,
+ attr_t a2,
+ short a3,
+ void *z)
+ { return(*(int *)0); }
+
+#undef wdeleteln
+int wdeleteln(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef wgetstr
+int wgetstr(
+ WINDOW *a1,
+ char *z)
+ { return(*(int *)0); }
+
+#undef winchstr
+int winchstr(
+ WINDOW *a1,
+ chtype *z)
+ { return(*(int *)0); }
+
+#undef winsertln
+int winsertln(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef winsstr
+int winsstr(
+ WINDOW *a1,
+ const char *z)
+ { return(*(int *)0); }
+
+#undef winstr
+int winstr(
+ WINDOW *a1,
+ char *z)
+ { return(*(int *)0); }
+
+#undef wstandout
+int wstandout(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef wstandend
+int wstandend(
+ WINDOW *z)
+ { return(*(int *)0); }
+
+#undef mouse_trafo
+bool mouse_trafo(
+ int *a1,
+ int *a2,
+ bool z)
+ { return(*(bool *)0); }
+
+/* ./base/lib_getch.c */
+
+#include <fifo_defs.h>
+
+#undef ESCDELAY
+int ESCDELAY;
+
+#undef wgetch
+int wgetch(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_getstr.c */
+
+#undef wgetnstr
+int wgetnstr(
+ WINDOW *win,
+ char *str,
+ int maxlen)
+ { return(*(int *)0); }
+
+/* ./base/lib_hline.c */
+
+#undef whline
+int whline(
+ WINDOW *win,
+ chtype ch,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_immedok.c */
+
+#undef immedok
+void immedok(
+ WINDOW *win,
+ bool flag)
+ { /* void */ }
+
+/* ./base/lib_inchstr.c */
+
+#undef winchnstr
+int winchnstr(
+ WINDOW *win,
+ chtype *str,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_initscr.c */
+
+#include <tic.h>
+
+#undef initscr
+WINDOW *initscr(void)
+ { return(*(WINDOW **)0); }
+
+/* ./base/lib_insch.c */
+
+#undef winsch
+int winsch(
+ WINDOW *win,
+ chtype c)
+ { return(*(int *)0); }
+
+/* ./base/lib_insdel.c */
+
+#undef winsdelln
+int winsdelln(
+ WINDOW *win,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_insstr.c */
+
+#undef winsnstr
+int winsnstr(
+ WINDOW *win,
+ const char *s,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_instr.c */
+
+#undef winnstr
+int winnstr(
+ WINDOW *win,
+ char *str,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_isendwin.c */
+
+#undef isendwin
+bool isendwin(void)
+ { return(*(bool *)0); }
+
+/* ./base/lib_leaveok.c */
+
+#undef leaveok
+int leaveok(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./base/lib_mouse.c */
+
+#undef getmouse
+int getmouse(
+ MEVENT *aevent)
+ { return(*(int *)0); }
+
+#undef ungetmouse
+int ungetmouse(
+ MEVENT *aevent)
+ { return(*(int *)0); }
+
+#undef mousemask
+mmask_t mousemask(
+ mmask_t newmask,
+ mmask_t *oldmask)
+ { return(*(mmask_t *)0); }
+
+#undef wenclose
+bool wenclose(
+ const WINDOW *win,
+ int y,
+ int x)
+ { return(*(bool *)0); }
+
+#undef mouseinterval
+int mouseinterval(
+ int maxclick)
+ { return(*(int *)0); }
+
+#undef _nc_has_mouse
+int _nc_has_mouse(void)
+ { return(*(int *)0); }
+
+#undef wmouse_trafo
+bool wmouse_trafo(
+ const WINDOW *win,
+ int *pY,
+ int *pX,
+ bool to_screen)
+ { return(*(bool *)0); }
+
+/* ./base/lib_move.c */
+
+#undef wmove
+int wmove(
+ WINDOW *win,
+ int y,
+ int x)
+ { return(*(int *)0); }
+
+/* ./tty/lib_mvcur.c */
+
+#undef _nc_msec_cost
+int _nc_msec_cost(
+ const char *const cap,
+ int affcnt)
+ { return(*(int *)0); }
+
+#undef _nc_mvcur_resume
+void _nc_mvcur_resume(void)
+ { /* void */ }
+
+#undef _nc_mvcur_init
+void _nc_mvcur_init(void)
+ { /* void */ }
+
+#undef _nc_mvcur_wrap
+void _nc_mvcur_wrap(void)
+ { /* void */ }
+
+#undef mvcur
+int mvcur(
+ int yold,
+ int xold,
+ int ynew,
+ int xnew)
+ { return(*(int *)0); }
+
+/* ./base/lib_mvwin.c */
+
+#undef mvwin
+int mvwin(
+ WINDOW *win,
+ int by,
+ int bx)
+ { return(*(int *)0); }
+
+/* ./base/lib_newterm.c */
+
+#undef filter
+void filter(void)
+ { /* void */ }
+
+#undef newterm
+SCREEN *newterm(
+ char *term,
+ FILE *ofp,
+ FILE *ifp)
+ { return(*(SCREEN **)0); }
+
+/* ./base/lib_newwin.c */
+
+#undef _nc_freewin
+void _nc_freewin(
+ WINDOW *win)
+ { /* void */ }
+
+#undef newwin
+WINDOW *newwin(
+ int num_lines,
+ int num_columns,
+ int begy,
+ int begx)
+ { return(*(WINDOW **)0); }
+
+#undef derwin
+WINDOW *derwin(
+ WINDOW *orig,
+ int num_lines,
+ int num_columns,
+ int begy,
+ int begx)
+ { return(*(WINDOW **)0); }
+
+#undef subwin
+WINDOW *subwin(
+ WINDOW *w,
+ int l,
+ int c,
+ int y,
+ int x)
+ { return(*(WINDOW **)0); }
+
+#undef _nc_makenew
+WINDOW *_nc_makenew(
+ int num_lines,
+ int num_columns,
+ int begy,
+ int begx,
+ int flags)
+ { return(*(WINDOW **)0); }
+
+/* ./base/lib_nl.c */
+
+#undef nl
+int nl(void)
+ { return(*(int *)0); }
+
+#undef nonl
+int nonl(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_overlay.c */
+
+#undef overlay
+int overlay(
+ const WINDOW *win1,
+ WINDOW *win2)
+ { return(*(int *)0); }
+
+#undef overwrite
+int overwrite(
+ const WINDOW *win1,
+ WINDOW *win2)
+ { return(*(int *)0); }
+
+#undef copywin
+int copywin(
+ const WINDOW *src,
+ WINDOW *dst,
+ int sminrow,
+ int smincol,
+ int dminrow,
+ int dmincol,
+ int dmaxrow,
+ int dmaxcol,
+ int over)
+ { return(*(int *)0); }
+
+/* ./base/lib_pad.c */
+
+#undef newpad
+WINDOW *newpad(
+ int l,
+ int c)
+ { return(*(WINDOW **)0); }
+
+#undef subpad
+WINDOW *subpad(
+ WINDOW *orig,
+ int l,
+ int c,
+ int begy,
+ int begx)
+ { return(*(WINDOW **)0); }
+
+#undef prefresh
+int prefresh(
+ WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
+ { return(*(int *)0); }
+
+#undef pnoutrefresh
+int pnoutrefresh(
+ WINDOW *win,
+ int pminrow,
+ int pmincol,
+ int sminrow,
+ int smincol,
+ int smaxrow,
+ int smaxcol)
+ { return(*(int *)0); }
+
+#undef pechochar
+int pechochar(
+ WINDOW *pad,
+ const chtype ch)
+ { return(*(int *)0); }
+
+/* ./base/lib_printw.c */
+
+#undef printw
+int printw(
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef wprintw
+int wprintw(
+ WINDOW *win,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef mvprintw
+int mvprintw(
+ int y,
+ int x,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef mvwprintw
+int mvwprintw(
+ WINDOW *win,
+ int y,
+ int x,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef vwprintw
+int vwprintw(
+ WINDOW *win,
+ char *fmt,
+ va_list argp)
+ { return(*(int *)0); }
+
+/* ./base/lib_redrawln.c */
+
+#undef wredrawln
+int wredrawln(
+ WINDOW *win,
+ int beg,
+ int num)
+ { return(*(int *)0); }
+
+/* ./base/lib_refresh.c */
+
+#undef wrefresh
+int wrefresh(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+#undef wnoutrefresh
+int wnoutrefresh(
+ WINDOW *win)
+ { return(*(int *)0); }
+
+/* ./base/lib_restart.c */
+
+#undef restartterm
+int restartterm(
+ char *term,
+ int filenum,
+ int *errret)
+ { return(*(int *)0); }
+
+/* ./base/lib_scanw.c */
+
+#undef vwscanw
+int vwscanw(
+ WINDOW *win,
+ char *fmt,
+ va_list argp)
+ { return(*(int *)0); }
+
+#undef scanw
+int scanw(
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef wscanw
+int wscanw(
+ WINDOW *win,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef mvscanw
+int mvscanw(
+ int y,
+ int x,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+#undef mvwscanw
+int mvwscanw(
+ WINDOW *win,
+ int y,
+ int x,
+ char *fmt,
+ ...)
+ { return(*(int *)0); }
+
+/* ./base/lib_screen.c */
+
+#include <sys/stat.h>
+#include <time.h>
+
+#undef getwin
+WINDOW *getwin(
+ FILE *filep)
+ { return(*(WINDOW **)0); }
+
+#undef putwin
+int putwin(
+ WINDOW *win,
+ FILE *filep)
+ { return(*(int *)0); }
+
+#undef scr_restore
+int scr_restore(
+ const char *file)
+ { return(*(int *)0); }
+
+#undef scr_dump
+int scr_dump(
+ const char *file)
+ { return(*(int *)0); }
+
+#undef scr_init
+int scr_init(
+ const char *file)
+ { return(*(int *)0); }
+
+#undef scr_set
+int scr_set(
+ const char *file)
+ { return(*(int *)0); }
+
+/* ./base/lib_scroll.c */
+
+#undef _nc_scroll_window
+void _nc_scroll_window(
+ WINDOW *win,
+ int const n,
+ short const top,
+ short const bottom,
+ chtype blank)
+ { /* void */ }
+
+#undef wscrl
+int wscrl(
+ WINDOW *win,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_scrollok.c */
+
+#undef scrollok
+int scrollok(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./base/lib_scrreg.c */
+
+#undef wsetscrreg
+int wsetscrreg(
+ WINDOW *win,
+ int top,
+ int bottom)
+ { return(*(int *)0); }
+
+/* ./base/lib_set_term.c */
+
+#undef set_term
+SCREEN *set_term(
+ SCREEN *screen)
+ { return(*(SCREEN **)0); }
+
+#undef delscreen
+void delscreen(
+ SCREEN *sp)
+ { /* void */ }
+
+#undef _nc_setupscreen
+int _nc_setupscreen(
+ short slines,
+ short const scolumns,
+ FILE *output)
+ { return(*(int *)0); }
+
+#undef _nc_ripoffline
+int _nc_ripoffline(
+ int line,
+ int (*init)(
+ WINDOW *p1,
+ int p2))
+ { return(*(int *)0); }
+
+#undef ripoffline
+int ripoffline(
+ int line,
+ int (*init)(
+ WINDOW *p1,
+ int p2))
+ { return(*(int *)0); }
+
+/* ./base/lib_slk.c */
+
+#undef _nc_slk_format
+int _nc_slk_format;
+
+#undef _nc_slk_initialize
+int _nc_slk_initialize(
+ WINDOW *stwin,
+ int cols)
+ { return(*(int *)0); }
+
+#undef slk_restore
+int slk_restore(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkatr_set.c */
+
+#undef slk_attr_set
+int slk_attr_set(
+ const attr_t attr,
+ short color_pair_number,
+ void *opts)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkatrof.c */
+
+#undef slk_attroff
+int slk_attroff(
+ const chtype attr)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkatron.c */
+
+#undef slk_attron
+int slk_attron(
+ const chtype attr)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkatrset.c */
+
+#undef slk_attrset
+int slk_attrset(
+ const chtype attr)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkattr.c */
+
+#undef slk_attr
+attr_t slk_attr(void)
+ { return(*(attr_t *)0); }
+
+/* ./base/lib_slkclear.c */
+
+#undef slk_clear
+int slk_clear(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkcolor.c */
+
+#undef slk_color
+int slk_color(
+ short color_pair_number)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkinit.c */
+
+#undef slk_init
+int slk_init(
+ int format)
+ { return(*(int *)0); }
+
+/* ./base/lib_slklab.c */
+
+#undef slk_label
+char *slk_label(
+ int n)
+ { return(*(char **)0); }
+
+/* ./base/lib_slkrefr.c */
+
+#undef slk_noutrefresh
+int slk_noutrefresh(void)
+ { return(*(int *)0); }
+
+#undef slk_refresh
+int slk_refresh(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_slkset.c */
+
+#undef slk_set
+int slk_set(
+ int i,
+ const char *astr,
+ int format)
+ { return(*(int *)0); }
+
+/* ./base/lib_slktouch.c */
+
+#undef slk_touch
+int slk_touch(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_touch.c */
+
+#undef is_linetouched
+bool is_linetouched(
+ WINDOW *win,
+ int line)
+ { return(*(bool *)0); }
+
+#undef is_wintouched
+bool is_wintouched(
+ WINDOW *win)
+ { return(*(bool *)0); }
+
+#undef wtouchln
+int wtouchln(
+ WINDOW *win,
+ int y,
+ int n,
+ int changed)
+ { return(*(int *)0); }
+
+/* ./trace/lib_traceatr.c */
+
+#undef _nc_lib_traceatr
+void _nc_lib_traceatr(void)
+ { /* void */ }
+
+/* ./trace/lib_tracedmp.c */
+
+#undef _nc_lib_tracedmp
+void _nc_lib_tracedmp(void)
+ { /* void */ }
+
+/* ./trace/lib_tracemse.c */
+
+#undef _nc_lib_tracemouse
+void _nc_lib_tracemouse(void)
+ { /* void */ }
+
+/* ./tty/lib_tstp.c */
+
+#include <signal.h>
+#include <SigAction.h>
+
+#undef _nc_signal_handler
+void _nc_signal_handler(
+ bool enable)
+ { /* void */ }
+
+/* ./base/lib_ungetch.c */
+
+#undef ungetch
+int ungetch(
+ int ch)
+ { return(*(int *)0); }
+
+/* ./tty/lib_vidattr.c */
+
+#undef vidputs
+int vidputs(
+ attr_t newmode,
+ int (*outc)(
+ int p1))
+ { return(*(int *)0); }
+
+#undef vidattr
+int vidattr(
+ attr_t newmode)
+ { return(*(int *)0); }
+
+#undef termattrs
+chtype termattrs(void)
+ { return(*(chtype *)0); }
+
+/* ./base/lib_vline.c */
+
+#undef wvline
+int wvline(
+ WINDOW *win,
+ chtype ch,
+ int n)
+ { return(*(int *)0); }
+
+/* ./base/lib_wattroff.c */
+
+#undef wattr_off
+int wattr_off(
+ WINDOW *win,
+ attr_t at,
+ void *opts)
+ { return(*(int *)0); }
+
+/* ./base/lib_wattron.c */
+
+#undef wattr_on
+int wattr_on(
+ WINDOW *win,
+ attr_t at,
+ void *opts)
+ { return(*(int *)0); }
+
+/* ./base/lib_winch.c */
+
+#undef winch
+chtype winch(
+ WINDOW *win)
+ { return(*(chtype *)0); }
+
+/* ./base/lib_window.c */
+
+#undef _nc_synchook
+void _nc_synchook(
+ WINDOW *win)
+ { /* void */ }
+
+#undef mvderwin
+int mvderwin(
+ WINDOW *win,
+ int y,
+ int x)
+ { return(*(int *)0); }
+
+#undef syncok
+int syncok(
+ WINDOW *win,
+ bool bf)
+ { return(*(int *)0); }
+
+#undef wsyncup
+void wsyncup(
+ WINDOW *win)
+ { /* void */ }
+
+#undef wsyncdown
+void wsyncdown(
+ WINDOW *win)
+ { /* void */ }
+
+#undef wcursyncup
+void wcursyncup(
+ WINDOW *win)
+ { /* void */ }
+
+#undef dupwin
+WINDOW *dupwin(
+ WINDOW *win)
+ { return(*(WINDOW **)0); }
+
+/* ./base/nc_panel.c */
+
+#undef _nc_panelhook
+struct panelhook *_nc_panelhook(void)
+ { return(*(struct panelhook **)0); }
+
+/* ./base/safe_sprintf.c */
+
+#undef _nc_printf_string
+char *_nc_printf_string(
+ const char *fmt,
+ va_list ap)
+ { return(*(char **)0); }
+
+/* ./tty/tty_update.c */
+
+#include <sys/time.h>
+
+#undef doupdate
+int doupdate(void)
+ { return(*(int *)0); }
+
+#undef _nc_outstr
+void _nc_outstr(
+ const char *str)
+ { /* void */ }
+
+#undef _nc_scrolln
+int _nc_scrolln(
+ int n,
+ int top,
+ int bot,
+ int maxy)
+ { return(*(int *)0); }
+
+#undef _nc_screen_resume
+void _nc_screen_resume(void)
+ { /* void */ }
+
+#undef _nc_screen_init
+void _nc_screen_init(void)
+ { /* void */ }
+
+#undef _nc_screen_wrap
+void _nc_screen_wrap(void)
+ { /* void */ }
+
+#undef _nc_do_xmc_glitch
+void _nc_do_xmc_glitch(
+ attr_t previous)
+ { /* void */ }
+
+/* ./base/memmove.c */
+
+#undef _nc_memmove
+void _nc_memmove(void)
+ { /* void */ }
+
+/* ./base/sigaction.c */
+
+#undef _nc_sigaction
+void _nc_sigaction(void)
+ { /* void */ }
+
+/* ./base/vsscanf.c */
+
+#undef _nc_vsscanf
+void _nc_vsscanf(void)
+ { /* void */ }
+
+/* ./base/define_key.c */
+
+#undef define_key
+int define_key(
+ char *str,
+ int keycode)
+ { return(*(int *)0); }
+
+/* ./expanded.c */
+
+#undef _nc_toggle_attr_on
+void _nc_toggle_attr_on(
+ attr_t *S,
+ attr_t at)
+ { /* void */ }
+
+#undef _nc_toggle_attr_off
+void _nc_toggle_attr_off(
+ attr_t *S,
+ attr_t at)
+ { /* void */ }
+
+#undef _nc_can_clear_with
+int _nc_can_clear_with(
+ chtype ch)
+ { return(*(int *)0); }
+
+#undef _nc_DelCharCost
+int _nc_DelCharCost(
+ int count)
+ { return(*(int *)0); }
+
+#undef _nc_InsCharCost
+int _nc_InsCharCost(
+ int count)
+ { return(*(int *)0); }
+
+#undef _nc_UpdateAttrs
+void _nc_UpdateAttrs(
+ chtype c)
+ { /* void */ }
+
+/* ./base/keybound.c */
+
+#undef keybound
+char *keybound(
+ int code,
+ int count)
+ { return(*(char **)0); }
+
+/* ./base/keyok.c */
+
+#undef keyok
+int keyok(
+ int c,
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./base/lib_dft_fgbg.c */
+
+#undef use_default_colors
+int use_default_colors(void)
+ { return(*(int *)0); }
+
+/* ./base/lib_freeall.c */
+
+#undef _nc_freeall
+void _nc_freeall(void)
+ { /* void */ }
+
+/* ./tinfo/lib_print.c */
+
+#undef mcprint
+int mcprint(
+ char *data,
+ int len)
+ { return(*(int *)0); }
+
+/* ./base/resizeterm.c */
+
+#undef resizeterm
+int resizeterm(
+ int ToLines,
+ int ToCols)
+ { return(*(int *)0); }
+
+/* ./trace/trace_tries.c */
+
+#undef _nc_trace_tries
+void _nc_trace_tries(
+ struct tries *tree)
+ { /* void */ }
+
+/* ./trace/trace_xnames.c */
+
+#include <term_entry.h>
+
+#undef _nc_trace_xnames
+void _nc_trace_xnames(
+ TERMTYPE *tp)
+ { /* void */ }
+
+/* ./base/tries.c */
+
+#undef _nc_expand_try
+char *_nc_expand_try(
+ struct tries *tree,
+ unsigned short code,
+ int *count,
+ size_t len)
+ { return(*(char **)0); }
+
+#undef _nc_remove_key
+int _nc_remove_key(
+ struct tries **tree,
+ unsigned short code)
+ { return(*(int *)0); }
+
+#undef _nc_remove_string
+int _nc_remove_string(
+ struct tries **tree,
+ char *string)
+ { return(*(int *)0); }
+
+/* ./base/wresize.c */
+
+#undef wresize
+int wresize(
+ WINDOW *win,
+ int ToLines,
+ int ToCols)
+ { return(*(int *)0); }
+
+/* ./tinfo/access.c */
+
+#undef _nc_access
+int _nc_access(
+ const char *path,
+ int mode)
+ { return(*(int *)0); }
+
+/* ./tinfo/alloc_entry.c */
+
+#undef _nc_init_entry
+void _nc_init_entry(
+ TERMTYPE *const tp)
+ { /* void */ }
+
+#undef _nc_copy_entry
+ENTRY *_nc_copy_entry(
+ ENTRY *oldp)
+ { return(*(ENTRY **)0); }
+
+#undef _nc_save_str
+char *_nc_save_str(
+ const char *const string)
+ { return(*(char **)0); }
+
+#undef _nc_wrap_entry
+void _nc_wrap_entry(
+ ENTRY *const ep)
+ { /* void */ }
+
+#undef _nc_merge_entry
+void _nc_merge_entry(
+ TERMTYPE *const to,
+ TERMTYPE *const from)
+ { /* void */ }
+
+/* ./tinfo/alloc_ttype.c */
+
+#undef _nc_align_termtype
+void _nc_align_termtype(
+ TERMTYPE *to,
+ TERMTYPE *from)
+ { /* void */ }
+
+#undef _nc_copy_termtype
+void _nc_copy_termtype(
+ TERMTYPE *dst,
+ TERMTYPE *src)
+ { /* void */ }
+
+/* ./tinfo/captoinfo.c */
+
+#undef _nc_captoinfo
+char *_nc_captoinfo(
+ const char *cap,
+ const char *s,
+ int const parametrized)
+ { return(*(char **)0); }
+
+#undef _nc_infotocap
+char *_nc_infotocap(
+ const char *cap,
+ const char *str,
+ int const parametrized)
+ { return(*(char **)0); }
+
+/* ./codes.c */
+
+#undef boolcodes
+char *const boolcodes[] = {0};
+#undef numcodes
+char *const numcodes[] = {0};
+#undef strcodes
+char *const strcodes[] = {0};
+
+/* ./comp_captab.c */
+
+#include <ncurses_cfg.h>
+
+#undef _nc_info_hash_table
+const struct name_table_entry *const _nc_info_hash_table[995] = {0};
+#undef _nc_cap_hash_table
+const struct name_table_entry *const _nc_cap_hash_table[995] = {0};
+#undef _nc_capalias_table
+const struct alias _nc_capalias_table[] = {0};
+#undef _nc_infoalias_table
+const struct alias _nc_infoalias_table[] = {0};
+
+#undef _nc_get_table
+const struct name_table_entry *_nc_get_table(
+ bool termcap)
+ { return(*(const struct name_table_entry **)0); }
+
+#undef _nc_get_hash_table
+const struct name_table_entry *const *_nc_get_hash_table(
+ bool termcap)
+ { return(*(const struct name_table_entry **)0); }
+
+/* ./tinfo/comp_error.c */
+
+#undef _nc_suppress_warnings
+bool _nc_suppress_warnings;
+#undef _nc_curr_line
+int _nc_curr_line;
+#undef _nc_curr_col
+int _nc_curr_col;
+
+#undef _nc_set_source
+void _nc_set_source(
+ const char *const name)
+ { /* void */ }
+
+#undef _nc_set_type
+void _nc_set_type(
+ const char *const name)
+ { /* void */ }
+
+#undef _nc_get_type
+void _nc_get_type(
+ char *name)
+ { /* void */ }
+
+#undef _nc_warning
+void _nc_warning(
+ const char *const fmt,
+ ...)
+ { /* void */ }
+
+#undef _nc_err_abort
+void _nc_err_abort(
+ const char *const fmt,
+ ...)
+ { /* void */ }
+
+#undef _nc_syserr_abort
+void _nc_syserr_abort(
+ const char *const fmt,
+ ...)
+ { /* void */ }
+
+/* ./tinfo/comp_expand.c */
+
+#undef _nc_tic_expand
+char *_nc_tic_expand(
+ const char *srcp,
+ bool tic_format,
+ bool numbers)
+ { return(*(char **)0); }
+
+/* ./tinfo/comp_hash.c */
+
+#include <hashsize.h>
+
+#undef _nc_find_entry
+struct name_table_entry const *_nc_find_entry(
+ const char *string,
+ const struct name_table_entry *const *hash_table)
+ { return(*(struct name_table_entry const **)0); }
+
+#undef _nc_find_type_entry
+struct name_table_entry const *_nc_find_type_entry(
+ const char *string,
+ int type,
+ const struct name_table_entry *table)
+ { return(*(struct name_table_entry const **)0); }
+
+/* ./tinfo/comp_parse.c */
+
+#undef _nc_check_termtype
+void (*_nc_check_termtype)(
+ TERMTYPE *p1);
+#undef _nc_head
+ENTRY *_nc_head;
+#undef _nc_tail
+ENTRY *_nc_tail;
+
+#undef _nc_free_entries
+void _nc_free_entries(
+ ENTRY *head)
+ { /* void */ }
+
+#undef _nc_entry_match
+bool _nc_entry_match(
+ char *n1,
+ char *n2)
+ { return(*(bool *)0); }
+
+#undef _nc_read_entry_source
+void _nc_read_entry_source(
+ FILE *fp,
+ char *buf,
+ int literal,
+ bool silent,
+ bool (*hook)(
+ ENTRY *p1))
+ { /* void */ }
+
+#undef _nc_resolve_uses
+int _nc_resolve_uses(void)
+ { return(*(int *)0); }
+
+/* ./tinfo/comp_scan.c */
+
+#undef _nc_syntax
+int _nc_syntax;
+#undef _nc_curr_file_pos
+long _nc_curr_file_pos;
+#undef _nc_comment_start
+long _nc_comment_start;
+#undef _nc_comment_end
+long _nc_comment_end;
+#undef _nc_start_line
+long _nc_start_line;
+
+#undef _nc_get_token
+int _nc_get_token(void)
+ { return(*(int *)0); }
+
+#undef _nc_trans_string
+char _nc_trans_string(
+ char *ptr)
+ { return(*(char *)0); }
+
+#undef _nc_push_token
+void _nc_push_token(
+ int tokclass)
+ { /* void */ }
+
+#undef _nc_panic_mode
+void _nc_panic_mode(
+ char ch)
+ { /* void */ }
+
+#undef _nc_reset_input
+void _nc_reset_input(
+ FILE *fp,
+ char *buf)
+ { /* void */ }
+
+/* ./tinfo/doalloc.c */
+
+#undef _nc_doalloc
+void *_nc_doalloc(
+ void *oldp,
+ size_t amount)
+ { return(*(void **)0); }
+
+/* ./fallback.c */
+
+#undef _nc_fallback
+const TERMTYPE *_nc_fallback(
+ const char *name)
+ { return(*(const TERMTYPE **)0); }
+
+/* ./tinfo/free_ttype.c */
+
+#undef _nc_free_termtype
+void _nc_free_termtype(
+ TERMTYPE *ptr)
+ { /* void */ }
+
+#undef _nc_user_definable
+bool _nc_user_definable;
+
+#undef use_extended_names
+int use_extended_names(
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./tinfo/getenv_num.c */
+
+#undef _nc_getenv_num
+int _nc_getenv_num(
+ const char *name)
+ { return(*(int *)0); }
+
+/* ./tinfo/home_terminfo.c */
+
+#undef _nc_home_terminfo
+char *_nc_home_terminfo(void)
+ { return(*(char **)0); }
+
+/* ./tinfo/init_keytry.c */
+
+#if 0
+
+#include <init_keytry.h>
+
+#undef _nc_tinfo_fkeys
+struct tinfo_fkeys _nc_tinfo_fkeys[];
+
+#endif
+
+#undef _nc_init_keytry
+void _nc_init_keytry(void)
+ { /* void */ }
+
+/* ./tinfo/lib_acs.c */
+
+#undef acs_map
+chtype acs_map[128 ];
+
+#undef _nc_init_acs
+void _nc_init_acs(void)
+ { /* void */ }
+
+/* ./tinfo/lib_baudrate.c */
+
+#include <termcap.h>
+
+struct speed {
+ speed_t s;
+ int sp;
+};
+
+#undef _nc_baudrate
+int _nc_baudrate(
+ int OSpeed)
+ { return(*(int *)0); }
+
+#undef _nc_ospeed
+int _nc_ospeed(
+ int BaudRate)
+ { return(*(int *)0); }
+
+#undef baudrate
+int baudrate(void)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_cur_term.c */
+
+#undef cur_term
+TERMINAL *cur_term;
+
+#undef set_curterm
+TERMINAL *set_curterm(
+ TERMINAL *term)
+ { return(*(TERMINAL **)0); }
+
+#undef del_curterm
+int del_curterm(
+ TERMINAL *term)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_data.c */
+
+#undef stdscr
+WINDOW *stdscr;
+#undef curscr
+WINDOW *curscr;
+#undef newscr
+WINDOW *newscr;
+#undef _nc_screen_chain
+SCREEN *_nc_screen_chain;
+#undef SP
+SCREEN *SP;
+
+/* ./tinfo/lib_has_cap.c */
+
+#undef has_ic
+bool has_ic(void)
+ { return(*(bool *)0); }
+
+#undef has_il
+bool has_il(void)
+ { return(*(bool *)0); }
+
+/* ./tinfo/lib_kernel.c */
+
+#undef erasechar
+char erasechar(void)
+ { return(*(char *)0); }
+
+#undef killchar
+char killchar(void)
+ { return(*(char *)0); }
+
+#undef flushinp
+int flushinp(void)
+ { return(*(int *)0); }
+
+/* ./lib_keyname.c */
+
+#include <stdlib.h>
+#include <string.h>
+#include <curses.h>
+
+#undef _nc_key_names
+const struct kn _nc_key_names[] = {0};
+
+#undef keyname
+char *keyname(
+ int c)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_longname.c */
+
+#undef longname
+char *longname(void)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_napms.c */
+
+#undef napms
+int napms(
+ int ms)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_options.c */
+
+#undef idlok
+int idlok(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+#undef idcok
+void idcok(
+ WINDOW *win,
+ bool flag)
+ { /* void */ }
+
+#undef halfdelay
+int halfdelay(
+ int t)
+ { return(*(int *)0); }
+
+#undef nodelay
+int nodelay(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+#undef notimeout
+int notimeout(
+ WINDOW *win,
+ bool f)
+ { return(*(int *)0); }
+
+#undef wtimeout
+void wtimeout(
+ WINDOW *win,
+ int delay)
+ { /* void */ }
+
+#undef keypad
+int keypad(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+#undef meta
+int meta(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+#undef curs_set
+int curs_set(
+ int vis)
+ { return(*(int *)0); }
+
+#undef typeahead
+int typeahead(
+ int fd)
+ { return(*(int *)0); }
+
+#undef has_key
+int has_key(
+ int keycode)
+ { return(*(int *)0); }
+
+#undef _nc_keypad
+int _nc_keypad(
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_raw.c */
+
+#undef raw
+int raw(void)
+ { return(*(int *)0); }
+
+#undef cbreak
+int cbreak(void)
+ { return(*(int *)0); }
+
+#undef qiflush
+void qiflush(void)
+ { /* void */ }
+
+#undef noraw
+int noraw(void)
+ { return(*(int *)0); }
+
+#undef nocbreak
+int nocbreak(void)
+ { return(*(int *)0); }
+
+#undef noqiflush
+void noqiflush(void)
+ { /* void */ }
+
+#undef intrflush
+int intrflush(
+ WINDOW *win,
+ bool flag)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_setup.c */
+
+#include <sys/ioctl.h>
+
+#undef use_env
+void use_env(
+ bool f)
+ { /* void */ }
+
+#undef LINES
+int LINES;
+#undef COLS
+int COLS;
+#undef TABSIZE
+int TABSIZE;
+
+#undef _nc_update_screensize
+void _nc_update_screensize(void)
+ { /* void */ }
+
+#undef ttytype
+char ttytype[256 ];
+
+#undef setupterm
+int setupterm(
+ char *tname,
+ int Filedes,
+ int *errret)
+ { return(*(int *)0); }
+
+/* ./tinfo/lib_termcap.c */
+
+#undef UP
+char *UP;
+#undef BC
+char *BC;
+
+#undef tgetent
+int tgetent(
+ char *bufp,
+ const char *name)
+ { return(*(int *)0); }
+
+#if 0
+
+#include <capdefaults.c>
+
+#endif
+
+#undef tgetflag
+int tgetflag(
+ char *id)
+ { return(*(int *)0); }
+
+#undef tgetnum
+int tgetnum(
+ char *id)
+ { return(*(int *)0); }
+
+#undef tgetstr
+char *tgetstr(
+ char *id,
+ char **area)
+ { return(*(char **)0); }
+
+#undef tgoto
+char *tgoto(
+ const char *string,
+ int x,
+ int y)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_termname.c */
+
+#undef termname
+char *termname(void)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_ti.c */
+
+#undef tigetflag
+int tigetflag(
+ char *str)
+ { return(*(int *)0); }
+
+#undef tigetnum
+int tigetnum(
+ char *str)
+ { return(*(int *)0); }
+
+#undef tigetstr
+char *tigetstr(
+ char *str)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_tparm.c */
+
+typedef union {
+ unsigned int num;
+ char *str;
+} stack_frame;
+
+#undef tparm
+char *tparm(
+ char *string,
+ ...)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_tputs.c */
+
+#undef PC
+char PC;
+#undef ospeed
+speed_t ospeed;
+#undef _nc_nulls_sent
+int _nc_nulls_sent;
+
+#undef delay_output
+int delay_output(
+ int ms)
+ { return(*(int *)0); }
+
+#undef _nc_outch
+int _nc_outch(
+ int ch)
+ { return(*(int *)0); }
+
+#undef putp
+int putp(
+ const char *string)
+ { return(*(int *)0); }
+
+#undef tputs
+int tputs(
+ const char *string,
+ int affcnt,
+ int (*outc)(
+ int p1))
+ { return(*(int *)0); }
+
+/* ./trace/lib_trace.c */
+
+#include <fcntl.h>
+
+#undef _nc_tracing
+unsigned _nc_tracing;
+
+#undef trace
+void trace(
+ const unsigned int tracelevel)
+ { /* void */ }
+
+#undef _nc_visbuf2
+const char *_nc_visbuf2(
+ int bufnum,
+ const char *buf)
+ { return(*(const char **)0); }
+
+#undef _nc_visbuf
+const char *_nc_visbuf(
+ const char *buf)
+ { return(*(const char **)0); }
+
+/* ./trace/lib_tracebits.c */
+
+#undef _nc_tracebits
+char *_nc_tracebits(void)
+ { return(*(char **)0); }
+
+/* ./trace/lib_tracechr.c */
+
+#undef _tracechar
+char *_tracechar(
+ const unsigned char ch)
+ { return(*(char **)0); }
+
+/* ./tinfo/lib_ttyflags.c */
+
+#undef _nc_get_tty_mode
+int _nc_get_tty_mode(
+ struct termios *buf)
+ { return(*(int *)0); }
+
+#undef _nc_set_tty_mode
+int _nc_set_tty_mode(
+ struct termios *buf)
+ { return(*(int *)0); }
+
+#undef def_shell_mode
+int def_shell_mode(void)
+ { return(*(int *)0); }
+
+#undef def_prog_mode
+int def_prog_mode(void)
+ { return(*(int *)0); }
+
+#undef reset_prog_mode
+int reset_prog_mode(void)
+ { return(*(int *)0); }
+
+#undef reset_shell_mode
+int reset_shell_mode(void)
+ { return(*(int *)0); }
+
+#undef savetty
+int savetty(void)
+ { return(*(int *)0); }
+
+#undef resetty
+int resetty(void)
+ { return(*(int *)0); }
+
+/* ./tty/lib_twait.c */
+
+#undef _nc_timed_wait
+int _nc_timed_wait(
+ int mode,
+ int milliseconds,
+ int *timeleft)
+ { return(*(int *)0); }
+
+/* ./tinfo/name_match.c */
+
+#undef _nc_first_name
+char *_nc_first_name(
+ const char *const sp)
+ { return(*(char **)0); }
+
+#undef _nc_name_match
+int _nc_name_match(
+ const char *const namelst,
+ const char *const name,
+ const char *const delim)
+ { return(*(int *)0); }
+
+/* ./names.c */
+
+#undef boolnames
+char *const boolnames[] = {0};
+#undef boolfnames
+char *const boolfnames[] = {0};
+#undef numnames
+char *const numnames[] = {0};
+#undef numfnames
+char *const numfnames[] = {0};
+#undef strnames
+char *const strnames[] = {0};
+#undef strfnames
+char *const strfnames[] = {0};
+
+/* ./tinfo/parse_entry.c */
+#undef _nc_curr_token
+struct token _nc_curr_token;
+
+#undef _nc_parse_entry
+int _nc_parse_entry(
+ struct entry *entryp,
+ int literal,
+ bool silent)
+ { return(*(int *)0); }
+
+#undef _nc_capcmp
+int _nc_capcmp(
+ const char *s,
+ const char *t)
+ { return(*(int *)0); }
+
+typedef struct {const char *from; const char *to;} assoc;
+
+/* ./tinfo/read_entry.c */
+
+#undef _nc_tic_dir
+const char *_nc_tic_dir(
+ const char *path)
+ { return(*(const char **)0); }
+
+#undef _nc_keep_tic_dir
+void _nc_keep_tic_dir(
+ const char *path)
+ { /* void */ }
+
+#undef _nc_read_file_entry
+int _nc_read_file_entry(
+ const char *const filename,
+ TERMTYPE *ptr)
+ { return(*(int *)0); }
+
+#undef _nc_read_entry
+int _nc_read_entry(
+ const char *const tn,
+ char *const filename,
+ TERMTYPE *const tp)
+ { return(*(int *)0); }
+
+/* ./tinfo/read_termcap.c */
+
+#undef _nc_read_termcap
+void _nc_read_termcap(void)
+ { /* void */ }
+
+/* ./tinfo/setbuf.c */
+
+#undef _nc_set_buffer
+void _nc_set_buffer(
+ FILE *ofp,
+ bool buffered)
+ { /* void */ }
+
+/* ./trace/trace_buf.c */
+
+typedef struct {
+ char *text;
+ size_t size;
+} LIST;
+
+#undef _nc_trace_buf
+char *_nc_trace_buf(
+ int bufnum,
+ size_t want)
+ { return(*(char **)0); }
+
+/* ./tinfo/add_tries.c */
+
+#undef _nc_add_to_try
+void _nc_add_to_try(
+ struct tries **tree,
+ char *str,
+ unsigned short code)
+ { /* void */ }
+
+/* ./unctrl.c */
+
+#undef unctrl
+char *unctrl(
+ chtype ch)
+ { return(*(char **)0); }
+
+/* ./tinfo/write_entry.c */
+
+#undef _nc_set_writedir
+void _nc_set_writedir(
+ char *dir)
+ { /* void */ }
+
+#undef _nc_write_entry
+void _nc_write_entry(
+ TERMTYPE *const tp)
+ { /* void */ }
+
+#undef _nc_tic_written
+int _nc_tic_written(void)
+ { return(*(int *)0); }
diff --git a/contrib/ncurses/ncurses/modules b/contrib/ncurses/ncurses/modules
new file mode 100644
index 000000000000..5bb8227270c5
--- /dev/null
+++ b/contrib/ncurses/ncurses/modules
@@ -0,0 +1,186 @@
+# $Id: modules,v 1.69 1999/07/18 02:38:37 tom Exp $
+##############################################################################
+# Copyright (c) 1998,1999 Free Software Foundation, Inc. #
+# #
+# Permission is hereby granted, free of charge, to any person obtaining a #
+# copy of this software and associated documentation files (the "Software"), #
+# to deal in the Software without restriction, including without limitation #
+# the rights to use, copy, modify, merge, publish, distribute, distribute #
+# with modifications, sublicense, and/or sell copies of the Software, and to #
+# permit persons to whom the Software is furnished to do so, subject to the #
+# following conditions: #
+# #
+# The above copyright notice and this permission notice shall be included in #
+# all copies or substantial portions of the Software. #
+# #
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
+# THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
+# DEALINGS IN THE SOFTWARE. #
+# #
+# Except as contained in this notice, the name(s) of the above copyright #
+# holders shall not be used in advertising or otherwise to promote the sale, #
+# use or other dealings in this Software without prior written #
+# authorization. #
+##############################################################################
+#
+# Author: Thomas E. Dickey <dickey@clark.net> 1996,1997,1998
+#
+
+@ base
+# Library objects
+hardscroll lib $(serial)
+hashmap lib $(serial) ../include/term.h
+lib_addch lib $(base)
+lib_addstr lib $(base)
+lib_beep lib $(base) ../include/term.h
+lib_bkgd lib $(base)
+lib_box lib $(base)
+lib_chgat lib $(base)
+lib_clear lib $(base)
+lib_clearok lib $(base)
+lib_clrbot lib $(base)
+lib_clreol lib $(base)
+lib_color lib $(base) ../include/term.h
+lib_colorset lib $(base)
+lib_delch lib $(base)
+lib_delwin lib $(base)
+lib_echo lib $(base)
+lib_endwin lib $(base) ../include/term.h
+lib_erase lib $(base)
+lib_flash lib $(base) ../include/term.h
+lib_gen lib . ../include/curses.h
+lib_getch lib $(base)
+lib_getstr lib $(base) ../include/term.h
+lib_hline lib $(base)
+lib_immedok lib $(base)
+lib_inchstr lib $(base)
+lib_initscr lib $(base) $(INCDIR)/tic.h
+lib_insch lib $(base)
+lib_insdel lib $(base)
+lib_insstr lib $(base)
+lib_instr lib $(base)
+lib_isendwin lib $(base)
+lib_leaveok lib $(base)
+lib_mouse lib $(base) ../include/term.h
+lib_move lib $(base)
+lib_mvcur lib $(serial) ../include/term.h $(INCDIR)/tic.h
+lib_mvwin lib $(base)
+lib_newterm lib $(base) ../include/term.h
+lib_newwin lib $(base)
+lib_nl lib $(base)
+lib_overlay lib $(base)
+lib_pad lib $(base)
+lib_printw lib $(base)
+lib_redrawln lib $(base)
+lib_refresh lib $(base)
+lib_restart lib $(base) ../include/term.h
+lib_scanw lib $(base)
+lib_screen lib $(base) ../include/term.h
+lib_scroll lib $(base)
+lib_scrollok lib $(base)
+lib_scrreg lib $(base)
+lib_set_term lib $(base) ../include/term.h
+lib_slk lib $(base) ../include/term.h
+lib_slkatr_set lib $(base)
+lib_slkatrof lib $(base)
+lib_slkatron lib $(base)
+lib_slkatrset lib $(base)
+lib_slkattr lib $(base)
+lib_slkclear lib $(base)
+lib_slkcolor lib $(base)
+lib_slkinit lib $(base)
+lib_slklab lib $(base)
+lib_slkrefr lib $(base) ../include/term.h
+lib_slkset lib $(base)
+lib_slktouch lib $(base)
+lib_touch lib $(base)
+lib_traceatr lib $(trace) ../include/term.h
+lib_tracedmp lib $(trace)
+lib_tracemse lib $(trace)
+lib_tstp lib $(serial)
+lib_ungetch lib $(base)
+lib_vidattr lib $(serial) ../include/term.h
+lib_vline lib $(base)
+lib_wattroff lib $(base)
+lib_wattron lib $(base)
+lib_winch lib $(base)
+lib_window lib $(base)
+nc_panel lib $(base)
+safe_sprintf lib $(base)
+tty_update lib $(serial) ../include/term.h
+
+# Modules for porting
+memmove lib $(base)
+sigaction lib $(base)
+vsscanf lib $(base)
+
+# Extensions to the base library
+@ ext_funcs
+define_key lib $(base)
+expanded lib .
+keybound lib $(base)
+keyok lib $(base)
+lib_dft_fgbg lib $(base) ../include/term.h
+lib_freeall lib $(base)
+lib_print lib $(tinfo) ../include/term.h
+resizeterm lib $(base) ../include/term.h
+trace_xnames lib $(trace) ../include/term.h $(INCDIR)/term_entry.h
+tries lib $(base)
+wresize lib $(base) ../include/term.h
+
+# Support for termcap (and tic, etc.), which can be a separate library
+@ termlib
+access lib $(tinfo)
+add_tries lib $(tinfo)
+alloc_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+alloc_ttype lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+captoinfo lib $(tinfo) $(INCDIR)/tic.h
+codes lib .
+comp_captab lib . $(INCDIR)/tic.h ../include/term.h ../include/hashsize.h
+comp_error lib $(tinfo) $(INCDIR)/tic.h
+comp_expand lib $(tinfo) $(INCDIR)/tic.h
+comp_hash lib $(tinfo) ../include/term.h $(INCDIR)/tic.h ../include/hashsize.h
+comp_parse lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+comp_scan lib $(tinfo) $(INCDIR)/tic.h
+doalloc lib $(tinfo)
+fallback lib . ../include/term.h $(INCDIR)/tic.h
+free_ttype lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+getenv_num lib $(tinfo)
+home_terminfo lib $(tinfo)
+init_keytry lib $(tinfo) ../include/term.h $(INCDIR)/tic.h init_keytry.h
+lib_acs lib $(tinfo) ../include/term.h
+lib_baudrate lib $(tinfo) ../include/term.h
+lib_cur_term lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h
+lib_data lib $(tinfo)
+lib_has_cap lib $(tinfo) ../include/term.h
+lib_kernel lib $(tinfo) ../include/term.h
+lib_keyname lib . ../include/term.h
+lib_longname lib $(tinfo)
+lib_napms lib $(tinfo)
+lib_options lib $(tinfo) ../include/term.h
+lib_raw lib $(tinfo) ../include/term.h
+lib_setup lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h
+lib_termcap lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+lib_termname lib $(tinfo) $(INCDIR)/tic.h
+lib_ti lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+lib_tparm lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
+lib_tputs lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
+lib_trace lib $(trace) $(INCDIR)/tic.h
+lib_tracebits lib $(trace) ../include/term.h
+lib_tracechr lib $(trace)
+lib_ttyflags lib $(tinfo) ../include/term.h
+lib_twait lib $(serial)
+name_match lib $(tinfo) ../include/term.h $(INCDIR)/tic.h
+names lib .
+parse_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h ../include/parametrized.h
+read_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+read_termcap lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
+setbuf lib $(tinfo)
+trace_buf lib $(trace)
+trace_tries lib $(trace)
+unctrl lib .
+write_entry lib $(tinfo) ../include/term.h $(INCDIR)/term_entry.h $(INCDIR)/tic.h
diff --git a/contrib/ncurses/ncurses/tinfo/MKcaptab.awk b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
new file mode 100644
index 000000000000..910af94b7a48
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/MKcaptab.awk
@@ -0,0 +1,70 @@
+#!/bin/sh
+# $Id: MKcaptab.awk,v 1.11 1999/01/24 02:46:42 Jeffrey.C.Honig Exp $
+AWK=${1-awk}
+DATA=${2-../include/Caps}
+
+cat <<'EOF'
+/*
+ * comp_captab.c -- The names of the capabilities indexed via a hash
+ * table for the compiler.
+ *
+ */
+
+#include <ncurses_cfg.h>
+#include <tic.h>
+#include <term.h>
+
+EOF
+
+./make_hash 1 info <$DATA
+./make_hash 3 cap <$DATA
+
+cat <<'EOF'
+const struct alias _nc_capalias_table[] =
+{
+EOF
+
+$AWK <$DATA '
+$1 == "capalias" {
+ if ($3 == "IGNORE")
+ to = "(char *)NULL";
+ else
+ to = "\"" $3 "\"";
+ printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
+ $2, to, $4, $5
+ }
+'
+
+cat <<'EOF'
+ {(char *)NULL, (char *)NULL, (char *)NULL}
+};
+
+const struct alias _nc_infoalias_table[] =
+{
+EOF
+
+$AWK <$DATA '
+$1 == "infoalias" {
+ if ($3 == "IGNORE")
+ to = "(char *)NULL";
+ else
+ to = "\"" $3 "\"";
+ printf "\t{\"%s\", %s, \"%s\"},\t /* %s */\n",
+ $2, to, $4, $5
+ }
+'
+
+cat <<'EOF'
+ {(char *)NULL, (char *)NULL, (char *)NULL}
+};
+
+const struct name_table_entry *_nc_get_table(bool termcap)
+{
+ return termcap ? _nc_cap_table: _nc_info_table ;
+}
+
+const struct name_table_entry * const * _nc_get_hash_table(bool termcap)
+{
+ return termcap ? _nc_cap_hash_table: _nc_info_hash_table ;
+}
+EOF
diff --git a/contrib/ncurses/ncurses/tinfo/MKfallback.sh b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
new file mode 100755
index 000000000000..2a76f6239b2b
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/MKfallback.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+# $Id: MKfallback.sh,v 1.9 1999/06/15 22:57:45 tom Exp $
+#
+# MKfallback.sh -- create fallback table for entry reads
+#
+# This script generates source code for a custom version of read_entry.c
+# that (instead of reading capabilities for an argument terminal type
+# from an on-disk terminfo tree) tries to match the type with one of a
+# specified list of types generated in.
+#
+cat <<EOF
+/*
+ * DO NOT EDIT THIS FILE BY HAND! It is generated by MKfallback.sh.
+ */
+
+#include <curses.priv.h>
+#include <term.h>
+
+EOF
+
+if [ "$*" ]
+then
+ cat <<EOF
+#include <tic.h>
+
+/* fallback entries for: $* */
+EOF
+ for x in $*
+ do
+ echo "/* $x */"
+ infocmp -E $x
+ done
+
+ cat <<EOF
+static const TERMTYPE fallbacks[$#] =
+{
+EOF
+ comma=""
+ for x in $*
+ do
+ echo "$comma /* $x */"
+ infocmp -e $x
+ comma=","
+ done
+
+ cat <<EOF
+};
+
+EOF
+fi
+
+cat <<EOF
+const TERMTYPE *_nc_fallback(const char *name GCC_UNUSED)
+{
+EOF
+
+if [ "$*" ]
+then
+ cat <<EOF
+ const TERMTYPE *tp;
+
+ for (tp = fallbacks;
+ tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
+ tp++)
+ if (_nc_name_match(tp->term_names, name, "|"))
+ return(tp);
+EOF
+else
+ echo " /* the fallback list is empty */";
+fi
+
+cat <<EOF
+ return((TERMTYPE *)0);
+}
+EOF
diff --git a/contrib/ncurses/ncurses/tinfo/MKnames.awk b/contrib/ncurses/ncurses/tinfo/MKnames.awk
new file mode 100644
index 000000000000..b97eccc15e38
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/MKnames.awk
@@ -0,0 +1,98 @@
+# $Id: MKnames.awk,v 1.10 1999/01/16 23:36:34 tom Exp $
+BEGIN {
+ print "/* This file was generated by MKnames.awk */" > "namehdr"
+ print "" > "namehdr"
+ print "#include <curses.priv.h>" > "namehdr"
+ print "" > "namehdr"
+ print "#define IT NCURSES_CONST char * const" > "namehdr"
+ print "" > "namehdr"
+ print "#if BROKEN_LINKER" > "namehdr"
+ print "#include <term.h>" > "namehdr"
+ print "#define DCL(it) static IT data##it[]" > "namehdr"
+ print "#else" > "namehdr"
+ print "#define DCL(it) IT it[]" > "namehdr"
+ print "#endif" > "namehdr"
+ print "" > "namehdr"
+ print "/*" > "boolnames"
+ print " * names.c - Arrays of capability names and codes" > "boolnames"
+ print " *" > "boolnames"
+ print " */" > "boolnames"
+ print "" > "boolnames"
+ print "DCL(boolnames) = {" > "boolnames"
+ print "DCL(boolfnames) = {" > "boolfnames"
+ print "DCL(boolcodes) = {" > "boolcodes"
+ print "DCL(numnames) = {" > "numnames"
+ print "DCL(numfnames) = {" > "numfnames"
+ print "DCL(numcodes) = {" > "numcodes"
+ print "DCL(strnames) = {" > "strnames"
+ print "DCL(strfnames) = {" > "strfnames"
+ print "DCL(strcodes) = {" > "strcodes"
+ }
+
+$1 ~ /^#/ {next;}
+
+$1 == "SKIPWARN" {next;}
+
+$3 == "bool" {
+ printf "\t\t\"%s\",\n", $2 > "boolnames"
+ printf "\t\t\"%s\",\n", $1 > "boolfnames"
+ printf "\t\t\"%s\",\n", $4 > "boolcodes"
+ }
+
+$3 == "num" {
+ printf "\t\t\"%s\",\n", $2 > "numnames"
+ printf "\t\t\"%s\",\n", $1 > "numfnames"
+ printf "\t\t\"%s\",\n", $4 > "numcodes"
+ }
+
+$3 == "str" {
+ printf "\t\t\"%s\",\n", $2 > "strnames"
+ printf "\t\t\"%s\",\n", $1 > "strfnames"
+ printf "\t\t\"%s\",\n", $4 > "strcodes"
+ }
+
+END {
+ print "\t\t(NCURSES_CONST char *)0," > "boolnames"
+ print "};" > "boolnames"
+ print "" > "boolnames"
+ print "\t\t(NCURSES_CONST char *)0," > "boolfnames"
+ print "};" > "boolfnames"
+ print "" > "boolfnames"
+ print "\t\t(NCURSES_CONST char *)0," > "boolcodes"
+ print "};" > "boolcodes"
+ print "" > "boolcodes"
+ print "\t\t(NCURSES_CONST char *)0," > "numnames"
+ print "};" > "numnames"
+ print "" > "numnames"
+ print "\t\t(NCURSES_CONST char *)0," > "numfnames"
+ print "};" > "numfnames"
+ print "" > "numfnames"
+ print "\t\t(NCURSES_CONST char *)0," > "numcodes"
+ print "};" > "numcodes"
+ print "" > "numcodes"
+ print "\t\t(NCURSES_CONST char *)0," > "strnames"
+ print "};" > "strnames"
+ print "" > "strnames"
+ print "\t\t(NCURSES_CONST char *)0," > "strfnames"
+ print "};" > "strfnames"
+ print "" > "strfnames"
+ print "\t\t(NCURSES_CONST char *)0," > "strcodes"
+ print "};" > "strcodes"
+ print "" > "strcodes"
+ print "#if BROKEN_LINKER" > "nameftr"
+ print "#define FIX(it) IT *_nc_##it(void) { return data##it; }" > "nameftr"
+ print "FIX(boolnames)" > "nameftr"
+ print "FIX(boolfnames)" > "nameftr"
+ print "FIX(numnames)" > "nameftr"
+ print "FIX(numfnames)" > "nameftr"
+ print "FIX(strnames)" > "nameftr"
+ print "FIX(strfnames)" > "nameftr"
+ print "#endif /* BROKEN_LINKER */" > "nameftr"
+ print "" > "codeftr"
+ print "#if BROKEN_LINKER" > "codeftr"
+ print "#define FIX(it) IT *_nc_##it(void) { return data##it; }" > "codeftr"
+ print "FIX(boolcodes)" > "codeftr"
+ print "FIX(numcodes)" > "codeftr"
+ print "FIX(strcodes)" > "codeftr"
+ print "#endif /* BROKEN_LINKER */" > "codeftr"
+ }
diff --git a/contrib/ncurses/ncurses/tinfo/README b/contrib/ncurses/ncurses/tinfo/README
new file mode 100644
index 000000000000..8b092c1ba41c
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/README
@@ -0,0 +1,8 @@
+-- $Id: README,v 1.1 1998/11/07 22:59:07 tom Exp $
+
+The files in this directory (tinfo) are those that support the terminfo
+database and interfaces for ncurses. The terminfo library can be built
+separately, as a lower-level library for ncurses, but usually is bundled.
+
+In addition to the standard documented interfaces, ncurses uses internal
+functions which reside in tinfo to satisfy linkage requirements.
diff --git a/contrib/ncurses/ncurses/tinfo/access.c b/contrib/ncurses/ncurses/tinfo/access.c
new file mode 100644
index 000000000000..54e549497c94
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/access.c
@@ -0,0 +1,55 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ ****************************************************************************/
+
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: access.c,v 1.1 1998/07/25 20:17:09 tom Exp $")
+
+int _nc_access(const char *path, int mode)
+{
+ if (access(path, mode) < 0) {
+ if ((mode & W_OK) != 0
+ && errno == ENOENT) {
+ char head[PATH_MAX];
+ char *leaf = strrchr(strcpy(head, path), '/');
+ if (leaf == 0)
+ leaf = head;
+ *leaf = '\0';
+ if (head == leaf)
+ (void)strcpy(head, ".");
+ return access(head, R_OK|W_OK|X_OK);
+ }
+ return -1;
+ }
+ return 0;
+}
diff --git a/contrib/ncurses/ncurses/tinfo/add_tries.c b/contrib/ncurses/ncurses/tinfo/add_tries.c
new file mode 100644
index 000000000000..95a9e965c5a7
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/add_tries.c
@@ -0,0 +1,124 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ ****************************************************************************/
+
+/*
+** add_tries.c
+**
+** Add keycode/string to tries-tree.
+**
+*/
+
+#include <curses.priv.h>
+
+MODULE_ID("$Id: add_tries.c,v 1.1 1998/11/08 00:04:18 tom Exp $")
+
+#define SET_TRY(dst,src) if ((dst->ch = *src++) == 128) dst->ch = '\0'
+#define CMP_TRY(a,b) ((a)? (a == b) : (b == 128))
+
+void _nc_add_to_try(struct tries **tree, char *str, unsigned short code)
+{
+ static bool out_of_memory = FALSE;
+ struct tries *ptr, *savedptr;
+ unsigned char *txt = (unsigned char *)str;
+
+ if (txt == 0 || *txt == '\0' || out_of_memory || code == 0)
+ return;
+
+ if ((*tree) != 0) {
+ ptr = savedptr = (*tree);
+
+ for (;;) {
+ unsigned char cmp = *txt;
+
+ while (!CMP_TRY(ptr->ch, cmp)
+ && ptr->sibling != 0)
+ ptr = ptr->sibling;
+
+ if (CMP_TRY(ptr->ch, cmp)) {
+ if (*(++txt) == '\0') {
+ ptr->value = code;
+ return;
+ }
+ if (ptr->child != 0)
+ ptr = ptr->child;
+ else
+ break;
+ } else {
+ if ((ptr->sibling = typeCalloc(struct tries,1)) == 0) {
+ out_of_memory = TRUE;
+ return;
+ }
+
+ savedptr = ptr = ptr->sibling;
+ SET_TRY(ptr,txt);
+ ptr->value = 0;
+
+ break;
+ }
+ } /* end for (;;) */
+ } else { /* (*tree) == 0 :: First sequence to be added */
+ savedptr = ptr = (*tree) = typeCalloc(struct tries,1);
+
+ if (ptr == 0) {
+ out_of_memory = TRUE;
+ return;
+ }
+
+ SET_TRY(ptr,txt);
+ ptr->value = 0;
+ }
+
+ /* at this point, we are adding to the try. ptr->child == 0 */
+
+ while (*txt) {
+ ptr->child = typeCalloc(struct tries,1);
+
+ ptr = ptr->child;
+
+ if (ptr == 0) {
+ out_of_memory = TRUE;
+
+ while ((ptr = savedptr) != 0) {
+ savedptr = ptr->child;
+ free(ptr);
+ }
+
+ return;
+ }
+
+ SET_TRY(ptr,txt);
+ ptr->value = 0;
+ }
+
+ ptr->value = code;
+ return;
+}
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_entry.c b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
new file mode 100644
index 000000000000..570b48a9af80
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/alloc_entry.c
@@ -0,0 +1,225 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * alloc_entry.c -- allocation functions for terminfo entries
+ *
+ * _nc_copy_entry()
+ * _nc_init_entry()
+ * _nc_merge_entry()
+ * _nc_save_str()
+ * _nc_wrap_entry()
+ *
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+#include <term_entry.h>
+
+MODULE_ID("$Id: alloc_entry.c,v 1.30 1999/03/01 02:03:45 tom Exp $")
+
+#define ABSENT_OFFSET -1
+#define CANCELLED_OFFSET -2
+
+#define MAX_STRTAB 4096 /* documented maximum entry size */
+
+static char stringbuf[MAX_STRTAB]; /* buffer for string capabilities */
+static size_t next_free; /* next free character in stringbuf */
+
+void _nc_init_entry(TERMTYPE *const tp)
+/* initialize a terminal type data block */
+{
+int i;
+
+#if NCURSES_XNAMES
+ tp->num_Booleans = BOOLCOUNT;
+ tp->num_Numbers = NUMCOUNT;
+ tp->num_Strings = STRCOUNT;
+ tp->ext_Booleans = 0;
+ tp->ext_Numbers = 0;
+ tp->ext_Strings = 0;
+#endif
+ if (tp->Booleans == 0)
+ tp->Booleans = typeMalloc(char,BOOLCOUNT);
+ if (tp->Numbers == 0)
+ tp->Numbers = typeMalloc(short,NUMCOUNT);
+ if (tp->Strings == 0)
+ tp->Strings = typeMalloc(char *,STRCOUNT);
+
+ for_each_boolean(i,tp)
+ tp->Booleans[i] = FALSE;
+
+ for_each_number(i,tp)
+ tp->Numbers[i] = ABSENT_NUMERIC;
+
+ for_each_string(i,tp)
+ tp->Strings[i] = ABSENT_STRING;
+
+ next_free = 0;
+}
+
+ENTRY *_nc_copy_entry(ENTRY *oldp)
+{
+ ENTRY *newp = typeCalloc(ENTRY,1);
+
+ if (newp != 0) {
+ *newp = *oldp;
+ _nc_copy_termtype(&(newp->tterm), &(oldp->tterm));
+ }
+ return newp;
+}
+
+char *_nc_save_str(const char *const string)
+/* save a copy of string in the string buffer */
+{
+size_t old_next_free = next_free;
+size_t len = strlen(string) + 1;
+
+ if (next_free + len < MAX_STRTAB)
+ {
+ strcpy(&stringbuf[next_free], string);
+ DEBUG(7, ("Saved string %s", _nc_visbuf(string)));
+ DEBUG(7, ("at location %d", (int) next_free));
+ next_free += len;
+ }
+ return(stringbuf + old_next_free);
+}
+
+void _nc_wrap_entry(ENTRY *const ep)
+/* copy the string parts to allocated storage, preserving pointers to it */
+{
+int offsets[MAX_ENTRY_SIZE/2], useoffsets[MAX_USES];
+int i, n;
+TERMTYPE *tp = &(ep->tterm);
+
+ n = tp->term_names - stringbuf;
+ for_each_string(i, &(ep->tterm)) {
+ if (tp->Strings[i] == ABSENT_STRING)
+ offsets[i] = ABSENT_OFFSET;
+ else if (tp->Strings[i] == CANCELLED_STRING)
+ offsets[i] = CANCELLED_OFFSET;
+ else
+ offsets[i] = tp->Strings[i] - stringbuf;
+ }
+
+ for (i=0; i < ep->nuses; i++) {
+ if (ep->uses[i].parent == (void *)0)
+ useoffsets[i] = ABSENT_OFFSET;
+ else
+ useoffsets[i] = (char *)(ep->uses[i].parent) - stringbuf;
+ }
+
+ if ((tp->str_table = typeMalloc(char, next_free)) == (char *)0)
+ _nc_err_abort("Out of memory");
+ (void) memcpy(tp->str_table, stringbuf, next_free);
+
+ tp->term_names = tp->str_table + n;
+ for_each_string(i, &(ep->tterm)) {
+ if (offsets[i] == ABSENT_OFFSET)
+ tp->Strings[i] = ABSENT_STRING;
+ else if (offsets[i] == CANCELLED_OFFSET)
+ tp->Strings[i] = CANCELLED_STRING;
+ else
+ tp->Strings[i] = tp->str_table + offsets[i];
+ }
+
+#if NCURSES_XNAMES
+ if ((n = NUM_EXT_NAMES(tp)) != 0) {
+ unsigned length = 0;
+ for (i = 0; i < n; i++) {
+ length += strlen(tp->ext_Names[i]) + 1;
+ offsets[i] = tp->ext_Names[i] - stringbuf;
+ }
+ if ((tp->ext_str_table = typeMalloc(char, length)) == 0)
+ _nc_err_abort("Out of memory");
+ for (i = 0, length = 0; i < n; i++) {
+ tp->ext_Names[i] = tp->ext_str_table + length;
+ strcpy(tp->ext_Names[i], stringbuf + offsets[i]);
+ length += strlen(tp->ext_Names[i]) + 1;
+ }
+ }
+#endif
+
+ for (i=0; i < ep->nuses; i++) {
+ if (useoffsets[i] == ABSENT_OFFSET)
+ ep->uses[i].parent = (void *)0;
+ else
+ ep->uses[i].parent = (char *)(tp->str_table + useoffsets[i]);
+ }
+}
+
+void _nc_merge_entry(TERMTYPE *const to, TERMTYPE *const from)
+/* merge capabilities from `from' entry into `to' entry */
+{
+ int i;
+
+#if NCURSES_XNAMES
+ _nc_align_termtype(to, from);
+#endif
+ for_each_boolean(i, from)
+ {
+ int mergebool = from->Booleans[i];
+
+ if (mergebool == CANCELLED_BOOLEAN)
+ to->Booleans[i] = FALSE;
+ else if (mergebool == TRUE)
+ to->Booleans[i] = mergebool;
+ }
+
+ for_each_number(i, from)
+ {
+ int mergenum = from->Numbers[i];
+
+ if (mergenum == CANCELLED_NUMERIC)
+ to->Numbers[i] = ABSENT_NUMERIC;
+ else if (mergenum != ABSENT_NUMERIC)
+ to->Numbers[i] = mergenum;
+ }
+
+ /*
+ * Note: the copies of strings this makes don't have their own
+ * storage. This is OK right now, but will be a problem if we
+ * we ever want to deallocate entries.
+ */
+ for_each_string(i, from)
+ {
+ char *mergestring = from->Strings[i];
+
+ if (mergestring == CANCELLED_STRING)
+ to->Strings[i] = ABSENT_STRING;
+ else if (mergestring != ABSENT_STRING)
+ to->Strings[i] = mergestring;
+ }
+}
diff --git a/contrib/ncurses/ncurses/tinfo/alloc_ttype.c b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
new file mode 100644
index 000000000000..a1bf9b0733f0
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/alloc_ttype.c
@@ -0,0 +1,461 @@
+/****************************************************************************
+ * Copyright (c) 1999 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1999 *
+ ****************************************************************************/
+
+
+/*
+ * align_ttype.c -- functions for TERMTYPE
+ *
+ * _nc_align_termtype()
+ * _nc_copy_termtype()
+ *
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+#include <term_entry.h>
+
+MODULE_ID("$Id: alloc_ttype.c,v 1.6 1999/03/01 22:10:44 tom Exp $")
+
+#if NCURSES_XNAMES
+/*
+ * Merge the a/b lists into dst. Both a/b are sorted (see _nc_extend_names()),
+ * so we do not have to worry about order dependencies.
+ */
+static int merge_names(char **dst, char **a, int na, char **b, int nb)
+{
+ int n = 0;
+ while (na && nb) {
+ int cmp = strcmp(*a, *b);
+ if (cmp < 0) {
+ dst[n++] = *a++;
+ na--;
+ } else if (cmp > 0) {
+ dst[n++] = *b++;
+ nb--;
+ } else if (cmp == 0) {
+ dst[n++] = *a;
+ a++, b++;
+ na--, nb--;
+ }
+ }
+ while (na-- > 0) {
+ dst[n++] = *a++;
+ }
+ while (nb-- > 0) {
+ dst[n++] = *b++;
+ }
+ DEBUG(4, ("merge_names -> %d", n));
+ return n;
+}
+
+static bool find_name(char **table, int length, char *name)
+{
+ while (length-- > 0) {
+ if (!strcmp(*table++, name)) {
+ DEBUG(4, ("found name '%s'", name));
+ return TRUE;
+ }
+ }
+ DEBUG(4, ("did not find name '%s'", name));
+ return FALSE;
+}
+
+static void realign_data(TERMTYPE *to, char **ext_Names, int ext_Booleans, int ext_Numbers, int ext_Strings)
+{
+ int n, m, base;
+ int limit = (to->ext_Booleans + to->ext_Numbers + to->ext_Strings);
+
+ if (to->ext_Booleans != ext_Booleans) {
+ to->num_Booleans += (ext_Booleans - to->ext_Booleans);
+ to->Booleans = typeRealloc(char, to->num_Booleans, to->Booleans);
+ for (n = to->ext_Booleans-1,
+ m = ext_Booleans-1,
+ base = to->num_Booleans - (m+1); m >= 0; m--) {
+ if (find_name(to->ext_Names, limit, ext_Names[m])) {
+ to->Booleans[base + m] = to->Booleans[base + n--];
+ } else {
+ to->Booleans[base + m] = FALSE;
+ }
+ }
+ to->ext_Booleans = ext_Booleans;
+ }
+ if (to->ext_Numbers != ext_Numbers) {
+ to->num_Numbers += (ext_Numbers - to->ext_Numbers);
+ to->Numbers = typeRealloc(short, to->num_Numbers, to->Numbers);
+ for (n = to->ext_Numbers-1,
+ m = ext_Numbers-1,
+ base = to->num_Numbers - (m+1); m >= 0; m--) {
+ if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans])) {
+ to->Numbers[base + m] = to->Numbers[base + n--];
+ } else {
+ to->Numbers[base + m] = ABSENT_NUMERIC;
+ }
+ }
+ to->ext_Numbers = ext_Numbers;
+ }
+ if (to->ext_Strings != ext_Strings) {
+ to->num_Strings += (ext_Strings - to->ext_Strings);
+ to->Strings = typeRealloc(char*, to->num_Strings, to->Strings);
+ for (n = to->ext_Strings-1,
+ m = ext_Strings-1,
+ base = to->num_Strings - (m+1); m >= 0; m--) {
+ if (find_name(to->ext_Names, limit, ext_Names[m+ext_Booleans+ext_Numbers])) {
+ to->Strings[base + m] = to->Strings[base + n--];
+ } else {
+ to->Strings[base + m] = ABSENT_STRING;
+ }
+ }
+ to->ext_Strings = ext_Strings;
+ }
+}
+
+/*
+ * Returns the first index in ext_Names[] for the given token-type
+ */
+static int _nc_first_ext_name(TERMTYPE *tp, int token_type)
+{
+ int first;
+
+ switch (token_type) {
+ case BOOLEAN:
+ first = 0;
+ break;
+ case NUMBER:
+ first = tp->ext_Booleans;
+ break;
+ case STRING:
+ first = tp->ext_Booleans + tp->ext_Numbers;
+ break;
+ default:
+ first = 0;
+ break;
+ }
+ return first;
+}
+
+/*
+ * Returns the last index in ext_Names[] for the given token-type
+ */
+static int _nc_last_ext_name(TERMTYPE *tp, int token_type)
+{
+ int last;
+
+ switch (token_type) {
+ case BOOLEAN:
+ last = tp->ext_Booleans;
+ break;
+ case NUMBER:
+ last = tp->ext_Booleans + tp->ext_Numbers;
+ break;
+ default:
+ case STRING:
+ last = NUM_EXT_NAMES(tp);
+ break;
+ }
+ return last;
+}
+
+/*
+ * Lookup an entry from extended-names, returning -1 if not found
+ */
+static int _nc_find_ext_name(TERMTYPE *tp, char *name, int token_type)
+{
+ unsigned j;
+ unsigned first = _nc_first_ext_name(tp, token_type);
+ unsigned last = _nc_last_ext_name(tp, token_type);
+
+ for (j = first; j < last; j++) {
+ if (!strcmp(name, tp->ext_Names[j])) {
+ return j;
+ }
+ }
+ return -1;
+}
+
+/*
+ * Translate an index into ext_Names[] into the corresponding index into data
+ * (e.g., Booleans[]).
+ */
+static int _nc_ext_data_index(TERMTYPE *tp, int n, int token_type)
+{
+ switch (token_type) {
+ case BOOLEAN:
+ n += (tp->num_Booleans - tp->ext_Booleans);
+ break;
+ case NUMBER:
+ n += (tp->num_Numbers - tp->ext_Numbers)
+ - (tp->ext_Booleans);
+ break;
+ default:
+ case STRING:
+ n += (tp->num_Strings - tp->ext_Strings)
+ - (tp->ext_Booleans + tp->ext_Numbers);
+ }
+ return n;
+}
+
+/*
+ * Adjust tables to remove (not free) an extended name and its corresponding
+ * data.
+ */
+static void _nc_del_ext_name(TERMTYPE *tp, char *name, int token_type)
+{
+ int j;
+ int first, last;
+
+ if ((first = _nc_find_ext_name(tp, name, token_type)) >= 0) {
+ last = NUM_EXT_NAMES(tp) - 1;
+ for (j = first; j < last; j++) {
+ tp->ext_Names[j] = tp->ext_Names[j+1];
+ }
+ first = _nc_ext_data_index(tp, first, token_type);
+ switch (token_type) {
+ case BOOLEAN:
+ last = tp->num_Booleans - 1;
+ for (j = first; j < last; j++)
+ tp->Booleans[j] = tp->Booleans[j+1];
+ tp->ext_Booleans -= 1;
+ tp->num_Booleans -= 1;
+ break;
+ case NUMBER:
+ last = tp->num_Numbers - 1;
+ for (j = first; j < last; j++)
+ tp->Numbers[j] = tp->Numbers[j+1];
+ tp->ext_Numbers -= 1;
+ tp->num_Numbers -= 1;
+ break;
+ case STRING:
+ last = tp->num_Strings - 1;
+ for (j = first; j < last; j++)
+ tp->Strings[j] = tp->Strings[j+1];
+ tp->ext_Strings -= 1;
+ tp->num_Strings -= 1;
+ break;
+ }
+ }
+}
+
+/*
+ * Adjust tables to insert an extended name, making room for new data. The
+ * index into the corresponding data array is returned.
+ */
+static int _nc_ins_ext_name(TERMTYPE *tp, char *name, int token_type)
+{
+ unsigned first = _nc_first_ext_name(tp, token_type);
+ unsigned last = _nc_last_ext_name(tp, token_type);
+ unsigned total = NUM_EXT_NAMES(tp) + 1;
+ unsigned j, k;
+
+ for (j = first; j < last; j++) {
+ int cmp = strcmp(name, tp->ext_Names[j]);
+ if (cmp == 0)
+ /* already present */
+ return _nc_ext_data_index(tp, j, token_type);
+ if (cmp < 0) {
+ break;
+ }
+ }
+
+ tp->ext_Names = typeRealloc(char *, total, tp->ext_Names);
+ for (k = total-1; k > j; k--)
+ tp->ext_Names[k] = tp->ext_Names[k-1];
+ tp->ext_Names[j] = name;
+ j = _nc_ext_data_index(tp, j, token_type);
+
+ switch (token_type) {
+ case BOOLEAN:
+ tp->ext_Booleans += 1;
+ tp->num_Booleans += 1;
+ tp->Booleans = typeRealloc(char, tp->num_Booleans, tp->Booleans);
+ for (k = tp->num_Booleans-1; k > j; k--)
+ tp->Booleans[k] = tp->Booleans[k-1];
+ break;
+ case NUMBER:
+ tp->ext_Numbers += 1;
+ tp->num_Numbers += 1;
+ tp->Numbers = typeRealloc(short, tp->num_Numbers, tp->Numbers);
+ for (k = tp->num_Numbers-1; k > j; k--)
+ tp->Numbers[k] = tp->Numbers[k-1];
+ break;
+ case STRING:
+ tp->ext_Strings += 1;
+ tp->num_Strings += 1;
+ tp->Strings = typeRealloc(char *, tp->num_Strings, tp->Strings);
+ for (k = tp->num_Strings-1; k > j; k--)
+ tp->Strings[k] = tp->Strings[k-1];
+ break;
+ }
+ return j;
+}
+
+/*
+ * Look for strings that are marked cancelled, which happen to be the same name
+ * as a boolean or number. We'll get this as a special case when we get a
+ * cancellation of a name that is inherited from another entry.
+ */
+static void adjust_cancels(TERMTYPE *to, TERMTYPE *from)
+{
+ int first = to->ext_Booleans + to->ext_Numbers;
+ int last = first + to->ext_Strings;
+ int j, k;
+
+ for (j = first; j < last; ) {
+ char *name = to->ext_Names[j];
+ unsigned j_str = to->num_Strings - first - to->ext_Strings;
+
+ if (to->Strings[j + j_str] == CANCELLED_STRING) {
+ if ((k = _nc_find_ext_name(from, to->ext_Names[j], BOOLEAN)) >= 0) {
+ _nc_del_ext_name(to, name, STRING);
+ k = _nc_ins_ext_name(to, name, BOOLEAN);
+ to->Booleans[k] = FALSE;
+ } else if ((k = _nc_find_ext_name(from, to->ext_Names[j], NUMBER)) >= 0) {
+ _nc_del_ext_name(to, name, STRING);
+ k = _nc_ins_ext_name(to, name, NUMBER);
+ to->Numbers[k] = CANCELLED_NUMERIC;
+ }
+ } else {
+ j++;
+ }
+ }
+}
+
+void _nc_align_termtype(TERMTYPE *to, TERMTYPE *from)
+{
+ int na = NUM_EXT_NAMES(to);
+ int nb = NUM_EXT_NAMES(from);
+ int n;
+ bool same;
+ char **ext_Names;
+ int ext_Booleans, ext_Numbers, ext_Strings;
+
+ DEBUG(2, ("align_termtype to(%d:%s), from(%d:%s)", na, to->term_names, nb, from->term_names));
+
+ if (na != 0 || nb != 0) {
+ if ((na == nb) /* check if the arrays are equivalent */
+ && (to->ext_Booleans == from->ext_Booleans)
+ && (to->ext_Numbers == from->ext_Numbers)
+ && (to->ext_Strings == from->ext_Strings)) {
+ for (n = 0, same = TRUE; n < na; n++) {
+ if (strcmp(to->ext_Names[n], from->ext_Names[n])) {
+ same = FALSE;
+ break;
+ }
+ }
+ if (same)
+ return;
+ }
+ /*
+ * This is where we pay for having a simple extension representation.
+ * Allocate a new ext_Names array and merge the two ext_Names arrays
+ * into it, updating to's counts for booleans, etc. Fortunately we do
+ * this only for the terminfo compiler (tic) and comparer (infocmp).
+ */
+ ext_Names = typeMalloc(char *, na+nb);
+
+ if (to->ext_Strings && (from->ext_Booleans + from->ext_Numbers))
+ adjust_cancels(to, from);
+
+ if (from->ext_Strings && (to->ext_Booleans + to->ext_Numbers))
+ adjust_cancels(from, to);
+
+ ext_Booleans = merge_names(ext_Names,
+ to->ext_Names,
+ to->ext_Booleans,
+ from->ext_Names,
+ from->ext_Booleans);
+ ext_Numbers = merge_names(ext_Names + ext_Booleans,
+ to->ext_Names
+ + to->ext_Booleans,
+ to->ext_Numbers,
+ from->ext_Names
+ + from->ext_Booleans,
+ from->ext_Numbers);
+ ext_Strings = merge_names(ext_Names + ext_Numbers + ext_Booleans,
+ to->ext_Names
+ + to->ext_Booleans
+ + to->ext_Numbers,
+ to->ext_Strings,
+ from->ext_Names
+ + from->ext_Booleans
+ + from->ext_Numbers,
+ from->ext_Strings);
+ /*
+ * Now we must reallocate the Booleans, etc., to allow the data to be
+ * overlaid.
+ */
+ if (na != (ext_Booleans + ext_Numbers + ext_Strings)) {
+ realign_data(to, ext_Names, ext_Booleans, ext_Numbers, ext_Strings);
+ free(to->ext_Names);
+ to->ext_Names = ext_Names;
+ DEBUG(2, ("realigned %d extended names for '%s' (to)", NUM_EXT_NAMES(to), to->term_names));
+ }
+ if (nb != (ext_Booleans + ext_Numbers + ext_Strings)) {
+ nb = (ext_Booleans + ext_Numbers + ext_Strings);
+ realign_data(from, ext_Names, ext_Booleans, ext_Numbers, ext_Strings);
+ from->ext_Names = typeRealloc(char *, nb, from->ext_Names);
+ memcpy(from->ext_Names, ext_Names, sizeof(char *) * nb);
+ DEBUG(2, ("realigned %d extended names for '%s' (from)", NUM_EXT_NAMES(from), from->term_names));
+ }
+ }
+}
+#endif
+
+void _nc_copy_termtype(TERMTYPE *dst, TERMTYPE *src)
+{
+ int i;
+
+ *dst = *src; /* ...to copy the sizes and string-tables */
+ dst->Booleans = typeMalloc(char, NUM_BOOLEANS(dst));
+ dst->Numbers = typeMalloc(short, NUM_NUMBERS(dst));
+ dst->Strings = typeMalloc(char *, NUM_STRINGS(dst));
+
+ /* FIXME: use memcpy for these and similar loops */
+ for_each_boolean(i,dst)
+ dst->Booleans[i] = src->Booleans[i];
+ for_each_number(i,dst)
+ dst->Numbers[i] = src->Numbers[i];
+ for_each_string(i,dst)
+ dst->Strings[i] = src->Strings[i];
+
+ /* FIXME: we probably should also copy str_table and ext_str_table,
+ * but tic and infocmp are not written to exploit that (yet).
+ */
+
+#if NCURSES_XNAMES
+ if ((i = NUM_EXT_NAMES(src)) != 0) {
+ dst->ext_Names = typeMalloc(char *, i);
+ memcpy(dst->ext_Names, src->ext_Names, i * sizeof(char *));
+ }
+#endif
+
+}
diff --git a/contrib/ncurses/ncurses/tinfo/captoinfo.c b/contrib/ncurses/ncurses/tinfo/captoinfo.c
new file mode 100644
index 000000000000..d0881ecd4792
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/captoinfo.c
@@ -0,0 +1,807 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+
+/*
+ * captoinfo.c --- conversion between termcap and terminfo formats
+ *
+ * The captoinfo() code was swiped from Ross Ridge's mytinfo package,
+ * adapted to fit ncurses by Eric S. Raymond <esr@snark.thyrsus.com>.
+ *
+ * There is just one entry point:
+ *
+ * char *captoinfo(n, s, parametrized)
+ *
+ * Convert value s for termcap string capability named n into terminfo
+ * format.
+ *
+ * This code recognizes all the standard 4.4BSD %-escapes:
+ *
+ * %% output `%'
+ * %d output value as in printf %d
+ * %2 output value as in printf %2d
+ * %3 output value as in printf %3d
+ * %. output value as in printf %c
+ * %+x add x to value, then do %.
+ * %>xy if value > x then add y, no output
+ * %r reverse order of two parameters, no output
+ * %i increment by one, no output
+ * %n exclusive-or all parameters with 0140 (Datamedia 2500)
+ * %B BCD (16*(value/10)) + (value%10), no output
+ * %D Reverse coding (value - 2*(value%16)), no output (Delta Data).
+ *
+ * Also, %02 and %03 are accepted as synonyms for %2 and %3.
+ *
+ * Besides all the standard termcap escapes, this translator understands
+ * the following extended escapes:
+ *
+ * used by GNU Emacs termcap libraries
+ * %a[+*-/=][cp]x GNU arithmetic.
+ * %m xor the first two parameters by 0177
+ * %b backup to previous parameter
+ * %f skip this parameter
+ *
+ * used by the University of Waterloo (MFCF) termcap libraries
+ * %-x subtract parameter FROM char x and output it as a char
+ * %ax add the character x to parameter
+ *
+ * If #define WATERLOO is on, also enable these translations:
+ *
+ * %sx subtract parameter FROM the character x
+ *
+ * By default, this Waterloo translations are not compiled in, because
+ * the Waterloo %s conflicts with the way terminfo uses %s in strings for
+ * function programming.
+ *
+ * Note the two definitions of %a: the GNU definition is translated if the
+ * characters after the 'a' are valid for it, otherwise the UW definition
+ * is translated.
+ */
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+#include <tic.h>
+
+MODULE_ID("$Id: captoinfo.c,v 1.24 1999/07/24 20:06:13 tom Exp $")
+
+#define MAX_PUSHED 16 /* max # args we can push onto the stack */
+#define MAX_ENTRY 2048 /* maximum chars in a translated capability */
+
+static int stack[MAX_PUSHED]; /* the stack */
+static int stackptr; /* the next empty place on the stack */
+static int onstack; /* the top of stack */
+static int seenm; /* seen a %m */
+static int seenn; /* seen a %n */
+static int seenr; /* seen a %r */
+static int param; /* current parameter */
+static char *dp; /* pointer to end of the converted string */
+
+static char *my_string;
+static size_t my_length;
+
+static char *init_string(void)
+/* initialize 'my_string', 'my_length' */
+{
+ if (my_string == 0)
+ my_string = typeMalloc(char, my_length = 256);
+ if (my_string == 0)
+ _nc_err_abort("Out of memory");
+
+ *my_string = '\0';
+ return my_string;
+}
+
+static char *save_string(char *d, const char *const s)
+{
+ size_t have = (d - my_string);
+ size_t need = have + strlen(s) + 2;
+ if (need > my_length) {
+ my_string = (char *)realloc(my_string, my_length = (need + need));
+ if (my_string == 0)
+ _nc_err_abort("Out of memory");
+ d = my_string + have;
+ }
+ (void) strcpy(d, s);
+ return d + strlen(d);
+}
+
+static inline char *save_char(char *s, char c)
+{
+ static char temp[2];
+ temp[0] = c;
+ return save_string(s, temp);
+}
+
+static void push(void)
+/* push onstack on to the stack */
+{
+ if (stackptr > MAX_PUSHED)
+ _nc_warning("string too complex to convert");
+ else
+ stack[stackptr++] = onstack;
+}
+
+static void pop(void)
+/* pop the top of the stack into onstack */
+{
+ if (stackptr == 0) {
+ if (onstack == 0)
+ _nc_warning("I'm confused");
+ else
+ onstack = 0;
+ }
+ else
+ onstack = stack[--stackptr];
+ param++;
+}
+
+static int cvtchar(register const char *sp)
+/* convert a character to a terminfo push */
+{
+ unsigned char c = 0;
+ int len;
+
+ switch(*sp) {
+ case '\\':
+ switch(*++sp) {
+ case '\'':
+ case '$':
+ case '\\':
+ case '%':
+ c = *sp;
+ len = 2;
+ break;
+ case '\0':
+ c = '\\';
+ len = 1;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ len = 1;
+ while (isdigit(*sp))
+ {
+ c = 8 * c + (*sp++ - '0');
+ len++;
+ }
+ break;
+ default:
+ c = *sp;
+ len = 2;
+ break;
+ }
+ break;
+ case '^':
+ c = (*++sp & 0x1f);
+ len = 2;
+ break;
+ default:
+ c = *sp;
+ len = 1;
+ }
+ if (isgraph(c) && c != ',' && c != '\'' && c != '\\' && c != ':') {
+ *dp++ = '%'; *dp++ = '\''; *dp++ = c; *dp++ = '\'';
+ } else {
+ *dp++ = '%'; *dp++ = '{';
+ if (c > 99)
+ *dp++ = c / 100 + '0';
+ if (c > 9)
+ *dp++ = ((int)(c / 10)) % 10 + '0';
+ *dp++ = c % 10 + '0';
+ *dp++ = '}';
+ }
+ return len;
+}
+
+static void getparm(int parm, int n)
+/* push n copies of param on the terminfo stack if not already there */
+{
+ if (seenr) {
+ if (parm == 1)
+ parm = 2;
+ else if (parm == 2)
+ parm = 1;
+ }
+ if (onstack == parm) {
+ if (n > 1) {
+ _nc_warning("string may not be optimal");
+ *dp++ = '%'; *dp++ = 'P'; *dp++ = 'a';
+ while(n--) {
+ *dp++ = '%'; *dp++ = 'g'; *dp++ = 'a';
+ }
+ }
+ return;
+ }
+ if (onstack != 0)
+ push();
+
+ onstack = parm;
+
+ while(n--) { /* %p0 */
+ *dp++ = '%'; *dp++ = 'p'; *dp++ = '0' + parm;
+ }
+
+ if (seenn && parm < 3) { /* %{96}%^ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '9'; *dp++ = '6'; *dp++ = '}';
+ *dp++ = '%'; *dp++ = '^';
+ }
+
+ if (seenm && parm < 3) { /* %{127}%^ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '1'; *dp++ = '2'; *dp++ = '7';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '^';
+ }
+}
+
+char *_nc_captoinfo(
+/* convert a termcap string to terminfo format */
+register const char *cap, /* relevant terminfo capability index */
+register const char *s, /* string value of the capability */
+int const parametrized) /* do % translations if 1, pad translations if >=0 */
+{
+ static char line[MAX_ENTRY];
+ const char *capstart;
+
+ stackptr = 0;
+ onstack = 0;
+ seenm = 0;
+ seenn = 0;
+ seenr = 0;
+ param = 1;
+
+ dp = line;
+
+ /* skip the initial padding (if we haven't been told not to) */
+ capstart = 0;
+ if (s == 0)
+ s = "";
+ if (parametrized >= 0 && isdigit(*s))
+ for (capstart = s; ; s++)
+ if (!(isdigit(*s) || *s == '*' || *s == '.'))
+ break;
+
+ while(*s != '\0') {
+ switch(*s) {
+ case '%':
+ s++;
+ if (parametrized < 1) {
+ *dp++ = '%';
+ break;
+ }
+ switch(*s++) {
+ case '%': *dp++ = '%'; break;
+ case 'r':
+ if (seenr++ == 1) {
+ _nc_warning("saw %%r twice in %s", cap);
+ }
+ break;
+ case 'm':
+ if (seenm++ == 1) {
+ _nc_warning("saw %%m twice in %s", cap);
+ }
+ break;
+ case 'n':
+ if (seenn++ == 1) {
+ _nc_warning("saw %%n twice in %s", cap);
+ }
+ break;
+ case 'i': *dp++ = '%'; *dp++ = 'i'; break;
+ case '6':
+ case 'B':
+ getparm(param, 2);
+ /* %{6}%*%+ */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '6';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '8':
+ case 'D':
+ getparm(param, 2);
+ /* %{2}%*%- */
+ *dp++ = '%'; *dp++ = '{'; *dp++ = '2';
+ *dp++ = '}'; *dp++ = '%'; *dp++ = '*';
+ *dp++ = '%'; *dp++ = '-';
+ break;
+ case '>':
+ getparm(param, 2);
+ /* %?%{x}%>%t%{y}%+%; */
+ *dp++ = '%'; *dp++ = '?';
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '>';
+ *dp++ = '%'; *dp++ = 't';
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ *dp++ = '%'; *dp++ = ';';
+ break;
+ case 'a':
+ if ((*s == '=' || *s == '+' || *s == '-'
+ || *s == '*' || *s == '/')
+ && (s[1] == 'p' || s[1] == 'c')
+ && s[2] != '\0') {
+ int l;
+ l = 2;
+ if (*s != '=')
+ getparm(param, 1);
+ if (s[1] == 'p') {
+ getparm(param + s[2] - '@', 1);
+ if (param != onstack) {
+ pop();
+ param--;
+ }
+ l++;
+ } else
+ l += cvtchar(s + 2);
+ switch(*s) {
+ case '+':
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '-':
+ *dp++ = '%'; *dp++ = '-';
+ break;
+ case '*':
+ *dp++ = '%'; *dp++ = '*';
+ break;
+ case '/':
+ *dp++ = '%'; *dp++ = '/';
+ break;
+ case '=':
+ if (seenr) {
+ if (param == 1)
+ onstack = 2;
+ else if (param == 2)
+ onstack = 1;
+ else
+ onstack = param;
+ }
+ else
+ onstack = param;
+ break;
+ }
+ s += l;
+ break;
+ }
+ getparm(param, 1);
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ break;
+ case '+':
+ getparm(param, 1);
+ s += cvtchar(s);
+ *dp++ = '%'; *dp++ = '+';
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case 's':
+#ifdef WATERLOO
+ s += cvtchar(s);
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '-';
+#else
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = 's';
+ pop();
+#endif /* WATERLOO */
+ break;
+ case '-':
+ s += cvtchar(s);
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = '-';
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case '.':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = 'c';
+ pop();
+ break;
+ case '0': /* not clear any of the historical termcaps did this */
+ if (*s == '3')
+ goto see03;
+ else if (*s != '2')
+ goto invalid;
+ /* FALLTHRU */
+ case '2':
+ getparm(param, 1);
+ *dp++ = '%'; /* *dp++ = '0'; */
+ *dp++ = '2'; *dp++ = 'd';
+ pop();
+ break;
+ case '3': see03:
+ getparm(param, 1);
+ *dp++ = '%'; /* *dp++ = '0'; */
+ *dp++ = '3'; *dp++ = 'd';
+ pop();
+ break;
+ case 'd':
+ getparm(param, 1);
+ *dp++ = '%'; *dp++ = 'd';
+ pop();
+ break;
+ case 'f':
+ param++;
+ break;
+ case 'b':
+ param--;
+ break;
+ case '\\':
+ *dp++ = '%';
+ *dp++ = '\\';
+ break;
+ default: invalid:
+ *dp++ = '%';
+ s--;
+ _nc_warning("unknown %% code %s in %s",
+ _tracechar(*s), cap);
+ break;
+ }
+ break;
+#ifdef REVISIBILIZE
+ case '\\':
+ *dp++ = *s++; *dp++ = *s++; break;
+ case '\n':
+ *dp++ = '\\'; *dp++ = 'n'; s++; break;
+ case '\t':
+ *dp++ = '\\'; *dp++ = 't'; s++; break;
+ case '\r':
+ *dp++ = '\\'; *dp++ = 'r'; s++; break;
+ case '\200':
+ *dp++ = '\\'; *dp++ = '0'; s++; break;
+ case '\f':
+ *dp++ = '\\'; *dp++ = 'f'; s++; break;
+ case '\b':
+ *dp++ = '\\'; *dp++ = 'b'; s++; break;
+ case ' ':
+ *dp++ = '\\'; *dp++ = 's'; s++; break;
+ case '^':
+ *dp++ = '\\'; *dp++ = '^'; s++; break;
+ case ':':
+ *dp++ = '\\'; *dp++ = ':'; s++; break;
+ case ',':
+ *dp++ = '\\'; *dp++ = ','; s++; break;
+ default:
+ if (*s == '\033') {
+ *dp++ = '\\';
+ *dp++ = 'E';
+ s++;
+ } else if (*s > 0 && *s < 32) {
+ *dp++ = '^';
+ *dp++ = *s + '@';
+ s++;
+ } else if (*s <= 0 || *s >= 127) {
+ *dp++ = '\\';
+ *dp++ = ((*s & 0300) >> 6) + '0';
+ *dp++ = ((*s & 0070) >> 3) + '0';
+ *dp++ = (*s & 0007) + '0';
+ s++;
+ } else
+ *dp++ = *s++;
+ break;
+#else
+ default:
+ *dp++ = *s++;
+ break;
+#endif
+ }
+ }
+
+ /*
+ * Now, if we stripped off some leading padding, add it at the end
+ * of the string as mandatory padding.
+ */
+ if (capstart)
+ {
+ *dp++ = '$';
+ *dp++ = '<';
+ for (s = capstart; ; s++)
+ if (isdigit(*s) || *s == '*' || *s == '.')
+ *dp++ = *s;
+ else
+ break;
+ *dp++ = '/';
+ *dp++ = '>';
+ }
+
+ *dp = '\0';
+ return(line);
+}
+
+/*
+ * Here are the capabilities infotocap assumes it can translate to:
+ *
+ * %% output `%'
+ * %d output value as in printf %d
+ * %2 output value as in printf %2d
+ * %3 output value as in printf %3d
+ * %. output value as in printf %c
+ * %+c add character c to value, then do %.
+ * %>xy if value > x then add y, no output
+ * %r reverse order of two parameters, no output
+ * %i increment by one, no output
+ * %n exclusive-or all parameters with 0140 (Datamedia 2500)
+ * %B BCD (16*(value/10)) + (value%10), no output
+ * %D Reverse coding (value - 2*(value%16)), no output (Delta Data).
+ * %m exclusive-or all parameters with 0177 (not in 4.4BSD)
+ */
+
+char *_nc_infotocap(
+/* convert a terminfo string to termcap format */
+register const char *cap GCC_UNUSED, /* relevant termcap capability index */
+register const char *str, /* string value of the capability */
+int const parametrized) /* do % translations if 1, pad translations if >=0 */
+{
+ int seenone = 0, seentwo = 0, saw_m = 0, saw_n = 0;
+ const char *padding;
+ const char *trimmed = 0;
+ char ch1 = 0, ch2 = 0;
+ char *bufptr = init_string();
+ char temp[256];
+
+ /* we may have to move some trailing mandatory padding up front */
+ padding = str + strlen(str) - 1;
+ if (*padding == '>' && *--padding == '/')
+ {
+ --padding;
+ while (isdigit(*padding) || *padding == '.' || *padding == '*')
+ padding--;
+ if (*padding == '<' && *--padding == '$')
+ trimmed = padding;
+ padding += 2;
+
+ while (isdigit(*padding) || *padding == '.' || *padding == '*')
+ bufptr = save_char(bufptr, *padding++);
+ }
+
+ for (; *str && str != trimmed; str++)
+ {
+ int c1, c2;
+ char *cp = 0;
+
+ if (str[0] == '\\' && (str[1] == '^' || str[1] == ','))
+ {
+ bufptr = save_char(bufptr, *++str);
+ }
+ else if (str[0] == '$' && str[1] == '<') /* discard padding */
+ {
+ str += 2;
+ while (isdigit(*str) || *str == '.' || *str == '*' || *str == '/' || *str == '>')
+ str++;
+ --str;
+ }
+ else if (*str != '%' || (parametrized < 1))
+ bufptr = save_char(bufptr, *str);
+ else if (sscanf(str, "%%?%%{%d}%%>%%t%%{%d}%%+%%;", &c1,&c2) == 2)
+ {
+ str = strchr(str, ';');
+ (void) sprintf(temp, "%%>%s%s", unctrl(c1), unctrl(c2));
+ bufptr = save_string(bufptr, temp);
+ }
+ else if (sscanf(str, "%%?%%{%d}%%>%%t%%'%c'%%+%%;", &c1,&ch2) == 2)
+ {
+ str = strchr(str, ';');
+ (void) sprintf(temp, "%%>%s%c", unctrl(c1), ch2);
+ bufptr = save_string(bufptr, temp);
+ }
+ else if (sscanf(str, "%%?%%'%c'%%>%%t%%{%d}%%+%%;", &ch1,&c2) == 2)
+ {
+ str = strchr(str, ';');
+ (void) sprintf(temp, "%%>%c%c", ch1, c2);
+ bufptr = save_string(bufptr, temp);
+ }
+ else if (sscanf(str, "%%?%%'%c'%%>%%t%%'%c'%%+%%;", &ch1, &ch2) == 2)
+ {
+ str = strchr(str, ';');
+ (void) sprintf(temp, "%%>%c%c", ch1, ch2);
+ bufptr = save_string(bufptr, temp);
+ }
+ else if (strncmp(str, "%{6}%*%+", 8) == 0)
+ {
+ str += 7;
+ (void) sprintf(temp, "%%B");
+ bufptr = save_string(bufptr, temp);
+ }
+ else if ((sscanf(str, "%%{%d}%%+%%c", &c1) == 1
+ || sscanf(str, "%%'%c'%%+%%c", &ch1) == 1)
+ && (cp = strchr(str, '+')))
+ {
+ str = cp + 2;
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, '+');
+
+ if (ch1)
+ c1 = ch1;
+ if (is7bits(c1) && isprint(c1))
+ bufptr = save_char(bufptr, (char)c1);
+ else
+ {
+ if (c1 == (c1 & 0x1f)) /* iscntrl() returns T on 255 */
+ (void) strcpy(temp, unctrl(c1));
+ else
+ (void) sprintf(temp, "\\%03o", c1);
+ bufptr = save_string(bufptr, temp);
+ }
+ }
+ else if (strncmp(str, "%{2}%*%-", 8) == 0)
+ {
+ str += 7;
+ (void) sprintf(temp, "%%D");
+ bufptr = save_string(bufptr, temp);
+ }
+ else if (strncmp(str, "%{96}%^", 7) == 0)
+ {
+ str += 6;
+ if (saw_m++ == 0)
+ {
+ (void) sprintf(temp, "%%n");
+ bufptr = save_string(bufptr, temp);
+ }
+ }
+ else if (strncmp(str, "%{127}%^", 8) == 0)
+ {
+ str += 7;
+ if (saw_n++ == 0)
+ {
+ (void) sprintf(temp, "%%m");
+ bufptr = save_string(bufptr, temp);
+ }
+ }
+ else
+ {
+ str++;
+ switch (*str) {
+ case '%':
+ bufptr = save_char(bufptr, '%');
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ bufptr = save_char(bufptr, '%');
+ while (isdigit(*str))
+ bufptr = save_char(bufptr, *str++);
+ if (*str == 'd')
+ str++;
+ else
+ _nc_warning("numeric prefix is missing trailing d in %s",
+ cap);
+ --str;
+ break;
+
+ case 'd':
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, 'd');
+ break;
+
+ case 'c':
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, '.');
+ break;
+
+ /*
+ * %s isn't in termcap, but it's convenient to pass it through
+ * so we can represent things like terminfo pfkey strings in
+ * termcap notation.
+ */
+ case 's':
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, 's');
+ break;
+
+ case 'p':
+ str++;
+ if (*str == '1')
+ seenone = 1;
+ else if (*str == '2')
+ {
+ if (!seenone && !seentwo)
+ {
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, 'r');
+ seentwo++;
+ }
+ }
+ else if (*str >= '3')
+ return(0);
+ break;
+
+ case 'i':
+ bufptr = save_char(bufptr, '%');
+ bufptr = save_char(bufptr, 'i');
+ break;
+
+ default:
+ return(0);
+
+ } /* endswitch (*str) */
+ } /* endelse (*str == '%') */
+
+ if (*str == '\0')
+ break;
+
+ } /* endwhile (*str) */
+
+ return(my_string);
+}
+
+#ifdef MAIN
+
+int curr_line;
+
+int main(int argc, char *argv[])
+{
+ int c, tc = FALSE;
+
+ while ((c = getopt(argc, argv, "c")) != EOF)
+ switch (c)
+ {
+ case 'c':
+ tc = TRUE;
+ break;
+ }
+
+ curr_line = 0;
+ for (;;)
+ {
+ char buf[BUFSIZ];
+
+ ++curr_line;
+ if (fgets(buf, sizeof(buf), stdin) == 0)
+ break;
+ buf[strlen(buf) - 1] = '\0';
+ _nc_set_source(buf);
+
+ if (tc)
+ {
+ char *cp = _nc_infotocap("to termcap", buf, 1);
+
+ if (cp)
+ (void) fputs(cp, stdout);
+ }
+ else
+ (void) fputs(_nc_captoinfo("to terminfo", buf, 1), stdout);
+ (void) putchar('\n');
+ }
+ return(0);
+}
+#endif /* MAIN */
+
+/* captoinfo.c ends here */
+
diff --git a/contrib/ncurses/ncurses/tinfo/comp_error.c b/contrib/ncurses/ncurses/tinfo/comp_error.c
new file mode 100644
index 000000000000..2b2d503013c0
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/comp_error.c
@@ -0,0 +1,132 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * comp_error.c -- Error message routines
+ *
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+
+MODULE_ID("$Id: comp_error.c,v 1.16 1998/08/01 23:39:51 tom Exp $")
+
+bool _nc_suppress_warnings;
+int _nc_curr_line; /* current line # in input */
+int _nc_curr_col; /* current column # in input */
+
+static const char *sourcename;
+static char termtype[MAX_NAME_SIZE+1];
+
+void _nc_set_source(const char *const name)
+{
+ sourcename = name;
+}
+
+void _nc_set_type(const char *const name)
+{
+ if (name)
+ strncpy( termtype, name, MAX_NAME_SIZE );
+ else
+ termtype[0] = '\0';
+}
+
+void _nc_get_type(char *name)
+{
+ strcpy( name, termtype );
+}
+
+static inline void where_is_problem(void)
+{
+ fprintf (stderr, "\"%s\"", sourcename);
+ if (_nc_curr_line >= 0)
+ fprintf (stderr, ", line %d", _nc_curr_line);
+ if (_nc_curr_col >= 0)
+ fprintf (stderr, ", col %d", _nc_curr_col);
+ if (termtype[0])
+ fprintf (stderr, ", terminal '%s'", termtype);
+ fputc(':', stderr);
+ fputc(' ', stderr);
+}
+
+void _nc_warning(const char *const fmt, ...)
+{
+va_list argp;
+
+ if (_nc_suppress_warnings)
+ return;
+
+ where_is_problem();
+ va_start(argp,fmt);
+ vfprintf (stderr, fmt, argp);
+ fprintf (stderr, "\n");
+ va_end(argp);
+}
+
+
+void _nc_err_abort(const char *const fmt, ...)
+{
+va_list argp;
+
+ where_is_problem();
+ va_start(argp,fmt);
+ vfprintf (stderr, fmt, argp);
+ fprintf (stderr, "\n");
+ va_end(argp);
+ exit(EXIT_FAILURE);
+}
+
+
+void _nc_syserr_abort(const char *const fmt, ...)
+{
+va_list argp;
+
+ where_is_problem();
+ va_start(argp,fmt);
+ vfprintf (stderr, fmt, argp);
+ fprintf (stderr, "\n");
+ va_end(argp);
+
+ /* If we're debugging, try to show where the problem occurred - this
+ * will dump core.
+ */
+#if defined(TRACE) || !defined(NDEBUG)
+ abort();
+#else
+ /* Dumping core in production code is not a good idea.
+ */
+ exit(EXIT_FAILURE);
+#endif
+}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_expand.c b/contrib/ncurses/ncurses/tinfo/comp_expand.c
new file mode 100644
index 000000000000..eb552fadabda
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/comp_expand.c
@@ -0,0 +1,189 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Thomas E. Dickey <dickey@clark.net> 1998 *
+ ****************************************************************************/
+
+#include <curses.priv.h>
+
+#include <ctype.h>
+#include <tic.h>
+
+MODULE_ID("$Id: comp_expand.c,v 1.11 1999/03/07 00:51:07 tom Exp $")
+
+static int trailing_spaces(const char *src)
+{
+ while (*src == ' ')
+ src++;
+ return *src == 0;
+}
+
+/* this deals with differences over whether 0x7f and 0x80..0x9f are controls */
+#define CHAR_OF(s) (*(unsigned const char *)(s))
+#define REALCTL(s) (CHAR_OF(s) < 127 && iscntrl(CHAR_OF(s)))
+#define REALPRINT(s) (CHAR_OF(s) < 127 && isprint(CHAR_OF(s)))
+
+char *_nc_tic_expand(const char *srcp, bool tic_format, int numbers)
+{
+static char * buffer;
+static size_t length;
+
+int bufp;
+const char *ptr, *str = VALID_STRING(srcp) ? srcp : "";
+bool islong = (strlen(str) > 3);
+size_t need = (2 + strlen(str)) * 4;
+int ch;
+
+ if (buffer == 0 || need > length) {
+ if ((buffer = typeRealloc(char, length = need, buffer)) == 0)
+ return 0;
+ }
+
+ bufp = 0;
+ ptr = str;
+ while ((ch = (*str & 0xff)) != 0) {
+ if (ch == '%' && REALPRINT(str+1)) {
+ buffer[bufp++] = *str++;
+ /*
+ * Though the character literals are more compact, most
+ * terminal descriptions use numbers and are not easy
+ * to read in character-literal form.
+ */
+ switch (numbers) {
+ case -1:
+ if (str[0] == S_QUOTE
+ && str[1] != '\\'
+ && REALPRINT(str+1)
+ && str[2] == S_QUOTE) {
+ sprintf(buffer+bufp, "{%d}", str[1]);
+ bufp += strlen(buffer+bufp);
+ str += 2;
+ } else {
+ buffer[bufp++] = *str;
+ }
+ break;
+ /*
+ * If we have a "%{number}", try to translate it into
+ * a "%'char'" form, since that will run a little faster
+ * when we're interpreting it. Also, having one form
+ * for the constant makes it simpler to compare terminal
+ * descriptions.
+ */
+ case 1:
+ if (str[0] == L_BRACE
+ && isdigit(str[1])) {
+ char *dst = 0;
+ long value = strtol(str+1, &dst, 0);
+ if (dst != 0
+ && *dst == R_BRACE
+ && value < 127
+ && value != '\\' /* FIXME */
+ && isprint((int)value)) {
+ ch = (int)value;
+ buffer[bufp++] = S_QUOTE;
+ if (ch == '\\'
+ || ch == S_QUOTE)
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = ch;
+ buffer[bufp++] = S_QUOTE;
+ str = dst;
+ } else {
+ buffer[bufp++] = *str;
+ }
+ } else {
+ buffer[bufp++] = *str;
+ }
+ break;
+ default:
+ buffer[bufp++] = *str;
+ break;
+ }
+ }
+ else if (ch == 128) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = '0';
+ }
+ else if (ch == '\033') {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 'E';
+ }
+ else if (ch == '\\' && tic_format && (str == srcp || str[-1] != '^')) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = '\\';
+ }
+ else if (ch == ' ' && tic_format && (str == srcp || trailing_spaces(str))) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 's';
+ }
+ else if ((ch == ',' || ch == ':' || ch == '^') && tic_format) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = ch;
+ }
+ else if (REALPRINT(str) && (ch != ',' && ch != ':' && !(ch == '!' && !tic_format) && ch != '^'))
+ buffer[bufp++] = ch;
+#if 0 /* FIXME: this would be more readable (in fact the whole 'islong' logic should be removed) */
+ else if (ch == '\b') {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 'b';
+ }
+ else if (ch == '\f') {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 'f';
+ }
+ else if (ch == '\t' && islong) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 't';
+ }
+#endif
+ else if (ch == '\r' && (islong || (strlen(srcp) > 2 && str[1] == '\0'))) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 'r';
+ }
+ else if (ch == '\n' && islong) {
+ buffer[bufp++] = '\\';
+ buffer[bufp++] = 'n';
+ }
+#define UnCtl(c) ((c) + '@')
+ else if (REALCTL(str) && ch != '\\' && (!islong || isdigit(str[1])))
+ {
+ (void) sprintf(&buffer[bufp], "^%c", UnCtl(ch));
+ bufp += 2;
+ }
+ else
+ {
+ (void) sprintf(&buffer[bufp], "\\%03o", ch);
+ bufp += 4;
+ }
+
+ str++;
+ }
+
+ buffer[bufp] = '\0';
+ return(buffer);
+}
diff --git a/contrib/ncurses/ncurses/tinfo/comp_hash.c b/contrib/ncurses/ncurses/tinfo/comp_hash.c
new file mode 100644
index 000000000000..7e0bdd0524fe
--- /dev/null
+++ b/contrib/ncurses/ncurses/tinfo/comp_hash.c
@@ -0,0 +1,325 @@
+/****************************************************************************
+ * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * *
+ * Permission is hereby granted, free of charge, to any person obtaining a *
+ * copy of this software and associated documentation files (the *
+ * "Software"), to deal in the Software without restriction, including *
+ * without limitation the rights to use, copy, modify, merge, publish, *
+ * distribute, distribute with modifications, sublicense, and/or sell *
+ * copies of the Software, and to permit persons to whom the Software is *
+ * furnished to do so, subject to the following conditions: *
+ * *
+ * The above copyright notice and this permission notice shall be included *
+ * in all copies or substantial portions of the Software. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
+ * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
+ * *
+ * Except as contained in this notice, the name(s) of the above copyright *
+ * holders shall not be used in advertising or otherwise to promote the *
+ * sale, use or other dealings in this Software without prior written *
+ * authorization. *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
+ * and: Eric S. Raymond <esr@snark.thyrsus.com> *
+ ****************************************************************************/
+
+
+/*
+ * comp_hash.c --- Routines to deal with the hashtable of capability
+ * names.
+ *
+ */
+
+#include <curses.priv.h>
+
+#include <tic.h>
+#include <hashsize.h>
+
+#ifdef MAIN_PROGRAM
+#include <ctype.h>
+#undef DEBUG
+#define DEBUG(level, params) /*nothing*/
+#endif
+
+MODULE_ID("$Id: comp_hash.c,v 1.21 1999/06/26 21:25:11 tom Exp $")
+
+static int hash_function(const char *);
+
+/*
+ * _nc_make_hash_table()
+ *
+ * Takes the entries in table[] and hashes them into hash_table[]
+ * by name. There are CAPTABSIZE entries in table[] and HASHTABSIZE
+ * slots in hash_table[].
+ *
+ */
+
+#ifdef MAIN_PROGRAM
+
+#undef MODULE_ID
+#define MODULE_ID(id) /*nothing*/
+#include <tinfo/doalloc.c>
+
+static void _nc_make_hash_table(struct name_table_entry *table,
+ struct name_table_entry **hash_table)
+{
+int i;
+int hashvalue;
+int collisions = 0;
+
+ for (i = 0; i < CAPTABSIZE; i++) {
+ hashvalue = hash_function(table[i].nte_name);
+
+ if (hash_table[hashvalue] != (struct name_table_entry *) 0)
+ collisions++;
+
+ if (hash_table[hashvalue] != 0)
+ table[i].nte_link = (short)(hash_table[hashvalue] - table);
+ hash_table[hashvalue] = &table[i];
+ }
+
+ DEBUG(4, ("Hash table complete: %d collisions out of %d entries", collisions, CAPTABSIZE));
+}
+#endif
+
+
+/*
+ * int hash_function(string)
+ *
+ * Computes the hashing function on the given string.
+ *
+ * The current hash function is the sum of each consectutive pair
+ * of characters, taken as two-byte integers, mod Hashtabsize.
+ *
+ */
+