libpayload: Add PDCurses and ncurses' libform/libmenu

PDCurses provides an alternative implementation of the curses library
standard in addition to tinycurses.
Where tinycurses is really tiny, PDCurses is more complete and provides
virtually unlimited windows and the full API.
The PDCurses code is brought in "vanilla", with all local changes
residing in curses/pdcurses-backend/

In addition to a curses library, this change also provides libpanel (as
part of the PDCurses code), and libform and libmenu which were derived
from ncurses-5.9.
As they rely on ncurses internals (and PDCurses is not ncurses), more
changes were required for these libraries to work.

The build system is extended to install the right set of header files
depending on the selected curses implementation.

Change-Id: I9e5b920f94b6510da01da2f656196a993170d1c5
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Reviewed-on: http://review.coreboot.org/106
Tested-by: build bot (Jenkins)
Reviewed-by: Marc Jones <marcj303@gmail.com>
This commit is contained in:
Patrick Georgi
2011-07-07 15:41:53 +02:00
committed by Stefan Reinauer
parent 1ac19e28ee
commit 3b77b723ca
273 changed files with 72620 additions and 7 deletions

View File

@@ -0,0 +1,170 @@
# $Id: Makefile.in,v 1.53 2010/11/27 21:45:27 tom Exp $
##############################################################################
# Copyright (c) 1998-2009,2010 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 1996-on
#
# 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
VPATH = @srcdir@
THIS = Makefile
x = @EXEEXT@
o = .@OBJEXT@
MODEL = @DFT_LWR_MODEL@
DESTDIR = @DESTDIR@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
LIBTOOL = @LIBTOOL@
LIBTOOL_CLEAN = @LIB_CLEAN@
LIBTOOL_COMPILE = @LIB_COMPILE@
LIBTOOL_LINK = @LIB_LINK@
LIBTOOL_INSTALL = @LIB_INSTALL@
LIBTOOL_UNINSTALL = @LIB_UNINSTALL@
LT_UNDEF = @LT_UNDEF@
INSTALL = @INSTALL@
INSTALL_LIB = @INSTALL@ @INSTALL_LIB@
INSTALL_PROG = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
AR = @AR@
ARFLAGS = @ARFLAGS@
AWK = @AWK@
LD = @LD@
LN_S = @LN_S@
CTAGS = @CTAGS@
ETAGS = @ETAGS@
CC = @CC@
CPP = @CPP@
CFLAGS = @CFLAGS@
CPPFLAGS = -I@top_srcdir@/ncurses -DHAVE_CONFIG_H @CPPFLAGS@
CCFLAGS = $(CPPFLAGS) $(CFLAGS)
CFLAGS_LIBTOOL = $(CCFLAGS)
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 = $(LIBTOOL_LINK)
LDFLAGS = @LDFLAGS@ @LD_MODEL@ @LIBS@
SHLIB_DIRS = -L../lib
SHLIB_LIST = $(SHLIB_DIRS) -lncurses@LIB_SUFFIX@ @SHLIB_LIST@
MK_SHARED_LIB = @MK_SHARED_LIB@
NCURSES_MAJOR = @NCURSES_MAJOR@
NCURSES_MINOR = @NCURSES_MINOR@
REL_VERSION = @cf_cv_rel_version@
ABI_VERSION = @cf_cv_abi_version@
RANLIB = @LIB_PREP@
LIBRARIES = @LIBS_TO_MAKE@
LINT = @LINT@
LINT_OPTS = @LINT_OPTS@
LINT_LIBS = -lform -lncurses @LIBS@
AUTO_SRC = \
../include/form.h
################################################################################
all \
libs \
install :: $(AUTO_SRC) $(LIBRARIES)
sources : $(AUTO_SRC)
$(DESTDIR)$(bindir) \
$(DESTDIR)$(libdir) :
mkdir -p $@
# 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 $@
HEADER_DEPS = \
$(srcdir)/form.priv.h \
$(srcdir)/form.h \
../include/mf_common.h \
../include/curses.h \
../include/eti.h
tags:
$(CTAGS) *.[ch]
@MAKE_UPPER_TAGS@TAGS:
@MAKE_UPPER_TAGS@ $(ETAGS) *.[ch]
mostlyclean ::
-rm -f core tags TAGS *~ *.bak *.i *.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,42 @@
-------------------------------------------------------------------------------
-- Copyright (c) 1998-2003,2006 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. --
-------------------------------------------------------------------------------
-- $Id: READ.ME,v 0.7 2006/04/22 23:13:05 tom Exp $
-------------------------------------------------------------------------------
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

View File

@@ -0,0 +1,70 @@
/****************************************************************************
* Copyright (c) 2004,2010 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 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: f_trace.c,v 1.2 2010/01/23 21:14:36 tom Exp $")
NCURSES_EXPORT(FIELD **)
_nc_retrace_field_ptr(FIELD **code)
{
T((T_RETURN("%p"), (void *)code));
return code;
}
NCURSES_EXPORT(FIELD *)
_nc_retrace_field(FIELD *code)
{
T((T_RETURN("%p"), (void *)code));
return code;
}
NCURSES_EXPORT(FIELDTYPE *)
_nc_retrace_field_type(FIELDTYPE *code)
{
T((T_RETURN("%p"), (void *)code));
return code;
}
NCURSES_EXPORT(FORM *)
_nc_retrace_form(FORM *code)
{
T((T_RETURN("%p"), (void *)code));
return code;
}
NCURSES_EXPORT(Form_Hook)
_nc_retrace_form_hook(Form_Hook code)
{
T((T_RETURN("%p"), code));
return code;
}

View File

@@ -0,0 +1,98 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_arg.c,v 1.12 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_fieldtype_arg(FIELDTYPE *typ,
void *(*const make_arg)(va_list *),
void *(*const copy_arg)(const void *),
void (*const free_arg) (void *))
{
T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
(void *)typ, make_arg, copy_arg, free_arg));
if (typ != 0 && make_arg != (void *)0)
{
typ->status |= _HAS_ARGS;
typ->makearg = make_arg;
typ->copyarg = copy_arg;
typ->freearg = free_arg;
RETURN(E_OK);
}
RETURN(E_BAD_ARGUMENT);
}
/*---------------------------------------------------------------------------
| 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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
field_arg(const FIELD *field)
{
T((T_CALLED("field_arg(%p)"), (const void *)field));
returnVoidPtr(Normalize_Field(field)->arg);
}
/* fld_arg.c ends here */

View File

@@ -0,0 +1,119 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_attr.c,v 1.11 2010/01/23 21:12:08 tom Exp $")
/*----------------------------------------------------------------------------
Field-Attribute manipulation routines
--------------------------------------------------------------------------*/
/* "Template" macro to generate a function to set a fields attribute */
#define GEN_FIELD_ATTR_SET_FCT( name ) \
NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
{\
int res = E_BAD_ARGUMENT;\
T((T_CALLED("set_field_" #name "(%p,%s)"), field, _traceattr(attr)));\
if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\
{\
Normalize_Field( field );\
if (field != 0) \
{ \
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 ) \
NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
{\
T((T_CALLED("field_" #name "(%p)"), (const void *) field));\
returnAttr( 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,137 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_current.c,v 1.12 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_current_field(FORM *form, FIELD *field)
{
int err = E_OK;
T((T_CALLED("set_current_field(%p,%p)"), (void *)form, (void *)field));
if (form == 0 || field == 0)
{
RETURN(E_BAD_ARGUMENT);
}
else if ((form != field->form) || Field_Is_Not_Selectable(field))
{
RETURN(E_REQUEST_DENIED);
}
else if ((form->status & _POSTED) == 0)
{
form->current = field;
form->curpage = field->page;
}
else
{
if ((form->status & _IN_DRIVER) != 0)
{
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, (int)field->page, field);
Call_Hook(form, forminit);
}
else
{
err = _nc_Set_Current_Field(form, field);
}
Call_Hook(form, fieldinit);
(void)_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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
current_field(const FORM *form)
{
T((T_CALLED("current_field(%p)"), (const void *)form));
returnField(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_index(const FIELD *field)
{
T((T_CALLED("field_index(%p)"), (const void *)field));
returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
}
/* fld_current.c ends here */

View File

@@ -0,0 +1,399 @@
/****************************************************************************
* Copyright (c) 1998-2007,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_def.c,v 1.38 2010/01/23 21:14:35 tom 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 */
(FIELD_CELL *)0, /* buf */
(char *)0 /* usrptr */
NCURSES_FIELD_EXTENSION
};
NCURSES_EXPORT_VAR(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-dependent argument list to construct
| it.
|
| Return Values : Pointer to argument structure. Maybe NULL.
| In case of an error in *err an error counter is increased.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(TypeArgument *)
_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
assert(err != 0 && ap != (va_list *)0);
if ((typ->status & _LINKED_TYPE) != 0)
{
p = typeMalloc(TypeArgument, 1);
if (p != 0)
{
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 != (void *)0);
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 error counter is increased.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(TypeArgument *)
_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
assert(err != 0 && argp != 0);
if ((typ->status & _LINKED_TYPE) != 0)
{
p = typeMalloc(TypeArgument, 1);
if (p != 0)
{
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 != (void *)0)
{
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 : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
{
if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
if ((typ->status & _LINKED_TYPE) != 0)
{
assert(argp != 0);
_nc_Free_Argument(typ->left, argp->left);
_nc_Free_Argument(typ->right, argp->right);
free(argp);
}
else
{
if (typ->freearg != (void *)0)
{
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 occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
_nc_Copy_Type(FIELD *dst, FIELD const *src)
{
int err = 0;
assert(dst != 0 && src != 0);
dst->type = src->type;
dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
if (err != 0)
{
_nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
dst->type = (FIELDTYPE *)0;
dst->arg = (void *)0;
return FALSE;
}
else
{
if (dst->type != 0)
{
dst->type->ref++;
}
return TRUE;
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : void _nc_Free_Type( FIELD *field )
|
| Description : Release Argument structure for this field
|
| Return Values : -
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void)
_nc_Free_Type(FIELD *field)
{
assert(field != 0);
if (field->type != 0)
{
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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
{
static const FIELD_CELL blank = BLANK;
static const FIELD_CELL zeros = ZEROS;
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
T((T_CALLED("new_field(%d,%d,%d,%d,%d,%d)"), rows, cols, frow, fcol, nrow, nbuf));
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 = typeMalloc(FIELD, 1)) != 0)
{
T((T_CREATE("field %p"), (void *)New_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 USE_WIDEC_SUPPORT
New_Field->working = newpad(1, Buffer_Length(New_Field) + 1);
New_Field->expanded = typeCalloc(char *, 1 + (unsigned)nbuf);
#endif
if (_nc_Copy_Type(New_Field, &default_field))
{
size_t len;
len = Total_Buffer_Size(New_Field);
if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
/* Prefill buffers with blanks and insert terminating zeroes
between buffers */
int i, j;
int cells = Buffer_Length(New_Field);
for (i = 0; i <= New_Field->nbuf; i++)
{
FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
for (j = 0; j < cells; ++j)
{
buffer[j] = blank;
}
buffer[j] = zeros;
}
returnField(New_Field);
}
}
}
if (New_Field)
free_field(New_Field);
SET_ERROR(err);
returnField((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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
free_field(FIELD *field)
{
T((T_CALLED("free_field(%p)"), (void *)field));
if (!field)
{
RETURN(E_BAD_ARGUMENT);
}
else if (field->form != 0)
{
RETURN(E_CONNECTED);
}
else if (field == field->link)
{
if (field->buf != 0)
free(field->buf);
}
else
{
FIELD *f;
for (f = field; f->link != field; f = f->link)
{
}
f->link = field->link;
}
_nc_Free_Type(field);
#if USE_WIDEC_SUPPORT
if (field->expanded != 0)
{
int n;
for (n = 0; n <= field->nbuf; ++n)
{
FreeIfNeeded(field->expanded[n]);
}
free(field->expanded);
(void)delwin(field->working);
}
#endif
free(field);
RETURN(E_OK);
}
/* fld_def.c ends here */

View File

@@ -0,0 +1,101 @@
/****************************************************************************
* Copyright (c) 1998-2007,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_dup.c,v 1.13 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
dup_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
T((T_CALLED("dup_field(%p,%d,%d)"), (void *)field, frow, fcol));
if (field && (frow >= 0) && (fcol >= 0) &&
((err = E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
(New_Field = typeMalloc(FIELD, 1)))
{
T((T_CREATE("field %p"), (void *)New_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 i, len;
len = Total_Buffer_Size(New_Field);
if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
for (i = 0; i < len; ++i)
New_Field->buf[i] = field->buf[i];
returnField(New_Field);
}
}
}
if (New_Field)
free_field(New_Field);
SET_ERROR(err);
returnField((FIELD *)0);
}
/* fld_dup.c ends here */

View File

@@ -0,0 +1,70 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_ftchoice.c,v 1.12 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_fieldtype_choice(FIELDTYPE *typ,
bool (*const next_choice) (FIELD *, const void *),
bool (*const prev_choice) (FIELD *, const void *))
{
T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), (void *)typ, next_choice, prev_choice));
if (!typ || !next_choice || !prev_choice)
RETURN(E_BAD_ARGUMENT);
typ->status |= _HAS_CHOICE;
#if NCURSES_INTEROP_FUNCS
typ->enum_next.onext = next_choice;
typ->enum_prev.oprev = prev_choice;
#else
typ->next = next_choice;
typ->prev = prev_choice;
#endif
RETURN(E_OK);
}
/* fld_ftchoice.c ends here */

View File

@@ -0,0 +1,87 @@
/****************************************************************************
* Copyright (c) 1998-2007,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_ftlink.c,v 1.14 2010/01/23 21:14:35 tom 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 occurred.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
T((T_CALLED("link_fieldtype(%p,%p)"), (void *)type1, (void *)type2));
if (type1 && type2)
{
nftyp = typeMalloc(FIELDTYPE, 1);
if (nftyp)
{
T((T_CREATE("fieldtype %p"), (void *)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);
}
returnFieldType(nftyp);
}
/* fld_ftlink.c ends here */

View File

@@ -0,0 +1,113 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_info.c,v 1.11 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_info(const FIELD *field,
int *rows, int *cols,
int *frow, int *fcol,
int *nrow, int *nbuf)
{
T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
(const void *)field,
(void *)rows, (void *)cols,
(void *)frow, (void *)fcol,
(void *)nrow, (void *)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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
{
T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"),
(const void *)field,
(void *)drows,
(void *)dcols,
(void *)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,86 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_just.c,v 1.12 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_just(FIELD *field, int just)
{
int res = E_BAD_ARGUMENT;
T((T_CALLED("set_field_just(%p,%d)"), (void *)field, just));
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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_just(const FIELD *field)
{
T((T_CALLED("field_just(%p)"), (const void *)field));
returnCode(Normalize_Field(field)->just);
}
/* fld_just.c ends here */

View File

@@ -0,0 +1,96 @@
/****************************************************************************
* Copyright (c) 1998-2007,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_link.c,v 1.12 2010/01/23 21:14:35 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
link_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
T((T_CALLED("link_field(%p,%d,%d)"), (void *)field, frow, fcol));
if (field && (frow >= 0) && (fcol >= 0) &&
((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
(New_Field = typeMalloc(FIELD, 1)))
{
T((T_CREATE("field %p"), (void *)New_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))
returnField(New_Field);
}
if (New_Field)
free_field(New_Field);
SET_ERROR(err);
returnField((FIELD *)0);
}
/* fld_link.c ends here */

View File

@@ -0,0 +1,77 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_max.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_max_field(FIELD *field, int maxgrow)
{
T((T_CALLED("set_max_field(%p,%d)"), (void *)field, 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,64 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_move.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
move_field(FIELD *field, int frow, int fcol)
{
T((T_CALLED("move_field(%p,%d,%d)"), (void *)field, frow, 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,143 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_newftyp.c,v 1.19 2010/01/23 21:14:36 tom Exp $")
static FIELDTYPE 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 */
INIT_FT_FUNC(NULL), /* field validation function */
INIT_FT_FUNC(NULL), /* Character check function */
INIT_FT_FUNC(NULL), /* enumerate next function */
INIT_FT_FUNC(NULL), /* enumerate previous function */
#if NCURSES_INTEROP_FUNCS
NULL /* generic callback alternative to makearg */
#endif
};
NCURSES_EXPORT_VAR(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 occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
new_fieldtype(bool (*const field_check) (FIELD *, const void *),
bool (*const char_check) (int, const void *))
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
if ((field_check) || (char_check))
{
nftyp = typeMalloc(FIELDTYPE, 1);
if (nftyp)
{
T((T_CREATE("fieldtype %p"), (void *)nftyp));
*nftyp = default_fieldtype;
#if NCURSES_INTEROP_FUNCS
nftyp->fieldcheck.ofcheck = field_check;
nftyp->charcheck.occheck = char_check;
#else
nftyp->fcheck = field_check;
nftyp->ccheck = char_check;
#endif
}
else
{
SET_ERROR(E_SYSTEM_ERROR);
}
}
else
{
SET_ERROR(E_BAD_ARGUMENT);
}
returnFieldType(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
free_fieldtype(FIELDTYPE *typ)
{
T((T_CALLED("free_fieldtype(%p)"), (void *)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,138 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_opts.c,v 1.12 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_opts(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
T((T_CALLED("set_field_opts(%p,%d)"), (void *)field, opts));
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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Field_Options)
field_opts(const FIELD *field)
{
T((T_CALLED("field_opts(%p)"), (const void *)field));
returnCode(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_opts_on(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
T((T_CALLED("field_opts_on(%p,%d)"), (void *)field, opts));
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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_opts_off(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
T((T_CALLED("field_opts_off(%p,%d)"), (void *)field, opts));
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,85 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_pad.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_pad(FIELD *field, int ch)
{
int res = E_BAD_ARGUMENT;
T((T_CALLED("set_field_pad(%p,%d)"), (void *)field, ch));
Normalize_Field(field);
if (isprint(UChar(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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_pad(const FIELD *field)
{
T((T_CALLED("field_pad(%p)"), (const void *)field));
returnCode(Normalize_Field(field)->pad);
}
/* fld_pad.c ends here */

View File

@@ -0,0 +1,82 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_page.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_new_page(FIELD *field, bool new_page_flag)
{
T((T_CALLED("set_new_page(%p,%d)"), (void *)field, 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
new_page(const FIELD *field)
{
T((T_CALLED("new_page(%p)"), (const void *)field));
returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
}
/* fld_page.c ends here */

View File

@@ -0,0 +1,79 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_stat.c,v 1.12 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_status(FIELD *field, bool status)
{
T((T_CALLED("set_field_status(%p,%d)"), (void *)field, 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
field_status(const FIELD *field)
{
T((T_CALLED("field_status(%p)"), (const void *)field));
returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
}
/* fld_stat.c ends here */

View File

@@ -0,0 +1,97 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_type.c,v 1.16 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_type(FIELD *field, FIELDTYPE *type,...)
{
va_list ap;
int res = E_SYSTEM_ERROR;
int err = 0;
T((T_CALLED("set_field_type(%p,%p)"), (void *)field, (void *)type));
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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
field_type(const FIELD *field)
{
T((T_CALLED("field_type(%p)"), (const void *)field));
returnFieldType(Normalize_Field(field)->type);
}
/* fld_type.c ends here */

View File

@@ -0,0 +1,72 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fld_user.c,v 1.16 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_field_userptr(FIELD *field, void *usrptr)
{
T((T_CALLED("set_field_userptr(%p,%p)"), (void *)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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
field_userptr(const FIELD *field)
{
T((T_CALLED("field_userptr(%p)"), (const void *)field));
returnVoidPtr(Normalize_Field(field)->usrptr);
}
/* fld_user.c ends here */

View File

@@ -0,0 +1,423 @@
/****************************************************************************
* Copyright (c) 1998-2004,2009 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, 1995,1997 *
****************************************************************************/
/* $Id: form.h,v 0.21 2009/11/07 19:31:11 tom Exp $ */
#ifndef FORM_H
#define FORM_H
#include <curses.h>
#include <eti.h>
#include <ncurses_cfg.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef FORM_PRIV_H
typedef void *FIELD_CELL;
#endif
#ifndef NCURSES_FIELD_INTERNALS
#define NCURSES_FIELD_INTERNALS /* nothing */
#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; /* off-screen 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 */
FIELD_CELL * buf; /* field buffers */
void * usrptr; /* user pointer */
/*
* The wide-character configuration requires extra information. Because
* there are existing applications that manipulate the members of FIELD
* directly, we cannot make the struct opaque. Offsets of members up to
* this point are the same in the narrow- and wide-character configuration.
* But note that the type of buf depends on the configuration, and is made
* opaque for that reason.
*/
NCURSES_FIELD_INTERNALS
} FIELD;
/*********
* 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;
/**************
* 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 */
#if NCURSES_INTEROP_FUNCS
union {
bool (*ofcheck)(FIELD *,const void *); /* field validation */
bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
} fieldcheck;
union {
bool (*occheck)(int,const void *); /* character validation */
bool (*gccheck)(int,FORM*,
FIELD*,const void*); /* generic char validation */
} charcheck;
union {
bool (*onext)(FIELD *,const void *); /* enumerate next value */
bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
} enum_next;
union {
bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
} enum_prev;
void* (*genericarg)(void*); /* Alternate Arg method */
#else
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 */
#endif
} FIELDTYPE;
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 (0x0001U)
#define O_ACTIVE (0x0002U)
#define O_PUBLIC (0x0004U)
#define O_EDIT (0x0008U)
#define O_WRAP (0x0010U)
#define O_BLANK (0x0020U)
#define O_AUTOSKIP (0x0040U)
#define O_NULLOK (0x0080U)
#define O_PASSOK (0x0100U)
#define O_STATIC (0x0200U)
/* form options */
#define O_NL_OVERLOAD (0x0001U)
#define O_BS_OVERLOAD (0x0002U)
/* 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 word 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 NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
/************************************
* built-in additional field types *
* They are not defined in SVr4 *
************************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
/***********************
* FIELDTYPE routines *
***********************/
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
bool (* const field_check)(FIELD *,const void *),
bool (* const char_check)(int,const void *));
extern NCURSES_EXPORT(FIELDTYPE *) link_fieldtype(
FIELDTYPE *, FIELDTYPE *);
extern NCURSES_EXPORT(int) free_fieldtype (FIELDTYPE *);
extern NCURSES_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
void * (* const make_arg)(va_list *),
void * (* const copy_arg)(const void *),
void (* const free_arg)(void *));
extern NCURSES_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
bool (* const next_choice)(FIELD *,const void *),
bool (* const prev_choice)(FIELD *,const void *));
/*******************
* FIELD routines *
*******************/
extern NCURSES_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
extern NCURSES_EXPORT(FIELD *) dup_field (FIELD *,int,int);
extern NCURSES_EXPORT(FIELD *) link_field (FIELD *,int,int);
extern NCURSES_EXPORT(int) free_field (FIELD *);
extern NCURSES_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
extern NCURSES_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
extern NCURSES_EXPORT(int) set_max_field ( FIELD *,int);
extern NCURSES_EXPORT(int) move_field (FIELD *,int,int);
extern NCURSES_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
extern NCURSES_EXPORT(int) set_new_page (FIELD *,bool);
extern NCURSES_EXPORT(int) set_field_just (FIELD *,int);
extern NCURSES_EXPORT(int) field_just (const FIELD *);
extern NCURSES_EXPORT(int) set_field_fore (FIELD *,chtype);
extern NCURSES_EXPORT(int) set_field_back (FIELD *,chtype);
extern NCURSES_EXPORT(int) set_field_pad (FIELD *,int);
extern NCURSES_EXPORT(int) field_pad (const FIELD *);
extern NCURSES_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
extern NCURSES_EXPORT(int) set_field_status (FIELD *,bool);
extern NCURSES_EXPORT(int) set_field_userptr (FIELD *, void *);
extern NCURSES_EXPORT(int) set_field_opts (FIELD *,Field_Options);
extern NCURSES_EXPORT(int) field_opts_on (FIELD *,Field_Options);
extern NCURSES_EXPORT(int) field_opts_off (FIELD *,Field_Options);
extern NCURSES_EXPORT(chtype) field_fore (const FIELD *);
extern NCURSES_EXPORT(chtype) field_back (const FIELD *);
extern NCURSES_EXPORT(bool) new_page (const FIELD *);
extern NCURSES_EXPORT(bool) field_status (const FIELD *);
extern NCURSES_EXPORT(void *) field_arg (const FIELD *);
extern NCURSES_EXPORT(void *) field_userptr (const FIELD *);
extern NCURSES_EXPORT(FIELDTYPE *) field_type (const FIELD *);
extern NCURSES_EXPORT(char *) field_buffer (const FIELD *,int);
extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
/******************
* FORM routines *
******************/
extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_sub (const FORM *);
extern NCURSES_EXPORT(Form_Hook) form_init (const FORM *);
extern NCURSES_EXPORT(Form_Hook) form_term (const FORM *);
extern NCURSES_EXPORT(Form_Hook) field_init (const FORM *);
extern NCURSES_EXPORT(Form_Hook) field_term (const FORM *);
extern NCURSES_EXPORT(int) free_form (FORM *);
extern NCURSES_EXPORT(int) set_form_fields (FORM *,FIELD **);
extern NCURSES_EXPORT(int) field_count (const FORM *);
extern NCURSES_EXPORT(int) set_form_win (FORM *,WINDOW *);
extern NCURSES_EXPORT(int) set_form_sub (FORM *,WINDOW *);
extern NCURSES_EXPORT(int) set_current_field (FORM *,FIELD *);
extern NCURSES_EXPORT(int) field_index (const FIELD *);
extern NCURSES_EXPORT(int) set_form_page (FORM *,int);
extern NCURSES_EXPORT(int) form_page (const FORM *);
extern NCURSES_EXPORT(int) scale_form (const FORM *,int *,int *);
extern NCURSES_EXPORT(int) set_form_init (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_form_term (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_field_init (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) set_field_term (FORM *,Form_Hook);
extern NCURSES_EXPORT(int) post_form (FORM *);
extern NCURSES_EXPORT(int) unpost_form (FORM *);
extern NCURSES_EXPORT(int) pos_form_cursor (FORM *);
extern NCURSES_EXPORT(int) form_driver (FORM *,int);
extern NCURSES_EXPORT(int) set_form_userptr (FORM *,void *);
extern NCURSES_EXPORT(int) set_form_opts (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_opts_on (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_opts_off (FORM *,Form_Options);
extern NCURSES_EXPORT(int) form_request_by_name (const char *);
extern NCURSES_EXPORT(const char *) form_request_name (int);
extern NCURSES_EXPORT(void *) form_userptr (const FORM *);
extern NCURSES_EXPORT(Form_Options) form_opts (const FORM *);
extern NCURSES_EXPORT(bool) data_ahead (const FORM *);
extern NCURSES_EXPORT(bool) data_behind (const FORM *);
#if NCURSES_SP_FUNCS
extern NCURSES_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
#endif
#ifdef __cplusplus
}
#endif
#endif /* FORM_H */

View File

@@ -0,0 +1,299 @@
/****************************************************************************
* Copyright (c) 1998-2008,2009 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, 1995,1997 *
****************************************************************************/
/* $Id: form.priv.h,v 0.32 2009/11/07 21:26:43 tom Exp $ */
#ifndef FORM_PRIV_H
#define FORM_PRIV_H 1
#include "curspriv.h"
#include "mf_common.h"
#define UChar(c) ((unsigned char)(c))
#if USE_WIDEC_SUPPORT
#if HAVE_WCTYPE_H
#include <wctype.h>
#endif
#ifndef MB_LEN_MAX
#define MB_LEN_MAX 8 /* should be >= MB_CUR_MAX, but that may be a function */
#endif
#define FIELD_CELL NCURSES_CH_T
#define NCURSES_FIELD_INTERNALS char** expanded; WINDOW *working;
#define NCURSES_FIELD_EXTENSION , (char **)0, (WINDOW *)0
#else
#define FIELD_CELL char
#define NCURSES_FIELD_EXTENSION /* nothing */
#endif
#include "form.h"
/***********************
* Default objects *
***********************/
extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form;
extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
extern NCURSES_EXPORT_VAR(FIELDTYPE *) _nc_Default_FieldType;
/* form status values */
#define _OVLMODE (0x04U) /* Form is in overlay mode */
#define _WINDOW_MODIFIED (0x10U) /* Current field window has been modified */
#define _FCHECK_REQUIRED (0x20U) /* Current field needs validation */
/* field status values */
#define _CHANGED (0x01U) /* Field has been changed */
#define _NEWTOP (0x02U) /* Vertical scrolling occurred */
#define _NEWPAGE (0x04U) /* field begins new page of form */
#define _MAY_GROW (0x08U) /* dynamic field may still grow */
/* fieldtype status values */
#define _LINKED_TYPE (0x01U) /* Type is a linked type */
#define _HAS_ARGS (0x02U) /* Type has arguments */
#define _HAS_CHOICE (0x04U) /* Type has choice methods */
#define _RESIDENT (0x08U) /* Type is built-in */
#define _GENERIC (0x10U) /* A generic field type */
/* 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 != 0) ? (form) : _nc_Default_Form)
/* If field is NULL replace field argument by default-field */
#define Normalize_Field(field) \
((field) = (field != 0) ? (field) : _nc_Default_Field)
#if NCURSES_SP_FUNCS
#define Get_Form_Screen(form) \
((form)->win ? _nc_screen_of((form->win)):CURRENT_SCREEN)
#else
#define Get_Form_Screen(form) CURRENT_SCREEN
#endif
/* Retrieve forms window */
#define Get_Form_Window(form) \
((form)->sub != NULL \
? (form)->sub \
: ((form)->win != NULL \
? (form)->win \
: StdScreen(Get_Form_Screen(form))))
/* 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) * sizeof(FIELD_CELL) )
/* 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) (((unsigned)((f)->opts) & O_SELECTABLE)==O_SELECTABLE)
#define Field_Is_Not_Selectable(f) (((unsigned)((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 (Field_Options)( \
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)
#define C_ZEROS '\0'
extern NCURSES_EXPORT(TypeArgument *) _nc_Make_Argument (const FIELDTYPE*, va_list*, int*);
extern NCURSES_EXPORT(TypeArgument *) _nc_Copy_Argument (const FIELDTYPE*, const TypeArgument*, int*);
extern NCURSES_EXPORT(void) _nc_Free_Argument (const FIELDTYPE*, TypeArgument*);
extern NCURSES_EXPORT(bool) _nc_Copy_Type (FIELD*, FIELD const *);
extern NCURSES_EXPORT(void) _nc_Free_Type (FIELD *);
extern NCURSES_EXPORT(int) _nc_Synchronize_Attributes (FIELD*);
extern NCURSES_EXPORT(int) _nc_Synchronize_Options (FIELD*, Field_Options);
extern NCURSES_EXPORT(int) _nc_Set_Form_Page (FORM*, int, FIELD*);
extern NCURSES_EXPORT(int) _nc_Refresh_Current_Field (FORM*);
extern NCURSES_EXPORT(FIELD *) _nc_First_Active_Field (FORM*);
extern NCURSES_EXPORT(bool) _nc_Internal_Validation (FORM*);
extern NCURSES_EXPORT(int) _nc_Set_Current_Field (FORM*, FIELD*);
extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
#if NCURSES_INTEROP_FUNCS
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_INTEGER(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALNUM(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ALPHA(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_ENUM(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_NUMERIC(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_REGEXP(void);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_TYPE_IPV4(void);
extern NCURSES_EXPORT(FIELDTYPE *)
_nc_generic_fieldtype(bool (*const field_check) (FORM*,
FIELD *,
const void *),
bool (*const char_check) (int,
FORM*,
FIELD*,
const void *),
bool (*const next)(FORM*,FIELD*,const void*),
bool (*const prev)(FORM*,FIELD*,const void*),
void (*freecallback)(void*));
extern NCURSES_EXPORT(int) _nc_set_generic_fieldtype(FIELD*, FIELDTYPE*, int (*)(void**));
extern NCURSES_EXPORT(WINDOW*) _nc_form_cursor(const FORM* , int* , int* );
#define INIT_FT_FUNC(func) {func}
#else
#define INIT_FT_FUNC(func) func
#endif
extern NCURSES_EXPORT(void) _nc_get_fieldbuffer(FORM*, FIELD*, FIELD_CELL*);
#if USE_WIDEC_SUPPORT
extern NCURSES_EXPORT(wchar_t *) _nc_Widen_String(char *, int *);
#endif
#ifdef TRACE
#define returnField(code) TRACE_RETURN(code,field)
#define returnFieldPtr(code) TRACE_RETURN(code,field_ptr)
#define returnForm(code) TRACE_RETURN(code,form)
#define returnFieldType(code) TRACE_RETURN(code,field_type)
#define returnFormHook(code) TRACE_RETURN(code,form_hook)
extern NCURSES_EXPORT(FIELD **) _nc_retrace_field_ptr (FIELD **);
extern NCURSES_EXPORT(FIELD *) _nc_retrace_field (FIELD *);
extern NCURSES_EXPORT(FIELDTYPE *) _nc_retrace_field_type (FIELDTYPE *);
extern NCURSES_EXPORT(FORM *) _nc_retrace_form (FORM *);
extern NCURSES_EXPORT(Form_Hook) _nc_retrace_form_hook (Form_Hook);
#else /* !TRACE */
#define returnFieldPtr(code) return code
#define returnFieldType(code) return code
#define returnField(code) return code
#define returnForm(code) return code
#define returnFormHook(code) return code
#endif /* TRACE/!TRACE */
/*
* Use Check_CTYPE_Field() to simplify FIELDTYPE's that use only the ccheck()
* function.
*/
#if USE_WIDEC_SUPPORT
#define Check_CTYPE_Field(result, buffer, width, ccheck) \
while (*buffer && *buffer == ' ') \
buffer++; \
if (*buffer) \
{ \
bool blank = FALSE; \
int len; \
int n; \
wchar_t *list = _nc_Widen_String((char *)buffer, &len); \
if (list != 0) \
{ \
result = TRUE; \
for (n = 0; n < len; ++n) \
{ \
if (blank) \
{ \
if (list[n] != ' ') \
{ \
result = FALSE; \
break; \
} \
} \
else if (list[n] == ' ') \
{ \
blank = TRUE; \
result = (n + 1 >= width); \
} \
else if (!ccheck(list[n], NULL)) \
{ \
result = FALSE; \
break; \
} \
} \
free(list); \
} \
}
#else
#define Check_CTYPE_Field(result, buffer, width, ccheck) \
while (*buffer && *buffer == ' ') \
buffer++; \
if (*buffer) \
{ \
unsigned char *s = buffer; \
int l = -1; \
while (*buffer && ccheck(*buffer, NULL)) \
buffer++; \
l = (int)(buffer - s); \
while (*buffer && *buffer == ' ') \
buffer++; \
result = ((*buffer || (l < width)) ? FALSE : TRUE); \
}
#endif
#endif /* FORM_PRIV_H */

View File

@@ -0,0 +1,70 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_cursor.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
pos_form_cursor(FORM *form)
{
int res;
T((T_CALLED("pos_form_cursor(%p)"), (void *)form));
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,193 @@
/****************************************************************************
* Copyright (c) 1998-2005,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_data.c,v 1.15 2010/01/23 21:14:36 tom Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_behind(const FORM *form)
|
| Description : Check for off-screen data behind. This is nearly trivial
| because the beginning of a field is fixed.
|
| Return Values : TRUE - there are off-screen data behind
| FALSE - there are no off-screen data behind
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
data_behind(const FORM *form)
{
bool result = FALSE;
T((T_CALLED("data_behind(%p)"), (const void *)form));
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;
}
}
returnBool(result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static char * Only_Padding(
| WINDOW *w,
| int len,
| int pad)
|
| Description : Test if 'length' cells starting at the current position
| contain a padding character.
|
| Return Values : true if only padding cells are found
+--------------------------------------------------------------------------*/
NCURSES_INLINE static bool
Only_Padding(WINDOW *w, int len, int pad)
{
bool result = TRUE;
int y, x, j;
FIELD_CELL cell;
getyx(w, y, x);
for (j = 0; j < len; ++j)
{
if (wmove(w, y, x + j) != ERR)
{
#if USE_WIDEC_SUPPORT
if (win_wch(w, &cell) != ERR)
{
if ((chtype)CharOf(cell) != ChCharOf(pad)
|| cell.chars[1] != 0)
{
result = FALSE;
break;
}
}
#else
cell = winch(w);
if (ChCharOf(cell) != ChCharOf(pad))
{
result = FALSE;
break;
}
#endif
}
else
{
/* if an error, return true: no non-padding text found */
break;
}
}
/* no need to reset the cursor position; caller does this */
return result;
}
/*---------------------------------------------------------------------------
| 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
data_ahead(const FORM *form)
{
bool result = FALSE;
T((T_CALLED("data_ahead(%p)"), (const void *)form));
if (form && (form->status & _POSTED) && form->current)
{
FIELD *field;
bool cursor_moved = FALSE;
int pos;
field = form->current;
assert(form->w);
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);
if (Only_Padding(form->w, check_len, field->pad))
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++;
if (!Only_Padding(form->w, field->cols, field->pad))
{
result = TRUE;
break;
}
}
}
if (cursor_moved)
wmove(form->w, form->currow, form->curcol);
}
returnBool(result);
}
/* frm_data.c ends here */

View File

@@ -0,0 +1,448 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_def.c,v 1.25 2010/01/23 21:14:36 tom 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 */
};
NCURSES_EXPORT_VAR(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;
T((T_CALLED("Connect_Fields(%p,%p)"), (void *)form, (void *)fields));
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 || (short)field_cnt < 0)
RETURN(E_BAD_ARGUMENT);
/* allocate page structures */
if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0)
{
T((T_CREATE("_PAGE %p"), (void *)pg));
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);
}
if (fld)
{
form->page[page_nr].smin = fld->index;
form->page[page_nr].smax = fld->sprev->index;
}
else
{
form->page[page_nr].smin = 0;
form->page[page_nr].smax = 0;
}
}
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
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_CONNECTED - a field is already connected
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_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_sp(SCREEN* sp, FIELD** fields )
|
| Description : Create new form with given array of fields.
|
| Return Values : Pointer to form. NULL if error occurred.
! Set errno:
| E_OK - success
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_CONNECTED - a field is already connected
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FORM *)
NCURSES_SP_NAME(new_form) (NCURSES_SP_DCLx FIELD **fields)
{
int err = E_SYSTEM_ERROR;
FORM *form = (FORM *)0;
T((T_CALLED("new_form(%p,%p)"), (void *)SP_PARM, (void *)fields));
if (IsValidScreen(SP_PARM))
{
form = typeMalloc(FORM, 1);
if (form)
{
T((T_CREATE("form %p"), (void *)form));
*form = *_nc_Default_Form;
/* This ensures win and sub are always non-null,
so we can derive always the SCREEN that this form is
running on. */
form->win = StdScreen(SP_PARM);
form->sub = StdScreen(SP_PARM);
if ((err = Associate_Fields(form, fields)) != E_OK)
{
free_form(form);
form = (FORM *)0;
}
}
}
if (!form)
SET_ERROR(err);
returnForm(form);
}
/*---------------------------------------------------------------------------
| 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 occurred.
! Set errno:
| E_OK - success
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_CONNECTED - a field is already connected
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
#if NCURSES_SP_FUNCS
NCURSES_EXPORT(FORM *)
new_form(FIELD **fields)
{
return NCURSES_SP_NAME(new_form) (CURRENT_SCREEN, fields);
}
#endif
/*---------------------------------------------------------------------------
| 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
free_form(FORM *form)
{
T((T_CALLED("free_form(%p)"), (void *)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 or field array
| E_CONNECTED - a field is already connected
| E_POSTED - form is posted
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_fields(FORM *form, FIELD **fields)
{
FIELD **old;
int res;
T((T_CALLED("set_form_fields(%p,%p)"), (void *)form, (void *)fields));
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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD **)
form_fields(const FORM *form)
{
T((T_CALLED("form_field(%p)"), (const void *)form));
returnFieldPtr(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
field_count(const FORM *form)
{
T((T_CALLED("field_count(%p)"), (const void *)form));
returnCode(Normalize_Form(form)->maxfield);
}
/* frm_def.c ends here */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,142 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_hook.c,v 1.15 2010/01/23 21:12:08 tom Exp $")
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
{\
T((T_CALLED("set_" #typ"_"#name"(%p,%p)"), form, 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 ) \
NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
{\
T((T_CALLED(#typ "_" #name "(%p)"), (const void *) form));\
returnFormHook( 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,127 @@
/****************************************************************************
* Copyright (c) 1998-2005,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_opts.c,v 1.15 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_opts(FORM *form, Form_Options opts)
{
T((T_CALLED("set_form_opts(%p,%d)"), (void *)form, 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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Form_Options)
form_opts(const FORM *form)
{
T((T_CALLED("form_opts(%p)"), (const void *)form));
returnCode((int)(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
form_opts_on(FORM *form, Form_Options opts)
{
T((T_CALLED("form_opts_on(%p,%d)"), (void *)form, 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
form_opts_off(FORM *form, Form_Options opts)
{
T((T_CALLED("form_opts_off(%p,%d)"), (void *)form, 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,106 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_page.c,v 1.11 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_page(FORM *form, int page)
{
int err = E_OK;
T((T_CALLED("set_form_page(%p,%d)"), (void *)form, page));
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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
form_page(const FORM *form)
{
T((T_CALLED("form_page(%p)"), (const void *)form));
returnCode(Normalize_Form(form)->curpage);
}
/* frm_page.c ends here */

View File

@@ -0,0 +1,124 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_post.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
post_form(FORM *form)
{
WINDOW *formwin;
int err;
int page;
T((T_CALLED("post_form(%p)"), (void *)form));
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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
unpost_form(FORM *form)
{
T((T_CALLED("unpost_form(%p)"), (void *)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,170 @@
/****************************************************************************
* Copyright (c) 1998-2008,2009 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, 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.17 2009/10/10 16:17:01 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
form_request_name(int request)
{
T((T_CALLED("form_request_name(%d)"), request));
if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
{
SET_ERROR(E_BAD_ARGUMENT);
returnCPtr((const char *)0);
}
else
returnCPtr(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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(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];
T((T_CALLED("form_request_by_name(%s)"), _nc_visbuf(str)));
if (str)
{
strncpy(buf, str, sizeof(buf));
while ((i < sizeof(buf)) && (buf[i] != '\0'))
{
buf[i] = (char)toupper(UChar(buf[i]));
i++;
}
for (i = 0; i < A_SIZE; i++)
{
if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
returnCode(MIN_FORM_COMMAND + (int)i);
}
}
RETURN(E_NO_MATCH);
}
/* frm_req_name.c ends here */

View File

@@ -0,0 +1,69 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_scale.c,v 1.10 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
scale_form(const FORM *form, int *rows, int *cols)
{
T((T_CALLED("scale_form(%p,%p,%p)"),
(const void *)form,
(void *)rows,
(void *)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,86 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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, 1995-1997,2009 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_sub.c,v 1.12 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_sub(FORM *form, WINDOW *win)
{
T((T_CALLED("set_form_sub(%p,%p)"), (void *)form, (void *)win));
if (form && (form->status & _POSTED))
RETURN(E_POSTED);
else
{
#if NCURSES_SP_FUNCS
FORM *f = Normalize_Form(form);
f->sub = win ? win : StdScreen(Get_Form_Screen(f));
RETURN(E_OK);
#else
Normalize_Form(form)->sub = win;
RETURN(E_OK);
#endif
}
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : WINDOW *form_sub(const FORM *)
|
| Description : Retrieve the window of the form.
|
| Return Values : The pointer to the Subwindow.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
form_sub(const FORM *form)
{
const FORM *f;
T((T_CALLED("form_sub(%p)"), (const void *)form));
f = Normalize_Form(form);
returnWin(Get_Form_Window(f));
}
/* frm_sub.c ends here */

View File

@@ -0,0 +1,72 @@
/****************************************************************************
* Copyright (c) 1998-2004,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_user.c,v 1.15 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_userptr(FORM *form, void *usrptr)
{
T((T_CALLED("set_form_userptr(%p,%p)"), (void *)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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
form_userptr(const FORM *form)
{
T((T_CALLED("form_userptr(%p)"), (const void *)form));
returnVoidPtr(Normalize_Form(form)->usrptr);
}
/* frm_user.c ends here */

View File

@@ -0,0 +1,92 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: frm_win.c,v 1.16 2010/01/23 21:14:36 tom 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
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
set_form_win(FORM *form, WINDOW *win)
{
T((T_CALLED("set_form_win(%p,%p)"), (void *)form, (void *)win));
if (form && (form->status & _POSTED))
RETURN(E_POSTED);
else
{
#if NCURSES_SP_FUNCS
FORM *f = Normalize_Form(form);
f->win = win ? win : StdScreen(Get_Form_Screen(f));
RETURN(E_OK);
#else
Normalize_Form(form)->win = win;
RETURN(E_OK);
#endif
}
}
/*---------------------------------------------------------------------------
| 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.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
form_win(const FORM *form)
{
WINDOW *result;
const FORM *f;
T((T_CALLED("form_win(%p)"), (const void *)form));
f = Normalize_Form(form);
#if NCURSES_SP_FUNCS
result = (f->win ? f->win : StdScreen(Get_Form_Screen(f)));
#else
result = (f->win ? f->win : stdscr);
#endif
returnWin(result);
}
/* frm_win.c ends here */

View File

@@ -0,0 +1,202 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_alnum.c,v 1.24 2010/01/23 21:14:36 tom Exp $")
#define thisARG alnumARG
typedef struct
{
int width;
}
thisARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_This_Type(void *arg)
|
| Description : Allocate structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_This_Type(void *arg)
{
thisARG *argp = (thisARG *) 0;
if (arg)
{
argp = typeMalloc(thisARG, 1);
if (argp)
{
T((T_CREATE("thisARG %p"), (void *)argp));
argp->width = *((int *)arg);
}
}
return ((void *)argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_This_Type(va_list *ap)
|
| Description : Allocate structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Make_This_Type(va_list *ap)
{
int w = va_arg(*ap, int);
return Generic_This_Type((void *)&w);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_ThisType(const void *argp)
|
| Description : Copy structure for alphanumeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *
Copy_This_Type(const void *argp)
{
const thisARG *ap = (const thisARG *)argp;
thisARG *result = typeMalloc(thisARG, 1);
if (result)
{
T((T_CREATE("thisARG %p"), (void *)result));
*result = *ap;
}
return ((void *)result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_This_Type(void *argp)
|
| Description : Free structure for alphanumeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void
Free_This_Type(void *argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Character(int c, const void *argp GCC_UNUSED)
{
#if USE_WIDEC_SUPPORT
if (iswalnum((wint_t) c))
return TRUE;
#endif
return (isalnum(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Field(FIELD *field, const void *argp)
{
int width = ((const thisARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field, 0);
bool result = (width < 0);
Check_CTYPE_Field(result, bp, width, Check_This_Character);
return (result);
}
static FIELDTYPE typeTHIS =
{
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_This_Type,
Copy_This_Type,
Free_This_Type,
INIT_FT_FUNC(Check_This_Field),
INIT_FT_FUNC(Check_This_Character),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
Generic_This_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_ALNUM(void)
{
return TYPE_ALNUM;
}
#endif
/* fty_alnum.c ends here */

View File

@@ -0,0 +1,202 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_alpha.c,v 1.26 2010/01/23 21:14:36 tom Exp $")
#define thisARG alphaARG
typedef struct
{
int width;
}
thisARG;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_This_Type(va_list *ap)
|
| Description : Allocate structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_This_Type(void *arg)
{
thisARG *argp = (thisARG *) 0;
if (arg)
{
argp = typeMalloc(thisARG, 1);
if (argp)
{
T((T_CREATE("thisARG %p"), (void *)argp));
argp->width = *((int *)arg);
}
}
return ((void *)argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_This_Type(va_list *ap)
|
| Description : Allocate structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Make_This_Type(va_list *ap)
{
int w = va_arg(*ap, int);
return Generic_This_Type((void *)&w);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_This_Type(const void * argp)
|
| Description : Copy structure for alpha type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *
Copy_This_Type(const void *argp)
{
const thisARG *ap = (const thisARG *)argp;
thisARG *result = typeMalloc(thisARG, 1);
if (result)
{
T((T_CREATE("thisARG %p"), (void *)result));
*result = *ap;
}
return ((void *)result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_This_Type(void *argp)
|
| Description : Free structure for alpha type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void
Free_This_Type(void *argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Character(int c, const void *argp GCC_UNUSED)
{
#if USE_WIDEC_SUPPORT
if (iswalpha((wint_t) c))
return TRUE;
#endif
return (isalpha(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Field(FIELD *field, const void *argp)
{
int width = ((const thisARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field, 0);
bool result = (width < 0);
Check_CTYPE_Field(result, bp, width, Check_This_Character);
return (result);
}
static FIELDTYPE typeTHIS =
{
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_This_Type,
Copy_This_Type,
Free_This_Type,
INIT_FT_FUNC(Check_This_Field),
INIT_FT_FUNC(Check_This_Character),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
Generic_This_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_ALPHA(void)
{
return TYPE_ALPHA;
}
#endif
/* fty_alpha.c ends here */

View File

@@ -0,0 +1,442 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_enum.c,v 1.26 2010/05/01 21:11:07 tom Exp $")
typedef struct
{
char **kwds;
int count;
bool checkcase;
bool checkunique;
}
enumARG;
typedef struct
{
char **kwds;
int ccase;
int cunique;
}
enumParams;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_Enum_Type(void * arg)
|
| Description : Allocate structure for enumeration type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_Enum_Type(void *arg)
{
enumARG *argp = (enumARG *)0;
enumParams *params = (enumParams *) arg;
if (params)
{
argp = typeMalloc(enumARG, 1);
if (argp)
{
int cnt = 0;
char **kp = (char **)0;
char **kwds = (char **)0;
char **kptarget;
int ccase, cunique;
T((T_CREATE("enumARG %p"), (void *)argp));
kwds = params->kwds;
ccase = params->ccase;
cunique = params->cunique;
argp->checkcase = ccase ? TRUE : FALSE;
argp->checkunique = cunique ? TRUE : FALSE;
argp->kwds = (char **)0;
kp = kwds;
while (kp && (*kp++))
cnt++;
argp->count = cnt;
if (cnt > 0)
{
/* We copy the keywords, because we can't rely on the fact
that the caller doesn't relocate or free the memory used
for the keywords (maybe he has GC)
*/
argp->kwds = typeMalloc(char *, cnt + 1);
kp = kwds;
if ((kptarget = argp->kwds) != 0)
{
while (kp && (*kp))
{
(*kptarget++) = strdup(*kp++);
}
*kptarget = (char *)0;
}
}
}
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| 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)
{
enumParams params;
params.kwds = va_arg(*ap, char **);
params.ccase = va_arg(*ap, int);
params.cunique = va_arg(*ap, int);
return Generic_Enum_Type((void *)&params);
}
/*---------------------------------------------------------------------------
| 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)
{
enumARG *result = (enumARG *)0;
if (argp)
{
const enumARG *ap = (const enumARG *)argp;
result = typeMalloc(enumARG, 1);
if (result)
{
T((T_CREATE("enumARG %p"), (void *)result));
*result = *ap;
if (ap->count > 0)
{
char **kptarget;
char **kp = ap->kwds;
result->kwds = typeMalloc(char *, 1 + ap->count);
if ((kptarget = result->kwds) != 0)
{
while (kp && (*kp))
{
(*kptarget++) = strdup(*kp++);
}
*kptarget = (char *)0;
}
}
}
}
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)
{
const enumARG *ap = (const enumARG *)argp;
if (ap->kwds && ap->count > 0)
{
char **kp = ap->kwds;
int cnt = 0;
while (kp && (*kp))
{
free(*kp++);
cnt++;
}
assert(cnt == ap->count);
free(ap->kwds);
}
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 whether 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 (kwds && (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 (kwds && (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);
if (kwds)
{
while (cnt--)
{
if (Compare((unsigned char *)(*kwds++), bp, ccase) == EXACT)
break;
}
if (cnt <= 0)
kwds = args->kwds;
if ((cnt >= 0) || (Compare((const 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);
if (kwds)
{
while (cnt--)
{
if (Compare((unsigned char *)(*kwds--), bp, ccase) == EXACT)
break;
}
if (cnt <= 0)
kwds = &args->kwds[args->count - 1];
if ((cnt >= 0) || (Compare((const 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,
INIT_FT_FUNC(Check_Enum_Field),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(Next_Enum),
INIT_FT_FUNC(Previous_Enum),
#if NCURSES_INTEROP_FUNCS
Generic_Enum_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE *)
TYPE_ENUM = &typeENUM;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_ENUM(void)
{
return TYPE_ENUM;
}
#endif
/* fty_enum.c ends here */

View File

@@ -0,0 +1,297 @@
/****************************************************************************
* Copyright (c) 2008-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_generic.c,v 1.5 2010/01/23 21:14:36 tom Exp $")
/*
* This is not a full implementation of a field type, but adds some
* support for higher level languages with some restrictions to interop
* with C language. Especially the collection of arguments for the
* various fieldtypes is not based on the vararg C mechanism, but on a
* iterator based callback mechanism that allowes the high level language
* to provide the arguments as a structure. Most languages have mechanisms
* to layout structures so that they can be passed to C.
* The languages can register a new generic fieldtype dynamically and store
* a handle (key) to the calling object as an argument. Together with that
* it can register a freearg callback, so that the high level language
* remains in control of the memory management of the arguments they pass.
* The design idea is, that the high-level language - typically a OO
* language like C# or Java, uses it's own dispatching mechanisms
* (polymorphism) to call the proper check routines responsible for the
* argument type. So these language implement typically only one generic
* fieldtype they register with the forms library using this call.
*
* For that purpose we have extended the fieldtype struc by a new element
* that gets the arguments from a single struct passed by the caller.
*
*/
#if NCURSES_INTEROP_FUNCS
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_This_Type( void * arg )
|
| Description : We interpret the passed arg just as a handle the
| calling language uses to keep track of its allocated
| argument structures. We can simply copy it back.
|
| Return Values : Pointer to argument structure
+--------------------------------------------------------------------------*/
static void *
Generic_This_Type(void *arg)
{
return (arg);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FIELDTYPE *_nc_generic_fieldtype(
| bool (* const field_check)(FIELD *,const void *),
| bool (* const char_check) (int, const void *),
| bool (*const next)(FORM*,FIELD*,const void*),
| bool (*const prev)(FORM*,FIELD*,const void*),
| void (*freecallback)(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. A callback to allow the
| release of the allocated memory must also be provided.
| For generic field types, we provide some more
| information about the field as parameters.
|
| 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 occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_generic_fieldtype(bool (*const field_check) (FORM *, FIELD *, const void *),
bool (*const char_check) (int, FORM *, FIELD *, const
void *),
bool (*const next) (FORM *, FIELD *, const void *),
bool (*const prev) (FORM *, FIELD *, const void *),
void (*freecallback) (void *))
{
int code = E_SYSTEM_ERROR;
FIELDTYPE *res = (FIELDTYPE *)0;
T((T_CALLED("_nc_generic_fieldtype(%p,%p,%p,%p,%p)"),
field_check, char_check, next, prev, freecallback));
if (field_check || char_check)
{
res = typeMalloc(FIELDTYPE, 1);
if (res)
{
*res = *_nc_Default_FieldType;
res->status |= (_HAS_ARGS | _GENERIC);
res->fieldcheck.gfcheck = field_check;
res->charcheck.gccheck = char_check;
res->genericarg = Generic_This_Type;
res->freearg = freecallback;
res->enum_next.gnext = next;
res->enum_prev.gprev = prev;
code = E_OK;
}
}
else
code = E_BAD_ARGUMENT;
if (E_OK != code)
SET_ERROR(code);
returnFieldType(res);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static TypeArgument *GenericArgument(
| const FIELDTYPE* typ,
| int (*argiterator)(void**),
| int* err)
|
| Description : The iterator callback must browse through all fieldtype
| parameters that have an argument associated with the
| type. The iterator returns 1 if the operation to get
| the next element was successfull, 0 otherwise. If the
| iterator could move to the next argument, it fills
| the void* pointer representing the argument into the
| location provided as argument to the iterator.
| The err reference is used to keep track of errors.
|
| Return Values : Pointer to argument structure
+--------------------------------------------------------------------------*/
static TypeArgument *
GenericArgument(const FIELDTYPE *typ,
int (*argiterator) (void **), int *err)
{
TypeArgument *res = (TypeArgument *)0;
if (typ != 0 && (typ->status & _HAS_ARGS) != 0 && err != 0 && argiterator != 0)
{
if (typ->status & _LINKED_TYPE)
{
/* Composite fieldtypes keep track internally of their own memory */
TypeArgument *p = typeMalloc(TypeArgument, 1);
if (p)
{
p->left = GenericArgument(typ->left, argiterator, err);
p->right = GenericArgument(typ->right, argiterator, err);
return p;
}
else
*err += 1;
}
else
{
assert(typ->genericarg != (void *)0);
if (typ->genericarg == 0)
*err += 1;
else
{
void *argp;
int valid = argiterator(&argp);
if (valid == 0 || argp == 0 ||
!(res = (TypeArgument *)typ->genericarg(argp)))
{
*err += 1;
}
}
}
}
return res;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int _nc_set_generic_fieldtype(
| FIELD* field,
| FIELDTYPE* ftyp,
| int (*argiterator)(void**))
|
| Description : Assign the fieldtype to the field and use the iterator
| mechanism to get the arguments when a check is
| performed.
|
| Return Values : E_OK if all went well
| E_SYSTEM_ERROR if an error occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
_nc_set_generic_fieldtype(FIELD *field,
FIELDTYPE *ftyp,
int (*argiterator) (void **))
{
int code = E_SYSTEM_ERROR;
int err = 0;
if (field)
{
if (field && field->type)
_nc_Free_Type(field);
field->type = ftyp;
if (ftyp)
{
if (argiterator)
{
/* The precondition is that the iterator is reset */
field->arg = (void *)GenericArgument(field->type, argiterator, &err);
if (err)
{
_nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
field->type = (FIELDTYPE *)0;
field->arg = (void *)0;
}
else
{
code = E_OK;
if (field->type)
field->type->ref++;
}
}
}
else
{
field->arg = (void *)0;
code = E_OK;
}
}
return code;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : WINDOW* _nc_form_cursor(
| FORM* form,
| int *pRow, int *pCol)
|
| Description : Get the current position of the form cursor position
| We also return the field window
|
| Return Values : The fields Window or NULL on error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
_nc_form_cursor(const FORM *form, int *pRow, int *pCol)
{
int code = E_SYSTEM_ERROR;
WINDOW *res = (WINDOW *)0;
if (!(form == 0 || pRow == 0 || pCol == 0))
{
*pRow = form->currow;
*pCol = form->curcol;
res = form->w;
code = E_OK;
}
if (code != E_OK)
SET_ERROR(code);
return res;
}
#else
extern void _nc_fty_generic(void);
void
_nc_fty_generic(void)
{
}
#endif
/* fty_generic.c ends here */

View File

@@ -0,0 +1,293 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_int.c,v 1.25 2010/01/23 21:14:36 tom Exp $")
#if USE_WIDEC_SUPPORT
#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
#else
#define isDigit(c) isdigit(UChar(c))
#endif
#define thisARG integerARG
typedef struct
{
int precision;
long low;
long high;
}
thisARG;
typedef struct
{
int precision;
long low;
long high;
}
integerPARM;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_This_Type( void * arg )
|
| Description : Allocate structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_This_Type(void *arg)
{
thisARG *argp = (thisARG *) 0;
thisARG *param = (thisARG *) arg;
if (param)
{
argp = typeMalloc(thisARG, 1);
if (argp)
{
T((T_CREATE("thisARG %p"), (void *)argp));
*argp = *param;
}
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_This_Type( va_list * ap )
|
| Description : Allocate structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Make_This_Type(va_list *ap)
{
thisARG arg;
arg.precision = va_arg(*ap, int);
arg.low = va_arg(*ap, long);
arg.high = va_arg(*ap, long);
return Generic_This_Type((void *)&arg);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_This_Type(const void * argp)
|
| Description : Copy structure for integer type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *
Copy_This_Type(const void *argp)
{
const thisARG *ap = (const thisARG *)argp;
thisARG *result = (thisARG *) 0;
if (argp)
{
result = typeMalloc(thisARG, 1);
if (result)
{
T((T_CREATE("thisARG %p"), (void *)result));
*result = *ap;
}
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_This_Type(void * argp)
|
| Description : Free structure for integer type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void
Free_This_Type(void *argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Field(FIELD *field, const void *argp)
{
const thisARG *argi = (const thisARG *)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];
bool result = FALSE;
while (*bp && *bp == ' ')
bp++;
if (*bp)
{
if (*bp == '-')
bp++;
#if USE_WIDEC_SUPPORT
if (*bp)
{
bool blank = FALSE;
int len;
int n;
wchar_t *list = _nc_Widen_String((char *)bp, &len);
if (list != 0)
{
result = TRUE;
for (n = 0; n < len; ++n)
{
if (blank)
{
if (list[n] != ' ')
{
result = FALSE;
break;
}
}
else if (list[n] == ' ')
{
blank = TRUE;
}
else if (!isDigit(list[n]))
{
result = FALSE;
break;
}
}
free(list);
}
}
#else
while (*bp)
{
if (!isdigit(UChar(*bp)))
break;
bp++;
}
while (*bp && *bp == ' ')
bp++;
result = (*bp == '\0');
#endif
if (result)
{
val = atol(s);
if (low < high)
{
if (val < low || val > high)
result = FALSE;
}
if (result)
{
sprintf(buf, "%.*ld", (prec > 0 ? prec : 0), val);
set_field_buffer(field, 0, buf);
}
}
}
return (result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Character(int c, const void *argp GCC_UNUSED)
{
return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
}
static FIELDTYPE typeTHIS =
{
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_This_Type,
Copy_This_Type,
Free_This_Type,
INIT_FT_FUNC(Check_This_Field),
INIT_FT_FUNC(Check_This_Character),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
Generic_This_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_INTEGER(void)
{
return TYPE_INTEGER;
}
#endif
/* fty_int.c ends here */

View File

@@ -0,0 +1,120 @@
/****************************************************************************
* Copyright (c) 1998-2006,2009 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 : Per Foreby, perf@efd.lth.se *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_ipv4.c,v 1.10 2009/11/07 20:17:58 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(UChar(*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 (isspace(UChar(*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(UChar(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,
INIT_FT_FUNC(Check_IPV4_Field),
INIT_FT_FUNC(Check_IPV4_Character),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
NULL
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_IPV4 = &typeIPV4;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_IPV4(void)
{
return TYPE_IPV4;
}
#endif
/* fty_ipv4.c ends here */

View File

@@ -0,0 +1,339 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_num.c,v 1.28 2010/01/23 21:14:36 tom Exp $")
#if HAVE_LOCALE_H
#include <locale.h>
#endif
#if HAVE_LOCALE_H
#define isDecimalPoint(c) ((c) == ((L && L->decimal_point) ? *(L->decimal_point) : '.'))
#else
#define isDecimalPoint(c) ((c) == '.')
#endif
#if USE_WIDEC_SUPPORT
#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
#else
#define isDigit(c) isdigit(UChar(c))
#endif
#define thisARG numericARG
typedef struct
{
int precision;
double low;
double high;
struct lconv *L;
}
thisARG;
typedef struct
{
int precision;
double low;
double high;
}
thisPARM;
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_This_Type(void * arg)
|
| Description : Allocate structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_This_Type(void *arg)
{
thisARG *argn = (thisARG *) 0;
thisPARM *args = (thisPARM *) arg;
if (args)
{
argn = typeMalloc(thisARG, 1);
if (argn)
{
T((T_CREATE("thisARG %p"), (void *)argn));
argn->precision = args->precision;
argn->low = args->low;
argn->high = args->high;
#if HAVE_LOCALE_H
argn->L = localeconv();
#else
argn->L = NULL;
#endif
}
}
return (void *)argn;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Make_This_Type(va_list * ap)
|
| Description : Allocate structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Make_This_Type(va_list *ap)
{
thisPARM arg;
arg.precision = va_arg(*ap, int);
arg.low = va_arg(*ap, double);
arg.high = va_arg(*ap, double);
return Generic_This_Type((void *)&arg);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Copy_This_Type(const void * argp)
|
| Description : Copy structure for numeric type argument.
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
static void *
Copy_This_Type(const void *argp)
{
const thisARG *ap = (const thisARG *)argp;
thisARG *result = (thisARG *) 0;
if (argp)
{
result = typeMalloc(thisARG, 1);
if (result)
{
T((T_CREATE("thisARG %p"), (void *)result));
*result = *ap;
}
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void Free_This_Type(void * argp)
|
| Description : Free structure for numeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
static void
Free_This_Type(void *argp)
{
if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Field(FIELD *field, const void *argp)
{
const thisARG *argn = (const thisARG *)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];
bool result = FALSE;
while (*bp && *bp == ' ')
bp++;
if (*bp)
{
if (*bp == '-' || *bp == '+')
bp++;
#if USE_WIDEC_SUPPORT
if (*bp)
{
bool blank = FALSE;
int state = 0;
int len;
int n;
wchar_t *list = _nc_Widen_String((char *)bp, &len);
if (list != 0)
{
result = TRUE;
for (n = 0; n < len; ++n)
{
if (blank)
{
if (list[n] != ' ')
{
result = FALSE;
break;
}
}
else if (list[n] == ' ')
{
blank = TRUE;
}
else if (isDecimalPoint(list[n]))
{
if (++state > 1)
{
result = FALSE;
break;
}
}
else if (!isDigit(list[n]))
{
result = FALSE;
break;
}
}
free(list);
}
}
#else
while (*bp)
{
if (!isdigit(UChar(*bp)))
break;
bp++;
}
if (isDecimalPoint(*bp))
{
bp++;
while (*bp)
{
if (!isdigit(UChar(*bp)))
break;
bp++;
}
}
while (*bp && *bp == ' ')
bp++;
result = (*bp == '\0');
#endif
if (result)
{
val = atof(s);
if (low < high)
{
if (val < low || val > high)
result = FALSE;
}
if (result)
{
sprintf(buf, "%.*f", (prec > 0 ? prec : 0), val);
set_field_buffer(field, 0, buf);
}
}
}
return (result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static bool Check_This_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_This_Character(int c, const void *argp)
{
const thisARG *argn = (const thisARG *)argp;
struct lconv *L = argn->L;
return ((isDigit(c) ||
c == '+' ||
c == '-' ||
isDecimalPoint(c))
? TRUE
: FALSE);
}
static FIELDTYPE typeTHIS =
{
_HAS_ARGS | _RESIDENT,
1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_This_Type,
Copy_This_Type,
Free_This_Type,
INIT_FT_FUNC(Check_This_Field),
INIT_FT_FUNC(Check_This_Character),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
Generic_This_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_NUMERIC(void)
{
return TYPE_NUMERIC;
}
#endif
/* fty_num.c ends here */

View File

@@ -0,0 +1,350 @@
/****************************************************************************
* Copyright (c) 1998-2009,2010 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 *
* *
***************************************************************************/
#include "form.priv.h"
MODULE_ID("$Id: fty_regex.c,v 1.24 2010/01/23 21:14:37 tom 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
#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
# define MAYBE_UNUSED
#else
# define MAYBE_UNUSED GCC_UNUSED
#endif
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : static void *Generic_RegularExpression_Type(void * arg)
|
| Description : Allocate structure for regex type argument.
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
static void *
Generic_RegularExpression_Type(void *arg MAYBE_UNUSED)
{
#if HAVE_REGEX_H_FUNCS
char *rx = (char *)arg;
RegExp_Arg *preg = (RegExp_Arg *)0;
if (rx)
{
preg = typeMalloc(RegExp_Arg, 1);
if (preg)
{
T((T_CREATE("RegExp_Arg %p"), (void *)preg));
if (((preg->pRegExp = typeMalloc(regex_t, 1)) != 0)
&& !regcomp(preg->pRegExp, rx,
(REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
{
T((T_CREATE("regex_t %p"), (void *)preg->pRegExp));
preg->refCount = typeMalloc(unsigned long, 1);
*(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 = (char *)arg;
RegExp_Arg *pArg = (RegExp_Arg *)0;
if (rx)
{
pArg = typeMalloc(RegExp_Arg, 1);
if (pArg)
{
int blen = RX_INCREMENT;
T((T_CREATE("RegExp_Arg %p"), pArg));
pArg->compiled_expression = NULL;
pArg->refCount = typeMalloc(unsigned long, 1);
*(pArg->refCount) = 1;
do
{
char *buf = typeMalloc(char, 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 *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)
{
char *rx = va_arg(*ap, char *);
return Generic_RegularExpression_Type((void *)rx);
}
/*---------------------------------------------------------------------------
| 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 MAYBE_UNUSED)
{
#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 MAYBE_UNUSED)
{
#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 MAYBE_UNUSED,
const void *argp MAYBE_UNUSED)
{
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,
INIT_FT_FUNC(Check_RegularExpression_Field),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
INIT_FT_FUNC(NULL),
#if NCURSES_INTEROP_FUNCS
Generic_RegularExpression_Type
#endif
};
NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_REGEXP = &typeREGEXP;
#if NCURSES_INTEROP_FUNCS
/* The next routines are to simplify the use of ncurses from
programming languages with restictions on interop with C level
constructs (e.g. variable access or va_list + ellipsis constructs)
*/
NCURSES_EXPORT(FIELDTYPE *)
_nc_TYPE_REGEXP(void)
{
return TYPE_REGEXP;
}
#endif
/* fty_regex.c ends here */

View File

@@ -0,0 +1,32 @@
##############################################################################
# Copyright (c) 1998,2006 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
# vile:makemode

View File

@@ -0,0 +1,777 @@
/****************************************************************************
* Copyright (c) 1998-2005,2010 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 1996-2005,2010 *
****************************************************************************/
/* LINTLIBRARY */
/* ./f_trace.c */
#include <form.priv.h>
#undef _nc_retrace_field_ptr
FIELD **_nc_retrace_field_ptr(
FIELD **code)
{ return(*(FIELD ***)0); }
#undef _nc_retrace_field
FIELD *_nc_retrace_field(
FIELD *code)
{ return(*(FIELD **)0); }
#undef _nc_retrace_field_type
FIELDTYPE *_nc_retrace_field_type(
FIELDTYPE *code)
{ return(*(FIELDTYPE **)0); }
#undef _nc_retrace_form
FORM *_nc_retrace_form(
FORM *code)
{ return(*(FORM **)0); }
#undef _nc_retrace_form_hook
Form_Hook _nc_retrace_form_hook(
Form_Hook code)
{ return(*(Form_Hook *)0); }
/* ./fld_arg.c */
#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
NCURSES_BOOL _nc_Copy_Type(
FIELD *dst,
FIELD const *src)
{ return(*(NCURSES_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,
NCURSES_BOOL (*const next_choice)(
FIELD *p1,
const void *p2),
NCURSES_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
FIELDTYPE *_nc_Default_FieldType;
#undef new_fieldtype
FIELDTYPE *new_fieldtype(
NCURSES_BOOL (*const field_check)(
FIELD *p1,
const void *p2),
NCURSES_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,
NCURSES_BOOL new_page_flag)
{ return(*(int *)0); }
#undef new_page
NCURSES_BOOL new_page(
const FIELD *field)
{ return(*(NCURSES_BOOL *)0); }
/* ./fld_stat.c */
#undef set_field_status
int set_field_status(
FIELD *field,
NCURSES_BOOL status)
{ return(*(int *)0); }
#undef field_status
NCURSES_BOOL field_status(
const FIELD *field)
{ return(*(NCURSES_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
NCURSES_BOOL data_behind(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
#undef data_ahead
NCURSES_BOOL data_ahead(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
/* ./frm_def.c */
#undef _nc_Default_Form
FORM *_nc_Default_Form;
#undef new_form_sp
FORM *new_form_sp(
SCREEN *sp,
FIELD **fields)
{ return(*(FORM **)0); }
#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_get_fieldbuffer
void _nc_get_fieldbuffer(
FORM *form,
FIELD *field,
char *buf)
{ /* void */ }
#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
NCURSES_BOOL _nc_Internal_Validation(
FORM *form)
{ return(*(NCURSES_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;
NCURSES_BOOL checkcase;
NCURSES_BOOL checkunique;
}
enumARG;
typedef struct
{
char **kwds;
int ccase;
int cunique;
}
enumParams;
#undef TYPE_ENUM
FIELDTYPE *TYPE_ENUM;
/* ./fty_generic.c */
#undef _nc_fty_generic
void _nc_fty_generic(void)
{ /* void */ }
/* ./fty_int.c */
typedef struct
{
int precision;
long low;
long high;
}
integerARG;
typedef struct
{
int precision;
long low;
long high;
}
integerPARM;
#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;
typedef struct
{
int precision;
double low;
double high;
}
thisPARM;
#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,777 @@
/****************************************************************************
* Copyright (c) 2010 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 2010 *
****************************************************************************/
/* LINTLIBRARY */
/* ./f_trace.c */
#include <form.priv.h>
#undef _nc_retrace_field_ptr
FIELD **_nc_retrace_field_ptr(
FIELD **code)
{ return(*(FIELD ***)0); }
#undef _nc_retrace_field
FIELD *_nc_retrace_field(
FIELD *code)
{ return(*(FIELD **)0); }
#undef _nc_retrace_field_type
FIELDTYPE *_nc_retrace_field_type(
FIELDTYPE *code)
{ return(*(FIELDTYPE **)0); }
#undef _nc_retrace_form
FORM *_nc_retrace_form(
FORM *code)
{ return(*(FORM **)0); }
#undef _nc_retrace_form_hook
Form_Hook _nc_retrace_form_hook(
Form_Hook code)
{ return(*(Form_Hook *)0); }
/* ./fld_arg.c */
#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
NCURSES_BOOL _nc_Copy_Type(
FIELD *dst,
FIELD const *src)
{ return(*(NCURSES_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,
NCURSES_BOOL (*const next_choice)(
FIELD *p1,
const void *p2),
NCURSES_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
FIELDTYPE *_nc_Default_FieldType;
#undef new_fieldtype
FIELDTYPE *new_fieldtype(
NCURSES_BOOL (*const field_check)(
FIELD *p1,
const void *p2),
NCURSES_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,
NCURSES_BOOL new_page_flag)
{ return(*(int *)0); }
#undef new_page
NCURSES_BOOL new_page(
const FIELD *field)
{ return(*(NCURSES_BOOL *)0); }
/* ./fld_stat.c */
#undef set_field_status
int set_field_status(
FIELD *field,
NCURSES_BOOL status)
{ return(*(int *)0); }
#undef field_status
NCURSES_BOOL field_status(
const FIELD *field)
{ return(*(NCURSES_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
NCURSES_BOOL data_behind(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
#undef data_ahead
NCURSES_BOOL data_ahead(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
/* ./frm_def.c */
#undef _nc_Default_Form
FORM *_nc_Default_Form;
#undef new_form_sp
FORM *new_form_sp(
SCREEN *sp,
FIELD **fields)
{ return(*(FORM **)0); }
#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_get_fieldbuffer
void _nc_get_fieldbuffer(
FORM *form,
FIELD *field,
char *buf)
{ /* void */ }
#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
NCURSES_BOOL _nc_Internal_Validation(
FORM *form)
{ return(*(NCURSES_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;
NCURSES_BOOL checkcase;
NCURSES_BOOL checkunique;
}
enumARG;
typedef struct
{
char **kwds;
int ccase;
int cunique;
}
enumParams;
#undef TYPE_ENUM
FIELDTYPE *TYPE_ENUM;
/* ./fty_generic.c */
#undef _nc_fty_generic
void _nc_fty_generic(void)
{ /* void */ }
/* ./fty_int.c */
typedef struct
{
int precision;
long low;
long high;
}
integerARG;
typedef struct
{
int precision;
long low;
long high;
}
integerPARM;
#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;
typedef struct
{
int precision;
double low;
double high;
}
thisPARM;
#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,783 @@
/****************************************************************************
* Copyright (c) 2010 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 2010 *
****************************************************************************/
/* LINTLIBRARY */
/* ./f_trace.c */
#include <form.priv.h>
#undef _nc_retrace_field_ptr
FIELD **_nc_retrace_field_ptr(
FIELD **code)
{ return(*(FIELD ***)0); }
#undef _nc_retrace_field
FIELD *_nc_retrace_field(
FIELD *code)
{ return(*(FIELD **)0); }
#undef _nc_retrace_field_type
FIELDTYPE *_nc_retrace_field_type(
FIELDTYPE *code)
{ return(*(FIELDTYPE **)0); }
#undef _nc_retrace_form
FORM *_nc_retrace_form(
FORM *code)
{ return(*(FORM **)0); }
#undef _nc_retrace_form_hook
Form_Hook _nc_retrace_form_hook(
Form_Hook code)
{ return(*(Form_Hook *)0); }
/* ./fld_arg.c */
#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
NCURSES_BOOL _nc_Copy_Type(
FIELD *dst,
FIELD const *src)
{ return(*(NCURSES_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,
NCURSES_BOOL (*const next_choice)(
FIELD *p1,
const void *p2),
NCURSES_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
FIELDTYPE *_nc_Default_FieldType;
#undef new_fieldtype
FIELDTYPE *new_fieldtype(
NCURSES_BOOL (*const field_check)(
FIELD *p1,
const void *p2),
NCURSES_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,
NCURSES_BOOL new_page_flag)
{ return(*(int *)0); }
#undef new_page
NCURSES_BOOL new_page(
const FIELD *field)
{ return(*(NCURSES_BOOL *)0); }
/* ./fld_stat.c */
#undef set_field_status
int set_field_status(
FIELD *field,
NCURSES_BOOL status)
{ return(*(int *)0); }
#undef field_status
NCURSES_BOOL field_status(
const FIELD *field)
{ return(*(NCURSES_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
NCURSES_BOOL data_behind(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
#undef data_ahead
NCURSES_BOOL data_ahead(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
/* ./frm_def.c */
#undef _nc_Default_Form
FORM *_nc_Default_Form;
#undef new_form_sp
FORM *new_form_sp(
SCREEN *sp,
FIELD **fields)
{ return(*(FORM **)0); }
#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_get_fieldbuffer
void _nc_get_fieldbuffer(
FORM *form,
FIELD *field,
cchar_t *buf)
{ /* void */ }
#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
NCURSES_BOOL _nc_Internal_Validation(
FORM *form)
{ return(*(NCURSES_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); }
#undef _nc_Widen_String
wchar_t *_nc_Widen_String(
char *source,
int *lengthp)
{ return(*(wchar_t **)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;
NCURSES_BOOL checkcase;
NCURSES_BOOL checkunique;
}
enumARG;
typedef struct
{
char **kwds;
int ccase;
int cunique;
}
enumParams;
#undef TYPE_ENUM
FIELDTYPE *TYPE_ENUM;
/* ./fty_generic.c */
#undef _nc_fty_generic
void _nc_fty_generic(void)
{ /* void */ }
/* ./fty_int.c */
typedef struct
{
int precision;
long low;
long high;
}
integerARG;
typedef struct
{
int precision;
long low;
long high;
}
integerPARM;
#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;
typedef struct
{
int precision;
double low;
double high;
}
thisPARM;
#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,783 @@
/****************************************************************************
* Copyright (c) 2002-2005,2010 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 2002-2005,2010 *
****************************************************************************/
/* LINTLIBRARY */
/* ./f_trace.c */
#include <form.priv.h>
#undef _nc_retrace_field_ptr
FIELD **_nc_retrace_field_ptr(
FIELD **code)
{ return(*(FIELD ***)0); }
#undef _nc_retrace_field
FIELD *_nc_retrace_field(
FIELD *code)
{ return(*(FIELD **)0); }
#undef _nc_retrace_field_type
FIELDTYPE *_nc_retrace_field_type(
FIELDTYPE *code)
{ return(*(FIELDTYPE **)0); }
#undef _nc_retrace_form
FORM *_nc_retrace_form(
FORM *code)
{ return(*(FORM **)0); }
#undef _nc_retrace_form_hook
Form_Hook _nc_retrace_form_hook(
Form_Hook code)
{ return(*(Form_Hook *)0); }
/* ./fld_arg.c */
#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
NCURSES_BOOL _nc_Copy_Type(
FIELD *dst,
FIELD const *src)
{ return(*(NCURSES_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,
NCURSES_BOOL (*const next_choice)(
FIELD *p1,
const void *p2),
NCURSES_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
FIELDTYPE *_nc_Default_FieldType;
#undef new_fieldtype
FIELDTYPE *new_fieldtype(
NCURSES_BOOL (*const field_check)(
FIELD *p1,
const void *p2),
NCURSES_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,
NCURSES_BOOL new_page_flag)
{ return(*(int *)0); }
#undef new_page
NCURSES_BOOL new_page(
const FIELD *field)
{ return(*(NCURSES_BOOL *)0); }
/* ./fld_stat.c */
#undef set_field_status
int set_field_status(
FIELD *field,
NCURSES_BOOL status)
{ return(*(int *)0); }
#undef field_status
NCURSES_BOOL field_status(
const FIELD *field)
{ return(*(NCURSES_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
NCURSES_BOOL data_behind(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
#undef data_ahead
NCURSES_BOOL data_ahead(
const FORM *form)
{ return(*(NCURSES_BOOL *)0); }
/* ./frm_def.c */
#undef _nc_Default_Form
FORM *_nc_Default_Form;
#undef new_form_sp
FORM *new_form_sp(
SCREEN *sp,
FIELD **fields)
{ return(*(FORM **)0); }
#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_get_fieldbuffer
void _nc_get_fieldbuffer(
FORM *form,
FIELD *field,
cchar_t *buf)
{ /* void */ }
#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
NCURSES_BOOL _nc_Internal_Validation(
FORM *form)
{ return(*(NCURSES_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); }
#undef _nc_Widen_String
wchar_t *_nc_Widen_String(
char *source,
int *lengthp)
{ return(*(wchar_t **)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;
NCURSES_BOOL checkcase;
NCURSES_BOOL checkunique;
}
enumARG;
typedef struct
{
char **kwds;
int ccase;
int cunique;
}
enumParams;
#undef TYPE_ENUM
FIELDTYPE *TYPE_ENUM;
/* ./fty_generic.c */
#undef _nc_fty_generic
void _nc_fty_generic(void)
{ /* void */ }
/* ./fty_int.c */
typedef struct
{
int precision;
long low;
long high;
}
integerARG;
typedef struct
{
int precision;
long low;
long high;
}
integerPARM;
#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;
typedef struct
{
int precision;
double low;
double high;
}
thisPARM;
#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,78 @@
# $Id: modules,v 1.17 2010/01/23 16:26:37 tom Exp $
##############################################################################
# Copyright (c) 1998-2009,2010 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 1995-on
# and: Juergen Pfeifer 2008
#
@ base
# Library objects
f_trace lib $(srcdir) $(HEADER_DEPS)
fld_arg lib $(srcdir) $(HEADER_DEPS)
fld_attr lib $(srcdir) $(HEADER_DEPS)
fld_current lib $(srcdir) $(HEADER_DEPS)
fld_def lib $(srcdir) $(HEADER_DEPS)
fld_dup lib $(srcdir) $(HEADER_DEPS)
fld_ftchoice lib $(srcdir) $(HEADER_DEPS)
fld_ftlink lib $(srcdir) $(HEADER_DEPS)
fld_info lib $(srcdir) $(HEADER_DEPS)
fld_just lib $(srcdir) $(HEADER_DEPS)
fld_link lib $(srcdir) $(HEADER_DEPS)
fld_max lib $(srcdir) $(HEADER_DEPS)
fld_move lib $(srcdir) $(HEADER_DEPS)
fld_newftyp lib $(srcdir) $(HEADER_DEPS)
fld_opts lib $(srcdir) $(HEADER_DEPS)
fld_pad lib $(srcdir) $(HEADER_DEPS)
fld_page lib $(srcdir) $(HEADER_DEPS)
fld_stat lib $(srcdir) $(HEADER_DEPS)
fld_type lib $(srcdir) $(HEADER_DEPS)
fld_user lib $(srcdir) $(HEADER_DEPS)
frm_cursor lib $(srcdir) $(HEADER_DEPS)
frm_data lib $(srcdir) $(HEADER_DEPS)
frm_def lib $(srcdir) $(HEADER_DEPS)
frm_driver lib $(srcdir) $(HEADER_DEPS)
frm_hook lib $(srcdir) $(HEADER_DEPS)
frm_opts lib $(srcdir) $(HEADER_DEPS)
frm_page lib $(srcdir) $(HEADER_DEPS)
frm_post lib $(srcdir) $(HEADER_DEPS)
frm_req_name lib $(srcdir) $(HEADER_DEPS)
frm_scale lib $(srcdir) $(HEADER_DEPS)
frm_sub lib $(srcdir) $(HEADER_DEPS)
frm_user lib $(srcdir) $(HEADER_DEPS)
frm_win lib $(srcdir) $(HEADER_DEPS)
fty_alnum lib $(srcdir) $(HEADER_DEPS)
fty_alpha lib $(srcdir) $(HEADER_DEPS)
fty_enum lib $(srcdir) $(HEADER_DEPS)
fty_generic lib $(srcdir) $(HEADER_DEPS)
fty_int lib $(srcdir) $(HEADER_DEPS)
fty_ipv4 lib $(srcdir) $(HEADER_DEPS)
fty_num lib $(srcdir) $(HEADER_DEPS)
fty_regex lib $(srcdir) $(HEADER_DEPS)
# vile:makemode