Import unmodified (but trimmed) ncurses 5.0 prerelease 990821.

This contains the full eti (panel, form, menu) extensions.
bmake glue to follow.

Obtained from:	ftp://ftp.clark.net/pub/dickey/ncurses
This commit is contained in:
Peter Wemm 1999-08-24 01:06:48 +00:00
commit 0e3d540892
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/ncurses/dist/; revision=50276
svn path=/vendor/ncurses/5.0-19990821/; revision=50278; tag=vendor/ncurses/5.0-19990821
532 changed files with 150840 additions and 0 deletions

351
contrib/ncurses/ANNOUNCE Normal file
View File

@ -0,0 +1,351 @@
Announcing ncurses 5.0
The ncurses (new curses) library is a free software emulation of
curses in System V Release 4.0, and more. It uses terminfo format,
supports pads and color and multiple highlights and forms characters
and function-key mapping, and has all the other SYSV-curses
enhancements over BSD curses.
In mid-June 1995, the maintainer of 4.4BSD curses declared that he
considered 4.4BSD curses obsolete, and is encouraging the keepers of
Unix releases such as BSD/OS, freeBSD and netBSD to switch over to
ncurses.
The ncurses code was developed under GNU/Linux. It should port easily
to any ANSI/POSIX-conforming UNIX. It has even been ported to OS/2
Warp!
The distribution includes the library and support utilities, including
a terminfo compiler tic(1), a decompiler infocmp(1), clear(1),
tput(1), tset(1), and a termcap conversion tool captoinfo(1). Full
manual pages are provided for the library and tools.
The ncurses distribution is available via anonymous FTP at the GNU
distribution site [1]ftp://ftp.gnu.org/pub/gnu. It is also available
at [2]ftp://ftp.clark.net/pub/dickey/ncurses.
Release Notes
We decided to release ncurses as a new whole number release (5.0)
because it incorporates several interface changes, including some that
would invalidate existing shared libraries. These are the highlights
from the change-log since ncurses 4.2 release.
Interface changes:
* The principal source of changes to the interface comes from the
release of X/Open Curses in 1997. Earlier versions of ncurses (4.0
and before) were based on a draft version of the specification.
The release version adds parameters to some functions to support
the evolving internationalization of curses. These summarize the
impact:
+ modified several prototypes to correspond with 1997 version
of X/Open Curses (affects ABI since developers have used
attr_get).
+ corrected prototypes for slk_* functions, using chtype rather
than attr_t.
+ the slk_attr_{set,off,on} functions need an additional void*
parameter according to XSI.
+ correct macros for wattr_set, wattr_get, separate wattrset
macro from these to preserve behavior that allows attributes
to be combined with color pair numbers.
+ reviewed/updated curses.h, term.h against X/Open Curses Issue
4 Version 2. This includes making some parameters
NCURSES_CONST rather than const, e.g., in termcap.h.
+ reviewed/corrected macros in curses.h as per XSI document.
+ add set_a_attributes and set_pglen_inch to terminfo
structure, as per XSI and Solaris 2.5.
* The newest version of the X/Open Curses is implemented on Solaris
and other vendor's systems. It adds new features to the terminfo
descriptions:
+ implement tparm %l format.
+ implement tparm printf-style width and precision for %s, %d,
%x, %o as per XSI.
* We made additional changes to reduce impact by future interface
changes:
+ change key_names[] array to static since it is not part of
the curses interface.
+ move macro winch to a function, to hide details of struct
ldat
* modify configure script to embed ABI in shared libraries for HP-UX
10.x (detailed request by Tim Mooney).
* modify configuration of shared libraries on Digital Unix so that
versioning is embedded in the library, rather than implied by
links (patch by Tim Mooney).
New features:
* enable sigwinch handler by default.
* turn on hashmap scrolling code by default
* improved support for termcap applications
+ modify tput to accept termcap names as an alternative to
terminfo names.
+ provide support for termcap PC variable by copying it from
terminfo data and using it as the padding character in tputs.
+ provide support for termcap ospeed variable by copying it
from the internal cur_term member, and using ospeed as the
baudrate reference for the delay_output and tputs functions.
+ change name-comparisons in lib_termcap to compare no more
than 2 characters.
+ add configure option --enable-tcap-names, which essentially
allows users to define new capabilities as in termcap.
* add mouse support to ncurses menus.
* add mouse and dll support for OS/2 EMX
* modify terminfo parsing to accept octal and hexadecimal constants
* add configure option --enable-no-padding, to allow environment
variable $NCURSES_NO_PADDING to eliminate non-mandatory padding,
thereby making terminal emulators (e.g., for vt100) a little more
efficient.
* modify lib_color.c to eliminate dependency on orig_colors and
orig_pair, since SVr4 curses does not require these either, but
uses them when they are available.
* add -f option to infocmp and tic, which formats the terminfo
if/then/else/endif so that they are readable (with newlines and
tabs).
* modify tic to compile into %'char' form in preference to
%{number}, since that is a little more efficient.
Major bug fixes:
* modify lib_tstp.c to block SIGTTOU when handling SIGTSTP, fixes a
problem where ncurses applications which were run via a shell
script would hang when given a ^Z. Also, check if the terminal's
process group is consistent, i.e., a shell has not taken ownership
of it, before deciding to save the current terminal settings in
the SIGTSTP handler.
* suppress sc/rc capabilities from terminal description if they
appear in smcup/rmcup. This affects only scrolling optimization,
to fix a problem reported by several people with xterm's alternate
screen, though the problem is more general.
* modify relative_move and tputs to avoid an interaction with the
BSD-style padding. The relative_move function could produce a
string to replace on the screen which began with a numeric
character, which was then interpreted by tputs as padding.
* modify setupterm so that cancelled strings are treated the same as
absent strings, cancelled and absent booleans false (does not
affect tic, infocmp).
* modify lib_vidattr.c to allow for terminal types (e.g.,
xterm-color) which may reset all attributes in the 'op'
capability, so that colors are set before turning on bold and
other attributes, but still after turning attributes off.
* use 'access()' to check if ncurses library should be permitted to
open or modify files with fopen/open/link/unlink/remove calls, in
case the calling application is running in setuid mode.
* correction to doupdate, for case where terminal does not support
insert/delete character. The logic did not check that there was a
difference in alignment of changes to old/new screens before
repainting the whole non-blank portion of the line. Modified to
fall through into logic that reduces by the portion which does not
differ.
Features of Ncurses
The ncurses package is fully compatible with SVr4 (System V Release 4)
curses:
* All 257 of the SVr4 calls have been implemented (and are
documented).
* Full support for SVr4 curses features including keyboard mapping,
color, forms-drawing with ACS characters, and automatic
recognition of keypad and function keys.
* An emulation of the SVr4 panels library, supporting a stack of
windows with backing store, is included.
* An emulation of the SVr4 menus library, supporting a uniform but
flexible interface for menu programming, is included.
* An emulation of the SVr4 form library, supporting data collection
through on-screen forms, is included.
* Binary terminfo entries generated by the ncurses tic(1)
implementation are bit-for-bit-compatible with the entry format
SVr4 curses uses.
* The utilities have options to allow you to filter terminfo entries
for use with less capable curses/terminfo versions such as the
HP/UX and AIX ports.
The ncurses package also has many useful extensions over SVr4:
* The API is 8-bit clean and base-level conformant with the X/OPEN
curses specification, XSI curses (that is, it implements all BASE
level features, but not all EXTENDED features). Most
EXTENDED-level features not directly concerned with wide-character
support are implemented, including many function calls not
supported under SVr4 curses (but portability of all calls is
documented so you can use the SVr4 subset only).
* Unlike SVr4 curses, ncurses can write to the rightmost-bottommost
corner of the screen if your terminal has an insert-character
capability.
* Ada95 and C++ bindings.
* Support for mouse event reporting with X Window xterm and OS/2
console windows.
* Extended mouse support via Alessandro Rubini's gpm package.
* The function wresize() allows you to resize windows, preserving
their data.
* The function use_default_colors() allows you to use the terminal's
default colors for the default color pair, achieving the effect of
transparent colors.
* The functions keyok() and define_key() allow you to better control
the use of function keys, e.g., disabling the ncurses KEY_MOUSE,
or by defining more than one control sequence to map to a given
key code.
* Support for 16-color terminals, such as aixterm and XFree86 xterm.
* Better cursor-movement optimization. The package now features a
cursor-local-movement computation more efficient than either BSD's
or System V's.
* Super hardware scrolling support. The screen-update code
incorporates a novel, simple, and cheap algorithm that enables it
to make optimal use of hardware scrolling, line-insertion, and
line-deletion for screen-line movements. This algorithm is more
powerful than the 4.4BSD curses quickch() routine.
* Real support for terminals with the magic-cookie glitch. The
screen-update code will refrain from drawing a highlight if the
magic- cookie unattributed spaces required just before the
beginning and after the end would step on a non-space character.
It will automatically shift highlight boundaries when doing so
would make it possible to draw the highlight without changing the
visual appearance of the screen.
* It is possible to generate the library with a list of pre-loaded
fallback entries linked to it so that it can serve those terminal
types even when no terminfo tree or termcap file is accessible
(this may be useful for support of screen-oriented programs that
must run in single-user mode).
* The tic(1)/captoinfo utility provided with ncurses has the ability
to translate many termcaps from the XENIX, IBM and AT&T extension
sets.
* A BSD-like tset(1) utility is provided.
* The ncurses library and utilities will automatically read terminfo
entries from $HOME/.terminfo if it exists, and compile to that
directory if it exists and the user has no write access to the
system directory. This feature makes it easier for users to have
personal terminfo entries without giving up access to the system
terminfo directory.
* You may specify a path of directories to search for compiled
descriptions with the environment variable TERMINFO_DIRS (this
generalizes the feature provided by TERMINFO under stock System
V.)
* In terminfo source files, use capabilities may refer not just to
other entries in the same source file (as in System V) but also to
compiled entries in either the system terminfo directory or the
user's $HOME/.terminfo directory.
* A script (capconvert) is provided to help BSD users transition
from termcap to terminfo. It gathers the information in a TERMCAP
environment variable and/or a ~/.termcap local entries file and
converts it to an equivalent local terminfo tree under
$HOME/.terminfo.
* Automatic fallback to the /etc/termcap file can be compiled in
when it is not possible to build a terminfo tree. This feature is
neither fast nor cheap, you don't want to use it unless you have
to, but it's there.
* The table-of-entries utility toe makes it easy for users to see
exactly what terminal types are available on the system.
* The library meets the XSI requirement that every macro entry point
have a corresponding function which may be linked (and will be
prototype-checked) if the macro definition is disabled with
#undef.
* An HTML "Introduction to Programming with NCURSES" document
provides a narrative introduction to the curses programming
interface.
State of the Package
Numerous bugs present in earlier versions have been fixed; the library
is far more reliable than it used to be. Bounds checking in many
`dangerous' entry points has been improved. The code is now type-safe
according to gcc -Wall. The library has been checked for malloc leaks
and arena corruption by the Purify memory-allocation tester.
The ncurses code has been tested with a wide variety of applications
including (versions starting with those noted):
ded
directory-editor [3]ftp://ftp.clark.net/pub/dickey/ded.
dialog
the underlying application used in Slackware's setup, and the
basis for similar applications on GNU/Linux.
lynx-2.7
the character-screen WWW browser
Midnight Commander 4.1
file manager
mutt 0.88
mail utility
ncftp 2.0
file-transfer utility
nvi
New vi versions 1.50 are able to use ncurses versions 1.9.7 and
later.
taper
tape archive utility
vh-1.6
Volks-Hypertext browser for the Jargon File
as well as some that use ncurses for the terminfo support alone:
minicom-1.75
terminal emulator
tin-unoff
tin 1.4 newsreader, supporting color, MIME
[4]ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff.
vile
vi-like-emacs [5]ftp://ftp.clark.net/pub/dickey/vile.
The ncurses distribution includes a selection of test programs
(including a few games).
Who's Who and What's What
The original developers of ncurses are [6]Zeyd Ben-Halim and [7]Eric
S. Raymond. Ongoing work is being done by [8]Thomas Dickey and
[9]Jürgen Pfeifer. [10]Florian La Roche acts as the maintainer for the
Free Software Foundation, which holds the copyright on ncurses.
Contact the current maintainers at [11]bug-ncurses@gnu.org.
To join the ncurses mailing list, please write email to
bug-ncurses-request@gnu.org containing the line:
subscribe <name>@<host.domain>
This list is open to anyone interested in helping with the development
and testing of this package.
Beta versions of ncurses and patches to the current release are made
available at [12]ftp://ftp.clark.net/pub/dickey/ncurses.
Future Plans
* Extended-level XPG4 conformance, with internationalization
support.
* Ports to more systems, including DOS and Windows.
We need people to help with these projects. If you are interested in
working on them, please join the ncurses list.
Other Related Resources
The distribution includes and uses a version of the terminfo-format
terminal description file maintained by Eric Raymond.
[13]http://earthspace.net/~esr/terminfo.
You can find lots of information on terminal-related topics not
covered in the terminfo file at [14]Richard Shuford's archive.
References
1. ftp://ftp.gnu.org/pub/gnu
2. ftp://ftp.clark.net/pub/dickey/ncurses
3. ftp://ftp.clark.net/pub/dickey/ded
4. ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff
5. ftp://ftp.clark.net/pub/dickey/vile
6. mailto:zmbenhal@netcom.com
7. http://www.ccil.org/~esr/home.html
8. mailto:dickey@clark.net
9. mailto:juergen.pfeifer@gmx.net
10. mailto:florian@gnu.org
11. mailto:bug-ncurses@gnu.org
12. ftp://ftp.clark.net/pub/dickey/ncurses
13. http://earthspace.net/~esr/terminfo
14. http://www.cs.utk.edu/~shuford/terminal_index.html

481
contrib/ncurses/INSTALL Normal file
View File

@ -0,0 +1,481 @@
-- $Id: INSTALL,v 1.32 1999/07/24 21:06:24 tom Exp $
---------------------------------------------------------------------
How to install Ncurses/Terminfo on your system
---------------------------------------------------------------------
************************************************************
* READ ALL OF THIS FILE BEFORE YOU TRY TO INSTALL NCURSES. *
************************************************************
You should be reading the file INSTALL in a directory called ncurses-d.d, where
d.d is the current version number. There should be several subdirectories,
including `c++', `form', `man', `menu', 'misc', `ncurses', `panel', `progs',
and `test'. See the README file for a roadmap to the package.
If you are a Linux or FreeBSD or NetBSD distribution integrator or packager,
please read and act on the section titled IF YOU ARE A SYSTEM INTEGRATOR
below.
If you are converting from BSD curses and do not have root access, be sure
to read the BSD CONVERSION NOTES section below.
If you are using a version of XFree86 xterm older than 3.1.2F, see the section
on RECENT XTERM VERSIONS below.
If you are trying to build GNU Emacs using ncurses for terminal support,
read the USING NCURSES WITH EMACS section below.
If you are trying to build applications using gpm with ncurses,
read the USING NCURSES WITH GPM section below.
If you are trying to build Elvis using ncurses for terminal support,
read the USING NCURSES WITH ELVIS section below.
If you are running over the Andrew File System see the note below on
USING NCURSES WITH AFS.
If you want to build the Ada95 binding, go to the Ada95 directory and
follow the instructions there. The Ada95 binding is not covered below.
If you are using anything but (a) Linux, or (b) one of the 4.4BSD-based
i386 Unixes, go read the Portability section in the TO-DO file before you
do anything else.
REQUIREMENTS:
You will need the following in order to build and install ncurses under UNIX:
* ANSI C compiler (gcc is recommended)
* sh (bash will do)
* awk (mawk or gawk will do)
* sed
* BSD or System V style install (a script is enclosed)
Ncurses has been also built in the OS/2 EMX environment.
INSTALLATION PROCEDURE:
1. First, decide whether you want ncurses to replace your existing library (in
which case you'll need super-user privileges) or be installed in parallel
with it.
The --prefix option to configure changes the root directory for installing
ncurses. The default is in subdirectories of /usr/local. Use
--prefix=/usr to replace your default curses distribution. This is the
default for Linux and BSD/OS users.
The package gets installed beneath the --prefix directory as follows:
In $(prefix)/bin: tic, infocmp, captoinfo, tset,
reset, clear, tput, toe
In $(prefix)/lib: libncurses*.* libcurses.a
In $(prefix)/share/terminfo: compiled terminal descriptions
In $(prefix)/include: C header files
Under $(prefix)/man: the manual pages
Note however that the configure script attempts to locate previous
installation of ncurses, and will set the default prefix according to where
it finds the ncurses headers.
2. Type `./configure' in the top-level directory of the distribution to
configure ncurses for your operating system and create the Makefiles.
Besides --prefix, various configuration options are available to customize
the installation; use `./configure --help' to list the available options.
If your operating system is not supported, read the PORTABILITY section in
the file ncurses/README for information on how to create a configuration
file for your system.
The `configure' script generates makefile rules for one or more object
models and their associated libraries:
libncurses.a (normal)
libcurses.a (normal, a link to libncurses.a)
This gets left out if you configure with --disable-overwrite.
libncurses.so (shared)
libncurses_g.a (debug)
libncurses_p.a (profile)
If you do not specify any models, the normal and debug libraries will be
configured. Typing `configure' with no arguments is equivalent to:
./configure --with-normal --with-debug --enable-overwrite
Typing
./configure --with-shared
makes the shared libraries the default, resulting in
./configure --with-shared --with-normal --with-debug --enable-overwrite
If you want only shared libraries, type
./configure --with-shared --without-normal --without-debug
Rules for generating shared libraries are highly dependent upon the choice
of host system and compiler. We've been testing shared libraries on Linux
and SunOS with gcc, but more work needs to be done to make shared libraries
work on other systems.
You can make curses and terminfo fall back to an existing file of termcap
definitions by configuring with --enable-termcap. If you do this, the
library will search /etc/termcap before the terminfo database, and will
also interpret the contents of the TERM environment variable. See the
section BSD CONVERSION NOTES below.
3. Type `make'. Ignore any warnings, no error messages should be produced.
This should compile the ncurses library, the terminfo compiler tic(1),
captoinfo(1), infocmp(1), toe(1), clear(1) tset(1), reset(1), and tput(1)
programs (see the man pages for explanation of what they do), some test
programs, and the panels, menus, and forms libraries.
4. Run ncurses and several other test programs in the test directory to
verify that ncurses functions correctly before doing an install that
may overwrite system files. Read the file test/README for details on
the test programs.
NOTE: You must have installed the terminfo database, or set the
environment variable $TERMINFO to point to a SVr4-compatible terminfo
database before running the test programs. Not all vendors' terminfo
databases are SVr4-compatible, but most seem to be. Exceptions include
DEC's Digital Unix (formerly known as OSF/1).
The ncurses program is designed specifically to test the ncurses library.
You can use it to verify that the screen highlights work correctly, that
cursor addressing and window scrolling works OK, etc.
5. Once you've tested, you can type `make install' to install libraries,
the programs, the terminfo database and the man pages. Alternately, you
can type `make install' in each directory you want to install. In the
top-level directory, you can do a partial install using these commands:
'make install.progs' installs tic, infocmp, etc...
'make install.includes' installs the headers.
'make install.libs' installs the libraries (and the headers).
'make install.data' installs the terminfo data. (Note: `tic' must
be installed before the terminfo data can be
compiled).
'make install.man' installs the man pages.
############################################################################
# CAVEAT EMPTOR: `install.data' run as root will NUKE any existing #
# terminfo database. If you have any custom or unusual entries SAVE them #
# before you install ncurses. I have a file called terminfo.custom for #
# this purpose. Don't forget to run tic on the file once you're done. #
############################################################################
The terminfo(5) manual page wants to be preprocessed with tbl(1) before
being formatted by nroff(1). Modern man(1) implementations tend to do
this by default, but you may want to look at your version's man page
to be sure.
If the system already has a curses library that you need to keep using
for some bizarre binary-compatibility reason, you'll need to distinguish
between it and ncurses. If ncurses is installed outside the standard
directories (/usr/include and /usr/lib) then all your users will need
to use the -I option to compile programs and -L to link them.
If you have BSD curses installed in your system and you accidentally
compile using its curses.h you'll end up with a large number of
undefined symbols at link time. _waddbytes is one of them.
IF YOU DO NOT HAVE ROOT: Change directory to the `progs' subdirectory
and run the `capconvert' script. This script will deduce various things
about your environment and use them to build you a private terminfo tree,
so you can use ncurses applications.
If more than one user at your site does this, the space for the duplicate
trees is wasted. Try to get your site administrators to install a system-
wide terminfo tree instead.
See the BSD CONVERSION NOTES section below for a few more details.
6. The c++ directory has C++ classes that are built on top of ncurses and
panels. You need to have c++ (and its libraries) installed before you can
compile and run the demo.
If you do not have C++, you must use the --without-cxx option to tell
the configure script to not attempt to build the C++ bindings.
7. If you're running an older Linux, you must either (a) tell Linux that the
console terminal type is `linux' or (b) make a link to or copy of the
linux entry in the appropriate place under your terminfo directory, named
`console'. All 1.3 and many 1.2 distributions (including Yggdrasil and
Red Hat) already have the console type set to `linux'.
The way to change the wired-in console type depends on the configuration
of your system. This may involve editing /etc/inittab, /etc/ttytype,
/etc/profile and other such files.
Warning: this is not for the fainthearted, if you mess up your console
getty entries you can make your system unusable! However, if you are
a distribution maker, this is the right thing to do (see the note for
integrators near the end of this file).
The easier way is to link or copy l/linux to c/console under your terminfo
directory. Note: this will go away next time you do `make install.data'
and you'll have to redo it. There is no need to have entries for all
possible screen sizes, ncurses will figure out the size automatically.
IF YOU ARE A SYSTEM INTEGRATOR:
Beginning with 1.9.9, the ncurses distribution includes both a tset
utility and /usr/share/tabset directory. If you are installing ncurses,
it is no longer either necessary or desirable to install tset-jv.
Configuration and Installation:
Configure with --prefix=/usr to make the install productions put
libraries and headers in the correct locations (overwriting any
previous curses libraries and headers). This will put the terminfo
hierarchy under /usr/share/terminfo; you may want to override this with
--datadir=/usr/share/misc; terminfo and tabset are installed under the
data directory.
Please configure the ncurses library in a pure-terminfo mode; that
is, with the --disable-termcap option. This will make the ncurses
library smaller and faster. The ncurses library includes a termcap
emulation that queries the terminfo database, so even applications
that use raw termcap to query terminal characteristics will win
(providing you recompile and relink them!).
If you must configure with termcap fallback enabled, you may also
wish to use the --enable-getcap option. This option speeds up
termcap-based startups, at the expense of not allowing personal
termcap entries to reference the terminfo tree. See the code in
ncurses/tinfo/read_termcap.c for details.
Note that if you have $TERMCAP set, ncurses will use that value
to locate termcap data. In particular, running from xterm will
set $TERMCAP to the contents of the xterm's termcap entry.
If ncurses sees that, it will not examine /etc/termcap.
Keyboard Mapping:
The terminfo file assumes that Shift-Tab generates \E[Z (the ECMA-48
reverse-tabulation sequence) rather than ^I. Here are the loadkeys -d
mappings that will set this up:
keycode 15 = Tab Tab
alt keycode 15 = Meta_Tab
shift keycode 15 = F26
string F26 ="\033[Z"
Naming the Console Terminal
In various Linuxes (and possibly elsewhere) there has been a practice
of designating the system console driver type as `console'. Please
do not do this any more! It complicates peoples' lives, because it
can mean that several different terminfo entries from different
operating systems all logically want to be called `console'.
Please pick a name unique to your console driver and set that up
in the /etc/inittab table or local equivalent. Send the entry to the
terminfo maintainer (listed in the misc/terminfo file) to be included
in the terminfo file, if it's not already there. See the
term(7) manual page included with this distribution for more on
conventions for choosing type names.
Here are some recommended primary console names:
linux -- Linux console driver
freebsd -- FreeBSD
netbsd -- NetBSD
bsdos -- BSD/OS
If you are responsible for integrating ncurses for one of these
distribution, please either use the recommended name or get back
to us explaining why you don't want to, so we can work out nomenclature
that will make users' lives easier rather than harder.
RECENT XTERM VERSIONS
The terminfo database file included with this distribution assumes you
are running an XFree86 xterm based on X11R6 (i.e., xterm-r6). The
earlier X11R5 entry (xterm-r5) is provided as well.
If you are running XFree86 version 3.2 (actually 3.1.2F and up), you
should consider using the xterm-xf86-v32 (or later, the most recent
version is always named "xterm-xfree86") entry, which adds ANSI color
and the VT220 capabilities which have been added in XFree86. If you
are running a mixed network, however, where this terminal description
may be used on an older xterm, you may have problems, since
applications that assume these capabilities will produce incorrect
output on the older xterm (e.g., highlighting is not cleared).
CONFIGURING FALLBACK ENTRIES
In order to support operation of ncurses programs before the terminfo
tree is accessible (that is, in single-user mode or at OS installation
time) the ncurses library can be compiled to include an array of
pre-fetched fallback entries.
These entries are checked by setupterm() only when the conventional
fetches from the terminfo tree and the termcap fallback (if configured)
have been tried and failed. Thus, the presence of a fallback will not
shadow modifications to the on-disk entry for the same type, when that
entry is accessible.
By default, there are no entries on the fallback list. After you
have built the ncurses suite for the first time, you can change
the list (the process needs infocmp(1)). To do so, use the script
MKfallback.sh. A configure script option --with-fallbacks does this
(it accepts a comma-separated list of the names you wish, and does
not require a rebuild).
If you wanted (say) to have linux, vt100, and xterm fallbacks, you
would use the commands
cd ncurses;
MKfallback.sh linux vt100 xterm >fallback.c
Then just rebuild and reinstall the library as you would normally.
You can restore the default empty fallback list with
MKfallback.sh >fallback.c
The overhead for an empty fallback list is one trivial stub function.
Any non-empty fallback list is const-ed and therefore lives in sharable
text space. You can look at the comment trailing each initializer in
the generated ncurses/fallback.c file to see the core cost of the
fallbacks. A good rule of thumb for modern vt100-like entries is that
each one will cost about 2.5K of text space.
BSD CONVERSION NOTES:
If you need to support really ancient BSD programs, you probably
want to configure with the --enable-bsdpad option. What this does
is enable code in tputs() that recognizes a numeric prefix on a
capability as a request for that much trailing padding in milliseconds.
There are old BSD programs that do things like tputs("50").
(If you are distributing ncurses as a support-library component of
an application you probably want to put the remainder of this section
in the package README file.)
The following note applies only if you have configured ncurses with
--enable-termcap.
------------------------------- CUT HERE --------------------------------
If you are installing this application privately (either because you
have no root access or want to experiment with it before doing a root
installation), there are a couple of details you need to be aware of.
They have to do with the ncurses library, which uses terminfo rather
than termcap for describing terminal characteristics.
Though the ncurses library is terminfo-based, it will interpret your
TERMCAP variable (if present), any local termcap files you reference
through it, and the system termcap file. However, in order to avoid
slowing down your application startup, it will only do this once per
terminal type!
The first time you load a given terminal type from your termcap
database, the library initialization code will automatically write it
in terminfo format to a subdirectory under $HOME/.terminfo. After
that, the initialization code will find it there and do a (much
faster) terminfo fetch.
Usually, all this means is that your home directory will silently grow
an invisible .terminfo subdirectory which will get filled in with
terminfo descriptions of terminal types as you invoke them. If anyone
ever installs a global terminfo tree on your system, this will quietly
stop happening and your $HOME/.terminfo will become redundant.
The objective of all this logic is to make converting from BSD termcap
as painless as possible without slowing down your application (termcap
compilation is expensive).
If you don't have a TERMCAP variable or custom personal termcap file,
you can skip the rest of this dissertation.
If you *do* have a TERMCAP variable and/or a custom personal termcap file
that defines a terminal type, that definition will stop being visible
to this application after the first time you run it, because it will
instead see the terminfo entry that it wrote to $HOME/terminfo the
first time around.
Subsequently, editing the TERMCAP variable or personal TERMCAP file
will have no effect unless you explicitly remove the terminfo entry
under $HOME/terminfo. If you do that, the entry will be recompiled
from your termcap resources the next time it is invoked.
To avoid these complications, use infocmp(1) and tic(1) to edit the
terminfo directory directly.
------------------------------- CUT HERE --------------------------------
USING NCURSES WITH AFS:
AFS treats each directory as a separate logical filesystem, you
can't hard-link across them. The --enable-symlinks option copes
with this by making tic use symbolic links.
USING NCURSES WITH EMACS:
GNU Emacs has its own termcap support. By default, it uses a mixture
of those functions and code linked from the host system's libraries.
You need to foil this and shut out the GNU termcap library entirely.
In order to do this, hack the Linux config file (s/linux.h) to contain
a #define TERMINFO and set the symbol LIBS_TERMCAP to "-lncurses".
We have submitted such a change for the 19.30 release, so it may
already be applied in your sources -- check for the #define TERMINFO.
USING NCURSES WITH GPM:
Ncurses 4.1 and up can be configured to use GPM (General Purpose Mouse)
which is used on Linux console. Be aware that GPM is commonly
installed as a shared library which contains a wrapper for the curses
wgetch() function (libcurses.o). Some integrators have simplified
linking applications by combining all of libcurses.so (the BSD curses)
into the libgpm.so file, producing symbol conflicts with ncurses. You
may be able to work around this problem by linking as follows:
cc -o foo foo.o -lncurses -lgpm -lncurses
but the linker may not cooperate, producing mysterious errors.
A patched version of gpm is available:
ftp.clark.net:/pub/dickey/ncurses/gpm-1.10-970125.tgz
This patch is incorporated in gpm 1.12; however some integrators
are slow to update this library.
USING NCURSES WITH ELVIS:
To use ncurses as the screen-painting library for Elvis, apply the
following patch to the Elvis curses
*** curses.c.orig Sun Jun 26 05:48:23 1994
--- curses.c Sun Feb 11 16:50:41 1996
***************
*** 986,992 ****
{
if (has_IM)
do_IM();
! do_IC();
qaddch(ch);
if (has_EI)
do_EI();
--- 986,995 ----
{
if (has_IM)
do_IM();
!#ifdef NCURSES_VERSION
! else /* ncurses does insertion in a slightly nonstandard way */
!#endif
! do_IC();
qaddch(ch);
if (has_EI)
do_EI();
This patch is for elvis-1.8pl4 but it can even be used for elvis-1.8pl3 with
an offset of -11 lines.
BUGS:
Send any feedback to the ncurses mailing list at
bug-ncurses@gnu.org. To subscribe send mail to
bug-ncurses-request@gnu.org with body that reads:
subscribe ncurses <your-email-address-here>
The Hacker's Guide in the misc directory includes some guidelines
on how to report bugs in ways that will get them fixed most quickly.

798
contrib/ncurses/MANIFEST Normal file
View File

@ -0,0 +1,798 @@
./ANNOUNCE
./Ada95/Makefile.in
./Ada95/README
./Ada95/TODO
./Ada95/gen/Makefile.in
./Ada95/gen/gen.c
./Ada95/gen/normal.m4
./Ada95/gen/terminal_interface-curses-aux.ads.m4
./Ada95/gen/terminal_interface-curses-forms-field_types.ads.m4
./Ada95/gen/terminal_interface-curses-forms-field_user_data.ads.m4
./Ada95/gen/terminal_interface-curses-forms-form_user_data.ads.m4
./Ada95/gen/terminal_interface-curses-forms.ads.m4
./Ada95/gen/terminal_interface-curses-menus-item_user_data.ads.m4
./Ada95/gen/terminal_interface-curses-menus-menu_user_data.ads.m4
./Ada95/gen/terminal_interface-curses-menus.ads.m4
./Ada95/gen/terminal_interface-curses-mouse.ads.m4
./Ada95/gen/terminal_interface-curses-panels-user_data.ads.m4
./Ada95/gen/terminal_interface-curses-panels.ads.m4
./Ada95/gen/terminal_interface-curses.ads.m4
./Ada95/html/ada/files.htm
./Ada95/html/ada/files/T.htm
./Ada95/html/ada/funcs.htm
./Ada95/html/ada/funcs/A.htm
./Ada95/html/ada/funcs/C.htm
./Ada95/html/ada/funcs/E.htm
./Ada95/html/ada/funcs/F.htm
./Ada95/html/ada/funcs/G.htm
./Ada95/html/ada/funcs/I.htm
./Ada95/html/ada/funcs/L.htm
./Ada95/html/ada/funcs/M.htm
./Ada95/html/ada/funcs/N.htm
./Ada95/html/ada/funcs/P.htm
./Ada95/html/ada/funcs/R.htm
./Ada95/html/ada/funcs/S.htm
./Ada95/html/ada/funcs/T.htm
./Ada95/html/ada/funcs/U.htm
./Ada95/html/ada/funcs/V.htm
./Ada95/html/ada/index.htm
./Ada95/html/ada/main.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-alpha__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-alphanumeric__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-enumeration-ada__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-enumeration__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-intfield__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-ipv4_address__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-numeric__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-regexp__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-user-choice__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types-user__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_types__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-field_user_data__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms-form_user_data__ads.htm
./Ada95/html/ada/terminal_interface-curses-forms__ads.htm
./Ada95/html/ada/terminal_interface-curses-menus-item_user_data__ads.htm
./Ada95/html/ada/terminal_interface-curses-menus-menu_user_data__ads.htm
./Ada95/html/ada/terminal_interface-curses-menus__ads.htm
./Ada95/html/ada/terminal_interface-curses-mouse__ads.htm
./Ada95/html/ada/terminal_interface-curses-panels-user_data__ads.htm
./Ada95/html/ada/terminal_interface-curses-panels__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-complex_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-decimal_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-enumeration_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-fixed_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-float_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-integer_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io-modular_io__ads.htm
./Ada95/html/ada/terminal_interface-curses-text_io__ads.htm
./Ada95/html/ada/terminal_interface-curses__ads.htm
./Ada95/html/ada/terminal_interface__ads.htm
./Ada95/html/index.html
./Ada95/html/man/curs_addch.3x.html
./Ada95/html/man/curs_addchstr.3x.html
./Ada95/html/man/curs_addstr.3x.html
./Ada95/html/man/curs_attr.3x.html
./Ada95/html/man/curs_beep.3x.html
./Ada95/html/man/curs_bkgd.3x.html
./Ada95/html/man/curs_border.3x.html
./Ada95/html/man/curs_clear.3x.html
./Ada95/html/man/curs_color.3x.html
./Ada95/html/man/curs_delch.3x.html
./Ada95/html/man/curs_deleteln.3x.html
./Ada95/html/man/curs_getch.3x.html
./Ada95/html/man/curs_getstr.3x.html
./Ada95/html/man/curs_getyx.3x.html
./Ada95/html/man/curs_inch.3x.html
./Ada95/html/man/curs_inchstr.3x.html
./Ada95/html/man/curs_initscr.3x.html
./Ada95/html/man/curs_inopts.3x.html
./Ada95/html/man/curs_insch.3x.html
./Ada95/html/man/curs_insstr.3x.html
./Ada95/html/man/curs_instr.3x.html
./Ada95/html/man/curs_kernel.3x.html
./Ada95/html/man/curs_mouse.3x.html
./Ada95/html/man/curs_move.3x.html
./Ada95/html/man/curs_outopts.3x.html
./Ada95/html/man/curs_overlay.3x.html
./Ada95/html/man/curs_pad.3x.html
./Ada95/html/man/curs_print.3x.html
./Ada95/html/man/curs_printw.3x.html
./Ada95/html/man/curs_refresh.3x.html
./Ada95/html/man/curs_scanw.3x.html
./Ada95/html/man/curs_scr_dmp.3x.html
./Ada95/html/man/curs_scr_dump.3x.html
./Ada95/html/man/curs_scroll.3x.html
./Ada95/html/man/curs_slk.3x.html
./Ada95/html/man/curs_termattrs.3x.html
./Ada95/html/man/curs_termcap.3x.html
./Ada95/html/man/curs_terminfo.3x.html
./Ada95/html/man/curs_touch.3x.html
./Ada95/html/man/curs_util.3x.html
./Ada95/html/man/curs_window.3x.html
./Ada95/html/man/define_key.3x.html
./Ada95/html/man/dft_fgbg.3x.html
./Ada95/html/man/form.3x.html
./Ada95/html/man/form_cursor.3x.html
./Ada95/html/man/form_data.3x.html
./Ada95/html/man/form_driver.3x.html
./Ada95/html/man/form_field.3x.html
./Ada95/html/man/form_field_attributes.3x.html
./Ada95/html/man/form_field_buffer.3x.html
./Ada95/html/man/form_field_info.3x.html
./Ada95/html/man/form_field_just.3x.html
./Ada95/html/man/form_field_new.3x.html
./Ada95/html/man/form_field_opts.3x.html
./Ada95/html/man/form_field_userptr.3x.html
./Ada95/html/man/form_field_validation.3x.html
./Ada95/html/man/form_fieldtype.3x.html
./Ada95/html/man/form_hook.3x.html
./Ada95/html/man/form_new.3x.html
./Ada95/html/man/form_new_page.3x.html
./Ada95/html/man/form_opts.3x.html
./Ada95/html/man/form_page.3x.html
./Ada95/html/man/form_post.3x.html
./Ada95/html/man/form_requestname.3x.html
./Ada95/html/man/form_userptr.3x.html
./Ada95/html/man/form_win.3x.html
./Ada95/html/man/keyok.3x.html
./Ada95/html/man/menu.3x.html
./Ada95/html/man/menu_attribs.3x.html
./Ada95/html/man/menu_cursor.3x.html
./Ada95/html/man/menu_driver.3x.html
./Ada95/html/man/menu_format.3x.html
./Ada95/html/man/menu_hook.3x.html
./Ada95/html/man/menu_items.3x.html
./Ada95/html/man/menu_mark.3x.html
./Ada95/html/man/menu_new.3x.html
./Ada95/html/man/menu_opts.3x.html
./Ada95/html/man/menu_pattern.3x.html
./Ada95/html/man/menu_post.3x.html
./Ada95/html/man/menu_requestname.3x.html
./Ada95/html/man/menu_spacing.3x.html
./Ada95/html/man/menu_userptr.3x.html
./Ada95/html/man/menu_win.3x.html
./Ada95/html/man/mitem_current.3x.html
./Ada95/html/man/mitem_name.3x.html
./Ada95/html/man/mitem_new.3x.html
./Ada95/html/man/mitem_opts.3x.html
./Ada95/html/man/mitem_userptr.3x.html
./Ada95/html/man/mitem_value.3x.html
./Ada95/html/man/mitem_visible.3x.html
./Ada95/html/man/ncurses.3x.html
./Ada95/html/man/panel.3x.html
./Ada95/html/man/resizeterm.3x.html
./Ada95/html/man/wresize.3x.html
./Ada95/html/table.html
./Ada95/samples/Makefile.in
./Ada95/samples/README
./Ada95/samples/explain.txt
./Ada95/samples/rain.adb
./Ada95/samples/rain.ads
./Ada95/samples/sample-curses_demo-attributes.adb
./Ada95/samples/sample-curses_demo-attributes.ads
./Ada95/samples/sample-curses_demo-mouse.adb
./Ada95/samples/sample-curses_demo-mouse.ads
./Ada95/samples/sample-curses_demo.adb
./Ada95/samples/sample-curses_demo.ads
./Ada95/samples/sample-explanation.adb
./Ada95/samples/sample-explanation.ads
./Ada95/samples/sample-form_demo-aux.adb
./Ada95/samples/sample-form_demo-aux.ads
./Ada95/samples/sample-form_demo-handler.adb
./Ada95/samples/sample-form_demo-handler.ads
./Ada95/samples/sample-form_demo.adb
./Ada95/samples/sample-form_demo.ads
./Ada95/samples/sample-function_key_setting.adb
./Ada95/samples/sample-function_key_setting.ads
./Ada95/samples/sample-header_handler.adb
./Ada95/samples/sample-header_handler.ads
./Ada95/samples/sample-helpers.adb
./Ada95/samples/sample-helpers.ads
./Ada95/samples/sample-keyboard_handler.adb
./Ada95/samples/sample-keyboard_handler.ads
./Ada95/samples/sample-manifest.ads
./Ada95/samples/sample-menu_demo-aux.adb
./Ada95/samples/sample-menu_demo-aux.ads
./Ada95/samples/sample-menu_demo-handler.adb
./Ada95/samples/sample-menu_demo-handler.ads
./Ada95/samples/sample-menu_demo.adb
./Ada95/samples/sample-menu_demo.ads
./Ada95/samples/sample-my_field_type.adb
./Ada95/samples/sample-my_field_type.ads
./Ada95/samples/sample-text_io_demo.adb
./Ada95/samples/sample-text_io_demo.ads
./Ada95/samples/sample.adb
./Ada95/samples/sample.ads
./Ada95/samples/status.adb
./Ada95/samples/status.ads
./Ada95/samples/tour.adb
./Ada95/samples/tour.ads
./Ada95/src/Makefile.in
./Ada95/src/terminal_interface-curses-aux.adb
./Ada95/src/terminal_interface-curses-forms-field_types-alpha.adb
./Ada95/src/terminal_interface-curses-forms-field_types-alpha.ads
./Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.adb
./Ada95/src/terminal_interface-curses-forms-field_types-alphanumeric.ads
./Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.adb
./Ada95/src/terminal_interface-curses-forms-field_types-enumeration-ada.ads
./Ada95/src/terminal_interface-curses-forms-field_types-enumeration.adb
./Ada95/src/terminal_interface-curses-forms-field_types-enumeration.ads
./Ada95/src/terminal_interface-curses-forms-field_types-intfield.adb
./Ada95/src/terminal_interface-curses-forms-field_types-intfield.ads
./Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.adb
./Ada95/src/terminal_interface-curses-forms-field_types-ipv4_address.ads
./Ada95/src/terminal_interface-curses-forms-field_types-numeric.adb
./Ada95/src/terminal_interface-curses-forms-field_types-numeric.ads
./Ada95/src/terminal_interface-curses-forms-field_types-regexp.adb
./Ada95/src/terminal_interface-curses-forms-field_types-regexp.ads
./Ada95/src/terminal_interface-curses-forms-field_types-user-choice.adb
./Ada95/src/terminal_interface-curses-forms-field_types-user-choice.ads
./Ada95/src/terminal_interface-curses-forms-field_types-user.adb
./Ada95/src/terminal_interface-curses-forms-field_types-user.ads
./Ada95/src/terminal_interface-curses-forms-field_types.adb
./Ada95/src/terminal_interface-curses-forms-field_user_data.adb
./Ada95/src/terminal_interface-curses-forms-form_user_data.adb
./Ada95/src/terminal_interface-curses-forms.adb
./Ada95/src/terminal_interface-curses-menus-item_user_data.adb
./Ada95/src/terminal_interface-curses-menus-menu_user_data.adb
./Ada95/src/terminal_interface-curses-menus.adb
./Ada95/src/terminal_interface-curses-mouse.adb
./Ada95/src/terminal_interface-curses-panels-user_data.adb
./Ada95/src/terminal_interface-curses-panels.adb
./Ada95/src/terminal_interface-curses-text_io-aux.adb
./Ada95/src/terminal_interface-curses-text_io-aux.ads
./Ada95/src/terminal_interface-curses-text_io-complex_io.adb
./Ada95/src/terminal_interface-curses-text_io-complex_io.ads
./Ada95/src/terminal_interface-curses-text_io-decimal_io.adb
./Ada95/src/terminal_interface-curses-text_io-decimal_io.ads
./Ada95/src/terminal_interface-curses-text_io-enumeration_io.adb
./Ada95/src/terminal_interface-curses-text_io-enumeration_io.ads
./Ada95/src/terminal_interface-curses-text_io-fixed_io.adb
./Ada95/src/terminal_interface-curses-text_io-fixed_io.ads
./Ada95/src/terminal_interface-curses-text_io-float_io.adb
./Ada95/src/terminal_interface-curses-text_io-float_io.ads
./Ada95/src/terminal_interface-curses-text_io-integer_io.adb
./Ada95/src/terminal_interface-curses-text_io-integer_io.ads
./Ada95/src/terminal_interface-curses-text_io-modular_io.adb
./Ada95/src/terminal_interface-curses-text_io-modular_io.ads
./Ada95/src/terminal_interface-curses-text_io.adb
./Ada95/src/terminal_interface-curses-text_io.ads
./Ada95/src/terminal_interface-curses.adb
./Ada95/src/terminal_interface.ads
./INSTALL
./MANIFEST
./Makefile.glibc
./Makefile.in
./Makefile.os2
./NEWS
./README
./README.emx
./README.glibc
./TO-DO
./aclocal.m4
./announce.html
./announce.html.in
./c++/Makefile.in
./c++/NEWS
./c++/PROBLEMS
./c++/README-first
./c++/cursesapp.cc
./c++/cursesapp.h
./c++/cursesf.cc
./c++/cursesf.h
./c++/cursesm.cc
./c++/cursesm.h
./c++/cursesmain.cc
./c++/cursesp.cc
./c++/cursesp.h
./c++/cursespad.cc
./c++/cursesw.cc
./c++/cursesw.h
./c++/cursslk.cc
./c++/cursslk.h
./c++/demo.cc
./c++/edit_cfg.sh
./c++/etip.h.in
./c++/headers
./c++/internal.h
./c++/modules
./config.guess
./config.sub
./configure
./configure.in
./convert_configure.pl
./dist.mk
./form/Makefile.in
./form/READ.ME
./form/fld_arg.c
./form/fld_attr.c
./form/fld_current.c
./form/fld_def.c
./form/fld_dup.c
./form/fld_ftchoice.c
./form/fld_ftlink.c
./form/fld_info.c
./form/fld_just.c
./form/fld_link.c
./form/fld_max.c
./form/fld_move.c
./form/fld_newftyp.c
./form/fld_opts.c
./form/fld_pad.c
./form/fld_page.c
./form/fld_stat.c
./form/fld_type.c
./form/fld_user.c
./form/form.h
./form/form.priv.h
./form/frm_cursor.c
./form/frm_data.c
./form/frm_def.c
./form/frm_driver.c
./form/frm_hook.c
./form/frm_opts.c
./form/frm_page.c
./form/frm_post.c
./form/frm_req_name.c
./form/frm_scale.c
./form/frm_sub.c
./form/frm_user.c
./form/frm_win.c
./form/fty_alnum.c
./form/fty_alpha.c
./form/fty_enum.c
./form/fty_int.c
./form/fty_ipv4.c
./form/fty_num.c
./form/fty_regex.c
./form/headers
./form/llib-lform
./form/modules
./include/Caps
./include/MKhashsize.sh
./include/MKparametrized.sh
./include/MKterm.h.awk.in
./include/Makefile.in
./include/capdefaults.c
./include/curses.h.in
./include/edit_cfg.sh
./include/headers
./include/nc_alloc.h
./include/nc_panel.h
./include/ncurses_cfg.hin
./include/term_entry.h
./include/termcap.h.in
./include/tic.h
./include/unctrl.h.in
./install-sh
./man/MKterminfo.sh
./man/Makefile.in
./man/captoinfo.1m
./man/clear.1
./man/curs_addch.3x
./man/curs_addchstr.3x
./man/curs_addstr.3x
./man/curs_attr.3x
./man/curs_beep.3x
./man/curs_bkgd.3x
./man/curs_border.3x
./man/curs_clear.3x
./man/curs_color.3x
./man/curs_delch.3x
./man/curs_deleteln.3x
./man/curs_getch.3x
./man/curs_getstr.3x
./man/curs_getyx.3x
./man/curs_inch.3x
./man/curs_inchstr.3x
./man/curs_initscr.3x
./man/curs_inopts.3x
./man/curs_insch.3x
./man/curs_insstr.3x
./man/curs_instr.3x
./man/curs_kernel.3x
./man/curs_mouse.3x
./man/curs_move.3x
./man/curs_outopts.3x
./man/curs_overlay.3x
./man/curs_pad.3x
./man/curs_print.3x
./man/curs_printw.3x
./man/curs_refresh.3x
./man/curs_scanw.3x
./man/curs_scr_dump.3x
./man/curs_scroll.3x
./man/curs_slk.3x
./man/curs_termattrs.3x
./man/curs_termcap.3x
./man/curs_terminfo.3x
./man/curs_touch.3x
./man/curs_util.3x
./man/curs_window.3x
./man/define_key.3x
./man/dft_fgbg.3x
./man/form.3x
./man/form_cursor.3x
./man/form_data.3x
./man/form_driver.3x
./man/form_field.3x
./man/form_field_attributes.3x
./man/form_field_buffer.3x
./man/form_field_info.3x
./man/form_field_just.3x
./man/form_field_new.3x
./man/form_field_opts.3x
./man/form_field_userptr.3x
./man/form_field_validation.3x
./man/form_fieldtype.3x
./man/form_hook.3x
./man/form_new.3x
./man/form_new_page.3x
./man/form_opts.3x
./man/form_page.3x
./man/form_post.3x
./man/form_requestname.3x
./man/form_userptr.3x
./man/form_win.3x
./man/infocmp.1m
./man/keybound.3x
./man/keyok.3x
./man/make_sed.sh
./man/man_db.renames
./man/menu.3x
./man/menu_attribs.3x
./man/menu_cursor.3x
./man/menu_driver.3x
./man/menu_format.3x
./man/menu_hook.3x
./man/menu_items.3x
./man/menu_mark.3x
./man/menu_new.3x
./man/menu_opts.3x
./man/menu_pattern.3x
./man/menu_post.3x
./man/menu_requestname.3x
./man/menu_spacing.3x
./man/menu_userptr.3x
./man/menu_win.3x
./man/mitem_current.3x
./man/mitem_name.3x
./man/mitem_new.3x
./man/mitem_opts.3x
./man/mitem_userptr.3x
./man/mitem_value.3x
./man/mitem_visible.3x
./man/ncurses.3x
./man/panel.3x
./man/resizeterm.3x
./man/term.5
./man/term.7
./man/terminfo.head
./man/terminfo.tail
./man/tic.1m
./man/toe.1m
./man/tput.1
./man/tset.1
./man/wresize.3x
./menu/Makefile.in
./menu/READ.ME
./menu/eti.h
./menu/headers
./menu/llib-lmenu
./menu/m_attribs.c
./menu/m_cursor.c
./menu/m_driver.c
./menu/m_format.c
./menu/m_global.c
./menu/m_hook.c
./menu/m_item_cur.c
./menu/m_item_nam.c
./menu/m_item_new.c
./menu/m_item_opt.c
./menu/m_item_top.c
./menu/m_item_use.c
./menu/m_item_val.c
./menu/m_item_vis.c
./menu/m_items.c
./menu/m_new.c
./menu/m_opts.c
./menu/m_pad.c
./menu/m_pattern.c
./menu/m_post.c
./menu/m_req_name.c
./menu/m_scale.c
./menu/m_spacing.c
./menu/m_sub.c
./menu/m_userptr.c
./menu/m_win.c
./menu/menu.h
./menu/menu.priv.h
./menu/mf_common.h
./menu/modules
./misc/Makefile.in
./misc/chkdef.cmd
./misc/cleantic.cmd
./misc/cmpdef.cmd
./misc/emx.src
./misc/form.def
./misc/form.ref
./misc/hackguide.doc
./misc/hackguide.html
./misc/makedef.cmd
./misc/makellib
./misc/menu.def
./misc/menu.ref
./misc/ncurses-intro.doc
./misc/ncurses-intro.html
./misc/ncurses.def
./misc/ncurses.ref
./misc/panel.def
./misc/panel.ref
./misc/run_tic.sh
./misc/shlib
./misc/tabset/std
./misc/tabset/stdcrt
./misc/tabset/vt100
./misc/tabset/vt300
./misc/tdlint
./misc/terminfo.src
./mk-0th.awk
./mk-1st.awk
./mk-2nd.awk
./mkinstalldirs
./ncurses/Makefile.in
./ncurses/README
./ncurses/SigAction.h
./ncurses/base/MKkeyname.awk
./ncurses/base/MKlib_gen.sh
./ncurses/base/MKunctrl.awk
./ncurses/base/README
./ncurses/base/define_key.c
./ncurses/base/keybound.c
./ncurses/base/keyok.c
./ncurses/base/lib_addch.c
./ncurses/base/lib_addstr.c
./ncurses/base/lib_beep.c
./ncurses/base/lib_bkgd.c
./ncurses/base/lib_box.c
./ncurses/base/lib_chgat.c
./ncurses/base/lib_clear.c
./ncurses/base/lib_clearok.c
./ncurses/base/lib_clrbot.c
./ncurses/base/lib_clreol.c
./ncurses/base/lib_color.c
./ncurses/base/lib_colorset.c
./ncurses/base/lib_delch.c
./ncurses/base/lib_delwin.c
./ncurses/base/lib_dft_fgbg.c
./ncurses/base/lib_echo.c
./ncurses/base/lib_endwin.c
./ncurses/base/lib_erase.c
./ncurses/base/lib_flash.c
./ncurses/base/lib_freeall.c
./ncurses/base/lib_getch.c
./ncurses/base/lib_getstr.c
./ncurses/base/lib_hline.c
./ncurses/base/lib_immedok.c
./ncurses/base/lib_inchstr.c
./ncurses/base/lib_initscr.c
./ncurses/base/lib_insch.c
./ncurses/base/lib_insdel.c
./ncurses/base/lib_insstr.c
./ncurses/base/lib_instr.c
./ncurses/base/lib_isendwin.c
./ncurses/base/lib_leaveok.c
./ncurses/base/lib_mouse.c
./ncurses/base/lib_move.c
./ncurses/base/lib_mvwin.c
./ncurses/base/lib_newterm.c
./ncurses/base/lib_newwin.c
./ncurses/base/lib_nl.c
./ncurses/base/lib_overlay.c
./ncurses/base/lib_pad.c
./ncurses/base/lib_printw.c
./ncurses/base/lib_redrawln.c
./ncurses/base/lib_refresh.c
./ncurses/base/lib_restart.c
./ncurses/base/lib_scanw.c
./ncurses/base/lib_screen.c
./ncurses/base/lib_scroll.c
./ncurses/base/lib_scrollok.c
./ncurses/base/lib_scrreg.c
./ncurses/base/lib_set_term.c
./ncurses/base/lib_slk.c
./ncurses/base/lib_slkatr_set.c
./ncurses/base/lib_slkatrof.c
./ncurses/base/lib_slkatron.c
./ncurses/base/lib_slkatrset.c
./ncurses/base/lib_slkattr.c
./ncurses/base/lib_slkclear.c
./ncurses/base/lib_slkcolor.c
./ncurses/base/lib_slkinit.c
./ncurses/base/lib_slklab.c
./ncurses/base/lib_slkrefr.c
./ncurses/base/lib_slkset.c
./ncurses/base/lib_slktouch.c
./ncurses/base/lib_touch.c
./ncurses/base/lib_ungetch.c
./ncurses/base/lib_vline.c
./ncurses/base/lib_wattroff.c
./ncurses/base/lib_wattron.c
./ncurses/base/lib_winch.c
./ncurses/base/lib_window.c
./ncurses/base/memmove.c
./ncurses/base/nc_panel.c
./ncurses/base/resizeterm.c
./ncurses/base/safe_sprintf.c
./ncurses/base/sigaction.c
./ncurses/base/tries.c
./ncurses/base/vsscanf.c
./ncurses/base/wresize.c
./ncurses/curses.priv.h
./ncurses/fifo_defs.h
./ncurses/llib-lncurses
./ncurses/modules
./ncurses/tinfo/MKcaptab.awk
./ncurses/tinfo/MKfallback.sh
./ncurses/tinfo/MKnames.awk
./ncurses/tinfo/README
./ncurses/tinfo/access.c
./ncurses/tinfo/add_tries.c
./ncurses/tinfo/alloc_entry.c
./ncurses/tinfo/alloc_ttype.c
./ncurses/tinfo/captoinfo.c
./ncurses/tinfo/comp_error.c
./ncurses/tinfo/comp_expand.c
./ncurses/tinfo/comp_hash.c
./ncurses/tinfo/comp_parse.c
./ncurses/tinfo/comp_scan.c
./ncurses/tinfo/doalloc.c
./ncurses/tinfo/free_ttype.c
./ncurses/tinfo/getenv_num.c
./ncurses/tinfo/home_terminfo.c
./ncurses/tinfo/init_keytry.c
./ncurses/tinfo/keys.list
./ncurses/tinfo/lib_acs.c
./ncurses/tinfo/lib_baudrate.c
./ncurses/tinfo/lib_cur_term.c
./ncurses/tinfo/lib_data.c
./ncurses/tinfo/lib_has_cap.c
./ncurses/tinfo/lib_kernel.c
./ncurses/tinfo/lib_longname.c
./ncurses/tinfo/lib_napms.c
./ncurses/tinfo/lib_options.c
./ncurses/tinfo/lib_print.c
./ncurses/tinfo/lib_raw.c
./ncurses/tinfo/lib_setup.c
./ncurses/tinfo/lib_termcap.c
./ncurses/tinfo/lib_termname.c
./ncurses/tinfo/lib_ti.c
./ncurses/tinfo/lib_tparm.c
./ncurses/tinfo/lib_tputs.c
./ncurses/tinfo/lib_ttyflags.c
./ncurses/tinfo/make_keys.c
./ncurses/tinfo/name_match.c
./ncurses/tinfo/parse_entry.c
./ncurses/tinfo/read_entry.c
./ncurses/tinfo/read_termcap.c
./ncurses/tinfo/setbuf.c
./ncurses/tinfo/write_entry.c
./ncurses/trace/README
./ncurses/trace/lib_trace.c
./ncurses/trace/lib_traceatr.c
./ncurses/trace/lib_tracebits.c
./ncurses/trace/lib_tracechr.c
./ncurses/trace/lib_tracedmp.c
./ncurses/trace/lib_tracemse.c
./ncurses/trace/trace_buf.c
./ncurses/trace/trace_tries.c
./ncurses/trace/trace_xnames.c
./ncurses/tty/MKexpanded.sh
./ncurses/tty/hardscroll.c
./ncurses/tty/hashmap.c
./ncurses/tty/lib_mvcur.c
./ncurses/tty/lib_tstp.c
./ncurses/tty/lib_twait.c
./ncurses/tty/lib_vidattr.c
./ncurses/tty/tty_display.h
./ncurses/tty/tty_input.h
./ncurses/tty/tty_update.c
./panel/Makefile.in
./panel/headers
./panel/llib-lpanel
./panel/modules
./panel/p_above.c
./panel/p_below.c
./panel/p_bottom.c
./panel/p_delete.c
./panel/p_hidden.c
./panel/p_hide.c
./panel/p_move.c
./panel/p_new.c
./panel/p_replace.c
./panel/p_show.c
./panel/p_top.c
./panel/p_update.c
./panel/p_user.c
./panel/p_win.c
./panel/panel.c
./panel/panel.h
./panel/panel.priv.h
./progs/MKtermsort.sh
./progs/Makefile.in
./progs/capconvert
./progs/clear.c
./progs/clear.sh
./progs/dump_entry.c
./progs/dump_entry.h
./progs/infocmp.c
./progs/modules
./progs/progs.priv.h
./progs/tic.c
./progs/toe.c
./progs/tput.c
./progs/tset.c
./shlib-versions
./sysdeps/unix/sysv/linux/Makefile
./sysdeps/unix/sysv/linux/alpha/configure
./sysdeps/unix/sysv/linux/configure
./sysdeps/unix/sysv/linux/edit_man.sed
./sysdeps/unix/sysv/linux/edit_man.sh
./sysdeps/unix/sysv/linux/run_tic.sh
./tack/COPYING
./tack/HISTORY
./tack/Makefile.in
./tack/README
./tack/ansi.c
./tack/charset.c
./tack/color.c
./tack/control.c
./tack/crum.c
./tack/edit.c
./tack/fun.c
./tack/init.c
./tack/menu.c
./tack/modes.c
./tack/modules
./tack/output.c
./tack/pad.c
./tack/scan.c
./tack/sync.c
./tack/sysdep.c
./tack/tack.1
./tack/tack.c
./tack/tack.h
./tar-copy.sh
./test/Makefile.in
./test/README
./test/blue.c
./test/bs.6
./test/bs.c
./test/cardfile.c
./test/cardfile.dat
./test/configure.in
./test/ditto.c
./test/filter.c
./test/firework.c
./test/firstlast.c
./test/gdc.6
./test/gdc.c
./test/hanoi.c
./test/hashtest.c
./test/keynames.c
./test/knight.c
./test/lrtest.c
./test/modules
./test/ncurses.c
./test/ncurses_tst.hin
./test/newdemo.c
./test/rain.c
./test/tclock.c
./test/test.priv.h
./test/testaddch.c
./test/testcurs.c
./test/testscanw.c
./test/tracemunch
./test/view.c
./test/worm.c
./test/xmas.c

View File

@ -0,0 +1,400 @@
# Copyright (C) 1997,1998 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# You should have received a copy of the GNU Library General Public
# License along with the GNU C Library; see the file COPYING.LIB. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# Makefile for ncurses part.
#
subdir := ncurses
ncurses-version = 4.2
form-version = $(ncurses-version)
menu-version = $(ncurses-version)
panel-version = $(ncurses-version)
extras := form menu ncurses panel
extra-libs = $(extras:%=lib%)
# These libraries will be built in the `others' pass rather than
# the `lib' pass, because they depend on libc.so being built already.
extra-libs-others = $(extra-libs)
# The sources are found in the appropriate subdir.
subdir-dirs = $(extras) progs test
vpath %.c $(subdir-dirs)
vpath %.h $(subdir-dirs)
libform-routines = \
fld_arg \
fld_attr \
fld_current \
fld_def \
fld_dup \
fld_ftchoice \
fld_ftlink \
fld_info \
fld_just \
fld_link \
fld_max \
fld_move \
fld_newftyp \
fld_opts \
fld_pad \
fld_page \
fld_stat \
fld_type \
fld_user \
frm_cursor \
frm_data \
frm_def \
frm_driver \
frm_hook \
frm_opts \
frm_page \
frm_post \
frm_req_name \
frm_scale \
frm_sub \
frm_user \
frm_win \
fty_alnum \
fty_alpha \
fty_enum \
fty_int \
fty_ipv4 \
fty_num \
fty_regex
libncurses-routines = \
base/define_key \
base/keybound \
base/keyok \
base/lib_addch \
base/lib_addstr \
base/lib_beep \
base/lib_bkgd \
base/lib_box \
base/lib_chgat \
base/lib_clear \
base/lib_clearok \
base/lib_clrbot \
base/lib_clreol \
base/lib_color \
base/lib_colorset \
base/lib_delch \
base/lib_delwin \
base/lib_dft_fgbg \
base/lib_echo \
base/lib_endwin \
base/lib_erase \
base/lib_flash \
base/lib_freeall \
base/lib_getch \
base/lib_getstr \
base/lib_hline \
base/lib_immedok \
base/lib_inchstr \
base/lib_initscr \
base/lib_insch \
base/lib_insdel \
base/lib_insstr \
base/lib_instr \
base/lib_isendwin \
base/lib_leaveok \
base/lib_mouse \
base/lib_move \
base/lib_mvwin \
base/lib_newterm \
base/lib_newwin \
base/lib_nl \
base/lib_overlay \
base/lib_pad \
base/lib_printw \
base/lib_redrawln \
base/lib_refresh \
base/lib_restart \
base/lib_scanw \
base/lib_screen \
base/lib_scroll \
base/lib_scrollok \
base/lib_scrreg \
base/lib_set_term \
base/lib_slk \
base/lib_slkatr_set \
base/lib_slkatrof \
base/lib_slkatron \
base/lib_slkatrset \
base/lib_slkattr \
base/lib_slkclear \
base/lib_slkcolor \
base/lib_slkinit \
base/lib_slklab \
base/lib_slkrefr \
base/lib_slkset \
base/lib_slktouch \
base/lib_touch \
base/lib_ungetch \
base/lib_vline \
base/lib_wattroff \
base/lib_wattron \
base/lib_winch \
base/lib_window \
base/memmove \
base/nc_panel \
base/resizeterm \
base/safe_sprintf \
base/sigaction \
base/tries \
base/vsscanf \
base/wresize \
codes \
comp_captab \
expanded \
fallback \
lib_gen \
lib_keyname \
names \
tinfo/access \
tinfo/add_tries \
tinfo/alloc_entry \
tinfo/alloc_ttype \
tinfo/captoinfo \
tinfo/comp_error \
tinfo/comp_expand \
tinfo/comp_hash \
tinfo/comp_parse \
tinfo/comp_scan \
tinfo/doalloc \
tinfo/free_ttype \
tinfo/getenv_num \
tinfo/home_terminfo \
tinfo/init_keytry \
tinfo/lib_acs \
tinfo/lib_baudrate \
tinfo/lib_cur_term \
tinfo/lib_data \
tinfo/lib_has_cap \
tinfo/lib_kernel \
tinfo/lib_longname \
tinfo/lib_napms \
tinfo/lib_options \
tinfo/lib_print \
tinfo/lib_raw \
tinfo/lib_setup \
tinfo/lib_termcap \
tinfo/lib_termname \
tinfo/lib_ti \
tinfo/lib_tparm \
tinfo/lib_tputs \
tinfo/lib_ttyflags \
tinfo/name_match \
tinfo/parse_entry \
tinfo/read_entry \
tinfo/read_termcap \
tinfo/setbuf \
tinfo/write_entry \
trace/lib_trace \
trace/lib_traceatr \
trace/lib_tracebits \
trace/lib_tracechr \
trace/lib_tracedmp \
trace/lib_tracemse \
trace/trace_buf \
trace/trace_tries \
trace/trace_xnames \
tty/hardscroll \
tty/hashmap \
tty/lib_mvcur \
tty/lib_tstp \
tty/lib_vidattr \
tty/lib_twait \
tty/tty_update \
unctrl
libmenu-routines = \
m_attribs \
m_cursor \
m_driver \
m_format \
m_global \
m_hook \
m_item_cur \
m_item_nam \
m_item_new \
m_item_opt \
m_item_top \
m_item_use \
m_item_val \
m_item_vis \
m_items \
m_new \
m_opts \
m_pad \
m_pattern \
m_post \
m_req_name \
m_scale \
m_spacing \
m_sub \
m_userptr \
m_win
libpanel-routines = \
panel \
p_above \
p_below \
p_bottom \
p_delete \
p_hide \
p_hidden \
p_move \
p_new \
p_replace \
p_show \
p_top \
p_update \
p_user \
p_win
headers = curses.h eti.h form.h menu.h panel.h term.h termcap.h \
unctrl.h
others = clear infocmp tic toe tput tset
install-bin = $(others)
clear-objs = clear.o
infocmp-objs = infocmp.o dump_entry.o
tic-objs = tic.o dump_entry.o
toe-objs = toe.o dump_entry.o
tput-objs = tput.o
tset-objs = tset.o dump_entry.o
extra-objs = $(tic-objs) $(toe-objs) $(infocmp-objs) $(clear-objs) \
$(tput-objs) $(tset-objs)
test-srcs = blue bs cardfile ditto firework firstlast gdc hanoi hashtest knight \
lrtest ncurses newdemo rain tclock testaddch testcurs \
testscanw view worm xmas
include ../Rules
ifndef tabsetdir
tabsetdir = $(datadir)/tabset
endif
ifndef inst_tabsetdir
inst_tabsetdir = $(install_root)/$(tabsetdir)
endif
ifndef terminfodir
terminfodir = $(datadir)/terminfo
endif
ifndef inst_terminfodir
inst_terminfodir = $(install_root)/$(terminfodir)
endif
ifndef mandir
mandir = $(prefix)/man
endif
ifndef inst_mandir
inst_mandir = $(install_root)/$(mandir)
endif
CPPFLAGS += -DTERMINFO='"$(terminfodir)"' -Iinclude -Iform -Incurses \
-Imenu -Ipanel -Iprogs -Itest
ifneq ($(strip $(objpfx)),)
CPPFLAGS += -I$(objpfx)
endif
LDLIBS-tclock = math/libm
tests: $(test-srcs:%=$(objpfx)%)
$(objpfx)clear: $(addprefix $(objpfx),$(clear-objs))
$(objpfx)infocmp: $(addprefix $(objpfx),$(infocmp-objs))
$(objpfx)tic: $(addprefix $(objpfx),$(tic-objs))
$(objpfx)toe: $(addprefix $(objpfx),$(toe-objs))
$(objpfx)tput: $(addprefix $(objpfx),$(tput-objs))
$(objpfx)tset: $(addprefix $(objpfx),$(tset-objs))
ifeq ($(build-shared),yes)
$(others:%=$(objpfx)%): $(objpfx)libncurses.so
else
$(others:%=$(objpfx)%): $(objpfx)libncurses.a
endif
$(test-srcs:%=$(objpfx)%): $(objpfx)libform.a $(objpfx)libmenu.a \
$(objpfx)libpanel.a $(objpfx)libncurses.a
# Depend on libc.so so a DT_NEEDED is generated in the shared objects.
# This ensures they will load libc.so for needed symbols if loaded by
# a statically-linked program that hasn't already loaded it.
$(extras:%=$(objpfx)lib%.so): $(common-objpfx)libc.so
subdir_install: $(inst_libdir)/libtermcap.a $(inst_libdir)/libcurses.a \
$(inst_bindir)/reset $(inst_bindir)/captoinfo
$(inst_libdir)/libtermcap.a $(inst_libdir)/libcurses.a: \
$(inst_libdir)/libncurses.a
$(make-link)
$(inst_bindir)/reset: $(inst_bindir)/tset
$(make-link)
$(inst_bindir)/captoinfo: $(inst_bindir)/tic
$(make-link)
ifeq (yes,$(build-shared))
subdir_install: $(inst_libdir)/libtermcap.so $(inst_libdir)/libcurses.so
$(inst_libdir)/libtermcap.so $(inst_libdir)/libcurses.so: \
$(inst_libdir)/libncurses.so
$(make-link)
endif
subdir_install: $(inst_mandir)/man5/terminfo.5
$(inst_mandir)/man5/terminfo.5: $(objpfx)terminfo.5 $(wildcard man/*.[0-9]*)
$(make-target-directory)
sh $(edit_man-sh) $(prefix) $(inst_mandir) $(edit_man-sed) $^
subdir_install: $(inst_tabsetdir)/std
$(inst_tabsetdir)/std: \
$(filter-out misc/tabset/CVS, $(wildcard misc/tabset/*))
$(make-target-directory)
for f in $^; do \
echo installing $$f; \
$(INSTALL_DATA) $$f $(inst_tabsetdir); \
done
ifeq (no,$(cross-compiling))
subdir_install: $(inst_terminfodir)/v/vt100
$(inst_terminfodir)/v/vt100: misc/terminfo.src $(objpfx)tic
$(make-target-directory)
sh $(run_tic-sh) $(common-objpfx) misc $(terminfodir) \
$(install_root)
endif
subdir_distclean subdir_realclean:
-rm -f $(addprefix $(objpfx), MKterm.h.awk codes.c \
comp_captab.c confdefs.h config.log curses.h \
expanded.c fallback.c hashsize.h keys.tries \
lib_gen.c lib_keyname.c names.c ncurses_cfg.h \
nomacros.h parametrized.h term.h termcap.h \
terminfo.5 termsort.c unctrl.c unctrl.h)

View File

@ -0,0 +1,92 @@
# $Id: Makefile.in,v 1.18 1998/08/22 23:45:00 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
#
# Master Makefile for ncurses library.
SHELL = /bin/sh
INSTALL_PREFIX=@INSTALL_PREFIX@
CF_MFLAGS = @cf_cv_makeflags@ INSTALL_PREFIX="$(INSTALL_PREFIX)"
@SET_MAKE@
NCURSES_MAJOR = @NCURSES_MAJOR@
NCURSES_MINOR = @NCURSES_MINOR@
NCURSES_PATCH = @NCURSES_PATCH@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
datadir = @datadir@
includedir = @includedir@
libdir = @libdir@
mandir = @mandir@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
DIRS_TO_MAKE = @DIRS_TO_MAKE@
all :: $(DIRS_TO_MAKE)
$(DIRS_TO_MAKE) :
mkdir $@
preinstall :
@ echo ''
@ echo '** Configuration summary for NCURSES $(NCURSES_MAJOR).$(NCURSES_MINOR) $(NCURSES_PATCH):'
@ echo ''
@ echo ' bin directory: '$(bindir)
@ echo ' lib directory: '$(libdir)
@ echo ' include directory: '$(includedir)
@ echo ' man directory: '$(mandir)
@ echo ' terminfo directory: '$(datadir)/terminfo
@ echo ''
@ test "$(includedir)" = "$(prefix)/include" || \
echo '** Include-directory is not in a standard location'
@ test ! -f $(includedir)/termcap.h || \
fgrep NCURSES_VERSION $(includedir)/termcap.h >/dev/null || \
echo '** Will overwrite non-ncurses termcap.h'
@ test ! -f $(includedir)/curses.h || \
fgrep NCURSES_VERSION $(includedir)/curses.h >/dev/null || \
echo '** Will overwrite non-ncurses curses.h'
# Put the common rules here so that we can easily construct the list of
# directories to visit.
all \
clean \
distclean \
mostlyclean \
realclean \
sources \
uninstall \
install ::

View File

@ -0,0 +1,235 @@
################################################################################
# Wrapper Makefile for ncurses library under OS/2.
################################################################################
# $Id: Makefile.os2,v 1.8 1998/12/13 02:23:13 tom Exp $
#
# Author: Juan Jose Garcia Ripoll <worm@arrakis.es>.
# Webpage: http://www.arrakis.es/~worm/
################################################################################
#
# Notes (from I Zakharevich)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~
# I could build the library with the following sequence of commands:
#
# touch Makefile
# make -f Makefile.os2 config
# make -f Makefile.os2 CC=gcc HOSTCC=gcc
# make -f Makefile.os2 CC=gcc HOSTCC=gcc
#
# Ignoring the following errors:
# Invalid configuration `os2'...
# ... ac_maketemp="make": not found
# ... syntax error: `done' unexpected
# No rule to make target `lib/ncurses4.dll'
#
# You may need to run
#
# rm make.defs
# make -f Makefile.os2 make.defs
#
# if the build of misc/panel.def fails.
#
# If you do not have perl, the configuration will fail. Use autoconf to
# generate the EMX-specific configure script (see README.emx), and run the
# configure script to generate the makefiles. Then, run
#
# make -f Makefile.os2 make.dlls
#
# Notes (from J J G Ripoll)
# ~~~~~~~~~~~~~~~~~~~~~~~~~
# The `make.defs' rule creates the new '.def' files and outputs a diagnostic
# about symbols that disappear from one release to the other, as well as
# checks about the new '.def' consistency. If there were no problems, the
# maintainer is free to replace the `.ref' files with the newer ones using the
# `save.defs' rule. So, the only tough work is ensuring that the symbols that
# disappear are not essential.
#
# I first thought about killing '_nc_*' symbols, but it seems that some of
# them --_nc_panel_hook, _nc_ada*, etc-- are needed outside ncurses.dll.
# However, the whole size of the export table will not be larger than 1k or
# so.
#
# [installation]
#
# The way things are handled in misc/Makefile is not well suited for OS/2,
# where only emx.src is needed. Thus, I've written a few wrapper rules in
# Makefile.os2 that handle installation/deinstallation.
#
# [distribution]
#
# There's also a new rule that configures and builds a sort of binary
# distribution, much like the one I prepared for 1.9.9e. It's `os2dist'.
#
################################################################################
all :: config
# This is for configuring
# What is a useful value for this?
CONFIG_OPTS = --enable-termcap
WWWGET = lynx -source
MV_F = mv -f
DLL_LN_OPTS = -Zcrtdll -Zdll -Zomf -Zmt
config: config.cache
config.cache: configure.cmd configure
-$(MV_F) $@ $@.ref
configure.cmd $(CONFIG_OPTS)
configure.cmd: configure convert_configure.pl
perl convert_configure.pl configure > $@
convert_configure.pl:
$(WWWGET) ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/$@ > $@
install ::
echo ***
echo *** Do not use this command. Use install.os2 instead.
echo ***
exit 2
install.os2 : install.emxdata install.libs install.progs
include ./Makefile
all :: make.dlls
#
# DLLs and that stuff
#
LIBRARIES = ncurses form menu panel
DLL_TAG = $(NCURSES_MAJOR)
LIB_TAG = _s
DLL_ROOTS = $(addsuffix $(DLL_TAG), $(LIBRARIES))
DLLS = $(addsuffix .dll, $(addprefix ./lib/, $(DLL_ROOTS)))
LIB_ROOTS = $(addsuffix $(LIB_TAG), $(LIBRARIES))
LIBS = $(addsuffix .lib, $(addprefix ./lib/, $(LIB_ROOTS)))
LIBS_AOUT = $(addsuffix .a, $(addprefix ./lib/, $(LIB_ROOTS)))
DEFS = $(addsuffix .def, $(addprefix ./misc/, $(LIBRARIES)))
DLL_SIGNATURE = NCurses-$(NCURSES_MAJOR)-$(NCURSES_MINOR)-$(NCURSES_PATCH)
./lib/%$(LIB_TAG).lib : ./misc/%.def
emximp -o $@ $<
./lib/%$(LIB_TAG).a : ./misc/%.def
emximp -o $@ $<
./lib/%$(DLL_TAG).dll : ./lib/%.a
emxomf -o ./lib/$*$(DLL_TAG).lib $<
if [ "$*" = "ncurses" ]; then \
gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
./misc/$*.def -o $@; \
else \
gcc $(LDFLAGS) $(DLL_LN_OPTS) ./lib/$*$(DLL_TAG).lib \
./lib/ncurses$(LIB_TAG).lib ./misc/$*.def -o $@; \
fi
-rm -f ./lib/$*$(DLL_TAG).lib
make.dlls : $(DEFS) $(LIBS) $(DLLS) $(LIBS_AOUT)
$(DEFS) : make.defs
LIBDIR = $(INSTALL_PREFIX)$(libdir)
$(LIBDIR) :
mkdir -p $@
install.libs :: $(LIBS) $(DLLS) $(LIBDIR)
@for i in $(DLL_ROOTS); do \
echo installing ./lib/$$i.dll as $(LIBDIR)/$$i.dll; \
$(INSTALL_DATA) ./lib/$$i.dll $(LIBDIR)/$$i.dll; done
@for i in $(LIB_ROOTS); do \
echo installing ./lib/$$i.lib as $(LIBDIR)/$$i.lib; \
$(INSTALL_DATA) ./lib/$$i.lib $(LIBDIR)/$$i.lib; done
uninstall.libs ::
-@for i in $(DLL_ROOTS); do \
echo uninstalling $(LIBDIR)/$$i.dll; \
rm -f $(LIBDIR)/$$i.dll; done
-@for i in $(LIB_ROOTS); do \
echo uninstalling $(LIBDIR)/$$i.lib; \
rm -f $(LIBDIR)/$$i.lib; done
make.defs :
for i in $(LIBRARIES); do \
echo LIBRARY $${i}$(DLL_TAG) INITINSTANCE TERMINSTANCE > ./misc/$$i.def; \
echo DESCRIPTION \"$(DLL_SIGNATURE), module $$i\" >> ./misc/$$i.def; \
echo CODE LOADONCALL >> ./misc/$$i.def; \
echo DATA LOADONCALL NONSHARED MULTIPLE >> ./misc/$$i.def; \
echo EXPORTS >> ./misc/$$i.def; \
echo Creating $$i.def; \
(cmd /C ".\\misc\\makedef.cmd ./lib/$$i.a ./misc/$$i.ref >> ./misc/$$i.def" \
&& cmd /C ".\\misc\\chkdef.cmd ./misc/$$i.def") \
|| exit 1; \
done
touch make.defs
save.defs :
for i in $(LIBRARIES); do \
test -f ./misc/$$i.def && cp ./misc/$$i.def ./misc/$$i.ref; \
done
clean \
os2clean ::
-rm -f $(DLLS) $(LIBS)
realclean ::
-rm -f $(addprefix ./misc/, $(addsuffix .def, $(LIBRARIES)))
#
# This is a simplified version of misc/Makefile
#
TICDIR = $(INSTALL_PREFIX)$(datadir)/terminfo
TABSETDIR = $(INSTALL_PREFIX)$(datadir)/tabset
$(TICDIR) :
mkdir -p $@
install \
install.emxdata :: $(TICDIR)
-@rm -fr $(TICDIR)/*
echo Building terminfo database, please wait...
set TERMINFO=$(TICDIR); ./progs/tic ./misc/emx.src
echo Installing the terminfo cleaner and the sources...
cp ./misc/emx.src ./misc/cleantic.cmd $(TICDIR)
./misc/cleantic.cmd $(TICDIR)
uninstall \
uninstall.emxdata ::
-cd $(TICDIR) && rm -rf *
-cd $(TABSETDIR) && rm -rf *
#
# This is for preparing binary distributions
#
OS2NAME=ncurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-emx
#
# FIXME: this assumes that we can rerun the configure script, changing only
# the install-prefix. That means we cannot provide "interesting" options
# when building.
#
os2dist :
$(MAKE) -f Makefile.os2 os2clean
./configure --without-debug --with-install-prefix=`pwd|sed -e 's@^.:@@'`/$(OS2NAME)
$(MAKE) -f Makefile.os2 $(CF_MFLAGS) install.os2
-rm -f $(OS2NAME).zip
echo NCurses-$(NCURSES_MAJOR).$(NCURSES_MINOR)-$(NCURSES_PATCH) for emx > $(OS2NAME)/FILE_ID.DIZ
echo Binary release. >> $(OS2NAME)/FILE_ID.DIZ
zip -r $(OS2NAME).zip ./$(OS2NAME)
clean \
os2clean ::
-rm -rf $(OS2NAME)
-rm -f $(OS2NAME).zip

3572
contrib/ncurses/NEWS Normal file

File diff suppressed because it is too large Load Diff

175
contrib/ncurses/README Normal file
View File

@ -0,0 +1,175 @@
-- $Id: README,v 1.17 1998/02/15 01:26:47 tom Exp $
-------------------------------------------------------------------------------
README file for the ncurses package
See the file ANNOUNCE for a summary of ncurses features and ports.
See the file INSTALL for instructions on how to build and install ncurses.
See the file NEWS for a release history and bug-fix notes.
See the file TO-DO for things that still need doing, including known bugs.
Browse the file misc/ncurses-intro.html for narrative descriptions of how
to use ncurses and the panel, menu, and form libraries.
Browse the file misc/hackguide.html for a tour of the package internals.
ROADMAP AND PACKAGE OVERVIEW:
You should be reading this file in a directory called: ncurses-d.d, where d.d
is the current version number (see the dist.mk file in this directory for
that). There should be a number of subdirectories, including `c++', `form',
`man', `menu', `misc', `ncurses', `panel', `progs', `test', 'tack' and `Ada95'.
(The 'tack' program is distributed separately).
A full build/install of this package typically installs several libraries, a
handful of utilities, and a database hierarchy. Here is an inventory of the
pieces:
The libraries are:
libncurses.a (normal)
libncurses.so (shared)
libncurses_g.a (debug and trace code enabled)
libncurses_p.a (profiling enabled)
libpanel.a (normal)
libpanel.so (shared)
libpanel_g.a (debug and trace code enabled)
libmenu.a (normal)
libmenu.so (shared)
libmenu_g.a (debug enabled)
libform.a (normal)
libform.so (shared)
libform_g.a (debug enabled)
The ncurses libraries implement the curses API. The panel, menu and forms
libraries implement clones of the SVr4 panel, menu and forms APIs. The source
code for these lives in the `ncurses', `panel', `menu', and `form' directories
respectively.
In the `c++' directory, you'll find code that defines an interface to the
curses, forms, menus and panels library packaged as C++ classes, and a demo program in C++
to test it. These class definition modules are not installed by the 'make
install.libs' rule as libncurses++.
In the `Ada95' directory, you'll find code and documentation for an
Ada95 binding of the curses API, to be used with the GNAT compiler.
This binding is built by a normal top-level `make' if configure detects
an usable version of GNAT (3.10 or above). It is not installed automatically.
See the Ada95 directory for more build and installation instructions and
for documentation of the binding.
To do its job, the ncurses code needs your terminal type to be set in the
environment variable TERM (normally set by your OS; under UNIX, getty(1)
typically does this, but you can override it in your .profile); and, it needs a
database of terminal descriptions in which to look up your terminal type's
capabilities.
In older (V7/BSD) versions of curses, the database was a flat text file,
/etc/termcap; in newer (USG/USL) versions, the database is a hierarchy of
fast-loading binary description blocks under /usr/lib/terminfo. These binary
blocks are compiled from an improved editable text representation called
`terminfo' format (documented in man/terminfo.5). The ncurses library can use
either /etc/termcap or the compiled binary terminfo blocks, but prefers the
second form.
In the `misc' directory, there is a text file terminfo.src, in editable
terminfo format, which can be used to generate the terminfo binaries (that's
what make install.data does). If the package was built with the
--enable-termcap option enabled, and the ncurses library cannot find a terminfo
description for your terminal, it will fall back to the termcap file supplied
with your system (which the ncurses package installation leaves strictly
alone).
The utilities are as follows:
tic -- terminfo source to binary compiler
infocmp -- terminfo binary to source decompiler/comparator
clear -- emits clear-screen for current terminal
tput -- shell-script access to terminal capabilities.
toe -- table of entries utility
tset -- terminal-initialization utility
The first two (tic and infocmp) are used for manipulating terminfo
descriptions; the next two (clear and tput) are for use in shell scripts. The
last (tset) is provided for 4.4BSD compatibility. The source code for all of
these lives in the `progs' directory.
Detailed documentation for all libraries and utilities can be found in
the `man' directory. An HTML introduction to ncurses, panels, and
menus programming lives in the `misc' directory. Manpages in HTML format
are under `Ada95/html'.
The `test' directory contains programs that can be used to verify or
demonstrate the functions of the ncurses libraries. See test/README for
descriptions of these programs. Notably, the `ncurses' utility is designed to
help you systematically exercise the library functions.
AUTHORS:
Pavel Curtis:
wrote the original ncurses
Zeyd M. Ben-Halim:
port of original to Linux and many enhancements.
Thomas Dickey (maintainer since 1.9.9e):
configuration scripts, porting, mods to adhere to XSI Curses in the
areas of background color, terminal modes. Also memory leak testing,
the wresize, default colors and key definition extensions and numerous
bug fixes (more than half of those enumerated in NEWS beginning with
the internal release 1.8.9).
Florian La Roche (official maintainer for FSF's ncurses 4.2)
Beginning with release 4.2, ncurses is distributed under an MIT-style
license.
Eric S. Raymond:
the man pages, infocmp(1), tput(1), clear(1), captoinfo(1), tset(1),
toe(1), most of tic(1), trace levels, the HTML intro, wgetnstr() and
many other entry points, the cursor-movement optimization, the
scroll-pack optimizer for vertical motions, the mouse interface and
xterm mouse support, and the ncurses test program.
Juergen Pfeifer
The menu and form libraries, C++ bindings for ncurses, menus, forms and
panels, as well as the Ada95 binding. Ongoing support for panel.
CONTRIBUTORS:
Alexander V. Lukyanov
for numerous fixes and improvements to the optimization logic.
David MacKenzie
for first-class bug-chasing and methodical testing.
Ross Ridge
for the code that hacks termcap parameterized strings into terminfo.
Warren Tucker and Gerhard Fuernkranz,
for writing and sending the panel library.
Hellmuth Michaelis,
for many patches and testing the optimization code.
Eric Newton, Ulrich Drepper, and Anatoly Ivasyuk:
the C++ code.
Jonathan Ross,
for lessons in using sed.
Keith Bostic (maintainer of 4.4BSD curses)
for help, criticism, comments, bug-finding, and being willing to
deep-six BSD curses for this one when it grew up.
Richard Stallman,
for his commitment to making ncurses free software.
Countless other people have contributed by reporting bugs, sending fixes,
suggesting improvements, and generally whining about ncurses :-)
BUGS:
See the INSTALL file for bug and developer-list addresses.
The Hacker's Guide in the misc directory includes some guidelines
on how to report bugs in ways that will get them fixed most quickly.

View File

@ -0,0 +1,48 @@
-- $Id: README.emx,v 1.1 1998/11/21 20:13:05 tom Exp $
-- Author: Thomas Dickey <dickey@clark.net>
-------------------------------------------------------------------------------
You can build ncurses on OS/2 in the EMX environment. But you must build and
acquire tools. Not all of the tools distributed with EMX work properly, and
some additional ones are required.
First, the configure script distributed with ncurses will not run as-is in EMX.
You can generate a new one if you have autoconf built for EMX. You will need
the EMX development tools, of course. Get these programs to start:
GNU m4 program (version 1.4)
GNU autoconf (version 2.12).
GNU patch (version 2.5)
Apply the autoconf patches from
http://www.clark.net/pub/dickey/autoconf
ftp://ftp.clark.net/pub/dickey/autoconf
These are ordered by date:
autoconf-2.12-970309.patch
autoconf-2.12-970429.patch
autoconf-2.12-971222-emx.patch
autoconf-2.12-971222.patch
autoconf-2.12-971230.patch
I built my development environment for ncurses using EMX 0.9c at the end of
1997. Much of the EMX patch for autoconf was done originally by J.J.G.Ripoll,
using a similar environment (he prefers using the 'ash' shell). Newer versions
may fix these problems:
+ The pdksh program distributed at Hobbes and Leo (with a 1996 date) is
defective. It does not process "here documents" correctly (which
renders it useless for running the autoconf script). I built my own
copy of pdksh 5.2.13, which does have the bug corrected (documented
in the change log for pdksh).
+ I also built from sources (because the distributed binaries did not
work) the cmp, diff programs.
Other required utilities such as ar, cat, chmod, cp, gawk, grep, mv,
ls, rm, mkdir, sed, sort and tr worked.
Once you have autoconf patched and installed, run 'autoconf' from the top-level
directory of ncurses to generate the EMX-specific configure script.

View File

@ -0,0 +1,5 @@
To compile this as an add-on for glibc, unpack it in the glibc source
tree and put ncurses on the add-on list when you do configure.
hjl@gnu.ai.mit.edu
03/21/1997

251
contrib/ncurses/TO-DO Normal file
View File

@ -0,0 +1,251 @@
-- $Id: TO-DO,v 1.39 1998/07/12 00:25:39 tom Exp $
SHORT-TERM TO-DO ITEMS:
Known Problems:
* GNAT does not put libraries in the correct order, so a build only links
properly if you use shared libraries since -lncurses is first.
* XPG4 specifies that the enhanced features are not available unless the
_XOPEN_SOURCE_EXTENDED test macro is defined by the application. Ncurses uses
this macro (incorrectly) to address a dependency upon wchar_t. The functions
which use wchar_t are not implemented, so the effect of the test macro is
pointless.
* The screen optimization has been tested only in an ad hoc manner. We should
develop a good set of regression tests to cover lib_doupdate.c and
lib_mvcur.c.
* Magic cookie support does not work, since the logic does not take into account
refresh. Also, the initial optimize does not adjust the current location
when a cookie is emitted.
* Scrolling optimization has holes: for example, it forces repaints of the
screen between calls to refresh().
* SVr4 uses slightly different rules for determining when softkeys are shown.
For example, they are initially displayed (before the ncurses 'e' test
activates them), and a touchwin can apparently also force them to be
displayed.
+ The code departs from perfect 8-bit cleanness in one respect; you cannot
specify a character \200 as part of a capability string, because the terminfo
library interprets \200 as a request to embed NUL (\000) at that point. This
is a legacy terminfo property we can't mess with.
* The window classes defined in the c++ subdirectory need documentation.
Some C++ programmer could earn a lot of good karma by doing this...
Portability (or lack thereof):
* Users of older System V UNIXes (but not Solaris, and probably not SVr4)
may trip over a known problem with the signal-handling code which causes
abrupt termination of ncurses applications following resume from a ^Z
suspend (this problem was first seen running lynx). You will not see
this problem if you are running Linux or one of the 4.4BSD derivatives
like FreeBSD, NetBSD, or BSDI. For details, see the analysis in the
header comment of ncurses/lib_tstp.c.
* In theory, vwprintw and vwscanf are supposed to use the older varargs.h
interface for handling variadic argument lists. Linux doesn't have
varargs.h, it has the newer X/Open-standard stdargs.h equivalent. So
these functions use stdargs instead. This is unlikely to be a problem
unless you're building ncurses on a System V old enough to only have
varargs.h. (Solaris 2.5.1 uses the stdarg.h binding as well).
* If you're using a BSD earlier than 4.4BSD, or a Linux old enough not to
have a native vsscanf(3) in its library, vwscanw() will not work. You lose.
(It should work on any System V, however). If you want to fix this, add
an implementation to ncurses/vsscanf.c.
* The demo build for the c++ library craps out with many link errors under gcc
2.6.3. We're told the C++ support in 2.6.3 is broken and that the right
fix is to upgrade to 2.7.0. This demo is also known to not build with
the Sun SPARCworks 4.1 C++ compiler, due to a problem resolving templates.
* Under Ultrix, configure craps out (Ultrix sh is lame). Run it under ksh.
* We've not tested the configure script with cross-compilers. The autoconf
tests are supposed to be able to support this (please report bugs). You will
have to configure and build in two steps. The first step must create the
automatically-generated sources (e.g., comp_captab.c) on your host machine.
Then, run "make mostlyclean", remove config.* from the top-level directory
and configure for the cross-compiler.
+ terminfo.5 does not format with the SunOS (and most other platform's) tbl
utility because it relies on a diversion for each table entry. Get the groff
package.
Untested features:
* The code for the HP color model using set_color_pair is untested.
* The code for handling soft labels on a terminal type with built-in support
for them (num_labels > 0, label_height, label_width, label_format, label_off,
label_on, plab_norm, lab_f*) has not been tested. The label_format and
lab_f* capabilities aren't presently used.
LONGER-TERM TO-DO ITEMS:
1. Extended COSE conformance
There is an XPG4 standard recently released which describes a superset
of the SVr4 API. The library is BASE conformant with this standard.
We would like to make ncurses fully conformant at the EXTENDED level
supporting internationalization.
Here are page references to all material involving wide or multi-byte
characters in Issue 4 of the XSI Curses standard, with notes on their
status in this implementation:
Page 1 (1.1.2) New Features discussion of internationalization.
Page 12 (2.4): Definition of cchar_t, wchar_t.
Page 16 (3.3.2): Introduction of multi-column characters.
Page 17-18 (3.3.5): Description of non-spacing characters.
Page 19-21 (3.4.2): Basic character operations.
Page 34 (addnstr): These should now call underlying wide-
character functions, and do (through waddnstr) if _XOPEN_SOURCE_EXTENDED is on).
Page 35 (addnwstr): wide-character add-string functions. All macros
except waddnwstr() which is not yet defined.
Page 36 (add_wch): wide-character add-char functions. All macros
except wadd_wch() which is not yet defined.
Page 39 (attr_get): implemented -- we've just made the current-
attributes field of the window an attr_t.
Page 43 (bkgrnd): None of these are implemented.
Page 45 (border_set): Neither of these is implemented.
Page 47 (box_set): box_set implemented as macro, but the underlying
wborder_set() is not yet defined.
Page 78 (echo_wchar): echo_wchar() implemented as macro, underlying
wecho_wchar() not yet implemented.
Page 81 (erasechar): Neither entry point is implemented.
Page 87 (getbkgrnd): Not implemented.
Page 88 (getcchar): Not implemented.
Page 93 (getn_wstr): All implemented (as macros) except the
underlying wgetn_wstr().
Page 97 (get_wch): All implemented (as macros) except the
underlying wget_wch().
Page 99 (get_wstr): Xref to page 93.
Page 105 (hline_set): All implemented (as macros) except the
underlying whline_set(), wvline_set().
Page 114 (innstr): Multi-byte character-completeness check is
not implemented.
Page 115 (innwstr): All implemented (as macros) except the
underlying winnw_str().
Page 119 (insnstr): Implementation may not be correct for multi-byte
characters.
Page 120 (ins_nwstr): Not implemented.
Page 121 (insstr): Xref to page 119.
Page 122 (instr): Xref to page 119.
Page 123 (ins_wch): Not implemented.
Page 124 (ins_wstr): Xref to page 120.
Page 126 (in_wch): Not implemented.
Page 127 (in_wchnstr): Not implemented.
Page 128 (inwstr): Xref to page 115.
Page 133 (killwchar): killwchar not implemented.
Page 158 (pechochar): pecho_wchar() not implemented.
Page 176 (setcchar): Not implemented.
Page 181 (slk_attroff): slk_wset not implemented.
Page 200 (ungetch): unget_wch() not implemented.
Page 203 (vidattr): vid_attr() and vid_puts() not implemented.
Page 206 (vline_set): Xref to page 105.
Page 214 (wunctrl): Not implemented.
Page 216 (curses.h): cchar_t, wint_t, wchar_t references.
Page 220 (curses.h): KEY_CODE_YES
Basically, the macro superstructure is there but the core is absent. We
need better multi-locale support guarantees from the OS to finish this.
If you are working on internationalization support, please contact us so
we can cooperate.
2. DOS port
Only 16 of the 55 files in the library depend on the terminfo format.
It should be possible to further kernelize the package, then rewrite
a small number of core files to produce a functionally-compatible
port that would do updates to a memory-mapped screen area. The first
result of this would be a DOS port.
3. X port
It would be nice if ncurses could recognize when it was running under X and
maintain its own window. With this feature, all ncurses programs would
automatically become X programs. The challenge is to handle resize events
properly.
4. Unused capabilities
The currently unused capabilities fall naturally into several groups:
A. Status-line capabilities:
Booleans: has_status_line, status_line_esc_ok.
Numerics: width_status_line.
Strings: dis_status_line, from_status_line, to_status_line.
System V Release 1 curses made no use of these at all. SVr4's use, if
any, is unknown. From the AT&T termcap file it looks like curses, in general,
shouldn't use them; terminal variants with status lines have their line count
decremented by 1, suggesting that curses is supposed to leave the status line
alone.
B. Printer capabilities:
Boolean: col_addr_glitch, cr_cancels_micro_mode, has_print_wheel,
row_addr_glitch, semi_auto_right_margin, cpi_changes_res,
lpi_changes_res.
Numeric: buffer_capacity, dot_horz_spacing, dot_vert_spacing,
max_micro_address, max_micro_jump, micro_col_size,
micro_line_size, number_of_pins, output_res_char,
output_res_line, output_res_horz_inch, print_rate,
wide_char_size, bit_image_entwining, bit_image_type.
String: down_half_line, form_feed, up_half_line, set_left_margin,
set_right_margin, clear_margins, change_char_pitch
... set_page_length (all the SVr4 printer caps),
Curses doesn't use these.
C. Printer-control capabilities:
Boolean: prtr_silent.
Strings: print_screen, prtr_on, prtr_off, prtr_non.
Curses doesn't use these.
D. Dialer strings:
Strings: hangup, dial_phone, quick_dial, tone, pulse, flash_hook,
fixed_pause, wait_tone.
Curses doesn't use these.
E. Window and virtual-terminal capabilities:
Numerics: maximum_windows, virtual_terminal.
Strings: req_for_input, create_window, goto_window, set_window.
These seem to be fossils from some AT&T experiments on character-based
window systems that never escaped the lab. The virtual_terminal cap had
something to do with building terminal emulations into tty line disciplines.
F. Unused VDT capabilities:
Booleans: erase_overstrike, has_meta_key, insert_null_glitch,
move_insert, dest_tabs_magic_smso, transparent_underline,
needs_xon_xoff, hard_cursor.
Numerics: lines_of_memory, buttons.
Strings: pkey_key, pkey_local, pkey_xmit, underline_char,
enter_xon_mode, exit_xon_mode, xon_character, xoff_character,
display_clock, remove_clock, user[0-5], display_pc_char,
enter_scancode_mode, exit_scancode_mode, pc_term_options,
scancode_escape, alt_scancode_esc.
These are the potentially important ones for ncurses. Notes:
i) ncurses doesn't need move_insert; it never uses cup/hpa/vpa while
insert_mode is on.
ii) We probably don't care about dest_tabs_magic_smso; only
Telerays used it and they're all long obsolete.

2140
contrib/ncurses/aclocal.m4 vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,387 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
$Id: announce.html,v 1.30 1999/05/16 17:01:39 juergen Exp $
-->
<HTML>
<HEAD>
<TITLE>Announcing ncurses 5.0</TITLE>
<link rev=made href="mailto:bug-ncurses@gnu.org">
</HEAD>
<BODY>
<H1>Announcing ncurses 5.0</H1>
The ncurses (new curses) library is a free software emulation of
curses in System V Release 4.0, and more. It uses terminfo format,
supports pads and color
and multiple highlights and forms characters and function-key mapping,
and has all the other SYSV-curses enhancements over BSD curses.<P>
In mid-June 1995, the maintainer of 4.4BSD curses declared that he
considered 4.4BSD curses obsolete, and is encouraging the keepers of
Unix releases such as BSD/OS, freeBSD and netBSD to switch over to
ncurses.<P>
The ncurses code was developed under GNU/Linux. It should port easily to
any ANSI/POSIX-conforming UNIX. It has even been ported to OS/2 Warp!<P>
The distribution includes the library and support utilities, including a
terminfo compiler tic(1), a decompiler infocmp(1), clear(1), tput(1), tset(1),
and a termcap conversion tool captoinfo(1). Full manual pages are provided for
the library and tools.<P>
The ncurses distribution is available via anonymous FTP at
the GNU distribution site
<A HREF="ftp://ftp.gnu.org/pub/gnu">ftp://ftp.gnu.org/pub/gnu</A>.
It is also available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H1>Release Notes</H1>
We decided to release ncurses as a new whole number release (5.0) because it
incorporates several interface changes, including some that would invalidate
existing shared libraries. These are the highlights from the change-log
since ncurses 4.2 release.
<p>
Interface changes:
<ul>
<li>The principal source of changes to the interface comes from the
release of X/Open Curses in 1997. Earlier versions of ncurses (4.0
and before) were based on a draft version of the specification. The
release version adds parameters to some functions to support the
evolving internationalization of curses. These summarize the impact:
<ul>
<li>modified several prototypes to correspond with 1997 version of
X/Open Curses (affects ABI since developers have used attr_get).
<li>corrected prototypes for slk_* functions, using chtype rather than
attr_t.
<li>the slk_attr_{set,off,on} functions need an additional void*
parameter according to XSI.
<li>correct macros for wattr_set, wattr_get, separate wattrset macro from
these to preserve behavior that allows attributes to be combined with
color pair numbers.
<li>reviewed/updated curses.h, term.h against X/Open Curses Issue 4
Version 2. This includes making some parameters NCURSES_CONST
rather than const, e.g., in termcap.h.
<li>reviewed/corrected macros in curses.h as per XSI document.
<li>add set_a_attributes and set_pglen_inch to terminfo structure, as per
XSI and Solaris 2.5.
</ul>
<li>The newest version of the X/Open Curses is implemented on Solaris
and other vendor's systems. It adds new features to the terminfo
descriptions:
<ul>
<li>implement tparm %l format.
<li>implement tparm printf-style width and precision for %s, %d, %x, %o
as per XSI.
</ul>
<li>We made additional changes to reduce impact by future interface
changes:
<ul>
<li>change key_names[] array to static since it is not part of the curses
interface.
<li>move macro winch to a function, to hide details of struct ldat
</ul>
<li>modify configure script to embed ABI in shared libraries for HP-UX
10.x (detailed request by Tim Mooney).
<li>modify configuration of shared libraries on Digital Unix so that
versioning is embedded in the library, rather than implied by
links (patch by Tim Mooney).
</ul>
New features:
<ul>
<li>enable sigwinch handler by default.
<li>turn on hashmap scrolling code by default
<li>improved support for termcap applications
<ul>
<li>modify tput to accept termcap names as an alternative to terminfo
names.
<li>provide support for termcap PC variable by copying it from terminfo
data and using it as the padding character in tputs.
<li>provide support for termcap ospeed variable by copying it from the
internal cur_term member, and using ospeed as the baudrate
reference for the delay_output and tputs functions.
<li>change name-comparisons in lib_termcap to compare no more than 2
characters.
<li>add configure option --enable-tcap-names, which essentially
allows users to define new capabilities as in termcap.
</ul>
<li>add mouse support to ncurses menus.
<li>add mouse and dll support for OS/2 EMX
<li>modify terminfo parsing to accept octal and hexadecimal constants
<li>add configure option --enable-no-padding, to allow environment
variable $NCURSES_NO_PADDING to eliminate non-mandatory padding,
thereby making terminal emulators (e.g., for vt100) a little more
efficient.
<li>modify lib_color.c to eliminate dependency on orig_colors and
orig_pair, since SVr4 curses does not require these either, but
uses them when they are available.
<li>add -f option to infocmp and tic, which formats the terminfo
if/then/else/endif so that they are readable (with newlines and
tabs).
<li>modify tic to compile into %'char' form in preference to %{number},
since that is a little more efficient.
</ul>
Major bug fixes:
<ul>
<li>modify lib_tstp.c to block SIGTTOU when handling SIGTSTP, fixes a
problem where ncurses applications which were run via a shell script
would hang when given a ^Z. Also, check if the terminal's process
group is consistent, i.e., a shell has not taken ownership of it,
before deciding to save the current terminal settings in the SIGTSTP
handler.
<li>suppress sc/rc capabilities from terminal description if they appear
in smcup/rmcup. This affects only scrolling optimization, to fix a
problem reported by several people with xterm's alternate screen,
though the problem is more general.
<li>modify relative_move and tputs to avoid an interaction with the
BSD-style padding. The relative_move function could produce a string
to replace on the screen which began with a numeric character, which
was then interpreted by tputs as padding.
<li>modify setupterm so that cancelled strings are treated the same as
absent strings, cancelled and absent booleans false (does not affect
tic, infocmp).
<li>modify lib_vidattr.c to allow for terminal types (e.g., xterm-color)
which may reset all attributes in the 'op' capability, so that colors
are set before turning on bold and other attributes, but still after
turning attributes off.
<li>use 'access()' to check if ncurses library should be permitted to
open or modify files with fopen/open/link/unlink/remove calls, in
case the calling application is running in setuid mode.
<li>correction to doupdate, for case where terminal does not support
insert/delete character. The logic did not check that there was a
difference in alignment of changes to old/new screens before
repainting the whole non-blank portion of the line. Modified to fall
through into logic that reduces by the portion which does not differ.
</ul>
<H1>Features of Ncurses</H1>
The ncurses package is fully compatible with SVr4 (System V Release 4) curses:<P>
<UL>
<LI>All 257 of the SVr4 calls have been implemented (and are documented).
<LI>Full support for SVr4 curses features including keyboard mapping, color,
forms-drawing with ACS characters, and automatic recognition of keypad
and function keys.
<LI>An emulation of the SVr4 panels library, supporting
a stack of windows with backing store, is included.
<LI>An emulation of the SVr4 menus library, supporting
a uniform but flexible interface for menu programming, is included.
<LI>An emulation of the SVr4 form library, supporting
data collection through on-screen forms, is included.
<LI>Binary terminfo entries generated by the ncurses tic(1) implementation
are bit-for-bit-compatible with the entry format SVr4 curses uses.
<LI>The utilities have options to allow you to filter terminfo
entries for use with less capable <STRONG>curses</STRONG>/<STRONG>terminfo</STRONG>
versions such as the HP/UX and AIX ports.</UL>
The ncurses package also has many useful extensions over SVr4:<P>
<UL>
<LI>The API is 8-bit clean and base-level conformant with the X/OPEN curses
specification, XSI curses (that is, it implements all BASE level features,
but not all EXTENDED features). Most EXTENDED-level features not directly
concerned with wide-character support are implemented, including many
function calls not supported under SVr4 curses (but portability of all
calls is documented so you can use the SVr4 subset only).
<LI>Unlike SVr4 curses, ncurses can write to the rightmost-bottommost corner
of the screen if your terminal has an insert-character capability.
<LI>Ada95 and C++ bindings.
<LI>Support for mouse event reporting with X Window xterm and OS/2 console windows.
<LI>Extended mouse support via Alessandro Rubini's gpm package.
<LI>The function <CODE>wresize()</CODE> allows you to resize windows, preserving
their data.
<LI>The function <CODE>use_default_colors()</CODE> allows you to
use the terminal's default colors for the default color pair,
achieving the effect of transparent colors.
<LI>The functions <CODE>keyok()</CODE>
and <CODE>define_key()</CODE> allow
you to better control the use of function keys,
e.g., disabling the ncurses KEY_MOUSE,
or by defining more than one control sequence to map to a given key code.
<LI>Support for 16-color terminals, such as aixterm and XFree86 xterm.
<LI>Better cursor-movement optimization. The package now features a
cursor-local-movement computation more efficient than either BSD's
or System V's.
<LI>Super hardware scrolling support. The screen-update code incorporates
a novel, simple, and cheap algorithm that enables it to make optimal
use of hardware scrolling, line-insertion, and line-deletion
for screen-line movements. This algorithm is more powerful than
the 4.4BSD curses quickch() routine.
<LI>Real support for terminals with the magic-cookie glitch. The
screen-update code will refrain from drawing a highlight if the magic-
cookie unattributed spaces required just before the beginning and
after the end would step on a non-space character. It will
automatically shift highlight boundaries when doing so would make it
possible to draw the highlight without changing the visual appearance
of the screen.
<LI>It is possible to generate the library with a list of pre-loaded
fallback entries linked to it so that it can serve those terminal types even
when no terminfo tree or termcap file is accessible (this may be useful
for support of screen-oriented programs that must run in single-user mode).
<LI>The tic(1)/captoinfo utility provided with ncurses has the
ability to translate many termcaps from the XENIX, IBM and
AT&amp;T extension sets.
<LI>A BSD-like tset(1) utility is provided.
<LI>The ncurses library and utilities will automatically read terminfo
entries from $HOME/.terminfo if it exists, and compile to that directory
if it exists and the user has no write access to the system directory.
This feature makes it easier for users to have personal terminfo entries
without giving up access to the system terminfo directory.
<LI>You may specify a path of directories to search for compiled
descriptions with the environment variable TERMINFO_DIRS (this
generalizes the feature provided by TERMINFO under stock System V.)
<LI>In terminfo source files, use capabilities may refer not just to
other entries in the same source file (as in System V) but also to
compiled entries in either the system terminfo directory or the user's
$HOME/.terminfo directory.
<LI>A script (<STRONG>capconvert</STRONG>) is provided to help BSD users
transition from termcap to terminfo. It gathers the information in a
TERMCAP environment variable and/or a ~/.termcap local entries file
and converts it to an equivalent local terminfo tree under $HOME/.terminfo.
<LI>Automatic fallback to the /etc/termcap file can be compiled in
when it is not possible to build a terminfo tree. This feature is neither
fast nor cheap, you don't want to use it unless you have to,
but it's there.
<LI>The table-of-entries utility <STRONG>toe</STRONG> makes it easy for users to
see exactly what terminal types are available on the system.
<LI>The library meets the XSI requirement that every macro entry
point have a corresponding function which may be linked (and will be
prototype-checked) if the macro definition is disabled with
<CODE>#undef</CODE>.
<LI>An HTML "Introduction to Programming with NCURSES" document provides
a narrative introduction to the curses programming interface.
</UL>
<H1>State of the Package</H1>
Numerous bugs present in earlier versions have been fixed; the
library is far more reliable than it used to be. Bounds checking in many
`dangerous' entry points has been improved. The code is now type-safe
according to gcc -Wall. The library has been checked for malloc leaks and
arena corruption by the Purify memory-allocation tester.<P>
The ncurses code has been tested with a wide variety of applications
including (versions starting with those noted):<P>
<DL>
<DT> ded
<DD> directory-editor
<A HREF="ftp://ftp.clark.net/pub/dickey/ded">ftp://ftp.clark.net/pub/dickey/ded</A>.
<DT> dialog
<DD> the underlying application used in Slackware's setup, and the basis
for similar applications on GNU/Linux.
<DT> lynx-2.7
<DD> the character-screen WWW browser
<DT> Midnight Commander 4.1
<DD> file manager
<DT> mutt 0.88
<DD> mail utility
<DT> ncftp 2.0
<DD> file-transfer utility
<DT> nvi
<DD> New vi versions 1.50 are able to use ncurses versions 1.9.7 and later.
<DT> taper
<DD> tape archive utility
<DT> vh-1.6
<DD> Volks-Hypertext browser for the Jargon File
</DL>
as well as some that use ncurses for the terminfo support alone:
<DL>
<DT> minicom-1.75
<DD> terminal emulator
<DT> tin-unoff
<DD> tin 1.4 newsreader, supporting color, MIME
<A HREF="ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff">ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff</A>.
<DT> vile
<DD> vi-like-emacs
<A HREF="ftp://ftp.clark.net/pub/dickey/vile">ftp://ftp.clark.net/pub/dickey/vile</A>.
</DL>
<P>
The ncurses distribution includes a selection of test programs (including
a few games).
<H2>Who's Who and What's What</H2>
The original developers of ncurses are <A
HREF="mailto:zmbenhal@netcom.com">Zeyd Ben-Halim</A> and
<A HREF="http://www.ccil.org/~esr/home.html">Eric S. Raymond</A>.
Ongoing work is being done by
<A HREF="mailto:dickey@clark.net">Thomas Dickey</A>
and
<A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>.
<A HREF="mailto:florian@gnu.org">Florian La Roche</A>
acts as the maintainer for the Free Software Foundation, which holds the
copyright on ncurses.
Contact the current maintainers at
<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.
<P>
To join the ncurses mailing list, please write email to
<CODE>bug-ncurses-request@gnu.org</CODE> containing the line:
<PRE>
subscribe &lt;name&gt;@&lt;host.domain&gt;
</PRE>
This list is open to anyone interested in helping with the development and
testing of this package.<P>
Beta versions of ncurses and patches to the current release are made available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H2>Future Plans</H2>
<UL>
<LI>Extended-level XPG4 conformance, with internationalization support.
<LI>Ports to more systems, including DOS and Windows.
</UL>
We need people to help with these projects. If you are interested in working
on them, please join the ncurses list.
<H2>Other Related Resources</H2>
The distribution includes and uses a version of the terminfo-format
terminal description file maintained by Eric Raymond.
<A HREF="http://earthspace.net/~esr/terminfo">http://earthspace.net/~esr/terminfo</A>.<P>
You can find lots of information on terminal-related topics
not covered in the terminfo file at
<A HREF="http://www.cs.utk.edu/~shuford/terminal_index.html">Richard Shuford's
archive</A>.
</BODY>
</HTML>
<!--
# The following sets edit modes for GNU EMACS
# Local Variables:
# mode:html
# case-fold-search:nil
# fill-column:70
# End:
-->

View File

@ -0,0 +1,387 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN">
<!--
$Id: announce.html.in,v 1.30 1999/05/16 17:01:39 juergen Exp $
-->
<HTML>
<HEAD>
<TITLE>Announcing ncurses @VERSION@</TITLE>
<link rev=made href="mailto:bug-ncurses@gnu.org">
</HEAD>
<BODY>
<H1>Announcing ncurses @VERSION@</H1>
The ncurses (new curses) library is a free software emulation of
curses in System V Release 4.0, and more. It uses terminfo format,
supports pads and color
and multiple highlights and forms characters and function-key mapping,
and has all the other SYSV-curses enhancements over BSD curses.<P>
In mid-June 1995, the maintainer of 4.4BSD curses declared that he
considered 4.4BSD curses obsolete, and is encouraging the keepers of
Unix releases such as BSD/OS, freeBSD and netBSD to switch over to
ncurses.<P>
The ncurses code was developed under GNU/Linux. It should port easily to
any ANSI/POSIX-conforming UNIX. It has even been ported to OS/2 Warp!<P>
The distribution includes the library and support utilities, including a
terminfo compiler tic(1), a decompiler infocmp(1), clear(1), tput(1), tset(1),
and a termcap conversion tool captoinfo(1). Full manual pages are provided for
the library and tools.<P>
The ncurses distribution is available via anonymous FTP at
the GNU distribution site
<A HREF="ftp://ftp.gnu.org/pub/gnu">ftp://ftp.gnu.org/pub/gnu</A>.
It is also available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H1>Release Notes</H1>
We decided to release ncurses as a new whole number release (5.0) because it
incorporates several interface changes, including some that would invalidate
existing shared libraries. These are the highlights from the change-log
since ncurses 4.2 release.
<p>
Interface changes:
<ul>
<li>The principal source of changes to the interface comes from the
release of X/Open Curses in 1997. Earlier versions of ncurses (4.0
and before) were based on a draft version of the specification. The
release version adds parameters to some functions to support the
evolving internationalization of curses. These summarize the impact:
<ul>
<li>modified several prototypes to correspond with 1997 version of
X/Open Curses (affects ABI since developers have used attr_get).
<li>corrected prototypes for slk_* functions, using chtype rather than
attr_t.
<li>the slk_attr_{set,off,on} functions need an additional void*
parameter according to XSI.
<li>correct macros for wattr_set, wattr_get, separate wattrset macro from
these to preserve behavior that allows attributes to be combined with
color pair numbers.
<li>reviewed/updated curses.h, term.h against X/Open Curses Issue 4
Version 2. This includes making some parameters NCURSES_CONST
rather than const, e.g., in termcap.h.
<li>reviewed/corrected macros in curses.h as per XSI document.
<li>add set_a_attributes and set_pglen_inch to terminfo structure, as per
XSI and Solaris 2.5.
</ul>
<li>The newest version of the X/Open Curses is implemented on Solaris
and other vendor's systems. It adds new features to the terminfo
descriptions:
<ul>
<li>implement tparm %l format.
<li>implement tparm printf-style width and precision for %s, %d, %x, %o
as per XSI.
</ul>
<li>We made additional changes to reduce impact by future interface
changes:
<ul>
<li>change key_names[] array to static since it is not part of the curses
interface.
<li>move macro winch to a function, to hide details of struct ldat
</ul>
<li>modify configure script to embed ABI in shared libraries for HP-UX
10.x (detailed request by Tim Mooney).
<li>modify configuration of shared libraries on Digital Unix so that
versioning is embedded in the library, rather than implied by
links (patch by Tim Mooney).
</ul>
New features:
<ul>
<li>enable sigwinch handler by default.
<li>turn on hashmap scrolling code by default
<li>improved support for termcap applications
<ul>
<li>modify tput to accept termcap names as an alternative to terminfo
names.
<li>provide support for termcap PC variable by copying it from terminfo
data and using it as the padding character in tputs.
<li>provide support for termcap ospeed variable by copying it from the
internal cur_term member, and using ospeed as the baudrate
reference for the delay_output and tputs functions.
<li>change name-comparisons in lib_termcap to compare no more than 2
characters.
<li>add configure option --enable-tcap-names, which essentially
allows users to define new capabilities as in termcap.
</ul>
<li>add mouse support to ncurses menus.
<li>add mouse and dll support for OS/2 EMX
<li>modify terminfo parsing to accept octal and hexadecimal constants
<li>add configure option --enable-no-padding, to allow environment
variable $NCURSES_NO_PADDING to eliminate non-mandatory padding,
thereby making terminal emulators (e.g., for vt100) a little more
efficient.
<li>modify lib_color.c to eliminate dependency on orig_colors and
orig_pair, since SVr4 curses does not require these either, but
uses them when they are available.
<li>add -f option to infocmp and tic, which formats the terminfo
if/then/else/endif so that they are readable (with newlines and
tabs).
<li>modify tic to compile into %'char' form in preference to %{number},
since that is a little more efficient.
</ul>
Major bug fixes:
<ul>
<li>modify lib_tstp.c to block SIGTTOU when handling SIGTSTP, fixes a
problem where ncurses applications which were run via a shell script
would hang when given a ^Z. Also, check if the terminal's process
group is consistent, i.e., a shell has not taken ownership of it,
before deciding to save the current terminal settings in the SIGTSTP
handler.
<li>suppress sc/rc capabilities from terminal description if they appear
in smcup/rmcup. This affects only scrolling optimization, to fix a
problem reported by several people with xterm's alternate screen,
though the problem is more general.
<li>modify relative_move and tputs to avoid an interaction with the
BSD-style padding. The relative_move function could produce a string
to replace on the screen which began with a numeric character, which
was then interpreted by tputs as padding.
<li>modify setupterm so that cancelled strings are treated the same as
absent strings, cancelled and absent booleans false (does not affect
tic, infocmp).
<li>modify lib_vidattr.c to allow for terminal types (e.g., xterm-color)
which may reset all attributes in the 'op' capability, so that colors
are set before turning on bold and other attributes, but still after
turning attributes off.
<li>use 'access()' to check if ncurses library should be permitted to
open or modify files with fopen/open/link/unlink/remove calls, in
case the calling application is running in setuid mode.
<li>correction to doupdate, for case where terminal does not support
insert/delete character. The logic did not check that there was a
difference in alignment of changes to old/new screens before
repainting the whole non-blank portion of the line. Modified to fall
through into logic that reduces by the portion which does not differ.
</ul>
<H1>Features of Ncurses</H1>
The ncurses package is fully compatible with SVr4 (System V Release 4) curses:<P>
<UL>
<LI>All 257 of the SVr4 calls have been implemented (and are documented).
<LI>Full support for SVr4 curses features including keyboard mapping, color,
forms-drawing with ACS characters, and automatic recognition of keypad
and function keys.
<LI>An emulation of the SVr4 panels library, supporting
a stack of windows with backing store, is included.
<LI>An emulation of the SVr4 menus library, supporting
a uniform but flexible interface for menu programming, is included.
<LI>An emulation of the SVr4 form library, supporting
data collection through on-screen forms, is included.
<LI>Binary terminfo entries generated by the ncurses tic(1) implementation
are bit-for-bit-compatible with the entry format SVr4 curses uses.
<LI>The utilities have options to allow you to filter terminfo
entries for use with less capable <STRONG>curses</STRONG>/<STRONG>terminfo</STRONG>
versions such as the HP/UX and AIX ports.</UL>
The ncurses package also has many useful extensions over SVr4:<P>
<UL>
<LI>The API is 8-bit clean and base-level conformant with the X/OPEN curses
specification, XSI curses (that is, it implements all BASE level features,
but not all EXTENDED features). Most EXTENDED-level features not directly
concerned with wide-character support are implemented, including many
function calls not supported under SVr4 curses (but portability of all
calls is documented so you can use the SVr4 subset only).
<LI>Unlike SVr4 curses, ncurses can write to the rightmost-bottommost corner
of the screen if your terminal has an insert-character capability.
<LI>Ada95 and C++ bindings.
<LI>Support for mouse event reporting with X Window xterm and OS/2 console windows.
<LI>Extended mouse support via Alessandro Rubini's gpm package.
<LI>The function <CODE>wresize()</CODE> allows you to resize windows, preserving
their data.
<LI>The function <CODE>use_default_colors()</CODE> allows you to
use the terminal's default colors for the default color pair,
achieving the effect of transparent colors.
<LI>The functions <CODE>keyok()</CODE>
and <CODE>define_key()</CODE> allow
you to better control the use of function keys,
e.g., disabling the ncurses KEY_MOUSE,
or by defining more than one control sequence to map to a given key code.
<LI>Support for 16-color terminals, such as aixterm and XFree86 xterm.
<LI>Better cursor-movement optimization. The package now features a
cursor-local-movement computation more efficient than either BSD's
or System V's.
<LI>Super hardware scrolling support. The screen-update code incorporates
a novel, simple, and cheap algorithm that enables it to make optimal
use of hardware scrolling, line-insertion, and line-deletion
for screen-line movements. This algorithm is more powerful than
the 4.4BSD curses quickch() routine.
<LI>Real support for terminals with the magic-cookie glitch. The
screen-update code will refrain from drawing a highlight if the magic-
cookie unattributed spaces required just before the beginning and
after the end would step on a non-space character. It will
automatically shift highlight boundaries when doing so would make it
possible to draw the highlight without changing the visual appearance
of the screen.
<LI>It is possible to generate the library with a list of pre-loaded
fallback entries linked to it so that it can serve those terminal types even
when no terminfo tree or termcap file is accessible (this may be useful
for support of screen-oriented programs that must run in single-user mode).
<LI>The tic(1)/captoinfo utility provided with ncurses has the
ability to translate many termcaps from the XENIX, IBM and
AT&amp;T extension sets.
<LI>A BSD-like tset(1) utility is provided.
<LI>The ncurses library and utilities will automatically read terminfo
entries from $HOME/.terminfo if it exists, and compile to that directory
if it exists and the user has no write access to the system directory.
This feature makes it easier for users to have personal terminfo entries
without giving up access to the system terminfo directory.
<LI>You may specify a path of directories to search for compiled
descriptions with the environment variable TERMINFO_DIRS (this
generalizes the feature provided by TERMINFO under stock System V.)
<LI>In terminfo source files, use capabilities may refer not just to
other entries in the same source file (as in System V) but also to
compiled entries in either the system terminfo directory or the user's
$HOME/.terminfo directory.
<LI>A script (<STRONG>capconvert</STRONG>) is provided to help BSD users
transition from termcap to terminfo. It gathers the information in a
TERMCAP environment variable and/or a ~/.termcap local entries file
and converts it to an equivalent local terminfo tree under $HOME/.terminfo.
<LI>Automatic fallback to the /etc/termcap file can be compiled in
when it is not possible to build a terminfo tree. This feature is neither
fast nor cheap, you don't want to use it unless you have to,
but it's there.
<LI>The table-of-entries utility <STRONG>toe</STRONG> makes it easy for users to
see exactly what terminal types are available on the system.
<LI>The library meets the XSI requirement that every macro entry
point have a corresponding function which may be linked (and will be
prototype-checked) if the macro definition is disabled with
<CODE>#undef</CODE>.
<LI>An HTML "Introduction to Programming with NCURSES" document provides
a narrative introduction to the curses programming interface.
</UL>
<H1>State of the Package</H1>
Numerous bugs present in earlier versions have been fixed; the
library is far more reliable than it used to be. Bounds checking in many
`dangerous' entry points has been improved. The code is now type-safe
according to gcc -Wall. The library has been checked for malloc leaks and
arena corruption by the Purify memory-allocation tester.<P>
The ncurses code has been tested with a wide variety of applications
including (versions starting with those noted):<P>
<DL>
<DT> ded
<DD> directory-editor
<A HREF="ftp://ftp.clark.net/pub/dickey/ded">ftp://ftp.clark.net/pub/dickey/ded</A>.
<DT> dialog
<DD> the underlying application used in Slackware's setup, and the basis
for similar applications on GNU/Linux.
<DT> lynx-2.7
<DD> the character-screen WWW browser
<DT> Midnight Commander 4.1
<DD> file manager
<DT> mutt 0.88
<DD> mail utility
<DT> ncftp 2.0
<DD> file-transfer utility
<DT> nvi
<DD> New vi versions 1.50 are able to use ncurses versions 1.9.7 and later.
<DT> taper
<DD> tape archive utility
<DT> vh-1.6
<DD> Volks-Hypertext browser for the Jargon File
</DL>
as well as some that use ncurses for the terminfo support alone:
<DL>
<DT> minicom-1.75
<DD> terminal emulator
<DT> tin-unoff
<DD> tin 1.4 newsreader, supporting color, MIME
<A HREF="ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff">ftp://ftp.akk.uni-karlsruhe.de/pub/news/clients/tin-unoff</A>.
<DT> vile
<DD> vi-like-emacs
<A HREF="ftp://ftp.clark.net/pub/dickey/vile">ftp://ftp.clark.net/pub/dickey/vile</A>.
</DL>
<P>
The ncurses distribution includes a selection of test programs (including
a few games).
<H2>Who's Who and What's What</H2>
The original developers of ncurses are <A
HREF="mailto:zmbenhal@netcom.com">Zeyd Ben-Halim</A> and
<A HREF="http://www.ccil.org/~esr/home.html">Eric S. Raymond</A>.
Ongoing work is being done by
<A HREF="mailto:dickey@clark.net">Thomas Dickey</A>
and
<A HREF="mailto:juergen.pfeifer@gmx.net">J&uuml;rgen Pfeifer</A>.
<A HREF="mailto:florian@gnu.org">Florian La Roche</A>
acts as the maintainer for the Free Software Foundation, which holds the
copyright on ncurses.
Contact the current maintainers at
<A HREF="mailto:bug-ncurses@gnu.org">bug-ncurses@gnu.org</A>.
<P>
To join the ncurses mailing list, please write email to
<CODE>bug-ncurses-request@gnu.org</CODE> containing the line:
<PRE>
subscribe &lt;name&gt;@&lt;host.domain&gt;
</PRE>
This list is open to anyone interested in helping with the development and
testing of this package.<P>
Beta versions of ncurses and patches to the current release are made available at
<A HREF="ftp://ftp.clark.net/pub/dickey/ncurses">ftp://ftp.clark.net/pub/dickey/ncurses</A>.
<H2>Future Plans</H2>
<UL>
<LI>Extended-level XPG4 conformance, with internationalization support.
<LI>Ports to more systems, including DOS and Windows.
</UL>
We need people to help with these projects. If you are interested in working
on them, please join the ncurses list.
<H2>Other Related Resources</H2>
The distribution includes and uses a version of the terminfo-format
terminal description file maintained by Eric Raymond.
<A HREF="http://earthspace.net/~esr/terminfo">http://earthspace.net/~esr/terminfo</A>.<P>
You can find lots of information on terminal-related topics
not covered in the terminfo file at
<A HREF="http://www.cs.utk.edu/~shuford/terminal_index.html">Richard Shuford's
archive</A>.
</BODY>
</HTML>
<!--
# The following sets edit modes for GNU EMACS
# Local Variables:
# mode:html
# case-fold-search:nil
# fill-column:70
# End:
-->

View File

@ -0,0 +1,185 @@
# $Id: Makefile.in,v 1.48 1999/07/31 09:47:11 juergen 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
#
# Simple makefile for c++ window class demo
# turn off _all_ suffix rules; we'll generate our own
.SUFFIXES:
SHELL = /bin/sh
MODEL = ../@DFT_OBJ_SUBDIR@
INSTALL_PREFIX = @INSTALL_PREFIX@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
includedir = @includedir@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
AR = @AR@
AR_OPTS = @AR_OPTS@
RANLIB = @RANLIB@
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
CXXLIBS = @CXXLIBS@
INCDIR = ../include
CPPFLAGS = -I../c++ -I$(INCDIR) -I$(srcdir) -DHAVE_CONFIG_H @CPPFLAGS@
CCFLAGS = $(CPPFLAGS) $(CXXFLAGS)
CFLAGS_NORMAL = $(CCFLAGS)
CFLAGS_DEBUG = $(CCFLAGS) @CXX_G_OPT@ -DTRACE
CFLAGS_PROFILE = $(CCFLAGS) -pg
CFLAGS_SHARED = $(CCFLAGS) # @CC_SHARED_OPTS@
CFLAGS_DEFAULT = $(CFLAGS_@DFT_UPR_MODEL@)
REL_VERSION = @cf_cv_rel_version@
ABI_VERSION = @cf_cv_abi_version@
LINK = @LINK_PROGS@ $(CXX)
LIBROOT = ncurses++
LIBNAME = lib$(LIBROOT).a
LDFLAGS = @EXTRA_LDFLAGS@ -L../lib -L$(libdir) \
-l$(LIBROOT) \
@TEST_ARGS@ @LDFLAGS@ \
@LD_MODEL@ @LIBS@ @EXTRA_LIBS@ @LOCAL_LDFLAGS@ $(CXXLIBS)
LDFLAGS_NORMAL = $(LDFLAGS)
LDFLAGS_DEBUG = $(LDFLAGS) @CC_G_OPT@
LDFLAGS_PROFILE = $(LDFLAGS) -pg
LDFLAGS_SHARED = $(LDFLAGS) @LD_SHARED_OPTS@
LDFLAGS_DEFAULT = $(LDFLAGS_@DFT_UPR_MODEL@)
AUTO_SRC = \
etip.h
all: $(AUTO_SRC) ../lib/$(LIBNAME) demo
sources : $(AUTO_SRC)
# Build a conventional library for installing, since a shared library would
# pull in all of the ncurses libraries (panel, menu, form, ncurses) as direct
# dependencies.
LIB_OBJS = \
$(MODEL)/cursesf.o \
$(MODEL)/cursesm.o \
$(MODEL)/cursesw.o \
$(MODEL)/cursespad.o \
$(MODEL)/cursesp.o \
$(MODEL)/cursslk.o \
$(MODEL)/cursesapp.o \
$(MODEL)/cursesmain.o
../lib/$(LIBNAME) : $(LIB_OBJS)
$(AR) $(AR_OPTS) $@ $?
$(RANLIB) $@
OBJS_DEMO = $(MODEL)/demo.o
$(MODEL)/demo.o : $(srcdir)/demo.cc \
$(cursesf_h) $(cursesm_h) $(cursesapp_h)
demo: $(OBJS_DEMO) \
../lib/$(LIBNAME) \
@TEST_DEPS@
@ECHO_LINK@ $(LINK) -o $@ $(OBJS_DEMO) $(LDFLAGS_DEFAULT)
etip.h: $(srcdir)/etip.h.in $(srcdir)/edit_cfg.sh
cp $(srcdir)/etip.h.in $@
sh $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
$(INSTALL_PREFIX)$(libdir) :
$(srcdir)/../mkinstalldirs $@
install \
install.libs:: ../lib/$(LIBNAME) $(INSTALL_PREFIX)$(libdir)
$(INSTALL) ../lib/$(LIBNAME) $(INSTALL_PREFIX)$(libdir)/$(LIBNAME)
uninstall \
uninstall.libs::
-rm -f $(INSTALL_PREFIX)$(libdir)/$(LIBNAME)
mostlyclean ::
-rm -f core tags TAGS *~ *.ln *.atac trace
clean :: mostlyclean
-rm -f demo $(AUTO_SRC) ../lib/$(LIBNAME) $(LIB_OBJS) $(OBJS_DEMO)
distclean :: clean
-rm -f Makefile
realclean :: distclean
###############################################################################
cursesw_h = $(srcdir)/cursesw.h \
etip.h \
$(INCDIR)/curses.h
cursesp_h = $(srcdir)/cursesp.h \
$(cursesw_h) \
$(INCDIR)/panel.h
cursesf_h = $(srcdir)/cursesf.h \
$(cursesp_h) \
$(INCDIR)/form.h
cursesm_h = $(srcdir)/cursesm.h \
$(cursesp_h) \
$(INCDIR)/menu.h
cursslk_h = $(srcdir)/cursslk.h \
$(cursesw_h)
cursesapp_h = $(srcdir)/cursesapp.h \
$(cursslk_h)
$(INCDIR)/form.h :
cd ../form && $(MAKE) $@
$(INCDIR)/menu.h :
cd ../menu && $(MAKE) $@
$(INCDIR)/panel.h :
cd ../panel && $(MAKE) $@
###############################################################################
# The remainder of this file is automatically generated during configuration
###############################################################################

42
contrib/ncurses/c++/NEWS Normal file
View File

@ -0,0 +1,42 @@
This is a log of changes that the ncurses C++ binding has gone
through starting with the integration of menu and forms integration
into the binding.
990731 + Improve support for pads. A viewport window may now be added to
a pad. It will then be possible to use a builtin panning mechanism
to view the pad.
970908 + Improve NCursesWindow class: added additional methods to
cover more ncurses functionality. Make refresh() and
noutrefresh() virtual members to allow different implementation
in the NCursesPanel class.
+ CAUTION: changed order of parameters in vline() and hline() of
NCursesWindow class.
+ Make refresh() in NCursesPanel non-static, it is now a
reimplementation of refresh() in the base class. Added
noutrefresh() to NCursesPanel.
+ Added NCursesForm and related classes to support libform
functionality.
+ Moved most of configuration related stuff from cursesw.h to
etip.h
+ Added NCursesApplication class to support easy configuration
of menu and forms related attributes as well as ripped of
title lines and Soft-Label-Keys for an application.
+ Support of Auto-Cleanup for a menus fieldlist.
+ Change of return type for current_item() and operator[] for
menus.
+ Enhanced demo.
970502
+ Introduced the THROW and THROWS functions/macros to prepare
a smoother transition to real exception handling.
+ Exception classes provided in etip.h
+ Added the NCursesMenu class to support libmenu functionality.
+ The inheritace relation between NCursesWindow and NCursesColorWindow
was kind of brain damage. Monochrome is a special case of colored, so
the relation should be just the opposite. This would allow all
derived classes like NCursesPanel, NCursesMenu or NCursesForm to
have colors.
To resolve that design flaw I put the color functionality into the
NCursesWindow class and it can be switched on by the static member
useColors(). NCursesColorWindow is still there for compatibility
reasons.

View File

@ -0,0 +1,5 @@
This is a list of open problems. This mainly lists known missing pieces
and design flaws.
1. Testing!!!
2. Better demo program

View File

@ -0,0 +1,58 @@
C++ interface to ncurses routines
-----------------------------------------------------------------------
This directory contains the source code for several C++ classes which
ease the use of writing ncurses-based programs. The code is derived
from the libg++ CursesWindow class but enhanced for ncurses.
The classes simplify the use of window specific functions by
encapsulating them in the window object. Function overloading is
used in order to narrow the interface. E.g. you don't have the
distinction between `printw' and `mvprintw' anymore.
A second benefit is the removal of all #defines which are included in
the curses.h file. This is a steady cause of trouble because many
common identifiers are used. Instead now all #defines are inline
functions which also allows strict type checking of arguments.
The next enhancement is color support. It was originally provided by a
derived class. This caused some trouble if you think about Panels or
Menus and Forms with colors. We decided to put color support into the
base class so that any derived class may use color support also.
The implementation chosen here is directed to unrestricted use
of mixes of color and monochrome windows. The original NCursesColorWindow
class is maintained for compatibility reasons.
The last point to mention is the support of other packages that are
distributed with the ncurses package: the panels library, the menu library
and the form library. This support is provided by the NCursesPanel class,
which is also derived from the NCursesWindow class and the NCursesMenu
and NCursesForm classes which are derived from NCursesPanel. This allows
building interfaces with windows.
Please see the example program for a quick introduction.
Note that at this point, there is no documentation for these classes.
Hopefully some will be written in the not too distant future. For now,
to find out how to use the classes, read the code and the example program.
Suggestions for enhancements and contributions of code (and docs) are
welcome. Please let us know which functionality you miss.
ATTENTION LINUX USERS: There is currently some discussion of
replacing the BSD curses in the Linux libc with ncurses. If
this is done we could perhaps include these classes in the Linux
libg++ replacing the original CursesWindow class (and renaming it
to CursesWindow). This could be done because NCursesWindow can
be made easily to a superset of the CursesWindow class.
Original author:
Eric Newton <newton@rocky.oswego.edu> for FSF's libg++
Authors of first ncurses based release (NCursesWindow, NCursesPanel):
Ulrich Drepper <drepper@ira.uka.de>
and Anatoly Ivasyuk <anatoly@nick.csh.rit.edu>
Author of this release:
Juergen Pfeifer <juergen.pfeifer@gmx.net>

View File

@ -0,0 +1,146 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
#include "cursesapp.h"
#include "internal.h"
MODULE_ID("$Id: cursesapp.cc,v 1.4 1999/05/16 17:31:11 juergen Exp $")
void
NCursesApplication::init(bool bColors) {
if (bColors)
NCursesWindow::useColors();
if (Root_Window->colors() > 1) {
b_Colors = TRUE;
Root_Window->setcolor(1);
Root_Window->setpalette(COLOR_YELLOW,COLOR_BLUE);
Root_Window->setcolor(2);
Root_Window->setpalette(COLOR_CYAN,COLOR_BLUE);
Root_Window->setcolor(3);
Root_Window->setpalette(COLOR_BLACK,COLOR_BLUE);
Root_Window->setcolor(4);
Root_Window->setpalette(COLOR_BLACK,COLOR_CYAN);
Root_Window->setcolor(5);
Root_Window->setpalette(COLOR_BLUE,COLOR_YELLOW);
Root_Window->setcolor(6);
Root_Window->setpalette(COLOR_BLACK,COLOR_GREEN);
}
else
b_Colors = FALSE;
Root_Window->bkgd(' '|window_backgrounds());
}
NCursesApplication* NCursesApplication::theApp = 0;
NCursesWindow* NCursesApplication::titleWindow = 0;
NCursesApplication::SLK_Link* NCursesApplication::slk_stack = 0;
NCursesApplication::~NCursesApplication() {
Soft_Label_Key_Set* S;
delete titleWindow;
while( (S=top()) ) {
pop();
delete S;
}
delete Root_Window;
::endwin();
}
int NCursesApplication::rinit(NCursesWindow& w) {
titleWindow = &w;
return OK;
}
void NCursesApplication::push(Soft_Label_Key_Set& S) {
SLK_Link* L = new SLK_Link;
assert(L);
L->prev = slk_stack;
L->SLKs = &S;
slk_stack = L;
if (Root_Window)
S.show();
}
bool NCursesApplication::pop() {
if (slk_stack) {
SLK_Link* L = slk_stack;
slk_stack = slk_stack->prev;
delete L;
if (Root_Window && top())
top()->show();
}
return (slk_stack ? FALSE : TRUE);
}
Soft_Label_Key_Set* NCursesApplication::top() const {
if (slk_stack)
return slk_stack->SLKs;
else
return (Soft_Label_Key_Set*)0;
}
int NCursesApplication::operator()(void) {
bool bColors = b_Colors;
Soft_Label_Key_Set* S;
int ts = titlesize();
if (ts>0)
NCursesWindow::ripoffline(ts,rinit);
Soft_Label_Key_Set::Label_Layout fmt = useSLKs();
if (fmt!=Soft_Label_Key_Set::None) {
S = new Soft_Label_Key_Set(fmt);
assert(S);
init_labels(*S);
}
Root_Window = new NCursesWindow(::stdscr);
init(bColors);
if (ts>0)
title();
if (fmt!=Soft_Label_Key_Set::None) {
push(*S);
}
return run();
}
NCursesApplication::NCursesApplication(bool bColors) {
b_Colors = bColors;
if (theApp)
THROW(new NCursesException("Application object already created."));
else
theApp = this;
}

View File

@ -0,0 +1,163 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: cursesapp.h,v 1.5 1999/05/16 17:29:59 juergen Exp $
#ifndef _CURSESAPP_H
#define _CURSESAPP_H
#include <cursslk.h>
class NCursesApplication {
public:
typedef struct _slk_link { // This structure is used to maintain
struct _slk_link* prev; // a stack of SLKs
Soft_Label_Key_Set* SLKs;
} SLK_Link;
private:
static int rinit(NCursesWindow& w); // Internal Init function for title
static NCursesApplication* theApp; // Global ref. to the application
static SLK_Link* slk_stack;
protected:
static NCursesWindow* titleWindow; // The Title Window (if any)
bool b_Colors; // Is this a color application?
NCursesWindow* Root_Window; // This is the stdscr equiv.
// Initialization of attributes;
// Rewrite this in your derived class if you prefer other settings
virtual void init(bool bColors);
// The number of lines for the title window. Default is no title window
// You may rewrite this in your derived class
virtual int titlesize() const {
return 0;
}
// This method is called to put something into the title window initially
// You may rewrite this in your derived class
virtual void title() {
}
// The layout used for the Soft Label Keys. Default is to have no SLKs.
// You may rewrite this in your derived class
virtual Soft_Label_Key_Set::Label_Layout useSLKs() const {
return Soft_Label_Key_Set::None;
}
// This method is called to initialize the SLKs. Default is nothing.
// You may rewrite this in your derived class
virtual void init_labels(Soft_Label_Key_Set& S) const {
}
// Your derived class must implement this method. The return value must
// be the exit value of your application.
virtual int run() = 0;
// The constructor is protected, so you may use it in your derived
// class constructor. The argument tells whether or not you want colors.
NCursesApplication(bool wantColors = FALSE);
public:
virtual ~NCursesApplication();
// Get a pointer to the current application object
static NCursesApplication* getApplication() {
return theApp;
}
// This method runs the application and returns its exit value
int operator()(void);
// Process the commandline arguments. The default implementation simply
// ignores them. Your derived class may rewrite this.
virtual void handleArgs(int argc, char* argv[]) {
}
// Does this application use colors?
inline bool useColors() const {
return b_Colors;
}
// Push the Key Set S onto the SLK Stack. S then becomes the current set
// of Soft Labelled Keys.
void push(Soft_Label_Key_Set& S);
// Throw away the current set of SLKs and make the previous one the
// new current set.
bool pop();
// Retrieve the current set of Soft Labelled Keys.
Soft_Label_Key_Set* top() const;
// Attributes to use for menu and forms foregrounds
virtual chtype foregrounds() const {
return b_Colors ? COLOR_PAIR(1) : A_BOLD;
}
// Attributes to use for menu and forms backgrounds
virtual chtype backgrounds() const {
return b_Colors ? COLOR_PAIR(2) : A_NORMAL;
}
// Attributes to use for inactive (menu) elements
virtual chtype inactives() const {
return b_Colors ? (COLOR_PAIR(3)|A_DIM) : A_DIM;
}
// Attributes to use for (form) labels and SLKs
virtual chtype labels() const {
return b_Colors ? COLOR_PAIR(4) : A_NORMAL;
}
// Attributes to use for form backgrounds
virtual chtype dialog_backgrounds() const {
return b_Colors ? COLOR_PAIR(4) : A_NORMAL;
}
// Attributes to use as default for (form) window backgrounds
virtual chtype window_backgrounds() const {
return b_Colors ? COLOR_PAIR(5) : A_NORMAL;
}
// Attributes to use for the title window
virtual chtype screen_titles() const {
return b_Colors ? COLOR_PAIR(6) : A_BOLD;
}
};
#endif // _CURSESAPP_H

View File

@ -0,0 +1,423 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
#include "cursesf.h"
#include "cursesapp.h"
#include "internal.h"
MODULE_ID("$Id: cursesf.cc,v 1.9 1999/05/16 17:29:36 juergen Exp $")
NCursesFormField::~NCursesFormField () {
if (field)
OnError(::free_field (field));
}
/* Construct a FIELD* array from an array of NCursesFormField
* objects.
*/
FIELD**
NCursesForm::mapFields(NCursesFormField* nfields[]) {
int fieldCount = 0,lcv;
assert(nfields);
for (lcv=0; nfields[lcv]->field; ++lcv)
++fieldCount;
FIELD** fields = new FIELD*[fieldCount + 1];
for (lcv=0;nfields[lcv]->field;++lcv) {
fields[lcv] = nfields[lcv]->field;
}
fields[lcv] = NULL;
my_fields = nfields;
if (form)
delete[] ::form_fields(form);
return fields;
}
void NCursesForm::setDefaultAttributes() {
NCursesApplication* S = NCursesApplication::getApplication();
int n = count();
if (n > 0) {
for(int i=0; i<n; i++) {
NCursesFormField* f = (*this)[i];
if ((f->options() & (O_EDIT|O_ACTIVE))==(O_EDIT|O_ACTIVE)) {
if (S) {
f->set_foreground(S->foregrounds());
f->set_background(S->backgrounds());
}
f->set_pad_character('_');
}
else {
if (S)
f->set_background(S->labels());
}
}
}
if (S) {
bkgd(' '|S->dialog_backgrounds());
if (sub)
sub->bkgd(' '|S->dialog_backgrounds());
}
}
void
NCursesForm::InitForm(NCursesFormField* nfields[],
bool with_frame,
bool autoDelete_Fields) {
int mrows, mcols;
keypad(TRUE);
meta(TRUE);
b_framed = with_frame;
b_autoDelete = autoDelete_Fields;
form = (FORM*)0;
form = ::new_form(mapFields(nfields));
if (!form)
OnError (E_SYSTEM_ERROR);
UserHook* hook = new UserHook;
hook->m_user = NULL;
hook->m_back = this;
hook->m_owner = form;
::set_form_userptr(form,(void*)hook);
::set_form_init (form, NCursesForm::frm_init);
::set_form_term (form, NCursesForm::frm_term);
::set_field_init (form, NCursesForm::fld_init);
::set_field_term (form, NCursesForm::fld_term);
scale(mrows, mcols);
::set_form_win(form, w);
if (with_frame) {
if ((mrows > height()-2) || (mcols > width()-2))
OnError(E_NO_ROOM);
sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
::set_form_sub(form, sub->w);
b_sub_owner = TRUE;
}
else {
sub = (NCursesWindow*)0;
b_sub_owner = FALSE;
}
options_on(O_NL_OVERLOAD);
setDefaultAttributes();
}
NCursesForm::~NCursesForm() {
UserHook* hook = (UserHook*)::form_userptr(form);
delete hook;
if (b_sub_owner) {
delete sub;
::set_form_sub(form,(WINDOW *)0);
}
if (form) {
FIELD** fields = ::form_fields(form);
int cnt = count();
OnError(::set_form_fields(form,(FIELD**)0));
if (b_autoDelete) {
if (cnt>0) {
for (int i=0; i <= cnt; i++)
delete my_fields[i];
}
delete[] my_fields;
}
::free_form(form);
// It's essential to do this after free_form()
delete[] fields;
}
}
void
NCursesForm::setSubWindow(NCursesWindow& nsub) {
if (!isDescendant(nsub))
OnError(E_SYSTEM_ERROR);
else {
if (b_sub_owner)
delete sub;
sub = &nsub;
::set_form_sub(form,sub->w);
}
}
/* Internal hook functions. They will route the hook
* calls to virtual methods of the NCursesForm class,
* so in C++ providing a hook is done simply by
* implementing a virtual method in a derived class
*/
void
NCursesForm::frm_init(FORM *f) {
getHook(f)->On_Form_Init();
}
void
NCursesForm::frm_term(FORM *f) {
getHook(f)->On_Form_Termination();
}
void
NCursesForm::fld_init(FORM *f) {
NCursesForm* F = getHook(f);
F->On_Field_Init (*(F->current_field ()));
}
void
NCursesForm::fld_term(FORM *f) {
NCursesForm* F = getHook(f);
F->On_Field_Termination (*(F->current_field ()));
}
void
NCursesForm::On_Form_Init() {
}
void
NCursesForm::On_Form_Termination() {
}
void
NCursesForm::On_Field_Init(NCursesFormField& field) {
}
void
NCursesForm::On_Field_Termination(NCursesFormField& field) {
}
// call the form driver and do basic error checking.
int
NCursesForm::driver (int c) {
int res = ::form_driver (form, c);
switch (res) {
case E_OK:
case E_REQUEST_DENIED:
case E_INVALID_FIELD:
case E_UNKNOWN_COMMAND:
break;
default:
OnError (res);
}
return (res);
}
void NCursesForm::On_Request_Denied(int c) const {
beep();
}
void NCursesForm::On_Invalid_Field(int c) const {
beep();
}
void NCursesForm::On_Unknown_Command(int c) const {
beep();
}
static const int CMD_QUIT = MAX_COMMAND + 1;
NCursesFormField*
NCursesForm::operator()(void) {
int drvCmnd;
int err;
int c;
post();
show();
refresh();
while (((drvCmnd = virtualize((c=getch()))) != CMD_QUIT)) {
switch((err=driver(drvCmnd))) {
case E_REQUEST_DENIED:
On_Request_Denied(c);
break;
case E_INVALID_FIELD:
On_Invalid_Field(c);
break;
case E_UNKNOWN_COMMAND:
On_Unknown_Command(c);
break;
case E_OK:
break;
default:
OnError(err);
}
}
unpost();
hide();
refresh();
return my_fields[::field_index (::current_field (form))];
}
// Provide a default key virtualization. Translate the keyboard
// code c into a form request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and form requests.
int
NCursesForm::virtualize(int c) {
switch(c) {
case KEY_HOME : return(REQ_FIRST_FIELD);
case KEY_END : return(REQ_LAST_FIELD);
case KEY_DOWN : return(REQ_DOWN_CHAR);
case KEY_UP : return(REQ_UP_CHAR);
case KEY_LEFT : return(REQ_PREV_CHAR);
case KEY_RIGHT : return(REQ_NEXT_CHAR);
case KEY_NPAGE : return(REQ_NEXT_PAGE);
case KEY_PPAGE : return(REQ_PREV_PAGE);
case KEY_BACKSPACE : return(REQ_DEL_PREV);
case KEY_ENTER : return(REQ_NEW_LINE);
case KEY_CLEAR : return(REQ_CLR_FIELD);
case CTRL('X') : return(CMD_QUIT); // eXit
case CTRL('F') : return(REQ_NEXT_FIELD); // Forward
case CTRL('B') : return(REQ_PREV_FIELD); // Backward
case CTRL('L') : return(REQ_LEFT_FIELD); // Left
case CTRL('R') : return(REQ_RIGHT_FIELD); // Right
case CTRL('U') : return(REQ_UP_FIELD); // Up
case CTRL('D') : return(REQ_DOWN_FIELD); // Down
case CTRL('W') : return(REQ_NEXT_WORD);
case CTRL('T') : return(REQ_PREV_WORD);
case CTRL('A') : return(REQ_BEG_FIELD);
case CTRL('E') : return(REQ_END_FIELD);
case CTRL('I') : return(REQ_INS_CHAR);
case CTRL('M') :
case CTRL('J') : return(REQ_NEW_LINE);
case CTRL('O') : return(REQ_INS_LINE);
case CTRL('V') : return(REQ_DEL_CHAR);
case CTRL('H') : return(REQ_DEL_PREV);
case CTRL('Y') : return(REQ_DEL_LINE);
case CTRL('G') : return(REQ_DEL_WORD);
case CTRL('K') : return(REQ_CLR_EOF);
case CTRL('N') : return(REQ_NEXT_CHOICE);
case CTRL('P') : return(REQ_PREV_CHOICE);
default:
return(c);
}
}
//
// -------------------------------------------------------------------------
// User Defined Fieldtypes
// -------------------------------------------------------------------------
//
bool UserDefinedFieldType::fcheck(FIELD *f, const void *u) {
NCursesFormField* F = (NCursesFormField*)u;
assert(F);
UserDefinedFieldType* udf = (UserDefinedFieldType*)(F->fieldtype());
assert(udf);
return udf->field_check(*F);
}
bool UserDefinedFieldType::ccheck(int c, const void *u) {
NCursesFormField* F = (NCursesFormField*)u;
assert(F);
UserDefinedFieldType* udf =
(UserDefinedFieldType*)(F->fieldtype());
assert(udf);
return udf->char_check(c);
}
void* UserDefinedFieldType::makearg(va_list* va) {
return va_arg(*va,NCursesFormField*);
}
FIELDTYPE* UserDefinedFieldType::generic_fieldtype =
::new_fieldtype(UserDefinedFieldType::fcheck,
UserDefinedFieldType::ccheck);
FIELDTYPE* UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice =
::new_fieldtype(UserDefinedFieldType::fcheck,
UserDefinedFieldType::ccheck);
bool UserDefinedFieldType_With_Choice::next_choice(FIELD *f, const void *u) {
NCursesFormField* F = (NCursesFormField*)u;
assert(F);
UserDefinedFieldType_With_Choice* udf =
(UserDefinedFieldType_With_Choice*)(F->fieldtype());
assert(udf);
return udf->next(*F);
}
bool UserDefinedFieldType_With_Choice::prev_choice(FIELD *f, const void *u) {
NCursesFormField* F = (NCursesFormField*)u;
assert(F);
UserDefinedFieldType_With_Choice* udf =
(UserDefinedFieldType_With_Choice*)(F->fieldtype());
assert(udf);
return udf->previous(*F);
}
class UDF_Init {
private:
int code;
static UDF_Init* I;
public:
UDF_Init() {
code = ::set_fieldtype_arg(UserDefinedFieldType::generic_fieldtype,
UserDefinedFieldType::makearg,
NULL,
NULL);
if (code==E_OK)
code = ::set_fieldtype_arg
(UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice,
UserDefinedFieldType::makearg,
NULL,
NULL);
if (code==E_OK)
code = ::set_fieldtype_choice
(UserDefinedFieldType_With_Choice::generic_fieldtype_with_choice,
UserDefinedFieldType_With_Choice::next_choice,
UserDefinedFieldType_With_Choice::prev_choice);
}
};
UDF_Init* UDF_Init::I = new UDF_Init();

View File

@ -0,0 +1,823 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: cursesf.h,v 1.10 1999/05/16 17:31:42 juergen Exp $
#ifndef _CURSESF_H
#define _CURSESF_H
#include <cursesp.h>
extern "C" {
# include <form.h>
}
//
// -------------------------------------------------------------------------
// The abstract base class for buitin and user defined Fieldtypes.
// -------------------------------------------------------------------------
//
class NCursesFormField; // forward declaration
// Class to represent builtin field types as well as C++ written new
// fieldtypes (see classes UserDefineFieldType...
class NCursesFieldType {
friend class NCursesFormField;
protected:
FIELDTYPE* fieldtype;
inline void OnError(int err) const THROWS(NCursesFormException) {
if (err!=E_OK)
THROW(new NCursesFormException (err));
}
NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
}
virtual ~NCursesFieldType() {}
// Set the fields f fieldtype to this one.
virtual void set(NCursesFormField& f) = 0;
public:
NCursesFieldType() : fieldtype((FIELDTYPE*)0) {
}
};
//
// -------------------------------------------------------------------------
// The class representing a forms field, wrapping the lowlevel FIELD struct
// -------------------------------------------------------------------------
//
class NCursesFormField {
friend class NCursesForm;
protected:
FIELD *field; // lowlevel structure
NCursesFieldType* ftype; // Associated field type
// Error handler
inline void OnError (int err) const THROWS(NCursesFormException) {
if (err != E_OK)
THROW(new NCursesFormException (err));
}
public:
// Create a 'Null' field. Can be used to delimit a field list
NCursesFormField()
: field((FIELD*)0), ftype((NCursesFieldType*)0) {
}
// Create a new field
NCursesFormField (int rows,
int cols,
int first_row = 0,
int first_col = 0,
int offscreen_rows = 0,
int additional_buffers = 0)
: ftype((NCursesFieldType*)0) {
field = ::new_field(rows,cols,first_row,first_col,
offscreen_rows, additional_buffers);
if (!field)
OnError(errno);
}
virtual ~NCursesFormField ();
// Duplicate the field at a new position
inline NCursesFormField* dup(int first_row, int first_col) {
NCursesFormField* f = new NCursesFormField();
if (!f)
OnError(E_SYSTEM_ERROR);
else {
f->ftype = ftype;
f->field = ::dup_field(field,first_row,first_col);
if (!f->field)
OnError(errno);
}
return f;
}
// Link the field to a new location
inline NCursesFormField* link(int first_row, int first_col) {
NCursesFormField* f = new NCursesFormField();
if (!f)
OnError(E_SYSTEM_ERROR);
else {
f->ftype = ftype;
f->field = ::link_field(field,first_row,first_col);
if (!f->field)
OnError(errno);
}
return f;
}
// Get the lowlevel field representation
inline FIELD* get_field() const {
return field;
}
// Retrieve info about the field
inline void info(int& rows, int& cols,
int& first_row, int& first_col,
int& offscreen_rows, int& additional_buffers) const {
OnError(::field_info(field, &rows, &cols,
&first_row, &first_col,
&offscreen_rows, &additional_buffers));
}
// Retrieve info about the fields dynamic properties.
inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
int& max_growth) const {
OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
&max_growth));
}
// For a dynamic field you may set the maximum growth limit.
// A zero means unlimited growth.
inline void set_maximum_growth(int growth = 0) {
OnError(::set_max_field(field,growth));
}
// Move the field to a new position
inline void move(int row, int col) {
OnError(::move_field(field,row,col));
}
// Mark the field to start a new page
inline void new_page(bool pageFlag = FALSE) {
OnError(::set_new_page(field,pageFlag));
}
// Retrieve whether or not the field starts a new page.
inline bool is_new_page() const {
return ::new_page(field);
}
// Set the justification for the field
inline void set_justification(int just) {
OnError(::set_field_just(field,just));
}
// Retrieve the fields justification
inline int justification() const {
return ::field_just(field);
}
// Set the foreground attribute for the field
inline void set_foreground(chtype fore) {
OnError(::set_field_fore(field,fore));
}
// Retrieve the fields foreground attribute
inline chtype fore() const {
return ::field_fore(field);
}
// Set the background attribute for the field
inline void set_background(chtype back) {
OnError(::set_field_back(field,back));
}
// Retrieve the fields background attribute
inline chtype back() const {
return ::field_back(field);
}
// Set the padding character for the field
inline void set_pad_character(int pad) {
OnError(::set_field_pad(field,pad));
}
// Retrieve the fields padding character
inline int pad() const {
return ::field_pad(field);
}
// Switch on the fields options
inline void options_on (Field_Options options) {
OnError (::field_opts_on (field, options));
}
// Switch off the fields options
inline void options_off (Field_Options options) {
OnError (::field_opts_off (field, options));
}
// Retrieve the fields options
inline Field_Options options () const {
return ::field_opts (field);
}
// Set the fields options
inline void set_options (Field_Options options) {
OnError (::set_field_opts (field, options));
}
// Mark the field as changed
inline void set_changed(bool changeFlag = TRUE) {
OnError(::set_field_status(field,changeFlag));
}
// Test whether or not the field is marked as changed
inline bool changed() const {
return ::field_status(field);
}
// Return the index of the field in the field array of a form
// or -1 if the field is not associated to a form
inline int (index)() const {
return ::field_index(field);
}
// Store a value in a fields buffer. The default buffer is nr. 0
inline void set_value(const char *val, int buffer = 0) {
OnError(::set_field_buffer(field,buffer,val));
}
// Retrieve the value of a fields buffer. The defaukt buffer is nr. 0
inline char* value(int buffer = 0) const {
return ::field_buffer(field,buffer);
}
// Set the validation type of the field.
inline void set_fieldtype(NCursesFieldType& f) {
ftype = &f;
f.set(*this); // A good friend may do that...
}
// Retrieve the validation type of the field.
inline NCursesFieldType* fieldtype() const {
return ftype;
}
};
//
// -------------------------------------------------------------------------
// The class representing a form, wrapping the lowlevel FORM struct
// -------------------------------------------------------------------------
//
class NCursesForm : public NCursesPanel {
protected:
FORM* form; // the lowlevel structure
private:
NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the form a border?
bool b_autoDelete; // Delete fields when deleting form?
NCursesFormField** my_fields; // The array of fields for this form
// This structure is used for the form's user data field to link the
// FORM* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesForm* m_back; // backward pointer to C++ object
const FORM* m_owner;
} UserHook;
// Get the backward pointer to the C++ object from a FORM
static inline NCursesForm* getHook(const FORM *f) {
UserHook* hook = (UserHook*)::form_userptr(f);
assert(hook && hook->m_owner==f);
return (NCursesForm*)(hook->m_back);
}
// This are the built-in hook functions in this C++ binding. In C++ we use
// virtual member functions (see below On_..._Init and On_..._Termination)
// to provide this functionality in an object oriented manner.
static void frm_init(FORM *);
static void frm_term(FORM *);
static void fld_init(FORM *);
static void fld_term(FORM *);
// Calculate FIELD* array for the menu
FIELD** mapFields(NCursesFormField* nfields[]);
protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = (UserHook*)::form_userptr (form);
assert (uptr && uptr->m_back==this && uptr->m_owner==form);
uptr->m_user = user;
}
inline void *get_user() {
UserHook* uptr = (UserHook*)::form_userptr (form);
assert (uptr && uptr->m_back==this && uptr->m_owner==form);
return uptr->m_user;
}
void InitForm (NCursesFormField* Fields[],
bool with_frame,
bool autoDeleteFields);
inline void OnError (int err) const THROWS(NCursesFormException) {
if (err != E_OK)
THROW(new NCursesFormException (err));
}
// this wraps the form_driver call.
virtual int driver (int c) ;
// 'Internal' constructor, builds an object without association to a
// field array.
NCursesForm( int lines,
int cols,
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(lines,cols,begin_y,begin_x),
form ((FORM*)0) {
}
public:
// Create form for the default panel.
NCursesForm (NCursesFormField* Fields[],
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel() {
InitForm(Fields, with_frame, autoDelete_Fields);
}
// Create a form in a panel with the given position and size.
NCursesForm (NCursesFormField* Fields[],
int lines,
int cols,
int begin_y,
int begin_x,
bool with_frame=FALSE, // reserve space for a frame?
bool autoDelete_Fields=FALSE) // do automatic cleanup?
: NCursesPanel(lines, cols, begin_y, begin_x) {
InitForm(Fields, with_frame, autoDelete_Fields);
}
virtual ~NCursesForm();
// Set the default attributes for the form
virtual void setDefaultAttributes();
// Retrieve current field of the form.
inline NCursesFormField* current_field() const {
return my_fields[::field_index(::current_field(form))];
}
// Set the forms subwindow
void setSubWindow(NCursesWindow& sub);
// Set these fields for the form
inline void setFields(NCursesFormField* Fields[]) {
OnError(::set_form_fields(form,mapFields(Fields)));
}
// Remove the form from the screen
inline void unpost (void) {
OnError (::unpost_form (form));
}
// Post the form to the screen if flag is true, unpost it otherwise
inline void post(bool flag = TRUE) {
OnError (flag ? ::post_form(form) : ::unpost_form (form));
}
// Decorations
inline void frame(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void label(const char *topLabel, const char *bottomLabel) {
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
OnError(E_SYSTEM_ERROR);
}
// -----
// Hooks
// -----
// Called after the form gets repositioned in its window.
// This is especially true if the form is posted.
virtual void On_Form_Init();
// Called before the form gets repositioned in its window.
// This is especially true if the form is unposted.
virtual void On_Form_Termination();
// Called after the field became the current field
virtual void On_Field_Init(NCursesFormField& field);
// Called before this field is left as current field.
virtual void On_Field_Termination(NCursesFormField& field);
// Calculate required window size for the form.
void scale(int& rows, int& cols) const {
OnError(::scale_form(form,&rows,&cols));
}
// Retrieve number of fields in the form.
int count() const {
return ::field_count(form);
}
// Make the page the current page of the form.
void set_page(int page) {
OnError(::set_form_page(form,page));
}
// Retrieve current page number
int page() const {
return ::form_page(form);
}
// Switch on the forms options
inline void options_on (Form_Options options) {
OnError (::form_opts_on (form, options));
}
// Switch off the forms options
inline void options_off (Form_Options options) {
OnError (::form_opts_off (form, options));
}
// Retrieve the forms options
inline Form_Options options () const {
return ::form_opts (form);
}
// Set the forms options
inline void set_options (Form_Options options) {
OnError (::set_form_opts (form, options));
}
// Are there more data in the current field after the data shown
inline bool data_ahead() const {
return ::data_ahead(form);
}
// Are there more data in the current field before the data shown
inline bool data_behind() const {
return ::data_behind(form);
}
// Position the cursor to the current field
inline void position_cursor () {
OnError (::pos_form_cursor (form));
}
// Set the current field
inline void set_current(NCursesFormField& F) {
OnError (::set_current_field(form, F.field));
}
// Provide a default key virtualization. Translate the keyboard
// code c into a form request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and form requests.
virtual int virtualize(int c);
// Operators
inline NCursesFormField* operator[](int i) const {
if ( (i < 0) || (i >= ::field_count (form)) )
OnError (E_BAD_ARGUMENT);
return my_fields[i];
}
// Perform the menu's operation
// Return the field where you left the form.
virtual NCursesFormField* operator()(void);
// Exception handlers. The default is a Beep.
virtual void On_Request_Denied(int c) const;
virtual void On_Invalid_Field(int c) const;
virtual void On_Unknown_Command(int c) const;
};
//
// -------------------------------------------------------------------------
// This is the typical C++ typesafe way to allow to attach
// user data to a field of a form. Its assumed that the user
// data belongs to some class T. Use T as template argument
// to create a UserField.
// -------------------------------------------------------------------------
template<class T> class NCursesUserField : public NCursesFormField
{
public:
NCursesUserField (int rows,
int cols,
int first_row = 0,
int first_col = 0,
const T* p_UserData = (T*)0,
int offscreen_rows = 0,
int additional_buffers = 0)
: NCursesFormField (rows, cols,
first_row, first_col,
offscreen_rows, additional_buffers) {
if (field)
OnError(::set_field_userptr(field,(void *)p_UserData));
}
virtual ~NCursesUserField() {};
inline const T* UserData (void) const {
return (const T*)::field_userptr (field);
}
inline virtual void setUserData(const T* p_UserData) {
if (field)
OnError (::set_field_userptr (field, (void *)p_UserData));
}
};
//
// -------------------------------------------------------------------------
// The same mechanism is used to attach user data to a form
// -------------------------------------------------------------------------
//
template<class T> class NCursesUserForm : public NCursesForm
{
protected:
// 'Internal' constructor, builds an object without association to a
// field array.
NCursesUserForm( int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0)
: NCursesForm(lines,cols,begin_y,begin_x) {
if (form)
set_user ((void *)p_UserData);
}
public:
NCursesUserForm (NCursesFormField Fields[],
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, with_frame, autoDelete_Fields) {
};
NCursesUserForm (NCursesFormField Fields[],
const T* p_UserData = (T*)0,
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, with_frame, autoDelete_Fields) {
if (form)
set_user ((void *)p_UserData);
};
NCursesUserForm (NCursesFormField Fields[],
int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0,
bool with_frame=FALSE,
bool autoDelete_Fields=FALSE)
: NCursesForm (Fields, lines, cols, begin_y, begin_x,
with_frame, autoDelete_Fields) {
if (form)
set_user ((void *)p_UserData);
};
virtual ~NCursesUserForm() {
};
inline T* UserData (void) const {
return (T*)get_user ();
};
inline virtual void setUserData (const T* p_UserData) {
if (form)
set_user ((void *)p_UserData);
}
};
//
// -------------------------------------------------------------------------
// Builtin Fieldtypes
// -------------------------------------------------------------------------
//
class Alpha_Field : public NCursesFieldType {
private:
int min_field_width;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
}
public:
Alpha_Field(int width)
: NCursesFieldType(TYPE_ALPHA),
min_field_width(width) {
}
};
class Alphanumeric_Field : public NCursesFieldType {
private:
int min_field_width;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
}
public:
Alphanumeric_Field(int width)
: NCursesFieldType(TYPE_ALNUM),
min_field_width(width) {
}
};
class Integer_Field : public NCursesFieldType {
private:
int precision;
long lower_limit, upper_limit;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit));
}
public:
Integer_Field(int prec, long low=0L, long high=0L)
: NCursesFieldType(TYPE_INTEGER),
precision(prec), lower_limit(low), upper_limit(high) {
}
};
class Numeric_Field : public NCursesFieldType {
private:
int precision;
double lower_limit, upper_limit;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
precision,lower_limit,upper_limit));
}
public:
Numeric_Field(int prec, double low=0.0, double high=0.0)
: NCursesFieldType(TYPE_NUMERIC),
precision(prec), lower_limit(low), upper_limit(high) {
}
};
class Regular_Expression_Field : public NCursesFieldType {
private:
char* regex;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,regex));
}
public:
Regular_Expression_Field(const char *expr)
: NCursesFieldType(TYPE_REGEXP) {
regex = new char[1+::strlen(expr)];
(strcpy)(regex,expr);
}
~Regular_Expression_Field() {
delete[] regex;
}
};
class Enumeration_Field : public NCursesFieldType {
private:
char** list;
int case_sensitive;
int non_unique_matches;
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,
list,case_sensitive,non_unique_matches));
}
public:
Enumeration_Field(char* enums[],
bool case_sens=FALSE,
bool non_unique=FALSE)
: NCursesFieldType(TYPE_ENUM),
list(enums),
case_sensitive(case_sens?-1:0),
non_unique_matches(non_unique?-1:0) {
}
};
class IPV4_Address_Field : public NCursesFieldType {
private:
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype));
}
public:
IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
}
};
//
// -------------------------------------------------------------------------
// Abstract base class for User-Defined Fieldtypes
// -------------------------------------------------------------------------
//
class UserDefinedFieldType : public NCursesFieldType {
friend class UDF_Init; // Internal helper to set up statics
private:
// For all C++ defined fieldtypes we need only one generic lowlevel
// FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype;
protected:
// This are the functions required by the low level libforms functions
// to construct a fieldtype.
static bool fcheck(FIELD *, const void*);
static bool ccheck(int c, const void *);
static void* makearg(va_list*);
void set(NCursesFormField& f) {
OnError(::set_field_type(f.get_field(),fieldtype,&f));
}
protected:
// Redefine this function to do a field validation. The argument
// is a reference to the field you should validate.
virtual bool field_check(NCursesFormField& f) = 0;
// Redefine this function to do a character validation. The argument
// is the character to be validated.
virtual bool char_check (int c) = 0;
public:
UserDefinedFieldType() : NCursesFieldType(generic_fieldtype) {
}
};
//
// -------------------------------------------------------------------------
// Abstract base class for User-Defined Fieldtypes with Choice functions
// -------------------------------------------------------------------------
//
class UserDefinedFieldType_With_Choice : public UserDefinedFieldType {
friend class UDF_Init; // Internal helper to set up statics
private:
// For all C++ defined fieldtypes with choice functions we need only one
// generic lowlevel FIELDTYPE* element.
static FIELDTYPE* generic_fieldtype_with_choice;
// This are the functions required by the low level libforms functions
// to construct a fieldtype with choice functions.
static bool next_choice(FIELD*, const void *);
static bool prev_choice(FIELD*, const void *);
protected:
// Redefine this function to do the retrieval of the next choice value.
// The argument is a reference to the field tobe examined.
virtual bool next (NCursesFormField& f) = 0;
// Redefine this function to do the retrieval of the previous choice value.
// The argument is a reference to the field tobe examined.
virtual bool previous(NCursesFormField& f) = 0;
public:
UserDefinedFieldType_With_Choice() {
fieldtype = generic_fieldtype_with_choice;
}
};
#endif // _CURSESF_H

View File

@ -0,0 +1,383 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
#include "cursesm.h"
#include "cursesapp.h"
#include "internal.h"
MODULE_ID("$Id: cursesm.cc,v 1.11 1999/07/31 09:45:23 juergen Exp $")
NCursesMenuItem::~NCursesMenuItem() {
if (item)
OnError(::free_item(item));
}
bool
NCursesMenuItem::action() {
return FALSE;
};
NCursesMenuCallbackItem::~NCursesMenuCallbackItem() {
}
bool
NCursesMenuCallbackItem::action() {
if (p_fct)
return p_fct (*this);
else
return FALSE;
}
/* Internal hook functions. They will route the hook
* calls to virtual methods of the NCursesMenu class,
* so in C++ providing a hook is done simply by
* implementing a virtual method in a derived class
*/
void
NCursesMenu::mnu_init(MENU *m) {
getHook(m)->On_Menu_Init();
}
void
NCursesMenu::mnu_term(MENU *m) {
getHook(m)->On_Menu_Termination();
}
void
NCursesMenu::itm_init(MENU *m) {
NCursesMenu* M = getHook(m);
M->On_Item_Init (*(M->current_item ()));
}
void
NCursesMenu::itm_term(MENU *m) {
NCursesMenu* M = getHook(m);
M->On_Item_Termination (*(M->current_item ()));
}
/* Construct an ITEM* array from an array of NCursesMenuItem
* objects.
*/
ITEM**
NCursesMenu::mapItems(NCursesMenuItem* nitems[]) {
int itemCount = 0,lcv;
for (lcv=0; nitems[lcv]->item; ++lcv)
++itemCount;
ITEM** items = new ITEM*[itemCount + 1];
for (lcv=0;nitems[lcv]->item;++lcv) {
items[lcv] = nitems[lcv]->item;
}
items[lcv] = NULL;
my_items = nitems;
if (menu)
delete[] ::menu_items(menu);
return items;
}
void
NCursesMenu::InitMenu(NCursesMenuItem* nitems[],
bool with_frame,
bool autoDelete_Items) {
int mrows, mcols;
keypad(TRUE);
meta(TRUE);
b_framed = with_frame;
b_autoDelete = autoDelete_Items;
menu = (MENU*)0;
menu = ::new_menu(mapItems(nitems));
if (!menu)
OnError (E_SYSTEM_ERROR);
UserHook* hook = new UserHook;
hook->m_user = NULL;
hook->m_back = this;
hook->m_owner = menu;
::set_menu_userptr(menu,(void*)hook);
::set_menu_init (menu, NCursesMenu::mnu_init);
::set_menu_term (menu, NCursesMenu::mnu_term);
::set_item_init (menu, NCursesMenu::itm_init);
::set_item_term (menu, NCursesMenu::itm_term);
scale(mrows, mcols);
::set_menu_win(menu, w);
if (with_frame) {
if ((mrows > height()-2) || (mcols > width()-2))
OnError(E_NO_ROOM);
sub = new NCursesWindow(*this,mrows,mcols,1,1,'r');
::set_menu_sub(menu, sub->w);
b_sub_owner = TRUE;
}
else {
sub = (NCursesWindow*)0;
b_sub_owner = FALSE;
}
setDefaultAttributes();
}
void
NCursesMenu::setDefaultAttributes() {
NCursesApplication* S = NCursesApplication::getApplication();
if (S) {
::set_menu_fore(menu, S->foregrounds());
::set_menu_back(menu, S->backgrounds());
::set_menu_grey(menu, S->inactives());
}
}
NCursesMenu::~NCursesMenu() {
UserHook* hook = (UserHook*)::menu_userptr(menu);
delete hook;
if (b_sub_owner) {
delete sub;
::set_menu_sub(menu,(WINDOW *)0);
}
if (menu) {
ITEM** itms = ::menu_items(menu);
int cnt = count();
OnError(::set_menu_items(menu,(ITEM**)0));
if (b_autoDelete) {
if (cnt>0) {
for (int i=0; i <= cnt; i++)
delete my_items[i];
}
delete[] my_items;
}
::free_menu(menu);
// It's essential to do this after free_menu()
delete[] itms;
}
}
void
NCursesMenu::setSubWindow(NCursesWindow& nsub) {
if (!isDescendant(nsub))
OnError(E_SYSTEM_ERROR);
else {
if (b_sub_owner)
delete sub;
sub = &nsub;
::set_menu_sub(menu,sub->w);
}
}
bool
NCursesMenu::set_pattern (const char *pat) {
int res = ::set_menu_pattern (menu, pat);
switch(res) {
case E_OK:
break;
case E_NO_MATCH:
return FALSE;
default:
OnError (res);
}
return TRUE;
}
// call the menu driver and do basic error checking.
int
NCursesMenu::driver (int c) {
int res = ::menu_driver (menu, c);
switch (res) {
case E_OK:
case E_REQUEST_DENIED:
case E_NOT_SELECTABLE:
case E_UNKNOWN_COMMAND:
case E_NO_MATCH:
break;
default:
OnError (res);
}
return (res);
}
static const int CMD_QUIT = MAX_COMMAND + 1;
static const int CMD_ACTION = MAX_COMMAND + 2;
//
// -------------------------------------------------------------------------
// Provide a default key virtualization. Translate the keyboard
// code c into a menu request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and menu requests.
// -------------------------------------------------------------------------
int
NCursesMenu::virtualize(int c) {
switch(c) {
case CTRL('X') : return(CMD_QUIT); // eXit
case KEY_DOWN : return(REQ_DOWN_ITEM);
case CTRL('N') : return(REQ_NEXT_ITEM); // Next
case KEY_UP : return(REQ_UP_ITEM);
case CTRL('P') : return(REQ_PREV_ITEM); // Previous
case CTRL('U') : return(REQ_SCR_ULINE); // Up
case CTRL('D') : return(REQ_SCR_DLINE); // Down
case CTRL('F') : return(REQ_SCR_DPAGE); // Forward
case CTRL('B') : return(REQ_SCR_UPAGE); // Backward
case CTRL('Y') : return(REQ_CLEAR_PATTERN);
case CTRL('H') : return(REQ_BACK_PATTERN);
case CTRL('A') : return(REQ_NEXT_MATCH);
case CTRL('E') : return(REQ_PREV_MATCH);
case CTRL('T') : return(REQ_TOGGLE_ITEM);
case CTRL('J') :
case CTRL('M') : return(CMD_ACTION);
case KEY_HOME : return(REQ_FIRST_ITEM);
case KEY_LEFT : return(REQ_LEFT_ITEM);
case KEY_RIGHT : return(REQ_RIGHT_ITEM);
case KEY_END : return(REQ_LAST_ITEM);
case KEY_BACKSPACE : return(REQ_BACK_PATTERN);
case KEY_NPAGE : return(REQ_SCR_DPAGE);
case KEY_PPAGE : return(REQ_SCR_UPAGE);
default:
return(c);
}
}
NCursesMenuItem*
NCursesMenu::operator()(void) {
int drvCmnd;
int err;
int c;
bool b_action = FALSE;
post();
show();
refresh();
while (!b_action && ((drvCmnd = virtualize((c=getch()))) != CMD_QUIT)) {
switch((err=driver(drvCmnd))) {
case E_REQUEST_DENIED:
On_Request_Denied(c);
break;
case E_NOT_SELECTABLE:
On_Not_Selectable(c);
break;
case E_UNKNOWN_COMMAND:
if (drvCmnd == CMD_ACTION) {
if (options() & O_ONEVALUE) {
NCursesMenuItem* itm = current_item();
assert(itm);
if (itm->options() & O_SELECTABLE)
{
b_action = itm->action();
refresh();
}
else
On_Not_Selectable(c);
}
else {
int n = count();
for(int i=0; i<n; i++) {
NCursesMenuItem* itm = my_items[i];
if (itm->value()) {
b_action |= itm->action();
refresh();
}
}
}
} else
On_Unknown_Command(c);
break;
case E_NO_MATCH:
On_No_Match(c);
break;
case E_OK:
break;
default:
OnError(err);
}
}
unpost();
hide();
refresh();
if (options() & O_ONEVALUE)
return my_items[::item_index (::current_item (menu))];
else
return NULL;
}
void
NCursesMenu::On_Menu_Init() {
}
void
NCursesMenu::On_Menu_Termination() {
}
void
NCursesMenu::On_Item_Init(NCursesMenuItem& item) {
}
void
NCursesMenu::On_Item_Termination(NCursesMenuItem& item) {
}
void
NCursesMenu::On_Request_Denied(int c) const {
beep();
}
void
NCursesMenu::On_Not_Selectable(int c) const {
beep();
}
void
NCursesMenu::On_No_Match(int c) const {
beep();
}
void
NCursesMenu::On_Unknown_Command(int c) const {
beep();
}

View File

@ -0,0 +1,592 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: cursesm.h,v 1.12 1999/05/16 17:30:27 juergen Exp $
#ifndef _CURSESM_H
#define _CURSESM_H
#include <cursesp.h>
extern "C" {
# include <menu.h>
}
//
// -------------------------------------------------------------------------
// This wraps the ITEM type of <menu.h>
// -------------------------------------------------------------------------
//
class NCursesMenuItem {
friend class NCursesMenu;
protected:
ITEM *item;
inline void OnError (int err) const THROWS(NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (err));
}
public:
NCursesMenuItem (const char* p_name = NULL,
const char* p_descript = NULL ) {
item = p_name ? ::new_item (p_name, p_descript) : (ITEM*)0;
if (p_name && !item)
OnError (E_SYSTEM_ERROR);
}
// Create an item. If you pass both parameters as NULL, a delimiting
// item is constructed which can be used to terminate a list of
// NCursesMenu objects.
virtual ~NCursesMenuItem ();
// Release the items memory
inline const char* name () const {
return ::item_name (item);
}
// Name of the item
inline const char* description () const {
return ::item_description (item);
}
// Description of the item
inline int (index) (void) const {
return ::item_index (item);
}
// Index of the item in an item array (or -1)
inline void options_on (Item_Options options) {
OnError (::item_opts_on (item, options));
}
// Switch on the items options
inline void options_off (Item_Options options) {
OnError (::item_opts_off (item, options));
}
// Switch off the item's option
inline Item_Options options () const {
return ::item_opts (item);
}
// Retrieve the items options
inline void set_options (Item_Options options) {
OnError (::set_item_opts (item, options));
}
// Set the items options
inline void set_value (bool f) {
OnError (::set_item_value (item,f));
}
// Set/Reset the items selection state
inline bool value () const {
return ::item_value (item);
}
// Retrieve the items selection state
inline bool visible () const {
return ::item_visible (item);
}
// Retrieve visibility of the item
virtual bool action();
// Perform an action associated with this item; you may use this in an
// user supplied driver for a menu; you may derive from this class and
// overload action() to supply items with different actions.
// If an action returns true, the menu will be exited. The default action
// is to do nothing.
};
// Prototype for an items callback function.
typedef bool ITEMCALLBACK(NCursesMenuItem&);
// If you don't like to create a child class for individual items to
// overload action(), you may use this class and provide a callback
// function pointer for items.
class NCursesMenuCallbackItem : public NCursesMenuItem {
private:
const ITEMCALLBACK* p_fct;
public:
NCursesMenuCallbackItem(const ITEMCALLBACK* fct = NULL,
const char* p_name = NULL,
const char* p_descript = NULL )
: NCursesMenuItem (p_name, p_descript),
p_fct (fct) {
}
virtual ~NCursesMenuCallbackItem();
bool action();
};
//
// -------------------------------------------------------------------------
// This wraps the MENU type of <menu.h>
// -------------------------------------------------------------------------
//
class NCursesMenu : public NCursesPanel {
protected:
MENU *menu;
private:
NCursesWindow* sub; // the subwindow object
bool b_sub_owner; // is this our own subwindow?
bool b_framed; // has the menu a border?
bool b_autoDelete; // Delete items when deleting menu?
NCursesMenuItem** my_items; // The array of items for this menu
// This structure is used for the menu's user data field to link the
// MENU* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesMenu* m_back; // backward pointer to C++ object
const MENU* m_owner;
} UserHook;
// Get the backward pointer to the C++ object from a MENU
static inline NCursesMenu* getHook(const MENU *m) {
UserHook* hook = (UserHook*)::menu_userptr(m);
assert(hook && hook->m_owner==m);
return (NCursesMenu*)(hook->m_back);
}
// This are the built-in hook functions in this C++ binding. In C++ we use
// virtual member functions (see below On_..._Init and On_..._Termination)
// to provide this functionality in an object oriented manner.
static void mnu_init(MENU *);
static void mnu_term(MENU *);
static void itm_init(MENU *);
static void itm_term(MENU *);
// Calculate ITEM* array for the menu
ITEM** mapItems(NCursesMenuItem* nitems[]);
protected:
// internal routines
inline void set_user(void *user) {
UserHook* uptr = (UserHook*)::menu_userptr (menu);
assert (uptr && uptr->m_back==this && uptr->m_owner==menu);
uptr->m_user = user;
}
inline void *get_user() {
UserHook* uptr = (UserHook*)::menu_userptr (menu);
assert (uptr && uptr->m_back==this && uptr->m_owner==menu);
return uptr->m_user;
}
void InitMenu (NCursesMenuItem* menu[],
bool with_frame,
bool autoDeleteItems);
inline void OnError (int err) const THROWS(NCursesMenuException) {
if (err != E_OK)
THROW(new NCursesMenuException (this, err));
}
// this wraps the menu_driver call.
virtual int driver (int c) ;
// 'Internal' constructor to create a menu without association to
// an array of items.
NCursesMenu( int lines,
int cols,
int begin_y = 0,
int begin_x = 0)
: NCursesPanel(lines,cols,begin_y,begin_x),
menu ((MENU*)0) {
}
public:
// Make a full window size menu
NCursesMenu (NCursesMenuItem* Items[],
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel() {
InitMenu(Items, with_frame, autoDelete_Items);
}
// Make a menu with a window of this size.
NCursesMenu (NCursesMenuItem* Items[],
int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
bool with_frame=FALSE, // Reserve space for a frame?
bool autoDelete_Items=FALSE) // Autocleanup of Items?
: NCursesPanel(lines, cols, begin_y, begin_x) {
InitMenu(Items, with_frame, autoDelete_Items);
}
virtual ~NCursesMenu ();
// Retrieve the menus subwindow
inline NCursesWindow& subWindow() const {
assert(sub!=NULL);
return *sub;
}
// Set the menus subwindow
void setSubWindow(NCursesWindow& sub);
// Set these items for the menu
inline void setItems(NCursesMenuItem* Items[]) {
OnError(::set_menu_items(menu,mapItems(Items)));
}
// Remove the menu from the screen
inline void unpost (void) {
OnError (::unpost_menu (menu));
}
// Post the menu to the screen if flag is true, unpost it otherwise
inline void post(bool flag = TRUE) {
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
}
// Get the numer of rows and columns for this menu
inline void scale (int& mrows, int& mcols) const {
OnError (::scale_menu (menu, &mrows, &mcols));
}
// Set the format of this menu
inline void set_format(int mrows, int mcols) {
OnError (::set_menu_format(menu, mrows, mcols));
}
// Get the format of this menu
inline void menu_format(int& rows,int& cols) {
::menu_format(menu,&rows,&cols);
}
// Items of the menu
inline NCursesMenuItem* items() const {
return *my_items;
}
// Get the number of items in this menu
inline int count() const {
return ::item_count(menu);
}
// Get the current item (i.e. the one the cursor is located)
inline NCursesMenuItem* current_item() const {
return my_items[::item_index(::current_item(menu))];
}
// Get the marker string
inline const char* mark() const {
return ::menu_mark(menu);
}
// Set the marker string
inline void set_mark(const char *mark) {
OnError (::set_menu_mark (menu, mark));
}
// Get the name of the request code c
inline static const char* request_name(int c) {
return ::menu_request_name(c);
}
// Get the current pattern
inline char* pattern() const {
return ::menu_pattern(menu);
}
// true if there is a pattern match, false otherwise.
bool set_pattern (const char *pat);
// set the default attributes for the menu
// i.e. set fore, back and grey attribute
virtual void setDefaultAttributes();
// Get the menus background attributes
inline chtype back() const {
return ::menu_back(menu);
}
// Get the menus foreground attributes
inline chtype fore() const {
return ::menu_fore(menu);
}
// Get the menus grey attributes (used for unselectable items)
inline chtype grey() const {
return ::menu_grey(menu);
}
// Set the menus background attributes
inline chtype set_background(chtype a) {
return ::set_menu_back(menu,a);
}
// Set the menus foreground attributes
inline chtype set_foreground(chtype a) {
return ::set_menu_fore(menu,a);
}
// Set the menus grey attributes (used for unselectable items)
inline chtype set_grey(chtype a) {
return ::set_menu_grey(menu,a);
}
inline void options_on (Menu_Options opts) {
OnError (::menu_opts_on (menu,opts));
}
inline void options_off(Menu_Options opts) {
OnError (::menu_opts_off(menu,opts));
}
inline Menu_Options options() const {
return ::menu_opts(menu);
}
inline void set_options (Menu_Options opts) {
OnError (::set_menu_opts (menu,opts));
}
inline int pad() const {
return ::menu_pad(menu);
}
inline void set_pad (int padch) {
OnError (::set_menu_pad (menu, padch));
}
// Position the cursor to the current item
inline void position_cursor () const {
OnError (::pos_menu_cursor (menu));
}
// Set the current item
inline void set_current(NCursesMenuItem& I) {
OnError (::set_current_item(menu, I.item));
}
// Get the current top row of the menu
inline int top_row (void) const {
return ::top_row (menu);
}
// Set the current top row of the menu
inline void set_top_row (int row) {
OnError (::set_top_row (menu, row));
}
// spacing control
// Set the spacing for the menu
inline void setSpacing(int spc_description,
int spc_rows,
int spc_columns) {
OnError(::set_menu_spacing(menu,
spc_description,
spc_rows,
spc_columns));
}
// Get the spacing info for the menu
inline void Spacing(int& spc_description,
int& spc_rows,
int& spc_columns) const {
OnError(::menu_spacing(menu,
&spc_description,
&spc_rows,
&spc_columns));
}
// Decorations
inline void frame(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::frame(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void boldframe(const char *title=NULL, const char* btitle=NULL) {
if (b_framed)
NCursesPanel::boldframe(title,btitle);
else
OnError(E_SYSTEM_ERROR);
}
inline void label(const char *topLabel, const char *bottomLabel) {
if (b_framed)
NCursesPanel::label(topLabel,bottomLabel);
else
OnError(E_SYSTEM_ERROR);
}
// -----
// Hooks
// -----
// Called after the menu gets repositioned in its window.
// This is especially true if the menu is posted.
virtual void On_Menu_Init();
// Called before the menu gets repositioned in its window.
// This is especially true if the menu is unposted.
virtual void On_Menu_Termination();
// Called after the item became the current item
virtual void On_Item_Init(NCursesMenuItem& item);
// Called before this item is left as current item.
virtual void On_Item_Termination(NCursesMenuItem& item);
// Provide a default key virtualization. Translate the keyboard
// code c into a menu request code.
// The default implementation provides a hopefully straightforward
// mapping for the most common keystrokes and menu requests.
virtual int virtualize(int c);
// Operators
inline NCursesMenuItem* operator[](int i) const {
if ( (i < 0) || (i >= ::item_count (menu)) )
OnError (E_BAD_ARGUMENT);
return (my_items[i]);
}
// Perform the menu's operation
// Return the item where you left the selection mark for a single
// selection menu, or NULL for a multivalued menu.
virtual NCursesMenuItem* operator()(void);
// --------------------
// Exception handlers
// Called by operator()
// --------------------
// Called if the request is denied
virtual void On_Request_Denied(int c) const;
// Called if the item is not selectable
virtual void On_Not_Selectable(int c) const;
// Called if pattern doesn't match
virtual void On_No_Match(int c) const;
// Called if the command is unknown
virtual void On_Unknown_Command(int c) const;
};
//
// -------------------------------------------------------------------------
// This is the typical C++ typesafe way to allow to attach
// user data to an item of a menu. Its assumed that the user
// data belongs to some class T. Use T as template argument
// to create a UserItem.
// -------------------------------------------------------------------------
//
template<class T> class NCursesUserItem : public NCursesMenuItem
{
public:
NCursesUserItem (const char* p_name,
const char* p_descript = NULL,
const T* p_UserData = (T*)0)
: NCursesMenuItem (p_name, p_descript) {
if (item)
OnError (::set_item_userptr (item, (void *)p_UserData));
};
virtual ~NCursesUserItem() {};
inline const T* UserData (void) const {
return (const T*)::item_userptr (item);
};
inline virtual void setUserData(const T* p_UserData) {
if (item)
OnError (::set_item_userptr (item, (void *)p_UserData));
}
};
//
// -------------------------------------------------------------------------
// The same mechanism is used to attach user data to a menu
// -------------------------------------------------------------------------
//
template<class T> class NCursesUserMenu : public NCursesMenu
{
protected:
NCursesUserMenu( int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0)
: NCursesMenu(lines,cols,begin_y,begin_x) {
if (menu)
set_user ((void *)p_UserData);
}
public:
NCursesUserMenu (NCursesMenuItem Items[],
const T* p_UserData = (T*)0,
bool with_frame=FALSE,
bool autoDelete_Items=FALSE)
: NCursesMenu (Items, with_frame, autoDelete_Items) {
if (menu)
set_user ((void *)p_UserData);
};
NCursesUserMenu (NCursesMenuItem Items[],
int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0,
bool with_frame=FALSE)
: NCursesMenu (Items, lines, cols, begin_y, begin_x, with_frame) {
if (menu)
set_user ((void *)p_UserData);
};
virtual ~NCursesUserMenu() {
};
inline T* UserData (void) const {
return (T*)get_user ();
};
inline virtual void setUserData (const T* p_UserData) {
if (menu)
set_user ((void *)p_UserData);
}
};
#endif // _CURSESM_H

View File

@ -0,0 +1,51 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
#include "cursesapp.h"
#include "internal.h"
MODULE_ID("$Id: cursesmain.cc,v 1.5 1999/05/16 17:31:22 juergen Exp $")
/* This is the default implementation of main() for a NCursesApplication.
* You only have to instantiate a static NCursesApplication object in your
* main application source file and link this module with your application.
*/
int main(int argc, char* argv[])
{
NCursesApplication* A = NCursesApplication::getApplication();
if (!A)
return(1);
A->handleArgs(argc,argv);
::endwin();
return((*A)());
}

View File

@ -0,0 +1,123 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1993,1997 *
****************************************************************************/
#include "cursesp.h"
#include "internal.h"
MODULE_ID("$Id: cursesp.cc,v 1.14 1999/05/16 17:30:51 juergen Exp $")
NCursesPanel* NCursesPanel::dummy = (NCursesPanel*)0;
void NCursesPanel::init() {
p = ::new_panel(w);
if (!p)
OnError(ERR);
UserHook* hook = new UserHook;
hook->m_user = NULL;
hook->m_back = this;
hook->m_owner = p;
::set_panel_userptr(p, (void *)hook);
}
NCursesPanel::~NCursesPanel() {
UserHook* hook = (UserHook*)::panel_userptr(p);
assert(hook && hook->m_back==this && hook->m_owner==p);
delete hook;
::del_panel(p);
::update_panels();
}
void
NCursesPanel::redraw() {
PANEL *pan;
pan = ::panel_above(NULL);
while (pan) {
::touchwin(panel_window(pan));
pan = ::panel_above(pan);
}
::update_panels();
::doupdate();
}
int
NCursesPanel::refresh() {
::update_panels();
return doupdate();
}
int
NCursesPanel::noutrefresh() {
::update_panels();
return OK;
}
void
NCursesPanel::boldframe(const char *title, const char* btitle) {
standout();
frame(title, btitle);
standend();
}
void
NCursesPanel::frame(const char *title,const char *btitle) {
int err = OK;
if (!title && !btitle) {
err = box();
}
else {
err = box();
if (err==OK)
label(title,btitle);
}
OnError(err);
}
void
NCursesPanel::label(const char *tLabel, const char *bLabel) {
if (tLabel)
centertext(0,tLabel);
if (bLabel)
centertext(maxy(),bLabel);
}
void
NCursesPanel::centertext(int row,const char *label) {
if (label) {
int x = (maxx() - strlen(label)) / 2;
if (x<0)
x=0;
OnError(addstr(row, x, label, width()));
}
}

View File

@ -0,0 +1,186 @@
// * This makes emacs happy -*-Mode: C++;-*-
#ifndef _CURSESP_H
#define _CURSESP_H
// $Id: cursesp.h,v 1.11 1999/07/31 09:46:05 juergen Exp $
#include <cursesw.h>
extern "C" {
# include <panel.h>
}
class NCursesPanel : public NCursesWindow {
protected:
PANEL *p;
static NCursesPanel *dummy;
private:
// This structure is used for the panel's user data field to link the
// PANEL* to the C++ object and to provide extra space for a user pointer.
typedef struct {
void* m_user; // the pointer for the user's data
const NCursesPanel* m_back; // backward pointer to C++ object
const PANEL* m_owner; // the panel itself
} UserHook;
void init(); // Initialize the panel object
protected:
void set_user(void *user) {
UserHook* uptr = (UserHook*)::panel_userptr (p);
assert (uptr && uptr->m_back==this && uptr->m_owner==p);
uptr->m_user = user;
}
// Set the user pointer of the panel.
void *get_user() {
UserHook* uptr = (UserHook*)::panel_userptr (p);
assert (uptr && uptr->m_back==this && uptr->m_owner==p);
return uptr->m_user;
}
void OnError (int err) const THROWS((NCursesPanelException)) {
if (err==ERR)
THROW(new NCursesPanelException (this, err));
}
// If err is equal to the curses error indicator ERR, an error handler
// is called.
public:
NCursesPanel(int lines,
int cols,
int begin_y = 0,
int begin_x = 0)
: NCursesWindow(lines,cols,begin_y,begin_x) {
init();
}
// Create a panel with this size starting at the requested position.
NCursesPanel() : NCursesWindow(::stdscr) { init(); }
// This constructor creates the default Panel associated with the
// ::stdscr window
virtual ~NCursesPanel();
// basic manipulation
inline void hide() {
OnError (::hide_panel(p));
}
// Hide the panel. It stays in the stack but becomes invisible.
inline void show() {
OnError (::show_panel(p));
}
// Show the panel, i.e. make it visible.
inline void top() {
OnError (::top_panel(p));
}
// Make this panel the top panel in the stack.
inline void bottom() {
OnError (::bottom_panel(p));
}
// Make this panel the bottom panel in the stack.
// N.B.: The panel associated with ::stdscr is always on the bottom. So
// actually bottom() makes the panel the first above ::stdscr.
virtual int mvwin(int y, int x) {
OnError(::move_panel(p, y, x));
return OK;
}
inline bool hidden() const {
return (::panel_hidden (p) ? TRUE : FALSE);
}
// Return TRUE if the panel is hidden, FALSE otherwise.
/* The functions panel_above() and panel_below() are not reflected in
the NCursesPanel class. The reason for this is, that we cannot
assume that a panel retrieved by those operations is one wrapped
by a C++ class. Although this situation might be handled, we also
need a reverse mapping from PANEL to NCursesPanel which needs some
redesign of the low level stuff. At the moment, we define them in the
interface but they will always produce an error. */
inline NCursesPanel& above() const {
OnError(ERR);
return *dummy;
}
inline NCursesPanel& below() const {
OnError(ERR);
return *dummy;
}
// Those two are rewrites of the corresponding virtual members of
// NCursesWindow
virtual int refresh();
// Propagate all panel changes to the virtual screen and update the
// physical screen.
virtual int noutrefresh();
// Propagate all panel changes to the virtual screen.
static void redraw();
// Redraw all panels.
// decorations
virtual void frame(const char* title=NULL,
const char* btitle=NULL);
// Put a frame around the panel and put the title centered in the top line
// and btitle in the bottom line.
virtual void boldframe(const char* title=NULL,
const char* btitle=NULL);
// Same as frame(), but use highlighted attributes.
virtual void label(const char* topLabel,
const char* bottomLabel);
// Put the title centered in the top line and btitle in the bottom line.
virtual void centertext(int row,const char* label);
// Put the label text centered in the specified row.
};
/* We use templates to provide a typesafe mechanism to associate
* user data with a panel. A NCursesUserPanel<T> is a panel
* associated with some user data of type T.
*/
template<class T> class NCursesUserPanel : public NCursesPanel
{
public:
NCursesUserPanel (int lines,
int cols,
int begin_y = 0,
int begin_x = 0,
const T* p_UserData = (T*)0)
: NCursesPanel (lines, cols, begin_y, begin_x) {
if (p)
set_user ((void *)p_UserData);
};
// This creates an user panel of the requested size with associated
// user data pointed to by p_UserData.
NCursesUserPanel(const T* p_UserData = (T*)0) : NCursesPanel() {
if (p)
set_user((void *)p_UserData);
};
// This creates an user panel associated with the ::stdscr and user data
// pointed to by p_UserData.
virtual ~NCursesUserPanel() {};
T* UserData (void) const {
return (T*)get_user ();
};
// Retrieve the user data associated with the panel.
virtual void setUserData (const T* p_UserData) {
if (p)
set_user ((void *)p_UserData);
}
// Associate the user panel with the user data pointed to by p_UserData.
};
#endif // _CURSESP_H

View File

@ -0,0 +1,270 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1999 *
****************************************************************************/
#include "etip.h"
#include "cursesw.h"
#include "internal.h"
MODULE_ID("$Id: cursespad.cc,v 1.1 1999/07/31 09:47:21 juergen Exp $")
NCursesPad::NCursesPad(int lines, int cols)
: NCursesWindow(),
viewWin((NCursesWindow*)0),
viewSub((NCursesWindow*)0),
h_gridsize(0), v_gridsize(0),
min_row(0), min_col(0)
{
w = ::newpad(lines,cols);
if ((WINDOW*)0==w) {
count--;
err_handler("Cannot construct window");
}
alloced = TRUE;
}
int NCursesPad::driver (int key) {
// Default implementation
switch(key) {
case KEY_UP:
// =======
return REQ_PAD_UP;
case KEY_DOWN:
// =========
return REQ_PAD_DOWN;
case KEY_LEFT:
// =========
return REQ_PAD_LEFT;
case KEY_RIGHT:
// ==========
return REQ_PAD_RIGHT;
case KEY_EXIT:
// =========
case CTRL('X'):
// ==========
return REQ_PAD_EXIT;
default: return(key);
}
}
void NCursesPad::operator()(void) {
NCursesWindow* W = Win();
if ((NCursesWindow*)0 != W) {
int Width = W->width();
int Height = W->height();
int req = REQ_PAD_REFRESH;
W->keypad(TRUE);
W->meta(TRUE);
refresh();
do {
bool changed = FALSE;
switch (req) {
case REQ_PAD_REFRESH:
// ================
changed = TRUE;
break;
case REQ_PAD_LEFT:
// =============
if (min_col > 0) {
changed = TRUE;
if (min_col < h_gridsize)
min_col = 0;
else
min_col -= h_gridsize;
}
else
OnNavigationError(req);
break;
case REQ_PAD_RIGHT:
// ==============
if (min_col < (width() - Width - 1)) {
changed = TRUE;
if (min_col > (width() - Width - h_gridsize - 1))
min_col = width() - Width - 1;
else
min_col += h_gridsize;
}
else
OnNavigationError(req);
break;
case REQ_PAD_UP:
// ===========
if (min_row > 0) {
changed = TRUE;
if (min_row < v_gridsize)
min_row = 0;
else
min_row -= v_gridsize;
}
else
OnNavigationError(req);
break;
case REQ_PAD_DOWN:
// =============
if (min_row < (height() - Height - 1)) {
changed = TRUE;
if (min_row > (height() - Height - v_gridsize - 1))
min_row = height() - Height - 1;
else
min_row += v_gridsize;
}
else
OnNavigationError(req);
break;
default:
OnUnknownOperation(req);
}
if (changed) {
noutrefresh();
W->syncup();
OnOperation(req);
viewWin->refresh();
}
} while( (req=driver(W->getch())) != REQ_PAD_EXIT );
}
}
int NCursesPad::refresh() {
int res = noutrefresh();
if (res==OK && ((NCursesWindow*)0 != viewWin)) {
res = (viewWin->refresh());
}
return(res);
}
int NCursesPad::noutrefresh() {
int res = OK;
NCursesWindow* W = Win();
if ((NCursesWindow*)0 != W) {
res = copywin(*W,min_row,min_col,
0,0,W->maxy(),W->maxx(),
FALSE);
if (res==OK) {
W->syncup();
res = viewWin->noutrefresh();
}
}
return (res);
}
void NCursesPad::setWindow(NCursesWindow& view,
int v_grid = 1,
int h_grid = 1)
{
viewWin = &view;
min_row = min_col = 0;
if (h_grid <=0 || v_grid <= 0)
err_handler("Illegal Gridsize");
else {
h_gridsize = h_grid;
v_gridsize = v_grid;
}
}
void NCursesPad::setSubWindow(NCursesWindow& sub)
{
if ((NCursesWindow*)0 == viewWin)
err_handler("Pad has no viewport");
if (!viewWin->isDescendant(sub))
THROW(new NCursesException("NCursesFramePad", E_SYSTEM_ERROR));
viewSub = &sub;
}
void NCursesFramedPad::OnOperation(int pad_req) {
NCursesWindow* W = Win();
NCursesWindow* Win = getWindow();
if (((NCursesWindow*)0 != W) && ((NCursesWindow*)0 != Win)) {
int Width = W->width();
int Height = W->height();
int i, row, col, h_len, v_len;
h_len = (Width*Width + width() - 1)/width();
if (h_len==0)
h_len = 1;
if (h_len > Width)
h_len = Width;
v_len = (Height*Height + height() - 1)/height();
if (v_len==0)
v_len = 1;
if (v_len > Height)
v_len = Height;
col = (min_col * Width + width() - 1) / width();
if (col + h_len > Width)
col = Width - h_len;
row = (min_row * Height + height() - 1) / height();
if (row + v_len > Height)
row = Height - v_len;
Win->vline(1,Width+1,Height);
Win->attron(A_REVERSE);
if (v_len>=2) {
Win->addch(row+1,Width+1,ACS_UARROW);
for(i=2;i<v_len;i++)
Win->addch(row+i,Width+1,' ');
Win->addch(row+v_len,Width+1,ACS_DARROW);
}
else {
for(i=1;i<=v_len;i++)
Win->addch(row+i,Width+1,' ');
}
Win->attroff(A_REVERSE);
Win->hline(Height+1,1,Width);
Win->attron(A_REVERSE);
if (h_len >= 2) {
Win->addch(Height+1,col+1,ACS_LARROW);
for(i=2;i<h_len;i++)
Win->addch(Height+1,col+i,' ');
Win->addch(Height+1,col+h_len,ACS_RARROW);
}
else {
for(i=1;i<=h_len;i++)
Win->addch(Height+1,col+i,' ');
}
Win->attroff(A_REVERSE);
}
}

View File

@ -0,0 +1,431 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/*
Copyright (C) 1989 Free Software Foundation
written by Eric Newton (newton@rocky.oswego.edu)
This file is part of the GNU C++ Library. This library is free
software; you can redistribute it and/or modify it under the terms of
the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your
option) any later version. This library is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
modified by Ulrich Drepper (drepper@karlsruhe.gmd.de)
and Anatoly Ivasyuk (anatoly@nick.csh.rit.edu)
modified by Juergen Pfeifer (juergen.pfeifer@gmx.net)
*/
#include "cursesw.h"
#include "internal.h"
MODULE_ID("$Id: cursesw.cc,v 1.13 1999/07/31 09:46:30 juergen Exp $")
#define COLORS_NEED_INITIALIZATION -1
#define COLORS_NOT_INITIALIZED 0
#define COLORS_MONOCHROME 1
#define COLORS_ARE_REALLY_THERE 2
// declare static variables for the class
long NCursesWindow::count = 0L;
bool NCursesWindow::b_initialized = FALSE;
#if defined(__GNUG__)
# ifndef _IO_va_list
# define _IO_va_list char *
# endif
#endif
int
NCursesWindow::scanw(const char* fmt, ...)
{
#if defined(__GNUG__)
va_list args;
va_start(args, fmt);
char buf[BUFSIZ];
int result = wgetstr(w, buf);
if (result == OK) {
strstreambuf ss(buf, BUFSIZ);
result = ss.vscan(fmt, (_IO_va_list)args);
}
va_end(args);
return result;
#else
return ERR;
#endif
}
int
NCursesWindow::scanw(int y, int x, const char* fmt, ...)
{
#if defined(__GNUG__)
va_list args;
va_start(args, fmt);
char buf[BUFSIZ];
int result = wmove(w, y, x);
if (result == OK) {
result = wgetstr(w, buf);
if (result == OK) {
strstreambuf ss(buf, BUFSIZ);
result = ss.vscan(fmt, (_IO_va_list)args);
}
}
va_end(args);
return result;
#else
return ERR;
#endif
}
int
NCursesWindow::printw(const char * fmt, ...)
{
va_list args;
va_start(args, fmt);
char buf[BUFSIZ];
vsprintf(buf, fmt, args);
va_end(args);
return waddstr(w, buf);
}
int
NCursesWindow::printw(int y, int x, const char * fmt, ...)
{
va_list args;
va_start(args, fmt);
int result = wmove(w, y, x);
if (result == OK) {
char buf[BUFSIZ];
vsprintf(buf, fmt, args);
result = waddstr(w, buf);
}
va_end(args);
return result;
}
void
NCursesWindow::init(void)
{
leaveok(0);
keypad(1);
meta(1);
}
void
NCursesWindow::err_handler(const char *msg) const THROWS(NCursesException)
{
THROW(new NCursesException(msg));
}
void
NCursesWindow::initialize() {
if (!b_initialized) {
::initscr();
b_initialized = TRUE;
if (colorInitialized==COLORS_NEED_INITIALIZATION) {
colorInitialized=COLORS_NOT_INITIALIZED;
useColors();
}
::noecho();
::cbreak();
}
}
NCursesWindow::NCursesWindow() {
if (!b_initialized)
initialize();
w = (WINDOW *)0;
init();
alloced = FALSE;
subwins = par = sib = 0;
count++;
}
NCursesWindow::NCursesWindow(int lines, int cols, int begin_y, int begin_x)
{
if (!b_initialized)
initialize();
w = ::newwin(lines, cols, begin_y, begin_x);
if (w == 0) {
err_handler("Cannot construct window");
}
init();
alloced = TRUE;
subwins = par = sib = 0;
count++;
}
NCursesWindow::NCursesWindow(WINDOW* &window)
{
if (!b_initialized)
initialize();
w = window;
init();
alloced = FALSE;
subwins = par = sib = 0;
count++;
}
NCursesWindow::NCursesWindow(NCursesWindow& win, int l, int c,
int begin_y, int begin_x, char absrel)
{
if (absrel == 'a') { // absolute origin
begin_y -= win.begy();
begin_x -= win.begx();
}
// Even though we treat subwindows as a tree, the standard curses
// library needs the `subwin' call to link to the parent in
// order to correctly perform refreshes, etc.
// Friendly enough, this also works for pads.
w = ::derwin(win.w, l, c, begin_y, begin_x);
if (w == 0) {
err_handler("Cannot construct subwindow");
}
par = &win;
sib = win.subwins;
win.subwins = this;
subwins = 0;
alloced = TRUE;
count++;
}
NCursesWindow::NCursesWindow(NCursesWindow& win, bool do_box = TRUE)
{
w = :: derwin(win.w,win.height()-2,win.width()-2,1,1);
if (w == 0) {
err_handler("Cannot construct subwindow");
}
par = &win;
sib = win.subwins;
win.subwins = this;
subwins = 0;
alloced = TRUE;
count++;
if (do_box) {
win.box();
win.touchwin();
}
}
NCursesWindow NCursesWindow::Clone() {
WINDOW *d = ::dupwin(w);
NCursesWindow W(d);
W.subwins = subwins;
W.sib = sib;
W.par = par;
W.alloced = alloced;
return W;
}
typedef int (*RIPOFFINIT)(NCursesWindow&);
static RIPOFFINIT R_INIT[5]; // There can't be more
static int r_init_idx = 0;
static RIPOFFINIT* prip = R_INIT;
extern "C" int _nc_ripoffline(int,int (*init)(WINDOW*,int));
NCursesWindow::NCursesWindow(WINDOW *win, int cols) {
w = win;
assert((w->_maxx+1)==cols);
alloced = FALSE;
subwins = par = sib = 0;
}
int NCursesWindow::ripoff_init(WINDOW *w, int cols)
{
int res = ERR;
RIPOFFINIT init = *prip++;
if (init) {
NCursesWindow* W = new NCursesWindow(w,cols);
res = init(*W);
}
return res;
}
int NCursesWindow::ripoffline(int ripoff_lines,
int (*init)(NCursesWindow& win)) {
int code = ::_nc_ripoffline(ripoff_lines,ripoff_init);
if (code==OK && init && ripoff_lines) {
R_INIT[r_init_idx++] = init;
}
return code;
}
bool
NCursesWindow::isDescendant(NCursesWindow& win) {
for (NCursesWindow* p = subwins; p != NULL; p = p->sib) {
if (p==&win)
return TRUE;
else {
if (p->isDescendant(win))
return TRUE;
}
}
return FALSE;
}
void
NCursesWindow::kill_subwindows()
{
for (NCursesWindow* p = subwins; p != 0; p = p->sib) {
p->kill_subwindows();
if (p->alloced) {
if (p->w != 0)
::delwin(p->w);
p->alloced = FALSE;
}
p->w = 0; // cause a run-time error if anyone attempts to use...
}
}
NCursesWindow::~NCursesWindow()
{
kill_subwindows();
if (par != 0) { // Snip us from the parent's list of subwindows.
NCursesWindow * win = par->subwins;
NCursesWindow * trail = 0;
for (;;) {
if (win == 0)
break;
else if (win == this) {
if (trail != 0)
trail->sib = win->sib;
else
par->subwins = win->sib;
break;
} else {
trail = win;
win = win->sib;
}
}
}
if (alloced && w != 0)
delwin(w);
if (alloced) {
--count;
if (count == 0) {
::endwin();
}
else if (count < 0) { // cannot happen!
err_handler("Too many windows destroyed");
}
}
}
// ---------------------------------------------------------------------
// Color stuff
//
int NCursesWindow::colorInitialized = COLORS_NOT_INITIALIZED;
void
NCursesWindow::useColors(void)
{
if (colorInitialized == COLORS_NOT_INITIALIZED) {
if (b_initialized) {
if (::has_colors()) {
::start_color();
colorInitialized = COLORS_ARE_REALLY_THERE;
}
else
colorInitialized = COLORS_MONOCHROME;
}
else
colorInitialized = COLORS_NEED_INITIALIZATION;
}
}
short
NCursesWindow::getcolor(int getback) const
{
short fore, back;
if (colorInitialized==COLORS_ARE_REALLY_THERE) {
if (pair_content(PAIR_NUMBER(w->_attrs), &fore, &back))
err_handler("Can't get color pair");
}
else {
// Monochrome means white on black
back = COLOR_BLACK;
fore = COLOR_WHITE;
}
return getback ? back : fore;
}
int NCursesWindow::NumberOfColors()
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
return COLORS;
else
return 1; // monochrome (actually there are two ;-)
}
short
NCursesWindow::getcolor() const
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
return PAIR_NUMBER(w->_attrs);
else
return 0; // we only have pair zero
}
int
NCursesWindow::setpalette(short fore, short back, short pair)
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
return init_pair(pair, fore, back);
else
return OK;
}
int
NCursesWindow::setpalette(short fore, short back)
{
if (colorInitialized==COLORS_ARE_REALLY_THERE)
return setpalette(fore, back, PAIR_NUMBER(w->_attrs));
else
return OK;
}
int
NCursesWindow::setcolor(short pair)
{
if (colorInitialized==COLORS_ARE_REALLY_THERE) {
if ((pair < 1) || (pair > COLOR_PAIRS))
err_handler("Can't set color pair");
attroff(A_COLOR);
attrset(COLOR_PAIR(pair));
}
return OK;
}
extern "C" int _nc_has_mouse(void);
bool NCursesWindow::has_mouse() const {
return ((::has_key(KEY_MOUSE) || ::_nc_has_mouse())
? TRUE : FALSE);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,121 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
#include "cursslk.h"
#include "cursesapp.h"
#include "internal.h"
MODULE_ID("$Id: cursslk.cc,v 1.5 1999/05/16 17:31:01 juergen Exp $")
void Soft_Label_Key_Set::Soft_Label_Key::operator=(char *text) {
delete[] label;
label = new char[1 + ::strlen(text)];
(strcpy)(label,text);
}
long Soft_Label_Key_Set::count = 0L;
int Soft_Label_Key_Set::num_labels = 0;
Soft_Label_Key_Set::Label_Layout
Soft_Label_Key_Set::format = None;
void Soft_Label_Key_Set::init() {
slk_array = new Soft_Label_Key[num_labels];
for(int i=0; i < num_labels; i++) {
slk_array[i].num = i+1;
}
b_attrInit = FALSE;
}
Soft_Label_Key_Set::Soft_Label_Key_Set() {
if (format==None)
Error("No default SLK layout");
init();
}
Soft_Label_Key_Set::Soft_Label_Key_Set(Soft_Label_Key_Set::Label_Layout fmt) {
if (fmt==None)
Error("Invalid SLK Layout");
if (count++==0) {
format = fmt;
if (ERR == ::slk_init((int)fmt))
Error("slk_init");
num_labels = (fmt>=PC_Style?12:8);
}
else if (fmt!=format)
Error("All SLKs must have same layout");
init();
}
Soft_Label_Key_Set::~Soft_Label_Key_Set() {
if (!::isendwin())
clear();
delete[] slk_array;
count--;
}
Soft_Label_Key_Set::Soft_Label_Key& Soft_Label_Key_Set::operator[](int i) {
if (i<1 || i>num_labels)
Error("Invalid Label index");
return slk_array[i-1];
}
void Soft_Label_Key_Set::activate_label(int i, bool bf) {
if (!b_attrInit) {
NCursesApplication* A = NCursesApplication::getApplication();
if (A) attrset(A->labels());
b_attrInit = TRUE;
}
Soft_Label_Key& K = (*this)[i];
if (ERR==::slk_set(K.num,bf?K.label:"",K.format))
Error("slk_set");
noutrefresh();
}
void Soft_Label_Key_Set::activate_labels(bool bf) {
if (!b_attrInit) {
NCursesApplication* A = NCursesApplication::getApplication();
if (A) attrset(A->labels());
b_attrInit = TRUE;
}
for(int i=1; i <= num_labels; i++) {
Soft_Label_Key& K = (*this)[i];
if (ERR==::slk_set(K.num,bf?K.label:"",K.format))
Error("slk_set");
}
if (bf)
restore();
else
clear();
noutrefresh();
}

View File

@ -0,0 +1,205 @@
// * this is for making emacs happy: -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: cursslk.h,v 1.5 1999/05/16 17:30:08 juergen Exp $
#ifndef _CURSSLK_H
#define _CURSSLK_H
#include <cursesw.h>
class Soft_Label_Key_Set {
public:
// This inner class represents the attributes of a Soft Label Key (SLK)
class Soft_Label_Key {
friend class Soft_Label_Key_Set;
public:
typedef enum { Left=0, Center=1, Right=2 } Justification;
private:
char *label; // The Text of the Label
Justification format; // The Justification
int num; // The number of the Label
Soft_Label_Key() : label((char*)0),format(Left),num(-1) {
}
virtual ~Soft_Label_Key() {
delete[] label;
};
public:
// Set the text of the Label
void operator=(char *text);
// Set the Justification of the Label
inline void operator=(Justification just) {
format = just;
}
// Retrieve the text of the label
inline char* operator()(void) const {
return label;
}
};
public:
typedef enum {
None = -1,
Three_Two_Three = 0,
Four_Four = 1,
PC_Style = 2,
PC_Style_With_Index = 3
} Label_Layout;
private:
static long count; // Number of Key Sets
static Label_Layout format; // Layout of the Key Sets
static int num_labels; // Number Of Labels in Key Sets
bool b_attrInit; // Are attributes initialized
Soft_Label_Key *slk_array; // The array of SLK's
// Init the Key Set
void init();
// Activate or Deactivate Label# i, Label counting starts with 1!
void activate_label(int i, bool bf=TRUE);
// Activate of Deactivate all Labels
void activate_labels(bool bf);
protected:
inline void Error (const char* msg) const THROWS(NCursesException) {
THROW(new NCursesException (msg));
}
// Remove SLK's from screen
void clear() {
if (ERR==::slk_clear())
Error("slk_clear");
}
// Restore them
void restore() {
if (ERR==::slk_restore())
Error("slk_restore");
}
public:
// Construct a Key Set, use the most comfortable layout as default.
// You must create a Soft_Label_Key_Set before you create any object of
// the NCursesWindow, NCursesPanel or derived classes. (Actually before
// ::initscr() is called).
Soft_Label_Key_Set(Label_Layout fmt);
// This constructor assumes, that you already constructed a Key Set
// with a layout by the constructor above. This layout will be reused.
Soft_Label_Key_Set();
virtual ~Soft_Label_Key_Set();
// Get Label# i. Label counting starts with 1!
Soft_Label_Key& operator[](int i);
// Retrieve number of Labels
inline int labels() const { return num_labels; }
// Refresh the SLK portion of the screen
inline void refresh() {
if (ERR==::slk_refresh())
Error("slk_refresh");
}
// Mark the SLK portion of the screen for refresh, defer actual refresh
// until next update call.
inline void noutrefresh() {
if (ERR==::slk_noutrefresh())
Error("slk_noutrefresh");
}
// Mark the whole SLK portion of the screen as modified
inline void touch() {
if (ERR==::slk_touch())
Error("slk_touch");
}
// Activate Label# i
inline void show(int i) {
activate_label(i,FALSE);
activate_label(i,TRUE);
}
// Hide Label# i
inline void hide(int i) {
activate_label(i,FALSE);
}
// Show all Labels
inline void show() {
activate_labels(FALSE);
activate_labels(TRUE);
}
// Hide all Labels
inline void hide() {
activate_labels(FALSE);
}
inline void attron(attr_t attrs) {
if (ERR==::slk_attron(attrs))
Error("slk_attron");
}
inline void attroff(attr_t attrs) {
if (ERR==::slk_attroff(attrs))
Error("slk_attroff");
}
inline void attrset(attr_t attrs) {
if (ERR==::slk_attrset(attrs))
Error("slk_attrset");
}
inline void color(short color_pair_number) {
if (ERR==::slk_color(color_pair_number))
Error("slk_color");
}
inline attr_t attr() const {
return ::slk_attr();
}
};
#endif // _CURSSLK_H

449
contrib/ncurses/c++/demo.cc Normal file
View File

@ -0,0 +1,449 @@
/*
* Silly demo program for the NCursesPanel class.
*
* written by Anatoly Ivasyuk (anatoly@nick.csh.rit.edu)
*
* Demo code for NCursesMenu and NCursesForm written by
* Juergen Pfeifer <juergen.pfeifer@gmx.net>
*
* $Id: demo.cc,v 1.17 1999/07/31 09:47:17 juergen Exp $
*/
#include "cursesapp.h"
#include "cursesm.h"
#include "cursesf.h"
#if HAVE_LIBC_H
# include <libc.h>
#endif
extern "C" unsigned int sleep(unsigned int);
#undef index // needed for NeXT
//
// -------------------------------------------------------------------------
//
class SillyDemo
{
public:
void run(int sleeptime) {
NCursesPanel *std = new NCursesPanel();
// Make a few small demo panels
NCursesPanel *u = new NCursesPanel(8,20,12,4);
NCursesPanel *v = new NCursesPanel(8,20,10,6);
NCursesPanel *w = new NCursesPanel(8,20,8,8);
NCursesPanel *x = new NCursesPanel(8,20,6,10);
NCursesPanel *y = new NCursesPanel(8,20,4,12);
NCursesPanel *z = new NCursesPanel(8,30,2,14);
// Draw something on the main screen, so we can see what happens
// when panels get moved or deleted.
std->box();
std->move(std->height()/2,1);
std->hline(std->width()-2);
std->move(1,std->width()/2);
std->vline(std->height()-2);
std->addch(0,std->width()/2,ACS_TTEE);
std->addch(std->height()-1,std->width()/2,ACS_BTEE);
std->addch(std->height()/2,0,ACS_LTEE);
std->addch(std->height()/2,std->width()-1,ACS_RTEE);
std->addch(std->height()/2,std->width()/2,ACS_PLUS);
// Draw frames with titles around panels so that we can see where
// the panels are located.
u->boldframe("Win U");
v->frame("Win V");
w->boldframe("Win W");
x->frame("Win X");
y->boldframe("Win Y");
z->frame("Win Z");
if (NCursesApplication::getApplication()->useColors()) {
u->bkgd(' '|COLOR_PAIR(1));
w->bkgd(' '|COLOR_PAIR(1));
y->bkgd(' '|COLOR_PAIR(1));
v->bkgd(' '|COLOR_PAIR(2));
x->bkgd(' '|COLOR_PAIR(2));
z->bkgd(' '|COLOR_PAIR(2));
}
// A refresh to any valid panel updates all panels and refreshes
// the screen. Using std is just convenient - We know it's always
// valid until the end of the program.
std->refresh();
sleep(sleeptime);
// Show what happens when panels are deleted and moved.
sleep(sleeptime);
delete u;
std->refresh();
sleep(sleeptime);
delete z;
std->refresh();
sleep(sleeptime);
delete v;
std->refresh();
// show how it looks when a panel moves
sleep(sleeptime);
y->mvwin(5,30);
std->refresh();
sleep(sleeptime);
delete y;
std->refresh();
// show how it looks when you raise a panel
sleep(sleeptime);
w->top();
std->refresh();
sleep(sleeptime);
delete w;
std->refresh();
sleep(sleeptime);
delete x;
std->clear();
std->refresh();
// Don't forget to clean up the main screen. Since this is the
// last thing using NCursesWindow, this has the effect of
// shutting down ncurses and restoring the terminal state.
sleep(sleeptime);
delete std;
}
};
class UserData
{
private:
int u;
public:
UserData(int x) : u(x) {}
int sleeptime() const { return u; }
};
//
// -------------------------------------------------------------------------
//
template<class T> class MyAction : public NCursesUserItem<T>
{
public:
MyAction (const char* p_name,
const T* p_UserData)
: NCursesUserItem<T>(p_name, (const char*)0, p_UserData)
{};
~MyAction() {}
bool action() {
SillyDemo a;
a.run(NCursesUserItem<T>::UserData()->sleeptime());
return FALSE;
}
};
class QuitItem : public NCursesMenuItem
{
public:
QuitItem() : NCursesMenuItem("Quit") {
}
bool action() {
return TRUE;
}
};
//
// -------------------------------------------------------------------------
//
class Label : public NCursesFormField
{
public:
Label(const char* title,
int row, int col)
: NCursesFormField(1,(int)::strlen(title),row,col) {
set_value(title);
options_off(O_EDIT|O_ACTIVE);
}
};
//
// -------------------------------------------------------------------------
//
class MyFieldType : public UserDefinedFieldType {
private:
int chk;
protected:
bool field_check(NCursesFormField& f) {
return TRUE;
}
bool char_check(int c) {
return (c==chk?TRUE:FALSE);
}
public:
MyFieldType(int x) : chk(x) {
}
};
//
// -------------------------------------------------------------------------
//
class TestForm : public NCursesForm
{
private:
NCursesFormField** F;
MyFieldType* mft;
Integer_Field *ift;
Enumeration_Field *eft;
static char *weekdays[];
public:
TestForm() : NCursesForm(13,51,(lines()-15)/2,(cols()-53)/2) {
F = new NCursesFormField*[10];
mft = new MyFieldType('X');
ift = new Integer_Field(0,1,10);
eft = new Enumeration_Field(weekdays);
F[0] = new Label("Demo Entry Form",0,16);
F[1] = new Label("Weekday Enum",2,1);
F[2] = new Label("Number(1-10)",2,21);
F[3] = new Label("Only 'X'",2,35);
F[4] = new Label("Multiline Field (Dynamic and Scrollable)",5,1);
F[5] = new NCursesFormField(1,18,3,1);
F[6] = new NCursesFormField(1,12,3,21);
F[7] = new NCursesFormField(1,12,3,35);
F[8] = new NCursesFormField(4,46,6,1,2);
F[9] = new NCursesFormField();
InitForm(F,TRUE,TRUE);
boldframe();
F[5]->set_fieldtype(*eft);
F[6]->set_fieldtype(*ift);
F[7]->set_fieldtype(*mft);
F[7]->set_maximum_growth(20); // max. 20 characters
F[7]->options_off(O_STATIC); // make field dynamic
F[8]->set_maximum_growth(10); // max. 10 lines
F[8]->options_off(O_STATIC); // make field dynamic
}
~TestForm() {
delete mft;
delete ift;
delete eft;
}
};
char* TestForm::weekdays[] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", (char *)0 };
//
// -------------------------------------------------------------------------
//
class FormAction : public NCursesMenuItem
{
public:
FormAction(const char *s) : NCursesMenuItem(s) {
}
bool action() {
TestForm F;
Soft_Label_Key_Set* S = new Soft_Label_Key_Set;
for(int i=1; i <= S->labels(); i++) {
char buf[5];
::sprintf(buf,"Frm%02d",i);
(*S)[i] = buf; // Text
(*S)[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
}
NCursesApplication::getApplication()->push(*S);
F();
NCursesApplication::getApplication()->pop();
return FALSE;
}
};
//
// -------------------------------------------------------------------------
//
class PadAction : public NCursesMenuItem
{
public:
PadAction(const char* s) : NCursesMenuItem(s) {
}
bool action() {
const int GRIDSIZE = 3;
const int PADSIZE = 200;
unsigned gridcount = 0;
NCursesPanel std;
NCursesPanel P(std.lines()-2,std.cols()-2,1,1);
NCursesFramedPad FP(P,PADSIZE,PADSIZE);
for (int i=0; i < PADSIZE; i++) {
for (int j=0; j < PADSIZE; j++) {
if (i % GRIDSIZE == 0 && j % GRIDSIZE == 0) {
if (i==0 || j==0)
FP.addch('+');
else
FP.addch((chtype)('A' + (gridcount++ % 26)));
}
else if (i % GRIDSIZE == 0)
FP.addch('-');
else if (j % GRIDSIZE == 0)
FP.addch('|');
else
FP.addch(' ');
}
}
P.label("Pad Demo",NULL);
FP();
P.clear();
return FALSE;
}
};
//
// -------------------------------------------------------------------------
//
class PassiveItem : public NCursesMenuItem {
public:
PassiveItem(const char* text) : NCursesMenuItem(text) {
options_off(O_SELECTABLE);
}
};
//
// -------------------------------------------------------------------------
//
class MyMenu : public NCursesMenu
{
private:
NCursesPanel* P;
NCursesMenuItem** I;
UserData *u;
static const int n_items = 7;
public:
MyMenu ()
: NCursesMenu (n_items+2, 8, (lines()-10)/2, (cols()-10)/2)
{
u = new UserData(1);
I = new NCursesMenuItem*[1+n_items];
I[0] = new PassiveItem("One");
I[1] = new PassiveItem("Two");
I[2] = new MyAction<UserData> ("Silly", u);
I[3] = new FormAction("Form");
I[4] = new PadAction("Pad");
I[5] = new PassiveItem("Six");
I[6] = new QuitItem();
I[7] = new NCursesMenuItem(); // Terminating empty item
InitMenu(I,TRUE,TRUE);
P = new NCursesPanel(1,n_items,LINES-1,1);
boldframe("Demo","Silly");
P->show();
}
~MyMenu()
{
P->hide();
delete P;
delete u;
}
virtual void On_Menu_Init()
{
NCursesWindow W(::stdscr);
P->move(0,0);
P->clrtoeol();
for(int i=1; i<=count(); i++)
P->addch('0' + i);
P->bkgd(W.getbkgd());
refresh();
}
virtual void On_Menu_Termination()
{
P->move(0,0);
P->clrtoeol();
refresh();
}
virtual void On_Item_Init(NCursesMenuItem& item)
{
P->move(0,item.index());
P->attron(A_REVERSE);
P->printw("%1d",1+item.index());
P->attroff(A_REVERSE);
refresh();
}
virtual void On_Item_Termination(NCursesMenuItem& item)
{
P->move(0,item.index());
P->attroff(A_REVERSE);
P->printw("%1d",1+item.index());
refresh();
}
};
//
// -------------------------------------------------------------------------
//
class TestApplication : public NCursesApplication {
protected:
int titlesize() const { return 1; }
void title();
Soft_Label_Key_Set::Label_Layout useSLKs() const {
return Soft_Label_Key_Set::PC_Style_With_Index;
}
void init_labels(Soft_Label_Key_Set& S) const;
public:
TestApplication() : NCursesApplication(TRUE) {
}
int run();
};
void TestApplication::init_labels(Soft_Label_Key_Set& S) const {
for(int i=1; i <= S.labels(); i++) {
char buf[5];
::sprintf(buf,"Key%02d",i);
S[i] = buf; // Text
S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification
}
}
void TestApplication::title() {
const char * const title = "Simple C++ Binding Demo";
const int len = ::strlen(title);
titleWindow->bkgd(screen_titles());
titleWindow->addstr(0,(titleWindow->cols()-len)/2,title);
titleWindow->noutrefresh();
}
int TestApplication::run() {
MyMenu M;
M();
return 0;
}
//
// -------------------------------------------------------------------------
//
static TestApplication Demo;

59
contrib/ncurses/c++/edit_cfg.sh Executable file
View File

@ -0,0 +1,59 @@
#!/bin/sh
# $Id: edit_cfg.sh,v 1.4 1998/02/11 12:13:41 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
#
# Edit the default value of the etip.h file based on the autoconf-generated
# values:
#
# $1 = ncurses_cfg.h
# $2 = etip.h
#
for name in \
HAVE_BUILTIN_H \
HAVE_TYPEINFO \
HAVE_VALUES_H
do
mv $2 $2.bak
if ( grep "[ ]$name[ ]1" $1 2>&1 >/dev/null)
then
sed -e 's/define '$name'.*$/ define '$name' 1/' $2.bak >$2
else
sed -e 's/define '$name'.*$/ define '$name' 0/' $2.bak >$2
fi
if (cmp -s $2 $2.bak)
then
echo '** same: '$name
mv $2.bak $2
else
echo '** edit: '$name
rm -f $2.bak
fi
done

View File

@ -0,0 +1,248 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: etip.h.in,v 1.10 1999/05/16 17:29:47 juergen Exp $
#ifndef _ETIP_H
#define _ETIP_H
// These are substituted at configure/build time
#ifndef HAVE_BUILTIN_H
#define HAVE_BUILTIN_H 0
#endif
#ifndef HAVE_TYPEINFO
#define HAVE_TYPEINFO 0
#endif
#ifndef HAVE_VALUES_H
#define HAVE_VALUES_H 0
#endif
#ifndef ETIP_NEEDS_MATH_H
#define ETIP_NEEDS_MATH_H 0
#endif
#ifndef ETIP_NEEDS_MATH_EXCEPTION
#define ETIP_NEEDS_MATH_EXCEPTION 0
#endif
#ifdef __GNUG__
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
# if HAVE_TYPEINFO
# include <typeinfo>
# endif
# endif
#endif
#if defined(__GNUG__)
# if HAVE_BUILTIN_H
# if ETIP_NEEDS_MATH_H
# if ETIP_NEEDS_MATH_EXCEPTION
# undef exception
# define exception math_exception
# endif
# include <math.h>
# endif
# undef exception
# define exception builtin_exception
# include <builtin.h>
# undef exception
# endif
#elif defined (__SUNPRO_CC)
# include <generic.h>
# include <string.h>
#else
# include <string.h>
#endif
extern "C" {
#if HAVE_VALUES_H
# include <values.h>
#endif
#include <assert.h>
#include <eti.h>
#include <errno.h>
}
// Forward Declarations
class NCursesPanel;
class NCursesMenu;
class NCursesForm;
class NCursesException
{
public:
const char *message;
int errorno;
NCursesException (const char* msg, int err)
: message(msg), errorno (err)
{};
NCursesException (const char* msg)
: message(msg), errorno (E_SYSTEM_ERROR)
{};
virtual const char *classname() const {
return "NCursesWindow";
}
};
class NCursesPanelException : public NCursesException
{
public:
const NCursesPanel* p;
NCursesPanelException (const char *msg, int err) :
NCursesException (msg, err),
p ((NCursesPanel*)0)
{};
NCursesPanelException (const NCursesPanel* panel,
const char *msg,
int err) :
NCursesException (msg, err),
p (panel)
{};
NCursesPanelException (int err) :
NCursesException ("panel library error", err),
p ((NCursesPanel*)0)
{};
NCursesPanelException (const NCursesPanel* panel,
int err) :
NCursesException ("panel library error", err),
p (panel)
{};
virtual const char *classname() const {
return "NCursesPanel";
}
};
class NCursesMenuException : public NCursesException
{
public:
const NCursesMenu* m;
NCursesMenuException (const char *msg, int err) :
NCursesException (msg, err),
m ((NCursesMenu *)0)
{};
NCursesMenuException (const NCursesMenu* menu,
const char *msg,
int err) :
NCursesException (msg, err),
m (menu)
{};
NCursesMenuException (int err) :
NCursesException ("menu library error", err),
m ((NCursesMenu *)0)
{};
NCursesMenuException (const NCursesMenu* menu,
int err) :
NCursesException ("menu library error", err),
m (menu)
{};
virtual const char *classname() const {
return "NCursesMenu";
}
};
class NCursesFormException : public NCursesException
{
public:
const NCursesForm* f;
NCursesFormException (const char *msg, int err) :
NCursesException (msg, err),
f ((NCursesForm*)0)
{};
NCursesFormException (const NCursesForm* form,
const char *msg,
int err) :
NCursesException (msg, err),
f (form)
{};
NCursesFormException (int err) :
NCursesException ("form library error", err),
f ((NCursesForm*)0)
{};
NCursesFormException (const NCursesForm* form,
int err) :
NCursesException ("form library error", err),
f (form)
{};
virtual const char *classname() const {
return "NCursesForm";
}
};
#if !(defined(__GNUG__)||defined(__SUNPRO_CC))
# include <iostream.h>
extern "C" void exit(int);
#endif
inline void THROW(const NCursesException *e) {
#if defined(__GNUG__)
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
(*lib_error_handler)(e?e->classname():"",e?e->message:"");
#else
throw *e;
#endif
#elif defined(__SUNPRO_CC)
genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
#else
if (e)
cerr << e->message << endl;
exit(0);
#endif
}
#define THROWS(s)
#endif // _ETIP_H

View File

@ -0,0 +1,39 @@
# C++ headers
# $Id: headers,v 1.2 1998/02/11 12:13:40 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
#
$(srcdir)/cursesapp.h
$(srcdir)/cursesf.h
$(srcdir)/cursesm.h
$(srcdir)/cursesp.h
$(srcdir)/cursesw.h
$(srcdir)/cursslk.h
etip.h

View File

@ -0,0 +1,47 @@
// * This makes emacs happy -*-Mode: C++;-*-
/****************************************************************************
* 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> 1997 *
****************************************************************************/
// $Id: internal.h,v 1.5 1999/05/16 17:29:25 juergen Exp $
#ifndef _CPLUS_INTERNAL_H
#define _CPLUS_INTERNAL_H 1
#ifdef USE_RCS_IDS
#define MODULE_ID(id) static const char Ident[] = id;
#else
#define MODULE_ID(id) /*nothing*/
#endif
#define CTRL(x) ((x) & 0x1f)
#endif

View File

@ -0,0 +1,43 @@
# Program modules
# $Id: modules,v 1.6 1999/07/31 09:46:54 juergen 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> 1995,1997
#
@ base
cursesf c++ $(srcdir) $(cursesf_h) $(cursesapp_h)
cursesm c++ $(srcdir) $(cursesm_h) $(cursesapp_h)
cursesp c++ $(srcdir) $(cursesp_h)
cursesw c++ $(srcdir) $(cursesw_h)
cursespad c++ $(srcdir) $(cursesw_h)
cursslk c++ $(srcdir) $(cursslk_h) $(cursesapp_h)
cursesapp c++ $(srcdir) $(cursesapp_h)
cursesmain c++ $(srcdir) $(cursesapp_h)
demo c++ $(srcdir) $(cursesf_h) $(cursesm_h) $(cursesapp_h)

969
contrib/ncurses/config.guess vendored Executable file
View File

@ -0,0 +1,969 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <bothner@cygnus.com>.
# The master version of this file is at the FSF in /home/gd/gnu/lib.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
#
# The plan is that this can be called by configure scripts if you
# don't specify an explicit system type (host/target name).
#
# Only a few systems have been added to this list; please add others
# (but try to keep the structure clean).
#
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
# (ghazi@noc.rutgers.edu 8/24/94.)
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
PATH=$PATH:/.attbin ; export PATH
fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
cat <<EOF >dummy.s
.globl main
.ent main
main:
.frame \$30,0,\$26,0
.prologue 0
.long 0x47e03d80 # implver $0
lda \$2,259
.long 0x47e20c21 # amask $2,$1
srl \$1,8,\$2
sll \$2,2,\$2
sll \$0,3,\$0
addl \$1,\$0,\$0
addl \$2,\$0,\$0
ret \$31,(\$26),1
.end main
EOF
${CC-cc} dummy.s -o dummy 2>/dev/null
if test "$?" = 0 ; then
./dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
;;
15)
UNAME_MACHINE="alphaev5"
;;
14)
UNAME_MACHINE="alphaev56"
;;
10)
UNAME_MACHINE="alphapca56"
;;
16)
UNAME_MACHINE="alphaev6"
;;
esac
fi
rm -f dummy.s dummy
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
exit 0 ;;
21064:Windows_NT:50:3)
echo alpha-dec-winnt3.5
exit 0 ;;
Amiga*:UNIX_System_V:4.0:*)
echo m68k-cbm-sysv4
exit 0;;
amiga:NetBSD:*:*)
echo m68k-cbm-netbsd${UNAME_RELEASE}
exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
*:[Aa]miga[Oo][Ss]:*:*)
echo ${UNAME_MACHINE}-unknown-amigaos
exit 0 ;;
arc64:OpenBSD:*:*)
echo mips64el-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
hkmips:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
pmax:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sgi:OpenBSD:*:*)
echo mips-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
wgrisc:OpenBSD:*:*)
echo mipsel-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
arm32:NetBSD:*:*)
echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
SR2?01:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
if test "`(/bin/universe) 2>/dev/null`" = att ; then
echo pyramid-pyramid-sysv3
else
echo pyramid-pyramid-bsd
fi
exit 0 ;;
NILE:*:*:dcosx)
echo pyramid-pyramid-svr4
exit 0 ;;
sun4H:SunOS:5.*:*)
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
i86pc:SunOS:5.*:*)
echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
sun4*:SunOS:*:*)
case "`/usr/bin/arch -k`" in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
# Japanese Language versions have a version number like `4.1.3-JL'.
echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
exit 0 ;;
sun3*:SunOS:*:*)
echo m68k-sun-sunos${UNAME_RELEASE}
exit 0 ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
case "`/bin/arch`" in
sun3)
echo m68k-sun-sunos${UNAME_RELEASE}
;;
sun4)
echo sparc-sun-sunos${UNAME_RELEASE}
;;
esac
exit 0 ;;
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
atari*:NetBSD:*:*)
echo m68k-atari-netbsd${UNAME_RELEASE}
exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sun3*:NetBSD:*:*)
echo m68k-sun-netbsd${UNAME_RELEASE}
exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:NetBSD:*:*)
echo m68k-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
mvme88k:OpenBSD:*:*)
echo m88k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
macppc:NetBSD:*:*)
echo powerpc-apple-netbsd${UNAME_RELEASE}
exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
RISC*:ULTRIX:*:*)
echo mips-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
VAX*:ULTRIX*:*:*)
echo vax-dec-ultrix${UNAME_RELEASE}
exit 0 ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
echo clipper-intergraph-clix${UNAME_RELEASE}
exit 0 ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
sed 's/^ //' << EOF >dummy.c
int main (argc, argv) int argc; char **argv; {
#if defined (host_mips) && defined (MIPSEB)
#if defined (SYSTYPE_SYSV)
printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_SVR4)
printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
#endif
#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
#endif
#endif
exit (-1);
}
EOF
${CC-cc} dummy.c -o dummy \
&& ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
&& rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo mips-mips-riscos${UNAME_RELEASE}
exit 0 ;;
Night_Hawk:Power_UNIX:*:*)
echo powerpc-harris-powerunix
exit 0 ;;
m88k:CX/UX:7*:*)
echo m88k-harris-cxux7
exit 0 ;;
m88k:*:4*:R4*)
echo m88k-motorola-sysv4
exit 0 ;;
m88k:*:3*:R3*)
echo m88k-motorola-sysv3
exit 0 ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
-o ${TARGET_BINARY_INTERFACE}x = x ] ; then
echo m88k-dg-dgux${UNAME_RELEASE}
else
echo m88k-dg-dguxbcs${UNAME_RELEASE}
fi
else echo i586-dg-dgux${UNAME_RELEASE}
fi
exit 0 ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
echo m88k-dolphin-sysv3
exit 0 ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
echo m88k-motorola-sysv3
exit 0 ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
echo m88k-tektronix-sysv3
exit 0 ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
echo m68k-tektronix-bsd
exit 0 ;;
*:IRIX*:*:*)
echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
exit 0 ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i?86:AIX:*:*)
echo i386-ibm-aix
exit 0 ;;
*:MVS:*:* | *:OS390:*:*|*:OS/390:*:*)
# uname -m gives a processor model number /* S/390 -- gil -- 1389 */
echo s390-ibm-os390 # on R1 and R2, uname -s reports OS390
exit 0 ;; # on R3, uname -s reports OS/390
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
sed 's/^ //' << EOF >dummy.c
#include <sys/systemcfg.h>
main()
{
if (!__power_pc())
exit(1);
puts("powerpc-ibm-aix3.2.5");
exit(0);
}
EOF
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo rs6000-ibm-aix3.2.5
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
echo rs6000-ibm-aix3.2.4
else
echo rs6000-ibm-aix3.2
fi
exit 0 ;;
*:AIX:*:4)
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
IBM_ARCH=rs6000
else
IBM_ARCH=powerpc
fi
if [ -x /usr/bin/oslevel ] ; then
IBM_REV=`/usr/bin/oslevel`
else
IBM_REV=4.${UNAME_RELEASE}
fi
echo ${IBM_ARCH}-ibm-aix${IBM_REV}
exit 0 ;;
*:AIX:*:*)
echo rs6000-ibm-aix
exit 0 ;;
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
echo rs6000-bull-bosx
exit 0 ;;
DPX/2?00:B.O.S.:*:*)
echo m68k-bull-sysv3
exit 0 ;;
9000/[34]??:4.3bsd:1.*:*)
echo m68k-hp-bsd
exit 0 ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
echo m68k-hp-bsd4.4
exit 0 ;;
9000/[34678]??:HP-UX:*:*)
case "${UNAME_MACHINE}" in
9000/31? ) HP_ARCH=m68000 ;;
9000/[34]?? ) HP_ARCH=m68k ;;
9000/6?? | 9000/7?? | 9000/80[024] | 9000/8?[13679] | 9000/892 )
sed 's/^ //' << EOF >dummy.c
#include <stdlib.h>
#include <unistd.h>
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy`
rm -f dummy.c dummy
esac
HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
exit 0 ;;
3050*:HI-UX:*:*)
sed 's/^ //' << EOF >dummy.c
#include <unistd.h>
int
main ()
{
long cpu = sysconf (_SC_CPU_VERSION);
/* The order matters, because CPU_IS_HP_MC68K erroneously returns
true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
results, however. */
if (CPU_IS_PA_RISC (cpu))
{
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
default: puts ("hppa-hitachi-hiuxwe2"); break;
}
}
else if (CPU_IS_HP_MC68K (cpu))
puts ("m68k-hitachi-hiuxwe2");
else puts ("unknown-hitachi-hiuxwe2");
exit (0);
}
EOF
${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
echo unknown-hitachi-hiuxwe2
exit 0 ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
echo hppa1.1-hp-bsd
exit 0 ;;
9000/8??:4.3bsd:*:*)
echo hppa1.0-hp-bsd
exit 0 ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
echo hppa1.1-hp-osf
exit 0 ;;
hp8??:OSF1:*:*)
echo hppa1.0-hp-osf
exit 0 ;;
i?86:OSF1:*:*)
if [ -x /usr/sbin/sysversion ] ; then
echo ${UNAME_MACHINE}-unknown-osf1mk
else
echo ${UNAME_MACHINE}-unknown-osf1
fi
exit 0 ;;
parisc*:Lites*:*:*)
echo hppa1.1-hp-lites
exit 0 ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
echo c1-convex-bsd
exit 0 ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
echo c34-convex-bsd
exit 0 ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
echo c38-convex-bsd
exit 0 ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
echo c4-convex-bsd
exit 0 ;;
CRAY*X-MP:*:*:*)
echo xmp-cray-unicos
exit 0 ;;
CRAY*Y-MP:*:*:*)
echo ymp-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY*[A-Z]90:*:*:*)
echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
exit 0 ;;
CRAY*TS:*:*:*)
echo t90-cray-unicos${UNAME_RELEASE}
exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
F300:UNIX_System_V:*:*)
FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
exit 0 ;;
F301:UNIX_System_V:*:*)
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
exit 0 ;;
hp3[0-9][05]:NetBSD:*:*)
echo m68k-hp-netbsd${UNAME_RELEASE}
exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
echo sparc-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
i?86:BSD/386:*:* | *:BSD/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
*:NetBSD:*:*)
echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit 0 ;;
i*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit 0 ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit 0 ;;
prep*:SunOS:5.*:*)
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit 0 ;;
*:GNU:*:*)
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
*:Linux:*:*)
# uname on the ARM produces all sorts of strangeness, and we need to
# filter it out.
case "$UNAME_MACHINE" in
arm* | sa110*) UNAME_MACHINE="arm" ;;
esac
# The BFD linker knows what the default object file format is, so
# first see if it will tell us.
ld_help_string=`ld --help 2>&1`
ld_supported_emulations=`echo $ld_help_string \
| sed -ne '/supported emulations:/!d
s/[ ][ ]*/ /g
s/.*supported emulations: *//
s/ .*//
p'`
case "$ld_supported_emulations" in
i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;;
i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;;
sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;;
esac
if test "${UNAME_MACHINE}" = "alpha" ; then
sed 's/^ //' <<EOF >dummy.s
.globl main
.ent main
main:
.frame \$30,0,\$26,0
.prologue 0
.long 0x47e03d80 # implver $0
lda \$2,259
.long 0x47e20c21 # amask $2,$1
srl \$1,8,\$2
sll \$2,2,\$2
sll \$0,3,\$0
addl \$1,\$0,\$0
addl \$2,\$0,\$0
ret \$31,(\$26),1
.end main
EOF
LIBC=""
${CC-cc} dummy.s -o dummy 2>/dev/null
if test "$?" = 0 ; then
./dummy
case "$?" in
7)
UNAME_MACHINE="alpha"
;;
15)
UNAME_MACHINE="alphaev5"
;;
14)
UNAME_MACHINE="alphaev56"
;;
10)
UNAME_MACHINE="alphapca56"
;;
16)
UNAME_MACHINE="alphaev6"
;;
esac
objdump --private-headers dummy | \
grep ld.so.1 > /dev/null
if test "$?" = 0 ; then
LIBC="libc1"
fi
fi
rm -f dummy.s dummy
echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >dummy.c <<EOF
main(argc, argv)
int argc;
char *argv[];
{
#ifdef __MIPSEB__
printf ("%s-unknown-linux-gnu\n", argv[1]);
#endif
#ifdef __MIPSEL__
printf ("%sel-unknown-linux-gnu\n", argv[1]);
#endif
return 0;
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
else
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
# If ld does not provide *any* "supported emulations:"
# that means it is gnuoldld.
echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
case "${UNAME_MACHINE}" in
i?86)
VENDOR=pc;
;;
*)
VENDOR=unknown;
;;
esac
# Determine whether the default compiler is a.out or elf
cat >dummy.c <<EOF
#include <features.h>
main(argc, argv)
int argc;
char *argv[];
{
#ifdef __ELF__
# ifdef __GLIBC__
# if (__GLIBC__ >= 2)
printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
# else
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
# endif
# else
printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
# endif
#else
printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
#endif
return 0;
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
fi ;;
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
# are messed up and put the nodename in both sysname and nodename.
i?86:DYNIX/ptx:4*:*)
echo i386-sequent-sysv4
exit 0 ;;
i?86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
exit 0 ;;
# SysVr5/Unixware7
i?86:*:5*:* | i?86:SYSTEM_V:5*:*)
if uname -a | grep SCO >/dev/null 2>/dev/null ; then
(/bin/uname -s|egrep UnixWare >/dev/null) && UNAME_VER=uw${UNAME_VERSION}
if /bin/uname -X 2>/dev/null >/dev/null ; then
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
fi
echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}${UNAME_VER}
else
echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
echo ${UNAME_MACHINE}-univel-sysv4.2uw${UNAME_VERSION}
else
echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
fi
exit 0 ;;
i?86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
else
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
i?86:UnixWare:*:*)
if /bin/uname -X 2>/dev/null >/dev/null ; then
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
&& UNAME_MACHINE=i586
fi
echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION}
exit 0 ;;
pc:*:*:*)
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
exit 0 ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
exit 0 ;;
paragon:*:*:*)
echo i860-intel-osf1
exit 0 ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
fi
exit 0 ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
echo m68010-convergent-sysv
exit 0 ;;
M68*:*:R3V[567]*:*)
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
OS_REL=''
test -r /etc/.relid \
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4.3${OS_REL} && exit 0
/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
&& echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& echo i486-ncr-sysv4 && exit 0 ;;
m68*:LynxOS:2.*:*)
echo m68k-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
mc68030:UNIX_System_V:4.*:*)
echo m68k-atari-sysv4
exit 0 ;;
i?86:LynxOS:2.*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
TSUNAMI:LynxOS:2.*:*)
echo sparc-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit 0 ;;
SM[BE]S:UNIX_SV:*:*)
echo mips-dde-sysv${UNAME_RELEASE}
exit 0 ;;
RM*:SINIX-*:*:*)
echo mips-sni-sysv4
exit 0 ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
echo ${UNAME_MACHINE}-sni-sysv4
else
echo ns32k-sni-sysv
fi
exit 0 ;;
PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit 0 ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
echo hppa1.1-stratus-sysv4
exit 0 ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
echo i860-stratus-sysv4
exit 0 ;;
mc68*:A/UX:*:*)
echo m68k-apple-aux${UNAME_RELEASE}
exit 0 ;;
news*:NEWS-OS:*:6*)
echo mips-sony-newsos6
exit 0 ;;
R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit 0 ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
echo powerpc-be-beos
exit 0 ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
echo powerpc-apple-beos
exit 0 ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
echo i586-pc-beos
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
cat >dummy.c <<EOF
#ifdef _SEQUENT_
# include <sys/types.h>
# include <sys/utsname.h>
#endif
main ()
{
#if defined (sony)
#if defined (MIPSEB)
/* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
I don't know.... */
printf ("mips-sony-bsd\n"); exit (0);
#else
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
#else
""
#endif
); exit (0);
#endif
#endif
#if defined (__arm) && defined (__acorn) && defined (__unix)
printf ("arm-acorn-riscix"); exit (0);
#endif
#if defined (hp300) && !defined (hpux)
printf ("m68k-hp-bsd\n"); exit (0);
#endif
#if defined (NeXT)
#if !defined (__ARCHITECTURE__)
#define __ARCHITECTURE__ "m68k"
#endif
int version;
version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
exit (0);
#endif
#if defined (MULTIMAX) || defined (n16)
#if defined (UMAXV)
printf ("ns32k-encore-sysv\n"); exit (0);
#else
#if defined (CMU)
printf ("ns32k-encore-mach\n"); exit (0);
#else
printf ("ns32k-encore-bsd\n"); exit (0);
#endif
#endif
#endif
#if defined (__386BSD__)
printf ("i386-pc-bsd\n"); exit (0);
#endif
#if defined (sequent)
#if defined (i386)
printf ("i386-sequent-dynix\n"); exit (0);
#endif
#if defined (ns32000)
printf ("ns32k-sequent-dynix\n"); exit (0);
#endif
#endif
#if defined (_SEQUENT_)
struct utsname un;
uname(&un);
if (strncmp(un.version, "V2", 2) == 0) {
printf ("i386-sequent-ptx2\n"); exit (0);
}
if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
printf ("i386-sequent-ptx1\n"); exit (0);
}
printf ("i386-sequent-ptx\n"); exit (0);
#endif
#if defined (vax)
#if !defined (ultrix)
printf ("vax-dec-bsd\n"); exit (0);
#else
printf ("vax-dec-ultrix\n"); exit (0);
#endif
#endif
#if defined (alliant) && defined (i860)
printf ("i860-alliant-bsd\n"); exit (0);
#endif
exit (1);
}
EOF
${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
rm -f dummy.c dummy
# Apollos put the system type in the environment.
test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
# Convex versions that predate uname can use getsysinfo(1)
if [ -x /usr/convex/getsysinfo ]
then
case `getsysinfo -f cpu_type` in
c1*)
echo c1-convex-bsd
exit 0 ;;
c2*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
else echo c2-convex-bsd
fi
exit 0 ;;
c34*)
echo c34-convex-bsd
exit 0 ;;
c38*)
echo c38-convex-bsd
exit 0 ;;
c4*)
echo c4-convex-bsd
exit 0 ;;
esac
fi
#echo '(Unable to guess system type)' 1>&2
exit 1

967
contrib/ncurses/config.sub vendored Executable file
View File

@ -0,0 +1,967 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc.
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
# Otherwise, we print the canonical config type on stdout and succeed.
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
# that are meaningful with *any* GNU software.
# Each package is responsible for reporting which valid configurations
# it does not support. The user should be able to distinguish
# a failure to support a valid configuration from a meaningless
# configuration.
# The goal of this file is to map all the various variations of a given
# machine specification into a single specification in the form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or in some cases, the newer four-part form:
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
if [ x$1 = x ]
then
echo Configuration name missing. 1>&2
echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
echo "or $0 ALIAS" 1>&2
echo where ALIAS is a recognized configuration type. 1>&2
exit 1
fi
# First pass through any local machine types.
case $1 in
*local*)
echo $1
exit 0
;;
*)
;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
linux-gnu*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
then os=`echo $1 | sed 's/.*-/-/'`
else os=; fi
;;
esac
### Let's recognize common machines as not being operating systems so
### that things like config.sub decstation-3100 work. We also
### recognize some manufacturers as not being operating systems, so we
### can provide default operating systems below.
case $os in
-sun*os*)
# Prevent following clause from handling this invalid input.
;;
-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple)
os=
basic_machine=$1
;;
-hiux*)
os=-hiuxwe2
;;
-sco5)
os=sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco4)
os=-sco3.2v4
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2.[4-9]*)
os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco3.2v[4-9]*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*)
os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-isc)
os=-isc2.2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-clix*)
basic_machine=clipper-intergraph
;;
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*)
os=-lynxos
;;
-ptx*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
;;
-windowsnt*)
os=`echo $os | sed -e 's/windowsnt/winnt/'`
;;
-psos*)
os=-psos
;;
esac
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w \
| alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \
| i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \
| mips64 | mipsel | mips64el | mips64orion | mips64orionel \
| mipstx39 | mipstx39el \
| sparc | sparclet | sparclite | sparc64 | v850)
basic_machine=$basic_machine-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i[34567]86)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
# Recognize the basic CPU types with company name.
vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \
| xmp-* | ymp-* \
| hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
| alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \
| ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
| sparc64-* | mips64-* | mipsel-* \
| mips64el-* | mips64orion-* | mips64orionel-* \
| mipstx39-* | mipstx39el-* \
| f301-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
basic_machine=m68000-att
;;
3b*)
basic_machine=we32k-att
;;
alliant | fx80)
basic_machine=fx80-alliant
;;
altos | altos3068)
basic_machine=m68k-altos
;;
am29k)
basic_machine=a29k-none
os=-bsd
;;
amdahl)
basic_machine=580-amdahl
os=-sysv
;;
amiga | amiga-*)
basic_machine=m68k-cbm
;;
amigaos | amigados)
basic_machine=m68k-cbm
os=-amigaos
;;
amigaunix | amix)
basic_machine=m68k-cbm
os=-sysv4
;;
apollo68)
basic_machine=m68k-apollo
os=-sysv
;;
aux)
basic_machine=m68k-apple
os=-aux
;;
balance)
basic_machine=ns32k-sequent
os=-dynix
;;
convex-c1)
basic_machine=c1-convex
os=-bsd
;;
convex-c2)
basic_machine=c2-convex
os=-bsd
;;
convex-c32)
basic_machine=c32-convex
os=-bsd
;;
convex-c34)
basic_machine=c34-convex
os=-bsd
;;
convex-c38)
basic_machine=c38-convex
os=-bsd
;;
cray | ymp)
basic_machine=ymp-cray
os=-unicos
;;
cray2)
basic_machine=cray2-cray
os=-unicos
;;
[ctj]90-cray)
basic_machine=c90-cray
os=-unicos
;;
crds | unos)
basic_machine=m68k-crds
;;
da30 | da30-*)
basic_machine=m68k-da30
;;
decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
basic_machine=mips-dec
;;
delta | 3300 | motorola-3300 | motorola-delta \
| 3300-motorola | delta-motorola)
basic_machine=m68k-motorola
;;
delta88)
basic_machine=m88k-motorola
os=-sysv3
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
;;
dpx2* | dpx2*-bull)
basic_machine=m68k-bull
os=-sysv3
;;
ebmon29k)
basic_machine=a29k-amd
os=-ebmon
;;
elxsi)
basic_machine=elxsi-elxsi
os=-bsd
;;
encore | umax | mmax)
basic_machine=ns32k-encore
;;
fx2800)
basic_machine=i860-alliant
;;
genix)
basic_machine=ns32k-ns
;;
gmicro)
basic_machine=tron-gmicro
os=-sysv
;;
h3050r* | hiux*)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
h8300hms)
basic_machine=h8300-hitachi
os=-hms
;;
harris)
basic_machine=m88k-harris
os=-sysv3
;;
hp300-*)
basic_machine=m68k-hp
;;
hp300bsd)
basic_machine=m68k-hp
os=-bsd
;;
hp300hpux)
basic_machine=m68k-hp
os=-hpux
;;
hp9k2[0-9][0-9] | hp9k31[0-9])
basic_machine=m68000-hp
;;
hp9k3[2-9][0-9])
basic_machine=m68k-hp
;;
hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7)
basic_machine=hppa1.1-hp
;;
hp9k8[0-9][0-9] | hp8[0-9][0-9])
basic_machine=hppa1.0-hp
;;
hppa-next)
os=-nextstep3
;;
i370-ibm* | ibm*)
basic_machine=i370-ibm
os=-mvs
;;
s390 | s390-ibm*)
# OS/390 support after:
# Linkname: Mortice Kern Systems (MKS) Inc. - OS/390 OpenEdition -- GNU Utilities Downloads
# URL: http://www.mks.com/s390/gnu/download.htm#autoconf
basic_machine=s390-ibm # /* S/390 -- gil -- 1419 */
os=-os390
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i[34567]86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
;;
i[34567]86v4*)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv4
;;
i[34567]86v)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv
;;
i[34567]86sol2)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-solaris2
;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
-irix*)
;;
*)
os=-irix4
;;
esac
;;
isi68 | isi)
basic_machine=m68k-isi
os=-sysv
;;
m88k-omron*)
basic_machine=m88k-omron
;;
magnum | m3230)
basic_machine=mips-mips
os=-sysv
;;
merlin)
basic_machine=ns32k-utek
os=-sysv
;;
miniframe)
basic_machine=m68000-convergent
;;
mipsel*-linux*)
basic_machine=mipsel-unknown
os=-linux-gnu
;;
mips*-linux*)
basic_machine=mips-unknown
os=-linux-gnu
;;
mips3*-*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
;;
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
os=-newsos
;;
news1000)
basic_machine=m68030-sony
os=-newsos
;;
news-3600 | risc-news)
basic_machine=mips-sony
os=-newsos
;;
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep* )
;;
-ns2*)
os=-nextstep2
;;
*)
os=-nextstep3
;;
esac
;;
nh3000)
basic_machine=m68k-harris
os=-cxux
;;
nh[45]000)
basic_machine=m88k-harris
os=-cxux
;;
nindy960)
basic_machine=i960-intel
os=-nindy
;;
np1)
basic_machine=np1-gould
;;
pa-hitachi)
basic_machine=hppa1.1-hitachi
os=-hiuxwe2
;;
paragon)
basic_machine=i860-intel
os=-osf
;;
pbd)
basic_machine=sparc-tti
;;
pbb)
basic_machine=m68k-tti
;;
pc532 | pc532-*)
basic_machine=ns32k-pc532
;;
pentium | p5 | k5 | nexen)
basic_machine=i586-pc
;;
pentiumpro | p6 | k6 | 6x86)
basic_machine=i686-pc
;;
pentiumii | pentium2)
basic_machine=i786-pc
;;
pentium-* | p5-* | k5-* | nexen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumpro-* | p6-* | k6-* | 6x86-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pn)
basic_machine=pn-gould
;;
power) basic_machine=rs6000-ibm
;;
ppc) basic_machine=powerpc-unknown
;;
ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppcle | powerpclittle | ppc-le | powerpc-little)
basic_machine=powerpcle-unknown
;;
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ps2)
basic_machine=i386-ibm
;;
rm[46]00)
basic_machine=mips-siemens
;;
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
sequent)
basic_machine=i386-sequent
;;
sh)
basic_machine=sh-hitachi
os=-hms
;;
sps7)
basic_machine=m68k-bull
os=-sysv2
;;
spur)
basic_machine=spur-unknown
;;
sun2)
basic_machine=m68000-sun
;;
sun2os3)
basic_machine=m68000-sun
os=-sunos3
;;
sun2os4)
basic_machine=m68000-sun
os=-sunos4
;;
sun3os3)
basic_machine=m68k-sun
os=-sunos3
;;
sun3os4)
basic_machine=m68k-sun
os=-sunos4
;;
sun4os3)
basic_machine=sparc-sun
os=-sunos3
;;
sun4os4)
basic_machine=sparc-sun
os=-sunos4
;;
sun4sol2)
basic_machine=sparc-sun
os=-solaris2
;;
sun3 | sun3-*)
basic_machine=m68k-sun
;;
sun4)
basic_machine=sparc-sun
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
symmetry)
basic_machine=i386-sequent
os=-dynix
;;
tx39)
basic_machine=mipstx39-unknown
;;
tx39el)
basic_machine=mipstx39el-unknown
;;
tower | tower-32)
basic_machine=m68k-ncr
;;
udi29k)
basic_machine=a29k-amd
os=-udi
;;
ultra3)
basic_machine=a29k-nyu
os=-sym1
;;
vaxv)
basic_machine=vax-dec
os=-sysv
;;
vms)
basic_machine=vax-dec
os=-vms
;;
vpp*|vx|vx-*)
basic_machine=f301-fujitsu
;;
vxworks960)
basic_machine=i960-wrs
os=-vxworks
;;
vxworks68)
basic_machine=m68k-wrs
os=-vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
os=-vxworks
;;
xmp)
basic_machine=xmp-cray
os=-unicos
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
none)
basic_machine=none-none
os=-none
;;
# Here we handle the default manufacturer of certain CPU types. It is in
# some cases the only manufacturer, in others, it is the most popular.
mips)
if [ x$os = x-linux-gnu ]; then
basic_machine=mips-unknown
else
basic_machine=mips-mips
fi
;;
romp)
basic_machine=romp-ibm
;;
rs6000)
basic_machine=rs6000-ibm
;;
vax)
basic_machine=vax-dec
;;
pdp11)
basic_machine=pdp11-dec
;;
we32k)
basic_machine=we32k-att
;;
sparc)
basic_machine=sparc-sun
;;
cydra)
basic_machine=cydra-cydrome
;;
orion)
basic_machine=orion-highlevel
;;
orion105)
basic_machine=clipper-highlevel
;;
*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
exit 1
;;
esac
# Here we canonicalize certain aliases for manufacturers.
case $basic_machine in
*-digital*)
basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
;;
*-commodore*)
basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
;;
*)
;;
esac
# Decode manufacturer-specific aliases for certain operating systems.
if [ x"$os" != x"" ]
then
case $os in
# First match some system type aliases
# that might get confused with valid system types.
# -solaris* is a basic system type, with this one exception.
-solaris1 | -solaris1.*)
os=`echo $os | sed -e 's|solaris1|sunos4|'`
;;
-solaris)
os=-solaris2
;;
-svr4*)
os=-sysv4
;;
-unixware*)
os=-sysv4.2uw
;;
-gnu/linux*)
os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
;;
# First accept the basic system types.
# The portable systems comes first.
# Each alternative MUST END IN A *, to match a version number.
# -sysv* is not here because it comes later, after sysvr4.
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* | -os390* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
-sunos5*)
os=`echo $os | sed -e 's|sunos5|solaris2|'`
;;
-sunos6*)
os=`echo $os | sed -e 's|sunos6|solaris3|'`
;;
-osfrose*)
os=-osfrose
;;
-osf*)
os=-osf
;;
-utek*)
os=-bsd
;;
-dynix*)
os=-bsd
;;
-acis*)
os=-aos
;;
-ctix* | -uts*)
os=-sysv
;;
-ns2 )
os=-nextstep2
;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
;;
-sinix*)
os=-sysv4
;;
-triton*)
os=-sysv3
;;
-oss*)
os=-sysv3
;;
-svr4)
os=-sysv4
;;
-svr3)
os=-sysv3
;;
-sysvr4)
os=-sysv4
;;
# This must come after -sysvr4.
-sysv*)
;;
-xenix)
os=-xenix
;;
-none)
;;
*)
# Get rid of the `-' at the beginning of $os.
os=`echo $os | sed 's/[^-]*-//'`
echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
exit 1
;;
esac
else
# Here we handle the default operating systems that come with various machines.
# The value should be what the vendor currently ships out the door with their
# machine or put another way, the most popular os provided with the machine.
# Note that if you're going to try to match "-MANUFACTURER" here (say,
# "-sun"), then you have to tell the case statement up towards the top
# that MANUFACTURER isn't an operating system. Otherwise, code above
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
case $basic_machine in
*-acorn)
os=-riscix1.2
;;
arm*-semi)
os=-aout
;;
pdp11-*)
os=-none
;;
*-dec | vax-*)
os=-ultrix4.2
;;
m68*-apollo)
os=-domain
;;
i386-sun)
os=-sunos4.0.2
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
*-tti) # must be before sparc entry or we get the wrong os.
os=-sysv3
;;
sparc-* | *-sun)
os=-sunos4.1.1
;;
*-be)
os=-beos
;;
s390-ibm)
os=-os390 # /* S/390 -- gil -- 1451 */
;;
*-ibm)
os=-aix
;;
*-hp)
os=-hpux
;;
*-hitachi)
os=-hiux
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=-sysv
;;
*-cbm)
os=-amigaos
;;
*-dg)
os=-dgux
;;
*-dolphin)
os=-sysv3
;;
m68k-ccur)
os=-rtu
;;
m88k-omron*)
os=-luna
;;
*-next )
os=-nextstep
;;
*-sequent)
os=-ptx
;;
*-crds)
os=-unos
;;
*-ns)
os=-genix
;;
i370-*)
os=-mvs
;;
*-next)
os=-nextstep3
;;
*-gould)
os=-sysv
;;
*-highlevel)
os=-bsd
;;
*-encore)
os=-bsd
;;
*-sgi)
os=-irix
;;
*-siemens)
os=-sysv4
;;
*-masscomp)
os=-rtu
;;
f301-fujitsu)
os=-uxpv
;;
*)
os=-none
;;
esac
fi
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
vendor=unknown
case $basic_machine in
*-unknown)
case $os in
-riscix*)
vendor=acorn
;;
-sunos*)
vendor=sun
;;
-aix*)
vendor=ibm
;;
-hpux*)
vendor=hp
;;
-hiux*)
vendor=hitachi
;;
-unos*)
vendor=crds
;;
-dgux*)
vendor=dg
;;
-luna*)
vendor=omron
;;
-genix*)
vendor=ns
;;
-mvs*)
vendor=ibm
;;
-ptx*)
vendor=sequent
;;
-vxsim* | -vxworks*)
vendor=wrs
;;
-aux*)
vendor=apple
;;
esac
basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
;;
esac
echo $basic_machine$os

7085
contrib/ncurses/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,968 @@
dnl***************************************************************************
dnl Copyright (c) 1998,1999 Free Software Foundation, Inc. *
dnl *
dnl Permission is hereby granted, free of charge, to any person obtaining a *
dnl copy of this software and associated documentation files (the *
dnl "Software"), to deal in the Software without restriction, including *
dnl without limitation the rights to use, copy, modify, merge, publish, *
dnl distribute, distribute with modifications, sublicense, and/or sell *
dnl copies of the Software, and to permit persons to whom the Software is *
dnl furnished to do so, subject to the following conditions: *
dnl *
dnl The above copyright notice and this permission notice shall be included *
dnl in all copies or substantial portions of the Software. *
dnl *
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
dnl IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
dnl DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
dnl OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
dnl THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
dnl *
dnl Except as contained in this notice, the name(s) of the above copyright *
dnl holders shall not be used in advertising or otherwise to promote the *
dnl sale, use or other dealings in this Software without prior written *
dnl authorization. *
dnl***************************************************************************
dnl
dnl Author: Thomas E. Dickey <dickey@clark.net> 1996,1997
dnl
dnl $Id: configure.in,v 1.169 1999/08/21 20:33:10 tom Exp $
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.12.971222)
AC_REVISION($Revision: 1.169 $)
AC_INIT(ncurses/base/lib_initscr.c)
AC_CONFIG_HEADER(include/ncurses_cfg.h:include/ncurses_cfg.hin)
CF_SUBST_NCURSES_VERSION
CF_CHECK_CACHE
AC_ARG_WITH(system-type,
[ --with-system-type=XXX test: override derived host system-type],
[AC_MSG_WARN(overriding system type to $withval)
cf_cv_system_name=$withval])
# We need a configure script only when compiling as part of GNU C library.
# Here we have to generate one of the files we need while compiling.
#
# The only problem is that users of the package might think they have to
# run configure themself and find it irritating when nothing happens.
#
# So we try here to find out whether we are called from the glibc configure
# or by a user.
#
dnl Check if we are a drop-in addition to glibc.
AC_ARG_ENABLE(add-ons, dnl
[ --enable-add-ons=DIR... used to check if we are a glibc add-on.],
[glibc_add_on=yes],
[glibc_add_on=])
dnl We need to use [ and ] for other purposes for a while now.
changequote(,)dnl
if test x"$glibc_add_on" = "xyes" ; then
rm -f $srcdir/Banner
# We are in glibc.
rm -f $srcdir/Makefile
cp $srcdir/Makefile.glibc $srcdir/Makefile
echo "ncurses `grep \"^[ ]*ncurses-version[ ]*=.*$\" \
$srcdir/Makefile | sed -e \
's/^[ ]*ncurses-version[ ]*=[ ]*\([^ ^ ]*\)[ ]*$/\1/'`" > $srcdir/Banner
exit 0
fi
changequote([,])dnl
### Save the given $CFLAGS to allow user-override.
cf_user_CFLAGS="$CFLAGS"
### Default install-location
CF_CFG_DEFAULTS
### Checks for programs.
AC_PROG_CC
if test -n "$GCC" ; then
AC_MSG_CHECKING(version of gcc)
eval "$CC --version"
fi
if test $host != $build; then
AC_CHECK_PROGS(BUILD_CC, $CC gcc cc)
fi
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_ISC_POSIX
CF_ANSI_CC_REQD
CF_PROG_EXT
case "$cf_cv_system_name" in
freebsd*) #(vi
test -z "$LDCONFIG" && LDCONFIG="/sbin/ldconfig -R"
;;
*) LDPATH=$PATH:/sbin:/usr/sbin
AC_PATH_PROG(LDCONFIG,ldconfig,,$LDPATH)
;;
esac
AC_SUBST(LDCONFIG)
dnl DEFECT in autoconf 2.12: an attempt to set policy, this breaks the
dnl configure script by not letting us test if C++
dnl is present, making this option necessary.
AC_MSG_CHECKING(if you want to build with C++)
AC_ARG_WITH(cxx,
[ --without-cxx suppress check for C++, don't build demo],
[cf_with_cxx=$withval],
[cf_with_cxx=yes])
AC_MSG_RESULT($cf_with_cxx)
if test "X$cf_with_cxx" != Xno ; then
AC_PROG_CXX
fi
changequote(,)dnl
if test -n "$GXX" ; then case "`${CXX-g++} --version`" in 1*|2.[0-6]*) GXX=""; CXX=""; ac_cv_prog_gxx=no; cf_cxx_library=no ; echo No: templates do not work;; esac; fi
changequote([,])dnl
AC_MSG_CHECKING(if you want to build with Ada95)
AC_ARG_WITH(ada,
[ --without-ada suppress check for Ada95, don't build demo],
[cf_with_ada=$withval],
[cf_with_ada=yes])
AC_MSG_RESULT($cf_with_ada)
AC_MSG_CHECKING(if you want to build programs such as tic)
AC_ARG_WITH(progs,
[ --without-progs suppress build with programs (e.g., tic)],
[cf_with_progs=$withval],
[cf_with_progs=yes])
AC_MSG_RESULT($cf_with_progs)
modules_to_build="ncurses"
if test "X$cf_with_progs" != Xno ; then
modules_to_build="$modules_to_build progs tack"
fi
modules_to_build="$modules_to_build panel menu form"
AC_PROG_AWK
AC_PROG_MAKE_SET
CF_PROG_INSTALL
AC_SYS_LONG_FILE_NAMES
AC_PROG_LN_S
AC_PROG_RANLIB
AC_CHECK_PROGS(LINT, tdlint lint alint)
AC_CHECK_PROGS(MAN, man man_db)
AC_SUBST(LINT_OPTS)
dnl These are standard among *NIX systems, but not when cross-compiling
CF_SUBST(loader,LD,ld)
CF_SUBST(archiver,AR,ar)
CF_SUBST(archiver options,AR_OPTS,rv)
CF_MAKEFLAGS
dnl Special option for use by system-builders: the install-prefix is used to
dnl adjust the location into which the actual install is done, so that an
dnl archive can be built without modifying the host system's configuration.
AC_MSG_CHECKING(if you have specified an install-prefix)
AC_ARG_WITH(install-prefix,
[ --with-install-prefix prefixes actual install-location],
[case "$withval" in #(vi
yes|no) #(vi
;;
*) INSTALL_PREFIX="$withval"
;;
esac])
AC_MSG_RESULT($INSTALL_PREFIX)
AC_SUBST(INSTALL_PREFIX)
###############################################################################
CF_MAN_PAGES
###############################################################################
CF_HELP_MESSAGE(Options to Specify the Libraries Built/Used:)
### Options to allow the user to specify the set of libraries which are used.
### Use "--without-normal --with-shared" to allow the default model to be
### shared, for example.
cf_list_models=""
AC_MSG_CHECKING(if you want to build shared libraries)
AC_ARG_WITH(shared,
[ --with-shared generate shared-libraries],
[with_shared=$withval],
[with_shared=no])
AC_MSG_RESULT($with_shared)
test "$with_shared" = "yes" && cf_list_models="$cf_list_models shared"
AC_MSG_CHECKING(if you want to build static libraries)
AC_ARG_WITH(normal,
[ --with-normal generate normal-libraries (default)],
[with_normal=$withval],
[with_normal=yes])
AC_MSG_RESULT($with_normal)
test "$with_normal" = "yes" && cf_list_models="$cf_list_models normal"
AC_MSG_CHECKING(if you want to build debug libraries)
AC_ARG_WITH(debug,
[ --with-debug generate debug-libraries (default)],
[with_debug=$withval],
[with_debug=yes])
AC_MSG_RESULT($with_debug)
test "$with_debug" = "yes" && cf_list_models="$cf_list_models debug"
AC_MSG_CHECKING(if you want to build profiling libraries)
AC_ARG_WITH(profile,
[ --with-profile generate profile-libraries],
[with_profile=$withval],
[with_profile=no])
AC_MSG_RESULT($with_profile)
test "$with_profile" = "yes" && cf_list_models="$cf_list_models profile"
AC_MSG_CHECKING(if you want to build a separate terminfo library)
AC_ARG_WITH(termlib,
[ --with-termlib generate separate terminfo library],
[with_termlib=$withval],
[with_termlib=no])
AC_MSG_RESULT($with_termlib)
### Checks for special libraries, must be done up-front.
AC_MSG_CHECKING(if you want to link with dbmalloc for testing)
AC_ARG_WITH(dbmalloc,
[ --with-dbmalloc test: use Conor Cahill's dbmalloc library],
[with_dbmalloc=$withval],
[with_dbmalloc=no])
AC_MSG_RESULT($with_dbmalloc)
if test $with_dbmalloc = yes ; then
AC_CHECK_LIB(dbmalloc,debug_malloc)
fi
AC_MSG_CHECKING(if you want to link with dmalloc for testing)
AC_ARG_WITH(dmalloc,
[ --with-dmalloc test: use Gray Watson's dmalloc library],
[with_dmalloc=$withval],
[with_dmalloc=no])
AC_MSG_RESULT($with_dmalloc)
if test $with_dmalloc = yes ; then
AC_CHECK_LIB(dmalloc,dmalloc_debug)
fi
SHLIB_LIST=""
AC_MSG_CHECKING(if you want to link with the gpm mouse library)
AC_ARG_WITH(gpm,
[ --with-gpm use Alessandro Rubini's GPM library],
[with_gpm=$withval],
[with_gpm=no])
AC_MSG_RESULT($with_gpm)
if test $with_gpm = yes ; then
AC_CHECK_LIB(gpm,Gpm_Open,[
EXTRA_LIBS="-lgpm -lncurses $EXTRA_LIBS"
SHLIB_LIST="-lgpm $SHLIB_LIST"
AC_DEFINE(HAVE_LIBGPM)
AC_CHECK_HEADERS(gpm.h)
],,-lcurses -ltermcap)
fi
TINFO_LIST="$SHLIB_LIST"
test $with_termlib = yes && SHLIB_LIST="$SHLIB_LIST -ltinfo"
AC_SUBST(EXTRA_LIBS)
AC_SUBST(TINFO_LIST)
AC_SUBST(SHLIB_LIST)
AC_MSG_CHECKING(for specified models)
test -z "$cf_list_models" && cf_list_models=normal
AC_MSG_RESULT($cf_list_models)
### Use the first model as the default, and save its suffix for use in building
### up test-applications.
DFT_LWR_MODEL=`echo $cf_list_models | $AWK '{print $1}'`
CF_UPPER(DFT_UPR_MODEL,$DFT_LWR_MODEL)dnl
CF_LIB_SUFFIX($DFT_LWR_MODEL,DFT_DEP_SUFFIX)dnl
CF_LIB_TYPE($DFT_LWR_MODEL,DFT_ARG_SUFFIX)dnl
CF_OBJ_SUBDIR($DFT_LWR_MODEL,DFT_OBJ_SUBDIR)dnl
AC_SUBST(DFT_OBJ_SUBDIR)dnl the default object-directory ("obj")
AC_SUBST(DFT_LWR_MODEL)dnl the default model ("normal")
AC_SUBST(DFT_UPR_MODEL)dnl the default model ("NORMAL")
AC_SUBST(DFT_DEP_SUFFIX)dnl the corresponding library-suffix (".a")
AC_SUBST(DFT_ARG_SUFFIX)dnl the string to append to "-lncurses" ("")
AC_SUBST(cf_list_models)dnl the complete list of models ("normal debug")
TINFO_NAME=tinfo
AC_SUBST(TINFO_NAME)
LIB_NAME=ncurses
AC_SUBST(LIB_NAME)
LIB_DIR=../lib
CF_LIB_PREFIX(cf_prefix)
LIB_PREFIX=$LIB_DIR/$cf_prefix
AC_SUBST(LIB_PREFIX)
dnl Not all ports of gcc support the -g option
dnl autoconf 2.12 uses different symbol for -g option than autoconf 2.10, etc.
if test X"$CC_G_OPT" = X"" ; then
CC_G_OPT='-g'
test -n "$GCC" && test "${ac_cv_prog_cc_g}" != yes && CC_G_OPT=''
fi
AC_SUBST(CC_G_OPT)
if test X"$CXX_G_OPT" = X"" ; then
CXX_G_OPT='-g'
test -n "$GXX" && test "${ac_cv_prog_cxx_g}" != yes && CXX_G_OPT=''
fi
AC_SUBST(CXX_G_OPT)
case $DFT_LWR_MODEL in
normal) LD_MODEL='' ;;
debug) LD_MODEL=$CC_G_OPT ;;
profile) LD_MODEL='-pg';;
shared) LD_MODEL='' ;;
esac
AC_SUBST(LD_MODEL)dnl the type of link (e.g., -g or -pg)
AC_MSG_CHECKING(if rpath option should be used)
AC_ARG_ENABLE(rpath,
[ --enable-rpath use rpath option when generating shared libraries],
[cf_cv_ld_rpath=$enableval],
[cf_cv_ld_rpath=no])
AC_MSG_RESULT($cf_cv_ld_rpath)
CF_SHARED_OPTS
if test "$CC_SHARED_OPTS" = "unknown"; then
for model in $cf_list_models; do
if test "$model" = "shared"; then
AC_ERROR(Shared libraries are not supported in this version)
fi
done
fi
###############################################################################
CF_HELP_MESSAGE(Fine-Tuning Your Configuration:)
### use option --disable-overwrite to leave out the link to -lcurses
AC_MSG_CHECKING(if you wish to install ncurses overwriting curses)
AC_ARG_ENABLE(overwrite,
[ --disable-overwrite leave out the link to -lcurses],
[with_overwrite=$enableval
test "$with_overwrite" = no && \
test "x$includedir" = 'x${prefix}/include' && \
includedir='$(prefix)/include/ncurses'
],
[with_overwrite=yes])
AC_MSG_RESULT($with_overwrite)
AC_MSG_CHECKING(where we will install curses.h)
AC_MSG_RESULT($includedir)
AC_MSG_CHECKING(if external terminfo-database is used)
AC_ARG_ENABLE(database,
[ --disable-database use only built-in data],
[with_database=$enableval],
[with_database=yes])
AC_MSG_RESULT($with_database)
test $with_database != no && AC_DEFINE(USE_DATABASE)
AC_MSG_CHECKING(if you want to build with function extensions)
AC_ARG_ENABLE(ext-funcs,
[ --disable-ext-funcs disable function-extensions],
[with_ext_funcs=$enableval],
[with_ext_funcs=yes])
AC_MSG_RESULT($with_ext_funcs)
test "$with_ext_funcs" = yes && AC_DEFINE(NCURSES_EXT_FUNCS)
AC_MSG_CHECKING(for list of fallback descriptions)
AC_ARG_WITH(fallbacks,
[ --with-fallbacks=XXX specify list of fallback terminal descriptions],
[with_fallback=$withval],
[with_fallback=])
AC_MSG_RESULT($with_fallback)
FALLBACK_LIST=`echo $with_fallback|sed -e 's/,/ /g'`
AC_SUBST(FALLBACK_LIST)
AC_MSG_CHECKING(for list of terminfo directories)
CF_WITH_PATHLIST(terminfo-dirs,
[ --with-terminfo-dirs=XXX specify list of terminfo directories],
TERMINFO_DIRS,
DATADIR/terminfo,
${datadir}/terminfo)
AC_MSG_RESULT($TERMINFO_DIRS)
test -n "$TERMINFO_DIRS" && AC_DEFINE_UNQUOTED(TERMINFO_DIRS,"$TERMINFO_DIRS")
if test $with_database = no ; then
if test -z $with_fallback ; then
AC_ERROR(You have disabled the database w/o specifying fallbacks)
fi
fi
### use option --disable-big-core to make tic run on small machines
### We need 4Mb, check if we can allocate 50% more than that.
AC_MSG_CHECKING(if big-core option selected)
AC_ARG_ENABLE(big-core,
[ --disable-big-core assume machine has little memory],
[with_big_core=$enableval],
[AC_TRY_RUN([
#include <stdlib.h>
#include <string.h>
int main() { exit(malloc(6000000L) == 0); }],
[with_big_core=yes],
[with_big_core=no],
[with_big_core=no])])
AC_MSG_RESULT($with_big_core)
test "$with_big_core" = "yes" && AC_DEFINE(HAVE_BIG_CORE)
### use option --enable-termcap to compile in the termcap fallback support
AC_MSG_CHECKING(if you want termcap-fallback support)
AC_ARG_ENABLE(termcap,
[ --enable-termcap compile in termcap fallback support],
[with_termcap=$enableval],
[with_termcap=no])
AC_MSG_RESULT($with_termcap)
if test "$with_termcap" != "yes" ; then
AC_DEFINE(PURE_TERMINFO)
else
### use option --enable-getcap to use a hacked getcap for reading termcaps
AC_MSG_CHECKING(if fast termcap-loader is needed)
AC_ARG_ENABLE(getcap,
[ --enable-getcap fast termcap load, no xrefs to terminfo],
[with_getcap=$enableval],
[with_getcap=no])
AC_MSG_RESULT($with_getcap)
test "$with_getcap" = "yes" && AC_DEFINE(USE_GETCAP)
AC_MSG_CHECKING(if translated termcaps will be cached in ~/.terminfo)
AC_ARG_ENABLE(getcap-cache,
[ --enable-getcap-cache cache translated termcaps in ~/.terminfo],
[with_getcap_cache=$enableval],
[with_getcap_cache=no])
AC_MSG_RESULT($with_getcap_cache)
test "$with_getcap_cache" = "yes" && AC_DEFINE(USE_GETCAP_CACHE)
fi
### Use option --enable-symlinks to make tic use symlinks, not hard links
### to reduce storage requirements for the terminfo database.
CF_LINK_FUNCS
with_links=no
with_symlinks=no
if test "$ac_cv_func_link" != yes ; then
AC_MSG_CHECKING(if tic should use symbolic links)
if test "$ac_cv_func_symlink" = yes ; then
with_symlinks=yes
else
with_symlinks=no
fi
AC_MSG_RESULT($with_symlinks)
elif test "$ac_cv_func_symlink" != yes ; then
AC_MSG_CHECKING(if tic should use hard links)
if test "$ac_cv_func_link" = yes ; then
with_links=yes
else
with_links=no
fi
AC_MSG_RESULT($with_links)
else
AC_MSG_CHECKING(if tic should use symbolic links)
AC_ARG_ENABLE(symlinks,
[ --enable-symlinks make tic use symbolic links not hard links],
[with_symlinks=$enableval],
[with_symlinks=no])
AC_MSG_RESULT($with_symlinks)
fi
test "$with_links" = yes && AC_DEFINE(USE_LINKS)
test "$with_symlinks" = yes && AC_DEFINE(USE_SYMLINKS)
### use option --enable-bsdpad to have tputs process BSD-style prefix padding
AC_MSG_CHECKING(if tputs should process BSD-style prefix padding)
AC_ARG_ENABLE(bsdpad,
[ --enable-bsdpad recognize BSD-style prefix padding],
[with_bsdpad=$enableval],
[with_bsdpad=no])
AC_MSG_RESULT($with_bsdpad)
test "$with_bsdpad" = yes && AC_DEFINE(BSD_TPUTS)
### use option --enable-const to turn on use of const beyond that in XSI.
AC_MSG_CHECKING(for extended use of const keyword)
AC_ARG_ENABLE(const,
[ --enable-const compile with extra/non-standard const],
[with_ext_const=$enableval],
[with_ext_const=no])
AC_MSG_RESULT($with_ext_const)
NCURSES_CONST=""
if test "$with_ext_const" = yes ; then
AC_DEFINE(NCURSES_CONST,const)
NCURSES_CONST=const
fi
AC_SUBST(NCURSES_CONST)
### Enable compiling-in rcs id's
AC_MSG_CHECKING(if RCS identifiers should be compiled-in)
AC_ARG_WITH(rcs-ids,
[ --with-rcs-ids compile-in RCS identifiers],
[with_rcs_ids=$withval],
[with_rcs_ids=no])
AC_MSG_RESULT($with_rcs_ids)
test "$with_rcs_ids" = yes && AC_DEFINE(USE_RCS_IDS)
###############################################################################
CF_HELP_MESSAGE(Experimental Code:)
AC_MSG_CHECKING(if you want all experimental code)
AC_ARG_WITH(develop,
[ --with-develop enable all experimental options for testing],
[with_develop=$withval],
[with_develop=no])
AC_MSG_RESULT($with_develop)
### use option --enable-broken-linker to force on use of broken-linker support
AC_MSG_CHECKING(if you want broken-linker support code)
AC_ARG_ENABLE(broken_linker,
[ --enable-broken_linker compile with broken-linker support code],
[with_broken_linker=$enableval],
[with_broken_linker=$BROKEN_LINKER])
AC_MSG_RESULT($with_broken_linker)
test "$with_broken_linker" = yes && AC_DEFINE(BROKEN_LINKER)
### use option --enable-hard-tabs to turn on use of hard-tabs optimize
AC_MSG_CHECKING(if you want experimental hard-tabs code)
AC_ARG_ENABLE(hard-tabs,
[ --enable-hard-tabs compile with experimental hard-tabs code],
[with_hardtabs=$enableval],
[with_hardtabs=$with_develop])
AC_MSG_RESULT($with_hardtabs)
test "$with_hardtabs" = yes && AC_DEFINE(USE_HARD_TABS)
### use option --enable-hashmap to turn on use of hashmap scrolling logic
AC_MSG_CHECKING(if you want experimental hashmap code)
AC_ARG_ENABLE(hashmap,
[ --enable-hashmap compile with experimental hashmap code],
[with_hashmap=$enableval],
[with_hashmap=yes])
AC_MSG_RESULT($with_hashmap)
test "$with_hashmap" = yes && AC_DEFINE(USE_HASHMAP)
AC_MSG_CHECKING(if you want experimental no-padding code)
AC_ARG_ENABLE(no-padding,
[ --enable-no-padding compile with experimental no-padding code],
[with_no_padding=$enableval],
[with_no_padding=yes])
AC_MSG_RESULT($with_no_padding)
test "$with_no_padding" = yes && AC_DEFINE(NCURSES_NO_PADDING)
AC_MSG_CHECKING(if you want experimental safe-sprintf code)
AC_ARG_ENABLE(safe-sprintf,
[ --enable-safe-sprintf compile with experimental safe-sprintf code],
[with_safe_sprintf=$enableval],
[with_safe_sprintf=no])
AC_MSG_RESULT($with_safe_sprintf)
test "$with_safe_sprintf" = yes && AC_DEFINE(USE_SAFE_SPRINTF)
### use option --disable-scroll-hints to turn off use of scroll-hints scrolling logic
AC_MSG_CHECKING(if you want to experiment without scrolling-hints code)
AC_ARG_ENABLE(scroll-hints,
[ --disable-scroll-hints compile hashmap without scroll-hints code],
[with_scroll_hints=$enableval],
[with_scroll_hints=yes;
# when hashmap is used scroll hints are useless
test $with_hashmap = yes && with_scroll_hints=no])
AC_MSG_RESULT($with_scroll_hints)
test "$with_scroll_hints" = yes && AC_DEFINE(USE_SCROLL_HINTS)
### use option --enable-tcap-names to allow user to define new capabilities
AC_MSG_CHECKING(if you want experimental definable names like termcap)
AC_ARG_ENABLE(tcap-names,
[ --enable-tcap-names compile with experimental definable-name code],
[with_tcap_names=$enableval],
[with_tcap_names=$with_develop])
AC_MSG_RESULT($with_tcap_names)
NCURSES_XNAMES=0
test "$with_tcap_names" = yes && NCURSES_XNAMES=1
AC_SUBST(NCURSES_XNAMES)
### use option --enable-sigwinch to turn on use of SIGWINCH logic
AC_MSG_CHECKING(if you want experimental SIGWINCH handler)
AC_ARG_ENABLE(sigwinch,
[ --enable-sigwinch compile with experimental SIGWINCH handler],
[with_sigwinch=$enableval],
[with_sigwinch=yes])
AC_MSG_RESULT($with_sigwinch)
test "$with_sigwinch" = yes && AC_DEFINE(USE_SIGWINCH)
### use option --enable-widec to turn on use of wide-character support
AC_MSG_CHECKING(if you want experimental wide-character code)
AC_ARG_ENABLE(widec,
[ --enable-widec compile with experimental wide-char code],
[with_widec=$enableval],
[with_widec=no])
AC_MSG_RESULT($with_widec)
test "$with_widec" = yes && AC_DEFINE(USE_WIDEC_SUPPORT)
### use option --enable-xmc-glitch to turn on use of magic-cookie optimize
AC_MSG_CHECKING(if you want experimental xmc code)
AC_ARG_ENABLE(xmc-glitch,
[ --enable-xmc-glitch compile with experimental xmc code],
[with_xmc_glitch=$enableval],
[with_xmc_glitch=$with_develop])
AC_MSG_RESULT($with_xmc_glitch)
test "$with_xmc_glitch" = yes && AC_DEFINE(USE_XMC_SUPPORT)
###############################################################################
CF_HELP_MESSAGE(Testing/development Options:)
### use option --disable-echo to suppress full display compiling commands
AC_ARG_ENABLE(echo,
[ --enable-echo build: display "compiling" commands (default)],
[with_echo=$enableval],
[with_echo=yes])
if test "$with_echo" = yes; then
ECHO_LINK=
else
ECHO_LINK='@ echo linking $@ ... ;'
fi
AC_SUBST(ECHO_LINK)
### use option --enable-warnings to turn on all gcc warnings
AC_ARG_ENABLE(warnings,
[ --enable-warnings build: turn on GCC compiler warnings],
[with_warnings=$enableval])
if test -n "$with_warnings"; then
ADAFLAGS="$ADAFLAGS -gnatg"
CF_GCC_WARNINGS
fi
CF_GCC_ATTRIBUTES
### use option --enable-assertions to turn on generation of assertion code
AC_ARG_ENABLE(assertions,
[ --enable-assertions test: turn on generation of assertion code],
[with_assertions=$enableval],
[with_assertions=no])
if test -n "$GCC"
then
if test $with_assertions = no
then
AC_DEFINE(NDEBUG)
CPPFLAGS="$CPPFLAGS -DNDEBUG"
else
ADAFLAGS="$ADAFLAGS -gnata"
fi
fi
### use option --disable-leaks to suppress "permanent" leaks, for testing
AC_ARG_ENABLE(leaks,
[ --disable-leaks test: suppress permanent memory-leaks],
[test $enableval = no && AC_DEFINE(NO_LEAKS)])
AC_DEFINE(HAVE_NC_ALLOC_H)
### use option --enable-expanded to generate certain macros as functions
AC_ARG_ENABLE(expanded,
[ --enable-expanded test: generate functions for certain macros],
[test $enableval = yes && AC_DEFINE(NCURSES_EXPANDED)])
### use option --disable-macros to suppress macros in favor of functions
AC_ARG_ENABLE(macros,
[ --disable-macros test: use functions rather than macros],
[test $enableval = no && AC_DEFINE(NCURSES_NOMACROS)])
### Checks for libraries.
AC_CHECK_FUNC(gettimeofday,
AC_DEFINE(HAVE_GETTIMEOFDAY),[
AC_CHECK_LIB(bsd, gettimeofday,
AC_DEFINE(HAVE_GETTIMEOFDAY)
LIBS="$LIBS -lbsd")])dnl CLIX: bzero, select, gettimeofday
MATH_LIB=""
AC_CHECK_FUNC(sin,,
AC_CHECK_LIB(m, sin,[MATH_LIB="-lm"]))
AC_SUBST(MATH_LIB)
### Checks for header files.
AC_STDC_HEADERS
AC_HEADER_DIRENT
CF_REGEX
dnl These are some other potentially nonportable headers.
AC_CHECK_HEADERS( \
fcntl.h \
getopt.h \
libc.h \
limits.h \
locale.h \
sys/bsdtypes.h \
sys/ioctl.h \
sys/param.h \
poll.h \
sys/select.h \
sys/stropts.h \
sys/time.h \
sys/times.h \
termio.h \
termios.h \
ttyent.h \
unistd.h \
values.h \
)
# check for ISC (this may also define _POSIX_SOURCE)
# Note: even non-Posix ISC needs <sys/bsdtypes.h> to declare fd_set
if test "$ISC" = yes ; then
AC_CHECK_LIB(cposix,main)
AC_CHECK_LIB(inet,bzero,LIBS="$LIBS -linet")dnl also 'select()'
AC_CHECK_HEADERS( sys/termio.h )
fi
CF_SYS_TIME_SELECT
### checks for compiler characteristics
AC_LANG_C
AC_C_CONST
AC_C_INLINE
test $ac_cv_c_inline != no && AC_DEFINE(CC_HAS_INLINE_FUNCS)
CF_TYPEOF_CHTYPE
CF_WIDEC_SHIFT
### Checks for external-data
CF_ERRNO
CF_LINK_DATAONLY
CF_SPEED_TYPE
### Checks for library functions.
AC_CHECK_FUNCS( getcwd \
getttynam \
memccpy \
nanosleep \
poll \
remove \
select \
setbuf \
setbuffer \
setvbuf \
sigaction \
sigvec \
strdup \
strstr \
tcgetattr \
tcgetpgrp \
times \
usleep \
vfscanf \
vsnprintf \
vsscanf \
)
if test "$with_getcap" = "yes" ; then
CF_CGETENT
fi
CF_ISASCII
CF_STRUCT_SIGACTION
CF_STRUCT_TERMIOS
dnl FIXME (may need this) AC_SYS_RESTARTABLE_SYSCALLS
if test "$cross_compiling" = yes ; then
AC_MSG_WARN(cross compiling: assume setvbuf params not reversed)
else
AC_FUNC_SETVBUF_REVERSED
fi
AC_TYPE_SIGNAL
CF_TYPE_SIGACTION
CF_SIZECHANGE
CF_FUNC_MEMMOVE
dnl We'll do our own -g libraries, unless the user's overridden via $CFLAGS
if test -z "$cf_user_CFLAGS" ; then
CF_STRIP_G_OPT(CFLAGS)
CF_STRIP_G_OPT(CXXFLAGS)
fi
dnl Check for C++ compiler characteristics (and ensure that it's there!)
CF_BOOL_DECL(cf_cv_cc_bool_type)
if test -n "$CXX" ; then
AC_LANG_CPLUSPLUS
case "`${CXX-g++} --version`" in
2.7*)
CF_CXX_LIBRARY
;;
*)
cf_cxx_library=yes
;;
esac
AC_CHECK_HEADERS(builtin.h typeinfo)
CF_BOOL_DECL
CF_BOOL_SIZE
CF_ETIP_DEFINES
else
cf_cxx_library=no
cf_cv_builtin_bool=0
# Just because we are not configuring against C++ right now does not
# mean that a user will not want to use C++. Some distributors disable
# the C++ portion of this configuration as a shortcut (or just to avoid
# compiling the demo in the c++ directory). So we need a reasonable
# default for the 'bool' type.
#
# Caveat: since the storage of the bool type is not standardized, it
# may change.
AC_MSG_CHECKING(for fallback type of bool)
case "$host_cpu" in #(vi
i?86) cf_cv_type_of_bool=char ;; #(vi
*) cf_cv_type_of_bool=int ;;
esac
AC_MSG_RESULT($cf_cv_type_of_bool)
fi
AC_SUBST(CXXLIBS)
CF_HELP_MESSAGE(Ada95 Binding Options:)
dnl Check for availability of GNU Ada Translator (GNAT).
dnl At the moment we support no other Ada95 compiler.
if test "$cf_with_ada" != "no" ; then
cf_ada_make=gnatmake
AC_CHECK_PROG(gnat_exists, $cf_ada_make, yes, no)
if test "$ac_cv_prog_gnat_exists" = no; then
cf_ada_make=
else
CF_GNAT_VERSION
AC_CHECK_PROG(m4_exists, m4, yes, no)
if test "$ac_cv_prog_m4_exists" = no; then
cf_cv_prog_gnat_correct=no
echo Ada95 binding required program m4 not found. Ada95 binding disabled.
fi
if test "$cf_cv_prog_gnat_correct" = yes; then
AC_MSG_CHECKING(if GNAT works)
CF_GNAT_TRY_RUN([procedure conftest;],
[with Text_IO;
with GNAT.OS_Lib;
procedure conftest is
begin
Text_IO.Put ("Hello World");
Text_IO.New_Line;
GNAT.OS_Lib.OS_Exit (0);
end conftest;],[cf_cv_prog_gnat_correct=yes],[cf_cv_prog_gnat_correct=no])
AC_MSG_RESULT($cf_cv_prog_gnat_correct)
fi
fi
if test "$cf_cv_prog_gnat_correct" = yes; then
ADAFLAGS="-O3 -gnatpn $ADAFLAGS"
AC_ARG_WITH(ada-compiler,
[ --with-ada-compiler=CMD Specify Ada95 compiler command (default gnatmake)],
[cf_ada_compiler=$withval],
[cf_ada_compiler=gnatmake])
cf_ada_package=terminal_interface
AC_SUBST(cf_ada_make)
AC_SUBST(cf_ada_compiler)
AC_SUBST(cf_ada_package)
AC_SUBST(ADAFLAGS)
AC_SUBST(cf_compile_generics)
AC_SUBST(cf_generic_objects)
CF_WITH_PATH(ada-include,
[ --with-ada-include=DIR Ada includes are in DIR],
ADA_INCLUDE,
PREFIX/lib/gnu-Ada/adainclude,
[$]prefix/lib/gnu-Ada/adainclude)
AC_SUBST(ADA_INCLUDE)
CF_WITH_PATH(ada-objects,
[ --with-ada-objects=DIR Ada objects are in DIR],
ADA_OBJECTS,
PREFIX/lib/gnu-Ada/adalib,
[$]prefix/lib/gnu-Ada/adalib)
AC_SUBST(ADA_OBJECTS)
if test $with_shared = no
then
AC_MSG_WARN(Ada95 applications will not link properly with static libraries)
fi
fi
fi
### It's not possible to appease gcc 2.6.3's conversion-warnings if we're
### using a 'char' for bools. gcc 2.7.0's conversion-warnings are broken too
### badly to consider using for development purposes, but 2.5.8 is okay.
if test -n "$with_warnings"; then
if test -n "$GCC"; then
case "`$CC --version`" in
2.6.3)
if test "$cf_cv_type_of_bool" != "char"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wconversion"
fi
;;
2.5*)
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wconversion"
;;
esac
fi
fi
### Construct the library-subsets, if any, from this set of keywords:
### none, base, ext_funcs, termlib.
AC_MSG_CHECKING(for library subsets)
if test "$with_termlib" = yes ; then
LIB_SUBSETS="termlib "
else
LIB_SUBSETS="termlib+"
fi
LIB_SUBSETS="${LIB_SUBSETS}base"
test "$with_ext_funcs" = yes && LIB_SUBSETS="${LIB_SUBSETS}+ext_funcs"
AC_MSG_RESULT($LIB_SUBSETS)
### Construct the list of include-directories to be generated
CF_INCLUDE_DIRS
CF_ADA_INCLUDE_DIRS
### Set up low-level terminfo dependencies for makefiles. Note that we
### could override this.
if test "$with_termlib" = yes ; then
TEST_DEPS="${LIB_PREFIX}${TINFO_NAME}${DFT_DEP_SUFFIX}"
TEST_ARGS="-l${TINFO_NAME}${DFT_ARG_SUFFIX}"
fi
PROG_DEPS="$TEST_DEPS"
PROG_ARGS="$TEST_ARGS"
### Construct the list of subdirectories for which we'll customize makefiles
### with the appropriate compile-rules.
CF_SRC_MODULES($modules_to_build)
CF_DIRS_TO_MAKE
### Now that we're done running tests, add the compiler-warnings, if any
CFLAGS="$CFLAGS $EXTRA_CFLAGS"
################################################################################
AC_OUTPUT( \
include/MKterm.h.awk \
include/curses.h \
include/termcap.h \
include/unctrl.h \
$SUB_MAKEFILES \
Makefile,[
CF_LIB_RULES
],[
### Special initialization commands, used to pass information from the
### configuration-run into config.status
AWK="$AWK"
CF_LIST_MODELS="$cf_list_models"
DFT_LWR_MODEL="$DFT_LWR_MODEL"
LDCONFIG="$LDCONFIG"
LIB_NAME="$LIB_NAME"
LIB_SUBSETS="$LIB_SUBSETS"
SRC_SUBDIRS="$SRC_SUBDIRS"
TINFO_NAME="$TINFO_NAME"
WITH_ECHO="$with_echo"
WITH_OVERWRITE="$with_overwrite"
cf_cv_abi_version="$cf_cv_abi_version"
cf_cv_do_symlinks="$cf_cv_do_symlinks"
cf_cv_rel_version="$cf_cv_rel_version"
cf_cv_rm_so_locs="$cf_cv_rm_so_locs"
cf_cv_system_name="$cf_cv_system_name"
cf_cxx_library="$cf_cxx_library"
target="$target"
],sort)dnl
${MAKE-make} preinstall

View File

@ -0,0 +1,54 @@
extproc perl -S -w
# The converted script is written to stdout, so run this script as
# convert_configure configure > configure.cmd
#
# When the converted script runs, it expects that /tmp dir is
# available (so we create it).
#
# run the result like this:
# .\configure
;
mkdir '/tmp', 0777 unless -d '/tmp';
print <<EOF;
extproc sh
# Make sensible defaults:
CC="gcc -Zexe"
export CC
#GCCOPT="$GCCOPT -Zexe"
#export GCCOPT
CONFIG_SHELL=sh
EOF
$checking_path = 0;
while (<>) {
if (/for\s+(\w+)\s+in\s*\$PATH\s*;/) {
$checking_path = 1;
$varname = $1;
$subst= <<EOS
$varname="`echo -E \\"\$$varname\\" | tr \\\\\\\\\\\\\\\\ / `"
EOS
}
$checking_path = 0 if /^\s*done\s*$/;
# We want to create an extra line like this one:
# ac_dir="`echo -E \"$ac_dir\" | tr \\\\\\\\ / `"
s{^((\s*)if\s+test)\s*-f\s*(\$$varname/\S+)\s*;}
{$2$subst$1 -f $3 -o -f $3.exe ;}
if $checking_path; # Checking for executables
s/^host=NONE$/host=os2/; # Make default host
s/"\$\{IFS}:"$/"\${IFS};"/; # Fix IFS line
s/\btest\s+-s\s+conftest\b/test -f conftest/g; # Fix exe test
# This one is needed for curses:
s/host=`\$ac_config_sub \$host_alias`/$&\nif test -z "$host"; then host=\$host_alias; fi/;
s,/bin/sh(?![/\w]),sh,g;
print;
}
__END__
Changes: 98/11 : support check for executables in ncurses.

62
contrib/ncurses/dist.mk Normal file
View File

@ -0,0 +1,62 @@
# $Id: dist.mk,v 1.162 1999/08/21 23:40:17 tom Exp $
# Makefile for creating ncurses distributions.
#
# This only needs to be used directly as a makefile by developers, but
# configure mines the current version number out of here. To move
# to a new version number, just edit this file and run configure.
#
SHELL = /bin/sh
# These define the major/minor/patch versions of ncurses.
NCURSES_MAJOR = 5
NCURSES_MINOR = 0
NCURSES_PATCH = 990821
# We don't append the patch to the version, since this only applies to releases
VERSION = $(NCURSES_MAJOR).$(NCURSES_MINOR)
DUMP = lynx -dump
DUMP2 = $(DUMP) -nolist
ALL = ANNOUNCE announce.html misc/ncurses-intro.doc misc/hackguide.doc
all : $(ALL)
dist: $(ALL)
(cd ..; tar cvf ncurses-$(VERSION).tar `sed <ncurses-$(VERSION)/MANIFEST 's/^./ncurses-$(VERSION)/'`; gzip ncurses-$(VERSION).tar)
distclean:
rm -f $(ALL)
# Don't mess with announce.html.in unless you have lynx available!
announce.html: announce.html.in
sed 's,@VERSION@,$(VERSION),' <announce.html.in >announce.html
ANNOUNCE : announce.html
$(DUMP) announce.html >ANNOUNCE
misc/ncurses-intro.doc: misc/ncurses-intro.html
$(DUMP2) misc/ncurses-intro.html > misc/ncurses-intro.doc
misc/hackguide.doc: misc/hackguide.html
$(DUMP2) misc/hackguide.html > misc/hackguide.doc
# Prepare distribution for version control
vcprepare:
find . -type d -exec mkdir {}/RCS \;
# Write-lock almost all files not under version control.
ADA_EXCEPTIONS=$(shell eval 'a="\\\\\|";for x in Ada95/gen/terminal*.m4; do echo -n $${a}Ada95/ada_include/`basename $${x} .m4`; done')
EXCEPTIONS = 'announce.html$\\|ANNOUNCE\\|misc/.*\\.doc\\|man/terminfo.5\\|lib_gen.c'$(ADA_EXCEPTIONS)
writelock:
for x in `grep -v $(EXCEPTIONS) MANIFEST`; do if [ ! -f `dirname $$x`/RCS/`basename $$x`,v ]; then chmod a-w $${x}; fi; done
# This only works on a clean source tree, of course.
MANIFEST:
-rm -f $@
touch $@
find . -type f -print |sort | fgrep -v .lsm |fgrep -v .spec >$@
TAGS:
etags */*.[ch]
# Makefile ends here

View File

@ -0,0 +1,148 @@
# $Id: Makefile.in,v 1.25 1998/04/04 00:49:55 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 form source code.
#
# This makes the following:
# 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,
# turn off _all_ suffix rules; we'll generate our own
.SUFFIXES:
SHELL = /bin/sh
THIS = Makefile
MODEL = @DFT_LWR_MODEL@
INSTALL_PREFIX = @INSTALL_PREFIX@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
includedir = @includedir@
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@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@ \
-DHAVE_CONFIG_H
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
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) -lncurses @SHLIB_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 = -lform -lncurses @LIBS@
AUTO_SRC = \
../include/form.h
################################################################################
all \
install :: $(AUTO_SRC) $(LIBRARIES)
sources : $(AUTO_SRC)
$(INSTALL_PREFIX)$(libdir) :
$(srcdir)/../mkinstalldirs $@
# make copies to simplify include-paths while still keeping form's include
# file in this directory.
../include/form.h : $(srcdir)/form.h
-rm -f $@
cp $(srcdir)/form.h $@
FORM_PRIV_H = \
$(srcdir)/form.priv.h \
$(srcdir)/form.h \
../include/mf_common.h \
../include/curses.h \
../include/eti.h
tags:
ctags *.[ch]
TAGS:
etags *.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.ln *.atac trace
clean :: mostlyclean
-rm -f $(AUTO_SRC)
distclean :: clean
-rm -f Makefile
realclean :: distclean
../include/mf_common.h \
../include/eti.h :
cd ../menu && $(MAKE) $@
###############################################################################
# The remainder of this file is automatically generated during configuration
###############################################################################

View File

@ -0,0 +1,15 @@
This is a clone of the form library that is available with typical
System V curses implementations (ETI).
It is modelled after the documentation that comes for this library with
a 386 based SVR4 implementation (ESIX).
The development environment was and is an ELF based Linux system.
For things that still need doing, see the TO-DO file in the top-level
directory.
Juergen Pfeifer
eMail: juergen.pfeifer@gmx.net

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_arg.c,v 1.4 1999/05/16 17:16:04 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_fieldtype_arg(
| FIELDTYPE *typ,
| void * (* const make_arg)(va_list *),
| void * (* const copy_arg)(const void *),
| void (* const free_arg)(void *) )
|
| Description : Connects to the type additional arguments necessary
| for a set_field_type call. The various function pointer
| arguments are:
| make_arg : allocates a structure for the field
| specific parameters.
| copy_arg : duplicate the structure created by
| make_arg
| free_arg : Release the memory allocated by make_arg
| or copy_arg
|
| At least make_arg must be non-NULL.
| You may pass NULL for copy_arg and free_arg if your
| make_arg function doesn't allocate memory and your
| arg fits into the storage for a (void*).
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
int set_fieldtype_arg(FIELDTYPE * typ,
void * (* const make_arg)(va_list *),
void * (* const copy_arg)(const void *),
void (* const free_arg)(void *))
{
if ( !typ || !make_arg )
RETURN(E_BAD_ARGUMENT);
typ->status |= _HAS_ARGS;
typ->makearg = make_arg;
typ->copyarg = copy_arg;
typ->freearg = free_arg;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void *field_arg(const FIELD *field)
|
| Description : Retrieve pointer to the fields argument structure.
|
| Return Values : Pointer to structure or NULL if none is defined.
+--------------------------------------------------------------------------*/
void *field_arg(const FIELD * field)
{
return Normalize_Field(field)->arg;
}
/* fld_arg.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_attr.c,v 1.4 1999/05/16 17:16:30 juergen Exp $")
/*----------------------------------------------------------------------------
Field-Attribute manipulation routines
--------------------------------------------------------------------------*/
/* "Template" macro to generate a function to set a fields attribute */
#define GEN_FIELD_ATTR_SET_FCT( name ) \
int set_field_ ## name (FIELD * field, chtype attr)\
{\
int res = E_BAD_ARGUMENT;\
if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
{\
Normalize_Field( field );\
if ((field -> name) != attr)\
{\
field -> name = attr;\
res = _nc_Synchronize_Attributes( field );\
}\
else\
res = E_OK;\
}\
RETURN(res);\
}
/* "Template" macro to generate a function to get a fields attribute */
#define GEN_FIELD_ATTR_GET_FCT( name ) \
chtype field_ ## name (const FIELD * field)\
{\
return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_fore(FIELD *field, chtype attr)
|
| Description : Sets the foreground of the field used to display the
| field contents.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
GEN_FIELD_ATTR_SET_FCT( fore )
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : chtype field_fore(const FIELD *)
|
| Description : Retrieve fields foreground attribute
|
| Return Values : The foreground attribute
+--------------------------------------------------------------------------*/
GEN_FIELD_ATTR_GET_FCT( fore )
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_back(FIELD *field, chtype attr)
|
| Description : Sets the background of the field used to display the
| fields extend.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
GEN_FIELD_ATTR_SET_FCT( back )
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : chtype field_back(const
|
| Description : Retrieve fields background attribute
|
| Return Values : The background attribute
+--------------------------------------------------------------------------*/
GEN_FIELD_ATTR_GET_FCT( back )
/* fld_attr.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_current.c,v 1.4 1999/05/16 17:16:46 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_current_field(FORM * form,FIELD * field)
|
| Description : Set the current field of the form to the specified one.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid form or field pointer
| E_REQUEST_DENIED - field not selectable
| E_BAD_STATE - called from a hook routine
| E_INVALID_FIELD - current field can't be left
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_current_field(FORM * form, FIELD * field)
{
int err = E_OK;
if ( !form || !field )
RETURN(E_BAD_ARGUMENT);
if ( (form != field->form) || Field_Is_Not_Selectable(field) )
RETURN(E_REQUEST_DENIED);
if (!(form->status & _POSTED))
{
form->current = field;
form->curpage = field->page;
}
else
{
if (form->status & _IN_DRIVER)
err = E_BAD_STATE;
else
{
if (form->current != field)
{
if (!_nc_Internal_Validation(form))
err = E_INVALID_FIELD;
else
{
Call_Hook(form,fieldterm);
if (field->page != form->curpage)
{
Call_Hook(form,formterm);
err = _nc_Set_Form_Page(form,field->page,field);
Call_Hook(form,forminit);
}
else
{
err = _nc_Set_Current_Field(form,field);
}
Call_Hook(form,fieldinit);
_nc_Refresh_Current_Field(form);
}
}
}
}
RETURN(err);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD *current_field(const FORM * form)
|
| Description : Return the current field.
|
| Return Values : Pointer to the current field.
+--------------------------------------------------------------------------*/
FIELD *current_field(const FORM * form)
{
return Normalize_Form(form)->current;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_index(const FIELD * field)
|
| Description : Return the index of the field in the field-array of
| the form.
|
| Return Values : >= 0 : field index
| -1 : fieldpointer invalid or field not connected
+--------------------------------------------------------------------------*/
int field_index(const FIELD * field)
{
return ( (field && field->form) ? field->index : -1 );
}
/* fld_current.c ends here */

View File

@ -0,0 +1,346 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_def.c,v 1.12 1999/05/16 17:37:48 juergen Exp $")
/* this can't be readonly */
static FIELD default_field = {
0, /* status */
0, /* rows */
0, /* cols */
0, /* frow */
0, /* fcol */
0, /* drows */
0, /* dcols */
0, /* maxgrow*/
0, /* nrow */
0, /* nbuf */
NO_JUSTIFICATION, /* just */
0, /* page */
0, /* index */
(int)' ', /* pad */
A_NORMAL, /* fore */
A_NORMAL, /* back */
ALL_FIELD_OPTS, /* opts */
(FIELD *)0, /* snext */
(FIELD *)0, /* sprev */
(FIELD *)0, /* link */
(FORM *)0, /* form */
(FIELDTYPE *)0, /* type */
(char *)0, /* arg */
(char *)0, /* buf */
(char *)0 /* usrptr */
};
FIELD *_nc_Default_Field = &default_field;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : TypeArgument *_nc_Make_Argument(
| const FIELDTYPE *typ,
| va_list *ap,
| int *err )
|
| Description : Create an argument structure for the specified type.
| Use the type-dependant argument list to construct
| it.
|
| Return Values : Pointer to argument structure. Maybe NULL.
| In case of an error in *err an errorcounter is increased.
+--------------------------------------------------------------------------*/
TypeArgument*
_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
if (typ && (typ->status & _HAS_ARGS))
{
assert(err && ap);
if (typ->status & _LINKED_TYPE)
{
p = (TypeArgument *)malloc(sizeof(TypeArgument));
if (p)
{
p->left = _nc_Make_Argument(typ->left ,ap,err);
p->right = _nc_Make_Argument(typ->right,ap,err);
return p;
}
else
*err += 1;
} else
{
assert(typ->makearg);
if ( !(res=(TypeArgument *)typ->makearg(ap)) )
*err += 1;
}
}
return res;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ,
| const TypeArgument *argp,
| int *err )
|
| Description : Create a copy of an argument structure for the specified
| type.
|
| Return Values : Pointer to argument structure. Maybe NULL.
| In case of an error in *err an errorcounter is increased.
+--------------------------------------------------------------------------*/
TypeArgument*
_nc_Copy_Argument(const FIELDTYPE *typ,
const TypeArgument *argp, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
if ( typ && (typ->status & _HAS_ARGS) )
{
assert(err && argp);
if (typ->status & _LINKED_TYPE)
{
p = (TypeArgument *)malloc(sizeof(TypeArgument));
if (p)
{
p->left = _nc_Copy_Argument(typ,argp->left ,err);
p->right = _nc_Copy_Argument(typ,argp->right,err);
return p;
}
*err += 1;
}
else
{
if (typ->copyarg)
{
if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
*err += 1;
}
else
res = (TypeArgument *)argp;
}
}
return res;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void _nc_Free_Argument(const FIELDTYPE *typ,
| TypeArgument * argp )
|
| Description : Release memory associated with the argument structure
| for the given fieldtype.
|
| Return Values : -
+--------------------------------------------------------------------------*/
void
_nc_Free_Argument(const FIELDTYPE * typ, TypeArgument * argp)
{
if (!typ || !(typ->status & _HAS_ARGS))
return;
if (typ->status & _LINKED_TYPE)
{
assert(argp);
_nc_Free_Argument(typ->left ,argp->left );
_nc_Free_Argument(typ->right,argp->right);
free(argp);
}
else
{
if (typ->freearg)
typ->freearg((void *)argp);
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
|
| Description : Copy argument structure of field src to field dst
|
| Return Values : TRUE - copy worked
| FALSE - error occured
+--------------------------------------------------------------------------*/
bool
_nc_Copy_Type(FIELD *dst, FIELD const *src)
{
int err = 0;
assert(dst && src);
dst->type = src->type;
dst->arg = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err);
if (err)
{
_nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg));
dst->type = (FIELDTYPE *)0;
dst->arg = (void *)0;
return FALSE;
}
else
{
if (dst->type)
dst->type->ref++;
return TRUE;
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void _nc_Free_Type( FIELD *field )
|
| Description : Release Argument structure for this field
|
| Return Values : -
+--------------------------------------------------------------------------*/
void
_nc_Free_Type(FIELD *field)
{
assert(field);
if (field->type)
field->type->ref--;
_nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD *new_field( int rows, int cols,
| int frow, int fcol,
| int nrow, int nbuf )
|
| Description : Create a new field with this many 'rows' and 'cols',
| starting at 'frow/fcol' in the subwindow of the form.
| Allocate 'nrow' off-screen rows and 'nbuf' additional
| buffers. If an error occurs, errno is set to
|
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
|
| Return Values : Pointer to the new field or NULL if failure.
+--------------------------------------------------------------------------*/
FIELD *new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
if (rows>0 &&
cols>0 &&
frow>=0 &&
fcol>=0 &&
nrow>=0 &&
nbuf>=0 &&
((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
(New_Field=(FIELD *)malloc(sizeof(FIELD))) )
{
*New_Field = default_field;
New_Field->rows = rows;
New_Field->cols = cols;
New_Field->drows = rows + nrow;
New_Field->dcols = cols;
New_Field->frow = frow;
New_Field->fcol = fcol;
New_Field->nrow = nrow;
New_Field->nbuf = nbuf;
New_Field->link = New_Field;
if (_nc_Copy_Type(New_Field,&default_field))
{
size_t len;
len = Total_Buffer_Size(New_Field);
if ((New_Field->buf = (char *)malloc(len)))
{
/* Prefill buffers with blanks and insert terminating zeroes
between buffers */
int i;
memset(New_Field->buf,' ',len);
for(i=0;i<=New_Field->nbuf;i++)
{
New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
= '\0';
}
return New_Field;
}
}
}
if (New_Field)
free_field(New_Field);
SET_ERROR( err );
return (FIELD *)0;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int free_field( FIELD *field )
|
| Description : Frees the storage allocated for the field.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid field pointer
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
int free_field(FIELD * field)
{
if (!field)
RETURN(E_BAD_ARGUMENT);
if (field->form)
RETURN(E_CONNECTED);
if (field == field->link)
{
if (field->buf)
free(field->buf);
}
else
{
FIELD *f;
for(f=field;f->link != field;f = f->link)
{}
f->link = field->link;
}
_nc_Free_Type(field);
free(field);
RETURN(E_OK);
}
/* fld_def.c ends here */

View File

@ -0,0 +1,97 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_dup.c,v 1.4 1999/05/16 17:17:08 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD *dup_field(FIELD *field, int frow, int fcol)
|
| Description : Duplicates the field at the specified position. All
| field attributes and the buffers are copied.
| If an error occurs, errno is set to
|
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
|
| Return Values : Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
FIELD *dup_field(FIELD * field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
if (field && (frow>=0) && (fcol>=0) &&
((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
(New_Field=(FIELD *)malloc(sizeof(FIELD))) )
{
*New_Field = *_nc_Default_Field;
New_Field->frow = frow;
New_Field->fcol = fcol;
New_Field->link = New_Field;
New_Field->rows = field->rows;
New_Field->cols = field->cols;
New_Field->nrow = field->nrow;
New_Field->drows = field->drows;
New_Field->dcols = field->dcols;
New_Field->maxgrow = field->maxgrow;
New_Field->nbuf = field->nbuf;
New_Field->just = field->just;
New_Field->fore = field->fore;
New_Field->back = field->back;
New_Field->pad = field->pad;
New_Field->opts = field->opts;
New_Field->usrptr = field->usrptr;
if (_nc_Copy_Type(New_Field,field))
{
size_t len;
len = Total_Buffer_Size(New_Field);
if ( (New_Field->buf=(char *)malloc(len)) )
{
memcpy(New_Field->buf,field->buf,len);
return New_Field;
}
}
}
if (New_Field)
free_field(New_Field);
SET_ERROR(err);
return (FIELD *)0;
}
/* fld_dup.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_ftchoice.c,v 1.4 1999/05/16 17:17:21 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_fieldtype_choice(
| FIELDTYPE *typ,
| bool (* const next_choice)(FIELD *,const void *),
| bool (* const prev_choice)(FIELD *,const void *))
|
| Description : Define implementation of enumeration requests.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid arguments
+--------------------------------------------------------------------------*/
int set_fieldtype_choice(FIELDTYPE * typ,
bool (* const next_choice) (FIELD *,const void *),
bool (* const prev_choice) (FIELD *,const void *))
{
if ( !typ || !next_choice || !prev_choice )
RETURN(E_BAD_ARGUMENT);
typ->status |= _HAS_CHOICE;
typ->next = next_choice;
typ->prev = prev_choice;
RETURN(E_OK);
}
/* fld_ftchoice.c ends here */

View File

@ -0,0 +1,83 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_ftlink.c,v 1.4 1999/05/16 17:17:33 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELDTYPE *link_fieldtype(
| FIELDTYPE *type1,
| FIELDTYPE *type2)
|
| Description : Create a new fieldtype built from the two given types.
| They are connected by an logical 'OR'.
| If an error occurs, errno is set to
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
| Return Values : Fieldtype pointer or NULL if error occured.
+--------------------------------------------------------------------------*/
FIELDTYPE *link_fieldtype(FIELDTYPE * type1, FIELDTYPE * type2)
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
if ( type1 && type2 )
{
nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
if (nftyp)
{
*nftyp = *_nc_Default_FieldType;
nftyp->status |= _LINKED_TYPE;
if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
nftyp->status |= _HAS_ARGS;
if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
nftyp->status |= _HAS_CHOICE;
nftyp->left = type1;
nftyp->right = type2;
type1->ref++;
type2->ref++;
}
else
{
SET_ERROR( E_SYSTEM_ERROR );
}
}
else
{
SET_ERROR( E_BAD_ARGUMENT );
}
return nftyp;
}
/* fld_ftlink.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_info.c,v 1.4 1999/05/16 17:17:52 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_info(const FIELD *field,
| int *rows, int *cols,
| int *frow, int *fcol,
| int *nrow, int *nbuf)
|
| Description : Retrieve infos about the fields creation parameters.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid field pointer
+--------------------------------------------------------------------------*/
int field_info(const FIELD *field,
int *rows, int *cols,
int *frow, int *fcol,
int *nrow, int *nbuf)
{
if (!field)
RETURN(E_BAD_ARGUMENT);
if (rows) *rows = field->rows;
if (cols) *cols = field->cols;
if (frow) *frow = field->frow;
if (fcol) *fcol = field->fcol;
if (nrow) *nrow = field->nrow;
if (nbuf) *nbuf = field->nbuf;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int dynamic_field_info(const FIELD *field,
| int *drows, int *dcols,
| int *maxgrow)
|
| Description : Retrieve informations about a dynamic fields current
| dynamic parameters.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
int dynamic_field_info(const FIELD *field,
int *drows, int *dcols, int *maxgrow)
{
if (!field)
RETURN(E_BAD_ARGUMENT);
if (drows) *drows = field->drows;
if (dcols) *dcols = field->dcols;
if (maxgrow) *maxgrow = field->maxgrow;
RETURN(E_OK);
}
/* fld_info.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_just.c,v 1.5 1999/05/16 17:18:06 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_just(FIELD *field, int just)
|
| Description : Set the fields type of justification.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - one of the arguments was incorrect
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_field_just(FIELD * field, int just)
{
int res = E_BAD_ARGUMENT;
if ((just==NO_JUSTIFICATION) ||
(just==JUSTIFY_LEFT) ||
(just==JUSTIFY_CENTER) ||
(just==JUSTIFY_RIGHT) )
{
Normalize_Field( field );
if (field->just != just)
{
field->just = just;
res = _nc_Synchronize_Attributes( field );
}
else
res = E_OK;
}
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_just( const FIELD *field )
|
| Description : Retrieve the fields type of justification
|
| Return Values : The justification type.
+--------------------------------------------------------------------------*/
int field_just(const FIELD * field)
{
return Normalize_Field( field )->just;
}
/* fld_just.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_link.c,v 1.4 1999/05/16 17:18:18 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD *link_field(FIELD *field, int frow, int fcol)
|
| Description : Duplicates the field at the specified position. The
| new field shares its buffers with the original one,
| the attributes are independent.
| If an error occurs, errno is set to
|
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
|
| Return Values : Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
FIELD *link_field(FIELD * field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
if (field && (frow>=0) && (fcol>=0) &&
((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
(New_Field = (FIELD *)malloc(sizeof(FIELD))) )
{
*New_Field = *_nc_Default_Field;
New_Field->frow = frow;
New_Field->fcol = fcol;
New_Field->link = field->link;
field->link = New_Field;
New_Field->buf = field->buf;
New_Field->rows = field->rows;
New_Field->cols = field->cols;
New_Field->nrow = field->nrow;
New_Field->nbuf = field->nbuf;
New_Field->drows = field->drows;
New_Field->dcols = field->dcols;
New_Field->maxgrow= field->maxgrow;
New_Field->just = field->just;
New_Field->fore = field->fore;
New_Field->back = field->back;
New_Field->pad = field->pad;
New_Field->opts = field->opts;
New_Field->usrptr = field->usrptr;
if (_nc_Copy_Type(New_Field,field))
return New_Field;
}
if (New_Field)
free_field(New_Field);
SET_ERROR( err );
return (FIELD *)0;
}
/* fld_link.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_max.c,v 1.4 1999/05/16 17:18:34 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_max_field(FIELD *field, int maxgrow)
|
| Description : Set the maximum growth for a dynamic field. If maxgrow=0
| the field may grow to any possible size.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
int set_max_field(FIELD *field, int maxgrow)
{
if (!field || (maxgrow<0))
RETURN(E_BAD_ARGUMENT);
else
{
bool single_line_field = Single_Line_Field(field);
if (maxgrow>0)
{
if (( single_line_field && (maxgrow < field->dcols)) ||
(!single_line_field && (maxgrow < field->drows)))
RETURN(E_BAD_ARGUMENT);
}
field->maxgrow = maxgrow;
field->status &= ~_MAY_GROW;
if (!(field->opts & O_STATIC))
{
if ((maxgrow==0) ||
( single_line_field && (field->dcols < maxgrow)) ||
(!single_line_field && (field->drows < maxgrow)))
field->status |= _MAY_GROW;
}
}
RETURN(E_OK);
}
/* fld_max.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_move.c,v 1.4 1999/05/16 17:38:51 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int move_field(FIELD *field,int frow, int fcol)
|
| Description : Moves the disconnected field to the new location in
| the forms subwindow.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument passed
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
int move_field(FIELD *field, int frow, int fcol)
{
if ( !field || (frow<0) || (fcol<0) )
RETURN(E_BAD_ARGUMENT);
if (field->form)
RETURN(E_CONNECTED);
field->frow = frow;
field->fcol = fcol;
RETURN(E_OK);
}
/* fld_move.c ends here */

View File

@ -0,0 +1,125 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_newftyp.c,v 1.5 1999/05/16 17:18:54 juergen Exp $")
static FIELDTYPE const default_fieldtype = {
0, /* status */
0L, /* reference count */
(FIELDTYPE *)0, /* pointer to left operand */
(FIELDTYPE *)0, /* pointer to right operand */
NULL, /* makearg function */
NULL, /* copyarg function */
NULL, /* freearg function */
NULL, /* field validation function */
NULL, /* Character check function */
NULL, /* enumerate next function */
NULL /* enumerate previous function */
};
const FIELDTYPE* _nc_Default_FieldType = &default_fieldtype;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELDTYPE *new_fieldtype(
| bool (* const field_check)(FIELD *,const void *),
| bool (* const char_check) (int, const void *) )
|
| Description : Create a new fieldtype. The application programmer must
| write a field_check and a char_check function and give
| them as input to this call.
| If an error occurs, errno is set to
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
| Return Values : Fieldtype pointer or NULL if error occured
+--------------------------------------------------------------------------*/
FIELDTYPE *new_fieldtype(
bool (* const field_check)(FIELD *,const void *),
bool (* const char_check) (int,const void *) )
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
if ( (field_check) || (char_check) )
{
nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
if (nftyp)
{
*nftyp = default_fieldtype;
nftyp->fcheck = field_check;
nftyp->ccheck = char_check;
}
else
{
SET_ERROR( E_SYSTEM_ERROR );
}
}
else
{
SET_ERROR( E_BAD_ARGUMENT );
}
return nftyp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int free_fieldtype(FIELDTYPE *typ)
|
| Description : Release the memory associated with this fieldtype.
|
| Return Values : E_OK - success
| E_CONNECTED - there are fields referencing the type
| E_BAD_ARGUMENT - invalid fieldtype pointer
+--------------------------------------------------------------------------*/
int free_fieldtype(FIELDTYPE *typ)
{
if (!typ)
RETURN(E_BAD_ARGUMENT);
if (typ->ref!=0)
RETURN(E_CONNECTED);
if (typ->status & _RESIDENT)
RETURN(E_CONNECTED);
if (typ->status & _LINKED_TYPE)
{
if (typ->left ) typ->left->ref--;
if (typ->right) typ->right->ref--;
}
free(typ);
RETURN(E_OK);
}
/* fld_newftyp.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_opts.c,v 1.6 1999/05/16 17:19:06 juergen Exp $")
/*----------------------------------------------------------------------------
Field-Options manipulation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_opts(FIELD *field, Field_Options opts)
|
| Description : Turns on the named options for this field and turns
| off all the remaining options.
|
| Return Values : E_OK - success
| E_CURRENT - the field is the current field
| E_BAD_ARGUMENT - invalid options
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_field_opts(FIELD * field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
res = _nc_Synchronize_Options( Normalize_Field(field), opts );
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Field_Options field_opts(const FIELD *field)
|
| Description : Retrieve the fields options.
|
| Return Values : The options.
+--------------------------------------------------------------------------*/
Field_Options field_opts(const FIELD * field)
{
return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_opts_on(FIELD *field, Field_Options opts)
|
| Description : Turns on the named options for this field and all the
| remaining options are unchanged.
|
| Return Values : E_OK - success
| E_CURRENT - the field is the current field
| E_BAD_ARGUMENT - invalid options
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int field_opts_on(FIELD * field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
Normalize_Field( field );
res = _nc_Synchronize_Options( field, field->opts | opts );
}
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_opts_off(FIELD *field, Field_Options opts)
|
| Description : Turns off the named options for this field and all the
| remaining options are unchanged.
|
| Return Values : E_OK - success
| E_CURRENT - the field is the current field
| E_BAD_ARGUMENT - invalid options
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int field_opts_off(FIELD * field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
Normalize_Field( field );
res = _nc_Synchronize_Options( field, field->opts & ~opts );
}
RETURN(res);
}
/* fld_opts.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_pad.c,v 1.4 1999/05/16 17:38:58 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_pad(FIELD *field, int ch)
|
| Description : Set the pad character used to fill the field. This must
| be a printable character.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid field pointer or pad character
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_field_pad(FIELD * field, int ch)
{
int res = E_BAD_ARGUMENT;
Normalize_Field( field );
if (isprint((unsigned char)ch))
{
if (field->pad != ch)
{
field->pad = ch;
res = _nc_Synchronize_Attributes( field );
}
else
res = E_OK;
}
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_pad(const FIELD *field)
|
| Description : Retrieve the fields pad character.
|
| Return Values : The pad character.
+--------------------------------------------------------------------------*/
int field_pad(const FIELD * field)
{
return Normalize_Field( field )->pad;
}
/* fld_pad.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_page.c,v 1.4 1999/05/16 17:19:37 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_new_page(FIELD *field, bool new_page_flag)
|
| Description : Marks the field as the beginning of a new page of
| the form.
|
| Return Values : E_OK - success
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
int set_new_page(FIELD * field, bool new_page_flag)
{
Normalize_Field(field);
if (field->form)
RETURN(E_CONNECTED);
if (new_page_flag)
field->status |= _NEWPAGE;
else
field->status &= ~_NEWPAGE;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool new_page(const FIELD *field)
|
| Description : Retrieve the info whether or not the field starts a
| new page on the form.
|
| Return Values : TRUE - field starts a new page
| FALSE - field doesn't start a new page
+--------------------------------------------------------------------------*/
bool new_page(const FIELD * field)
{
return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE;
}
/* fld_page.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_stat.c,v 1.6 1999/05/16 17:19:48 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_status(FIELD *field, bool status)
|
| Description : Set or clear the 'changed' indication flag for that
| fields primary buffer.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
int set_field_status(FIELD * field, bool status)
{
Normalize_Field( field );
if (status)
field->status |= _CHANGED;
else
field->status &= ~_CHANGED;
return(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool field_status(const FIELD *field)
|
| Description : Retrieve the value of the 'changed' indication flag
| for that fields primary buffer.
|
| Return Values : TRUE - buffer has been changed
| FALSE - buffer has not been changed
+--------------------------------------------------------------------------*/
bool field_status(const FIELD * field)
{
return ((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
}
/* fld_stat.c ends here */

View File

@ -0,0 +1,92 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_type.c,v 1.9 1999/05/16 17:19:59 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_type(FIELD *field, FIELDTYPE *type,...)
|
| Description : Associate the specified fieldtype with the field.
| Certain field types take additional arguments. Look
| at the spec of the field types !
|
| Return Values : E_OK - success
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_field_type(FIELD *field,FIELDTYPE *type, ...)
{
va_list ap;
int res = E_SYSTEM_ERROR;
int err = 0;
va_start(ap,type);
Normalize_Field(field);
_nc_Free_Type(field);
field->type = type;
field->arg = (void *)_nc_Make_Argument(field->type,&ap,&err);
if (err)
{
_nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
field->type = (FIELDTYPE *)0;
field->arg = (void *)0;
}
else
{
res = E_OK;
if (field->type)
field->type->ref++;
}
va_end(ap);
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELDTYPE *field_type(const FIELD *field)
|
| Description : Retrieve the associated fieldtype for this field.
|
| Return Values : Pointer to fieldtype of NULL if none is defined.
+--------------------------------------------------------------------------*/
FIELDTYPE *field_type(const FIELD * field)
{
return Normalize_Field(field)->type;
}
/* fld_type.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_user.c,v 1.8 1999/05/16 17:20:09 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_userptr(FIELD *field, void *usrptr)
|
| Description : Set the pointer that is reserved in any field to store
| application relevant informations
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
int set_field_userptr(FIELD * field, void *usrptr)
{
Normalize_Field( field )->usrptr = usrptr;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void *field_userptr(const FIELD *field)
|
| Description : Return the pointer that is reserved in any field to
| store application relevant informations.
|
| Return Values : Value of pointer. If no such pointer has been set,
| NULL is returned
+--------------------------------------------------------------------------*/
void *field_userptr(const FIELD *field)
{
return Normalize_Field( field )->usrptr;
}
/* fld_user.c ends here */

388
contrib/ncurses/form/form.h Normal file
View File

@ -0,0 +1,388 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#ifndef FORM_H
#define FORM_H
#include <curses.h>
#include <eti.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef int Form_Options;
typedef int Field_Options;
/**********
* _PAGE *
**********/
typedef struct {
short pmin; /* index of first field on page */
short pmax; /* index of last field on page */
short smin; /* index of top leftmost field on page */
short smax; /* index of bottom rightmost field on page */
} _PAGE;
/**********
* FIELD *
**********/
typedef struct fieldnode {
unsigned short status; /* flags */
short rows; /* size in rows */
short cols; /* size in cols */
short frow; /* first row */
short fcol; /* first col */
int drows; /* dynamic rows */
int dcols; /* dynamic cols */
int maxgrow; /* maximum field growth */
int nrow; /* offscreen rows */
short nbuf; /* additional buffers */
short just; /* justification */
short page; /* page on form */
short index; /* into form -> field */
int pad; /* pad character */
chtype fore; /* foreground attribute */
chtype back; /* background attribute */
Field_Options opts; /* options */
struct fieldnode * snext; /* sorted order pointer */
struct fieldnode * sprev; /* sorted order pointer */
struct fieldnode * link; /* linked field chain */
struct formnode * form; /* containing form */
struct typenode * type; /* field type */
void * arg; /* argument for type */
char * buf; /* field buffers */
void * usrptr; /* user pointer */
} FIELD;
/**************
* FIELDTYPE *
**************/
typedef struct typenode {
unsigned short status; /* flags */
long ref; /* reference count */
struct typenode * left; /* ptr to operand for | */
struct typenode * right; /* ptr to operand for | */
void* (*makearg)(va_list *); /* make fieldtype arg */
void* (*copyarg)(const void *); /* copy fieldtype arg */
void (*freearg)(void *); /* free fieldtype arg */
bool (*fcheck)(FIELD *,const void *); /* field validation */
bool (*ccheck)(int,const void *); /* character validation */
bool (*next)(FIELD *,const void *); /* enumerate next value */
bool (*prev)(FIELD *,const void *); /* enumerate prev value */
} FIELDTYPE;
/*********
* FORM *
*********/
typedef struct formnode {
unsigned short status; /* flags */
short rows; /* size in rows */
short cols; /* size in cols */
int currow; /* current row in field window*/
int curcol; /* current col in field window*/
int toprow; /* in scrollable field window */
int begincol; /* in horiz. scrollable field */
short maxfield; /* number of fields */
short maxpage; /* number of pages */
short curpage; /* index into page */
Form_Options opts; /* options */
WINDOW * win; /* window */
WINDOW * sub; /* subwindow */
WINDOW * w; /* window for current field */
FIELD ** field; /* field [maxfield] */
FIELD * current; /* current field */
_PAGE * page; /* page [maxpage] */
void * usrptr; /* user pointer */
void (*forminit)(struct formnode *);
void (*formterm)(struct formnode *);
void (*fieldinit)(struct formnode *);
void (*fieldterm)(struct formnode *);
} FORM;
typedef void (*Form_Hook)(FORM *);
/***************************
* miscellaneous #defines *
***************************/
/* field justification */
#define NO_JUSTIFICATION (0)
#define JUSTIFY_LEFT (1)
#define JUSTIFY_CENTER (2)
#define JUSTIFY_RIGHT (3)
/* field options */
#define O_VISIBLE (0x0001)
#define O_ACTIVE (0x0002)
#define O_PUBLIC (0x0004)
#define O_EDIT (0x0008)
#define O_WRAP (0x0010)
#define O_BLANK (0x0020)
#define O_AUTOSKIP (0x0040)
#define O_NULLOK (0x0080)
#define O_PASSOK (0x0100)
#define O_STATIC (0x0200)
/* form options */
#define O_NL_OVERLOAD (0x0001)
#define O_BS_OVERLOAD (0x0002)
/* form driver commands */
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
#define REQ_DEL_WORD (KEY_MAX + 37) /* delete line at cursor */
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
#if defined(MAX_COMMAND)
# if (MAX_FORM_COMMAND > MAX_COMMAND)
# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
# elif (MAX_COMMAND != (KEY_MAX + 128))
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
# endif
#else
# define MAX_COMMAND (KEY_MAX + 128)
#endif
/*************************
* standard field types *
*************************/
extern FIELDTYPE *TYPE_ALPHA,
*TYPE_ALNUM,
*TYPE_ENUM,
*TYPE_INTEGER,
*TYPE_NUMERIC,
*TYPE_REGEXP;
/************************************
* built-in additional field types *
* They are not defined in SVr4 *
************************************/
extern FIELDTYPE *TYPE_IPV4; /* Internet IP Version 4 address */
/***********************
* Default objects *
***********************/
extern FORM *_nc_Default_Form;
extern FIELD *_nc_Default_Field;
/***********************
* FIELDTYPE routines *
***********************/
extern FIELDTYPE
*new_fieldtype(
bool (* const field_check)(FIELD *,const void *),
bool (* const char_check)(int,const void *)),
*link_fieldtype(FIELDTYPE *,FIELDTYPE *);
extern int free_fieldtype(FIELDTYPE *),
set_fieldtype_arg(FIELDTYPE *,
void * (* const make_arg)(va_list *),
void * (* const copy_arg)(const void *),
void (* const free_arg)(void *)),
set_fieldtype_choice (FIELDTYPE *,
bool (* const next_choice)(FIELD *,const void *),
bool (* const prev_choice)(FIELD *,const void *));
/*******************
* FIELD routines *
*******************/
extern FIELD *new_field(int,int,int,int,int,int),
*dup_field(FIELD *,int,int),
*link_field(FIELD *,int,int);
extern int free_field(FIELD *),
field_info(const FIELD *,int *,int *,int *,int *,int *,int *),
dynamic_field_info(const FIELD *,int *,int *,int *),
set_max_field( FIELD *,int),
move_field(FIELD *,int,int),
set_field_type(FIELD *,FIELDTYPE *,...),
set_new_page(FIELD *,bool),
set_field_just(FIELD *,int),
field_just(const FIELD *),
set_field_fore(FIELD *,chtype),
set_field_back(FIELD *,chtype),
set_field_pad(FIELD *,int),
field_pad(const FIELD *),
set_field_buffer(FIELD *,int,const char *),
set_field_status(FIELD *,bool),
set_field_userptr(FIELD *, void *),
set_field_opts(FIELD *,Field_Options),
field_opts_on(FIELD *,Field_Options),
field_opts_off(FIELD *,Field_Options);
extern chtype field_fore(const FIELD *),
field_back(const FIELD *);
extern bool new_page(const FIELD *),
field_status(const FIELD *);
extern void *field_arg(const FIELD *);
extern void *field_userptr(const FIELD *);
extern FIELDTYPE
*field_type(const FIELD *);
extern char* field_buffer(const FIELD *,int);
extern Field_Options
field_opts(const FIELD *);
/******************
* FORM routines *
******************/
extern FORM *new_form(FIELD **);
extern FIELD **form_fields(const FORM *),
*current_field(const FORM *);
extern WINDOW *form_win(const FORM *),
*form_sub(const FORM *);
extern Form_Hook
form_init(const FORM *),
form_term(const FORM *),
field_init(const FORM *),
field_term(const FORM *);
extern int free_form(FORM *),
set_form_fields(FORM *,FIELD **),
field_count(const FORM *),
set_form_win(FORM *,WINDOW *),
set_form_sub(FORM *,WINDOW *),
set_current_field(FORM *,FIELD *),
field_index(const FIELD *),
set_form_page(FORM *,int),
form_page(const FORM *),
scale_form(const FORM *,int *,int *),
set_form_init(FORM *,Form_Hook),
set_form_term(FORM *,Form_Hook),
set_field_init(FORM *,Form_Hook),
set_field_term(FORM *,Form_Hook),
post_form(FORM *),
unpost_form(FORM *),
pos_form_cursor(FORM *),
form_driver(FORM *,int),
set_form_userptr(FORM *,void *),
set_form_opts(FORM *,Form_Options),
form_opts_on(FORM *,Form_Options),
form_opts_off(FORM *,Form_Options),
form_request_by_name(const char *);
extern const char
*form_request_name(int);
extern void *form_userptr(const FORM *);
extern Form_Options
form_opts(const FORM *);
extern bool data_ahead(const FORM *),
data_behind(const FORM *);
#ifdef __cplusplus
}
#endif
#endif /* FORM_H */

View File

@ -0,0 +1,128 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "mf_common.h"
#include "form.h"
/* form status values */
#define _OVLMODE (0x04) /* Form is in overlay mode */
#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
#define _FCHECK_REQUIRED (0x20) /* Current field needs validation */
/* field status values */
#define _CHANGED (0x01) /* Field has been changed */
#define _NEWTOP (0x02) /* Vertical scrolling occured */
#define _NEWPAGE (0x04) /* field begins new page of form */
#define _MAY_GROW (0x08) /* dynamic field may still grow */
/* fieldtype status values */
#define _LINKED_TYPE (0x01) /* Type is a linked type */
#define _HAS_ARGS (0x02) /* Type has arguments */
#define _HAS_CHOICE (0x04) /* Type has choice methods */
#define _RESIDENT (0x08) /* Type is builtin */
/* This are the field options required to be a selectable field in field
navigation requests */
#define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
/* If form is NULL replace form argument by default-form */
#define Normalize_Form(form) ((form)=(form)?(form):_nc_Default_Form)
/* If field is NULL replace field argument by default-field */
#define Normalize_Field(field) ((field)=(field)?(field):_nc_Default_Field)
/* Retrieve forms window */
#define Get_Form_Window(form) \
((form)->sub?(form)->sub:((form)->win?(form)->win:stdscr))
/* Calculate the size for a single buffer for this field */
#define Buffer_Length(field) ((field)->drows * (field)->dcols)
/* Calculate the total size of all buffers for this field */
#define Total_Buffer_Size(field) \
( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
/* Logic to determine whether or not a field is single lined */
#define Single_Line_Field(field) \
(((field)->rows + (field)->nrow) == 1)
/* Logic to determine whether or not a field is selectable */
#define Field_Is_Selectable(f) (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE)
typedef struct typearg {
struct typearg *left;
struct typearg *right;
} TypeArgument;
/* This is a dummy request code (normally invalid) to be used internally
with the form_driver() routine to position to the first active field
on the form
*/
#define FIRST_ACTIVE_MAGIC (-291056)
#define ALL_FORM_OPTS ( \
O_NL_OVERLOAD |\
O_BS_OVERLOAD )
#define ALL_FIELD_OPTS ( \
O_VISIBLE |\
O_ACTIVE |\
O_PUBLIC |\
O_EDIT |\
O_WRAP |\
O_BLANK |\
O_AUTOSKIP|\
O_NULLOK |\
O_PASSOK |\
O_STATIC )
#define C_BLANK ' '
#define is_blank(c) ((c)==C_BLANK)
extern const FIELDTYPE* _nc_Default_FieldType;
extern TypeArgument* _nc_Make_Argument(const FIELDTYPE*,va_list*,int*);
extern TypeArgument *_nc_Copy_Argument(const FIELDTYPE*,const TypeArgument*, int*);
extern void _nc_Free_Argument(const FIELDTYPE*,TypeArgument*);
extern bool _nc_Copy_Type(FIELD*, FIELD const *);
extern void _nc_Free_Type(FIELD *);
extern int _nc_Synchronize_Attributes(FIELD*);
extern int _nc_Synchronize_Options(FIELD*,Field_Options);
extern int _nc_Set_Form_Page(FORM*,int,FIELD*);
extern int _nc_Refresh_Current_Field(FORM*);
extern FIELD* _nc_First_Active_Field(FORM*);
extern bool _nc_Internal_Validation(FORM*);
extern int _nc_Set_Current_Field(FORM*,FIELD*);
extern int _nc_Position_Form_Cursor(FORM*);

View File

@ -0,0 +1,66 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_cursor.c,v 1.4 1999/05/16 17:20:19 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int pos_form_cursor(FORM * form)
|
| Description : Moves the form window cursor to the location required
| by the form driver to resume form processing. This may
| be needed after the application calls a curses library
| I/O routine that modifies the cursor position.
|
| Return Values : E_OK - Success
| E_SYSTEM_ERROR - System error.
| E_BAD_ARGUMENT - Invalid form pointer
| E_NOT_POSTED - Form is not posted
+--------------------------------------------------------------------------*/
int pos_form_cursor(FORM * form)
{
int res;
if (!form)
res = E_BAD_ARGUMENT;
else
{
if (!(form->status & _POSTED))
res = E_NOT_POSTED;
else
res = _nc_Position_Form_Cursor(form);
}
RETURN(res);
}
/* frm_cursor.c ends here */

View File

@ -0,0 +1,181 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_data.c,v 1.6 1999/05/16 17:20:29 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_behind(const FORM *form)
|
| Description : Check for off-screen data behind. This is nearly trivial
| becose the begin of a field is fixed.
|
| Return Values : TRUE - there are off-screen data behind
| FALSE - there are no off-screen data behind
+--------------------------------------------------------------------------*/
bool data_behind(const FORM *form)
{
bool result = FALSE;
if (form && (form->status & _POSTED) && form->current)
{
FIELD *field;
field = form->current;
if (!Single_Line_Field(field))
{
result = (form->toprow==0) ? FALSE : TRUE;
}
else
{
result = (form->begincol==0) ? FALSE : TRUE;
}
}
return(result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static char * After_Last_Non_Pad_Position(
| char *buffer,
| int len,
| int pad)
|
| Description : Find the last position in the buffer that doesn't
| contain a padding character.
|
| Return Values : The pointer to this position
+--------------------------------------------------------------------------*/
INLINE
static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
{
char *end = buffer + len;
assert(buffer && len>=0);
while ( (buffer < end) && (*(end-1)==pad) )
end--;
return end;
}
#define SMALL_BUFFER_SIZE (80)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_ahead(const FORM *form)
|
| Description : Check for off-screen data ahead. This is more difficult
| because a dynamic field has a variable end.
|
| Return Values : TRUE - there are off-screen data ahead
| FALSE - there are no off-screen data ahead
+--------------------------------------------------------------------------*/
bool data_ahead(const FORM *form)
{
bool result = FALSE;
if (form && (form->status & _POSTED) && form->current)
{
static char buffer[SMALL_BUFFER_SIZE + 1];
FIELD *field;
bool large_buffer;
bool cursor_moved = FALSE;
char *bp;
char *found_content;
int pos;
field = form->current;
assert(form->w);
large_buffer = (field->cols > SMALL_BUFFER_SIZE);
if (large_buffer)
bp = (char *)malloc((size_t)(field->cols) + 1);
else
bp = buffer;
assert(bp);
if (Single_Line_Field(field))
{
int check_len;
pos = form->begincol + field->cols;
while (pos < field->dcols)
{
check_len = field->dcols - pos;
if ( check_len >= field->cols )
check_len = field->cols;
cursor_moved = TRUE;
wmove(form->w,0,pos);
winnstr(form->w,bp,check_len);
found_content =
After_Last_Non_Pad_Position(bp,check_len,field->pad);
if (found_content==bp)
pos += field->cols;
else
{
result = TRUE;
break;
}
}
}
else
{
pos = form->toprow + field->rows;
while (pos < field->drows)
{
cursor_moved = TRUE;
wmove(form->w,pos,0);
pos++;
winnstr(form->w,bp,field->cols);
found_content =
After_Last_Non_Pad_Position(bp,field->cols,field->pad);
if (found_content!=bp)
{
result = TRUE;
break;
}
}
}
if (large_buffer)
free(bp);
if (cursor_moved)
wmove(form->w,form->currow,form->curcol);
}
return(result);
}
/* frm_data.c ends here */

View File

@ -0,0 +1,376 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_def.c,v 1.9 1999/05/16 17:20:43 juergen Exp $")
/* this can't be readonly */
static FORM default_form = {
0, /* status */
0, /* rows */
0, /* cols */
0, /* currow */
0, /* curcol */
0, /* toprow */
0, /* begincol */
-1, /* maxfield */
-1, /* maxpage */
-1, /* curpage */
ALL_FORM_OPTS, /* opts */
(WINDOW *)0, /* win */
(WINDOW *)0, /* sub */
(WINDOW *)0, /* w */
(FIELD **)0, /* field */
(FIELD *)0, /* current */
(_PAGE *)0, /* page */
(char *)0, /* usrptr */
NULL, /* forminit */
NULL, /* formterm */
NULL, /* fieldinit */
NULL /* fieldterm */
};
FORM *_nc_Default_Form = &default_form;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static FIELD *Insert_Field_By_Position(
| FIELD *new_field,
| FIELD *head )
|
| Description : Insert new_field into sorted fieldlist with head "head"
| and return new head of sorted fieldlist. Sorting
| criteria is (row,column). This is a circular list.
|
| Return Values : New head of sorted fieldlist
+--------------------------------------------------------------------------*/
static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
{
FIELD *current, *newhead;
assert(newfield);
if (!head)
{ /* empty list is trivial */
newhead = newfield->snext = newfield->sprev = newfield;
}
else
{
newhead = current = head;
while((current->frow < newfield->frow) ||
((current->frow==newfield->frow) &&
(current->fcol < newfield->fcol)) )
{
current = current->snext;
if (current==head)
{ /* We cycled through. Reset head to indicate that */
head = (FIELD *)0;
break;
}
}
/* we leave the loop with current pointing to the field after newfield*/
newfield->snext = current;
newfield->sprev = current->sprev;
newfield->snext->sprev = newfield;
newfield->sprev->snext = newfield;
if (current==head)
newhead = newfield;
}
return(newhead);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Disconnect_Fields(FORM *form)
|
| Description : Break association between form and array of fields.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Disconnect_Fields( FORM * form )
{
if (form->field)
{
FIELD **fields;
for(fields=form->field;*fields;fields++)
{
if (form == (*fields)->form)
(*fields)->form = (FORM *)0;
}
form->rows = form->cols = 0;
form->maxfield = form->maxpage = -1;
form->field = (FIELD **)0;
if (form->page)
free(form->page);
form->page = (_PAGE *)0;
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static int Connect_Fields(FORM *form, FIELD **fields)
|
| Description : Set association between form and array of fields.
|
| Return Values : E_OK - no error
| E_CONNECTED - a field is already connected
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
static int Connect_Fields(FORM * form, FIELD ** fields)
{
int field_cnt, j;
int page_nr;
int maximum_row_in_field, maximum_col_in_field;
_PAGE *pg;
assert(form);
form->field = fields;
form->maxfield = 0;
form->maxpage = 0;
if (!fields)
RETURN(E_OK);
page_nr = 0;
/* store formpointer in fields and count pages */
for(field_cnt=0;fields[field_cnt];field_cnt++)
{
if (fields[field_cnt]->form)
RETURN(E_CONNECTED);
if ( field_cnt==0 ||
(fields[field_cnt]->status & _NEWPAGE))
page_nr++;
fields[field_cnt]->form = form;
}
if (field_cnt==0)
RETURN(E_BAD_ARGUMENT);
/* allocate page structures */
if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
{
form->page = pg;
}
else
RETURN(E_SYSTEM_ERROR);
/* Cycle through fields and calculate page boundaries as well as
size of the form */
for(j=0;j<field_cnt;j++)
{
if (j==0)
pg->pmin = j;
else
{
if (fields[j]->status & _NEWPAGE)
{
pg->pmax = j-1;
pg++;
pg->pmin = j;
}
}
maximum_row_in_field = fields[j]->frow + fields[j]->rows;
maximum_col_in_field = fields[j]->fcol + fields[j]->cols;
if (form->rows < maximum_row_in_field)
form->rows = maximum_row_in_field;
if (form->cols < maximum_col_in_field)
form->cols = maximum_col_in_field;
}
pg->pmax = field_cnt-1;
form->maxfield = field_cnt;
form->maxpage = page_nr;
/* Sort fields on form pages */
for(page_nr = 0;page_nr < form->maxpage; page_nr++)
{
FIELD *fld = (FIELD *)0;
for(j = form->page[page_nr].pmin;j <= form->page[page_nr].pmax;j++)
{
fields[j]->index = j;
fields[j]->page = page_nr;
fld = Insert_Field_By_Position(fields[j],fld);
}
form->page[page_nr].smin = fld->index;
form->page[page_nr].smax = fld->sprev->index;
}
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static int Associate_Fields(FORM *form, FIELD **fields)
|
| Description : Set association between form and array of fields.
| If there are fields, position to first active field.
|
| Return Values : E_OK - success
| any other - error occured
+--------------------------------------------------------------------------*/
INLINE static int Associate_Fields(FORM *form, FIELD **fields)
{
int res = Connect_Fields(form,fields);
if (res == E_OK)
{
if (form->maxpage>0)
{
form->curpage = 0;
form_driver(form,FIRST_ACTIVE_MAGIC);
}
else
{
form->curpage = -1;
form->current = (FIELD *)0;
}
}
return(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FORM *new_form( FIELD **fields )
|
| Description : Create new form with given array of fields.
|
| Return Values : Pointer to form. NULL if error occured.
+--------------------------------------------------------------------------*/
FORM *new_form(FIELD ** fields)
{
int err = E_SYSTEM_ERROR;
FORM *form = (FORM *)malloc(sizeof(FORM));
if (form)
{
*form = *_nc_Default_Form;
if ((err=Associate_Fields(form,fields))!=E_OK)
{
free_form(form);
form = (FORM *)0;
}
}
if (!form)
SET_ERROR(err);
return(form);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int free_form( FORM *form )
|
| Description : Release internal memory associated with form.
|
| Return Values : E_OK - no error
| E_BAD_ARGUMENT - invalid form pointer
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
int free_form(FORM * form)
{
if ( !form )
RETURN(E_BAD_ARGUMENT);
if ( form->status & _POSTED)
RETURN(E_POSTED);
Disconnect_Fields( form );
if (form->page)
free(form->page);
free(form);
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_fields( FORM *form, FIELD **fields )
|
| Description : Set a new association of an array of fields to a form
|
| Return Values : E_OK - no error
| E_BAD_ARGUMENT - invalid form pointer
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
int set_form_fields(FORM * form, FIELD ** fields)
{
FIELD **old;
int res;
if ( !form )
RETURN(E_BAD_ARGUMENT);
if ( form->status & _POSTED )
RETURN(E_POSTED);
old = form->field;
Disconnect_Fields( form );
if( (res = Associate_Fields( form, fields )) != E_OK )
Connect_Fields( form, old );
RETURN(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELD **form_fields( const FORM *form )
|
| Description : Retrieve array of fields
|
| Return Values : Pointer to field array
+--------------------------------------------------------------------------*/
FIELD **form_fields(const FORM * form)
{
return (Normalize_Form( form )->field);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int field_count( const FORM *form )
|
| Description : Retrieve number of fields
|
| Return Values : Number of fields, -1 if none are defined
+--------------------------------------------------------------------------*/
int field_count(const FORM * form)
{
return (Normalize_Form( form )->maxfield);
}
/* frm_def.c ends here */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_hook.c,v 1.8 1999/05/16 17:21:04 juergen Exp $")
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
int set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
{\
(Normalize_Form( form ) -> typ ## name) = func ;\
RETURN(E_OK);\
}
/* "Template" macro to generate function to get application specific hook */
#define GEN_HOOK_GET_FUNCTION( typ, name ) \
Form_Hook typ ## _ ## name ( const FORM *form )\
{\
return ( Normalize_Form( form ) -> typ ## name );\
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_init(FORM *form, Form_Hook f)
|
| Description : Assigns an application defined initialization function
| to be called when the form is posted and just after
| the current field changes.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
GEN_HOOK_SET_FUNCTION(field,init)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Form_Hook field_init(const FORM *form)
|
| Description : Retrieve field initialization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
GEN_HOOK_GET_FUNCTION(field,init)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_term(FORM *form, Form_Hook f)
|
| Description : Assigns an application defined finalization function
| to be called when the form is unposted and just before
| the current field changes.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
GEN_HOOK_SET_FUNCTION(field,term)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Form_Hook field_term(const FORM *form)
|
| Description : Retrieve field finalization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
GEN_HOOK_GET_FUNCTION(field,term)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_init(FORM *form, Form_Hook f)
|
| Description : Assigns an application defined initialization function
| to be called when the form is posted and just after
| a page change.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
GEN_HOOK_SET_FUNCTION(form,init)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Form_Hook form_init(const FORM *form)
|
| Description : Retrieve form initialization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
GEN_HOOK_GET_FUNCTION(form,init)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_term(FORM *form, Form_Hook f)
|
| Description : Assigns an application defined finalization function
| to be called when the form is unposted and just before
| a page change.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
GEN_HOOK_SET_FUNCTION(form,term)
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Form_Hook form_term(const FORM *form)
|
| Description : Retrieve form finalization routine address.
|
| Return Values : The address or NULL if no hook defined.
+--------------------------------------------------------------------------*/
GEN_HOOK_GET_FUNCTION(form,term)
/* frm_hook.c ends here */

View File

@ -0,0 +1,116 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_opts.c,v 1.8 1999/05/16 17:38:05 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_opts(FORM *form, Form_Options opts)
|
| Description : Turns on the named options and turns off all the
| remaining options for that form.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
int set_form_opts(FORM * form, Form_Options opts)
{
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
Normalize_Form( form )->opts = opts;
RETURN(E_OK);
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : Form_Options form_opts(const FORM *)
|
| Description : Retrieves the current form options.
|
| Return Values : The option flags.
+--------------------------------------------------------------------------*/
Form_Options form_opts(const FORM * form)
{
return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_opts_on(FORM *form, Form_Options opts)
|
| Description : Turns on the named options; no other options are
| changed.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
int form_opts_on(FORM * form, Form_Options opts)
{
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
Normalize_Form( form )->opts |= opts;
RETURN(E_OK);
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_opts_off(FORM *form, Form_Options opts)
|
| Description : Turns off the named options; no other options are
| changed.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
int form_opts_off(FORM * form, Form_Options opts)
{
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
Normalize_Form(form)->opts &= ~opts;
RETURN(E_OK);
}
}
/* frm_opts.c ends here */

View File

@ -0,0 +1,100 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_page.c,v 1.5 1999/05/16 17:21:26 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_page(FORM * form,int page)
|
| Description : Set the page number of the form.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid form pointer or page number
| E_BAD_STATE - called from a hook routine
| E_INVALID_FIELD - current field can't be left
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int set_form_page(FORM * form, int page)
{
int err = E_OK;
if ( !form || (page<0) || (page>=form->maxpage) )
RETURN(E_BAD_ARGUMENT);
if (!(form->status & _POSTED))
{
form->curpage = page;
form->current = _nc_First_Active_Field(form);
}
else
{
if (form->status & _IN_DRIVER)
err = E_BAD_STATE;
else
{
if (form->curpage != page)
{
if (!_nc_Internal_Validation(form))
err = E_INVALID_FIELD;
else
{
Call_Hook(form,fieldterm);
Call_Hook(form,formterm);
err = _nc_Set_Form_Page(form,page,(FIELD *)0);
Call_Hook(form,forminit);
Call_Hook(form,fieldinit);
_nc_Refresh_Current_Field(form);
}
}
}
}
RETURN(err);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_page(const FORM * form)
|
| Description : Return the current page of the form.
|
| Return Values : >= 0 : current page number
| -1 : invalid form pointer
+--------------------------------------------------------------------------*/
int form_page(const FORM * form)
{
return Normalize_Form(form)->curpage;
}
/* frm_page.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_post.c,v 1.4 1999/05/16 17:21:39 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int post_form(FORM * form)
|
| Description : Writes the form into its associated subwindow.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid form pointer
| E_POSTED - form already posted
| E_NOT_CONNECTED - no fields connected to form
| E_NO_ROOM - form doesn't fit into subwindow
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
int post_form(FORM * form)
{
WINDOW *formwin;
int err;
int page;
if (!form)
RETURN(E_BAD_ARGUMENT);
if (form->status & _POSTED)
RETURN(E_POSTED);
if (!(form->field))
RETURN(E_NOT_CONNECTED);
formwin = Get_Form_Window(form);
if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin)))
RETURN(E_NO_ROOM);
/* reset form->curpage to an invald value. This forces Set_Form_Page
to do the page initialization which is required by post_form.
*/
page = form->curpage;
form->curpage = -1;
if ((err = _nc_Set_Form_Page(form,page,form->current))!=E_OK)
RETURN(err);
form->status |= _POSTED;
Call_Hook(form,forminit);
Call_Hook(form,fieldinit);
_nc_Refresh_Current_Field(form);
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int unpost_form(FORM * form)
|
| Description : Erase form from its associated subwindow.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid form pointer
| E_NOT_POSTED - form isn't posted
| E_BAD_STATE - called from a hook routine
+--------------------------------------------------------------------------*/
int unpost_form(FORM * form)
{
if (!form)
RETURN(E_BAD_ARGUMENT);
if (!(form->status & _POSTED))
RETURN(E_NOT_POSTED);
if (form->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
Call_Hook(form,fieldterm);
Call_Hook(form,formterm);
werase(Get_Form_Window(form));
delwin(form->w);
form->w = (WINDOW *)0;
form->status &= ~_POSTED;
RETURN(E_OK);
}
/* frm_post.c ends here */

View File

@ -0,0 +1,163 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
/***************************************************************************
* Module form_request_name *
* Routines to handle external names of menu requests *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_req_name.c,v 1.7 1999/05/16 17:21:53 juergen Exp $")
static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
"NEXT_PAGE" ,
"PREV_PAGE" ,
"FIRST_PAGE" ,
"LAST_PAGE" ,
"NEXT_FIELD" ,
"PREV_FIELD" ,
"FIRST_FIELD" ,
"LAST_FIELD" ,
"SNEXT_FIELD" ,
"SPREV_FIELD" ,
"SFIRST_FIELD" ,
"SLAST_FIELD" ,
"LEFT_FIELD" ,
"RIGHT_FIELD" ,
"UP_FIELD" ,
"DOWN_FIELD" ,
"NEXT_CHAR" ,
"PREV_CHAR" ,
"NEXT_LINE" ,
"PREV_LINE" ,
"NEXT_WORD" ,
"PREV_WORD" ,
"BEG_FIELD" ,
"END_FIELD" ,
"BEG_LINE" ,
"END_LINE" ,
"LEFT_CHAR" ,
"RIGHT_CHAR" ,
"UP_CHAR" ,
"DOWN_CHAR" ,
"NEW_LINE" ,
"INS_CHAR" ,
"INS_LINE" ,
"DEL_CHAR" ,
"DEL_PREV" ,
"DEL_LINE" ,
"DEL_WORD" ,
"CLR_EOL" ,
"CLR_EOF" ,
"CLR_FIELD" ,
"OVL_MODE" ,
"INS_MODE" ,
"SCR_FLINE" ,
"SCR_BLINE" ,
"SCR_FPAGE" ,
"SCR_BPAGE" ,
"SCR_FHPAGE" ,
"SCR_BHPAGE" ,
"SCR_FCHAR" ,
"SCR_BCHAR" ,
"SCR_HFLINE" ,
"SCR_HBLINE" ,
"SCR_HFHALF" ,
"SCR_HBHALF" ,
"VALIDATION" ,
"NEXT_CHOICE" ,
"PREV_CHOICE"
};
#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : const char * form_request_name (int request);
|
| Description : Get the external name of a form request.
|
| Return Values : Pointer to name - on success
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
const char *form_request_name( int request )
{
if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
{
SET_ERROR (E_BAD_ARGUMENT);
return (const char *)0;
}
else
return request_names[ request - MIN_FORM_COMMAND ];
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_request_by_name (const char *str);
|
| Description : Search for a request with this name.
|
| Return Values : Request Id - on success
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
int form_request_by_name( const char *str )
{
/* because the table is so small, it doesn't really hurt
to run sequentially through it.
*/
unsigned int i = 0;
char buf[16];
if (str)
{
strncpy(buf,str,sizeof(buf));
while( (i<sizeof(buf)) && (buf[i] != '\0') )
{
buf[i] = toupper(buf[i]);
i++;
}
for (i=0; i < A_SIZE; i++)
{
if (strncmp(request_names[i],buf,sizeof(buf))==0)
return MIN_FORM_COMMAND + i;
}
}
RETURN(E_NO_MATCH);
}
/* frm_req_name.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_scale.c,v 1.4 1999/05/16 17:22:02 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int scale_form( const FORM *form, int *rows, int *cols )
|
| Description : Retrieve size of form
|
| Return Values : E_OK - no error
| E_BAD_ARGUMENT - invalid form pointer
| E_NOT_CONNECTED - no fields connected to form
+--------------------------------------------------------------------------*/
int scale_form(const FORM * form, int * rows, int * cols)
{
if ( !form )
RETURN(E_BAD_ARGUMENT);
if ( !(form->field) )
RETURN(E_NOT_CONNECTED);
if (rows)
*rows = form->rows;
if (cols)
*cols = form->cols;
RETURN(E_OK);
}
/* frm_scale.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_sub.c,v 1.4 1999/05/16 17:22:11 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_sub(FORM *form, WINDOW *win)
|
| Description : Set the subwindow of the form to win.
|
| Return Values : E_OK - success
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
int set_form_sub(FORM * form, WINDOW * win)
{
if (form && (form->status & _POSTED))
RETURN(E_POSTED);
Normalize_Form( form )->sub = win;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : WINDOW *form_sub(const FORM *)
|
| Description : Retrieve the window of the form.
|
| Return Values : The pointer to the Subwindow.
+--------------------------------------------------------------------------*/
WINDOW *form_sub(const FORM * form)
{
const FORM* f = Normalize_Form( form );
return Get_Form_Window(f);
}
/* frm_sub.c ends here */

View File

@ -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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_user.c,v 1.8 1999/05/16 17:22:21 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_userptr(FORM *form, void *usrptr)
|
| Description : Set the pointer that is reserved in any form to store
| application relevant informations
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
int set_form_userptr(FORM * form, void *usrptr)
{
Normalize_Form(form)->usrptr = usrptr;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void *form_userptr(const FORM *form)
|
| Description : Return the pointer that is reserved in any form to
| store application relevant informations.
|
| Return Values : Value of pointer. If no such pointer has been set,
| NULL is returned
+--------------------------------------------------------------------------*/
void *form_userptr(const FORM * form)
{
return Normalize_Form(form)->usrptr;
}
/* frm_user.c ends here */

View File

@ -0,0 +1,70 @@
/****************************************************************************
* 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> 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_win.c,v 1.8 1999/05/16 17:22:32 juergen Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_win(FORM *form,WINDOW *win)
|
| Description : Set the window of the form to win.
|
| Return Values : E_OK - success
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
int set_form_win(FORM * form, WINDOW * win)
{
if (form && (form->status & _POSTED))
RETURN(E_POSTED);
Normalize_Form( form )->win = win;
RETURN(E_OK);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : WINDOW *form_win(const FORM *)
|
| Description : Retrieve the window of the form.
|
| Return Values : The pointer to the Window or stdscr if there is none.
+--------------------------------------------------------------------------*/
WINDOW *form_win(const FORM * form)
{
const FORM* f = Normalize_Form( form );
return (f->win ? f->win : stdscr);
}
/* frm_win.c ends here */

View File

@ -0,0 +1,137 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_alnum.c,v 1.9 1999/05/16 17:22:49 juergen Exp $")
typedef struct {
int width;
} alnumARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_AlphaNumeric_Type(va_list *ap)
|
| Description : Allocate structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_AlphaNumeric_Type(va_list * ap)
{
alnumARG *argp = (alnumARG *)malloc(sizeof(alnumARG));
if (argp)
argp->width = va_arg(*ap,int);
return ((void *)argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_AlphaNumericType(const void *argp)
|
| Description : Copy structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_AlphaNumeric_Type(const void *argp)
{
const alnumARG *ap = (const alnumARG *)argp;
alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG));
if (result)
*result = *ap;
return ((void *)result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_AlphaNumeric_Type(void *argp)
|
| Description : Free structure for alphanumeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_AlphaNumeric_Type(void * argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_AlphaNumeric_Field(
| FIELD *field,
| const void *argp)
|
| Description : Validate buffer content to be a valid alphanumeric value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
{
int width = ((const alnumARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
int l = -1;
unsigned char *s;
while(*bp && *bp==' ')
bp++;
if (*bp)
{
s = bp;
while(*bp && isalnum(*bp))
bp++;
l = (int)(bp-s);
while(*bp && *bp==' ')
bp++;
}
return ((*bp || (l < width)) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_AlphaNumeric_Character(
| int c,
| const void *argp )
|
| Description : Check a character for the alphanumeric type.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
{
return (isalnum(c) ? TRUE : FALSE);
}
static FIELDTYPE typeALNUM = {
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_AlphaNumeric_Type,
Copy_AlphaNumeric_Type,
Free_AlphaNumeric_Type,
Check_AlphaNumeric_Field,
Check_AlphaNumeric_Character,
NULL,
NULL
};
FIELDTYPE* TYPE_ALNUM = &typeALNUM;
/* fty_alnum.c ends here */

View File

@ -0,0 +1,138 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_alpha.c,v 1.9 1999/05/16 17:22:58 juergen Exp $")
typedef struct {
int width;
} alphaARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_Alpha_Type(va_list *ap)
|
| Description : Allocate structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_Alpha_Type(va_list * ap)
{
alphaARG *argp = (alphaARG *)malloc(sizeof(alphaARG));
if (argp)
{
argp->width = va_arg(*ap,int);
}
return ((void *)argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_Alpha_Type(const void * argp)
|
| Description : Copy structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_Alpha_Type(const void * argp)
{
const alphaARG *ap = (const alphaARG *)argp;
alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG));
if (result)
{
*result = *ap;
}
return ((void *)result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_Alpha_Type( void * argp )
|
| Description : Free structure for alpha type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_Alpha_Type(void * argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Alpha_Field(
| FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid alpha value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_Alpha_Field(FIELD * field, const void * argp)
{
int width = ((const alphaARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
int l = -1;
unsigned char *s;
while(*bp && *bp==' ')
bp++;
if (*bp)
{
s = bp;
while(*bp && isalpha(*bp))
bp++;
l = (int)(bp-s);
while(*bp && *bp==' ')
bp++;
}
return ((*bp || (l < width)) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Alpha_Character(
| int c,
| const void * argp)
|
| Description : Check a character for the alpha type.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
{
return (isalpha(c) ? TRUE : FALSE);
}
static FIELDTYPE typeALPHA = {
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Alpha_Type,
Copy_Alpha_Type,
Free_Alpha_Type,
Check_Alpha_Field,
Check_Alpha_Character,
NULL,
NULL
};
FIELDTYPE* TYPE_ALPHA = &typeALPHA;
/* fty_alpha.c ends here */

View File

@ -0,0 +1,289 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_enum.c,v 1.10 1999/05/16 17:23:14 juergen Exp $")
typedef struct {
char **kwds;
int count;
bool checkcase;
bool checkunique;
} enumARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_Enum_Type( va_list * ap )
|
| Description : Allocate structure for enumeration type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_Enum_Type(va_list * ap)
{
enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
char **kp;
int cnt=0;
if (argp)
{
int ccase, cunique;
argp->kwds = va_arg(*ap,char **);
ccase = va_arg(*ap,int);
cunique = va_arg(*ap,int);
argp->checkcase = ccase ? TRUE : FALSE;
argp->checkunique = cunique ? TRUE : FALSE;
kp = argp->kwds;
while( (*kp++) ) cnt++;
argp->count = cnt;
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_Enum_Type( const void * argp )
|
| Description : Copy structure for enumeration type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_Enum_Type(const void * argp)
{
const enumARG *ap = (const enumARG *)argp;
enumARG *result = (enumARG *)0;
if (argp)
{
result = (enumARG *)malloc(sizeof(enumARG));
if (result)
*result = *ap;
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_Enum_Type( void * argp )
|
| Description : Free structure for enumeration type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_Enum_Type(void * argp)
{
if (argp)
free(argp);
}
#define SKIP_SPACE(x) while(((*(x))!='\0') && (is_blank(*(x)))) (x)++
#define NOMATCH 0
#define PARTIAL 1
#define EXACT 2
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static int Compare(const unsigned char * s,
| const unsigned char * buf,
| bool ccase )
|
| Description : Check wether or not the text in 'buf' matches the
| text in 's', at least partial.
|
| Return Values : NOMATCH - buffer doesn't match
| PARTIAL - buffer matches partially
| EXACT - buffer matches exactly
+--------------------------------------------------------------------------*/
static int Compare(const unsigned char *s, const unsigned char *buf,
bool ccase)
{
SKIP_SPACE(buf); /* Skip leading spaces in both texts */
SKIP_SPACE(s);
if (*buf=='\0')
{
return (((*s)!='\0') ? NOMATCH : EXACT);
}
else
{
if (ccase)
{
while(*s++ == *buf)
{
if (*buf++=='\0') return EXACT;
}
}
else
{
while(toupper(*s++)==toupper(*buf))
{
if (*buf++=='\0') return EXACT;
}
}
}
/* At this location buf points to the first character where it no longer
matches with s. So if only blanks are following, we have a partial
match otherwise there is no match */
SKIP_SPACE(buf);
if (*buf)
return NOMATCH;
/* If it happens that the reference buffer is at its end, the partial
match is actually an exact match. */
return ((s[-1]!='\0') ? PARTIAL : EXACT);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Enum_Field(
| FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid enumeration value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_Enum_Field(FIELD * field, const void * argp)
{
char **kwds = ((const enumARG *)argp)->kwds;
bool ccase = ((const enumARG *)argp)->checkcase;
bool unique = ((const enumARG *)argp)->checkunique;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
char *s, *t, *p;
int res;
while( (s=(*kwds++)) )
{
if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
{
p=t=s; /* t is at least a partial match */
if ((unique && res!=EXACT))
{
while( (p = *kwds++) )
{
if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
{
if (res==EXACT)
{
t = p;
break;
}
else
t = (char *)0;
}
}
}
if (t)
{
set_field_buffer(field,0,t);
return TRUE;
}
if (!p)
break;
}
}
return FALSE;
}
static const char *dummy[] = { (char *)0 };
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Next_Enum(FIELD * field,
| const void * argp)
|
| Description : Check for the next enumeration value
|
| Return Values : TRUE - next value found and loaded
| FALSE - no next value loaded
+--------------------------------------------------------------------------*/
static bool Next_Enum(FIELD * field, const void * argp)
{
const enumARG *args = (const enumARG *)argp;
char **kwds = args->kwds;
bool ccase = args->checkcase;
int cnt = args->count;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
while(cnt--)
{
if (Compare((unsigned char *)(*kwds++),bp,ccase)==EXACT)
break;
}
if (cnt<=0)
kwds = args->kwds;
if ((cnt>=0) || (Compare((unsigned char *)dummy,bp,ccase)==EXACT))
{
set_field_buffer(field,0,*kwds);
return TRUE;
}
return FALSE;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Previous_Enum(
| FIELD * field,
| const void * argp)
|
| Description : Check for the previous enumeration value
|
| Return Values : TRUE - previous value found and loaded
| FALSE - no previous value loaded
+--------------------------------------------------------------------------*/
static bool Previous_Enum(FIELD * field, const void * argp)
{
const enumARG *args = (const enumARG *)argp;
int cnt = args->count;
char **kwds = &args->kwds[cnt-1];
bool ccase = args->checkcase;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
while(cnt--)
{
if (Compare((unsigned char *)(*kwds--),bp,ccase)==EXACT)
break;
}
if (cnt<=0)
kwds = &args->kwds[args->count-1];
if ((cnt>=0) || (Compare((unsigned char *)dummy,bp,ccase)==EXACT))
{
set_field_buffer(field,0,*kwds);
return TRUE;
}
return FALSE;
}
static FIELDTYPE typeENUM = {
_HAS_ARGS | _HAS_CHOICE | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Enum_Type,
Copy_Enum_Type,
Free_Enum_Type,
Check_Enum_Field,
NULL,
Next_Enum,
Previous_Enum
};
FIELDTYPE* TYPE_ENUM = &typeENUM;
/* fty_enum.c ends here */

View File

@ -0,0 +1,160 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_int.c,v 1.10 1999/05/16 17:23:22 juergen Exp $")
typedef struct {
int precision;
long low;
long high;
} integerARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_Integer_Type( va_list * ap )
|
| Description : Allocate structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_Integer_Type(va_list * ap)
{
integerARG *argp = (integerARG *)malloc(sizeof(integerARG));
if (argp)
{
argp->precision = va_arg(*ap,int);
argp->low = va_arg(*ap,long);
argp->high = va_arg(*ap,long);
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_Integer_Type(const void * argp)
|
| Description : Copy structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_Integer_Type(const void * argp)
{
const integerARG *ap = (const integerARG *)argp;
integerARG *result = (integerARG *)0;
if (argp)
{
result = (integerARG *)malloc(sizeof(integerARG));
if (result)
*result = *ap;
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_Integer_Type(void * argp)
|
| Description : Free structure for integer type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_Integer_Type(void * argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Integer_Field(
| FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid integer value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_Integer_Field(FIELD * field, const void * argp)
{
const integerARG *argi = (const integerARG *)argp;
long low = argi->low;
long high = argi->high;
int prec = argi->precision;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
char *s = (char *)bp;
long val;
char buf[100];
while( *bp && *bp==' ') bp++;
if (*bp)
{
if (*bp=='-') bp++;
while (*bp)
{
if (!isdigit(*bp)) break;
bp++;
}
while(*bp && *bp==' ') bp++;
if (*bp=='\0')
{
val = atol(s);
if (low<high)
{
if (val<low || val>high) return FALSE;
}
sprintf(buf,"%.*ld",(prec>0?prec:0),val);
set_field_buffer(field,0,buf);
return TRUE;
}
}
return FALSE;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Integer_Character(
| int c,
| const void * argp)
|
| Description : Check a character for the integer type.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
{
return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
}
static FIELDTYPE typeINTEGER = {
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Integer_Type,
Copy_Integer_Type,
Free_Integer_Type,
Check_Integer_Field,
Check_Integer_Character,
NULL,
NULL
};
FIELDTYPE* TYPE_INTEGER = &typeINTEGER;
/* fty_int.c ends here */

View File

@ -0,0 +1,81 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Per Foreby, perf@efd.lth.se *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_ipv4.c,v 1.2 1997/04/26 22:06:00 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_IPV4_Field(
| FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid IP number (Ver. 4)
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
{
char *bp = field_buffer(field,0);
int num = 0, len;
unsigned int d1, d2, d3, d4;
if(isdigit(*bp)) /* Must start with digit */
{
num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
if (num == 4)
{
bp += len; /* Make bp point to what sscanf() left */
while (*bp && isspace(*bp))
bp++; /* Allow trailing whitespace */
}
}
return ((num != 4 || *bp || d1 > 255 || d2 > 255
|| d3 > 255 || d4 > 255) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_IPV4_Character(
| int c,
| const void *argp )
|
| Description : Check a character for unsigned type or period.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
{
return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
}
static FIELDTYPE typeIPV4 = {
_RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
NULL,
NULL,
NULL,
Check_IPV4_Field,
Check_IPV4_Character,
NULL,
NULL
};
FIELDTYPE* TYPE_IPV4 = &typeIPV4;
/* fty_ipv4.c ends here */

View File

@ -0,0 +1,195 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_num.c,v 1.13 1999/05/16 17:23:30 juergen Exp $")
#if HAVE_LOCALE_H
#include <locale.h>
#endif
typedef struct {
int precision;
double low;
double high;
struct lconv* L;
} numericARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_Numeric_Type(va_list * ap)
|
| Description : Allocate structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_Numeric_Type(va_list * ap)
{
numericARG *argn = (numericARG *)malloc(sizeof(numericARG));
if (argn)
{
argn->precision = va_arg(*ap,int);
argn->low = va_arg(*ap,double);
argn->high = va_arg(*ap,double);
#if HAVE_LOCALE_H
argn->L = localeconv();
#else
argn->L = NULL;
#endif
}
return (void *)argn;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_Numeric_Type(const void * argp)
|
| Description : Copy structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_Numeric_Type(const void * argp)
{
const numericARG *ap = (const numericARG *)argp;
numericARG *result = (numericARG *)0;
if (argp)
{
result = (numericARG *)malloc(sizeof(numericARG));
if (result)
*result = *ap;
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_Numeric_Type(void * argp)
|
| Description : Free structure for numeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_Numeric_Type(void * argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Numeric_Field(FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid numeric value
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_Numeric_Field(FIELD * field, const void * argp)
{
const numericARG *argn = (const numericARG *)argp;
double low = argn->low;
double high = argn->high;
int prec = argn->precision;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
char *s = (char *)bp;
double val = 0.0;
struct lconv* L = argn->L;
char buf[64];
while(*bp && *bp==' ') bp++;
if (*bp)
{
if (*bp=='-' || *bp=='+')
bp++;
while(*bp)
{
if (!isdigit(*bp)) break;
bp++;
}
if (*bp==(
#if HAVE_LOCALE_H
(L && L->decimal_point) ? *(L->decimal_point) :
#endif
'.'))
{
bp++;
while(*bp)
{
if (!isdigit(*bp)) break;
bp++;
}
}
while(*bp && *bp==' ') bp++;
if (*bp=='\0')
{
val = atof(s);
if (low<high)
{
if (val<low || val>high) return FALSE;
}
sprintf(buf,"%.*f",(prec>0?prec:0),val);
set_field_buffer(field,0,buf);
return TRUE;
}
}
return FALSE;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_Numeric_Character(
| int c,
| const void * argp)
|
| Description : Check a character for the numeric type.
|
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
static bool Check_Numeric_Character(int c, const void * argp)
{
const numericARG *argn = (const numericARG *)argp;
struct lconv* L = argn->L;
return (isdigit(c) ||
c == '+' ||
c == '-' ||
c == (
#if HAVE_LOCALE_H
(L && L->decimal_point) ? *(L->decimal_point) :
#endif
'.')
) ? TRUE : FALSE;
}
static FIELDTYPE typeNUMERIC = {
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Numeric_Type,
Copy_Numeric_Type,
Free_Numeric_Type,
Check_Numeric_Field,
Check_Numeric_Character,
NULL,
NULL
};
FIELDTYPE* TYPE_NUMERIC = &typeNUMERIC;
/* fty_num.c ends here */

View File

@ -0,0 +1,257 @@
/*
* THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
* You may freely copy it for use as a template for your own field types.
* If you develop a field type that might be of general use, please send
* it back to the ncurses maintainers for inclusion in the next version.
*/
/***************************************************************************
* *
* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_regex.c,v 1.14 1999/05/16 17:23:38 juergen Exp $")
#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
#include <regex.h>
typedef struct
{
regex_t *pRegExp;
unsigned long *refCount;
} RegExp_Arg;
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
#undef RETURN
static int reg_errno;
static char *RegEx_Init(char *instring)
{
reg_errno = 0;
return instring;
}
static char *RegEx_Error(int code)
{
reg_errno = code;
return 0;
}
#define INIT register char *sp = RegEx_Init(instring);
#define GETC() (*sp++)
#define PEEKC() (*sp)
#define UNGETC(c) (--sp)
#define RETURN(c) return(c)
#define ERROR(c) return RegEx_Error(c)
#if HAVE_REGEXP_H_FUNCS
#include <regexp.h>
#else
#include <regexpr.h>
#endif
typedef struct
{
char *compiled_expression;
unsigned long *refCount;
} RegExp_Arg;
/* Maximum Length we allow for a compiled regular expression */
#define MAX_RX_LEN (2048)
#define RX_INCREMENT (256)
#endif
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_RegularExpression_Type(va_list * ap)
|
| Description : Allocate structure for regex type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *Make_RegularExpression_Type(va_list * ap)
{
#if HAVE_REGEX_H_FUNCS
char *rx = va_arg(*ap,char *);
RegExp_Arg *preg;
preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
if (preg)
{
if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
&& !regcomp(preg->pRegExp,rx,
(REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
{
preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
*(preg->refCount) = 1;
}
else
{
if (preg->pRegExp)
free(preg->pRegExp);
free(preg);
preg = (RegExp_Arg*)0;
}
}
return((void *)preg);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
char *rx = va_arg(*ap,char *);
RegExp_Arg *pArg;
pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
if (pArg)
{
int blen = RX_INCREMENT;
pArg->compiled_expression = NULL;
pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
*(pArg->refCount) = 1;
do {
char *buf = (char *)malloc(blen);
if (buf)
{
#if HAVE_REGEXP_H_FUNCS
char *last_pos = compile (rx, buf, &buf[blen], '\0');
#else /* HAVE_REGEXPR_H_FUNCS */
char *last_pos = compile (rx, buf, &buf[blen]);
#endif
if (reg_errno)
{
free(buf);
if (reg_errno==50)
blen += RX_INCREMENT;
else
{
free(pArg);
pArg = NULL;
break;
}
}
else
{
pArg->compiled_expression = buf;
break;
}
}
} while( blen <= MAX_RX_LEN );
}
if (pArg && !pArg->compiled_expression)
{
free(pArg);
pArg = NULL;
}
return (void *)pArg;
#else
return 0;
#endif
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_RegularExpression_Type(
| const void * argp)
|
| Description : Copy structure for regex type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *Copy_RegularExpression_Type(const void * argp)
{
#if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
const RegExp_Arg *ap = (const RegExp_Arg *)argp;
const RegExp_Arg *result = (const RegExp_Arg *)0;
if (ap)
{
*(ap->refCount) += 1;
result = ap;
}
return (void *)result;
#else
return 0;
#endif
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_RegularExpression_Type(void * argp)
|
| Description : Free structure for regex type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void Free_RegularExpression_Type(void * argp)
{
#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
RegExp_Arg *ap = (RegExp_Arg *)argp;
if (ap)
{
if (--(*(ap->refCount)) == 0)
{
#if HAVE_REGEX_H_FUNCS
if (ap->pRegExp)
{
free(ap->refCount);
regfree(ap->pRegExp);
}
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
if (ap->compiled_expression)
{
free(ap->refCount);
free(ap->compiled_expression);
}
#endif
free(ap);
}
}
#endif
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_RegularExpression_Field(
| FIELD * field,
| const void * argp)
|
| Description : Validate buffer content to be a valid regular expression
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
static bool Check_RegularExpression_Field(FIELD * field, const void * argp)
{
bool match = FALSE;
#if HAVE_REGEX_H_FUNCS
const RegExp_Arg *ap = (const RegExp_Arg*)argp;
if (ap && ap->pRegExp)
match = (regexec(ap->pRegExp,field_buffer(field,0),0,NULL,0) ? FALSE:TRUE);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
RegExp_Arg *ap = (RegExp_Arg *)argp;
if (ap && ap->compiled_expression)
match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE);
#endif
return match;
}
static FIELDTYPE typeREGEXP = {
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_RegularExpression_Type,
Copy_RegularExpression_Type,
Free_RegularExpression_Type,
Check_RegularExpression_Field,
NULL,
NULL,
NULL
};
FIELDTYPE* TYPE_REGEXP = &typeREGEXP;
/* fty_regex.c ends here */

View File

@ -0,0 +1,31 @@
##############################################################################
# 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
#
$(srcdir)/form.h

View File

@ -0,0 +1,694 @@
/****************************************************************************
* 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 *
****************************************************************************/
/* LINTLIBRARY */
/* ./fld_arg.c */
#include "form.priv.h"
#undef set_fieldtype_arg
int set_fieldtype_arg(
FIELDTYPE *typ,
void *(*const make_arg)(
va_list *p1),
void *(*const copy_arg)(
const void *p1),
void (*const free_arg)(
void *p1))
{ return(*(int *)0); }
#undef field_arg
void *field_arg(
const FIELD *field)
{ return(*(void **)0); }
/* ./fld_attr.c */
#undef set_field_fore
int set_field_fore(
FIELD *field,
chtype attr)
{ return(*(int *)0); }
#undef field_fore
chtype field_fore(
const FIELD *field)
{ return(*(chtype *)0); }
#undef set_field_back
int set_field_back(
FIELD *field,
chtype attr)
{ return(*(int *)0); }
#undef field_back
chtype field_back(
const FIELD *field)
{ return(*(chtype *)0); }
/* ./fld_current.c */
#undef set_current_field
int set_current_field(
FORM *form,
FIELD *field)
{ return(*(int *)0); }
#undef current_field
FIELD *current_field(
const FORM *form)
{ return(*(FIELD **)0); }
#undef field_index
int field_index(
const FIELD *field)
{ return(*(int *)0); }
/* ./fld_def.c */
#undef _nc_Default_Field
FIELD *_nc_Default_Field;
#undef _nc_Make_Argument
TypeArgument *_nc_Make_Argument(
const FIELDTYPE *typ,
va_list *ap,
int *err)
{ return(*(TypeArgument **)0); }
#undef _nc_Copy_Argument
TypeArgument *_nc_Copy_Argument(
const FIELDTYPE *typ,
const TypeArgument *argp,
int *err)
{ return(*(TypeArgument **)0); }
#undef _nc_Free_Argument
void _nc_Free_Argument(
const FIELDTYPE *typ,
TypeArgument *argp)
{ /* void */ }
#undef _nc_Copy_Type
bool _nc_Copy_Type(
FIELD *dst,
FIELD const *src)
{ return(*(bool *)0); }
#undef _nc_Free_Type
void _nc_Free_Type(
FIELD *field)
{ /* void */ }
#undef new_field
FIELD *new_field(
int rows,
int cols,
int frow,
int fcol,
int nrow,
int nbuf)
{ return(*(FIELD **)0); }
#undef free_field
int free_field(
FIELD *field)
{ return(*(int *)0); }
/* ./fld_dup.c */
#undef dup_field
FIELD *dup_field(
FIELD *field,
int frow,
int fcol)
{ return(*(FIELD **)0); }
/* ./fld_ftchoice.c */
#undef set_fieldtype_choice
int set_fieldtype_choice(
FIELDTYPE *typ,
bool (*const next_choice)(
FIELD *p1,
const void *p2),
bool (*const prev_choice)(
FIELD *p1,
const void *p2))
{ return(*(int *)0); }
/* ./fld_ftlink.c */
#undef link_fieldtype
FIELDTYPE *link_fieldtype(
FIELDTYPE *type1,
FIELDTYPE *type2)
{ return(*(FIELDTYPE **)0); }
/* ./fld_info.c */
#undef field_info
int field_info(
const FIELD *field,
int *rows,
int *cols,
int *frow,
int *fcol,
int *nrow,
int *nbuf)
{ return(*(int *)0); }
#undef dynamic_field_info
int dynamic_field_info(
const FIELD *field,
int *drows,
int *dcols,
int *maxgrow)
{ return(*(int *)0); }
/* ./fld_just.c */
#undef set_field_just
int set_field_just(
FIELD *field,
int just)
{ return(*(int *)0); }
#undef field_just
int field_just(
const FIELD *field)
{ return(*(int *)0); }
/* ./fld_link.c */
#undef link_field
FIELD *link_field(
FIELD *field,
int frow,
int fcol)
{ return(*(FIELD **)0); }
/* ./fld_max.c */
#undef set_max_field
int set_max_field(
FIELD *field,
int maxgrow)
{ return(*(int *)0); }
/* ./fld_move.c */
#undef move_field
int move_field(
FIELD *field,
int frow,
int fcol)
{ return(*(int *)0); }
/* ./fld_newftyp.c */
#undef _nc_Default_FieldType
const FIELDTYPE *_nc_Default_FieldType = {0};
#undef new_fieldtype
FIELDTYPE *new_fieldtype(
bool (*const field_check)(
FIELD *p1,
const void *p2),
bool (*const char_check)(
int p1,
const void *p2))
{ return(*(FIELDTYPE **)0); }
#undef free_fieldtype
int free_fieldtype(
FIELDTYPE *typ)
{ return(*(int *)0); }
/* ./fld_opts.c */
#undef set_field_opts
int set_field_opts(
FIELD *field,
Field_Options opts)
{ return(*(int *)0); }
#undef field_opts
Field_Options field_opts(
const FIELD *field)
{ return(*(Field_Options *)0); }
#undef field_opts_on
int field_opts_on(
FIELD *field,
Field_Options opts)
{ return(*(int *)0); }
#undef field_opts_off
int field_opts_off(
FIELD *field,
Field_Options opts)
{ return(*(int *)0); }
/* ./fld_pad.c */
#undef set_field_pad
int set_field_pad(
FIELD *field,
int ch)
{ return(*(int *)0); }
#undef field_pad
int field_pad(
const FIELD *field)
{ return(*(int *)0); }
/* ./fld_page.c */
#undef set_new_page
int set_new_page(
FIELD *field,
bool new_page_flag)
{ return(*(int *)0); }
#undef new_page
bool new_page(
const FIELD *field)
{ return(*(bool *)0); }
/* ./fld_stat.c */
#undef set_field_status
int set_field_status(
FIELD *field,
bool status)
{ return(*(int *)0); }
#undef field_status
bool field_status(
const FIELD *field)
{ return(*(bool *)0); }
/* ./fld_type.c */
#undef set_field_type
int set_field_type(
FIELD *field,
FIELDTYPE *type,
...)
{ return(*(int *)0); }
#undef field_type
FIELDTYPE *field_type(
const FIELD *field)
{ return(*(FIELDTYPE **)0); }
/* ./fld_user.c */
#undef set_field_userptr
int set_field_userptr(
FIELD *field,
void *usrptr)
{ return(*(int *)0); }
#undef field_userptr
void *field_userptr(
const FIELD *field)
{ return(*(void **)0); }
/* ./frm_cursor.c */
#undef pos_form_cursor
int pos_form_cursor(
FORM *form)
{ return(*(int *)0); }
/* ./frm_data.c */
#undef data_behind
bool data_behind(
const FORM *form)
{ return(*(bool *)0); }
#undef data_ahead
bool data_ahead(
const FORM *form)
{ return(*(bool *)0); }
/* ./frm_def.c */
#undef _nc_Default_Form
FORM *_nc_Default_Form;
#undef new_form
FORM *new_form(
FIELD **fields)
{ return(*(FORM **)0); }
#undef free_form
int free_form(
FORM *form)
{ return(*(int *)0); }
#undef set_form_fields
int set_form_fields(
FORM *form,
FIELD **fields)
{ return(*(int *)0); }
#undef form_fields
FIELD **form_fields(
const FORM *form)
{ return(*(FIELD ***)0); }
#undef field_count
int field_count(
const FORM *form)
{ return(*(int *)0); }
/* ./frm_driver.c */
#undef _nc_Position_Form_Cursor
int _nc_Position_Form_Cursor(
FORM *form)
{ return(*(int *)0); }
#undef _nc_Refresh_Current_Field
int _nc_Refresh_Current_Field(
FORM *form)
{ return(*(int *)0); }
#undef _nc_Synchronize_Attributes
int _nc_Synchronize_Attributes(
FIELD *field)
{ return(*(int *)0); }
#undef _nc_Synchronize_Options
int _nc_Synchronize_Options(
FIELD *field,
Field_Options newopts)
{ return(*(int *)0); }
#undef _nc_Set_Current_Field
int _nc_Set_Current_Field(
FORM *form,
FIELD *newfield)
{ return(*(int *)0); }
#undef _nc_Internal_Validation
bool _nc_Internal_Validation(
FORM *form)
{ return(*(bool *)0); }
#undef _nc_First_Active_Field
FIELD *_nc_First_Active_Field(
FORM *form)
{ return(*(FIELD **)0); }
#undef _nc_Set_Form_Page
int _nc_Set_Form_Page(
FORM *form,
int page,
FIELD *field)
{ return(*(int *)0); }
typedef struct {
int keycode;
int (*cmd)(FORM *);
} Binding_Info;
#undef form_driver
int form_driver(
FORM *form,
int c)
{ return(*(int *)0); }
#undef set_field_buffer
int set_field_buffer(
FIELD *field,
int buffer,
const char *value)
{ return(*(int *)0); }
#undef field_buffer
char *field_buffer(
const FIELD *field,
int buffer)
{ return(*(char **)0); }
/* ./frm_hook.c */
#undef set_field_init
int set_field_init(
FORM *form,
Form_Hook func)
{ return(*(int *)0); }
#undef field_init
Form_Hook field_init(
const FORM *form)
{ return(*(Form_Hook *)0); }
#undef set_field_term
int set_field_term(
FORM *form,
Form_Hook func)
{ return(*(int *)0); }
#undef field_term
Form_Hook field_term(
const FORM *form)
{ return(*(Form_Hook *)0); }
#undef set_form_init
int set_form_init(
FORM *form,
Form_Hook func)
{ return(*(int *)0); }
#undef form_init
Form_Hook form_init(
const FORM *form)
{ return(*(Form_Hook *)0); }
#undef set_form_term
int set_form_term(
FORM *form,
Form_Hook func)
{ return(*(int *)0); }
#undef form_term
Form_Hook form_term(
const FORM *form)
{ return(*(Form_Hook *)0); }
/* ./frm_opts.c */
#undef set_form_opts
int set_form_opts(
FORM *form,
Form_Options opts)
{ return(*(int *)0); }
#undef form_opts
Form_Options form_opts(
const FORM *form)
{ return(*(Form_Options *)0); }
#undef form_opts_on
int form_opts_on(
FORM *form,
Form_Options opts)
{ return(*(int *)0); }
#undef form_opts_off
int form_opts_off(
FORM *form,
Form_Options opts)
{ return(*(int *)0); }
/* ./frm_page.c */
#undef set_form_page
int set_form_page(
FORM *form,
int page)
{ return(*(int *)0); }
#undef form_page
int form_page(
const FORM *form)
{ return(*(int *)0); }
/* ./frm_post.c */
#undef post_form
int post_form(
FORM *form)
{ return(*(int *)0); }
#undef unpost_form
int unpost_form(
FORM *form)
{ return(*(int *)0); }
/* ./frm_req_name.c */
#undef form_request_name
const char *form_request_name(
int request)
{ return(*(const char **)0); }
#undef form_request_by_name
int form_request_by_name(
const char *str)
{ return(*(int *)0); }
/* ./frm_scale.c */
#undef scale_form
int scale_form(
const FORM *form,
int *rows,
int *cols)
{ return(*(int *)0); }
/* ./frm_sub.c */
#undef set_form_sub
int set_form_sub(
FORM *form,
WINDOW *win)
{ return(*(int *)0); }
#undef form_sub
WINDOW *form_sub(
const FORM *form)
{ return(*(WINDOW **)0); }
/* ./frm_user.c */
#undef set_form_userptr
int set_form_userptr(
FORM *form,
void *usrptr)
{ return(*(int *)0); }
#undef form_userptr
void *form_userptr(
const FORM *form)
{ return(*(void **)0); }
/* ./frm_win.c */
#undef set_form_win
int set_form_win(
FORM *form,
WINDOW *win)
{ return(*(int *)0); }
#undef form_win
WINDOW *form_win(
const FORM *form)
{ return(*(WINDOW **)0); }
/* ./fty_alnum.c */
typedef struct {
int width;
} alnumARG;
#undef TYPE_ALNUM
FIELDTYPE *TYPE_ALNUM;
/* ./fty_alpha.c */
typedef struct {
int width;
} alphaARG;
#undef TYPE_ALPHA
FIELDTYPE *TYPE_ALPHA;
/* ./fty_enum.c */
typedef struct {
char **kwds;
int count;
bool checkcase;
bool checkunique;
} enumARG;
#undef TYPE_ENUM
FIELDTYPE *TYPE_ENUM;
/* ./fty_int.c */
typedef struct {
int precision;
long low;
long high;
} integerARG;
#undef TYPE_INTEGER
FIELDTYPE *TYPE_INTEGER;
/* ./fty_ipv4.c */
#undef TYPE_IPV4
FIELDTYPE *TYPE_IPV4;
/* ./fty_num.c */
#include <locale.h>
typedef struct {
int precision;
double low;
double high;
struct lconv* L;
} numericARG;
#undef TYPE_NUMERIC
FIELDTYPE *TYPE_NUMERIC;
/* ./fty_regex.c */
#include <regex.h>
typedef struct
{
regex_t *pRegExp;
unsigned long *refCount;
} RegExp_Arg;
#undef TYPE_REGEXP
FIELDTYPE *TYPE_REGEXP;

View File

@ -0,0 +1,73 @@
# $Id: modules,v 1.13 1999/02/19 00:27:47 juergen 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
#
@ base
# Library objects
fld_arg lib $(srcdir) $(FORM_PRIV_H)
fld_attr lib $(srcdir) $(FORM_PRIV_H)
fld_current lib $(srcdir) $(FORM_PRIV_H)
fld_def lib $(srcdir) $(FORM_PRIV_H)
fld_dup lib $(srcdir) $(FORM_PRIV_H)
fld_ftchoice lib $(srcdir) $(FORM_PRIV_H)
fld_ftlink lib $(srcdir) $(FORM_PRIV_H)
fld_info lib $(srcdir) $(FORM_PRIV_H)
fld_just lib $(srcdir) $(FORM_PRIV_H)
fld_link lib $(srcdir) $(FORM_PRIV_H)
fld_max lib $(srcdir) $(FORM_PRIV_H)
fld_move lib $(srcdir) $(FORM_PRIV_H)
fld_newftyp lib $(srcdir) $(FORM_PRIV_H)
fld_opts lib $(srcdir) $(FORM_PRIV_H)
fld_pad lib $(srcdir) $(FORM_PRIV_H)
fld_page lib $(srcdir) $(FORM_PRIV_H)
fld_stat lib $(srcdir) $(FORM_PRIV_H)
fld_type lib $(srcdir) $(FORM_PRIV_H)
fld_user lib $(srcdir) $(FORM_PRIV_H)
frm_cursor lib $(srcdir) $(FORM_PRIV_H)
frm_data lib $(srcdir) $(FORM_PRIV_H)
frm_def lib $(srcdir) $(FORM_PRIV_H)
frm_driver lib $(srcdir) $(FORM_PRIV_H)
frm_hook lib $(srcdir) $(FORM_PRIV_H)
frm_opts lib $(srcdir) $(FORM_PRIV_H)
frm_page lib $(srcdir) $(FORM_PRIV_H)
frm_post lib $(srcdir) $(FORM_PRIV_H)
frm_req_name lib $(srcdir) $(FORM_PRIV_H)
frm_scale lib $(srcdir) $(FORM_PRIV_H)
frm_sub lib $(srcdir) $(FORM_PRIV_H)
frm_user lib $(srcdir) $(FORM_PRIV_H)
frm_win lib $(srcdir) $(FORM_PRIV_H)
fty_alnum lib $(srcdir) $(FORM_PRIV_H)
fty_alpha lib $(srcdir) $(FORM_PRIV_H)
fty_enum lib $(srcdir) $(FORM_PRIV_H)
fty_int lib $(srcdir) $(FORM_PRIV_H)
fty_ipv4 lib $(srcdir) $(FORM_PRIV_H)
fty_num lib $(srcdir) $(FORM_PRIV_H)
fty_regex lib $(srcdir) $(FORM_PRIV_H)

1314
contrib/ncurses/include/Caps Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
#!/bin/sh
#
# MKhashsize.sh --- generate size include for hash functions
#
echo "/*"
echo " * hashsize.h -- hash and token table constants"
echo " */"
CAPS="${1-Caps}"
TABSIZE=`grep -v '^[ #]' $CAPS | grep -v "^$" | grep -v "^capalias"| grep -v "^infoalias" | wc -l`
echo ""
echo "#define CAPTABSIZE ${TABSIZE}"
echo "#define HASHTABSIZE (${TABSIZE} * 2)"

View File

@ -0,0 +1,34 @@
#!/bin/sh
#
# MKparametrized.sh -- generate indirection vectors for various sort methods
#
# The output of this script is C source for an array specifying whether
# termcap strings should undergo parameter and padding translation.
#
CAPS="${1-Caps}"
cat <<EOF
/*
* parametrized.h --- is a termcap capability parametrized?
*
* Note: this file is generated using parametrized.sh, do not edit by hand.
* A value of -1 in the table means suppress both pad and % translations.
* A value of 0 in the table means do pad but not % translations.
* A value of 1 in the table means do both pad and % translations.
*/
static short const parametrized[] = {
EOF
# We detect whether % translations should be done by looking for #[0-9] in the
# description field. We presently suppress padding translation only for the
# XENIX acs_* capabilities. Maybe someday we'll dedicate a flag field for
# this, that would be cleaner....
${AWK-awk} <$CAPS '
$3 != "str" {next;}
$1 ~ /^acs_/ {print "-1,\t/* ", $2, " */"; count++; next;}
$0 ~ /#[0-9]/ {print "1,\t/* ", $2, " */"; count++; next;}
{print "0,\t/* ", $2, " */"; count++;}
END {printf("} /* %d entries */;\n\n", count);}
'

View File

@ -0,0 +1,310 @@
BEGIN {
print "/****************************************************************************"
print " * Copyright (c) 1998 Free Software Foundation, Inc. *"
print " * *"
print " * Permission is hereby granted, free of charge, to any person obtaining a *"
print " * copy of this software and associated documentation files (the *"
print " * "Software"), to deal in the Software without restriction, including *"
print " * without limitation the rights to use, copy, modify, merge, publish, *"
print " * distribute, distribute with modifications, sublicense, and/or sell *"
print " * copies of the Software, and to permit persons to whom the Software is *"
print " * furnished to do so, subject to the following conditions: *"
print " * *"
print " * The above copyright notice and this permission notice shall be included *"
print " * in all copies or substantial portions of the Software. *"
print " * *"
print " * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *"
print " * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *"
print " * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *"
print " * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *"
print " * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *"
print " * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *"
print " * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *"
print " * *"
print " * Except as contained in this notice, the name(s) of the above copyright *"
print " * holders shall not be used in advertising or otherwise to promote the *"
print " * sale, use or other dealings in this Software without prior written *"
print " * authorization. *"
print " ****************************************************************************/"
print ""
print "/****************************************************************************/"
print "/* Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */"
print "/* and: Eric S. Raymond <esr@snark.thyrsus.com> */"
print "/****************************************************************************/"
print ""
print "/* $Id: MKterm.h.awk.in,v 1.35 1999/02/24 01:04:55 tom Exp $ */"
print ""
print "/*"
print "** term.h -- Definition of struct term"
print "*/"
print ""
print "#ifndef _NCU_TERM_H"
print "#define _NCU_TERM_H 1"
print ""
print "#undef NCURSES_VERSION"
print "#define NCURSES_VERSION \"@NCURSES_MAJOR@.@NCURSES_MINOR@\""
print ""
print "#ifdef __cplusplus"
print "extern \"C\" {"
print "#endif"
print ""
print "/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H"
print " * and BROKEN_LINKER definition (based on the system for which this was"
print " * configured)."
print " */"
print ""
print "#undef HAVE_TERMIOS_H"
print "#define HAVE_TERMIOS_H 1/*default*/"
print ""
print "#undef HAVE_TERMIO_H"
print "#define HAVE_TERMIO_H 0/*default*/"
print ""
print "#undef HAVE_TCGETATTR"
print "#define HAVE_TCGETATTR 1/*default*/"
print ""
print "#undef BROKEN_LINKER"
print "#define BROKEN_LINKER 0/*default*/"
print ""
print "#undef NCURSES_CONST"
print "#define NCURSES_CONST @NCURSES_CONST@"
print ""
print "#undef NCURSES_XNAMES"
print "#define NCURSES_XNAMES @NCURSES_XNAMES@"
print ""
print "/* We will use these symbols to hide differences between"
print " * termios/termio/sgttyb interfaces."
print " */"
print "#undef TTY"
print "#undef SET_TTY"
print "#undef GET_TTY"
print ""
print "/* Assume Posix termio if we have the header and function */"
print "#if HAVE_TERMIOS_H && HAVE_TCGETATTR"
print ""
print "#undef TERMIOS"
print "#define TERMIOS 1"
print ""
print "#include <termios.h>"
print "#define TTY struct termios"
print ""
print "#else /* !HAVE_TERMIOS_H */"
print ""
print "#if HAVE_TERMIO_H"
print ""
print "#undef TERMIOS"
print "#define TERMIOS 1"
print ""
print "#include <termio.h>"
print "#define TTY struct termio"
print ""
print "/* Add definitions to make termio look like termios."
print " * But ifdef it, since there are some implementations"
print " * that try to do this for us in a fake <termio.h>."
print " */"
print "#ifndef TCSANOW"
print "#define TCSANOW TCSETA"
print "#endif"
print "#ifndef TCSADRAIN"
print "#define TCSADRAIN TCSETAW"
print "#endif"
print "#ifndef TCSAFLUSH"
print "#define TCSAFLUSH TCSETAF"
print "#endif"
print "#ifndef tcsetattr"
print "#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)"
print "#endif"
print "#ifndef tcgetattr"
print "#define tcgetattr(fd, arg) ioctl(fd, TCGETA, arg)"
print "#endif"
print "#ifndef cfgetospeed"
print "#define cfgetospeed(t) ((t)->c_cflag & CBAUD)"
print "#endif"
print "#ifndef TCIFLUSH "
print "#define TCIFLUSH 0"
print "#endif"
print "#ifndef TCOFLUSH "
print "#define TCOFLUSH 1"
print "#endif"
print "#ifndef TCIOFLUSH "
print "#define TCIOFLUSH 2"
print "#endif"
print "#ifndef tcflush"
print "#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)"
print "#endif"
print ""
print "#else /* !HAVE_TERMIO_H */"
print ""
print "#undef TERMIOS"
print "#include <sgtty.h>"
print "#include <sys/ioctl.h>"
print "#define TTY struct sgttyb"
print ""
print "#endif /* HAVE_TERMIO_H */"
print ""
print "#endif /* HAVE_TERMIOS_H */"
print ""
print "#ifdef TERMIOS"
print "#define GET_TTY(fd, buf) tcgetattr(fd, buf)"
print "#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)"
print "#else"
print "#define GET_TTY(fd, buf) gtty(fd, buf)"
print "#define SET_TTY(fd, buf) stty(fd, buf)"
print "#endif"
print ""
print "#define NAMESIZE 256"
print ""
print "#define CUR cur_term->type."
print ""
}
$2 == "%%-STOP-HERE-%%" {
print ""
printf "#define BOOLWRITE %d\n", BoolCount
printf "#define NUMWRITE %d\n", NumberCount
printf "#define STRWRITE %d\n", StringCount
print ""
print "/* older synonyms for some capabilities */"
print "#define beehive_glitch no_esc_ctlc"
print "#define teleray_glitch dest_tabs_magic_smso"
print "#define micro_char_size micro_col_size"
print ""
print "#ifdef __INTERNAL_CAPS_VISIBLE"
}
/^#/ {next;}
$3 == "bool" {
printf "#define %-30s CUR Booleans[%d]\n", $1, BoolCount++
}
$3 == "num" {
printf "#define %-30s CUR Numbers[%d]\n", $1, NumberCount++
}
$3 == "str" {
printf "#define %-30s CUR Strings[%d]\n", $1, StringCount++
}
END {
print "#endif /* __INTERNAL_CAPS_VISIBLE */"
print ""
print ""
print "/*"
print " * Predefined terminfo array sizes"
print " */"
printf "#define BOOLCOUNT %d\n", BoolCount
printf "#define NUMCOUNT %d\n", NumberCount
printf "#define STRCOUNT %d\n", StringCount
print ""
print "typedef struct termtype { /* in-core form of terminfo data */"
print " char *term_names; /* str_table offset of term names */"
print " char *str_table; /* pointer to string table */"
print " char *Booleans; /* array of boolean values */"
print " short *Numbers; /* array of integer values */"
print " char **Strings; /* array of string offsets */"
print ""
print "#if NCURSES_XNAMES"
print " char *ext_str_table; /* pointer to extended string table */"
print " char **ext_Names; /* corresponding names */"
print ""
print " unsigned short num_Booleans;/* count total Booleans */"
print " unsigned short num_Numbers; /* count total Numbers */"
print " unsigned short num_Strings; /* count total Strings */"
print ""
print " unsigned short ext_Booleans;/* count extensions to Booleans */"
print " unsigned short ext_Numbers; /* count extensions to Numbers */"
print " unsigned short ext_Strings; /* count extensions to Strings */"
print "#endif /* NCURSES_XNAMES */"
print ""
print "} TERMTYPE;"
print ""
print "typedef struct term { /* describe an actual terminal */"
print " TERMTYPE type; /* terminal type description */"
print " short Filedes; /* file description being written to */"
print " TTY Ottyb, /* original state of the terminal */"
print " Nttyb; /* current state of the terminal */"
print " int _baudrate; /* used to compute padding */"
print "} TERMINAL;"
print ""
print "extern TERMINAL *cur_term;"
print ""
print "#if BROKEN_LINKER"
print "#define boolnames _nc_boolnames()"
print "#define boolcodes _nc_boolcodes()"
print "#define boolfnames _nc_boolfnames()"
print "#define numnames _nc_numnames()"
print "#define numcodes _nc_numcodes()"
print "#define numfnames _nc_numfnames()"
print "#define strnames _nc_strnames()"
print "#define strcodes _nc_strcodes()"
print "#define strfnames _nc_strfnames()"
print ""
print "extern NCURSES_CONST char * const *_nc_boolnames(void);"
print "extern NCURSES_CONST char * const *_nc_boolcodes(void);"
print "extern NCURSES_CONST char * const *_nc_boolfnames(void);"
print "extern NCURSES_CONST char * const *_nc_numnames(void);"
print "extern NCURSES_CONST char * const *_nc_numcodes(void);"
print "extern NCURSES_CONST char * const *_nc_numfnames(void);"
print "extern NCURSES_CONST char * const *_nc_strnames(void);"
print "extern NCURSES_CONST char * const *_nc_strcodes(void);"
print "extern NCURSES_CONST char * const *_nc_strfnames(void);"
print ""
print "#else"
print ""
print "extern NCURSES_CONST char *const boolnames[];"
print "extern NCURSES_CONST char *const boolcodes[];"
print "extern NCURSES_CONST char *const boolfnames[];"
print "extern NCURSES_CONST char *const numnames[];"
print "extern NCURSES_CONST char *const numcodes[];"
print "extern NCURSES_CONST char *const numfnames[];"
print "extern NCURSES_CONST char *const strnames[];"
print "extern NCURSES_CONST char *const strcodes[];"
print "extern NCURSES_CONST char *const strfnames[];"
print ""
print "#endif"
print ""
print "/* internals */"
print "extern int _nc_set_tty_mode(TTY *buf);"
print "extern int _nc_get_tty_mode(TTY *buf);"
print "extern int _nc_read_entry(const char * const, char * const, TERMTYPE *const);"
print "extern int _nc_read_file_entry(const char *const, TERMTYPE *);"
print "extern char *_nc_first_name(const char *const);"
print "extern int _nc_name_match(const char *const, const char *const, const char *const);"
print "extern int _nc_read_termcap_entry(const char *const, TERMTYPE *const);"
print "extern const TERMTYPE *_nc_fallback(const char *);"
print ""
print "/* entry points */"
print "extern TERMINAL *set_curterm(TERMINAL *);"
print "extern int del_curterm(TERMINAL *);"
print ""
print "/* miscellaneous entry points */"
print "extern int restartterm(NCURSES_CONST char *, int, int *);"
print "extern int setupterm(NCURSES_CONST char *,int,int *);"
print ""
print "/* terminfo entry points, also declared in curses.h */"
print "#if !defined(__NCURSES_H)"
print "extern char *tigetstr(NCURSES_CONST char *);"
print "extern char *tparm(NCURSES_CONST char *, ...);"
print "extern char ttytype[];"
print "extern int putp(const char *);"
print "extern int tigetflag(NCURSES_CONST char *);"
print "extern int tigetnum(NCURSES_CONST char *);"
print "#endif /* __NCURSES_H */"
print ""
print "/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */"
print "#if !defined(_NCU_TERMCAP_H)"
print "extern char *tgetstr(NCURSES_CONST char *, char **);"
print "extern char *tgoto(const char *, int, int);"
print "extern int tgetent(char *, const char *);"
print "extern int tgetflag(NCURSES_CONST char *);"
print "extern int tgetnum(NCURSES_CONST char *);"
print "extern int tputs(const char *, int, int (*)(int));"
print "#endif /* _NCU_TERMCAP_H */"
print ""
print "#ifdef __cplusplus"
print "}"
print "#endif"
print ""
print "#endif /* _NCU_TERM_H */"
}

View File

@ -0,0 +1,106 @@
# $Id: Makefile.in,v 1.22 1998/02/11 12:13:46 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/installs ncurses include-files
#
# The variable 'srcdir' refers to the source-distribution, and can be set with
# the configure script by "--srcdir=DIR".
# turn off _all_ suffix rules; we'll generate our own
.SUFFIXES:
SHELL = /bin/sh
THIS = Makefile
INSTALL_PREFIX = @INSTALL_PREFIX@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
AWK = @AWK@
LN_S = @LN_S@
VERSION = @cf_cv_rel_version@
# These files are generated by the configure script
CONFIG_SRC = \
MKterm.h.awk \
curses.h \
termcap.h \
unctrl.h
# These files are generated by this makefile
AUTO_SRC = \
hashsize.h \
parametrized.h \
term.h
################################################################################
all \
sources \
install :: $(AUTO_SRC)
term.h: $(srcdir)/Caps MKterm.h.awk
$(AWK) -f MKterm.h.awk $(srcdir)/Caps > $@
sh $(srcdir)/edit_cfg.sh ../include/ncurses_cfg.h $@
hashsize.h: $(srcdir)/Caps $(srcdir)/MKhashsize.sh
sh $(srcdir)/MKhashsize.sh $(srcdir)/Caps >$@
parametrized.h: $(srcdir)/Caps $(srcdir)/MKparametrized.sh
AWK=$(AWK) sh $(srcdir)/MKparametrized.sh $(srcdir)/Caps >$@
tags:
ctags *.[ch]
TAGS:
etags *.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.ln *.atac trace
clean :: mostlyclean
-rm -f $(AUTO_SRC)
distclean :: clean
-rm -f Makefile $(CONFIG_SRC)
realclean :: distclean
###############################################################################
# The remainder of this file is automatically generated during configuration
###############################################################################

View File

@ -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> *
****************************************************************************/
/* $Id: capdefaults.c,v 1.8 1998/07/04 22:31:04 tom Exp $ */
/*
* Compute obsolete capabilities. The reason this is an include file
* is that the two places where it's needed want the macros to
* generate offsets to different structures. See the file Caps for
* explanations of these conversions.
*
* Note: This code is the functional inverse of the first part
* of postprocess_entry().
*/
{
char *sp;
int capval;
#define EXTRACT_DELAY(str) (sp = strchr(str, '*'), sp ? atoi(sp+1) : 0)
/* current (4.4BSD) capabilities marked obsolete */
if (VALID_STRING(carriage_return)
&& (capval = EXTRACT_DELAY(carriage_return)))
carriage_return_delay = capval;
if (VALID_STRING(newline) && (capval = EXTRACT_DELAY(newline)))
new_line_delay = capval;
/* current (4.4BSD) capabilities not obsolete */
if (!VALID_STRING(termcap_init2) && VALID_STRING(init_3string))
{
termcap_init2 = init_3string;
init_3string = (char *)0;
}
if (VALID_STRING(reset_1string)
&& !VALID_STRING(reset_2string)
&& VALID_STRING(reset_3string))
{
termcap_reset = reset_2string;
reset_2string = (char *)0;
}
#if USE_XMC_SUPPORT
if (magic_cookie_glitch_ul < 0 && magic_cookie_glitch && VALID_STRING(enter_underline_mode))
magic_cookie_glitch_ul = magic_cookie_glitch;
#else
magic_cookie_glitch_ul = -1;
#endif
/* totally obsolete capabilities */
linefeed_is_newline = VALID_STRING(newline)
&& (strcmp("\n", newline) == 0);
if (VALID_STRING(cursor_left)
&& (capval = EXTRACT_DELAY(cursor_left)))
backspace_delay = capval;
if (VALID_STRING(tab) && (capval = EXTRACT_DELAY(tab)))
horizontal_tab_delay = capval;
#undef EXTRACT_DELAY
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,66 @@
#!/bin/sh
# $Id: edit_cfg.sh,v 1.9 1998/02/11 12:13:46 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
#
# Edit the default value of the term.h file based on the autoconf-generated
# values:
#
# $1 = ncurses_cfg.h
# $2 = term.h
#
BAK=save$$
TMP=edit$$
trap "rm -f $BAK $TMP" 0 1 2 5 15
for name in \
HAVE_TCGETATTR \
HAVE_TERMIOS_H \
HAVE_TERMIO_H \
NCURSES_CONST \
BROKEN_LINKER
do
mv $2 $BAK
if ( grep "[ ]$name[ ]" $1 2>&1 >$TMP )
then
sed -e 's@#define '$name'.*$@'"`cat $TMP`@" $BAK >$2
elif test "$name" = "NCURSES_CONST" ; then
sed -e 's/define '$name'.*$/define '$name' \/\*nothing\*\//' $BAK >$2
else
sed -e 's/define '$name'.*$/define '$name' 0/' $BAK >$2
fi
if (cmp -s $2 $BAK)
then
echo '** same: '$name
mv $BAK $2
else
echo '** edit: '$name
rm -f $BAK
fi
done

View File

@ -0,0 +1,34 @@
##############################################################################
# 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
#
term.h
curses.h
unctrl.h
termcap.h

View File

@ -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> 1996,1997 *
****************************************************************************/
/* $Id: nc_alloc.h,v 1.7 1999/04/03 23:15:13 tom Exp $ */
#ifndef NC_ALLOC_included
#define NC_ALLOC_included 1
#if HAVE_LIBDMALLOC
#include <dmalloc.h> /* Gray Watson's library */
#else
#undef HAVE_LIBDMALLOC
#define HAVE_LIBDMALLOC 0
#endif
#if HAVE_LIBDBMALLOC
#include <dbmalloc.h> /* Conor Cahill's library */
#else
#undef HAVE_LIBDBMALLOC
#define HAVE_LIBDBMALLOC 0
#endif
#ifndef NO_LEAKS
#define NO_LEAKS 0
#endif
#if HAVE_LIBDBMALLOC || HAVE_LIBDMALLOC || NO_LEAKS
#define HAVE_NC_FREEALL 1
struct termtype;
extern void _nc_free_and_exit(int) GCC_NORETURN;
extern void _nc_free_tparm(void);
extern void _nc_leaks_dump_entry(void);
#define ExitProgram(code) _nc_free_and_exit(code)
#endif
#ifndef HAVE_NC_FREEALL
#define HAVE_NC_FREEALL 0
#endif
#ifndef ExitProgram
#define ExitProgram(code) return code
#endif
#endif /* NC_ALLOC_included */

Some files were not shown because too many files have changed in this diff Show More