summaryrefslogtreecommitdiff
path: root/lib/libform
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libform')
-rw-r--r--lib/libform/Makefile7
-rw-r--r--lib/libform/READ.ME33
-rw-r--r--lib/libform/f_trace.c (renamed from lib/libform/frm_adabind.c)65
-rw-r--r--lib/libform/fld_arg.c48
-rw-r--r--lib/libform/fld_attr.c56
-rw-r--r--lib/libform/fld_current.c82
-rw-r--r--lib/libform/fld_def.c360
-rw-r--r--lib/libform/fld_dup.c71
-rw-r--r--lib/libform/fld_ftchoice.c19
-rw-r--r--lib/libform/fld_ftlink.c34
-rw-r--r--lib/libform/fld_info.c59
-rw-r--r--lib/libform/fld_just.c29
-rw-r--r--lib/libform/fld_link.c67
-rw-r--r--lib/libform/fld_max.c24
-rw-r--r--lib/libform/fld_move.c17
-rw-r--r--lib/libform/fld_newftyp.c84
-rw-r--r--lib/libform/fld_opts.c40
-rw-r--r--lib/libform/fld_pad.c25
-rw-r--r--lib/libform/fld_page.c22
-rw-r--r--lib/libform/fld_stat.c22
-rw-r--r--lib/libform/fld_type.c27
-rw-r--r--lib/libform/fld_user.c19
-rw-r--r--lib/libform/form.3tbl100
-rw-r--r--lib/libform/form.h212
-rw-r--r--lib/libform/form.priv.h184
-rw-r--r--lib/libform/form_cursor.319
-rw-r--r--lib/libform/form_data.38
-rw-r--r--lib/libform/form_driver.3121
-rw-r--r--lib/libform/form_field.341
-rw-r--r--lib/libform/form_field_attributes.325
-rw-r--r--lib/libform/form_field_buffer.385
-rw-r--r--lib/libform/form_field_info.323
-rw-r--r--lib/libform/form_field_just.318
-rw-r--r--lib/libform/form_field_new.340
-rw-r--r--lib/libform/form_field_opts.336
-rw-r--r--lib/libform/form_field_userptr.324
-rw-r--r--lib/libform/form_field_validation.331
-rw-r--r--lib/libform/form_fieldtype.372
-rw-r--r--lib/libform/form_hook.334
-rw-r--r--lib/libform/form_new.332
-rw-r--r--lib/libform/form_new_page.318
-rw-r--r--lib/libform/form_opts.326
-rw-r--r--lib/libform/form_page.323
-rw-r--r--lib/libform/form_post.337
-rw-r--r--lib/libform/form_requestname.37
-rw-r--r--lib/libform/form_userptr.324
-rw-r--r--lib/libform/form_win.322
-rw-r--r--lib/libform/frm_cursor.c17
-rw-r--r--lib/libform/frm_data.c116
-rw-r--r--lib/libform/frm_def.c274
-rw-r--r--lib/libform/frm_driver.c3265
-rw-r--r--lib/libform/frm_hook.c62
-rw-r--r--lib/libform/frm_opts.c29
-rw-r--r--lib/libform/frm_page.c36
-rw-r--r--lib/libform/frm_post.c39
-rw-r--r--lib/libform/frm_req_name.c175
-rw-r--r--lib/libform/frm_scale.c24
-rw-r--r--lib/libform/frm_sub.c28
-rw-r--r--lib/libform/frm_user.c17
-rw-r--r--lib/libform/frm_win.c29
-rw-r--r--lib/libform/fty_alnum.c178
-rw-r--r--lib/libform/fty_alpha.c179
-rw-r--r--lib/libform/fty_enum.c251
-rw-r--r--lib/libform/fty_int.c208
-rw-r--r--lib/libform/fty_ipv4.c66
-rw-r--r--lib/libform/fty_num.c283
-rw-r--r--lib/libform/fty_regex.c181
-rw-r--r--lib/libform/shlib_version2
68 files changed, 4749 insertions, 3182 deletions
diff --git a/lib/libform/Makefile b/lib/libform/Makefile
index 802d1a72693..8ce3ad75cfa 100644
--- a/lib/libform/Makefile
+++ b/lib/libform/Makefile
@@ -3,12 +3,13 @@ WANTLINT=
SRCS= fld_arg.c fld_attr.c fld_current.c fld_def.c fld_dup.c fld_ftchoice.c \
fld_ftlink.c fld_info.c fld_just.c fld_link.c fld_max.c fld_move.c \
fld_newftyp.c fld_opts.c fld_pad.c fld_page.c fld_stat.c fld_type.c \
- fld_user.c frm_adabind.c frm_cursor.c frm_data.c frm_def.c \
+ fld_user.c frm_cursor.c frm_data.c frm_def.c \
frm_driver.c frm_hook.c frm_opts.c frm_page.c frm_post.c \
frm_req_name.c frm_scale.c frm_sub.c frm_user.c frm_win.c fty_alnum.c \
- fty_alpha.c fty_enum.c fty_int.c fty_ipv4.c fty_num.c fty_regex.c
+ fty_alpha.c fty_enum.c fty_int.c fty_ipv4.c fty_num.c fty_regex.c \
+ f_trace.c
HDRS= form.h
-CFLAGS+=-I${.CURDIR}/../libmenu -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
+CFLAGS+=-I${.CURDIR}/../libmenu -I${.CURDIR}/../libcurses
MAN= form.3tbl form_cursor.3 form_data.3 form_driver.3 form_field.3 \
form_field_attributes.3 form_field_buffer.3 form_field_info.3 \
form_field_just.3 form_field_new.3 form_field_opts.3 \
diff --git a/lib/libform/READ.ME b/lib/libform/READ.ME
index 12a540ea615..a2d2bb1bb26 100644
--- a/lib/libform/READ.ME
+++ b/lib/libform/READ.ME
@@ -1,3 +1,33 @@
+-------------------------------------------------------------------------------
+-- 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 1.3 2010/01/12 23:22:07 nicm Exp $
+-------------------------------------------------------------------------------
+
This is a clone of the form library that is available with typical
System V curses implementations (ETI).
@@ -10,6 +40,3 @@ For things that still need doing, see the TO-DO file in the top-level
directory.
Juergen Pfeifer
-
-eMail: Juergen.Pfeifer@T-Online.de
-
diff --git a/lib/libform/frm_adabind.c b/lib/libform/f_trace.c
index 5250e5767b9..97506441ba6 100644
--- a/lib/libform/frm_adabind.c
+++ b/lib/libform/f_trace.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_adabind.c,v 1.2 1998/07/24 02:37:24 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998 Free Software Foundation, Inc. *
+ * Copyright (c) 2004 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 *
@@ -29,55 +27,44 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> 1995,1997 *
+ * Author: Thomas E. Dickey *
****************************************************************************/
-/***************************************************************************
-* Module frm_adabind.c *
-* Helper routines to ease the implementation of an Ada95 binding to *
-* ncurses. For details and copyright of the binding see the ../Ada95 *
-* subdirectory. *
-***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_adabind.c,v 1.5 1998/02/11 12:13:43 tom Exp $")
-
-/* Prototypes for the functions in this module */
-void _nc_ada_normalize_field_opts (int *opt);
-void _nc_ada_normalize_form_opts (int *opt);
-void* _nc_ada_getvarg(va_list *);
-FIELD* _nc_get_field(const FORM*, int);
-
+MODULE_ID("$Id: f_trace.c,v 1.1 2010/01/12 23:22:07 nicm Exp $")
-void _nc_ada_normalize_field_opts (int *opt)
+NCURSES_EXPORT(FIELD **)
+_nc_retrace_field_ptr(FIELD **code)
{
- *opt = ALL_FIELD_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
-void _nc_ada_normalize_form_opts (int *opt)
+NCURSES_EXPORT(FIELD *)
+_nc_retrace_field(FIELD *code)
{
- *opt = ALL_FORM_OPTS & (*opt);
+ T((T_RETURN("%p"), code));
+ return code;
}
+NCURSES_EXPORT(FIELDTYPE *)
+_nc_retrace_field_type(FIELDTYPE *code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
+}
-/* This tiny stub helps us to get a void pointer from an argument list.
-// The mechanism for libform to handle arguments to field types uses
-// unfortunately functions with variable argument lists. In the Ada95
-// binding we replace this by a mechanism that only uses one argument
-// that is a pointer to a record describing all the specifics of an
-// user defined field type. So we need only this simple generic
-// procedure to get the pointer from the arglist.
-*/
-void *_nc_ada_getvarg(va_list *ap)
+NCURSES_EXPORT(FORM *)
+_nc_retrace_form(FORM *code)
{
- return va_arg(*ap,void*);
+ T((T_RETURN("%p"), code));
+ return code;
}
-FIELD* _nc_get_field(const FORM* frm, int idx) {
- if (frm && frm->field && idx>=0 && (idx<frm->maxfield))
- {
- return frm->field[idx];
- }
- else
- return (FIELD*)0;
+NCURSES_EXPORT(Form_Hook)
+_nc_retrace_form_hook(Form_Hook code)
+{
+ T((T_RETURN("%p"), code));
+ return code;
}
diff --git a/lib/libform/fld_arg.c b/lib/libform/fld_arg.c
index 5087cd986fc..7b690ac95ab 100644
--- a/lib/libform/fld_arg.c
+++ b/lib/libform/fld_arg.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_arg.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,21 +27,21 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_arg.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: fld_arg.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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:
@@ -63,34 +61,38 @@ MODULE_ID("$From: fld_arg.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| 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 *))
+set_fieldtype_arg(FIELDTYPE *typ,
+ void *(*const make_arg)(va_list *),
+ void *(*const copy_arg)(const void *),
+ void (*const free_arg) (void *))
{
- if ( !typ || !make_arg )
- RETURN(E_BAD_ARGUMENT);
+ T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"),
+ typ, make_arg, copy_arg, free_arg));
- typ->status |= _HAS_ARGS;
- typ->makearg = make_arg;
- typ->copyarg = copy_arg;
- typ->freearg = free_arg;
- RETURN(E_OK);
+ 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
+| 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)
+field_arg(const FIELD *field)
{
- return Normalize_Field(field)->arg;
+ T((T_CALLED("field_arg(%p)"), field));
+ returnVoidPtr(Normalize_Field(field)->arg);
}
/* fld_arg.c ends here */
diff --git a/lib/libform/fld_attr.c b/lib/libform/fld_attr.c
index 01f71c99008..fa8709fcc29 100644
--- a/lib/libform/fld_attr.c
+++ b/lib/libform/fld_attr.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_attr.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_attr.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_attr.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
Field-Attribute manipulation routines
@@ -43,16 +42,22 @@ MODULE_ID("$From: fld_attr.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
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 -> name) != attr)\
- {\
- field -> name = attr;\
- res = _nc_Synchronize_Attributes( field );\
- }\
- else\
- res = E_OK;\
+ if (field != 0) \
+ { \
+ if ((field -> name) != attr)\
+ {\
+ field -> name = attr;\
+ res = _nc_Synchronize_Attributes( field );\
+ }\
+ else\
+ {\
+ res = E_OK;\
+ }\
+ }\
}\
RETURN(res);\
}
@@ -61,13 +66,14 @@ NCURSES_IMPEXP int NCURSES_API set_field_ ## name (FIELD * field, chtype attr)\
#define GEN_FIELD_ATTR_GET_FCT( name ) \
NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
{\
- return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
+ T((T_CALLED("field_" #name "(%p)"), field));\
+ returnAttr( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_fore(FIELD *field, chtype attr)
-|
+|
| Description : Sets the foreground of the field used to display the
| field contents.
|
@@ -75,22 +81,22 @@ NCURSES_IMPEXP chtype NCURSES_API field_ ## name (const FIELD * field)\
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( fore )
+GEN_FIELD_ATTR_SET_FCT(fore)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : chtype field_fore(const FIELD *)
-|
+|
| Description : Retrieve fields foreground attribute
|
| Return Values : The foreground attribute
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( fore )
+GEN_FIELD_ATTR_GET_FCT(fore)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_back(FIELD *field, chtype attr)
-|
+|
| Description : Sets the background of the field used to display the
| fields extend.
|
@@ -98,16 +104,16 @@ GEN_FIELD_ATTR_GET_FCT( fore )
| E_BAD_ARGUMENT - invalid attributes
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_SET_FCT( back )
+GEN_FIELD_ATTR_SET_FCT(back)
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : chtype field_back(const
-|
+| Function : chtype field_back(const
+|
| Description : Retrieve fields background attribute
|
| Return Values : The background attribute
+--------------------------------------------------------------------------*/
-GEN_FIELD_ATTR_GET_FCT( back )
+GEN_FIELD_ATTR_GET_FCT(back)
/* fld_attr.c ends here */
diff --git a/lib/libform/fld_current.c b/lib/libform/fld_current.c
index 530dfbd69c5..b5c3a0fd2d8 100644
--- a/lib/libform/fld_current.c
+++ b/lib/libform/fld_current.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_current.c,v 1.4 2001/01/22 18:02:11 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,16 +27,17 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_current.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_current.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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
@@ -49,46 +48,53 @@ MODULE_ID("$From: fld_current.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_current_field (FORM * form, FIELD * field)
+set_current_field(FORM *form, FIELD *field)
{
int err = E_OK;
- if ( !form || !field )
- RETURN(E_BAD_ARGUMENT);
-
- if ( (form != field->form) || Field_Is_Not_Selectable(field) )
- RETURN(E_REQUEST_DENIED);
-
- if (!(form->status & _POSTED))
+ T((T_CALLED("set_current_field(%p,%p)"), form, 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)
- err = E_BAD_STATE;
+ if ((form->status & _IN_DRIVER) != 0)
+ {
+ err = E_BAD_STATE;
+ }
else
{
if (form->current != field)
{
- if (!_nc_Internal_Validation(form))
- err = E_INVALID_FIELD;
+ if (!_nc_Internal_Validation(form))
+ {
+ err = E_INVALID_FIELD;
+ }
else
{
- Call_Hook(form,fieldterm);
+ Call_Hook(form, fieldterm);
if (field->page != form->curpage)
{
- Call_Hook(form,formterm);
- err = _nc_Set_Form_Page(form,field->page,field);
- Call_Hook(form,forminit);
- }
- else
+ 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);
+ err = _nc_Set_Current_Field(form, field);
}
- Call_Hook(form,fieldinit);
- _nc_Refresh_Current_Field(form);
+ Call_Hook(form, fieldinit);
+ (void)_nc_Refresh_Current_Field(form);
}
}
}
@@ -97,23 +103,24 @@ set_current_field (FORM * form, FIELD * field)
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+current_field(const FORM *form)
{
- return Normalize_Form(form)->current;
+ T((T_CALLED("current_field(%p)"), form));
+ returnField(Normalize_Form(form)->current);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int field_index(const FIELD * field)
-|
+|
| Description : Return the index of the field in the field-array of
| the form.
|
@@ -121,9 +128,10 @@ current_field (const FORM * form)
| -1 : fieldpointer invalid or field not connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_index (const FIELD * field)
+field_index(const FIELD *field)
{
- return ( (field && field->form) ? field->index : -1 );
+ T((T_CALLED("field_index(%p)"), field));
+ returnCode((field != 0 && field->form != 0) ? (int)field->index : -1);
}
/* fld_current.c ends here */
diff --git a/lib/libform/fld_def.c b/lib/libform/fld_def.c
index d4402dcc282..46806b1104f 100644
--- a/lib/libform/fld_def.c
+++ b/lib/libform/fld_def.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_def.c,v 1.7 2003/11/08 19:17:27 jmc Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2007 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 *
@@ -29,296 +27,325 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_def.c,v 1.13 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_def.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/* this can't be readonly */
-static FIELD default_field = {
- 0, /* status */
- 0, /* rows */
- 0, /* cols */
- 0, /* frow */
- 0, /* fcol */
- 0, /* drows */
- 0, /* dcols */
- 0, /* maxgrow*/
- 0, /* nrow */
- 0, /* nbuf */
- NO_JUSTIFICATION, /* just */
- 0, /* page */
- 0, /* index */
- (int)' ', /* pad */
- A_NORMAL, /* fore */
- A_NORMAL, /* back */
- ALL_FIELD_OPTS, /* opts */
- (FIELD *)0, /* snext */
- (FIELD *)0, /* sprev */
- (FIELD *)0, /* link */
- (FORM *)0, /* form */
- (FIELDTYPE *)0, /* type */
- (char *)0, /* arg */
- (char *)0, /* buf */
- (char *)0 /* usrptr */
+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;
-
+NCURSES_EXPORT_VAR(FIELD *)
+_nc_Default_Field = &default_field;
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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 errorcounter is increased.
+| 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)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err)
{
- TypeArgument *res = (TypeArgument *)0;
+ TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
- if (typ && (typ->status & _HAS_ARGS))
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- assert(err && ap);
- if (typ->status & _LINKED_TYPE)
+ assert(err != 0 && ap != (va_list *)0);
+ if ((typ->status & _LINKED_TYPE) != 0)
{
- p = (TypeArgument *)malloc(sizeof(TypeArgument));
- if (p)
+ 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);
+ p->left = _nc_Make_Argument(typ->left, ap, err);
+ p->right = _nc_Make_Argument(typ->right, ap, err);
return p;
}
else
- *err += 1;
- } else
+ {
+ *err += 1;
+ }
+ }
+ else
{
- assert(typ->makearg);
- if ( !(res=(TypeArgument *)typ->makearg(ap)) )
- *err += 1;
+ assert(typ->makearg != (void *)0);
+ if (!(res = (TypeArgument *)typ->makearg(ap)))
+ {
+ *err += 1;
+ }
}
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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
+|
+| Description : Create a copy of an argument structure for the specified
| type.
|
| Return Values : Pointer to argument structure. Maybe NULL.
-| In case of an error in *err an errorcounter is increased.
+| 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)
+NCURSES_EXPORT(TypeArgument *)
+_nc_Copy_Argument(const FIELDTYPE *typ, const TypeArgument *argp, int *err)
{
TypeArgument *res = (TypeArgument *)0;
TypeArgument *p;
- if ( typ && (typ->status & _HAS_ARGS) )
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- assert(err && argp);
- if (typ->status & _LINKED_TYPE)
+ assert(err != 0 && argp != 0);
+ if ((typ->status & _LINKED_TYPE) != 0)
{
- p = (TypeArgument *)malloc(sizeof(TypeArgument));
- if (p)
+ 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);
+ p->left = _nc_Copy_Argument(typ, argp->left, err);
+ p->right = _nc_Copy_Argument(typ, argp->right, err);
return p;
}
*err += 1;
- }
- else
+ }
+ else
{
- if (typ->copyarg)
+ if (typ->copyarg != (void *)0)
{
- if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
- *err += 1;
+ if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
+ {
+ *err += 1;
+ }
}
else
- res = (TypeArgument *)argp;
+ {
+ res = (TypeArgument *)argp;
+ }
}
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+_nc_Free_Argument(const FIELDTYPE *typ, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_ARGS))
- return;
-
- if (typ->status & _LINKED_TYPE)
- {
- assert(argp);
- _nc_Free_Argument(typ->left ,argp->left );
- _nc_Free_Argument(typ->right,argp->right);
- free(argp);
- }
- else
+ if (typ != 0 && (typ->status & _HAS_ARGS) != 0)
{
- if (typ->freearg)
- typ->freearg((void *)argp);
+ 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
+| Facility : libnform
| Function : bool _nc_Copy_Type( FIELD *dst, FIELD const *src )
-|
+|
| Description : Copy argument structure of field src to field dst
|
| Return Values : TRUE - copy worked
-| FALSE - error occured
+| FALSE - error occurred
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Copy_Type
-(FIELD *dst, FIELD const *src)
+_nc_Copy_Type(FIELD *dst, FIELD const *src)
{
int err = 0;
- assert(dst && src);
+ assert(dst != 0 && src != 0);
dst->type = src->type;
- dst->arg = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err);
+ dst->arg = (void *)_nc_Copy_Argument(src->type, (TypeArgument *)(src->arg), &err);
- if (err)
+ if (err != 0)
{
- _nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg));
+ _nc_Free_Argument(dst->type, (TypeArgument *)(dst->arg));
dst->type = (FIELDTYPE *)0;
- dst->arg = (void *)0;
+ dst->arg = (void *)0;
return FALSE;
}
else
{
- if (dst->type)
- dst->type->ref++;
+ if (dst->type != 0)
+ {
+ dst->type->ref++;
+ }
return TRUE;
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+_nc_Free_Type(FIELD *field)
{
- assert(field);
- if (field->type)
- field->type->ref--;
- _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+ 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,
+| 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)
+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;
- if (rows>0 &&
- cols>0 &&
- frow>=0 &&
- fcol>=0 &&
- nrow>=0 &&
- nbuf>=0 &&
- ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
- (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+ 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)
{
- *New_Field = default_field;
- New_Field->rows = rows;
- New_Field->cols = cols;
+ T((T_CREATE("field %p"), 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;
+ 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))
+ if (_nc_Copy_Type(New_Field, &default_field))
{
size_t len;
len = Total_Buffer_Size(New_Field);
- if ((New_Field->buf = (char *)malloc(len)))
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
/* Prefill buffers with blanks and insert terminating zeroes
- between buffers */
- int i;
+ between buffers */
+ int i, j;
+ int cells = Buffer_Length(New_Field);
- memset(New_Field->buf,' ',len);
- for(i=0;i<=New_Field->nbuf;i++)
+ for (i = 0; i <= New_Field->nbuf; i++)
{
- New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
- = '\0';
+ FIELD_CELL *buffer = &(New_Field->buf[(cells + 1) * i]);
+
+ for (j = 0; j < cells; ++j)
+ {
+ buffer[j] = blank;
+ }
+ buffer[j] = zeros;
}
- return New_Field;
+ returnField(New_Field);
}
}
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
-
- SET_ERROR( err );
- return (FIELD *)0;
+
+ SET_ERROR(err);
+ returnField((FIELD *)0);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int free_field( FIELD *field )
-|
+|
| Description : Frees the storage allocated for the field.
|
| Return Values : E_OK - success
@@ -326,28 +353,45 @@ new_field
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_field (FIELD * field)
+free_field(FIELD *field)
{
- if (!field)
- RETURN(E_BAD_ARGUMENT);
-
- if (field->form)
- RETURN(E_CONNECTED);
-
- if (field == field->link)
+ T((T_CALLED("free_field(%p)"), field));
+ if (!field)
+ {
+ RETURN(E_BAD_ARGUMENT);
+ }
+ else if (field->form != 0)
{
- if (field->buf)
+ RETURN(E_CONNECTED);
+ }
+ else if (field == field->link)
+ {
+ if (field->buf != 0)
free(field->buf);
}
- else
+ else
{
FIELD *f;
- for(f=field;f->link != field;f = f->link)
- {}
+ 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);
}
diff --git a/lib/libform/fld_dup.c b/lib/libform/fld_dup.c
index 3671141705a..7a10ca5929b 100644
--- a/lib/libform/fld_dup.c
+++ b/lib/libform/fld_dup.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_dup.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 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 *
@@ -29,72 +27,75 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_dup.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_dup.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+dup_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
- if (field && (frow>=0) && (fcol>=0) &&
- ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */
- (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
+ T((T_CALLED("dup_field(%p,%d,%d)"), 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)))
{
- *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;
+ T((T_CREATE("field %p"), 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;
+ 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))
+ if (_nc_Copy_Type(New_Field, field))
{
- size_t len;
+ size_t i, len;
len = Total_Buffer_Size(New_Field);
- if ( (New_Field->buf=(char *)malloc(len)) )
+ if ((New_Field->buf = (FIELD_CELL *)malloc(len)))
{
- memcpy(New_Field->buf,field->buf,len);
- return New_Field;
+ for (i = 0; i < len; ++i)
+ New_Field->buf[i] = field->buf[i];
+ returnField(New_Field);
}
}
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
SET_ERROR(err);
- return (FIELD *)0;
+ returnField((FIELD *)0);
}
/* fld_dup.c ends here */
diff --git a/lib/libform/fld_ftchoice.c b/lib/libform/fld_ftchoice.c
index bf102348924..af4a2469959 100644
--- a/lib/libform/fld_ftchoice.c
+++ b/lib/libform/fld_ftchoice.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_ftchoice.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_ftchoice.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_ftchoice.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,12 +47,13 @@ MODULE_ID("$From: fld_ftchoice.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| 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 *))
+set_fieldtype_choice(FIELDTYPE *typ,
+ bool (*const next_choice) (FIELD *, const void *),
+ bool (*const prev_choice) (FIELD *, const void *))
{
- if ( !typ || !next_choice || !prev_choice )
+ T((T_CALLED("set_fieldtype_choice(%p,%p,%p)"), typ, next_choice, prev_choice));
+
+ if (!typ || !next_choice || !prev_choice)
RETURN(E_BAD_ARGUMENT);
typ->status |= _HAS_CHOICE;
diff --git a/lib/libform/fld_ftlink.c b/lib/libform/fld_ftlink.c
index 07557e59234..93072aa24b9 100644
--- a/lib/libform/fld_ftlink.c
+++ b/lib/libform/fld_ftlink.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_ftlink.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_ftlink.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_ftlink.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,40 +46,42 @@ MODULE_ID("$From: fld_ftlink.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
-| Return Values : Fieldtype pointer or NULL if error occured.
+| Return Values : Fieldtype pointer or NULL if error occurred.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
-link_fieldtype
-(FIELDTYPE * type1, FIELDTYPE * type2)
+link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2)
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
- if ( type1 && type2 )
+ T((T_CALLED("link_fieldtype(%p,%p)"), type1, type2));
+ if (type1 && type2)
{
- nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
if (nftyp)
{
+ T((T_CREATE("fieldtype %p"), nftyp));
*nftyp = *_nc_Default_FieldType;
nftyp->status |= _LINKED_TYPE;
- if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) )
+ if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS))
nftyp->status |= _HAS_ARGS;
- if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) )
+ if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE))
nftyp->status |= _HAS_CHOICE;
- nftyp->left = type1;
- nftyp->right = type2;
+ nftyp->left = type1;
+ nftyp->right = type2;
type1->ref++;
type2->ref++;
}
else
{
- SET_ERROR( E_SYSTEM_ERROR );
+ SET_ERROR(E_SYSTEM_ERROR);
}
}
else
{
- SET_ERROR( E_BAD_ARGUMENT );
+ SET_ERROR(E_BAD_ARGUMENT);
}
- return nftyp;
+ returnFieldType(nftyp);
}
/* fld_ftlink.c ends here */
diff --git a/lib/libform/fld_info.c b/lib/libform/fld_info.c
index da868e6c1d4..216a8d24500 100644
--- a/lib/libform/fld_info.c
+++ b/lib/libform/fld_info.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_info.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_info.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_info.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,24 +47,35 @@ MODULE_ID("$From: fld_info.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| 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)
+field_info(const FIELD *field,
+ int *rows, int *cols,
+ int *frow, int *fcol,
+ int *nrow, int *nbuf)
{
- if (!field)
+ T((T_CALLED("field_info(%p,%p,%p,%p,%p,%p,%p)"),
+ field,
+ rows, cols,
+ frow, fcol,
+ nrow, 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;
+ 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,
@@ -80,15 +89,19 @@ field_info
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-dynamic_field_info
-(const FIELD *field, int *drows, int *dcols, int *maxgrow)
+dynamic_field_info(const FIELD *field, int *drows, int *dcols, int *maxgrow)
{
+ T((T_CALLED("dynamic_field_info(%p,%p,%p,%p)"), field, drows, dcols, maxgrow));
+
if (!field)
RETURN(E_BAD_ARGUMENT);
- if (drows) *drows = field->drows;
- if (dcols) *dcols = field->dcols;
- if (maxgrow) *maxgrow = field->maxgrow;
+ if (drows)
+ *drows = field->drows;
+ if (dcols)
+ *dcols = field->dcols;
+ if (maxgrow)
+ *maxgrow = field->maxgrow;
RETURN(E_OK);
}
diff --git a/lib/libform/fld_just.c b/lib/libform/fld_just.c
index 61db459b6e7..0c1b7515af8 100644
--- a/lib/libform/fld_just.c
+++ b/lib/libform/fld_just.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_just.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_just.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_just.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,20 +45,22 @@ MODULE_ID("$From: fld_just.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_just (FIELD * field, int just)
+set_field_just(FIELD *field, int just)
{
int res = E_BAD_ARGUMENT;
- if ((just==NO_JUSTIFICATION) ||
- (just==JUSTIFY_LEFT) ||
- (just==JUSTIFY_CENTER) ||
- (just==JUSTIFY_RIGHT) )
+ T((T_CALLED("set_field_just(%p,%d)"), field, just));
+
+ if ((just == NO_JUSTIFICATION) ||
+ (just == JUSTIFY_LEFT) ||
+ (just == JUSTIFY_CENTER) ||
+ (just == JUSTIFY_RIGHT))
{
- Normalize_Field( field );
+ Normalize_Field(field);
if (field->just != just)
{
field->just = just;
- res = _nc_Synchronize_Attributes( field );
+ res = _nc_Synchronize_Attributes(field);
}
else
res = E_OK;
@@ -77,9 +77,10 @@ set_field_just (FIELD * field, int just)
| Return Values : The justification type.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_just (const FIELD * field)
+field_just(const FIELD *field)
{
- return Normalize_Field( field )->just;
+ T((T_CALLED("field_just(%p)"), field));
+ returnCode(Normalize_Field(field)->just);
}
/* fld_just.c ends here */
diff --git a/lib/libform/fld_link.c b/lib/libform/fld_link.c
index 8ee22de0067..544336845ac 100644
--- a/lib/libform/fld_link.c
+++ b/lib/libform/fld_link.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_link.c,v 1.4 2001/01/22 18:02:12 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_link.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_link.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -51,43 +49,48 @@ MODULE_ID("$From: fld_link.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| Return Values : Pointer to the new field or NULL if failure
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD *)
-link_field (FIELD * field, int frow, int fcol)
+link_field(FIELD *field, int frow, int fcol)
{
FIELD *New_Field = (FIELD *)0;
int err = E_BAD_ARGUMENT;
- if (field && (frow>=0) && (fcol>=0) &&
- ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
- (New_Field = (FIELD *)malloc(sizeof(FIELD))) )
+ T((T_CALLED("link_field(%p,%d,%d)"), 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)))
{
- *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;
+ T((T_CREATE("field %p"), 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))
- return New_Field;
+
+ if (_nc_Copy_Type(New_Field, field))
+ returnField(New_Field);
}
- if (New_Field)
+ if (New_Field)
free_field(New_Field);
- SET_ERROR( err );
- return (FIELD *)0;
+ SET_ERROR(err);
+ returnField((FIELD *)0);
}
/* fld_link.c ends here */
diff --git a/lib/libform/fld_max.c b/lib/libform/fld_max.c
index 64ca77bfde4..0d6c66f9cce 100644
--- a/lib/libform/fld_max.c
+++ b/lib/libform/fld_max.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_max.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_max.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_max.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,17 +45,19 @@ MODULE_ID("$From: fld_max.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_BAD_ARGUMENT - invalid argument
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_max_field (FIELD *field, int maxgrow)
+set_max_field(FIELD *field, int maxgrow)
{
- if (!field || (maxgrow<0))
+ T((T_CALLED("set_max_field(%p,%d)"), field, maxgrow));
+
+ if (!field || (maxgrow < 0))
RETURN(E_BAD_ARGUMENT);
else
{
bool single_line_field = Single_Line_Field(field);
- if (maxgrow>0)
+ if (maxgrow > 0)
{
- if (( single_line_field && (maxgrow < field->dcols)) ||
+ if ((single_line_field && (maxgrow < field->dcols)) ||
(!single_line_field && (maxgrow < field->drows)))
RETURN(E_BAD_ARGUMENT);
}
@@ -65,13 +65,13 @@ set_max_field (FIELD *field, int maxgrow)
field->status &= ~_MAY_GROW;
if (!(field->opts & O_STATIC))
{
- if ((maxgrow==0) ||
- ( single_line_field && (field->dcols < maxgrow)) ||
+ 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 */
diff --git a/lib/libform/fld_move.c b/lib/libform/fld_move.c
index 3fe67e621f2..864b024c8da 100644
--- a/lib/libform/fld_move.c
+++ b/lib/libform/fld_move.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_move.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_move.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_move.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,12 +46,14 @@ MODULE_ID("$From: fld_move.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-move_field (FIELD *field, int frow, int fcol)
+move_field(FIELD *field, int frow, int fcol)
{
- if ( !field || (frow<0) || (fcol<0) )
+ T((T_CALLED("move_field(%p,%d,%d)"), field, frow, fcol));
+
+ if (!field || (frow < 0) || (fcol < 0))
RETURN(E_BAD_ARGUMENT);
- if (field->form)
+ if (field->form)
RETURN(E_CONNECTED);
field->frow = frow;
@@ -62,4 +62,3 @@ move_field (FIELD *field, int frow, int fcol)
}
/* fld_move.c ends here */
-
diff --git a/lib/libform/fld_newftyp.c b/lib/libform/fld_newftyp.c
index 4abd3d5f16d..7d2e7ffb801 100644
--- a/lib/libform/fld_newftyp.c
+++ b/lib/libform/fld_newftyp.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_newftyp.c,v 1.5 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2007 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 *
@@ -29,76 +27,80 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_newftyp.c,v 1.6 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_newftyp.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
-static FIELDTYPE const default_fieldtype = {
- 0, /* status */
- 0L, /* reference count */
- (FIELDTYPE *)0, /* pointer to left operand */
- (FIELDTYPE *)0, /* pointer to right operand */
- NULL, /* makearg function */
- NULL, /* copyarg function */
- NULL, /* freearg function */
- NULL, /* field validation function */
- NULL, /* Character check function */
- NULL, /* enumerate next function */
- NULL /* enumerate previous function */
+static FIELDTYPE const default_fieldtype =
+{
+ 0, /* status */
+ 0L, /* reference count */
+ (FIELDTYPE *)0, /* pointer to left operand */
+ (FIELDTYPE *)0, /* pointer to right operand */
+ NULL, /* makearg function */
+ NULL, /* copyarg function */
+ NULL, /* freearg function */
+ NULL, /* field validation function */
+ NULL, /* Character check function */
+ NULL, /* enumerate next function */
+ NULL /* enumerate previous function */
};
-NCURSES_EXPORT_VAR(const FIELDTYPE*) _nc_Default_FieldType = &default_fieldtype;
-
+NCURSES_EXPORT_VAR(const FIELDTYPE *)
+_nc_Default_FieldType = &default_fieldtype;
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELDTYPE *new_fieldtype(
| bool (* const field_check)(FIELD *,const void *),
-| bool (* const char_check) (int, 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
+| If an error occurs, errno is set to
| E_BAD_ARGUMENT - invalid arguments
| E_SYSTEM_ERROR - system error (no memory)
|
-| Return Values : Fieldtype pointer or NULL if error occured
+| 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 *) )
+new_fieldtype(bool (*const field_check) (FIELD *, const void *),
+ bool (*const char_check) (int, const void *))
{
FIELDTYPE *nftyp = (FIELDTYPE *)0;
-
- if ( (field_check) || (char_check) )
+
+ T((T_CALLED("new_fieldtype(%p,%p)"), field_check, char_check));
+ if ((field_check) || (char_check))
{
- nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE));
+ nftyp = typeMalloc(FIELDTYPE, 1);
+
if (nftyp)
{
+ T((T_CREATE("fieldtype %p"), nftyp));
*nftyp = default_fieldtype;
nftyp->fcheck = field_check;
nftyp->ccheck = char_check;
}
else
{
- SET_ERROR( E_SYSTEM_ERROR );
+ SET_ERROR(E_SYSTEM_ERROR);
}
}
else
{
- SET_ERROR( E_BAD_ARGUMENT );
+ SET_ERROR(E_BAD_ARGUMENT);
}
- return nftyp;
+ returnFieldType(nftyp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int free_fieldtype(FIELDTYPE *typ)
-|
+|
| Description : Release the memory associated with this fieldtype.
|
| Return Values : E_OK - success
@@ -106,12 +108,14 @@ new_fieldtype (
| E_BAD_ARGUMENT - invalid fieldtype pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_fieldtype (FIELDTYPE *typ)
+free_fieldtype(FIELDTYPE *typ)
{
+ T((T_CALLED("free_fieldtype(%p)"), typ));
+
if (!typ)
RETURN(E_BAD_ARGUMENT);
- if (typ->ref!=0)
+ if (typ->ref != 0)
RETURN(E_CONNECTED);
if (typ->status & _RESIDENT)
@@ -119,8 +123,10 @@ free_fieldtype (FIELDTYPE *typ)
if (typ->status & _LINKED_TYPE)
{
- if (typ->left ) typ->left->ref--;
- if (typ->right) typ->right->ref--;
+ if (typ->left)
+ typ->left->ref--;
+ if (typ->right)
+ typ->right->ref--;
}
free(typ);
RETURN(E_OK);
diff --git a/lib/libform/fld_opts.c b/lib/libform/fld_opts.c
index 2a2bbea6f39..fb38ac125d8 100644
--- a/lib/libform/fld_opts.c
+++ b/lib/libform/fld_opts.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_opts.c,v 1.5 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_opts.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
Field-Options manipulation routines
@@ -52,12 +51,15 @@ MODULE_ID("$From: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_opts (FIELD * field, Field_Options opts)
+set_field_opts(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+
+ T((T_CALLED("set_field_opts(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
- res = _nc_Synchronize_Options( Normalize_Field(field), opts );
+ res = _nc_Synchronize_Options(Normalize_Field(field), opts);
RETURN(res);
}
@@ -70,9 +72,11 @@ set_field_opts (FIELD * field, Field_Options opts)
| Return Values : The options.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Field_Options)
-field_opts (const FIELD * field)
+field_opts(const FIELD *field)
{
- return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
+ T((T_CALLED("field_opts(%p)"), field));
+
+ returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts);
}
/*---------------------------------------------------------------------------
@@ -88,15 +92,17 @@ field_opts (const FIELD * field)
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_opts_on (FIELD * field, Field_Options opts)
+field_opts_on(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+ T((T_CALLED("field_opts_on(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
- Normalize_Field( field );
- res = _nc_Synchronize_Options( field, field->opts | opts );
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts | opts);
}
RETURN(res);
}
@@ -114,17 +120,19 @@ field_opts_on (FIELD * field, Field_Options opts)
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_opts_off (FIELD * field, Field_Options opts)
+field_opts_off(FIELD *field, Field_Options opts)
{
int res = E_BAD_ARGUMENT;
+ T((T_CALLED("field_opts_off(%p,%d)"), field, opts));
+
opts &= ALL_FIELD_OPTS;
if (!(opts & ~ALL_FIELD_OPTS))
{
- Normalize_Field( field );
- res = _nc_Synchronize_Options( field, field->opts & ~opts );
+ Normalize_Field(field);
+ res = _nc_Synchronize_Options(field, field->opts & ~opts);
}
RETURN(res);
-}
+}
/* fld_opts.c ends here */
diff --git a/lib/libform/fld_pad.c b/lib/libform/fld_pad.c
index 5d2e4dfdceb..9197b731bef 100644
--- a/lib/libform/fld_pad.c
+++ b/lib/libform/fld_pad.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_pad.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: fld_pad.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_pad.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,17 +46,19 @@ MODULE_ID("$From: fld_pad.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_pad (FIELD * field, int ch)
+set_field_pad(FIELD *field, int ch)
{
int res = E_BAD_ARGUMENT;
- Normalize_Field( field );
- if (isprint((unsigned char)ch))
+ T((T_CALLED("set_field_pad(%p,%d)"), field, ch));
+
+ Normalize_Field(field);
+ if (isprint(UChar(ch)))
{
if (field->pad != ch)
{
field->pad = ch;
- res = _nc_Synchronize_Attributes( field );
+ res = _nc_Synchronize_Attributes(field);
}
else
res = E_OK;
@@ -74,9 +75,11 @@ set_field_pad (FIELD * field, int ch)
| Return Values : The pad character.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_pad (const FIELD * field)
+field_pad(const FIELD *field)
{
- return Normalize_Field( field )->pad;
+ T((T_CALLED("field_pad(%p)"), field));
+
+ returnCode(Normalize_Field(field)->pad);
}
/* fld_pad.c ends here */
diff --git a/lib/libform/fld_page.c b/lib/libform/fld_page.c
index 3e37d022917..dbe94e0f926 100644
--- a/lib/libform/fld_page.c
+++ b/lib/libform/fld_page.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_page.c,v 1.4 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_page.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_page.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,13 +45,15 @@ MODULE_ID("$From: fld_page.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_CONNECTED - field is connected
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_new_page (FIELD * field, bool new_page_flag)
+set_new_page(FIELD *field, bool new_page_flag)
{
+ T((T_CALLED("set_new_page(%p,%d)"), field, new_page_flag));
+
Normalize_Field(field);
- if (field->form)
+ if (field->form)
RETURN(E_CONNECTED);
- if (new_page_flag)
+ if (new_page_flag)
field->status |= _NEWPAGE;
else
field->status &= ~_NEWPAGE;
@@ -72,9 +72,11 @@ set_new_page (FIELD * field, bool new_page_flag)
| FALSE - field doesn't start a new page
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-new_page (const FIELD * field)
+new_page(const FIELD *field)
{
- return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE;
+ T((T_CALLED("new_page(%p)"), field));
+
+ returnBool((Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE);
}
/* fld_page.c ends here */
diff --git a/lib/libform/fld_stat.c b/lib/libform/fld_stat.c
index 297f09022c1..ceb9168fac3 100644
--- a/lib/libform/fld_stat.c
+++ b/lib/libform/fld_stat.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_stat.c,v 1.6 2001/01/22 18:02:13 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_stat.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_stat.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,16 +44,18 @@ MODULE_ID("$From: fld_stat.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_status (FIELD * field, bool status)
+set_field_status(FIELD *field, bool status)
{
- Normalize_Field( field );
+ T((T_CALLED("set_field_status(%p,%d)"), field, status));
+
+ Normalize_Field(field);
if (status)
field->status |= _CHANGED;
else
field->status &= ~_CHANGED;
- return(E_OK);
+ RETURN(E_OK);
}
/*---------------------------------------------------------------------------
@@ -69,9 +69,11 @@ set_field_status (FIELD * field, bool status)
| FALSE - buffer has not been changed
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-field_status (const FIELD * field)
+field_status(const FIELD *field)
{
- return ((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
+ T((T_CALLED("field_status(%p)"), field));
+
+ returnBool((Normalize_Field(field)->status & _CHANGED) ? TRUE : FALSE);
}
/* fld_stat.c ends here */
diff --git a/lib/libform/fld_type.c b/lib/libform/fld_type.c
index dd3754c5c27..e530a449626 100644
--- a/lib/libform/fld_type.c
+++ b/lib/libform/fld_type.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_type.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_type.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_type.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -48,30 +46,32 @@ MODULE_ID("$From: fld_type.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_type (FIELD *field,FIELDTYPE *type, ...)
+set_field_type(FIELD *field, FIELDTYPE *type,...)
{
va_list ap;
int res = E_SYSTEM_ERROR;
int err = 0;
- va_start(ap,type);
+ T((T_CALLED("set_field_type(%p,%p)"), field, 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);
+ field->arg = (void *)_nc_Make_Argument(field->type, &ap, &err);
if (err)
{
- _nc_Free_Argument(field->type,(TypeArgument *)(field->arg));
+ _nc_Free_Argument(field->type, (TypeArgument *)(field->arg));
field->type = (FIELDTYPE *)0;
- field->arg = (void *)0;
+ field->arg = (void *)0;
}
else
{
res = E_OK;
- if (field->type)
+ if (field->type)
field->type->ref++;
}
@@ -88,9 +88,10 @@ set_field_type (FIELD *field,FIELDTYPE *type, ...)
| Return Values : Pointer to fieldtype of NULL if none is defined.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELDTYPE *)
-field_type (const FIELD * field)
+field_type(const FIELD *field)
{
- return Normalize_Field(field)->type;
+ T((T_CALLED("field_type(%p)"), field));
+ returnFieldType(Normalize_Field(field)->type);
}
/* fld_type.c ends here */
diff --git a/lib/libform/fld_user.c b/lib/libform/fld_user.c
index 2e08d902fbc..5d40c158586 100644
--- a/lib/libform/fld_user.c
+++ b/lib/libform/fld_user.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: fld_user.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fld_user.c,v 1.9 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: fld_user.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,9 +44,11 @@ MODULE_ID("$From: fld_user.c,v 1.9 2000/12/10 02:09:38 tom Exp $")
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_userptr (FIELD * field, void *usrptr)
+set_field_userptr(FIELD *field, void *usrptr)
{
- Normalize_Field( field )->usrptr = usrptr;
+ T((T_CALLED("set_field_userptr(%p,%p)"), field, usrptr));
+
+ Normalize_Field(field)->usrptr = usrptr;
RETURN(E_OK);
}
@@ -63,9 +63,10 @@ set_field_userptr (FIELD * field, void *usrptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-field_userptr (const FIELD *field)
+field_userptr(const FIELD *field)
{
- return Normalize_Field( field )->usrptr;
+ T((T_CALLED("field_userptr(%p)"), field));
+ returnVoidPtr(Normalize_Field(field)->usrptr);
}
/* fld_user.c ends here */
diff --git a/lib/libform/form.3tbl b/lib/libform/form.3tbl
index bc11d367eca..9e2c7ae7fc0 100644
--- a/lib/libform/form.3tbl
+++ b/lib/libform/form.3tbl
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form.3tbl,v 1.5 1999/07/11 14:14:03 millert Exp $
+.\" $OpenBSD: form.3tbl,v 1.6 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form.3x,v 1.13 1999/07/10 21:53:03 tom Exp $
+.\" $Id: form.3tbl,v 1.6 2010/01/12 23:22:07 nicm Exp $
.TH form 3 ""
.SH NAME
\fBform\fR - curses extension for programming forms
@@ -42,26 +42,34 @@ form screens on character-cell terminals. The library includes: field
routines, which create and modify form fields; and form routines, which group
fields into forms, display forms on the screen, and handle interaction with the
user.
-
-The \fBform\fR library uses the \fBcurses\fR libraries, and a curses
-initialization routine such as \fBinitscr\fR must be called before using any of
-these functions. To use the \fBform\fR library, link with the options
+.PP
+The \fBform\fR library uses the \fBcurses\fR libraries.
+To use the \fBform\fR library, link with the options
\fB-lform -lcurses\fR.
-
+.PP
+Your program should set up the locale, e.g.,
+.sp
+ \fBsetlocale(LC_ALL, "");\fP
+.sp
+so that input/output processing will work.
+.PP
+A curses initialization routine such as \fBinitscr\fR must be called
+before using any of these functions.
+.
.SS Current Default Values for Field Attributes
-
+.
The \fBform\fR library maintains a default value for field attributes. You
can get or set this default by calling the appropriate \fBset_\fR
or retrieval
routine with a \fBNULL\fR field pointer. Changing this default with a
\fBset_\fR function affects future field creations, but does not change the
rendering of fields already created.
-
+.
.SS Routine Name Index
-
+.
The following table lists each \fBform\fR routine and the name of
the manual page on which it is described.
-
+.
.TS
l l
l l .
@@ -71,7 +79,7 @@ current_field \fBform_page\fR(3)
data_ahead \fBform_data\fR(3)
data_behind \fBform_data\fR(3)
dup_field \fBform_field_new\fR(3)
-dynamic_fieldinfo \fBform_field_info\fR(3)
+dynamic_field_info \fBform_field_info\fR(3)
field_arg \fBform_field_validation\fR(3)
field_back \fBform_field_attributes\fR(3)
field_buffer \fBform_field_buffer\fR(3)
@@ -103,11 +111,13 @@ form_term \fBform_hook\fR(3)
form_userptr \fBform_userptr\fR(3)
form_win \fBform_win\fR(3)
free_field \fBform_field_new\fR(3)
+free_fieldtype \fBform_fieldtype\fR(3)
free_form \fBform_new\fR(3)
link_field \fBform_field_new\fR(3)
link_fieldtype \fBform_fieldtype\fR(3)
move_field \fBform_field\fR(3)
new_field \fBform_field_new\fR(3)
+new_fieldtype \fBform_fieldtype\fR(3)
new_form \fBform_new\fR(3)
new_page \fBform_new_page\fR(3)
pos_form_cursor \fBform_cursor\fR(3)
@@ -140,60 +150,66 @@ set_new_page \fBform_new_page\fR(3)
unpost_form \fBform_post\fR(3)
.TE
.SH RETURN VALUE
-Routines that return pointers return \fBNULL\fR on error. Routines that return
+Routines that return pointers return \fBNULL\fR on error,
+and set errno to the corresponding error-code returned by functions
+returning an integer.
+Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_CONNECTED\fR
-The field is already connected to a form.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
-The form is already posted.
-.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Form is too large for its window.
-.TP 5
-\fBE_NOT_POSTED\fR
-The form has not been posted.
-.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The form driver code saw an unknown request code.
+.B E_CONNECTED
+The field is already connected to a form.
.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of a field are not valid.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No fields are connected to the form.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_NOT_POSTED
+The form has not been posted.
+.TP 5
+.B E_NO_ROOM
+Form is too large for its window.
+.TP 5
+.B E_POSTED
+The form is already posted.
+.TP 5
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The form driver code saw an unknown request code.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header files
\fB<curses.h>\fR and \fB<eti.h>\fR.
-
-In your library list, libform.a should be before libcurses.a; that is,
-you want to say `-lform -lcurses', not the other way around (which would
-give you a link error using GNU \fBld\fR(1) and many other linkers).
+.PP
+In your library list, libform.a should be before libncurses.a; that is,
+you want to say `-lform -lncurses', not the other way around (which would
+give you a link error using most linkers).
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for ncurses by Eric
S. Raymond.
+.SH SEE ALSO
+This describes \fBncurses\fR
+version 5.7.
.\"#
.\"# The following sets edit modes for GNU EMACS
.\"# Local Variables:
diff --git a/lib/libform/form.h b/lib/libform/form.h
index f0ce4260a2b..d83bf69f058 100644
--- a/lib/libform/form.h
+++ b/lib/libform/form.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: form.h,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,9 +27,11 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: form.h,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
+
#ifndef FORM_H
#define FORM_H
@@ -42,6 +42,14 @@
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;
@@ -50,10 +58,10 @@ typedef int Field_Options;
**********/
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 */
+ 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;
/**********
@@ -61,31 +69,40 @@ typedef struct {
**********/
typedef struct fieldnode {
- unsigned short status; /* flags */
- short rows; /* size in rows */
- short cols; /* size in cols */
- short frow; /* first row */
- short fcol; /* first col */
- int drows; /* dynamic rows */
- int dcols; /* dynamic cols */
- int maxgrow; /* maximum field growth */
- int nrow; /* offscreen rows */
- short nbuf; /* additional buffers */
- short just; /* justification */
- short page; /* page on form */
- short index; /* into form -> field */
- int pad; /* pad character */
- chtype fore; /* foreground attribute */
- chtype back; /* background attribute */
- Field_Options opts; /* options */
- struct fieldnode * snext; /* sorted order pointer */
- struct fieldnode * sprev; /* sorted order pointer */
- struct fieldnode * link; /* linked field chain */
- struct formnode * form; /* containing form */
- struct typenode * type; /* field type */
- void * arg; /* argument for type */
- char * buf; /* field buffers */
- void * usrptr; /* user pointer */
+ 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;
/**************
@@ -93,20 +110,20 @@ typedef struct fieldnode {
**************/
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 | */
+ 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 */
+ void* (*makearg)(va_list *); /* make fieldtype arg */
+ void* (*copyarg)(const void *); /* copy fieldtype arg */
+ void (*freearg)(void *); /* free fieldtype arg */
- bool (*fcheck)(FIELD *,const void *); /* field validation */
- bool (*ccheck)(int,const void *); /* character validation */
+ bool (*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 */
+ bool (*next)(FIELD *,const void *); /* enumerate next value */
+ bool (*prev)(FIELD *,const void *); /* enumerate prev value */
} FIELDTYPE;
@@ -115,29 +132,29 @@ typedef struct typenode {
*********/
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 *);
+ 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;
@@ -154,20 +171,20 @@ typedef void (*Form_Hook)(FORM *);
#define JUSTIFY_RIGHT (3)
/* field options */
-#define O_VISIBLE (0x0001)
-#define O_ACTIVE (0x0002)
-#define O_PUBLIC (0x0004)
-#define O_EDIT (0x0008)
-#define O_WRAP (0x0010)
-#define O_BLANK (0x0020)
-#define O_AUTOSKIP (0x0040)
-#define O_NULLOK (0x0080)
-#define O_PASSOK (0x0100)
-#define O_STATIC (0x0200)
+#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 (0x0001)
-#define O_BS_OVERLOAD (0x0002)
+#define O_NL_OVERLOAD (0x0001U)
+#define O_BS_OVERLOAD (0x0002U)
/* form driver commands */
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
@@ -209,7 +226,7 @@ typedef void (*Form_Hook)(FORM *);
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
-#define REQ_DEL_WORD (KEY_MAX + 37) /* delete line at cursor */
+#define REQ_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 */
@@ -219,14 +236,14 @@ typedef void (*Form_Hook)(FORM *);
#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_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 */
@@ -255,15 +272,15 @@ 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 *
+ * They are not defined in SVr4 *
************************************/
extern NCURSES_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
- /***********************
- * Default objects *
- ***********************/
+ /***********************
+ * Default objects *
+ ***********************/
extern NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form;
extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
@@ -273,8 +290,9 @@ extern NCURSES_EXPORT_VAR(FIELD *) _nc_Default_Field;
***********************/
extern NCURSES_EXPORT(FIELDTYPE *) new_fieldtype (
bool (* const field_check)(FIELD *,const void *),
- bool (* const char_check)(int,const void *)),
- *link_fieldtype(FIELDTYPE *,FIELDTYPE *);
+ 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 *,
@@ -326,7 +344,7 @@ 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 *);
+extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
/******************
* FORM routines *
@@ -334,7 +352,7 @@ extern NCURSES_EXPORT(Field_Options) field_opts (const FIELD *);
extern NCURSES_EXPORT(FORM *) new_form (FIELD **);
-extern NCURSES_EXPORT(FIELD **)form_fields (const FORM *);
+extern NCURSES_EXPORT(FIELD **) form_fields (const FORM *);
extern NCURSES_EXPORT(FIELD *) current_field (const FORM *);
extern NCURSES_EXPORT(WINDOW *) form_win (const FORM *);
diff --git a/lib/libform/form.priv.h b/lib/libform/form.priv.h
index f2770a65642..f9f9c175869 100644
--- a/lib/libform/form.priv.h
+++ b/lib/libform/form.priv.h
@@ -1,7 +1,5 @@
-/* $OpenBSD: form.priv.h,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2006,2008 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 *
@@ -29,38 +27,69 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+/* $Id: form.priv.h,v 1.7 2010/01/12 23:22:07 nicm Exp $ */
+
+#ifndef FORM_PRIV_H
+#define FORM_PRIV_H 1
+
+#include "curses.priv.h"
#include "mf_common.h"
+
+#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"
/* form status values */
-#define _OVLMODE (0x04) /* Form is in overlay mode */
-#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
-#define _FCHECK_REQUIRED (0x20) /* Current field needs validation */
+#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 (0x01) /* Field has been changed */
-#define _NEWTOP (0x02) /* Vertical scrolling occured */
-#define _NEWPAGE (0x04) /* field begins new page of form */
-#define _MAY_GROW (0x08) /* dynamic field may still grow */
+#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 (0x01) /* Type is a linked type */
-#define _HAS_ARGS (0x02) /* Type has arguments */
-#define _HAS_CHOICE (0x04) /* Type has choice methods */
-#define _RESIDENT (0x08) /* Type is builtin */
+#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 */
/* This are the field options required to be a selectable field in field
navigation requests */
#define O_SELECTABLE (O_ACTIVE | O_VISIBLE)
/* If form is NULL replace form argument by default-form */
-#define Normalize_Form(form) ((form)=(form)?(form):_nc_Default_Form)
+#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)?(field):_nc_Default_Field)
+#define Normalize_Field(field) \
+ ((field) = (field != 0) ? (field) : _nc_Default_Field)
/* Retrieve forms window */
#define Get_Form_Window(form) \
@@ -71,20 +100,22 @@
/* Calculate the total size of all buffers for this field */
#define Total_Buffer_Size(field) \
- ( (Buffer_Length(field) + 1) * (1+(field)->nbuf) )
+ ( (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) (((f)->opts & O_SELECTABLE)==O_SELECTABLE)
-#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_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;
+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
@@ -96,7 +127,7 @@ typedef struct typearg {
O_NL_OVERLOAD |\
O_BS_OVERLOAD )
-#define ALL_FIELD_OPTS ( \
+#define ALL_FIELD_OPTS (Field_Options)( \
O_VISIBLE |\
O_ACTIVE |\
O_PUBLIC |\
@@ -108,23 +139,112 @@ typedef struct typearg {
O_PASSOK |\
O_STATIC )
-
#define C_BLANK ' '
#define is_blank(c) ((c)==C_BLANK)
+#define C_ZEROS '\0'
+
extern NCURSES_EXPORT_VAR(const FIELDTYPE *) _nc_Default_FieldType;
-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(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_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_Set_Current_Field (FORM*, FIELD*);
extern NCURSES_EXPORT(int) _nc_Position_Form_Cursor (FORM*);
+
+#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 */
diff --git a/lib/libform/form_cursor.3 b/lib/libform/form_cursor.3
index b8eed87ef3a..e6b9825c8a0 100644
--- a/lib/libform/form_cursor.3
+++ b/lib/libform/form_cursor.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_cursor.3,v 1.6 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_cursor.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_cursor.3x,v 1.4 1998/11/29 01:05:43 Rick.Ohnemus Exp $
+.\" $Id: form_cursor.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_cursor 3 ""
.SH NAME
\fBform_cursor\fR - position a form window cursor
@@ -46,17 +46,18 @@ form operation.
.SH RETURN VALUE
This routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_data.3 b/lib/libform/form_data.3
index 88cb4dd0b23..e7fca9792cd 100644
--- a/lib/libform/form_data.3
+++ b/lib/libform/form_data.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_data.3,v 1.10 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_data.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_data.3x,v 1.7 1998/11/29 01:13:22 Rick.Ohnemus Exp $
+.\" $Id: form_data.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.TH form_data 3 ""
.SH NAME
\fBform_data\fR - test for off-screen data in given forms
@@ -43,7 +43,7 @@ bool data_behind(const FORM *form);
.SH DESCRIPTION
The function \fBdata_ahead\fR tests whether there is off-screen data
ahead in the given form. It returns TRUE (1) or FALSE (0).
-
+.PP
The function \fBdata_behind\fR tests whether there is off-screen data
behind in the given form. It returns TRUE (1) or FALSE (0).
.SH SEE ALSO
diff --git a/lib/libform/form_driver.3 b/lib/libform/form_driver.3
index 5f8e753fd05..48d371abe8d 100644
--- a/lib/libform/form_driver.3
+++ b/lib/libform/form_driver.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: form_driver.3,v 1.7 1999/07/11 14:14:03 millert Exp $
+.\" $OpenBSD: form_driver.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2007,2008 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 *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_driver.3x,v 1.7 1999/07/10 23:13:18 tom Exp $
+.\" $Id: form_driver.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_driver 3 ""
.SH NAME
\fBform_driver\fR - command-processing loop of the form system
@@ -39,8 +39,21 @@ int form_driver(FORM *form, int c);
.br
.SH DESCRIPTION
Once a form has been posted (displayed), you should funnel input events to it
-through \fBform_driver\fR. This routine has two major input cases; either
-the input is a form navigation request or it's a printable ASCII character.
+through \fBform_driver\fR. This routine has three major input cases:
+.TP 3
+-
+The input is a form navigation request.
+Navigation request codes are constants defined in \fB<form.h>\fP,
+which are distinct from the key- and character codes returned by \fBwgetch\fP.
+.TP 3
+-
+The input is a printable character.
+Printable characters (which must be positive, less than 256) are
+checked according to the program's locale settings.
+.TP 3
+-
+The input is the KEY_MOUSE special key associated with an mouse event.
+.PP
The form driver requests are as follows:
.TP 5
REQ_NEXT_PAGE
@@ -54,7 +67,7 @@ Move to the first page.
.TP 5
REQ_LAST_PAGE
Move to the last field.
-
+.sp
.TP 5
REQ_NEXT_FIELD
Move to the next field.
@@ -91,7 +104,7 @@ Move up to a field.
.TP 5
REQ_DOWN_FIELD
Move down to a field.
-
+.sp
.TP 5
REQ_NEXT_CHAR
Move to the next char.
@@ -134,7 +147,7 @@ Move up in the field.
.TP 5
REQ_DOWN_CHAR
Move down in the field.
-
+.sp
.TP 5
REQ_NEW_LINE
Insert or overlay a new line.
@@ -171,7 +184,7 @@ Enter overlay mode.
.TP 5
REQ_INS_MODE
Enter insert mode.
-
+.sp
.TP 5
REQ_SCR_FLINE
Scroll the field forward a line.
@@ -190,7 +203,7 @@ Scroll the field forward half a page.
.TP 5
REQ_SCR_BHPAGE
Scroll the field backward half a page.
-
+.sp
.TP 5
REQ_SCR_FCHAR
Scroll the field forward a character.
@@ -209,7 +222,7 @@ Horizontal scroll the field forward half a line.
.TP 5
REQ_SCR_HBHALF
Horizontal scroll the field backward half a line.
-
+.sp
.TP
REQ_VALIDATION
Validate field.
@@ -220,43 +233,97 @@ Display next field choice.
REQ_PREV_CHOICE
Display previous field choice.
.PP
-If the second argument is a printable ASCII character, the driver places it
+If the second argument is a printable character, the driver places it
in the current position in the current field. If it is one of the forms
requests listed above, that request is executed.
+.SS MOUSE HANDLING
+.PP
+If the second argument is the KEY_MOUSE special key, the associated
+mouse event is translated into one of the above pre-defined requests.
+Currently only clicks in the user window (e.g. inside the form display
+area or the decoration window) are handled.
+.PP
+If you click above the display region of the form:
+.RS
+.TP
+a REQ_PREV_FIELD is generated for a single click,
+.TP
+a REQ_PREV_PAGE is generated for a double-click and
+.TP
+a REQ_FIRST_FIELD is generated for a triple-click.
+.RE
+.PP
+If you click below the display region of the form:
+.RS
+.TP
+a REQ_NEXT_FIELD is generated for a single click,
+.TP
+a REQ_NEXT_PAGE is generated for a double-click and
+.TP
+a REQ_LAST_FIELD is generated for a triple-click.
+.RE
.PP
-If the second argument is neither printable ASCII nor one of the above
+If you click at an field inside the display area of the form:
+.RS
+.TP 3
+-
+the form cursor is positioned to that field.
+.TP 3
+-
+If you double-click a field,
+the form cursor is positioned to that field
+and \fBE_UNKNOWN_COMMAND\fR is returned.
+This return value makes sense,
+because a double click usually means that an field-specific action should
+be returned.
+It is exactly the purpose of this return value to signal that an
+application specific command should be executed.
+.TP 3
+-
+If a translation
+into a request was done, \fBform_driver\fR returns the result of this request.
+.RE
+.PP
+If you clicked outside the user window or the mouse event could not be translated
+into a form request an \fBE_REQUEST_DENIED\fR is returned.
+.SS APPLICATION-DEFINED COMMANDS
+.PP
+If the second argument is neither printable nor one of the above
pre-defined form requests, the driver assumes it is an application-specific
command and returns \fBE_UNKNOWN_COMMAND\fR. Application-defined commands
should be defined relative to \fBMAX_COMMAND\fR, the maximum value of these
pre-defined requests.
.SH RETURN VALUE
-\fBform_driver\fR return one of the following error codes:
+\fBform_driver\fR returns one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
.TP 5
-\fBE_UNKNOWN_COMMAND\fR
-The form driver code saw an unknown request code.
-.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of field is invalid.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.TP 5
+.B E_UNKNOWN_COMMAND
+The form driver code saw an unknown request code.
+.
.SH SEE ALSO
-\fBcurses\fR(3), \fBform\fR(3).
+\fBcurses\fR(3),
+\fBform\fR(3),
+\fBwgetch\fR(3).
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header files
\fB<curses.h>\fR.
diff --git a/lib/libform/form_field.3 b/lib/libform/form_field.3
index 85c235cfcbb..c5a464763e4 100644
--- a/lib/libform/form_field.3
+++ b/lib/libform/form_field.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field.3x,v 1.5 1998/11/29 01:05:52 Rick.Ohnemus Exp $
+.\" $Id: form_field.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field 3 ""
.SH NAME
\fBform_field\fR - make and break connections between fields and forms
@@ -47,36 +47,37 @@ int move_field(FIELD *field, int frow, int fcol);
.SH DESCRIPTION
The function \fBset_form_fields\fR changes the field pointer array of
the given \fIform\fR. The array must be terminated by a \fBNULL\fR.
-
+.PP
The function \fBform_fields\fR returns the field array of the given form.
-
+.PP
The function \fBfield_count\fR returns the count of fields in \fIform\fR.
-
+.PP
The function \fBmove_field\fR moves the given field (which must be disconnected)
to a specified location on the screen.
.SH RETURN VALUES
-The function \fBform_fields\fR returns \fBNULL\fR on error.
-
-The function \fBfield_count\fR returns \fBERR\fR (the general
-\fBcurses\fR error return value) on error.
-
+The function \fBform_fields\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBfield_count\fR returns \fBERR\fR if the \fIform\fP parameter
+is \fBNULL\fP.
+.PP
The functions \fBset_form_fields\fR and \fBmove_field\fR return one of
the following codes on error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_CONNECTED
+The field is already connected to a form.
+.TP 5
+.B E_POSTED
The form is already posted.
.TP 5
-\fBE_CONNECTED\fR
-The field is already connected to a form.
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -85,7 +86,7 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
+.PP
The SVr4 forms library documentation specifies the \fBfield_count\fR error value
as -1 (which is the value of \fBERR\fR).
.SH AUTHORS
diff --git a/lib/libform/form_field_attributes.3 b/lib/libform/form_field_attributes.3
index 4074137a3bc..ed9ac222042 100644
--- a/lib/libform/form_field_attributes.3
+++ b/lib/libform/form_field_attributes.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_attributes.3,v 1.7 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_field_attributes.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_attributes.3x,v 1.5 1998/11/29 01:06:02 Rick.Ohnemus Exp $
+.\" $Id: form_field_attributes.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_field_attributes 3 ""
.SH NAME
\fBform_field_attributes\fR - color and attribute control for form fields
@@ -46,35 +46,36 @@ chtype field_back(const FIELD *field);
.br
int set_field_pad(FIELD *field, int pad);
.br
-chtype field_pad(const FIELD *field);
+int field_pad(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_fore\fR sets the foreground attribute of
\fIfield\fR. This is the highlight used to display the field contents. The
function \fBfield_fore\fR returns the foreground attribute. The default is
\fBA_STANDOUT\fR.
-
+.PP
The function \fBset_field_back\fR sets the background attribute of
\fIform\fR. This is the highlight used to display the extent fields in the
form. The function \fBfield_back\fR returns the background attribute. The
default is \fBA_NORMAL\fR.
-
+.PP
The function \fBset_field_pad\fR sets the character used to fill the field.
The function \fBfield_pad\fR returns the given form's pad character. The
default is a blank.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_buffer.3 b/lib/libform/form_field_buffer.3
index d3577eaac54..d9de3880c37 100644
--- a/lib/libform/form_field_buffer.3
+++ b/lib/libform/form_field_buffer.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_buffer.3,v 1.11 2000/04/12 21:48:03 aaron Exp $
+.\" $OpenBSD: form_field_buffer.3,v 1.12 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2008 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: From: form_field_buffer.3x,v 1.8 1999/06/16 00:37:09 juergen Exp $
+.\" $Id: form_field_buffer.3,v 1.12 2010/01/12 23:22:07 nicm Exp $
.TH form_field_buffer 3 ""
.SH NAME
\fBform_field_buffer\fR - field buffer control
@@ -48,44 +48,87 @@ int set_max_field(FIELD *field, int max);
.br
.SH DESCRIPTION
The function \fBset_field_buffer\fR sets the numbered buffer of the given field
-to contain a given string. Buffer 0 is the displayed value of the field; other
-numbered buffers may be allocated by applications through the \fBnbuf\fR
-argument of (see \fBform_field_new\fR(3)) but are not manipulated by the forms
-library. The function \fBfield_buffer\fR returns the address of the buffer.
-Please note that this buffer has always the length of the buffer, that means
-that it may typically contain trailing spaces. If you entered leading spaces
-the buffer may also contain them. If you want the raw data, you must write your
+to contain a given string:
+.RS 3
+.TP 3
+-
+Buffer 0 is the displayed value of the field.
+.TP 3
+-
+Other numbered buffers may be allocated by applications through the \fBnbuf\fR
+argument of (see \fBform_field_new\fR(3))
+but are not manipulated by the forms library.
+.RE
+.PP
+The function \fBfield_buffer\fR returns a pointer to
+the contents of the given numbered buffer:
+.RS 3
+.TP 3
+-
+The buffer contents always have the same length,
+and are padded with trailing spaces
+as needed to ensure this length is the same.
+.TP 3
+-
+The buffer may contain leading spaces, depending on how it was set.
+.TP 3
+-
+The buffer contents are set with \fBset_field_buffer\fP,
+or as a side effect of any editing operations on the corresponding field.
+.TP 3
+-
+Editing operations are based on the \fIwindow\fP which displays the field,
+rather than a \fIstring\fP.
+The window contains only printable characters, and is filled with blanks.
+If you want the raw data, you must write your
own routine that copies the value out of the buffer and removes the leading
-and trailing spaces. Please note also, that subsequent operations on the form
-will probably change the content of the buffer. So don't use it for long term
-storage of the entered form data.
-
+and trailing spaces.
+.TP 3
+-
+Because editing operations change the content of the buffer to
+correspond to the window, you should not rely on using buffers
+for long-term storage of form data.
+.RE
+.PP
The function \fBset_field_status\fR sets the associated status flag of
\fIfield\fR; \fBfield_status\fR gets the current value. The status flag
is set to a nonzero value whenever the field changes.
-
+.PP
The function \fBset_max_field\fR sets the maximum size for a dynamic field.
An argument of 0 turns off any maximum size threshold for that field.
.SH RETURN VALUE
The \fBfield_buffer\fR function returns NULL on error.
-
+It sets errno according to their success:
+.TP 5
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.PP
The \fBfield_status\fR function returns \fBTRUE\fR or \fBFALSE\fR.
-
+.PP
The remaining routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
+.PP
+When configured for wide-characters, \fBfield_buffer\fP returns a pointer
+to temporary storage (allocated and freed by the library).
+The application should not attempt to modify the data.
+It will be freed on the next call to \fBfield_buffer\fP to return the
+same buffer.
\fB<curses.h>\fR.
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
diff --git a/lib/libform/form_field_info.3 b/lib/libform/form_field_info.3
index da148a01c1f..23aad7cdafd 100644
--- a/lib/libform/form_field_info.3
+++ b/lib/libform/form_field_info.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_info.3,v 1.8 2000/06/19 03:53:56 millert Exp $
+.\" $OpenBSD: form_field_info.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2005,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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_info.3x,v 1.6 2000/04/15 22:21:31 tom Exp $
+.\" $Id: form_field_info.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_info 3 ""
.SH NAME
\fBform_field_info\fR - retrieve field characteristics
@@ -39,31 +39,32 @@
int field_info(const FIELD *field, int *rows, int *cols,
int *frow, int *fcol, int *nrow, int *nbuf);
.br
-int dynamic_field_info(const FIELD *field, int *rows, int *cols, *max);
+int dynamic_field_info(const FIELD *field, int *rows, int *cols, int *max);
.br
.SH DESCRIPTION
The function \fBfield_info\fR returns the sizes and other attributes passed in
to the field at its creation time. The attributes are: height, width, row of
upper-left corner, column of upper-left corner, number off-screen rows, and
number of working buffers.
-
+.PP
The function \fBdynamic_field_info\fR returns the actual size of the field, and
its maximum possible size. If the field has no size limit, the location
-addressed by the third argument will be set to 0. (A field can be made dynamic
-by turning off the \fBO_STATIC\fR).
+addressed by the third argument will be set to 0.
+A field can be made dynamic
+by turning off the \fBO_STATIC\fR option with \fBfield_opts_off\fR.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_just.3 b/lib/libform/form_field_just.3
index 502297418a7..c3246c2217b 100644
--- a/lib/libform/form_field_just.3
+++ b/lib/libform/form_field_just.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_just.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_just.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_just.3x,v 1.5 1998/11/29 01:06:32 Rick.Ohnemus Exp $
+.\" $Id: form_field_just.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_just 3 ""
.SH NAME
\fBform_field_just\fR - retrieve field characteristics
@@ -45,23 +45,23 @@ The function \fBset_field_just\fR sets the justification attribute of
a field; \fBfield_just\fR returns a field's justification attribute.
The attribute may be one of NO_JUSTIFICATION, JUSTIFY_RIGHT,
JUSTIFY_LEFT, or JUSTIFY_CENTER.
-
+.
.SH RETURN VALUE
The function \fBfield_just\fR returns one of: NO_JUSTIFICATION,
JUSTIFY_RIGHT, JUSTIFY_LEFT, or JUSTIFY_CENTER.
-
+.PP
The function \fBset_field_just\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_field_new.3 b/lib/libform/form_field_new.3
index 232803a9dd4..3528bb91907 100644
--- a/lib/libform/form_field_new.3
+++ b/lib/libform/form_field_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_new.3,v 1.9 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_new.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_field_new.3x,v 1.9 1998/11/29 01:06:44 Rick.Ohnemus Exp $
+.\" $Id: form_field_new.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_field_new 3 ""
.SH NAME
\fBform_field_new\fR - create and destroy form fields
@@ -50,31 +50,41 @@ int free_field(FIELD *field);
The function \fBnew_field\fR allocates a new field and initializes it from the
parameters given: height, width, row of upper-left corner, column of upper-left
corner, number off-screen rows, and number of additional working buffers.
-
+.PP
The function \fBdup_field\fR duplicates a field at a new location. Most
attributes (including current contents, size, validation type, buffer count,
growth threshold, justification, foreground, background, pad character,
options, and user pointer) are copied. Field status and the field page bit are
not copied.
-
+.PP
The function \fBlink_field\fR acts like \fBdup_field\fR, but the new field
shares buffers with its parent. Attribute data is separate.
-
+.PP
The function \fBfree_field\fR de-allocates storage associated with a field.
.SH RETURN VALUE
The function, \fBnew_field\fR, \fBdup_field\fR, \fBlink_field\fR return
\fBNULL\fR on error.
-
-The function \fBfree_field\fR returns one of the following:
+They set errno according to their success:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
+The function \fBfree_field\fR returns one of the following:
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_CONNECTED
+field is connected.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -83,10 +93,10 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
+.PP
It may be unwise to count on the set of attributes copied by
-\fBdup_field\fR(3) being portable; the System V forms library documents are
-not very explicit about what gets copied and what doesn't.
+\fBdup_field\fR being portable; the System V forms library documents are
+not very explicit about what gets copied and what does not.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_field_opts.3 b/lib/libform/form_field_opts.3
index 5b1af60c97c..17bc7a1c6a7 100644
--- a/lib/libform/form_field_opts.3
+++ b/lib/libform/form_field_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_opts.3,v 1.9 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_opts.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 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 *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_opts.3x,v 1.7 1998/11/29 01:06:54 Rick.Ohnemus Exp $
+.\" $Id: form_field_opts.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_field_opts 3 ""
.SH NAME
\fBform_field_opts\fR - set and get field options
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_opts(FIELD *field, OPTIONS opts);
+int set_field_opts(FIELD *field, Field_Options opts);
.br
-int field_opts_on(FIELD *field, OPTIONS opts);
+int field_opts_on(FIELD *field, Field_Options opts);
.br
-int field_opts_off(FIELD *field, OPTIONS opts);
+int field_opts_off(FIELD *field, Field_Options opts);
.br
-OPTIONS field_opts(const FIELD *field);
+Field_Options field_opts(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_opts\fR sets all the given field's option bits (field
option bits may be logically OR'ed together).
-
+.PP
The function \fBfield_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBfield_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBfield_opts\fR returns the field's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_VISIBLE
@@ -74,7 +74,7 @@ O_EDIT
The field can be edited.
.TP 5
O_WRAP
-Words that don't fit on a line are wrapped to the next line. Words are
+Words that do not fit on a line are wrapped to the next line. Words are
blank-separated.
.TP 5
O_BLANK
@@ -88,20 +88,24 @@ Allow a blank field.
.TP 5
O_STATIC
Field buffers are fixed to field's original size.
+Turn this option off to create a dynamic field.
.TP 5
O_PASSOK
Validate field only if modified by user.
.SH RETURN VALUE
Except for \fBfield_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CURRENT\fR
+.B E_CURRENT
The field is the current field.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.TP 5
diff --git a/lib/libform/form_field_userptr.3 b/lib/libform/form_field_userptr.3
index ce97c279689..f92f35a2019 100644
--- a/lib/libform/form_field_userptr.3
+++ b/lib/libform/form_field_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_field_userptr.3,v 1.7 1999/01/22 03:30:53 millert Exp $
+.\" $OpenBSD: form_field_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_field_userptr.3x,v 1.6 1998/11/29 01:07:05 Rick.Ohnemus Exp $
+.\" $Id: form_field_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_field_userptr 3 ""
.SH NAME
\fBform_field_userptr\fR - associate application data with a form field
@@ -45,14 +45,10 @@ Every form field has a field that can be used to hold application-specific data
(that is, the form-driver code leaves it alone). These functions get and set
that field.
.SH RETURN VALUE
-The function \fBfield_userptr\fR returns \fBNULL\fR on error. The function
-\fBset_field_userptr\fR returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+The function \fBfield_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_field_userptr\fR returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_field_validation.3 b/lib/libform/form_field_validation.3
index 267a59847e0..660d46e35cd 100644
--- a/lib/libform/form_field_validation.3
+++ b/lib/libform/form_field_validation.3
@@ -1,7 +1,7 @@
-.\" $OpenBSD: form_field_validation.3,v 1.8 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_field_validation.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -28,7 +28,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.'" $From: form_field_validation.3x,v 1.10 1998/03/11 21:12:53 juergen Exp $
+.\" $Id: form_field_validation.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_field_validation 3 ""
.SH NAME
\fBform_field_validation\fR - data type validation for fields
@@ -40,10 +40,25 @@ int set_field_type(FIELD *field, FIELDTYPE *type, ...);
FIELDTYPE *field_type(const FIELD *field);
.br
void *field_arg(const FIELD *field);
+.sp
+FIELDTYPE *TYPE_ALNUM;
+.br
+FIELDTYPE *TYPE_ALPHA;
+.br
+FIELDTYPE *TYPE_ENUM;
+.br
+FIELDTYPE *TYPE_INTEGER;
+.br
+FIELDTYPE *TYPE_NUMERIC;
+.br
+FIELDTYPE *TYPE_REGEXP;
+.br
+FIELDTYPE *TYPE_IPV4;
.br
.SH DESCRIPTION
The function \fBset_field_type\fR declares a data type for a given form field.
-This is the type checked by validation functions. The types are as follows:
+This is the type checked by validation functions.
+The predefined types are as follows:
.TP 5
TYPE_ALNUM
Alphanumeric data. Requires a third \fBint\fR argument, a minimum field width.
@@ -86,7 +101,7 @@ For details of the precision handling see \fBprintf's\fR man-page.
TYPE_REGEXP
Regular expression data. Requires a regular expression \fB(char *)\fR third argument;
the data is valid if the regular expression matches it. Regular expressions
-are in the format of \fBregcomp\fR(3) and \fBregexec\fR(3). Please notice
+are in the format of \fBregcomp\fR and \fBregexec\fR. Please notice
that the regular expression must match the whole field. If you have for
example an eight character wide field, a regular expression "^[0-9]*$" always
means that you have to fill all eight positions with digits. If you want to
@@ -100,17 +115,17 @@ is checked whether or not the buffer has the form a.b.c.d, where a,b,c and d are
numbers between 0 and 255. Trailing blanks in the buffer are ignored. The address
itself is not validated. Please note that this is an ncurses extension. This
field type may not be available in other curses implementations.
-
+.PP
It is possible to set up new programmer-defined field types. See the
\fBform_fieldtype\fR(3) manual page.
.SH RETURN VALUE
The functions \fBfield_type\fR and \fBfield_arg\fR return \fBNULL\fR on
error. The function \fBset_field_type\fR returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_fieldtype.3 b/lib/libform/form_fieldtype.3
index 965e3899b00..a8444862b9d 100644
--- a/lib/libform/form_fieldtype.3
+++ b/lib/libform/form_fieldtype.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_fieldtype.3,v 1.10 2003/05/16 08:48:27 jmc Exp $
+.\" $OpenBSD: form_fieldtype.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_fieldtype.3x,v 1.8 2000/07/15 22:02:03 tom Exp $
+.\" $Id: form_fieldtype.3,v 1.11 2010/01/12 23:22:07 nicm Exp $
.TH form_fieldtype 3 ""
.SH NAME
\fBform_fieldtype\fR - define validation-field types
@@ -49,7 +49,7 @@ int set_fieldtype_arg(
void (* const free_arg)(void *));
.br
int set_fieldtype_choice(
- FIELDTYPE *fieldtype
+ FIELDTYPE *fieldtype,
bool (* const next_choice)(FIELD *, const void *),
bool (* const prev_choice)(FIELD *, const void *));
.br
@@ -63,54 +63,76 @@ validity of an entered data string whenever the user attempts to leave a field.
The (FIELD *) argument is passed in so the validation predicate can see the
field's buffer, sizes and other attributes; the second argument is an
argument-block structure, about which more below.
-
+.PP
You also supply \fBnew_fieldtype\fR with \fIchar_check\fR,
a function to validate input characters as they are entered; it will be passed
the character to be checked and a pointer to an argument-block structure.
-
+.PP
The function \fBfree_fieldtype\fR frees the space allocated for a given
validation type.
-
-The function \fBset_fieldtype\fR associates three storage-management functions
-with a field type. The \fImak_arg\fR function is automatically applied to the
+.PP
+The function \fBset_fieldtype_arg\fR associates three storage-management functions
+with a field type.
+The \fImake_arg\fR function is automatically applied to the
list of arguments you give \fBset_field_type\fR when attaching validation
to a field; its job is to bundle these into an allocated argument-block
-object which can later be passed to validation predicated. The other two
-hook arguments should copy and free argument-block structures. They will
-be used by the forms-driver code. You must supply the \fImak_arg\fR function,
-the other two are optional, you may supply NULL for them. In this case it
-is assumed that \fImak_arg\fR doesn't allocate memory but simply loads the
+object which can later be passed to validation predicated.
+The other two hook arguments should copy and free argument-block structures.
+They will be used by the forms-driver code.
+You must supply the \fImake_arg\fR function,
+the other two are optional, you may supply NULL for them.
+In this case it is assumed
+that \fImake_arg\fR does not allocate memory but simply loads the
argument into a single scalar value.
-
+.PP
+The function \fBlink_fieldtype\fR creates
+a new field type from the two given types.
+They are connected by an logical 'OR'.
+.PP
The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
that the possible values of a field form an ordered set, and provide the forms
-user with a way to move through the set. The \fBset_fieldtype_choice\fR
+user with a way to move through the set.
+The \fBset_fieldtype_choice\fR
function allows forms programmers to define successor and predecessor functions
-for the field type. These functions take the field pointer and an
+for the field type.
+These functions take the field pointer and an
argument-block structure as arguments.
.SH RETURN VALUE
The pointer-valued routines return NULL on error.
-
+They set errno according to their success:
+.TP 5
+.B E_OK
+The routine succeeded.
+.TP 5
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
The integer-valued routines return one of the following codes on
error:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
The field is already connected to a form.
+.TP 5
+.B E_CURRENT
+The field is the current field.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
\fB<curses.h>\fR.
-
+.PP
All of the \fB(char *)\fR arguments of these functions should actually be
\fB(void *)\fR. The type has been left uncorrected for strict compatibility
with System V.
diff --git a/lib/libform/form_hook.3 b/lib/libform/form_hook.3
index 6a7d3227918..4d53f0351f2 100644
--- a/lib/libform/form_hook.3
+++ b/lib/libform/form_hook.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_hook.3,v 1.9 1999/03/28 18:01:03 millert Exp $
+.\" $OpenBSD: form_hook.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 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 *
@@ -29,47 +29,47 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_hook.3x,v 1.6 1999/03/20 22:37:15 Todd.Miller Exp $
+.\" $Id: form_hook.3,v 1.10 2010/01/12 23:22:07 nicm Exp $
.TH form_hook 3 ""
.SH NAME
\fBform_hook\fR - set hooks for automatic invocation by applications
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_init(FORM *form, void (*func)(FORM *));
+int set_field_init(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) field_init(const FORM *form);
+Form_Hook field_init(const FORM *form);
.br
-int set_field_term(FORM *form, void (*func)(FORM *));
+int set_field_term(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) field_term(const FORM *form);
+Form_Hook field_term(const FORM *form);
.br
-int set_form_init(FORM *form, void (*func)(FORM *));
+int set_form_init(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) form_init(const FORM *form);
+Form_Hook form_init(const FORM *form);
.br
-int set_form_term(FORM *form, void (*func)(FORM *));
+int set_form_term(FORM *form, Form_Hook func);
.br
-void (*)(FORM *) form_term(const FORM *form);
+Form_Hook form_term(const FORM *form);
.br
.SH DESCRIPTION
These functions make it possible to set hook functions to be called at various
points in the automatic processing of input event codes by \fBform_driver\fR.
-
+.PP
The function \fBset_field_init\fR sets a hook to be called at form-post time
and each time the selected field changes (after the change). \fBfield_init\fR
returns the current field init hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_field_term\fR sets a hook to be called at form-unpost time
and each time the selected field changes (before the change). \fBfield_term\fR
returns the current field term hook, if any (\fBNULL\fR if there is no such
hook).
-
+.PP
The function \fBset_form_init\fR sets a hook to be called at form-post time and
just after a page change once it is posted. \fBform_init\fR returns the
current form init hook, if any (\fBNULL\fR if there is no such hook).
-
+.PP
The function \fBset_form_term\fR sets a hook to be called at form-unpost time
and just before a page change once it is posted. \fBform_init\fR
returns the current form term hook, if any (\fBNULL\fR if there is no such
@@ -78,10 +78,10 @@ hook).
Routines that return pointers return \fBNULL\fR on error. Other routines
return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_new.3 b/lib/libform/form_new.3
index bd038576b9b..abe1a678197 100644
--- a/lib/libform/form_new.3
+++ b/lib/libform/form_new.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_new.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_new.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_new.3x,v 1.5 1998/11/29 01:07:37 Rick.Ohnemus Exp $
+.\" $Id: form_new.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_new 3 ""
.SH NAME
\fBform_new\fR - create and destroy forms
@@ -43,24 +43,34 @@ int free_form(FORM *form);
.SH DESCRIPTION
The function \fBnew_form\fR creates a new form connected to a specified field
pointer array (which must be \fBNULL\fR-terminated).
-
+.PP
The function \fBfree_form\fR disconnects \fIform\fR from its field array
and frees the storage allocated for the form.
.SH RETURN VALUE
The function \fBnew_form\fR returns \fBNULL\fR on error.
-
-The function \fBfree_form\fR returns one of the following:
+It sets errno according to the function's success:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+.B E_BAD_ARGUMENT
+Routine detected an incorrect or out-of-range argument.
+.TP 5
+.B E_CONNECTED
+The field is already connected to a form.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred, e.g., malloc failure.
+.PP
+The function \fBfree_form\fR returns one of the following:
+.TP 5
+.B E_OK
+The routine succeeded.
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The form has already been posted.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_new_page.3 b/lib/libform/form_new_page.3
index dea27f18e29..918fdf4d1db 100644
--- a/lib/libform/form_new_page.3
+++ b/lib/libform/form_new_page.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_new_page.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_new_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2002,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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_new_page.3x,v 1.5 1998/11/29 01:07:45 Rick.Ohnemus Exp $
+.\" $Id: form_new_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_new_page 3 ""
.SH NAME
\fBform_new_page\fR - form pagination functions
@@ -43,24 +43,24 @@ bool new_page(const FIELD *field);
.SH DESCRIPTION
The function \fBset_new_page\fR sets or resets a flag marking the given field
as the beginning of a new page on its form.
-
+.PP
The function \fBnew_page\fR is a predicate which tests if a given field marks
a page beginning on its form.
.SH RETURN VALUE
The function \fBnew_page\fR returns \fBTRUE\fR or \fBFALSE\fR.
-
+.PP
The function \fBset_new_page\fR return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_CONNECTED\fR
+.B E_CONNECTED
The given field is already connected to a form.
.SH SEE ALSO
-\fBcurses\fR(3) and 3 pages whose names begin with "form_" for detailed
+\fBcurses\fR(3) and related pages whose names begin "form_" for detailed
descriptions of the entry points.
.SH NOTES
The header file \fB<form.h>\fR automatically includes the header file
diff --git a/lib/libform/form_opts.3 b/lib/libform/form_opts.3
index 36906fe181d..429910b71b4 100644
--- a/lib/libform/form_opts.3
+++ b/lib/libform/form_opts.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_opts.3,v 1.8 1999/05/12 13:26:49 aaron Exp $
+.\" $OpenBSD: form_opts.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" Copyright (c) 1998-2006,2007 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 *
@@ -29,33 +29,33 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_opts.3x,v 1.6 1998/11/29 01:07:53 Rick.Ohnemus Exp $
+.\" $Id: form_opts.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_opts 3 ""
.SH NAME
\fBform_opts\fR - set and get form options
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_form_opts(FORM *form, OPTIONS opts);
+int set_form_opts(FORM *form, Field_Options opts);
.br
-int form_opts_on(FORM *form, OPTIONS opts);
+int form_opts_on(FORM *form, Field_Options opts);
.br
-int form_opts_off(FORM *form, OPTIONS opts);
+int form_opts_off(FORM *form, Field_Options opts);
.br
-OPTIONS form_opts(const FORM *form);
+Field_Options form_opts(const FORM *form);
.br
.SH DESCRIPTION
The function \fBset_form_opts\fR sets all the given form's option bits (form
option bits may be logically OR'ed together).
-
+.PP
The function \fBform_opts_on\fR turns on the given option bits, and leaves
others alone.
-
+.PP
The function \fBform_opts_off\fR turns off the given option bits, and leaves
others alone.
-
+.PP
The function \fBform_opts\fR returns the form's current option bits.
-
+.PP
The following options are defined (all are on by default):
.TP 5
O_NL_OVERLOAD
@@ -68,10 +68,10 @@ beginning of a field goes to the previous field.
.SH RETURN VALUE
Except for \fBform_opts\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/form_page.3 b/lib/libform/form_page.3
index 94bebc7d5cc..845cfc7852f 100644
--- a/lib/libform/form_page.3
+++ b/lib/libform/form_page.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_page.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_page.3x,v 1.8 1998/11/29 01:08:02 Rick.Ohnemus Exp $
+.\" $Id: form_page.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_page 3 ""
.SH NAME
\fBform_page\fR - set and get form page number
@@ -61,23 +61,24 @@ the argument is the null pointer or the field is not connected.
.SH RETURN VALUE
Except for \fBform_page\fR, each routine returns one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_INVALID_FIELD\fR
+.B E_INVALID_FIELD
Contents of a field are not valid.
.TP 5
-\fBE_REQUEST_DENIED\fR
+.B E_REQUEST_DENIED
The form driver could not process the request.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_post.3 b/lib/libform/form_post.3
index e5278e07dfc..1cc25cdae00 100644
--- a/lib/libform/form_post.3
+++ b/lib/libform/form_post.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_post.3,v 1.6 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_post.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_post.3x,v 1.4 1998/11/29 01:08:10 Rick.Ohnemus Exp $
+.\" $Id: form_post.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_post 3 ""
.SH NAME
\fBform_post\fR - write or erase forms from associated subwindows
@@ -45,34 +45,35 @@ The function \fBpost_form\fR displays a form to its associated subwindow. To
trigger physical display of the subwindow, use \fBrefresh\fR or some equivalent
\fBcurses\fR routine (the implicit \fBdoupdate\fR triggered by an \fBcurses\fR
input request will do).
-
+.PP
The function \fBunpost_form\fR erases form from its associated subwindow.
.SH RETURN VALUE
These routines return one of the following:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
-.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
-The form has already been posted.
-.TP 5
-\fBE_BAD_STATE\fR
+.B E_BAD_STATE
Routine was called from an initialization or termination function.
.TP 5
-\fBE_NO_ROOM\fR
-Form is too large for its window.
-.TP 5
-\fBE_NOT_POSTED\fR
+.B E_NOT_POSTED
The form has not been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the form.
+.TP 5
+.B E_NO_ROOM
+Form is too large for its window.
+.TP 5
+.B E_POSTED
+The form has already been posted.
+.TP 5
+.B E_SYSTEM_ERROR
+System error occurred (see \fBerrno\fR).
+.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_requestname.3 b/lib/libform/form_requestname.3
index 51a819faa4f..6812d20e5d9 100644
--- a/lib/libform/form_requestname.3
+++ b/lib/libform/form_requestname.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_requestname.3,v 1.6 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_requestname.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_requestname.3x,v 1.6 1998/11/29 01:08:18 Rick.Ohnemus Exp $
+.\" $Id: form_requestname.3,v 1.7 2010/01/12 23:22:07 nicm Exp $
.TH form_requestname 3 ""
.SH NAME
\fBform_requestname\fR - handle printable form request names
@@ -51,6 +51,7 @@ with the given name and returns its request code. Otherwise E_NO_MATCH is return
to \fBE_BAD_ARGUMENT\fR.
.br
\fBform_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+It does not set errno.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
diff --git a/lib/libform/form_userptr.3 b/lib/libform/form_userptr.3
index 0cd1226ed92..9ea1daf3cd2 100644
--- a/lib/libform/form_userptr.3
+++ b/lib/libform/form_userptr.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_userptr.3,v 1.7 1999/01/22 03:30:54 millert Exp $
+.\" $OpenBSD: form_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_userptr.3x,v 1.9 1998/11/29 01:08:39 Rick.Ohnemus Exp $
+.\" $Id: form_userptr.3,v 1.8 2010/01/12 23:22:07 nicm Exp $
.TH form_userptr 3 ""
.SH NAME
\fBform_userptr\fR - associate application data with a form item
@@ -45,14 +45,10 @@ Every form and every form item has a field that can be used to hold
application-specific data (that is, the form-driver code leaves it alone).
These functions get and set the form user pointer field.
.SH RETURN VALUE
-The function \fBform_userptr\fR returns \fBNULL\fR on error.
-The function \fBset_form_userptr\fR returns one of the following:
-.TP 5
-\fBE_OK\fR
-The routine succeeded.
-.TP 5
-\fBE_SYSTEM_ERROR\fR
-System error occurred (see \fBerrno\fR).
+The function \fBform_userptr\fR returns a pointer (which may be \fBNULL\fR).
+It does not set errno.
+.PP
+The function \fBset_form_userptr\fR returns \fBE_OK\fP (success).
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
.SH NOTES
@@ -61,9 +57,9 @@ The header file \fB<form.h>\fR automatically includes the header file
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
Version 7 or BSD versions.
-
-The user pointer should be a void pointer. We leave it as a char pointer for
-SVr4 compatibility.
+.PP
+The user pointer is a void pointer.
+We chose not to leave it as a char pointer for SVr4 compatibility.
.SH AUTHORS
Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
S. Raymond.
diff --git a/lib/libform/form_win.3 b/lib/libform/form_win.3
index da9faf1de8a..fb42bcb0bd5 100644
--- a/lib/libform/form_win.3
+++ b/lib/libform/form_win.3
@@ -1,8 +1,8 @@
'\" t
-.\" $OpenBSD: form_win.3,v 1.8 1999/05/08 20:29:03 millert Exp $
+.\" $OpenBSD: form_win.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.\"
.\"***************************************************************************
-.\" Copyright (c) 1998 Free Software Foundation, Inc. *
+.\" 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 *
@@ -29,7 +29,7 @@
.\" authorization. *
.\"***************************************************************************
.\"
-.\" $From: form_win.3x,v 1.8 1999/04/10 23:36:08 tom Exp $
+.\" $Id: form_win.3,v 1.9 2010/01/12 23:22:07 nicm Exp $
.TH form_win 3 ""
.SH NAME
\fBform_win\fR - make and break form window and subwindow associations
@@ -50,33 +50,33 @@ int scale_form(const FORM *form, int *rows, int *columns);
Every form has an associated pair of \fBcurses\fR windows. The form window
displays any title and border associated with the window; the form subwindow
displays the items of the form that are currently available for selection.
-
+.PP
The first four functions get and set those windows. It is not necessary to set
either window; by default, the driver code uses \fBstdscr\fR for both.
-
+.PP
In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as though
it were \fBstsdcr\fR. A form argument of \fBNULL\fR is treated as a request
to change the system default form window or subwindow.
-
+.PP
The function \fBscale_form\fR returns the minimum size required for the
subwindow of \fIform\fR.
.SH RETURN VALUE
Routines that return pointers return \fBNULL\fR on error. Routines that return
an integer return one of the following error codes:
.TP 5
-\fBE_OK\fR
+.B E_OK
The routine succeeded.
.TP 5
-\fBE_SYSTEM_ERROR\fR
+.B E_SYSTEM_ERROR
System error occurred (see \fBerrno\fR).
.TP 5
-\fBE_BAD_ARGUMENT\fR
+.B E_BAD_ARGUMENT
Routine detected an incorrect or out-of-range argument.
.TP 5
-\fBE_POSTED\fR
+.B E_POSTED
The form has already been posted.
.TP 5
-\fBE_NOT_CONNECTED\fR
+.B E_NOT_CONNECTED
No items are connected to the form.
.SH SEE ALSO
\fBcurses\fR(3), \fBform\fR(3).
diff --git a/lib/libform/frm_cursor.c b/lib/libform/frm_cursor.c
index 8eec04c5b46..e1533fd3fd3 100644
--- a/lib/libform/frm_cursor.c
+++ b/lib/libform/frm_cursor.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_cursor.c,v 1.4 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_cursor.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_cursor.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -50,16 +49,18 @@ MODULE_ID("$From: frm_cursor.c,v 1.5 2000/12/10 02:09:38 tom Exp $")
| E_NOT_POSTED - Form is not posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-pos_form_cursor (FORM * form)
+pos_form_cursor(FORM *form)
{
int res;
+ T((T_CALLED("pos_form_cursor(%p)"), form));
+
if (!form)
- res = E_BAD_ARGUMENT;
+ res = E_BAD_ARGUMENT;
else
{
if (!(form->status & _POSTED))
- res = E_NOT_POSTED;
+ res = E_NOT_POSTED;
else
res = _nc_Position_Form_Cursor(form);
}
diff --git a/lib/libform/frm_data.c b/lib/libform/frm_data.c
index 7f6dde0fd07..1b6ef2b8a86 100644
--- a/lib/libform/frm_data.c
+++ b/lib/libform/frm_data.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_data.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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 *
@@ -29,28 +27,30 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_data.c,v 1.7 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_data.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_behind(const FORM *form)
|
| Description : Check for off-screen data behind. This is nearly trivial
-| becose the begin of a field is fixed.
+| 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)
+data_behind(const FORM *form)
{
bool result = FALSE;
+ T((T_CALLED("data_behind(%p)"), form));
+
if (form && (form->status & _POSTED) && form->current)
{
FIELD *field;
@@ -58,42 +58,69 @@ data_behind (const FORM *form)
field = form->current;
if (!Single_Line_Field(field))
{
- result = (form->toprow==0) ? FALSE : TRUE;
+ result = (form->toprow == 0) ? FALSE : TRUE;
}
else
{
- result = (form->begincol==0) ? FALSE : TRUE;
+ result = (form->begincol == 0) ? FALSE : TRUE;
}
}
- return(result);
+ returnBool(result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static char * After_Last_Non_Pad_Position(
-| char *buffer,
+| Function : static char * Only_Padding(
+| WINDOW *w,
| int len,
| int pad)
|
-| Description : Find the last position in the buffer that doesn't
+| Description : Test if 'length' cells starting at the current position
| contain a padding character.
|
-| Return Values : The pointer to this position
+| Return Values : true if only padding cells are found
+--------------------------------------------------------------------------*/
-INLINE
-static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
+NCURSES_INLINE static bool
+Only_Padding(WINDOW *w, int len, int pad)
{
- char *end = buffer + len;
-
- assert(buffer && len>=0);
- while ( (buffer < end) && (*(end-1)==pad) )
- end--;
+ bool result = TRUE;
+ int y, x, j;
+ FIELD_CELL cell;
- return end;
+ 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;
}
-#define SMALL_BUFFER_SIZE (80)
-
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_ahead(const FORM *form)
@@ -105,31 +132,21 @@ static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
| FALSE - there are no off-screen data ahead
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-data_ahead (const FORM *form)
+data_ahead(const FORM *form)
{
bool result = FALSE;
+ T((T_CALLED("data_ahead(%p)"), form));
+
if (form && (form->status & _POSTED) && form->current)
{
- static char buffer[SMALL_BUFFER_SIZE + 1];
FIELD *field;
- bool large_buffer;
bool cursor_moved = FALSE;
- char *bp;
- char *found_content;
int pos;
field = form->current;
assert(form->w);
- large_buffer = (field->cols > SMALL_BUFFER_SIZE);
- if (large_buffer)
- bp = (char *)malloc((size_t)(field->cols) + 1);
- else
- bp = buffer;
-
- assert(bp);
-
if (Single_Line_Field(field))
{
int check_len;
@@ -138,15 +155,12 @@ data_ahead (const FORM *form)
while (pos < field->dcols)
{
check_len = field->dcols - pos;
- if ( check_len >= field->cols )
+ if (check_len >= field->cols)
check_len = field->cols;
cursor_moved = TRUE;
- wmove(form->w,0,pos);
- winnstr(form->w,bp,check_len);
- found_content =
- After_Last_Non_Pad_Position(bp,check_len,field->pad);
- if (found_content==bp)
- pos += field->cols;
+ wmove(form->w, 0, pos);
+ if (Only_Padding(form->w, check_len, field->pad))
+ pos += field->cols;
else
{
result = TRUE;
@@ -160,12 +174,9 @@ data_ahead (const FORM *form)
while (pos < field->drows)
{
cursor_moved = TRUE;
- wmove(form->w,pos,0);
+ wmove(form->w, pos, 0);
pos++;
- winnstr(form->w,bp,field->cols);
- found_content =
- After_Last_Non_Pad_Position(bp,field->cols,field->pad);
- if (found_content!=bp)
+ if (!Only_Padding(form->w, field->cols, field->pad))
{
result = TRUE;
break;
@@ -173,13 +184,10 @@ data_ahead (const FORM *form)
}
}
- if (large_buffer)
- free(bp);
-
if (cursor_moved)
- wmove(form->w,form->currow,form->curcol);
+ wmove(form->w, form->currow, form->curcol);
}
- return(result);
+ returnBool(result);
}
/* frm_data.c ends here */
diff --git a/lib/libform/frm_def.c b/lib/libform/frm_def.c
index ac123147d4a..63079bf5f3d 100644
--- a/lib/libform/frm_def.c
+++ b/lib/libform/frm_def.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_def.c,v 1.6 2001/01/22 18:02:14 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 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 *
@@ -29,37 +27,38 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_def.c,v 1.10 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_def.c,v 1.7 2010/01/12 23:22:07 nicm 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 */
+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;
@@ -76,39 +75,40 @@ NCURSES_EXPORT_VAR(FORM *) _nc_Default_Form = &default_form;
|
| Return Values : New head of sorted fieldlist
+--------------------------------------------------------------------------*/
-static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
+static FIELD *
+Insert_Field_By_Position(FIELD *newfield, FIELD *head)
{
FIELD *current, *newhead;
-
+
assert(newfield);
if (!head)
- { /* empty list is trivial */
+ { /* 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)) )
+ 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 */
+ 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;
+ /* 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)
+ if (current == head)
newhead = newfield;
}
- return(newhead);
+ return (newhead);
}
/*---------------------------------------------------------------------------
@@ -119,25 +119,26 @@ static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Disconnect_Fields( FORM * form )
+static void
+Disconnect_Fields(FORM *form)
{
if (form->field)
{
FIELD **fields;
- for(fields=form->field;*fields;fields++)
+ for (fields = form->field; *fields; fields++)
{
- if (form == (*fields)->form)
+ 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)
+ if (form->page)
free(form->page);
- form->page = (_PAGE *)0;
- }
+ form->page = (_PAGE *) 0;
+ }
}
/*---------------------------------------------------------------------------
@@ -151,85 +152,98 @@ static void Disconnect_Fields( FORM * form )
| E_BAD_ARGUMENT - Invalid form pointer or field array
| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
-static int Connect_Fields(FORM * form, FIELD ** fields)
+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)"), form, fields));
+
assert(form);
- form->field = fields;
+ form->field = fields;
form->maxfield = 0;
- form->maxpage = 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++)
+ for (field_cnt = 0; fields[field_cnt]; field_cnt++)
{
- if (fields[field_cnt]->form)
+ if (fields[field_cnt]->form)
RETURN(E_CONNECTED);
- if ( field_cnt==0 ||
- (fields[field_cnt]->status & _NEWPAGE))
+ if (field_cnt == 0 ||
+ (fields[field_cnt]->status & _NEWPAGE))
page_nr++;
fields[field_cnt]->form = form;
- }
- if (field_cnt==0)
+ }
+ if (field_cnt == 0 || (short)field_cnt < 0)
RETURN(E_BAD_ARGUMENT);
-
+
/* allocate page structures */
- if ( (pg = (_PAGE *)malloc(page_nr * sizeof(_PAGE))) != (_PAGE *)0 )
+ if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0)
{
+ T((T_CREATE("_PAGE %p"), 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++)
+ for (j = 0; j < field_cnt; j++)
{
- if (j==0)
+ if (j == 0)
pg->pmin = j;
else
{
if (fields[j]->status & _NEWPAGE)
{
- pg->pmax = j-1;
+ 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)
+
+ if (form->rows < maximum_row_in_field)
form->rows = maximum_row_in_field;
- if (form->cols < maximum_col_in_field)
+ if (form->cols < maximum_col_in_field)
form->cols = maximum_col_in_field;
}
-
- pg->pmax = field_cnt-1;
+
+ pg->pmax = field_cnt - 1;
form->maxfield = field_cnt;
- form->maxpage = page_nr;
-
+ form->maxpage = page_nr;
+
/* Sort fields on form pages */
- for(page_nr = 0;page_nr < form->maxpage; page_nr++)
+ 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++)
+
+ 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);
+ 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;
}
- form->page[page_nr].smin = fld->index;
- form->page[page_nr].smax = fld->sprev->index;
}
RETURN(E_OK);
}
@@ -242,46 +256,57 @@ static int Connect_Fields(FORM * form, FIELD ** fields)
| If there are fields, position to first active field.
|
| Return Values : E_OK - success
-| any other - error occured
+| E_BAD_ARGUMENT - Invalid form pointer or field array
+| E_CONNECTED - a field is already connected
+| E_SYSTEM_ERROR - not enough memory
+--------------------------------------------------------------------------*/
-INLINE static int Associate_Fields(FORM *form, FIELD **fields)
+NCURSES_INLINE static int
+Associate_Fields(FORM *form, FIELD **fields)
{
- int res = Connect_Fields(form,fields);
+ int res = Connect_Fields(form, fields);
+
if (res == E_OK)
{
- if (form->maxpage>0)
+ if (form->maxpage > 0)
{
form->curpage = 0;
- form_driver(form,FIRST_ACTIVE_MAGIC);
+ form_driver(form, FIRST_ACTIVE_MAGIC);
}
else
{
form->curpage = -1;
form->current = (FIELD *)0;
- }
+ }
}
- return(res);
+ return (res);
}
-
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : FORM *new_form( FIELD **fields )
|
| Description : Create new form with given array of fields.
|
-| Return Values : Pointer to form. NULL if error occured.
+| 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 *)
-new_form (FIELD ** fields)
-{
+new_form(FIELD **fields)
+{
int err = E_SYSTEM_ERROR;
- FORM *form = (FORM *)malloc(sizeof(FORM));
-
+ FORM *form = typeMalloc(FORM, 1);
+
+ T((T_CALLED("new_form(%p)"), fields));
if (form)
{
+ T((T_CREATE("form %p"), form));
*form = *_nc_Default_Form;
- if ((err=Associate_Fields(form,fields))!=E_OK)
+ if ((err = Associate_Fields(form, fields)) != E_OK)
{
free_form(form);
form = (FORM *)0;
@@ -290,8 +315,8 @@ new_form (FIELD ** fields)
if (!form)
SET_ERROR(err);
-
- return(form);
+
+ returnForm(form);
}
/*---------------------------------------------------------------------------
@@ -305,19 +330,21 @@ new_form (FIELD ** fields)
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-free_form (FORM * form)
+free_form(FORM *form)
{
- if ( !form )
+ T((T_CALLED("free_form(%p)"), form));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( form->status & _POSTED)
+ if (form->status & _POSTED)
RETURN(E_POSTED);
-
- Disconnect_Fields( form );
- if (form->page)
+
+ Disconnect_Fields(form);
+ if (form->page)
free(form->page);
free(form);
-
+
RETURN(E_OK);
}
@@ -327,31 +354,35 @@ free_form (FORM * form)
|
| Description : Set a new association of an array of fields to a form
|
-| Return Values : E_OK - no error
-| E_BAD_ARGUMENT - invalid form pointer
-| E_POSTED - form is posted
+| 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)
+set_form_fields(FORM *form, FIELD **fields)
{
FIELD **old;
int res;
-
- if ( !form )
+
+ T((T_CALLED("set_form_fields(%p,%p)"), form, fields));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( form->status & _POSTED )
+ 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 );
-
+ 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 )
@@ -361,9 +392,10 @@ set_form_fields (FORM * form, FIELD ** fields)
| Return Values : Pointer to field array
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(FIELD **)
-form_fields (const FORM * form)
+form_fields(const FORM *form)
{
- return (Normalize_Form( form )->field);
+ T((T_CALLED("form_field(%p)"), form));
+ returnFieldPtr(Normalize_Form(form)->field);
}
/*---------------------------------------------------------------------------
@@ -375,9 +407,11 @@ form_fields (const FORM * form)
| Return Values : Number of fields, -1 if none are defined
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-field_count (const FORM * form)
+field_count(const FORM *form)
{
- return (Normalize_Form( form )->maxfield);
+ T((T_CALLED("field_count(%p)"), form));
+
+ returnCode(Normalize_Form(form)->maxfield);
}
/* frm_def.c ends here */
diff --git a/lib/libform/frm_driver.c b/lib/libform/frm_driver.c
index 5db838901a1..ea428fd113c 100644
--- a/lib/libform/frm_driver.c
+++ b/lib/libform/frm_driver.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_driver.c,v 1.8 2003/01/05 22:41:37 deraadt Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2007,2008 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 *
@@ -29,21 +27,22 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
+MODULE_ID("$Id: frm_driver.c,v 1.9 2010/01/12 23:22:07 nicm Exp $")
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
- of the driver routines as well as the form_driver function.
+ of the driver routines as well as the form_driver function.
Essentially this module is nearly the whole library. This is because
all the functions in this module depends on some others in the module,
so it makes no sense to split them into separate files because they
will always be linked together. The only acceptable concern is turnaround
- time for this module, but now we have all Pentiums or Riscs, so what!
+ time for this module, but now we have all Pentiums or RISCs, so what!
The driver routines are grouped into nine generic categories:
@@ -54,12 +53,12 @@ MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
The current field of the form is left and some new field is
entered.
c) Intra-Field Navigation ( all functions prefixed by IFN_ )
- The current position in the current field is changed.
+ The current position in the current field is changed.
d) Vertical Scrolling ( all functions prefixed by VSC_ )
- Esseantially this is a specialization of Intra-Field navigation.
+ Essentially this is a specialization of Intra-Field navigation.
It has to check for a multi-line field.
e) Horizontal Scrolling ( all functions prefixed by HSC_ )
- Esseantially this is a specialization of Intra-Field navigation.
+ Essentially this is a specialization of Intra-Field navigation.
It has to check for a single-line field.
f) Field Editing ( all functions prefixed by FE_ )
The content of the current field is changed
@@ -80,34 +79,46 @@ MODULE_ID("$From: frm_driver.c,v 1.37 2000/12/10 02:09:38 tom Exp $")
/*
Some options that may effect compatibility in behavior to SVr4 forms,
-but they are here to allow a more intuitive and user friendly behaviour of
+but they are here to allow a more intuitive and user friendly behavior of
our form implementation. This doesn't affect the API, so we feel it is
uncritical.
-The initial implementation tries to stay very close with the behaviour
+The initial implementation tries to stay very close with the behavior
of the original SVr4 implementation, although in some areas it is quite
clear that this isn't the most appropriate way. As far as possible this
sources will allow you to build a forms lib that behaves quite similar
-to SVr4, but now and in the future we will give you better options.
+to SVr4, but now and in the future we will give you better options.
Perhaps at some time we will make this configurable at runtime.
*/
-/* Implement a more user-friendly previous/next word behaviour */
+/* Implement a more user-friendly previous/next word behavior */
#define FRIENDLY_PREV_NEXT_WORD (1)
-/* Fix the wrong behaviour for forms with all fields inactive */
+/* Fix the wrong behavior for forms with all fields inactive */
#define FIX_FORM_INACTIVE_BUG (1)
/* Allow dynamic field growth also when navigating past the end */
#define GROW_IF_NAVIGATE (1)
+#if USE_WIDEC_SUPPORT
+#define myADDNSTR(w, s, n) wadd_wchnstr(w, s, n)
+#define myINSNSTR(w, s, n) wins_wchnstr(w, s, n)
+#define myINNSTR(w, s, n) fix_wchnstr(w, s, n)
+#define myWCWIDTH(w, y, x) cell_width(w, y, x)
+#else
+#define myADDNSTR(w, s, n) waddnstr(w, s, n)
+#define myINSNSTR(w, s, n) winsnstr(w, s, n)
+#define myINNSTR(w, s, n) winnstr(w, s, n)
+#define myWCWIDTH(w, y, x) 1
+#endif
+
/*----------------------------------------------------------------------------
Forward references to some internally used static functions
--------------------------------------------------------------------------*/
-static int Inter_Field_Navigation ( int (* const fct) (FORM *), FORM * form );
-static int FN_Next_Field (FORM * form);
-static int FN_Previous_Field (FORM * form);
+static int Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form);
+static int FN_Next_Field(FORM *form);
+static int FN_Previous_Field(FORM *form);
static int FE_New_Line(FORM *);
static int FE_Delete_Previous(FORM *);
-
+
/*----------------------------------------------------------------------------
Macro Definitions.
@@ -151,7 +162,7 @@ static int FE_Delete_Previous(FORM *);
#define Address_Of_Current_Position_In_Buffer(form) \
Address_Of_Current_Position_In_Nth_Buffer(form,0)
-/* Logic to decide wether or not a field is actually a field with
+/* Logic to decide whether or not a field is actually a field with
vertical or horizontal scrolling */
#define Is_Scroll_Field(field) \
(((field)->drows > (field)->rows) || \
@@ -191,168 +202,320 @@ static int FE_Delete_Previous(FORM *);
#define First_Position_In_Current_Field(form) \
(((form)->currow==0) && ((form)->curcol==0))
-
#define Minimum(a,b) (((a)<=(b)) ? (a) : (b))
#define Maximum(a,b) (((a)>=(b)) ? (a) : (b))
-
+
+/*----------------------------------------------------------------------------
+ Useful constants
+ --------------------------------------------------------------------------*/
+static FIELD_CELL myBLANK = BLANK;
+static FIELD_CELL myZEROS;
+
+#ifdef TRACE
+static void
+check_pos(FORM *form, int lineno)
+{
+ int y, x;
+
+ if (form && form->w)
+ {
+ getyx(form->w, y, x);
+ if (y != form->currow || x != form->curcol)
+ {
+ T(("CHECKPOS %s@%d have position %d,%d vs want %d,%d",
+ __FILE__, lineno,
+ y, x,
+ form->currow, form->curcol));
+ }
+ }
+}
+#define CHECKPOS(form) check_pos(form, __LINE__)
+#else
+#define CHECKPOS(form) /* nothing */
+#endif
+
+/*----------------------------------------------------------------------------
+ Wide-character special functions
+ --------------------------------------------------------------------------*/
+#if USE_WIDEC_SUPPORT
+/* like winsnstr */
+static int
+wins_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int code = ERR;
+ int y, x;
+
+ while (n-- > 0)
+ {
+ getyx(w, y, x);
+ if ((code = wins_wch(w, s++)) != OK)
+ break;
+ if ((code = wmove(w, y, x + 1)) != OK)
+ break;
+ }
+ return code;
+}
+
+/* win_wchnstr is inconsistent with winnstr, since it returns OK rather than
+ * the number of items transferred.
+ */
+static int
+fix_wchnstr(WINDOW *w, cchar_t *s, int n)
+{
+ int x;
+
+ win_wchnstr(w, s, n);
+ /*
+ * This function is used to extract the text only from the window.
+ * Strip attributes and color from the string so they will not be added
+ * back when copying the string to the window.
+ */
+ for (x = 0; x < n; ++x)
+ {
+ RemAttr(s[x], A_ATTRIBUTES);
+ SetPair(s[x], 0);
+ }
+ return n;
+}
+
+/*
+ * Returns the column of the base of the given cell.
+ */
+static int
+cell_base(WINDOW *win, int y, int x)
+{
+ int result = x;
+
+ while (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecBase(CHDEREF(data)) || !isWidecExt(CHDEREF(data)))
+ {
+ result = x;
+ break;
+ }
+ --x;
+ }
+ return result;
+}
+
+/*
+ * Returns the number of columns needed for the given cell in a window.
+ */
+static int
+cell_width(WINDOW *win, int y, int x)
+{
+ int result = 1;
+
+ if (LEGALYX(win, y, x))
+ {
+ cchar_t *data = &(win->_line[y].text[x]);
+
+ if (isWidecExt(CHDEREF(data)))
+ {
+ /* recur, providing the number of columns to the next character */
+ result = cell_width(win, y, x - 1);
+ }
+ else
+ {
+ result = wcwidth(CharOf(CHDEREF(data)));
+ }
+ }
+ return result;
+}
+
+/*
+ * There is no wide-character function such as wdel_wch(), so we must find
+ * all of the cells that comprise a multi-column character and delete them
+ * one-by-one.
+ */
+static void
+delete_char(FORM *form)
+{
+ int cells = cell_width(form->w, form->currow, form->curcol);
+
+ form->curcol = cell_base(form->w, form->currow, form->curcol);
+ wmove(form->w, form->currow, form->curcol);
+ while (cells-- > 0)
+ {
+ wdelch(form->w);
+ }
+}
+#define DeleteChar(form) delete_char(form)
+#else
+#define DeleteChar(form) \
+ wmove((form)->w, (form)->currow, (form)->curcol), \
+ wdelch((form)->w)
+#endif
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *Get_Start_Of_Data(char * buf, int blen)
-|
+|
| Description : Return pointer to first non-blank position in buffer.
| If buffer is empty return pointer to buffer itself.
|
| Return Values : Pointer to first non-blank position in buffer
+--------------------------------------------------------------------------*/
-INLINE static char *Get_Start_Of_Data(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+Get_Start_Of_Data(FIELD_CELL *buf, int blen)
{
- char *p = buf;
- char *end = &buf[blen];
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &buf[blen];
- assert(buf && blen>=0);
- while( (p < end) && is_blank(*p) )
+ assert(buf && blen >= 0);
+ while ((p < end) && ISBLANK(*p))
p++;
- return( (p==end) ? buf : p );
+ return ((p == end) ? buf : p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *After_End_Of_Data(char * buf, int blen)
-|
+|
| Description : Return pointer after last non-blank position in buffer.
| If buffer is empty, return pointer to buffer itself.
|
-| Return Values : Pointer to position after last non-blank position in
+| Return Values : Pointer to position after last non-blank position in
| buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *After_End_Of_Data(char * buf,int blen)
+NCURSES_INLINE static FIELD_CELL *
+After_End_Of_Data(FIELD_CELL *buf, int blen)
{
- char *p = &buf[blen];
-
- assert(buf && blen>=0);
- while( (p>buf) && is_blank(p[-1]) )
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && ISBLANK(p[-1]))
p--;
- return( p );
+ return (p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *Get_First_Whitespace_Character(
| char * buf, int blen)
-|
+|
| Description : Position to the first whitespace character.
|
| Return Values : Pointer to first whitespace character in buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *Get_First_Whitespace_Character(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+Get_First_Whitespace_Character(FIELD_CELL *buf, int blen)
{
- char *p = buf;
- char *end = &p[blen];
-
- assert(buf && blen>=0);
- while( (p < end) && !is_blank(*p))
+ FIELD_CELL *p = buf;
+ FIELD_CELL *end = &p[blen];
+
+ assert(buf && blen >= 0);
+ while ((p < end) && !ISBLANK(*p))
p++;
- return( (p==end) ? buf : p );
+ return ((p == end) ? buf : p);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static char *After_Last_Whitespace_Character(
| char * buf, int blen)
-|
+|
| Description : Get the position after the last whitespace character.
|
-| Return Values : Pointer to position after last whitespace character in
+| Return Values : Pointer to position after last whitespace character in
| buffer.
+--------------------------------------------------------------------------*/
-INLINE static char *After_Last_Whitespace_Character(char * buf, int blen)
+NCURSES_INLINE static FIELD_CELL *
+After_Last_Whitespace_Character(FIELD_CELL *buf, int blen)
{
- char *p = &buf[blen];
-
- assert(buf && blen>=0);
- while( (p>buf) && !is_blank(p[-1]) )
+ FIELD_CELL *p = &buf[blen];
+
+ assert(buf && blen >= 0);
+ while ((p > buf) && !ISBLANK(p[-1]))
p--;
- return( p );
+ return (p);
}
/* Set this to 1 to use the div_t version. This is a good idea if your
compiler has an intrinsic div() support. Unfortunately GNU-C has it
- not yet.
+ not yet.
N.B.: This only works if form->curcol follows immediately form->currow
- and both are of type int.
+ and both are of type int.
*/
#define USE_DIV_T (0)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Adjust_Cursor_Position(
| FORM * form, const char * pos)
-|
-| Description : Set current row and column of the form to values
+|
+| Description : Set current row and column of the form to values
| corresponding to the buffer position.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void Adjust_Cursor_Position(FORM * form, const char * pos)
+NCURSES_INLINE static void
+Adjust_Cursor_Position(FORM *form, const FIELD_CELL *pos)
{
FIELD *field;
int idx;
field = form->current;
- assert( pos >= field->buf && field->dcols > 0);
- idx = (int)( pos - field->buf );
+ assert(pos >= field->buf && field->dcols > 0);
+ idx = (int)(pos - field->buf);
#if USE_DIV_T
- *((div_t *)&(form->currow)) = div(idx,field->dcols);
+ *((div_t *) & (form->currow)) = div(idx, field->dcols);
#else
form->currow = idx / field->dcols;
form->curcol = idx - field->cols * form->currow;
-#endif
- if ( field->drows < form->currow )
+#endif
+ if (field->drows < form->currow)
form->currow = 0;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Buffer_To_Window(
| const FIELD * field,
| WINDOW * win)
-|
-| Description : Copy the buffer to the window. If its a multiline
+|
+| Description : Copy the buffer to the window. If it is a multi-line
| field, the buffer is split to the lines of the
| window without any editing.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Buffer_To_Window(const FIELD * field, WINDOW * win)
+static void
+Buffer_To_Window(const FIELD *field, WINDOW *win)
{
int width, height;
+ int y, x;
int len;
int row;
- char *pBuffer;
+ FIELD_CELL *pBuffer;
assert(win && field);
- width = getmaxx(win);
+ getyx(win, y, x);
+ width = getmaxx(win);
height = getmaxy(win);
- for(row=0, pBuffer=field->buf;
- row < height;
- row++, pBuffer += width )
+ for (row = 0, pBuffer = field->buf;
+ row < height;
+ row++, pBuffer += width)
{
- if ((len = (int)( After_End_Of_Data( pBuffer, width ) - pBuffer )) > 0)
+ if ((len = (int)(After_End_Of_Data(pBuffer, width) - pBuffer)) > 0)
{
- wmove( win, row, 0 );
- waddnstr( win, pBuffer, len );
+ wmove(win, row, 0);
+ myADDNSTR(win, pBuffer, len);
}
- }
+ }
+ wmove(win, y, x);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Window_To_Buffer(
| WINDOW * win,
| FIELD * field)
-|
+|
| Description : Copy the content of the window into the buffer.
| The multiple lines of a window are simply
| concatenated into the buffer. Pad characters in
@@ -360,42 +523,48 @@ static void Buffer_To_Window(const FIELD * field, WINDOW * win)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Window_To_Buffer(WINDOW * win, FIELD * field)
+static void
+Window_To_Buffer(WINDOW *win, FIELD *field)
{
int pad;
int len = 0;
- char *p;
+ FIELD_CELL *p;
int row, height;
-
- assert(win && field && field->buf );
+
+ assert(win && field && field->buf);
pad = field->pad;
p = field->buf;
height = getmaxy(win);
- for(row=0; (row < height) && (row < field->drows); row++ )
+ for (row = 0; (row < height) && (row < field->drows); row++)
{
- wmove( win, row, 0 );
- len += winnstr( win, p+len, field->dcols );
+ wmove(win, row, 0);
+ len += myINNSTR(win, p + len, field->dcols);
}
- p[len] = '\0';
+ p[len] = myZEROS;
/* replace visual padding character by blanks in buffer */
if (pad != C_BLANK)
{
int i;
- for(i=0; i<len; i++, p++)
+
+ for (i = 0; i < len; i++, p++)
{
- if (*p==pad)
- *p = C_BLANK;
+ if ((unsigned long)CharOf(*p) == ChCharOf(pad)
+#if USE_WIDEC_SUPPORT
+ && p->chars[1] == 0
+#endif
+ )
+ *p = myBLANK;
}
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Synchronize_Buffer(FORM * form)
-|
+|
| Description : If there was a change, copy the content of the
| window into the buffer, so the buffer is synchronized
| with the windows content. We have to indicate that the
@@ -403,21 +572,22 @@ static void Window_To_Buffer(WINDOW * win, FIELD * field)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-INLINE static void Synchronize_Buffer(FORM * form)
+NCURSES_INLINE static void
+Synchronize_Buffer(FORM *form)
{
if (form->status & _WINDOW_MODIFIED)
{
form->status &= ~_WINDOW_MODIFIED;
- form->status |= _FCHECK_REQUIRED;
- Window_To_Buffer(form->w,form->current);
- wmove(form->w,form->currow,form->curcol);
+ form->status |= _FCHECK_REQUIRED;
+ Window_To_Buffer(form->w, form->current);
+ wmove(form->w, form->currow, form->curcol);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Field_Grown( FIELD *field, int amount)
-|
+|
| Description : This function is called for growable dynamic fields
| only. It has to increase the buffers and to allocate
| a new window for this field.
@@ -428,7 +598,8 @@ INLINE static void Synchronize_Buffer(FORM * form)
| Return Values : TRUE - field successfully increased
| FALSE - there was some error
+--------------------------------------------------------------------------*/
-static bool Field_Grown(FIELD * field, int amount)
+static bool
+Field_Grown(FIELD *field, int amount)
{
bool result = FALSE;
@@ -439,23 +610,23 @@ static bool Field_Grown(FIELD * field, int amount)
int new_buflen;
int old_dcols = field->dcols;
int old_drows = field->drows;
- char *oldbuf = field->buf;
- char *newbuf;
+ FIELD_CELL *oldbuf = field->buf;
+ FIELD_CELL *newbuf;
int growth;
FORM *form = field->form;
- bool need_visual_update = ((form != (FORM *)0) &&
+ bool need_visual_update = ((form != (FORM *)0) &&
(form->status & _POSTED) &&
- (form->current==field));
-
+ (form->current == field));
+
if (need_visual_update)
Synchronize_Buffer(form);
-
+
if (single_line_field)
{
growth = field->cols * amount;
if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->dcols,growth);
+ growth = Minimum(field->maxgrow - field->dcols, growth);
field->dcols += growth;
if (field->dcols == field->maxgrow)
field->status &= ~_MAY_GROW;
@@ -464,95 +635,142 @@ static bool Field_Grown(FIELD * field, int amount)
{
growth = (field->rows + field->nrow) * amount;
if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->drows,growth);
+ growth = Minimum(field->maxgrow - field->drows, growth);
field->drows += growth;
if (field->drows == field->maxgrow)
field->status &= ~_MAY_GROW;
}
/* drows, dcols changed, so we get really the new buffer length */
new_buflen = Buffer_Length(field);
- newbuf=(char *)malloc((size_t)Total_Buffer_Size(field));
+ newbuf = (FIELD_CELL *)malloc(Total_Buffer_Size(field));
if (!newbuf)
- { /* restore to previous state */
+ {
+ /* restore to previous state */
field->dcols = old_dcols;
field->drows = old_drows;
- if (( single_line_field && (field->dcols!=field->maxgrow)) ||
- (!single_line_field && (field->drows!=field->maxgrow)))
+ if ((single_line_field && (field->dcols != field->maxgrow)) ||
+ (!single_line_field && (field->drows != field->maxgrow)))
field->status |= _MAY_GROW;
- return FALSE;
}
else
- { /* Copy all the buffers. This is the reason why we can't
- just use realloc().
- */
- int i;
- char *old_bp;
- char *new_bp;
-
+ {
+ /* Copy all the buffers. This is the reason why we can't just use
+ * realloc().
+ */
+ int i, j;
+ FIELD_CELL *old_bp;
+ FIELD_CELL *new_bp;
+
+ result = TRUE; /* allow sharing of recovery on failure */
+
+ T((T_CREATE("fieldcell %p"), newbuf));
field->buf = newbuf;
- for(i=0;i<=field->nbuf;i++)
+ for (i = 0; i <= field->nbuf; i++)
{
- new_bp = Address_Of_Nth_Buffer(field,i);
- old_bp = oldbuf + i*(1+old_buflen);
- memcpy(new_bp,old_bp,(size_t)old_buflen);
- if (new_buflen > old_buflen)
- memset(new_bp + old_buflen,C_BLANK,
- (size_t)(new_buflen - old_buflen));
- *(new_bp + new_buflen) = '\0';
+ new_bp = Address_Of_Nth_Buffer(field, i);
+ old_bp = oldbuf + i * (1 + old_buflen);
+ for (j = 0; j < old_buflen; ++j)
+ new_bp[j] = old_bp[j];
+ while (j < new_buflen)
+ new_bp[j++] = myBLANK;
+ new_bp[new_buflen] = myZEROS;
}
- if (need_visual_update)
- {
- WINDOW *new_window = newpad(field->drows,field->dcols);
- if (!new_window)
- { /* restore old state */
- field->dcols = old_dcols;
- field->drows = old_drows;
- field->buf = oldbuf;
- if (( single_line_field &&
- (field->dcols!=field->maxgrow)) ||
- (!single_line_field &&
- (field->drows!=field->maxgrow)))
- field->status |= _MAY_GROW;
- free( newbuf );
- return FALSE;
+#if USE_WIDEC_SUPPORT && NCURSES_EXT_FUNCS
+ if (wresize(field->working, 1, Buffer_Length(field) + 1) == ERR)
+ result = FALSE;
+#endif
+
+ if (need_visual_update && result)
+ {
+ WINDOW *new_window = newpad(field->drows, field->dcols);
+
+ if (new_window != 0)
+ {
+ assert(form != (FORM *)0);
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+ Set_Field_Window_Attributes(field, form->w);
+ werase(form->w);
+ Buffer_To_Window(field, form->w);
+ untouchwin(form->w);
+ wmove(form->w, form->currow, form->curcol);
}
- assert(form!=(FORM *)0);
- delwin(form->w);
- form->w = new_window;
- Set_Field_Window_Attributes(field,form->w);
- werase(form->w);
- Buffer_To_Window(field,form->w);
- untouchwin(form->w);
- wmove(form->w,form->currow,form->curcol);
+ else
+ result = FALSE;
}
- free(oldbuf);
- /* reflect changes in linked fields */
- if (field != field->link)
+ if (result)
{
- FIELD *linked_field;
- for(linked_field = field->link;
- linked_field!= field;
- linked_field = linked_field->link)
+ free(oldbuf);
+ /* reflect changes in linked fields */
+ if (field != field->link)
{
- linked_field->buf = field->buf;
- linked_field->drows = field->drows;
- linked_field->dcols = field->dcols;
+ FIELD *linked_field;
+
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
+ {
+ linked_field->buf = field->buf;
+ linked_field->drows = field->drows;
+ linked_field->dcols = field->dcols;
+ }
}
}
- result = TRUE;
- }
+ else
+ {
+ /* restore old state */
+ field->dcols = old_dcols;
+ field->drows = old_drows;
+ field->buf = oldbuf;
+ if ((single_line_field &&
+ (field->dcols != field->maxgrow)) ||
+ (!single_line_field &&
+ (field->drows != field->maxgrow)))
+ field->status |= _MAY_GROW;
+ free(newbuf);
+ }
+ }
}
- return(result);
+ return (result);
}
+#ifdef NCURSES_MOUSE_VERSION
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
+| Function : int Field_encloses(FIELD *field, int ry, int rx)
+|
+| Description : Check if the given coordinates lie within the given field.
+|
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form pointer
+| E_SYSTEM_ERROR - form has no current field or
+| field-window
++--------------------------------------------------------------------------*/
+static int
+Field_encloses(FIELD *field, int ry, int rx)
+{
+ T((T_CALLED("Field_encloses(%p)"), field));
+ if (field != 0
+ && field->frow <= ry
+ && (field->frow + field->rows) > ry
+ && field->fcol <= rx
+ && (field->fcol + field->cols) > rx)
+ {
+ RETURN(E_OK);
+ }
+ RETURN(E_INVALID_FIELD);
+}
+#endif
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
| Function : int _nc_Position_Form_Cursor(FORM * form)
-|
+|
| Description : Position the cursor in the window for the current
-| field to be in sync. with the currow and curcol
+| field to be in sync. with the currow and curcol
| values.
|
| Return Values : E_OK - success
@@ -561,39 +779,39 @@ static bool Field_Grown(FIELD * field, int amount)
| field-window
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Position_Form_Cursor (FORM * form)
+_nc_Position_Form_Cursor(FORM *form)
{
- FIELD *field;
+ FIELD *field;
WINDOW *formwin;
-
+
if (!form)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
- if (!form->w || !form->current)
- return(E_SYSTEM_ERROR);
+ if (!form->w || !form->current)
+ return (E_SYSTEM_ERROR);
- field = form->current;
- formwin = Get_Form_Window(form);
+ field = form->current;
+ formwin = Get_Form_Window(form);
- wmove( form->w, form->currow, form->curcol );
- if ( Has_Invisible_Parts(field) )
+ wmove(form->w, form->currow, form->curcol);
+ if (Has_Invisible_Parts(field))
{
/* in this case fieldwin isn't derived from formwin, so we have
- to move the cursor in formwin by hand... */
+ to move the cursor in formwin by hand... */
wmove(formwin,
field->frow + form->currow - form->toprow,
field->fcol + form->curcol - form->begincol);
wcursyncup(formwin);
}
- else
+ else
wcursyncup(form->w);
- return(E_OK);
+ return (E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Refresh_Current_Field(FORM * form)
-|
+|
| Description : Propagate the changes in the fields window to the
| window of the form.
|
@@ -602,19 +820,21 @@ _nc_Position_Form_Cursor (FORM * form)
| E_SYSTEM_ERROR - general error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Refresh_Current_Field (FORM * form)
+_nc_Refresh_Current_Field(FORM *form)
{
WINDOW *formwin;
- FIELD *field;
+ FIELD *field;
+
+ T((T_CALLED("_nc_Refresh_Current_Field(%p)"), form));
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (!form->w || !form->current)
+ if (!form->w || !form->current)
RETURN(E_SYSTEM_ERROR);
- field = form->current;
- formwin = Get_Form_Window(form);
+ field = form->current;
+ formwin = Get_Form_Window(form);
if (field->opts & O_PUBLIC)
{
@@ -623,13 +843,14 @@ _nc_Refresh_Current_Field (FORM * form)
/* Again, in this case the fieldwin isn't derived from formwin,
so we have to perform a copy operation. */
if (Single_Line_Field(field))
- { /* horizontal scrolling */
+ {
+ /* horizontal scrolling */
if (form->curcol < form->begincol)
- form->begincol = form->curcol;
+ form->begincol = form->curcol;
else
{
if (form->curcol >= (form->begincol + field->cols))
- form->begincol = form->curcol - field->cols + 1;
+ form->begincol = form->curcol - field->cols + 1;
}
copywin(form->w,
formwin,
@@ -642,8 +863,9 @@ _nc_Refresh_Current_Field (FORM * form)
0);
}
else
- { /* A multiline, i.e. vertical scrolling field */
- int row_after_bottom,first_modified_row,first_unmodified_row;
+ {
+ /* A multi-line, i.e. vertical scrolling field */
+ int row_after_bottom, first_modified_row, first_unmodified_row;
if (field->drows > field->rows)
{
@@ -659,25 +881,27 @@ _nc_Refresh_Current_Field (FORM * form)
field->status |= _NEWTOP;
}
if (field->status & _NEWTOP)
- { /* means we have to copy whole range */
+ {
+ /* means we have to copy whole range */
first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
field->status &= ~_NEWTOP;
}
- else
- { /* we try to optimize : finding the range of touched
- lines */
+ else
+ {
+ /* we try to optimize : finding the range of touched
+ lines */
first_modified_row = form->toprow;
- while(first_modified_row < row_after_bottom)
+ while (first_modified_row < row_after_bottom)
{
- if (is_linetouched(form->w,first_modified_row))
+ if (is_linetouched(form->w, first_modified_row))
break;
first_modified_row++;
}
first_unmodified_row = first_modified_row;
- while(first_unmodified_row < row_after_bottom)
+ while (first_unmodified_row < row_after_bottom)
{
- if (!is_linetouched(form->w,first_unmodified_row))
+ if (!is_linetouched(form->w, first_unmodified_row))
break;
first_unmodified_row++;
}
@@ -685,7 +909,7 @@ _nc_Refresh_Current_Field (FORM * form)
}
else
{
- first_modified_row = form->toprow;
+ first_modified_row = form->toprow;
first_unmodified_row = first_modified_row + field->rows;
}
if (first_unmodified_row != first_modified_row)
@@ -702,45 +926,47 @@ _nc_Refresh_Current_Field (FORM * form)
wsyncup(formwin);
}
else
- { /* if the field-window is simply a derived window, i.e. contains
- no invisible parts, the whole thing is trivial
- */
+ {
+ /* if the field-window is simply a derived window, i.e. contains no
+ * invisible parts, the whole thing is trivial
+ */
wsyncup(form->w);
}
}
untouchwin(form->w);
- return _nc_Position_Form_Cursor(form);
+ returnCode(_nc_Position_Form_Cursor(form));
}
-
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Perform_Justification(
| FIELD * field,
| WINDOW * win)
-|
-| Description : Output field with requested justification
+|
+| Description : Output field with requested justification
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Perform_Justification(FIELD * field, WINDOW * win)
+static void
+Perform_Justification(FIELD *field, WINDOW *win)
{
- char *bp;
+ FIELD_CELL *bp;
int len;
- int col = 0;
+ int col = 0;
- bp = Get_Start_Of_Data(field->buf,Buffer_Length(field));
- len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field)) - bp);
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
- if (len>0)
+ if (len > 0)
{
assert(win && (field->drows == 1) && (field->dcols == field->cols));
- switch(field->just)
+ switch (field->just)
{
case JUSTIFY_LEFT:
break;
case JUSTIFY_CENTER:
- col = (field->cols - len)/2;
+ col = (field->cols - len) / 2;
break;
case JUSTIFY_RIGHT:
col = field->cols - len;
@@ -749,77 +975,79 @@ static void Perform_Justification(FIELD * field, WINDOW * win)
break;
}
- wmove(win,0,col);
- waddnstr(win,bp,len);
+ wmove(win, 0, col);
+ myADDNSTR(win, bp, len);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static void Undo_Justification(
| FIELD * field,
| WINDOW * win)
-|
+|
| Description : Display field without any justification, i.e.
| left justified
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Undo_Justification(FIELD * field, WINDOW * win)
+static void
+Undo_Justification(FIELD *field, WINDOW *win)
{
- char *bp;
+ FIELD_CELL *bp;
int len;
- bp = Get_Start_Of_Data(field->buf,Buffer_Length(field));
- len = (int)(After_End_Of_Data(field->buf,Buffer_Length(field))-bp);
+ bp = Get_Start_Of_Data(field->buf, Buffer_Length(field));
+ len = (int)(After_End_Of_Data(field->buf, Buffer_Length(field)) - bp);
- if (len>0)
+ if (len > 0)
{
assert(win);
- wmove(win,0,0);
- waddnstr(win,bp,len);
+ wmove(win, 0, 0);
+ myADDNSTR(win, bp, len);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Check_Char(
| FIELDTYPE * typ,
| int ch,
| TypeArgument *argp)
-|
+|
| Description : Perform a single character check for character ch
-| according to the fieldtype instance.
+| according to the fieldtype instance.
|
| Return Values : TRUE - Character is valid
| FALSE - Character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
+static bool
+Check_Char(FIELDTYPE *typ, int ch, TypeArgument *argp)
{
- if (typ)
+ if (typ)
{
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Check_Char(typ->left ,ch,argp->left ) ||
- Check_Char(typ->right,ch,argp->right) );
- }
- else
+ return (
+ Check_Char(typ->left, ch, argp->left) ||
+ Check_Char(typ->right, ch, argp->right));
+ }
+ else
{
if (typ->ccheck)
- return typ->ccheck(ch,(void *)argp);
+ return typ->ccheck(ch, (void *)argp);
}
}
- return (isprint((unsigned char)ch) ? TRUE : FALSE);
+ return (!iscntrl(UChar(ch)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Display_Or_Erase_Field(
| FIELD * field,
| bool bEraseFlag)
-|
+|
| Description : Create a subwindow for the field and display the
| buffer contents (apply justification if required)
| or simply erase the field.
@@ -827,7 +1055,8 @@ static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp)
| Return Values : E_OK - on success
| E_SYSTEM_ERROR - some error (typical no memory)
+--------------------------------------------------------------------------*/
-static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
+static int
+Display_Or_Erase_Field(FIELD *field, bool bEraseFlag)
{
WINDOW *win;
WINDOW *fwin;
@@ -836,17 +1065,17 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
return E_SYSTEM_ERROR;
fwin = Get_Form_Window(field->form);
- win = derwin(fwin,
- field->rows,field->cols,field->frow,field->fcol);
+ win = derwin(fwin,
+ field->rows, field->cols, field->frow, field->fcol);
- if (!win)
+ if (!win)
return E_SYSTEM_ERROR;
else
{
if (field->opts & O_VISIBLE)
- Set_Field_Window_Attributes(field,win);
+ Set_Field_Window_Attributes(field, win);
else
- wattrset(win,getattrs(fwin));
+ wattrset(win, WINDOW_ATTRS(fwin));
werase(win);
}
@@ -855,9 +1084,9 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
if (field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
- Perform_Justification(field,win);
+ Perform_Justification(field, win);
else
- Buffer_To_Window(field,win);
+ Buffer_To_Window(field, win);
}
field->status &= ~_NEWTOP;
}
@@ -871,176 +1100,186 @@ static int Display_Or_Erase_Field(FIELD * field, bool bEraseFlag)
#define Erase_Field(field) Display_Or_Erase_Field(field,TRUE)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Synchronize_Field(FIELD * field)
-|
+|
| Description : Synchronize the windows content with the value in
| the buffer.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
-static int Synchronize_Field(FIELD * field)
+static int
+Synchronize_Field(FIELD *field)
{
FORM *form;
int res = E_OK;
if (!field)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
- if (((form=field->form) != (FORM *)0)
+ if (((form = field->form) != (FORM *)0)
&& Field_Really_Appears(field))
{
if (field == form->current)
- {
- form->currow = form->curcol = form->toprow = form->begincol = 0;
+ {
+ form->currow = form->curcol = form->toprow = form->begincol = 0;
werase(form->w);
-
- if ( (field->opts & O_PUBLIC) && Justification_Allowed(field) )
- Undo_Justification( field, form->w );
+
+ if ((field->opts & O_PUBLIC) && Justification_Allowed(field))
+ Undo_Justification(field, form->w);
else
- Buffer_To_Window( field, form->w );
-
+ Buffer_To_Window(field, form->w);
+
field->status |= _NEWTOP;
- res = _nc_Refresh_Current_Field( form );
+ res = _nc_Refresh_Current_Field(form);
}
else
- res = Display_Field( field );
+ res = Display_Field(field);
}
field->status |= _CHANGED;
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Synchronize_Linked_Fields(FIELD * field)
-|
+|
| Description : Propagate the Synchronize_Field function to all linked
| fields. The first error that occurs in the sequence
-| of updates is the returnvalue.
+| of updates is the return value.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
-static int Synchronize_Linked_Fields(FIELD * field)
+static int
+Synchronize_Linked_Fields(FIELD *field)
{
FIELD *linked_field;
int res = E_OK;
int syncres;
if (!field)
- return(E_BAD_ARGUMENT);
+ return (E_BAD_ARGUMENT);
if (!field->link)
- return(E_SYSTEM_ERROR);
+ return (E_SYSTEM_ERROR);
- for(linked_field = field->link;
- linked_field!= field;
- linked_field = linked_field->link )
+ for (linked_field = field->link;
+ linked_field != field;
+ linked_field = linked_field->link)
{
- if (((syncres=Synchronize_Field(linked_field)) != E_OK) &&
- (res==E_OK))
+ if (((syncres = Synchronize_Field(linked_field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Synchronize_Attributes(FIELD * field)
-|
+|
| Description : If a fields visual attributes have changed, this
| routine is called to propagate those changes to the
-| screen.
+| screen.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid field pointer
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Synchronize_Attributes (FIELD * field)
+_nc_Synchronize_Attributes(FIELD *field)
{
FORM *form;
int res = E_OK;
WINDOW *formwin;
+ T((T_CALLED("_nc_Synchronize_Attributes(%p)"), field));
+
if (!field)
- return(E_BAD_ARGUMENT);
+ returnCode(E_BAD_ARGUMENT);
- if (((form=field->form) != (FORM *)0)
+ CHECKPOS(field->form);
+ if (((form = field->form) != (FORM *)0)
&& Field_Really_Appears(field))
- {
- if (form->current==field)
+ {
+ if (form->current == field)
{
Synchronize_Buffer(form);
- Set_Field_Window_Attributes(field,form->w);
+ Set_Field_Window_Attributes(field, form->w);
werase(form->w);
+ wmove(form->w, form->currow, form->curcol);
+
if (field->opts & O_PUBLIC)
{
if (Justification_Allowed(field))
- Undo_Justification(field,form->w);
- else
- Buffer_To_Window(field,form->w);
+ Undo_Justification(field, form->w);
+ else
+ Buffer_To_Window(field, form->w);
}
- else
+ else
{
- formwin = Get_Form_Window(form);
- copywin(form->w,formwin,
- 0,0,
- field->frow,field->fcol,
- field->rows-1,field->cols-1,0);
+ formwin = Get_Form_Window(form);
+ copywin(form->w, formwin,
+ 0, 0,
+ field->frow, field->fcol,
+ field->rows - 1, field->cols - 1, 0);
wsyncup(formwin);
- Buffer_To_Window(field,form->w);
- field->status |= _NEWTOP; /* fake refresh to paint all */
+ Buffer_To_Window(field, form->w);
+ field->status |= _NEWTOP; /* fake refresh to paint all */
_nc_Refresh_Current_Field(form);
}
}
- else
+ else
{
res = Display_Field(field);
}
}
- return(res);
+ CHECKPOS(form);
+ returnCode(res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Synchronize_Options(FIELD * field,
| Field_Options newopts)
-|
+|
| Description : If a fields options have changed, this routine is
| called to propagate these changes to the screen and
-| to really change the behaviour of the field.
+| to really change the behavior of the field.
|
| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid field pointer
+| E_BAD_ARGUMENT - invalid field pointer
+| E_CURRENT - field is the current one
| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Synchronize_Options
-(FIELD *field, Field_Options newopts)
+_nc_Synchronize_Options(FIELD *field, Field_Options newopts)
{
Field_Options oldopts;
Field_Options changed_opts;
FORM *form;
int res = E_OK;
+ T((T_CALLED("_nc_Synchronize_Options(%p,%#x)"), field, newopts));
+
if (!field)
- return(E_BAD_ARGUMENT);
+ returnCode(E_BAD_ARGUMENT);
- oldopts = field->opts;
+ oldopts = field->opts;
changed_opts = oldopts ^ newopts;
- field->opts = newopts;
- form = field->form;
+ field->opts = newopts;
+ form = field->form;
if (form)
{
if (form->current == field)
{
field->opts = oldopts;
- return(E_CURRENT);
+ returnCode(E_CURRENT);
}
if (form->status & _POSTED)
@@ -1070,12 +1309,13 @@ _nc_Synchronize_Options
int res2 = E_OK;
if (newopts & O_STATIC)
- { /* the field becomes now static */
+ {
+ /* the field becomes now static */
field->status &= ~_MAY_GROW;
/* if actually we have no hidden columns, justification may
occur again */
- if (single_line_field &&
- (field->cols == field->dcols) &&
+ if (single_line_field &&
+ (field->cols == field->dcols) &&
(field->just != NO_JUSTIFICATION) &&
Field_Really_Appears(field))
{
@@ -1083,62 +1323,65 @@ _nc_Synchronize_Options
}
}
else
- { /* field is no longer static */
- if ((field->maxgrow==0) ||
- ( single_line_field && (field->dcols < field->maxgrow)) ||
+ {
+ /* field is no longer static */
+ if ((field->maxgrow == 0) ||
+ (single_line_field && (field->dcols < field->maxgrow)) ||
(!single_line_field && (field->drows < field->maxgrow)))
{
field->status |= _MAY_GROW;
- /* a field with justification now changes its behaviour,
- so we must redisplay it */
- if (single_line_field &&
+ /* a field with justification now changes its behavior,
+ so we must redisplay it */
+ if (single_line_field &&
(field->just != NO_JUSTIFICATION) &&
Field_Really_Appears(field))
{
res2 = Display_Field(field);
- }
- }
+ }
+ }
}
if (res2 != E_OK)
res = res2;
}
- return(res);
+ returnCode(res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Set_Current_Field(FORM * form,
| FIELD * newfield)
-|
+|
| Description : Make the newfield the new current field.
|
-| Return Values : E_OK - success
-| E_BAD_ARGUMENT - invalid form or field pointer
-| E_SYSTEM_ERROR - some severe basic error
+| Return Values : E_OK - success
+| E_BAD_ARGUMENT - invalid form or field pointer
+| E_SYSTEM_ERROR - some severe basic error
+| E_NOT_CONNECTED - no fields are connected to the form
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Set_Current_Field
-(FORM *form, FIELD *newfield)
+_nc_Set_Current_Field(FORM *form, FIELD *newfield)
{
- FIELD *field;
+ FIELD *field;
WINDOW *new_window;
- if (!form || !newfield || !form->current || (newfield->form!=form))
- return(E_BAD_ARGUMENT);
+ T((T_CALLED("_nc_Set_Current_Field(%p,%p)"), form, newfield));
+
+ if (!form || !newfield || !form->current || (newfield->form != form))
+ returnCode(E_BAD_ARGUMENT);
- if ( (form->status & _IN_DRIVER) )
- return(E_BAD_STATE);
+ if ((form->status & _IN_DRIVER))
+ returnCode(E_BAD_STATE);
if (!(form->field))
- return(E_NOT_CONNECTED);
+ returnCode(E_NOT_CONNECTED);
field = form->current;
-
- if ((field!=newfield) ||
+
+ if ((field != newfield) ||
!(form->status & _POSTED))
{
- if ((form->w) &&
+ if ((form->w) &&
(field->opts & O_VISIBLE) &&
(field->form->curpage == field->page))
{
@@ -1147,52 +1390,57 @@ _nc_Set_Current_Field
{
if (field->drows > field->rows)
{
- if (form->toprow==0)
+ if (form->toprow == 0)
field->status &= ~_NEWTOP;
- else
+ else
field->status |= _NEWTOP;
- }
- else
+ }
+ else
{
if (Justification_Allowed(field))
{
- Window_To_Buffer(form->w,field);
+ Window_To_Buffer(form->w, field);
werase(form->w);
- Perform_Justification(field,form->w);
+ Perform_Justification(field, form->w);
wsyncup(form->w);
}
}
}
delwin(form->w);
+ form->w = (WINDOW *)0;
}
-
+
field = newfield;
if (Has_Invisible_Parts(field))
- new_window = newpad(field->drows,field->dcols);
- else
+ new_window = newpad(field->drows, field->dcols);
+ else
new_window = derwin(Get_Form_Window(form),
- field->rows,field->cols,field->frow,field->fcol);
+ field->rows, field->cols, field->frow, field->fcol);
- if (!new_window)
- return(E_SYSTEM_ERROR);
+ if (!new_window)
+ returnCode(E_SYSTEM_ERROR);
form->current = field;
- form->w = new_window;
+
+ if (form->w)
+ delwin(form->w);
+ form->w = new_window;
+
form->status &= ~_WINDOW_MODIFIED;
- Set_Field_Window_Attributes(field,form->w);
+ Set_Field_Window_Attributes(field, form->w);
if (Has_Invisible_Parts(field))
{
werase(form->w);
- Buffer_To_Window(field,form->w);
- }
- else
+ Buffer_To_Window(field, form->w);
+ }
+ else
{
if (Justification_Allowed(field))
{
werase(form->w);
- Undo_Justification(field,form->w);
+ Undo_Justification(field, form->w);
wsyncup(form->w);
}
}
@@ -1201,417 +1449,461 @@ _nc_Set_Current_Field
}
form->currow = form->curcol = form->toprow = form->begincol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
-
+
/*----------------------------------------------------------------------------
Intra-Field Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Character(FORM * form)
-|
-| Description : Move to the next character in the field. In a multiline
+|
+| Description : Move to the next character in the field. In a multi-line
| field this wraps at the end of the line.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the rightmost position
+--------------------------------------------------------------------------*/
-static int IFN_Next_Character(FORM * form)
+static int
+IFN_Next_Character(FORM *form)
{
FIELD *field = form->current;
-
- if ((++(form->curcol))==field->dcols)
+ int step = myWCWIDTH(form->w, form->currow, form->curcol);
+
+ T((T_CALLED("IFN_Next_Character(%p)"), form));
+ if ((form->curcol += step) == field->dcols)
{
- if ((++(form->currow))==field->drows)
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1)) {
- form->curcol = 0;
- return(E_OK);
- }
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ {
+ form->curcol = 0;
+ returnCode(E_OK);
+ }
#endif
form->currow--;
#if GROW_IF_NAVIGATE
- if (Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
- form->curcol--;
- return(E_REQUEST_DENIED);
+ form->curcol -= step;
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Character(FORM * form)
-|
-| Description : Move to the previous character in the field. In a
-| multiline field this wraps and the beginning of the
+|
+| Description : Move to the previous character in the field. In a
+| multi-line field this wraps and the beginning of the
| line.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the leftmost position
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Character(FORM * form)
+static int
+IFN_Previous_Character(FORM *form)
{
- if ((--(form->curcol))<0)
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Previous_Character(%p)"), form));
+ if ((form->curcol -= amount) < 0)
{
- if ((--(form->currow))<0)
+ if ((--(form->currow)) < 0)
{
form->currow++;
- form->curcol++;
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = form->current->dcols - 1;
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Line(FORM * form)
-|
+|
| Description : Move to the beginning of the next line in the field
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the last line
+--------------------------------------------------------------------------*/
-static int IFN_Next_Line(FORM * form)
+static int
+IFN_Next_Line(FORM *form)
{
FIELD *field = form->current;
- if ((++(form->currow))==field->drows)
+ T((T_CALLED("IFN_Next_Line(%p)"), form));
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
form->currow--;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Line(FORM * form)
-|
+|
| Description : Move to the beginning of the previous line in the field
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - at the first line
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Line(FORM * form)
+static int
+IFN_Previous_Line(FORM *form)
{
- if ( (--(form->currow)) < 0 )
+ T((T_CALLED("IFN_Previous_Line(%p)"), form));
+ if ((--(form->currow)) < 0)
{
form->currow++;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
form->curcol = 0;
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Next_Word(FORM * form)
-|
+|
| Description : Move to the beginning of the next word in the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - there is no next word
+--------------------------------------------------------------------------*/
-static int IFN_Next_Word(FORM * form)
+static int
+IFN_Next_Word(FORM *form)
{
FIELD *field = form->current;
- char *bp = Address_Of_Current_Position_In_Buffer(form);
- char *s;
- char *t;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+
+ T((T_CALLED("IFN_Next_Word(%p)"), form));
/* We really need access to the data, so we have to synchronize */
Synchronize_Buffer(form);
/* Go to the first whitespace after the current position (including
- current position). This is then the startpoint to look for the
- next non-blank data */
- s = Get_First_Whitespace_Character(bp,Buffer_Length(field) -
+ current position). This is then the starting point to look for the
+ next non-blank data */
+ s = Get_First_Whitespace_Character(bp, Buffer_Length(field) -
(int)(bp - field->buf));
/* Find the start of the next word */
- t = Get_Start_Of_Data(s,Buffer_Length(field) -
+ t = Get_Start_Of_Data(s, Buffer_Length(field) -
(int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
else
#endif
{
- Adjust_Cursor_Position(form,t);
- return(E_OK);
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Previous_Word(FORM * form)
-|
+|
| Description : Move to the beginning of the previous word in the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - there is no previous word
+--------------------------------------------------------------------------*/
-static int IFN_Previous_Word(FORM * form)
+static int
+IFN_Previous_Word(FORM *form)
{
FIELD *field = form->current;
- char *bp = Address_Of_Current_Position_In_Buffer(form);
- char *s;
- char *t;
- bool again = FALSE;
+ FIELD_CELL *bp = Address_Of_Current_Position_In_Buffer(form);
+ FIELD_CELL *s;
+ FIELD_CELL *t;
+ bool again = FALSE;
+
+ T((T_CALLED("IFN_Previous_Word(%p)"), form));
/* We really need access to the data, so we have to synchronize */
Synchronize_Buffer(form);
- s = After_End_Of_Data(field->buf,(int)(bp-field->buf));
+ s = After_End_Of_Data(field->buf, (int)(bp - field->buf));
/* s points now right after the last non-blank in the buffer before bp.
If bp was in a word, s equals bp. In this case we must find the last
whitespace in the buffer before bp and repeat the game to really find
the previous word! */
- if (s==bp)
+ if (s == bp)
again = TRUE;
-
+
/* And next call now goes backward to look for the last whitespace
before that, pointing right after this, so it points to the begin
- of the previous word.
- */
- t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+ of the previous word.
+ */
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
#endif
if (again)
- { /* and do it again, replacing bp by t */
- s = After_End_Of_Data(field->buf,(int)(t - field->buf));
- t = After_Last_Whitespace_Character(field->buf,(int)(s - field->buf));
+ {
+ /* and do it again, replacing bp by t */
+ s = After_End_Of_Data(field->buf, (int)(t - field->buf));
+ t = After_Last_Whitespace_Character(field->buf, (int)(s - field->buf));
#if !FRIENDLY_PREV_NEXT_WORD
- if (s==t)
- return(E_REQUEST_DENIED);
+ if (s == t)
+ returnCode(E_REQUEST_DENIED);
#endif
}
- Adjust_Cursor_Position(form,t);
- return(E_OK);
+ Adjust_Cursor_Position(form, t);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Beginning_Of_Field(FORM * form)
-|
+|
| Description : Place the cursor at the first non-pad character in
-| the field.
+| the field.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Field(FORM * form)
+static int
+IFN_Beginning_Of_Field(FORM *form)
{
FIELD *field = form->current;
+ T((T_CALLED("IFN_Beginning_Of_Field(%p)"), form));
Synchronize_Buffer(form);
Adjust_Cursor_Position(form,
- Get_Start_Of_Data(field->buf,Buffer_Length(field)));
- return(E_OK);
+ Get_Start_Of_Data(field->buf, Buffer_Length(field)));
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_End_Of_Field(FORM * form)
-|
+|
| Description : Place the cursor after the last non-pad character in
| the field. If the field occupies the last position in
-| the buffer, the cursos is positioned on the last
+| the buffer, the cursor is positioned on the last
| character.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_End_Of_Field(FORM * form)
+static int
+IFN_End_Of_Field(FORM *form)
{
FIELD *field = form->current;
- char *pos;
+ FIELD_CELL *pos;
+ T((T_CALLED("IFN_End_Of_Field(%p)"), form));
Synchronize_Buffer(form);
- pos = After_End_Of_Data(field->buf,Buffer_Length(field));
- if (pos==(field->buf + Buffer_Length(field)))
+ pos = After_End_Of_Data(field->buf, Buffer_Length(field));
+ if (pos == (field->buf + Buffer_Length(field)))
pos--;
- Adjust_Cursor_Position(form,pos);
- return(E_OK);
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Beginning_Of_Line(FORM * form)
-|
+|
| Description : Place the cursor on the first non-pad character in
| the current line of the field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_Beginning_Of_Line(FORM * form)
+static int
+IFN_Beginning_Of_Line(FORM *form)
{
FIELD *field = form->current;
+ T((T_CALLED("IFN_Beginning_Of_Line(%p)"), form));
Synchronize_Buffer(form);
Adjust_Cursor_Position(form,
- Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
- field->dcols));
- return(E_OK);
+ Get_Start_Of_Data(Address_Of_Current_Row_In_Buffer(form),
+ field->dcols));
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_End_Of_Line(FORM * form)
-|
+|
| Description : Place the cursor after the last non-pad character in the
-| current line of the field. If the field occupies the
+| current line of the field. If the field occupies the
| last column in the line, the cursor is positioned on the
| last character of the line.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int IFN_End_Of_Line(FORM * form)
+static int
+IFN_End_Of_Line(FORM *form)
{
FIELD *field = form->current;
- char *pos;
- char *bp;
+ FIELD_CELL *pos;
+ FIELD_CELL *bp;
+ T((T_CALLED("IFN_End_Of_Line(%p)"), form));
Synchronize_Buffer(form);
- bp = Address_Of_Current_Row_In_Buffer(form);
- pos = After_End_Of_Data(bp,field->dcols);
+ bp = Address_Of_Current_Row_In_Buffer(form);
+ pos = After_End_Of_Data(bp, field->dcols);
if (pos == (bp + field->dcols))
pos--;
- Adjust_Cursor_Position(form,pos);
- return(E_OK);
+ Adjust_Cursor_Position(form, pos);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Left_Character(FORM * form)
-|
+|
| Description : Move one character to the left in the current line.
-| This doesn't cycle.
+| This doesn't cycle.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in first column
+--------------------------------------------------------------------------*/
-static int IFN_Left_Character(FORM * form)
+static int
+IFN_Left_Character(FORM *form)
{
- if ( (--(form->curcol)) < 0 )
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol - 1);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Left_Character(%p)"), form));
+ if ((form->curcol -= amount) < 0)
{
- form->curcol++;
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Right_Character(FORM * form)
-|
+|
| Description : Move one character to the right in the current line.
| This doesn't cycle.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Right_Character(FORM * form)
+static int
+IFN_Right_Character(FORM *form)
{
- if ( (++(form->curcol)) == form->current->dcols )
+ int amount = myWCWIDTH(form->w, form->currow, form->curcol);
+ int oldcol = form->curcol;
+
+ T((T_CALLED("IFN_Right_Character(%p)"), form));
+ if ((form->curcol += amount) >= form->current->dcols)
{
#if GROW_IF_NAVIGATE
FIELD *field = form->current;
- if (Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+
+ if (Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
- --(form->curcol);
- return(E_REQUEST_DENIED);
+ form->curcol = oldcol;
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Up_Character(FORM * form)
-|
+|
| Description : Move one line up. This doesn't cycle through the lines
| of the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Up_Character(FORM * form)
+static int
+IFN_Up_Character(FORM *form)
{
- if ( (--(form->currow)) < 0 )
+ T((T_CALLED("IFN_Up_Character(%p)"), form));
+ if ((--(form->currow)) < 0)
{
form->currow++;
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int IFN_Down_Character(FORM * form)
-|
+|
| Description : Move one line down. This doesn't cycle through the
| lines of the field.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - already in last column
+--------------------------------------------------------------------------*/
-static int IFN_Down_Character(FORM * form)
+static int
+IFN_Down_Character(FORM *form)
{
FIELD *field = form->current;
- if ( (++(form->currow)) == field->drows )
+ T((T_CALLED("IFN_Down_Character(%p)"), form));
+ if ((++(form->currow)) == field->drows)
{
#if GROW_IF_NAVIGATE
- if (!Single_Line_Field(field) && Field_Grown(field,1))
- return(E_OK);
+ if (!Single_Line_Field(field) && Field_Grown(field, 1))
+ returnCode(E_OK);
#endif
--(form->currow);
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
}
- return(E_OK);
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Intra-Field Navigation routines
+ END of Intra-Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Vertical scrolling helper routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int VSC_Generic(FORM *form, int lines)
+| Facility : libnform
+| Function : static int VSC_Generic(FORM *form, int nlines)
|
-| Description : Scroll multi-line field forward (lines>0) or
-| backward (lines<0) this many lines.
+| Description : Scroll multi-line field forward (nlines>0) or
+| backward (nlines<0) this many lines.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED - can't scroll
+--------------------------------------------------------------------------*/
-static int VSC_Generic(FORM *form, int lines)
+static int
+VSC_Generic(FORM *form, int nlines)
{
FIELD *field = form->current;
int res = E_REQUEST_DENIED;
- int rows_to_go = (lines > 0 ? lines : -lines);
+ int rows_to_go = (nlines > 0 ? nlines : -nlines);
- if (lines > 0)
+ if (nlines > 0)
{
- if ( (rows_to_go + form->toprow) > (field->drows - field->rows) )
+ if ((rows_to_go + form->toprow) > (field->drows - field->rows))
rows_to_go = (field->drows - field->rows - form->toprow);
if (rows_to_go > 0)
@@ -1625,7 +1917,7 @@ static int VSC_Generic(FORM *form, int lines)
{
if (rows_to_go > form->toprow)
rows_to_go = form->toprow;
-
+
if (rows_to_go > 0)
{
form->currow -= rows_to_go;
@@ -1633,29 +1925,30 @@ static int VSC_Generic(FORM *form, int lines)
res = E_OK;
}
}
- return(res);
+ return (res);
}
/*----------------------------------------------------------------------------
End of Vertical scrolling helper routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Vertical scrolling routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Vertical_Scrolling(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Performs the generic vertical scrolling routines.
+|
+| Description : Performs the generic vertical scrolling routines.
| This has to check for a multi-line field and to set
-| the _NEWTOP flag if scrolling really occured.
+| the _NEWTOP flag if scrolling really occurred.
|
| Return Values : Propagated error code from low-level driver calls
+--------------------------------------------------------------------------*/
-static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Vertical_Scrolling(int (*const fct) (FORM *), FORM *form)
{
int res = E_REQUEST_DENIED;
@@ -1665,299 +1958,327 @@ static int Vertical_Scrolling(int (* const fct) (FORM *), FORM * form)
if (res == E_OK)
form->current->status |= _NEWTOP;
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Line_Forward(FORM * form)
-|
+|
| Description : Scroll multi-line field forward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Forward(FORM * form)
+static int
+VSC_Scroll_Line_Forward(FORM *form)
{
- return VSC_Generic(form,1);
+ T((T_CALLED("VSC_Scroll_Line_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, 1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Line_Backward(FORM * form)
-|
+|
| Description : Scroll multi-line field backward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Line_Backward(FORM * form)
+static int
+VSC_Scroll_Line_Backward(FORM *form)
{
- return VSC_Generic(form,-1);
+ T((T_CALLED("VSC_Scroll_Line_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Page_Forward(FORM * form)
-|
+|
| Description : Scroll a multi-line field forward a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Page_Forward(FORM *form)
{
- return VSC_Generic(form,form->current->rows);
+ T((T_CALLED("VSC_Scroll_Page_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, form->current->rows));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Half_Page_Forward(FORM * form)
-|
+|
| Description : Scroll a multi-line field forward half a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Forward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Forward(FORM *form)
{
- return VSC_Generic(form,(form->current->rows + 1)/2);
+ T((T_CALLED("VSC_Scroll_Half_Page_Forward(%p)"), form));
+ returnCode(VSC_Generic(form, (form->current->rows + 1) / 2));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Page_Backward(FORM * form)
-|
+|
| Description : Scroll a multi-line field backward a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Page_Backward(FORM *form)
{
- return VSC_Generic(form, -(form->current->rows));
+ T((T_CALLED("VSC_Scroll_Page_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -(form->current->rows)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int VSC_Scroll_Half_Page_Backward(FORM * form)
-|
+|
| Description : Scroll a multi-line field backward half a page
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int VSC_Scroll_Half_Page_Backward(FORM * form)
+static int
+VSC_Scroll_Half_Page_Backward(FORM *form)
{
- return VSC_Generic(form, -((form->current->rows + 1)/2));
+ T((T_CALLED("VSC_Scroll_Half_Page_Backward(%p)"), form));
+ returnCode(VSC_Generic(form, -((form->current->rows + 1) / 2)));
}
/*----------------------------------------------------------------------------
End of Vertical scrolling routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Horizontal scrolling helper routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int HSC_Generic(FORM *form, int columns)
+| Facility : libnform
+| Function : static int HSC_Generic(FORM *form, int ncolumns)
|
-| Description : Scroll single-line field forward (columns>0) or
-| backward (columns<0) this many columns.
+| Description : Scroll single-line field forward (ncolumns>0) or
+| backward (ncolumns<0) this many columns.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED - can't scroll
+--------------------------------------------------------------------------*/
-static int HSC_Generic(FORM *form, int columns)
+static int
+HSC_Generic(FORM *form, int ncolumns)
{
FIELD *field = form->current;
int res = E_REQUEST_DENIED;
- int cols_to_go = (columns > 0 ? columns : -columns);
+ int cols_to_go = (ncolumns > 0 ? ncolumns : -ncolumns);
- if (columns > 0)
+ if (ncolumns > 0)
{
if ((cols_to_go + form->begincol) > (field->dcols - field->cols))
cols_to_go = field->dcols - field->cols - form->begincol;
-
+
if (cols_to_go > 0)
{
- form->curcol += cols_to_go;
+ form->curcol += cols_to_go;
form->begincol += cols_to_go;
res = E_OK;
}
}
else
{
- if ( cols_to_go > form->begincol )
+ if (cols_to_go > form->begincol)
cols_to_go = form->begincol;
if (cols_to_go > 0)
{
- form->curcol -= cols_to_go;
+ form->curcol -= cols_to_go;
form->begincol -= cols_to_go;
res = E_OK;
}
}
- return(res);
+ return (res);
}
/*----------------------------------------------------------------------------
End of Horizontal scrolling helper routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Horizontal scrolling routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Horizontal_Scrolling(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Performs the generic horizontal scrolling routines.
+|
+| Description : Performs the generic horizontal scrolling routines.
| This has to check for a single-line field.
|
| Return Values : Propagated error code from low-level driver calls
+--------------------------------------------------------------------------*/
-static int Horizontal_Scrolling(int (* const fct) (FORM *), FORM * form)
+static int
+Horizontal_Scrolling(int (*const fct) (FORM *), FORM *form)
{
if (Single_Line_Field(form->current))
return fct(form);
else
- return(E_REQUEST_DENIED);
+ return (E_REQUEST_DENIED);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Scroll_Char_Forward(FORM * form)
-|
+|
| Description : Scroll single-line field forward a character
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Forward(FORM *form)
+static int
+HSC_Scroll_Char_Forward(FORM *form)
{
- return HSC_Generic(form,1);
+ T((T_CALLED("HSC_Scroll_Char_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, 1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Scroll_Char_Backward(FORM * form)
-|
+|
| Description : Scroll single-line field backward a character
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Scroll_Char_Backward(FORM *form)
+static int
+HSC_Scroll_Char_Backward(FORM *form)
{
- return HSC_Generic(form,-1);
+ T((T_CALLED("HSC_Scroll_Char_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -1));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Line_Forward(FORM* form)
-|
+|
| Description : Scroll single-line field forward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Line_Forward(FORM *form)
{
- return HSC_Generic(form,form->current->cols);
+ T((T_CALLED("HSC_Horizontal_Line_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, form->current->cols));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Half_Line_Forward(FORM* form)
-|
+|
| Description : Scroll single-line field forward half a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data ahead
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Forward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Forward(FORM *form)
{
- return HSC_Generic(form,(form->current->cols + 1)/2);
+ T((T_CALLED("HSC_Horizontal_Half_Line_Forward(%p)"), form));
+ returnCode(HSC_Generic(form, (form->current->cols + 1) / 2));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Line_Backward(FORM* form)
-|
+|
| Description : Scroll single-line field backward a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Line_Backward(FORM *form)
{
- return HSC_Generic(form,-(form->current->cols));
+ T((T_CALLED("HSC_Horizontal_Line_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -(form->current->cols)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int HSC_Horizontal_Half_Line_Backward(FORM* form)
-|
+|
| Description : Scroll single-line field backward half a line
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - no data behind
+--------------------------------------------------------------------------*/
-static int HSC_Horizontal_Half_Line_Backward(FORM * form)
+static int
+HSC_Horizontal_Half_Line_Backward(FORM *form)
{
- return HSC_Generic(form,-((form->current->cols + 1)/2));
+ T((T_CALLED("HSC_Horizontal_Half_Line_Backward(%p)"), form));
+ returnCode(HSC_Generic(form, -((form->current->cols + 1) / 2)));
}
/*----------------------------------------------------------------------------
End of Horizontal scrolling routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Field Editing
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Is_There_Room_For_A_Line(FORM * form)
-|
+|
| Description : Check whether or not there is enough room in the
| buffer to enter a whole line.
|
| Return Values : TRUE - there is enough space
| FALSE - there is not enough space
+--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Line(FORM * form)
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Line(FORM *form)
{
FIELD *field = form->current;
- char *begin_of_last_line, *s;
-
+ FIELD_CELL *begin_of_last_line, *s;
+
Synchronize_Buffer(form);
- begin_of_last_line = Address_Of_Row_In_Buffer(field,(field->drows-1));
- s = After_End_Of_Data(begin_of_last_line,field->dcols);
- return ((s==begin_of_last_line) ? TRUE : FALSE);
+ begin_of_last_line = Address_Of_Row_In_Buffer(field, (field->drows - 1));
+ s = After_End_Of_Data(begin_of_last_line, field->dcols);
+ return ((s == begin_of_last_line) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
-|
+|
| Description : Checks whether or not there is room for a new character
| in the current line.
|
| Return Values : TRUE - there is room
| FALSE - there is not enough room (line full)
+--------------------------------------------------------------------------*/
-INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
+NCURSES_INLINE static bool
+Is_There_Room_For_A_Char_In_Line(FORM *form)
{
int last_char_in_line;
- wmove(form->w,form->currow,form->current->dcols-1);
- last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
- wmove(form->w,form->currow,form->curcol);
+ wmove(form->w, form->currow, form->current->dcols - 1);
+ last_char_in_line = (int)(winch(form->w) & A_CHARTEXT);
+ wmove(form->w, form->currow, form->curcol);
return (((last_char_in_line == form->current->pad) ||
is_blank(last_char_in_line)) ? TRUE : FALSE);
}
@@ -1966,85 +2287,90 @@ INLINE static bool Is_There_Room_For_A_Char_In_Line(FORM * form)
!Is_There_Room_For_A_Char_In_Line(f)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Insert_String(
| FORM * form,
| int row,
| char *txt,
| int len )
-|
+|
| Description : Insert the 'len' characters beginning at pointer 'txt'
| into the 'row' of the 'form'. The insertion occurs
| on the beginning of the row, all other characters are
-| moved to the right. After the text a pad character will
+| moved to the right. After the text a pad character will
| be inserted to separate the text from the rest. If
| necessary the insertion moves characters on the next
| line to make place for the requested insertion string.
|
-| Return Values : E_OK - success
+| Return Values : E_OK - success
| E_REQUEST_DENIED -
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-static int Insert_String(FORM *form, int row, char *txt, int len)
-{
- FIELD *field = form->current;
- char *bp = Address_Of_Row_In_Buffer(field,row);
- int datalen = (int)(After_End_Of_Data(bp,field->dcols) - bp);
- int freelen = field->dcols - datalen;
- int requiredlen = len+1;
- char *split;
+static int
+Insert_String(FORM *form, int row, FIELD_CELL *txt, int len)
+{
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Row_In_Buffer(field, row);
+ int datalen = (int)(After_End_Of_Data(bp, field->dcols) - bp);
+ int freelen = field->dcols - datalen;
+ int requiredlen = len + 1;
+ FIELD_CELL *split;
int result = E_REQUEST_DENIED;
- const char *Space = " ";
if (freelen >= requiredlen)
{
- wmove(form->w,row,0);
- winsnstr(form->w,txt,len);
- wmove(form->w,row,len);
- winsnstr(form->w,Space,1);
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
return E_OK;
}
else
- { /* we have to move characters on the next line. If we are on the
- last line this may work, if the field is growable */
+ {
+ /* we have to move characters on the next line. If we are on the
+ last line this may work, if the field is growable */
if ((row == (field->drows - 1)) && Growable(field))
{
- if (!Field_Grown(field,1))
- return(E_SYSTEM_ERROR);
+ if (!Field_Grown(field, 1))
+ return (E_SYSTEM_ERROR);
/* !!!Side-Effect : might be changed due to growth!!! */
- bp = Address_Of_Row_In_Buffer(field,row);
+ bp = Address_Of_Row_In_Buffer(field, row);
}
- if (row < (field->drows - 1))
- {
- split = After_Last_Whitespace_Character(bp,
- (int)(Get_Start_Of_Data(bp + field->dcols - requiredlen ,
- requiredlen) - bp));
+ if (row < (field->drows - 1))
+ {
+ split =
+ After_Last_Whitespace_Character(bp,
+ (int)(Get_Start_Of_Data(bp
+ + field->dcols
+ - requiredlen,
+ requiredlen)
+ - bp));
/* split points now to the first character of the portion of the
line that must be moved to the next line */
- datalen = (int)(split-bp); /* + freelen has to stay on this line */
- freelen = field->dcols - (datalen + freelen); /* for the next line */
+ datalen = (int)(split - bp); /* + freelen has to stay on this line */
+ freelen = field->dcols - (datalen + freelen); /* for the next line */
- if ((result=Insert_String(form,row+1,split,freelen))==E_OK)
+ if ((result = Insert_String(form, row + 1, split, freelen)) == E_OK)
{
- wmove(form->w,row,datalen);
+ wmove(form->w, row, datalen);
wclrtoeol(form->w);
- wmove(form->w,row,0);
- winsnstr(form->w,txt,len);
- wmove(form->w,row,len);
- winsnstr(form->w,Space,1);
+ wmove(form->w, row, 0);
+ myINSNSTR(form->w, txt, len);
+ wmove(form->w, row, len);
+ myINSNSTR(form->w, &myBLANK, 1);
return E_OK;
}
}
- return(result);
+ return (result);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Wrapping_Not_Necessary_Or_Wrapping_Ok(
| FORM * form)
-|
+|
| Description : If a character has been entered into a field, it may
| be that wrapping has to occur. This routine checks
| whether or not wrapping is required and if so, performs
@@ -2055,40 +2381,43 @@ static int Insert_String(FORM *form, int row, char *txt, int len)
| E_REQUEST_DENIED -
| E_SYSTEM_ERROR - some system error
+--------------------------------------------------------------------------*/
-static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
+static int
+Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM *form)
{
- FIELD *field = form->current;
+ FIELD *field = form->current;
int result = E_REQUEST_DENIED;
bool Last_Row = ((field->drows - 1) == form->currow);
- if ( (field->opts & O_WRAP) && /* wrapping wanted */
- (!Single_Line_Field(field)) && /* must be multi-line */
- (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
- (!Last_Row || Growable(field)) ) /* there are more lines*/
+ if ((field->opts & O_WRAP) && /* wrapping wanted */
+ (!Single_Line_Field(field)) && /* must be multi-line */
+ (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */
+ (!Last_Row || Growable(field))) /* there are more lines */
{
- char *bp;
- char *split;
+ FIELD_CELL *bp;
+ FIELD_CELL *split;
int chars_to_be_wrapped;
int chars_to_remain_on_line;
+
if (Last_Row)
- { /* the above logic already ensures, that in this case the field
+ {
+ /* the above logic already ensures, that in this case the field
is growable */
- if (!Field_Grown(field,1))
+ if (!Field_Grown(field, 1))
return E_SYSTEM_ERROR;
}
bp = Address_Of_Current_Row_In_Buffer(form);
- Window_To_Buffer(form->w,field);
- split = After_Last_Whitespace_Character(bp,field->dcols);
+ Window_To_Buffer(form->w, field);
+ split = After_Last_Whitespace_Character(bp, field->dcols);
/* split points to the first character of the sequence to be brought
on the next line */
chars_to_remain_on_line = (int)(split - bp);
- chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
+ chars_to_be_wrapped = field->dcols - chars_to_remain_on_line;
if (chars_to_remain_on_line > 0)
{
- if ((result=Insert_String(form,form->currow+1,split,
- chars_to_be_wrapped)) == E_OK)
+ if ((result = Insert_String(form, form->currow + 1, split,
+ chars_to_be_wrapped)) == E_OK)
{
- wmove(form->w,form->currow,chars_to_remain_on_line);
+ wmove(form->w, form->currow, chars_to_remain_on_line);
wclrtoeol(form->w);
if (form->curcol >= chars_to_remain_on_line)
{
@@ -2100,61 +2429,61 @@ static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form)
}
else
return E_OK;
- if (result!=E_OK)
+ if (result != E_OK)
{
- wmove(form->w,form->currow,form->curcol);
- wdelch(form->w);
- Window_To_Buffer(form->w,field);
+ DeleteChar(form);
+ Window_To_Buffer(form->w, field);
result = E_REQUEST_DENIED;
}
}
else
- result = E_OK; /* wrapping was not necessary */
- return(result);
+ result = E_OK; /* wrapping was not necessary */
+ return (result);
}
-
+
/*----------------------------------------------------------------------------
Field Editing routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Field_Editing(
| int (* const fct) (FORM *),
| FORM * form)
-|
+|
| Description : Generic routine for field editing requests. The driver
| routines are only called for editable fields, the
-| _WINDOW_MODIFIED flag is set if editing occured.
+| _WINDOW_MODIFIED flag is set if editing occurred.
| This is somewhat special due to the overload semantics
| of the NEW_LINE and DEL_PREV requests.
|
| Return Values : Error code from low level drivers.
+--------------------------------------------------------------------------*/
-static int Field_Editing(int (* const fct) (FORM *), FORM * form)
+static int
+Field_Editing(int (*const fct) (FORM *), FORM *form)
{
int res = E_REQUEST_DENIED;
- /* We have to deal here with the specific case of the overloaded
- behaviour of New_Line and Delete_Previous requests.
+ /* We have to deal here with the specific case of the overloaded
+ behavior of New_Line and Delete_Previous requests.
They may end up in navigational requests if we are on the first
character in a field. But navigation is also allowed on non-
editable fields.
- */
- if ((fct==FE_Delete_Previous) &&
- (form->opts & O_BS_OVERLOAD) &&
- First_Position_In_Current_Field(form) )
+ */
+ if ((fct == FE_Delete_Previous) &&
+ (form->opts & O_BS_OVERLOAD) &&
+ First_Position_In_Current_Field(form))
{
- res = Inter_Field_Navigation(FN_Previous_Field,form);
+ res = Inter_Field_Navigation(FN_Previous_Field, form);
}
else
{
- if (fct==FE_New_Line)
+ if (fct == FE_New_Line)
{
- if ((form->opts & O_NL_OVERLOAD) &&
+ if ((form->opts & O_NL_OVERLOAD) &&
First_Position_In_Current_Field(form))
{
- res = Inter_Field_Navigation(FN_Next_Field,form);
+ res = Inter_Field_Navigation(FN_Next_Field, form);
}
else
/* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
@@ -2166,7 +2495,7 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
if (form->current->opts & O_EDIT)
{
res = fct(form);
- if (res==E_OK)
+ if (res == E_OK)
form->status |= _WINDOW_MODIFIED;
}
}
@@ -2175,11 +2504,11 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_New_Line(FORM * form)
-|
+|
| Description : Perform a new line request. This is rather complex
-| compared to other routines in this code due to the
+| compared to other routines in this code due to the
| rather difficult to understand description in the
| manuals.
|
@@ -2187,130 +2516,141 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
| E_REQUEST_DENIED - new line not allowed
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
-static int FE_New_Line(FORM * form)
+static int
+FE_New_Line(FORM *form)
{
- FIELD *field = form->current;
- char *bp, *t;
- bool Last_Row = ((field->drows - 1)==form->currow);
-
- if (form->status & _OVLMODE)
+ FIELD *field = form->current;
+ FIELD_CELL *bp, *t;
+ bool Last_Row = ((field->drows - 1) == form->currow);
+
+ T((T_CALLED("FE_New_Line(%p)"), form));
+ if (form->status & _OVLMODE)
{
- if (Last_Row &&
+ if (Last_Row &&
(!(Growable(field) && !Single_Line_Field(field))))
{
if (!(form->opts & O_NL_OVERLOAD))
- return(E_REQUEST_DENIED);
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
/* we have to set this here, although it is also
handled in the generic routine. The reason is,
that FN_Next_Field may fail, but the form is
definitively changed */
form->status |= _WINDOW_MODIFIED;
- return Inter_Field_Navigation(FN_Next_Field,form);
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
- else
+ else
{
- if (Last_Row && !Field_Grown(field,1))
- { /* N.B.: due to the logic in the 'if', LastRow==TRUE
- means here that the field is growable and not
- a single-line field */
- return(E_SYSTEM_ERROR);
+ if (Last_Row && !Field_Grown(field, 1))
+ {
+ /* N.B.: due to the logic in the 'if', LastRow==TRUE
+ means here that the field is growable and not
+ a single-line field */
+ returnCode(E_SYSTEM_ERROR);
}
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
form->currow++;
form->curcol = 0;
form->status |= _WINDOW_MODIFIED;
- return(E_OK);
+ returnCode(E_OK);
}
}
- else
- { /* Insert Mode */
+ else
+ {
+ /* Insert Mode */
if (Last_Row &&
!(Growable(field) && !Single_Line_Field(field)))
{
if (!(form->opts & O_NL_OVERLOAD))
- return(E_REQUEST_DENIED);
- return Inter_Field_Navigation(FN_Next_Field,form);
+ returnCode(E_REQUEST_DENIED);
+ returnCode(Inter_Field_Navigation(FN_Next_Field, form));
}
- else
+ else
{
bool May_Do_It = !Last_Row && Is_There_Room_For_A_Line(form);
-
+
if (!(May_Do_It || Growable(field)))
- return(E_REQUEST_DENIED);
- if (!May_Do_It && !Field_Grown(field,1))
- return(E_SYSTEM_ERROR);
-
- bp= Address_Of_Current_Position_In_Buffer(form);
- t = After_End_Of_Data(bp,field->dcols - form->curcol);
+ returnCode(E_REQUEST_DENIED);
+ if (!May_Do_It && !Field_Grown(field, 1))
+ returnCode(E_SYSTEM_ERROR);
+
+ bp = Address_Of_Current_Position_In_Buffer(form);
+ t = After_End_Of_Data(bp, field->dcols - form->curcol);
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
form->currow++;
- form->curcol=0;
- wmove(form->w,form->currow,form->curcol);
+ form->curcol = 0;
+ wmove(form->w, form->currow, form->curcol);
winsertln(form->w);
- waddnstr(form->w,bp,(int)(t-bp));
+ myADDNSTR(form->w, bp, (int)(t - bp));
form->status |= _WINDOW_MODIFIED;
- return E_OK;
+ returnCode(E_OK);
}
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Insert_Character(FORM * form)
-|
+|
| Description : Insert blank character at the cursor position
|
| Return Values : E_OK
| E_REQUEST_DENIED
+--------------------------------------------------------------------------*/
-static int FE_Insert_Character(FORM * form)
+static int
+FE_Insert_Character(FORM *form)
{
FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+ T((T_CALLED("FE_Insert_Character(%p)"), form));
+ if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
{
bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
if (There_Is_Room ||
((Single_Line_Field(field) && Growable(field))))
{
- if (!There_Is_Room && !Field_Grown(field,1))
- result = E_SYSTEM_ERROR;
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ result = E_SYSTEM_ERROR;
else
{
- winsch(form->w,(chtype)C_BLANK);
+ winsch(form->w, (chtype)C_BLANK);
result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form);
}
}
}
- return result;
+ returnCode(result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Insert_Line(FORM * form)
-|
+|
| Description : Insert a blank line at the cursor position
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - line can not be inserted
+--------------------------------------------------------------------------*/
-static int FE_Insert_Line(FORM * form)
+static int
+FE_Insert_Line(FORM *form)
{
FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if (Check_Char(field->type,(int)C_BLANK,(TypeArgument *)(field->arg)))
+ T((T_CALLED("FE_Insert_Line(%p)"), form));
+ if (Check_Char(field->type, (int)C_BLANK, (TypeArgument *)(field->arg)))
{
- bool Maybe_Done = (form->currow!=(field->drows-1)) &&
- Is_There_Room_For_A_Line(form);
+ bool Maybe_Done = (form->currow != (field->drows - 1)) &&
+ Is_There_Room_For_A_Line(form);
if (!Single_Line_Field(field) &&
(Maybe_Done || Growable(field)))
{
- if (!Maybe_Done && !Field_Grown(field,1))
+ if (!Maybe_Done && !Field_Grown(field, 1))
result = E_SYSTEM_ERROR;
else
{
@@ -2320,27 +2660,29 @@ static int FE_Insert_Line(FORM * form)
}
}
}
- return result;
+ returnCode(result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Character(FORM * form)
-|
+|
| Description : Delete character at the cursor position
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Delete_Character(FORM * form)
+static int
+FE_Delete_Character(FORM *form)
{
- wdelch(form->w);
- return E_OK;
+ T((T_CALLED("FE_Delete_Character(%p)"), form));
+ DeleteChar(form);
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Previous(FORM * form)
-|
+|
| Description : Delete character before cursor. Again this is a rather
| difficult piece compared to others due to the overloading
| semantics of backspace.
@@ -2350,301 +2692,353 @@ static int FE_Delete_Character(FORM * form)
| Return Values : E_OK - success
| E_REQUEST_DENIED - Character can't be deleted
+--------------------------------------------------------------------------*/
-static int FE_Delete_Previous(FORM * form)
+static int
+FE_Delete_Previous(FORM *form)
{
- FIELD *field = form->current;
-
+ FIELD *field = form->current;
+
+ T((T_CALLED("FE_Delete_Previous(%p)"), form));
if (First_Position_In_Current_Field(form))
- return E_REQUEST_DENIED;
+ returnCode(E_REQUEST_DENIED);
- if ( (--(form->curcol))<0 )
+ if ((--(form->curcol)) < 0)
{
- char *this_line, *prev_line, *prev_end, *this_end;
-
+ FIELD_CELL *this_line, *prev_line, *prev_end, *this_end;
+ int this_row = form->currow;
+
form->curcol++;
- if (form->status & _OVLMODE)
- return E_REQUEST_DENIED;
-
- prev_line = Address_Of_Row_In_Buffer(field,(form->currow-1));
- this_line = Address_Of_Row_In_Buffer(field,(form->currow));
+ if (form->status & _OVLMODE)
+ returnCode(E_REQUEST_DENIED);
+
+ prev_line = Address_Of_Row_In_Buffer(field, (form->currow - 1));
+ this_line = Address_Of_Row_In_Buffer(field, (form->currow));
Synchronize_Buffer(form);
- prev_end = After_End_Of_Data(prev_line,field->dcols);
- this_end = After_End_Of_Data(this_line,field->dcols);
- if ((int)(this_end-this_line) >
- (field->cols-(int)(prev_end-prev_line)))
- return E_REQUEST_DENIED;
+ prev_end = After_End_Of_Data(prev_line, field->dcols);
+ this_end = After_End_Of_Data(this_line, field->dcols);
+ if ((int)(this_end - this_line) >
+ (field->cols - (int)(prev_end - prev_line)))
+ returnCode(E_REQUEST_DENIED);
+ wmove(form->w, form->currow, form->curcol);
wdeleteln(form->w);
- Adjust_Cursor_Position(form,prev_end);
- wmove(form->w,form->currow,form->curcol);
- waddnstr(form->w,this_line,(int)(this_end-this_line));
- }
- else
+ Adjust_Cursor_Position(form, prev_end);
+ /*
+ * If we did not really move to the previous line, help the user a
+ * little. It is however a little inconsistent. Normally, when
+ * backspacing around the point where text wraps to a new line in a
+ * multi-line form, we absorb one keystroke for the wrapping point. That
+ * is consistent with SVr4 forms. However, SVr4 does not allow typing
+ * into the last column of the field, and requires the user to enter a
+ * newline to move to the next line. Therefore it can consistently eat
+ * that keystroke. Since ncurses allows the last column, it wraps
+ * automatically (given the proper options). But we cannot eat the
+ * keystroke to back over the wrapping point, since that would put the
+ * cursor past the end of the form field. In this case, just delete the
+ * character at the end of the field.
+ */
+ if (form->currow == this_row && this_row > 0)
+ {
+ form->currow -= 1;
+ form->curcol = field->dcols - 1;
+ DeleteChar(form);
+ }
+ else
+ {
+ wmove(form->w, form->currow, form->curcol);
+ myADDNSTR(form->w, this_line, (int)(this_end - this_line));
+ }
+ }
+ else
{
- wmove(form->w,form->currow,form->curcol);
- wdelch(form->w);
+ DeleteChar(form);
}
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Line(FORM * form)
-|
+|
| Description : Delete line at cursor position.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Delete_Line(FORM * form)
+static int
+FE_Delete_Line(FORM *form)
{
+ T((T_CALLED("FE_Delete_Line(%p)"), form));
form->curcol = 0;
wdeleteln(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Delete_Word(FORM * form)
-|
+|
| Description : Delete word at cursor position
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - failure
+--------------------------------------------------------------------------*/
-static int FE_Delete_Word(FORM * form)
+static int
+FE_Delete_Word(FORM *form)
{
- FIELD *field = form->current;
- char *bp = Address_Of_Current_Row_In_Buffer(form);
- char *ep = bp + field->dcols;
- char *cp = bp + form->curcol;
- char *s;
-
+ FIELD *field = form->current;
+ FIELD_CELL *bp = Address_Of_Current_Row_In_Buffer(form);
+ FIELD_CELL *ep = bp + field->dcols;
+ FIELD_CELL *cp = bp + form->curcol;
+ FIELD_CELL *s;
+
+ T((T_CALLED("FE_Delete_Word(%p)"), form));
Synchronize_Buffer(form);
- if (is_blank(*cp))
- return E_REQUEST_DENIED; /* not in word */
+ if (ISBLANK(*cp))
+ returnCode(E_REQUEST_DENIED); /* not in word */
/* move cursor to begin of word and erase to end of screen-line */
Adjust_Cursor_Position(form,
- After_Last_Whitespace_Character(bp,form->curcol));
- wmove(form->w,form->currow,form->curcol);
+ After_Last_Whitespace_Character(bp, form->curcol));
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
/* skip over word in buffer */
- s = Get_First_Whitespace_Character(cp,(int)(ep-cp));
+ s = Get_First_Whitespace_Character(cp, (int)(ep - cp));
/* to begin of next word */
- s = Get_Start_Of_Data(s,(int)(ep - s));
- if ( (s!=cp) && !is_blank(*s))
+ s = Get_Start_Of_Data(s, (int)(ep - s));
+ if ((s != cp) && !ISBLANK(*s))
{
/* copy remaining line to window */
- waddnstr(form->w,s,(int)(s - After_End_Of_Data(s,(int)(ep - s))));
+ myADDNSTR(form->w, s, (int)(s - After_End_Of_Data(s, (int)(ep - s))));
}
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Clear_To_End_Of_Line(FORM * form)
-|
+|
| Description : Clear to end of current line.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Line(FORM * form)
+static int
+FE_Clear_To_End_Of_Line(FORM *form)
{
+ T((T_CALLED("FE_Clear_To_End_Of_Line(%p)"), form));
+ wmove(form->w, form->currow, form->curcol);
wclrtoeol(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static int FE_Clear_To_End_Of_Form(FORM * form)
-|
-| Description : Clear to end of form.
+| Facility : libnform
+| Function : static int FE_Clear_To_End_Of_Field(FORM * form)
+|
+| Description : Clear to end of field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_To_End_Of_Form(FORM * form)
+static int
+FE_Clear_To_End_Of_Field(FORM *form)
{
+ T((T_CALLED("FE_Clear_To_End_Of_Field(%p)"), form));
+ wmove(form->w, form->currow, form->curcol);
wclrtobot(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FE_Clear_Field(FORM * form)
-|
+|
| Description : Clear entire field.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int FE_Clear_Field(FORM * form)
+static int
+FE_Clear_Field(FORM *form)
{
+ T((T_CALLED("FE_Clear_Field(%p)"), form));
form->currow = form->curcol = 0;
werase(form->w);
- return E_OK;
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Field Editing routines
+ END of Field Editing routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Edit Mode routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int EM_Overlay_Mode(FORM * form)
-|
+|
| Description : Switch to overlay mode.
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int EM_Overlay_Mode(FORM * form)
+static int
+EM_Overlay_Mode(FORM *form)
{
+ T((T_CALLED("EM_Overlay_Mode(%p)"), form));
form->status |= _OVLMODE;
- return E_OK;
+ returnCode(E_OK);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int EM_Insert_Mode(FORM * form)
-|
+|
| Description : Switch to insert mode
|
| Return Values : E_OK - success
+--------------------------------------------------------------------------*/
-static int EM_Insert_Mode(FORM * form)
+static int
+EM_Insert_Mode(FORM *form)
{
+ T((T_CALLED("EM_Insert_Mode(%p)"), form));
form->status &= ~_OVLMODE;
- return E_OK;
+ returnCode(E_OK);
}
/*----------------------------------------------------------------------------
- END of Edit Mode routines
+ END of Edit Mode routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Choice Requests
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Next_Choice(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
-|
+|
| Description : Get the next field choice. For linked types this is
| done recursively.
|
| Return Values : TRUE - next choice successfully retrieved
| FALSE - couldn't retrieve next choice
+--------------------------------------------------------------------------*/
-static bool Next_Choice(FIELDTYPE * typ, FIELD *field, TypeArgument *argp)
+static bool
+Next_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_CHOICE))
+ if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Next_Choice(typ->left ,field,argp->left) ||
- Next_Choice(typ->right,field,argp->right) );
- }
+ return (
+ Next_Choice(typ->left, field, argp->left) ||
+ Next_Choice(typ->right, field, argp->right));
+ }
else
{
assert(typ->next);
- return typ->next(field,(void *)argp);
+ return typ->next(field, (void *)argp);
}
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Previous_Choice(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument *argp)
-|
+|
| Description : Get the previous field choice. For linked types this
| is done recursively.
|
| Return Values : TRUE - previous choice successfully retrieved
| FALSE - couldn't retrieve previous choice
+--------------------------------------------------------------------------*/
-static bool Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Previous_Choice(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
- if (!typ || !(typ->status & _HAS_CHOICE))
+ if (!typ || !(typ->status & _HAS_CHOICE))
return FALSE;
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Previous_Choice(typ->left ,field,argp->left) ||
- Previous_Choice(typ->right,field,argp->right));
- }
- else
+ return (
+ Previous_Choice(typ->left, field, argp->left) ||
+ Previous_Choice(typ->right, field, argp->right));
+ }
+ else
{
assert(typ->prev);
- return typ->prev(field,(void *)argp);
+ return typ->prev(field, (void *)argp);
}
}
/*----------------------------------------------------------------------------
End of Helper routines for Choice Requests
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Routines for Choice Requests
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int CR_Next_Choice(FORM * form)
-|
+|
| Description : Get the next field choice.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - next choice couldn't be retrieved
+--------------------------------------------------------------------------*/
-static int CR_Next_Choice(FORM * form)
+static int
+CR_Next_Choice(FORM *form)
{
FIELD *field = form->current;
+
+ T((T_CALLED("CR_Next_Choice(%p)"), form));
Synchronize_Buffer(form);
- return ((Next_Choice(field->type,field,(TypeArgument *)(field->arg))) ?
- E_OK : E_REQUEST_DENIED);
+ returnCode((Next_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int CR_Previous_Choice(FORM * form)
-|
+|
| Description : Get the previous field choice.
|
| Return Values : E_OK - success
| E_REQUEST_DENIED - prev. choice couldn't be retrieved
+--------------------------------------------------------------------------*/
-static int CR_Previous_Choice(FORM * form)
+static int
+CR_Previous_Choice(FORM *form)
{
FIELD *field = form->current;
+
+ T((T_CALLED("CR_Previous_Choice(%p)"), form));
Synchronize_Buffer(form);
- return ((Previous_Choice(field->type,field,(TypeArgument *)(field->arg))) ?
- E_OK : E_REQUEST_DENIED);
+ returnCode((Previous_Choice(field->type, field, (TypeArgument *)(field->arg)))
+ ? E_OK
+ : E_REQUEST_DENIED);
}
/*----------------------------------------------------------------------------
End of Routines for Choice Requests
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Field Validations.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static bool Check_Field(
| FIELDTYPE * typ,
| FIELD * field,
| TypeArgument * argp)
-|
+|
| Description : Check the field according to its fieldtype and its
| actual arguments. For linked fieldtypes this is done
| recursively.
@@ -2652,59 +3046,63 @@ static int CR_Previous_Choice(FORM * form)
| Return Values : TRUE - field is valid
| FALSE - field is invalid.
+--------------------------------------------------------------------------*/
-static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
+static bool
+Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp)
{
if (typ)
{
if (field->opts & O_NULLOK)
{
- char *bp = field->buf;
+ FIELD_CELL *bp = field->buf;
+
assert(bp);
- while(is_blank(*bp))
- { bp++; }
- if (*bp == '\0')
+ while (ISBLANK(*bp))
+ {
+ bp++;
+ }
+ if (CharOf(*bp) == 0)
return TRUE;
}
if (typ->status & _LINKED_TYPE)
{
assert(argp);
- return(
- Check_Field(typ->left ,field,argp->left ) ||
- Check_Field(typ->right,field,argp->right) );
+ return (
+ Check_Field(typ->left, field, argp->left) ||
+ Check_Field(typ->right, field, argp->right));
}
- else
+ else
{
if (typ->fcheck)
- return typ->fcheck(field,(void *)argp);
+ return typ->fcheck(field, (void *)argp);
}
}
return TRUE;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : bool _nc_Internal_Validation(FORM * form )
-|
-| Description : Validate the current field of the form.
+|
+| Description : Validate the current field of the form.
|
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(bool)
-_nc_Internal_Validation (FORM *form)
+_nc_Internal_Validation(FORM *form)
{
FIELD *field;
- field = form->current;
-
+ field = form->current;
+
Synchronize_Buffer(form);
if ((form->status & _FCHECK_REQUIRED) ||
(!(field->opts & O_PASSOK)))
{
- if (!Check_Field(field->type,field,(TypeArgument *)(field->arg)))
+ if (!Check_Field(field->type, field, (TypeArgument *)(field->arg)))
return FALSE;
- form->status &= ~_FCHECK_REQUIRED;
+ form->status &= ~_FCHECK_REQUIRED;
field->status |= _CHANGED;
Synchronize_Linked_Fields(field);
}
@@ -2713,67 +3111,71 @@ _nc_Internal_Validation (FORM *form)
/*----------------------------------------------------------------------------
End of Helper routines for Field Validations.
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Routines for Field Validation.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FV_Validation(FORM * form)
-|
+|
| Description : Validate the current field of the form.
|
| Return Values : E_OK - field valid
| E_INVALID_FIELD - field not valid
+--------------------------------------------------------------------------*/
-static int FV_Validation(FORM * form)
+static int
+FV_Validation(FORM *form)
{
+ T((T_CALLED("FV_Validation(%p)"), form));
if (_nc_Internal_Validation(form))
- return E_OK;
+ returnCode(E_OK);
else
- return E_INVALID_FIELD;
+ returnCode(E_INVALID_FIELD);
}
/*----------------------------------------------------------------------------
End of routines for Field Validation.
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Inter-Field Navigation
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Next_Field_On_Page(FIELD * field)
-|
-| Description : Get the next field after the given field on the current
+|
+| Description : Get the next field after the given field on the current
| page. The order of fields is the one defined by the
| fields array. Only visible and active fields are
| counted.
|
| Return Values : Pointer to the next field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Next_Field_On_Page(FIELD * field)
+NCURSES_INLINE static FIELD *
+Next_Field_On_Page(FIELD *field)
{
- FORM *form = field->form;
+ FORM *form = field->form;
FIELD **field_on_page = &form->field[field->index];
FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
- FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
do
{
- field_on_page =
- (field_on_page==last_on_page) ? first_on_page : field_on_page + 1;
+ field_on_page =
+ (field_on_page == last_on_page) ? first_on_page : field_on_page + 1;
if (Field_Is_Selectable(*field_on_page))
break;
- } while(field!=(*field_on_page));
- return(*field_on_page);
+ }
+ while (field != (*field_on_page));
+ return (*field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : FIELD* _nc_First_Active_Field(FORM * form)
-|
+|
| Description : Get the first active field on the current page,
| if there are such. If there are none, get the first
| visible field on the page. If there are also none,
@@ -2781,17 +3183,18 @@ INLINE static FIELD *Next_Field_On_Page(FIELD * field)
|
| Return Values : Pointer to calculated field.
+--------------------------------------------------------------------------*/
-NCURSES_EXPORT(FIELD*)
-_nc_First_Active_Field (FORM * form)
+NCURSES_EXPORT(FIELD *)
+_nc_First_Active_Field(FORM *form)
{
FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
FIELD *proposed = Next_Field_On_Page(*last_on_page);
if (proposed == *last_on_page)
- { /* there might be the special situation, where there is no
- active and visible field on the current page. We then select
- the first visible field on this readonly page
- */
+ {
+ /* there might be the special situation, where there is no
+ active and visible field on the current page. We then select
+ the first visible field on this readonly page
+ */
if (Field_Is_Not_Selectable(proposed))
{
FIELD **field = &form->field[proposed->index];
@@ -2799,66 +3202,71 @@ _nc_First_Active_Field (FORM * form)
do
{
- field = (field==last_on_page) ? first : field + 1;
+ field = (field == last_on_page) ? first : field + 1;
if (((*field)->opts & O_VISIBLE))
break;
- } while(proposed!=(*field));
-
+ }
+ while (proposed != (*field));
+
proposed = *field;
- if ((proposed == *last_on_page) && !(proposed->opts&O_VISIBLE))
- { /* This means, there is also no visible field on the page.
- So we propose the first one and hope the very best...
- Some very clever user has designed a readonly and invisible
- page on this form.
+ if ((proposed == *last_on_page) && !(proposed->opts & O_VISIBLE))
+ {
+ /* This means, there is also no visible field on the page.
+ So we propose the first one and hope the very best...
+ Some very clever user has designed a readonly and invisible
+ page on this form.
*/
proposed = *first;
}
}
}
- return(proposed);
+ return (proposed);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Previous_Field_On_Page(FIELD * field)
-|
-| Description : Get the previous field before the given field on the
-| current page. The order of fields is the one defined by
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined by
| the fields array. Only visible and active fields are
| counted.
|
| Return Values : Pointer to the previous field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Previous_Field_On_Page(FIELD * field)
+NCURSES_INLINE static FIELD *
+Previous_Field_On_Page(FIELD *field)
{
- FORM *form = field->form;
+ FORM *form = field->form;
FIELD **field_on_page = &form->field[field->index];
FIELD **first_on_page = &form->field[form->page[form->curpage].pmin];
- FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
-
+ FIELD **last_on_page = &form->field[form->page[form->curpage].pmax];
+
do
{
- field_on_page =
- (field_on_page==first_on_page) ? last_on_page : field_on_page - 1;
+ field_on_page =
+ (field_on_page == first_on_page) ? last_on_page : field_on_page - 1;
if (Field_Is_Selectable(*field_on_page))
break;
- } while(field!=(*field_on_page));
-
+ }
+ while (field != (*field_on_page));
+
return (*field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Sorted_Next_Field(FIELD * field)
-|
-| Description : Get the next field after the given field on the current
+|
+| Description : Get the next field after the given field on the current
| page. The order of fields is the one defined by the
| (row,column) geometry, rows are major.
|
| Return Values : Pointer to the next field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Next_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Sorted_Next_Field(FIELD *field)
{
FIELD *field_on_page = field;
@@ -2867,22 +3275,24 @@ INLINE static FIELD *Sorted_Next_Field(FIELD * field)
field_on_page = field_on_page->snext;
if (Field_Is_Selectable(field_on_page))
break;
- } while(field_on_page!=field);
-
+ }
+ while (field_on_page != field);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static FIELD *Sorted_Previous_Field(FIELD * field)
-|
-| Description : Get the previous field before the given field on the
-| current page. The order of fields is the one defined
+|
+| Description : Get the previous field before the given field on the
+| current page. The order of fields is the one defined
| by the (row,column) geometry, rows are major.
|
| Return Values : Pointer to the previous field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Sorted_Previous_Field(FIELD *field)
{
FIELD *field_on_page = field;
@@ -2891,73 +3301,79 @@ INLINE static FIELD *Sorted_Previous_Field(FIELD * field)
field_on_page = field_on_page->sprev;
if (Field_Is_Selectable(field_on_page))
break;
- } while(field_on_page!=field);
-
+ }
+ while (field_on_page != field);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Left_Neighbour_Field(FIELD * field)
-|
-| Description : Get the left neighbour of the field on the same line
+| Facility : libnform
+| Function : static FIELD *Left_Neighbor_Field(FIELD * field)
+|
+| Description : Get the left neighbor of the field on the same line
| and the same page. Cycles through the line.
|
-| Return Values : Pointer to left neighbour field.
+| Return Values : Pointer to left neighbor field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Left_Neighbour_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Left_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
- /* For a field that has really a left neighbour, the while clause
+ /* For a field that has really a left neighbor, the while clause
immediately fails and the loop is left, positioned at the right
- neighbour. Otherwise we cycle backwards through the sorted fieldlist
+ neighbor. Otherwise we cycle backwards through the sorted field list
until we enter the same line (from the right end).
- */
+ */
do
{
field_on_page = Sorted_Previous_Field(field_on_page);
- } while(field_on_page->frow != field->frow);
-
+ }
+ while (field_on_page->frow != field->frow);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Right_Neighbour_Field(FIELD * field)
-|
-| Description : Get the right neighbour of the field on the same line
+| Facility : libnform
+| Function : static FIELD *Right_Neighbor_Field(FIELD * field)
+|
+| Description : Get the right neighbor of the field on the same line
| and the same page.
|
-| Return Values : Pointer to right neighbour field.
+| Return Values : Pointer to right neighbor field.
+--------------------------------------------------------------------------*/
-INLINE static FIELD *Right_Neighbour_Field(FIELD * field)
+NCURSES_INLINE static FIELD *
+Right_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
- /* See the comments on Left_Neighbour_Field to understand how it works */
+ /* See the comments on Left_Neighbor_Field to understand how it works */
do
{
field_on_page = Sorted_Next_Field(field_on_page);
- } while(field_on_page->frow != field->frow);
-
+ }
+ while (field_on_page->frow != field->frow);
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Upper_Neighbour_Field(FIELD * field)
-|
+| Facility : libnform
+| Function : static FIELD *Upper_Neighbor_Field(FIELD * field)
+|
| Description : Because of the row-major nature of sorting the fields,
-| its more difficult to define whats the upper neighbour
+| it is more difficult to define whats the upper neighbor
| field really means. We define that it must be on a
| 'previous' line (cyclic order!) and is the rightmost
| field laying on the left side of the given field. If
| this set is empty, we take the first field on the line.
|
-| Return Values : Pointer to the upper neighbour field.
+| Return Values : Pointer to the upper neighbor field.
+--------------------------------------------------------------------------*/
-static FIELD *Upper_Neighbour_Field(FIELD * field)
+static FIELD *
+Upper_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
int frow = field->frow;
@@ -2966,45 +3382,48 @@ static FIELD *Upper_Neighbour_Field(FIELD * field)
/* Walk back to the 'previous' line. The second term in the while clause
just guarantees that we stop if we cycled through the line because
there might be no 'previous' line if the page has just one line.
- */
+ */
do
{
field_on_page = Sorted_Previous_Field(field_on_page);
- } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
-
- if (field_on_page->frow!=frow)
- { /* We really found a 'previous' line. We are positioned at the
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
+
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'previous' line. We are positioned at the
rightmost field on this line */
- frow = field_on_page->frow;
+ frow = field_on_page->frow;
- /* We walk to the left as long as we are really right of the
- field. */
- while(field_on_page->frow==frow && field_on_page->fcol>fcol)
+ /* We walk to the left as long as we are really right of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol > fcol)
field_on_page = Sorted_Previous_Field(field_on_page);
- /* If we wrapped, just go to the right which is the first field on
- the row */
- if (field_on_page->frow!=frow)
+ /* If we wrapped, just go to the right which is the first field on
+ the row */
+ if (field_on_page->frow != frow)
field_on_page = Sorted_Next_Field(field_on_page);
}
-
+
return (field_on_page);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static FIELD *Down_Neighbour_Field(FIELD * field)
-|
+| Facility : libnform
+| Function : static FIELD *Down_Neighbor_Field(FIELD * field)
+|
| Description : Because of the row-major nature of sorting the fields,
-| its more difficult to define whats the down neighbour
+| its more difficult to define whats the down neighbor
| field really means. We define that it must be on a
| 'next' line (cyclic order!) and is the leftmost
| field laying on the right side of the given field. If
| this set is empty, we take the last field on the line.
|
-| Return Values : Pointer to the upper neighbour field.
+| Return Values : Pointer to the upper neighbor field.
+--------------------------------------------------------------------------*/
-static FIELD *Down_Neighbour_Field(FIELD * field)
+static FIELD *
+Down_Neighbor_Field(FIELD *field)
{
FIELD *field_on_page = field;
int frow = field->frow;
@@ -3013,42 +3432,44 @@ static FIELD *Down_Neighbour_Field(FIELD * field)
/* Walk forward to the 'next' line. The second term in the while clause
just guarantees that we stop if we cycled through the line because
there might be no 'next' line if the page has just one line.
- */
+ */
do
{
field_on_page = Sorted_Next_Field(field_on_page);
- } while(field_on_page->frow==frow && field_on_page->fcol!=fcol);
+ }
+ while (field_on_page->frow == frow && field_on_page->fcol != fcol);
- if (field_on_page->frow!=frow)
- { /* We really found a 'next' line. We are positioned at the rightmost
+ if (field_on_page->frow != frow)
+ {
+ /* We really found a 'next' line. We are positioned at the rightmost
field on this line */
frow = field_on_page->frow;
- /* We walk to the right as long as we are really left of the
- field. */
- while(field_on_page->frow==frow && field_on_page->fcol<fcol)
+ /* We walk to the right as long as we are really left of the
+ field. */
+ while (field_on_page->frow == frow && field_on_page->fcol < fcol)
field_on_page = Sorted_Next_Field(field_on_page);
- /* If we wrapped, just go to the left which is the last field on
- the row */
- if (field_on_page->frow!=frow)
+ /* If we wrapped, just go to the left which is the last field on
+ the row */
+ if (field_on_page->frow != frow)
field_on_page = Sorted_Previous_Field(field_on_page);
}
-
- return(field_on_page);
+
+ return (field_on_page);
}
-
+
/*----------------------------------------------------------------------------
Inter-Field Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Inter_Field_Navigation(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Generic behaviour for changing the current field, the
+|
+| Description : Generic behavior for changing the current field, the
| field is left and a new field is entered. So the field
| must be validated and the field init/term hooks must
| be called.
@@ -3057,229 +3478,254 @@ static FIELD *Down_Neighbour_Field(FIELD * field)
| E_INVALID_FIELD - field is invalid
| some other - error from subordinate call
+--------------------------------------------------------------------------*/
-static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form)
+static int
+Inter_Field_Navigation(int (*const fct) (FORM *), FORM *form)
{
int res;
- if (!_nc_Internal_Validation(form))
+ if (!_nc_Internal_Validation(form))
res = E_INVALID_FIELD;
else
{
- Call_Hook(form,fieldterm);
+ Call_Hook(form, fieldterm);
res = fct(form);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, fieldinit);
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Next_Field(FORM * form)
-|
+|
| Description : Move to the next field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Next_Field(FORM * form)
+static int
+FN_Next_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Next_Field_On_Page(form->current));
+ T((T_CALLED("FN_Next_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Previous_Field(FORM * form)
-|
-| Description : Move to the previous field on the current page of the
+|
+| Description : Move to the previous field on the current page of the
| form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Previous_Field(FORM * form)
+static int
+FN_Previous_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Previous_Field_On_Page(form->current));
+ T((T_CALLED("FN_Previous_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_First_Field(FORM * form)
-|
+|
| Description : Move to the first field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_First_Field(FORM * form)
+static int
+FN_First_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Next_Field_On_Page(form->field[form->page[form->curpage].pmax]));
+ T((T_CALLED("FN_First_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Next_Field_On_Page(form->field[form->page[form->curpage].pmax])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Last_Field(FORM * form)
-|
+|
| Description : Move to the last field on the current page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Last_Field(FORM * form)
+static int
+FN_Last_Field(FORM *form)
{
- return
- _nc_Set_Current_Field(form,
- Previous_Field_On_Page(form->field[form->page[form->curpage].pmin]));
+ T((T_CALLED("FN_Last_Field(%p)"), form));
+ returnCode(
+ _nc_Set_Current_Field(form,
+ Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Next_Field(FORM * form)
-|
+|
| Description : Move to the sorted next field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Next_Field(FORM * form)
+static int
+FN_Sorted_Next_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Next_Field(form->current));
+ T((T_CALLED("FN_Sorted_Next_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Previous_Field(FORM * form)
-|
+|
| Description : Move to the sorted previous field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Previous_Field(FORM * form)
+static int
+FN_Sorted_Previous_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Previous_Field(form->current));
+ T((T_CALLED("FN_Sorted_Previous_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_First_Field(FORM * form)
-|
+|
| Description : Move to the sorted first field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_First_Field(FORM * form)
+static int
+FN_Sorted_First_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Next_Field(form->field[form->page[form->curpage].smax]));
+ T((T_CALLED("FN_Sorted_First_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Next_Field(form->field[form->page[form->curpage].smax])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Sorted_Last_Field(FORM * form)
-|
+|
| Description : Move to the sorted last field on the current page
| of the form.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Sorted_Last_Field(FORM * form)
+static int
+FN_Sorted_Last_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Sorted_Previous_Field(form->field[form->page[form->curpage].smin]));
+ T((T_CALLED("FN_Sorted_Last_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Sorted_Previous_Field(form->field[form->page[form->curpage].smin])));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Left_Field(FORM * form)
-|
+|
| Description : Get the field on the left of the current field on the
| same line and the same page. Cycles through the line.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Left_Field(FORM * form)
+static int
+FN_Left_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Left_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Left_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Left_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Right_Field(FORM * form)
-|
+|
| Description : Get the field on the right of the current field on the
| same line and the same page. Cycles through the line.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Right_Field(FORM * form)
+static int
+FN_Right_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Right_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Right_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Right_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Up_Field(FORM * form)
-|
-| Description : Get the upper neighbour of the current field. This
+|
+| Description : Get the upper neighbor of the current field. This
| cycles through the page. See the comments of the
-| Upper_Neighbour_Field function to understand how
-| 'upper' is defined.
+| Upper_Neighbor_Field function to understand how
+| 'upper' is defined.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Up_Field(FORM * form)
+static int
+FN_Up_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Upper_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Up_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Upper_Neighbor_Field(form->current)));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int FN_Down_Field(FORM * form)
-|
-| Description : Get the down neighbour of the current field. This
+|
+| Description : Get the down neighbor of the current field. This
| cycles through the page. See the comments of the
-| Down_Neighbour_Field function to understand how
-| 'down' is defined.
+| Down_Neighbor_Field function to understand how
+| 'down' is defined.
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int FN_Down_Field(FORM * form)
+static int
+FN_Down_Field(FORM *form)
{
- return _nc_Set_Current_Field(form,
- Down_Neighbour_Field(form->current));
+ T((T_CALLED("FN_Down_Field(%p)"), form));
+ returnCode(_nc_Set_Current_Field(form,
+ Down_Neighbor_Field(form->current)));
}
/*----------------------------------------------------------------------------
- END of Field Navigation routines
+ END of Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for Page Navigation
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int _nc_Set_Form_Page(FORM * form,
| int page,
| FIELD * field)
-|
-| Description : Make the given page nr. the current page and make
+|
+| Description : Make the given page number the current page and make
| the given field the current field on the page. If
| for the field NULL is given, make the first field on
| the page the current field. The routine acts only
@@ -3287,14 +3733,15 @@ static int FN_Down_Field(FORM * form)
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+| E_BAD_ARGUMENT - invalid field pointer
+| E_SYSTEM_ERROR - some severe basic error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-_nc_Set_Form_Page
-(FORM * form, int page, FIELD * field)
+_nc_Set_Form_Page(FORM *form, int page, FIELD *field)
{
int res = E_OK;
- if ((form->curpage!=page))
+ if ((form->curpage != page))
{
FIELD *last_field, *field_on_page;
@@ -3304,64 +3751,67 @@ _nc_Set_Form_Page
do
{
if (field_on_page->opts & O_VISIBLE)
- if ((res=Display_Field(field_on_page))!=E_OK)
- return(res);
+ if ((res = Display_Field(field_on_page)) != E_OK)
+ return (res);
field_on_page = field_on_page->snext;
- } while(field_on_page != last_field);
+ }
+ while (field_on_page != last_field);
if (field)
- res = _nc_Set_Current_Field(form,field);
+ res = _nc_Set_Current_Field(form, field);
else
/* N.B.: we don't encapsulate this by Inter_Field_Navigation(),
because this is already executed in a page navigation
- context that contains field navigation
+ context that contains field navigation
*/
res = FN_First_Field(form);
}
- return(res);
+ return (res);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Next_Page_Number(const FORM * form)
-|
+|
| Description : Calculate the page number following the current page
| number. This cycles if the highest page number is
-| reached.
+| reached.
|
| Return Values : The next page number
+--------------------------------------------------------------------------*/
-INLINE static int Next_Page_Number(const FORM * form)
+NCURSES_INLINE static int
+Next_Page_Number(const FORM *form)
{
return (form->curpage + 1) % form->maxpage;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Previous_Page_Number(const FORM * form)
-|
+|
| Description : Calculate the page number before the current page
| number. This cycles if the first page number is
-| reached.
+| reached.
|
| Return Values : The previous page number
+--------------------------------------------------------------------------*/
-INLINE static int Previous_Page_Number(const FORM * form)
+NCURSES_INLINE static int
+Previous_Page_Number(const FORM *form)
{
- return (form->curpage!=0 ? form->curpage - 1 : form->maxpage - 1);
+ return (form->curpage != 0 ? form->curpage - 1 : form->maxpage - 1);
}
-
+
/*----------------------------------------------------------------------------
- Page Navigation routines
+ Page Navigation routines
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Page_Navigation(
| int (* const fct) (FORM *),
| FORM * form)
-|
-| Description : Generic behaviour for changing a page. This means
+|
+| Description : Generic behavior for changing a page. This means
| that the field is left and a new field is entered.
| So the field must be validated and the field init/term
| hooks must be called. Because also the page is changed,
@@ -3371,192 +3821,220 @@ INLINE static int Previous_Page_Number(const FORM * form)
| E_INVALID_FIELD - field is invalid
| some other - error from subordinate call
+--------------------------------------------------------------------------*/
-static int Page_Navigation(int (* const fct) (FORM *), FORM * form)
+static int
+Page_Navigation(int (*const fct) (FORM *), FORM *form)
{
int res;
- if (!_nc_Internal_Validation(form))
+ if (!_nc_Internal_Validation(form))
res = E_INVALID_FIELD;
else
{
- Call_Hook(form,fieldterm);
- Call_Hook(form,formterm);
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
res = fct(form);
- Call_Hook(form,forminit);
- Call_Hook(form,fieldinit);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
}
return res;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Next_Page(FORM * form)
-|
+|
| Description : Move to the next page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Next_Page(FORM * form)
-{
- return _nc_Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0);
+static int
+PN_Next_Page(FORM *form)
+{
+ T((T_CALLED("PN_Next_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, Next_Page_Number(form), (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Previous_Page(FORM * form)
-|
+|
| Description : Move to the previous page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Previous_Page(FORM * form)
+static int
+PN_Previous_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0);
+ T((T_CALLED("PN_Previous_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, Previous_Page_Number(form), (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_First_Page(FORM * form)
-|
+|
| Description : Move to the first page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_First_Page(FORM * form)
+static int
+PN_First_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,0,(FIELD *)0);
+ T((T_CALLED("PN_First_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, 0, (FIELD *)0));
}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int PN_Last_Page(FORM * form)
-|
+|
| Description : Move to the last page of the form
|
| Return Values : E_OK - success
| != E_OK - error from subordinate call
+--------------------------------------------------------------------------*/
-static int PN_Last_Page(FORM * form)
+static int
+PN_Last_Page(FORM *form)
{
- return _nc_Set_Form_Page(form,form->maxpage-1,(FIELD *)0);
+ T((T_CALLED("PN_Last_Page(%p)"), form));
+ returnCode(_nc_Set_Form_Page(form, form->maxpage - 1, (FIELD *)0));
}
+
/*----------------------------------------------------------------------------
- END of Field Navigation routines
+ END of Field Navigation routines
--------------------------------------------------------------------------*/
-
+
/*----------------------------------------------------------------------------
Helper routines for the core form driver.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : static int Data_Entry(FORM * form,int c)
-|
+|
| Description : Enter character c into at the current position of the
| current field of the form.
|
-| Return Values : E_OK -
-| E_REQUEST_DENIED -
+| Return Values : E_OK - success
+| E_REQUEST_DENIED - driver could not process the request
| E_SYSTEM_ERROR -
+--------------------------------------------------------------------------*/
-static int Data_Entry(FORM * form, int c)
+static int
+Data_Entry(FORM *form, int c)
{
- FIELD *field = form->current;
+ FIELD *field = form->current;
int result = E_REQUEST_DENIED;
- if ( (field->opts & O_EDIT)
+ T((T_CALLED("Data_Entry(%p,%s)"), form, _tracechtype((chtype)c)));
+ if ((field->opts & O_EDIT)
#if FIX_FORM_INACTIVE_BUG
- && (field->opts & O_ACTIVE)
+ && (field->opts & O_ACTIVE)
#endif
- )
+ )
{
- if ( (field->opts & O_BLANK) &&
- First_Position_In_Current_Field(form) &&
- !(form->status & _FCHECK_REQUIRED) &&
- !(form->status & _WINDOW_MODIFIED) )
+ if ((field->opts & O_BLANK) &&
+ First_Position_In_Current_Field(form) &&
+ !(form->status & _FCHECK_REQUIRED) &&
+ !(form->status & _WINDOW_MODIFIED))
werase(form->w);
if (form->status & _OVLMODE)
{
- waddch(form->w,(chtype)c);
- }
- else /* no _OVLMODE */
+ waddch(form->w, (chtype)c);
+ }
+ else
+ /* no _OVLMODE */
{
bool There_Is_Room = Is_There_Room_For_A_Char_In_Line(form);
if (!(There_Is_Room ||
((Single_Line_Field(field) && Growable(field)))))
- return E_REQUEST_DENIED;
+ RETURN(E_REQUEST_DENIED);
- if (!There_Is_Room && !Field_Grown(field,1))
- return E_SYSTEM_ERROR;
+ if (!There_Is_Room && !Field_Grown(field, 1))
+ RETURN(E_SYSTEM_ERROR);
- winsch(form->w,(chtype)c);
+ winsch(form->w, (chtype)c);
}
- if ((result=Wrapping_Not_Necessary_Or_Wrapping_Ok(form))==E_OK)
+ if ((result = Wrapping_Not_Necessary_Or_Wrapping_Ok(form)) == E_OK)
{
- bool End_Of_Field= (((field->drows-1)==form->currow) &&
- ((field->dcols-1)==form->curcol));
+ bool End_Of_Field = (((field->drows - 1) == form->currow) &&
+ ((field->dcols - 1) == form->curcol));
+
form->status |= _WINDOW_MODIFIED;
if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP))
- result = Inter_Field_Navigation(FN_Next_Field,form);
+ result = Inter_Field_Navigation(FN_Next_Field, form);
else
{
- if (End_Of_Field && Growable(field) && !Field_Grown(field,1))
+ if (End_Of_Field && Growable(field) && !Field_Grown(field, 1))
result = E_SYSTEM_ERROR;
else
{
+#if USE_WIDEC_SUPPORT
+ /*
+ * We have just added a byte to the form field. It may have
+ * been part of a multibyte character. If it was, the
+ * addch_used field is nonzero and we should not try to move
+ * to a new column.
+ */
+ if (WINDOW_EXT(form->w, addch_used) == 0)
+ IFN_Next_Character(form);
+#else
IFN_Next_Character(form);
+#endif
result = E_OK;
}
}
}
}
- return result;
+ RETURN(result);
}
-
+
/* Structure to describe the binding of a request code to a function.
The member keycode codes the request value as well as the generic
routine to use for the request. The code for the generic routine
is coded in the upper 16 Bits while the request code is coded in
- the lower 16 bits.
+ the lower 16 bits.
In terms of C++ you might think of a request as a class with a
virtual method "perform". The different types of request are
derived from this base class and overload (or not) the base class
implementation of perform.
*/
-typedef struct {
- int keycode; /* must be at least 32 bit: hi:mode, lo: key */
- int (*cmd)(FORM *); /* low level driver routine for this key */
-} Binding_Info;
+typedef struct
+{
+ int keycode; /* must be at least 32 bit: hi:mode, lo: key */
+ int (*cmd) (FORM *); /* low level driver routine for this key */
+}
+Binding_Info;
/* You may see this is the class-id of the request type class */
-#define ID_PN (0x00000000) /* Page navigation */
-#define ID_FN (0x00010000) /* Inter-Field navigation */
-#define ID_IFN (0x00020000) /* Intra-Field navigation */
-#define ID_VSC (0x00030000) /* Vertical Scrolling */
-#define ID_HSC (0x00040000) /* Horizontal Scrolling */
-#define ID_FE (0x00050000) /* Field Editing */
-#define ID_EM (0x00060000) /* Edit Mode */
-#define ID_FV (0x00070000) /* Field Validation */
-#define ID_CH (0x00080000) /* Choice */
+#define ID_PN (0x00000000) /* Page navigation */
+#define ID_FN (0x00010000) /* Inter-Field navigation */
+#define ID_IFN (0x00020000) /* Intra-Field navigation */
+#define ID_VSC (0x00030000) /* Vertical Scrolling */
+#define ID_HSC (0x00040000) /* Horizontal Scrolling */
+#define ID_FE (0x00050000) /* Field Editing */
+#define ID_EM (0x00060000) /* Edit Mode */
+#define ID_FV (0x00070000) /* Field Validation */
+#define ID_CH (0x00080000) /* Choice */
#define ID_Mask (0xffff0000)
#define Key_Mask (0x0000ffff)
#define ID_Shft (16)
/* This array holds all the Binding Infos */
-static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
+/* *INDENT-OFF* */
+static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{
{ REQ_NEXT_PAGE |ID_PN ,PN_Next_Page},
{ REQ_PREV_PAGE |ID_PN ,PN_Previous_Page},
{ REQ_FIRST_PAGE |ID_PN ,PN_First_Page},
{ REQ_LAST_PAGE |ID_PN ,PN_Last_Page},
-
+
{ REQ_NEXT_FIELD |ID_FN ,FN_Next_Field},
{ REQ_PREV_FIELD |ID_FN ,FN_Previous_Field},
{ REQ_FIRST_FIELD |ID_FN ,FN_First_Field},
@@ -3569,7 +4047,7 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_RIGHT_FIELD |ID_FN ,FN_Right_Field},
{ REQ_UP_FIELD |ID_FN ,FN_Up_Field},
{ REQ_DOWN_FIELD |ID_FN ,FN_Down_Field},
-
+
{ REQ_NEXT_CHAR |ID_IFN ,IFN_Next_Character},
{ REQ_PREV_CHAR |ID_IFN ,IFN_Previous_Character},
{ REQ_NEXT_LINE |ID_IFN ,IFN_Next_Line},
@@ -3584,7 +4062,7 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_RIGHT_CHAR |ID_IFN ,IFN_Right_Character},
{ REQ_UP_CHAR |ID_IFN ,IFN_Up_Character},
{ REQ_DOWN_CHAR |ID_IFN ,IFN_Down_Character},
-
+
{ REQ_NEW_LINE |ID_FE ,FE_New_Line},
{ REQ_INS_CHAR |ID_FE ,FE_Insert_Character},
{ REQ_INS_LINE |ID_FE ,FE_Insert_Line},
@@ -3593,36 +4071,37 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
{ REQ_DEL_LINE |ID_FE ,FE_Delete_Line},
{ REQ_DEL_WORD |ID_FE ,FE_Delete_Word},
{ REQ_CLR_EOL |ID_FE ,FE_Clear_To_End_Of_Line},
- { REQ_CLR_EOF |ID_FE ,FE_Clear_To_End_Of_Form},
+ { REQ_CLR_EOF |ID_FE ,FE_Clear_To_End_Of_Field},
{ REQ_CLR_FIELD |ID_FE ,FE_Clear_Field},
-
+
{ REQ_OVL_MODE |ID_EM ,EM_Overlay_Mode},
{ REQ_INS_MODE |ID_EM ,EM_Insert_Mode},
-
+
{ REQ_SCR_FLINE |ID_VSC ,VSC_Scroll_Line_Forward},
{ REQ_SCR_BLINE |ID_VSC ,VSC_Scroll_Line_Backward},
{ REQ_SCR_FPAGE |ID_VSC ,VSC_Scroll_Page_Forward},
{ REQ_SCR_BPAGE |ID_VSC ,VSC_Scroll_Page_Backward},
{ REQ_SCR_FHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Forward},
{ REQ_SCR_BHPAGE |ID_VSC ,VSC_Scroll_Half_Page_Backward},
-
+
{ REQ_SCR_FCHAR |ID_HSC ,HSC_Scroll_Char_Forward},
{ REQ_SCR_BCHAR |ID_HSC ,HSC_Scroll_Char_Backward},
{ REQ_SCR_HFLINE |ID_HSC ,HSC_Horizontal_Line_Forward},
{ REQ_SCR_HBLINE |ID_HSC ,HSC_Horizontal_Line_Backward},
{ REQ_SCR_HFHALF |ID_HSC ,HSC_Horizontal_Half_Line_Forward},
{ REQ_SCR_HBHALF |ID_HSC ,HSC_Horizontal_Half_Line_Backward},
-
+
{ REQ_VALIDATION |ID_FV ,FV_Validation},
{ REQ_NEXT_CHOICE |ID_CH ,CR_Next_Choice},
{ REQ_PREV_CHOICE |ID_CH ,CR_Previous_Choice}
};
+/* *INDENT-ON* */
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int form_driver(FORM * form,int c)
-|
+|
| Description : This is the workhorse of the forms system. It checks
| to determine whether the character c is a request or
| data. If it is a request, the form driver executes
@@ -3641,213 +4120,457 @@ static const Binding_Info bindings[MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1] =
| E_INVALID_FIELD - field contents are invalid
| E_BAD_STATE - called from inside a hook routine
| E_REQUEST_DENIED - request failed
+| E_NOT_CONNECTED - no fields are connected to the form
| E_UNKNOWN_COMMAND - command not known
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_driver (FORM * form, int c)
+form_driver(FORM *form, int c)
{
- const Binding_Info* BI = (Binding_Info *)0;
+ const Binding_Info *BI = (Binding_Info *) 0;
int res = E_UNKNOWN_COMMAND;
+ T((T_CALLED("form_driver(%p,%d)"), form, c));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
if (!(form->field))
RETURN(E_NOT_CONNECTED);
-
+
assert(form->page);
-
- if (c==FIRST_ACTIVE_MAGIC)
+
+ if (c == FIRST_ACTIVE_MAGIC)
{
form->current = _nc_First_Active_Field(form);
- return E_OK;
+ RETURN(E_OK);
}
-
- assert(form->current &&
- form->current->buf &&
+
+ assert(form->current &&
+ form->current->buf &&
(form->current->form == form)
- );
-
- if ( form->status & _IN_DRIVER )
+ );
+
+ if (form->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- if ( !( form->status & _POSTED ) )
+ if (!(form->status & _POSTED))
RETURN(E_NOT_POSTED);
-
- if ((c>=MIN_FORM_COMMAND && c<=MAX_FORM_COMMAND) &&
- ((bindings[c-MIN_FORM_COMMAND].keycode & Key_Mask) == c))
- BI = &(bindings[c-MIN_FORM_COMMAND]);
-
+
+ if ((c >= MIN_FORM_COMMAND && c <= MAX_FORM_COMMAND) &&
+ ((bindings[c - MIN_FORM_COMMAND].keycode & Key_Mask) == c))
+ BI = &(bindings[c - MIN_FORM_COMMAND]);
+
if (BI)
{
- typedef int (*Generic_Method)(int (* const)(FORM *),FORM *);
- static const Generic_Method Generic_Methods[] =
- {
- Page_Navigation, /* overloaded to call field&form hooks */
- Inter_Field_Navigation, /* overloaded to call field hooks */
- NULL, /* Intra-Field is generic */
- Vertical_Scrolling, /* Overloaded to check multi-line */
- Horizontal_Scrolling, /* Overloaded to check single-line */
- Field_Editing, /* Overloaded to mark modification */
- NULL, /* Edit Mode is generic */
- NULL, /* Field Validation is generic */
- NULL /* Choice Request is generic */
- };
- size_t nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0]));
- size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff;
-
- if ( (method >= nMethods) || !(BI->cmd) )
+ typedef int (*Generic_Method) (int (*const) (FORM *), FORM *);
+ static const Generic_Method Generic_Methods[] =
+ {
+ Page_Navigation, /* overloaded to call field&form hooks */
+ Inter_Field_Navigation, /* overloaded to call field hooks */
+ NULL, /* Intra-Field is generic */
+ Vertical_Scrolling, /* Overloaded to check multi-line */
+ Horizontal_Scrolling, /* Overloaded to check single-line */
+ Field_Editing, /* Overloaded to mark modification */
+ NULL, /* Edit Mode is generic */
+ NULL, /* Field Validation is generic */
+ NULL /* Choice Request is generic */
+ };
+ size_t nMethods = (sizeof(Generic_Methods) / sizeof(Generic_Methods[0]));
+ size_t method = (BI->keycode >> ID_Shft) & 0xffff; /* see ID_Mask */
+
+ if ((method >= nMethods) || !(BI->cmd))
res = E_SYSTEM_ERROR;
else
{
Generic_Method fct = Generic_Methods[method];
+
if (fct)
- res = fct(BI->cmd,form);
+ res = fct(BI->cmd, form);
else
- res = (BI->cmd)(form);
+ res = (BI->cmd) (form);
+ }
+ }
+#ifdef NCURSES_MOUSE_VERSION
+ else if (KEY_MOUSE == c)
+ {
+ MEVENT event;
+ WINDOW *win = form->win ? form->win : stdscr;
+ WINDOW *sub = form->sub ? form->sub : win;
+
+ getmouse(&event);
+ if ((event.bstate & (BUTTON1_CLICKED |
+ BUTTON1_DOUBLE_CLICKED |
+ BUTTON1_TRIPLE_CLICKED))
+ && wenclose(win, event.y, event.x))
+ { /* we react only if the click was in the userwin, that means
+ * inside the form display area or at the decoration window.
+ */
+ int ry = event.y, rx = event.x; /* screen coordinates */
+
+ res = E_REQUEST_DENIED;
+ if (mouse_trafo(&ry, &rx, FALSE))
+ { /* rx, ry are now "curses" coordinates */
+ if (ry < sub->_begy)
+ { /* we clicked above the display region; this is
+ * interpreted as "scroll up" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_PREV_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_PREV_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_FIRST_FIELD);
+ }
+ else if (ry > sub->_begy + sub->_maxy)
+ { /* we clicked below the display region; this is
+ * interpreted as "scroll down" request
+ */
+ if (event.bstate & BUTTON1_CLICKED)
+ res = form_driver(form, REQ_NEXT_FIELD);
+ else if (event.bstate & BUTTON1_DOUBLE_CLICKED)
+ res = form_driver(form, REQ_NEXT_PAGE);
+ else if (event.bstate & BUTTON1_TRIPLE_CLICKED)
+ res = form_driver(form, REQ_LAST_FIELD);
+ }
+ else if (wenclose(sub, event.y, event.x))
+ { /* Inside the area we try to find the hit item */
+ int i;
+
+ ry = event.y;
+ rx = event.x;
+ if (wmouse_trafo(sub, &ry, &rx, FALSE))
+ {
+ int min_field = form->page[form->curpage].pmin;
+ int max_field = form->page[form->curpage].pmax;
+
+ for (i = min_field; i <= max_field; ++i)
+ {
+ FIELD *field = form->field[i];
+
+ if (Field_Is_Selectable(field)
+ && Field_encloses(field, ry, rx) == E_OK)
+ {
+ res = _nc_Set_Current_Field(form, field);
+ if (res == E_OK)
+ res = _nc_Position_Form_Cursor(form);
+ if (res == E_OK
+ && (event.bstate & BUTTON1_DOUBLE_CLICKED))
+ res = E_UNKNOWN_COMMAND;
+ break;
+ }
+ }
+ }
+ }
+ }
}
- }
- else
+ else
+ res = E_REQUEST_DENIED;
+ }
+#endif /* NCURSES_MOUSE_VERSION */
+ else if (!(c & (~(int)MAX_REGULAR_CHARACTER)))
{
- if (!(c & (~(int)MAX_REGULAR_CHARACTER)) &&
- isprint((unsigned char)c) &&
- Check_Char(form->current->type,c,
+ /*
+ * If we're using 8-bit characters, iscntrl+isprint cover the whole set.
+ * But with multibyte characters, there is a third possibility, i.e.,
+ * parts of characters that build up into printable characters which are
+ * not considered printable.
+ *
+ * FIXME: the wide-character branch should also use Check_Char().
+ */
+#if USE_WIDEC_SUPPORT
+ if (!iscntrl(UChar(c)))
+#else
+ if (isprint(UChar(c)) &&
+ Check_Char(form->current->type, c,
(TypeArgument *)(form->current->arg)))
- res = Data_Entry(form,c);
+#endif
+ res = Data_Entry(form, c);
}
_nc_Refresh_Current_Field(form);
RETURN(res);
}
-
+
/*----------------------------------------------------------------------------
Field-Buffer manipulation routines.
- The effects of setting a buffer is tightly coupled to the core of the form
+ The effects of setting a buffer are tightly coupled to the core of the form
driver logic. This is especially true in the case of growable fields.
- So I don't separate this into an own module.
+ So I don't separate this into a separate module.
--------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : int set_field_buffer(FIELD *field,
| int buffer, char *value)
-|
+|
| Description : Set the given buffer of the field to the given value.
| Buffer 0 stores the displayed content of the field.
| For dynamic fields this may grow the fieldbuffers if
| the length of the value exceeds the current buffer
| length. For buffer 0 only printable values are allowed.
| For static fields, the value needs not to be zero ter-
-| minated. It is copied up to the length of the buffer.
+| minated. It is copied up to the length of the buffer.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_field_buffer
-(FIELD * field, int buffer, const char * value)
+set_field_buffer(FIELD *field, int buffer, const char *value)
{
- char *s, *p;
+ FIELD_CELL *p;
int res = E_OK;
+ unsigned int i;
unsigned int len;
- if ( !field || !value || ((buffer < 0)||(buffer > field->nbuf)) )
- RETURN(E_BAD_ARGUMENT);
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *widevalue = 0;
+#endif
- len = Buffer_Length(field);
+ T((T_CALLED("set_field_buffer(%p,%d,%s)"), field, buffer, _nc_visbuf(value)));
- if (buffer==0)
- {
- const char *v;
- unsigned int i = 0;
+ if (!field || !value || ((buffer < 0) || (buffer > field->nbuf)))
+ RETURN(E_BAD_ARGUMENT);
- for(v=value; *v && (i<len); v++,i++)
- {
- if (!isprint((unsigned char)*v))
- RETURN(E_BAD_ARGUMENT);
- }
- }
+ len = Buffer_Length(field);
if (Growable(field))
{
/* for a growable field we must assume zero terminated strings, because
- somehow we have to detect the length of what should be copied.
- */
+ somehow we have to detect the length of what should be copied.
+ */
unsigned int vlen = strlen(value);
+
if (vlen > len)
{
if (!Field_Grown(field,
- (int)(1 + (vlen-len)/((field->rows+field->nrow)*field->cols))))
+ (int)(1 + (vlen - len) / ((field->rows + field->nrow)
+ * field->cols))))
RETURN(E_SYSTEM_ERROR);
- /* in this case we also have to check, wether or not the remaining
- characters in value are also printable for buffer 0. */
- if (buffer==0)
- {
- unsigned int i;
-
- for(i=len; i<vlen; i++)
- if (!isprint((unsigned char)value[i]))
- RETURN(E_BAD_ARGUMENT);
- }
len = vlen;
}
}
-
- p = Address_Of_Nth_Buffer(field,buffer);
-#if HAVE_MEMCCPY
- s = memccpy(p,value,0,len);
-#else
- for(s=(char *)value; *s && (s < (value+len)); s++)
- p[s-value] = *s;
- if (s < (value+len))
+ p = Address_Of_Nth_Buffer(field, buffer);
+
+#if USE_WIDEC_SUPPORT
+ /*
+ * Use addstr's logic for converting a string to an array of cchar_t's.
+ * There should be a better way, but this handles nonspacing characters
+ * and other special cases that we really do not want to handle here.
+ */
+#if NCURSES_EXT_FUNCS
+ if (wresize(field->working, field->drows, field->dcols) == ERR)
+#endif
{
- p[s-value] = *s++;
- s = p + (s-value);
+ delwin(field->working);
+ field->working = newpad(field->drows, field->dcols);
}
- else
- s=(char *)0;
-#endif
+ wclear(field->working);
+ mvwaddstr(field->working, 0, 0, value);
- if (s)
- { /* this means, value was null terminated and not greater than the
- buffer. We have to pad with blanks. Please note that due to memccpy
- logic s points after the terminating null. */
- s--; /* now we point to the terminator. */
- assert(len >= (unsigned int)(s-p));
- if (len > (unsigned int)(s-p))
- memset(s,C_BLANK,len-(unsigned int)(s-p));
+ if ((widevalue = typeCalloc(FIELD_CELL, len + 1)) == 0)
+ {
+ RETURN(E_SYSTEM_ERROR);
+ }
+ else
+ {
+ for (i = 0; i < (unsigned)field->drows; ++i)
+ {
+ mvwin_wchnstr(field->working, i, 0,
+ widevalue + (i * field->dcols),
+ field->dcols);
+ }
+ for (i = 0; i < len; ++i)
+ {
+ if (CharEq(myZEROS, widevalue[i]))
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = widevalue[i];
+ }
+ free(widevalue);
}
+#else
+ for (i = 0; i < len; ++i)
+ {
+ if (value[i] == '\0')
+ {
+ while (i < len)
+ p[i++] = myBLANK;
+ break;
+ }
+ p[i] = value[i];
+ }
+#endif
- if (buffer==0)
+ if (buffer == 0)
{
int syncres;
- if (((syncres=Synchronize_Field( field ))!=E_OK) &&
- (res==E_OK))
+
+ if (((syncres = Synchronize_Field(field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
- if (((syncres=Synchronize_Linked_Fields(field ))!=E_OK) &&
- (res==E_OK))
+ if (((syncres = Synchronize_Linked_Fields(field)) != E_OK) &&
+ (res == E_OK))
res = syncres;
}
RETURN(res);
-}
+}
/*---------------------------------------------------------------------------
-| Facility : libnform
+| Facility : libnform
| Function : char *field_buffer(const FIELD *field,int buffer)
-|
+|
| Description : Return the address of the buffer for the field.
|
| Return Values : Pointer to buffer or NULL if arguments were invalid.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(char *)
-field_buffer (const FIELD * field, int buffer)
+field_buffer(const FIELD *field, int buffer)
{
+ char *result = 0;
+
+ T((T_CALLED("field_buffer(%p,%d)"), field, buffer));
+
if (field && (buffer >= 0) && (buffer <= field->nbuf))
- return Address_Of_Nth_Buffer(field,buffer);
- else
- return (char *)0;
+ {
+#if USE_WIDEC_SUPPORT
+ FIELD_CELL *data = Address_Of_Nth_Buffer(field, buffer);
+ unsigned need = 0;
+ int size = Buffer_Length(field);
+ int n;
+
+ /* determine the number of bytes needed to store the expanded string */
+ for (n = 0; n < size; ++n)
+ {
+ if (!isWidecExt(data[n]))
+ {
+ mbstate_t state;
+ size_t next;
+
+ init_mb(state);
+ next = _nc_wcrtomb(0, data[n].chars[0], &state);
+ if (!isEILSEQ(next))
+ need += next;
+ }
+ }
+
+ /* allocate a place to store the expanded string */
+ if (field->expanded[buffer] != 0)
+ free(field->expanded[buffer]);
+ field->expanded[buffer] = typeMalloc(char, need + 1);
+
+ /* expand the multibyte data */
+ if ((result = field->expanded[buffer]) != 0)
+ {
+ wclear(field->working);
+ mvwadd_wchnstr(field->working, 0, 0, data, size);
+ mvwinnstr(field->working, 0, 0, result, (int)need);
+ }
+#else
+ result = Address_Of_Nth_Buffer(field, buffer);
+#endif
+ }
+ returnPtr(result);
+}
+
+#if USE_WIDEC_SUPPORT
+
+/* FIXME: see lib_get_wch.c */
+#if HAVE_MBTOWC && HAVE_MBLEN
+#define reset_mbytes(state) mblen(NULL, 0), mbtowc(NULL, NULL, 0)
+#define count_mbytes(buffer,length,state) mblen(buffer,length)
+#define trans_mbytes(wch,buffer,length,state) \
+ (int) mbtowc(&wch, buffer, length)
+#elif HAVE_MBRTOWC && HAVE_MBRLEN
+#define NEED_STATE
+#define reset_mbytes(state) init_mb(state)
+#define count_mbytes(buffer,length,state) mbrlen(buffer,length,&state)
+#define trans_mbytes(wch,buffer,length,state) \
+ (int) mbrtowc(&wch, buffer, length, &state)
+#else
+make an error
+#endif
+
+/*---------------------------------------------------------------------------
+| Convert a multibyte string to a wide-character string. The result must be
+| freed by the caller.
++--------------------------------------------------------------------------*/
+NCURSES_EXPORT(wchar_t *)
+_nc_Widen_String(char *source, int *lengthp)
+{
+ wchar_t *result = 0;
+ wchar_t wch;
+ size_t given = strlen(source);
+ size_t tries;
+ int pass;
+ int status;
+
+#ifdef NEED_STATE
+ mbstate_t state;
+#endif
+
+ for (pass = 0; pass < 2; ++pass)
+ {
+ unsigned need = 0;
+ size_t passed = 0;
+
+ while (passed < given)
+ {
+ bool found = FALSE;
+
+ for (tries = 1, status = 0; tries <= (given - passed); ++tries)
+ {
+ int save = source[passed + tries];
+
+ source[passed + tries] = 0;
+ reset_mbytes(state);
+ status = trans_mbytes(wch, source + passed, tries, state);
+ source[passed + tries] = save;
+
+ if (status > 0)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ {
+ if (pass)
+ {
+ result[need] = wch;
+ }
+ passed += status;
+ ++need;
+ }
+ else
+ {
+ if (pass)
+ {
+ result[need] = source[passed];
+ }
+ ++need;
+ ++passed;
+ }
+ }
+
+ if (!pass)
+ {
+ if (!need)
+ break;
+ result = typeCalloc(wchar_t, need);
+
+ *lengthp = need;
+ if (result == 0)
+ break;
+ }
+ }
+
+ return result;
}
+#endif
/* frm_driver.c ends here */
diff --git a/lib/libform/frm_hook.c b/lib/libform/frm_hook.c
index 8b4c3dfc8e5..540aab8ff74 100644
--- a/lib/libform/frm_hook.c
+++ b/lib/libform/frm_hook.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_hook.c,v 1.6 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,17 +27,18 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_hook.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_hook.c,v 1.7 2010/01/12 23:22:07 nicm 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);\
}
@@ -48,95 +47,96 @@ NCURSES_IMPEXP int NCURSES_API set_ ## typ ## _ ## name (FORM *form, Form_Hook f
#define GEN_HOOK_GET_FUNCTION( typ, name ) \
NCURSES_IMPEXP Form_Hook NCURSES_API typ ## _ ## name ( const FORM *form )\
{\
- return ( Normalize_Form( form ) -> typ ## name );\
+ T((T_CALLED(#typ "_" #name "(%p)"), form));\
+ returnFormHook( Normalize_Form( form ) -> typ ## name );\
}
-
+
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_SET_FUNCTION(field, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_GET_FUNCTION(field, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_SET_FUNCTION(field, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_GET_FUNCTION(field, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_SET_FUNCTION(form, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_GET_FUNCTION(form, init)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_SET_FUNCTION(form, term)
/*---------------------------------------------------------------------------
-| Facility : libnform
+| 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)
+GEN_HOOK_GET_FUNCTION(form, term)
/* frm_hook.c ends here */
diff --git a/lib/libform/frm_opts.c b/lib/libform/frm_opts.c
index 300493d518e..0c00cb3c23d 100644
--- a/lib/libform/frm_opts.c
+++ b/lib/libform/frm_opts.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_opts.c,v 1.7 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2004,2005 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_opts.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_opts.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,14 +45,16 @@ MODULE_ID("$From: frm_opts.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_opts (FORM * form, Form_Options opts)
+set_form_opts(FORM *form, Form_Options opts)
{
+ T((T_CALLED("set_form_opts(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Form( form )->opts = opts;
+ Normalize_Form(form)->opts = opts;
RETURN(E_OK);
}
}
@@ -68,9 +68,10 @@ set_form_opts (FORM * form, Form_Options opts)
| Return Values : The option flags.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(Form_Options)
-form_opts (const FORM * form)
+form_opts(const FORM *form)
{
- return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
+ T((T_CALLED("form_opts(%p)"), form));
+ returnCode((int)(Normalize_Form(form)->opts & ALL_FORM_OPTS));
}
/*---------------------------------------------------------------------------
@@ -84,14 +85,16 @@ form_opts (const FORM * form)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_opts_on (FORM * form, Form_Options opts)
+form_opts_on(FORM *form, Form_Options opts)
{
+ T((T_CALLED("form_opts_on(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
else
{
- Normalize_Form( form )->opts |= opts;
+ Normalize_Form(form)->opts |= opts;
RETURN(E_OK);
}
}
@@ -107,8 +110,10 @@ form_opts_on (FORM * form, Form_Options opts)
| E_BAD_ARGUMENT - invalid options
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_opts_off (FORM * form, Form_Options opts)
+form_opts_off(FORM *form, Form_Options opts)
{
+ T((T_CALLED("form_opts_off(%p,%d)"), form, opts));
+
opts &= ALL_FORM_OPTS;
if (opts & ~ALL_FORM_OPTS)
RETURN(E_BAD_ARGUMENT);
diff --git a/lib/libform/frm_page.c b/lib/libform/frm_page.c
index fbad21e25cf..5aa3892729b 100644
--- a/lib/libform/frm_page.c
+++ b/lib/libform/frm_page.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_page.c,v 1.4 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_page.c,v 1.6 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_page.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,35 +47,37 @@ MODULE_ID("$From: frm_page.c,v 1.6 2000/12/10 02:09:37 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_page (FORM * form, int page)
+set_form_page(FORM *form, int page)
{
int err = E_OK;
- if ( !form || (page<0) || (page>=form->maxpage) )
+ T((T_CALLED("set_form_page(%p,%d)"), 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)
+ if (form->status & _IN_DRIVER)
err = E_BAD_STATE;
else
{
if (form->curpage != page)
{
- if (!_nc_Internal_Validation(form))
+ 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);
+ 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);
}
}
@@ -96,9 +96,11 @@ set_form_page (FORM * form, int page)
| -1 : invalid form pointer
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_page (const FORM * form)
+form_page(const FORM *form)
{
- return Normalize_Form(form)->curpage;
+ T((T_CALLED("form_page(%p)"), form));
+
+ returnCode(Normalize_Form(form)->curpage);
}
/* frm_page.c ends here */
diff --git a/lib/libform/frm_post.c b/lib/libform/frm_post.c
index 4027c5f29f8..b3bfc913d5c 100644
--- a/lib/libform/frm_post.c
+++ b/lib/libform/frm_post.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_post.c,v 1.4 2001/01/22 18:02:15 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,11 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
+
#include "form.priv.h"
-MODULE_ID("$From: frm_post.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_post.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -49,37 +48,39 @@ MODULE_ID("$From: frm_post.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_SYSTEM_ERROR - system error
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-post_form (FORM * form)
+post_form(FORM *form)
{
WINDOW *formwin;
int err;
int page;
+ T((T_CALLED("post_form(%p)"), form));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (form->status & _POSTED)
+ 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)))
+ 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)
+ 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);
+ Call_Hook(form, forminit);
+ Call_Hook(form, fieldinit);
_nc_Refresh_Current_Field(form);
RETURN(E_OK);
@@ -97,19 +98,21 @@ post_form (FORM * form)
| E_BAD_STATE - called from a hook routine
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-unpost_form (FORM * form)
+unpost_form(FORM *form)
{
+ T((T_CALLED("unpost_form(%p)"), form));
+
if (!form)
RETURN(E_BAD_ARGUMENT);
- if (!(form->status & _POSTED))
+ if (!(form->status & _POSTED))
RETURN(E_NOT_POSTED);
- if (form->status & _IN_DRIVER)
+ if (form->status & _IN_DRIVER)
RETURN(E_BAD_STATE);
- Call_Hook(form,fieldterm);
- Call_Hook(form,formterm);
+ Call_Hook(form, fieldterm);
+ Call_Hook(form, formterm);
werase(Get_Form_Window(form));
delwin(form->w);
diff --git a/lib/libform/frm_req_name.c b/lib/libform/frm_req_name.c
index 069fe6df1d6..898283ed65d 100644
--- a/lib/libform/frm_req_name.c
+++ b/lib/libform/frm_req_name.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_req_name.c,v 1.5 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2005,2008 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 *
@@ -29,7 +27,7 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
/***************************************************************************
@@ -39,71 +37,73 @@
#include "form.priv.h"
-MODULE_ID("$From: frm_req_name.c,v 1.8 2000/12/10 02:09:37 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"
+MODULE_ID("$Id: frm_req_name.c,v 1.6 2010/01/12 23:22:07 nicm 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]))
/*---------------------------------------------------------------------------
@@ -116,18 +116,19 @@ static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
| NULL - on invalid request code
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(const char *)
-form_request_name ( int request )
+form_request_name(int request)
{
- if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
+ T((T_CALLED("form_request_name(%d)"), request));
+
+ if ((request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND))
{
- SET_ERROR (E_BAD_ARGUMENT);
- return (const char *)0;
+ SET_ERROR(E_BAD_ARGUMENT);
+ returnCPtr((const char *)0);
}
else
- return request_names[ request - MIN_FORM_COMMAND ];
+ returnCPtr(request_names[request - MIN_FORM_COMMAND]);
}
-
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int form_request_by_name (const char *str);
@@ -138,28 +139,30 @@ form_request_name ( int request )
| E_NO_MATCH - request not found
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-form_request_by_name ( const char *str )
-{
+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') )
+ strncpy(buf, str, sizeof(buf));
+ while ((i < sizeof(buf)) && (buf[i] != '\0'))
{
- buf[i] = toupper(buf[i]);
+ buf[i] = toupper(UChar(buf[i]));
i++;
}
-
- for (i=0; i < A_SIZE; i++)
+
+ for (i = 0; i < A_SIZE; i++)
{
- if (strncmp(request_names[i],buf,sizeof(buf))==0)
- return MIN_FORM_COMMAND + i;
- }
+ if (strncmp(request_names[i], buf, sizeof(buf)) == 0)
+ returnCode(MIN_FORM_COMMAND + (int) i);
+ }
}
RETURN(E_NO_MATCH);
}
diff --git a/lib/libform/frm_scale.c b/lib/libform/frm_scale.c
index 45ef3c1c8a3..cd76e6ac7e4 100644
--- a/lib/libform/frm_scale.c
+++ b/lib/libform/frm_scale.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_scale.c,v 1.4 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_scale.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_scale.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -47,19 +45,21 @@ MODULE_ID("$From: frm_scale.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_NOT_CONNECTED - no fields connected to form
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-scale_form (const FORM * form, int * rows, int * cols)
+scale_form(const FORM *form, int *rows, int *cols)
{
- if ( !form )
+ T((T_CALLED("scale_form(%p,%p,%p)"), form, rows, cols));
+
+ if (!form)
RETURN(E_BAD_ARGUMENT);
- if ( !(form->field) )
+ if (!(form->field))
RETURN(E_NOT_CONNECTED);
-
- if (rows)
+
+ if (rows)
*rows = form->rows;
- if (cols)
+ if (cols)
*cols = form->cols;
-
+
RETURN(E_OK);
}
diff --git a/lib/libform/frm_sub.c b/lib/libform/frm_sub.c
index 6a6f50278b5..0a1f9336cc1 100644
--- a/lib/libform/frm_sub.c
+++ b/lib/libform/frm_sub.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_sub.c,v 1.4 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_sub.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_sub.c,v 1.5 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,14 +44,16 @@ MODULE_ID("$From: frm_sub.c,v 1.5 2000/12/10 02:09:37 tom Exp $")
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_sub (FORM * form, WINDOW * win)
+set_form_sub(FORM *form, WINDOW *win)
{
- if (form && (form->status & _POSTED))
+ T((T_CALLED("set_form_sub(%p,%p)"), form, win));
+
+ if (form && (form->status & _POSTED))
RETURN(E_POSTED);
- Normalize_Form( form )->sub = win;
+ Normalize_Form(form)->sub = win;
RETURN(E_OK);
-}
+}
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -64,10 +64,14 @@ set_form_sub (FORM * form, WINDOW * win)
| Return Values : The pointer to the Subwindow.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-form_sub (const FORM * form)
+form_sub(const FORM *form)
{
- const FORM* f = Normalize_Form( form );
- return Get_Form_Window(f);
+ const FORM *f;
+
+ T((T_CALLED("form_sub(%p)"), form));
+
+ f = Normalize_Form(form);
+ returnWin(Get_Form_Window(f));
}
/* frm_sub.c ends here */
diff --git a/lib/libform/frm_user.c b/lib/libform/frm_user.c
index 96bfab481ab..75b27457d87 100644
--- a/lib/libform/frm_user.c
+++ b/lib/libform/frm_user.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_user.c,v 1.6 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_user.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_user.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,8 +44,10 @@ MODULE_ID("$From: frm_user.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_userptr (FORM * form, void *usrptr)
+set_form_userptr(FORM *form, void *usrptr)
{
+ T((T_CALLED("set_form_userptr(%p,%p)"), form, usrptr));
+
Normalize_Form(form)->usrptr = usrptr;
RETURN(E_OK);
}
@@ -63,9 +63,10 @@ set_form_userptr (FORM * form, void *usrptr)
| NULL is returned
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(void *)
-form_userptr (const FORM * form)
+form_userptr(const FORM *form)
{
- return Normalize_Form(form)->usrptr;
+ T((T_CALLED("form_userptr(%p)"), form));
+ returnVoidPtr(Normalize_Form(form)->usrptr);
}
/* frm_user.c ends here */
diff --git a/lib/libform/frm_win.c b/lib/libform/frm_win.c
index d428b6d274c..eb1d64a755c 100644
--- a/lib/libform/frm_win.c
+++ b/lib/libform/frm_win.c
@@ -1,7 +1,5 @@
-/* $OpenBSD: frm_win.c,v 1.6 2001/01/22 18:02:16 millert Exp $ */
-
/****************************************************************************
- * Copyright (c) 1998,2000 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2003,2004 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 *
@@ -29,12 +27,12 @@
****************************************************************************/
/****************************************************************************
- * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
+ * Author: Juergen Pfeifer, 1995,1997 *
****************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: frm_win.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
+MODULE_ID("$Id: frm_win.c,v 1.7 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -46,14 +44,16 @@ MODULE_ID("$From: frm_win.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
| E_POSTED - form is posted
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(int)
-set_form_win (FORM * form, WINDOW * win)
+set_form_win(FORM *form, WINDOW *win)
{
- if (form && (form->status & _POSTED))
+ T((T_CALLED("set_form_win(%p,%p)"), form, win));
+
+ if (form && (form->status & _POSTED))
RETURN(E_POSTED);
- Normalize_Form( form )->win = win;
+ Normalize_Form(form)->win = win;
RETURN(E_OK);
-}
+}
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -64,11 +64,14 @@ set_form_win (FORM * form, WINDOW * win)
| Return Values : The pointer to the Window or stdscr if there is none.
+--------------------------------------------------------------------------*/
NCURSES_EXPORT(WINDOW *)
-form_win (const FORM * form)
+form_win(const FORM *form)
{
- const FORM* f = Normalize_Form( form );
- return (f->win ? f->win : stdscr);
+ const FORM *f;
+
+ T((T_CALLED("form_win(%p)"), form));
+
+ f = Normalize_Form(form);
+ returnWin(f->win ? f->win : stdscr);
}
/* frm_win.c ends here */
-
diff --git a/lib/libform/fty_alnum.c b/lib/libform/fty_alnum.c
index 61a4fb7ab78..f25b094edc7 100644
--- a/lib/libform/fty_alnum.c
+++ b/lib/libform/fty_alnum.c
@@ -1,139 +1,167 @@
-/* $OpenBSD: fty_alnum.c,v 1.7 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_alnum.c,v 1.10 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_alnum.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#define thisARG alnumARG
-typedef struct {
- int width;
-} alnumARG;
+typedef struct
+ {
+ int width;
+ }
+thisARG;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_AlphaNumeric_Type(va_list *ap)
-|
+| 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_AlphaNumeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- alnumARG *argp = (alnumARG *)malloc(sizeof(alnumARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
if (argp)
- argp->width = va_arg(*ap,int);
+ {
+ T((T_CREATE("thisARG %p"), argp));
+ argp->width = va_arg(*ap, int);
+ }
return ((void *)argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_AlphaNumericType(const void *argp)
-|
-| Description : Copy structure for alphanumeric type argument.
+| 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_AlphaNumeric_Type(const void *argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const alnumARG *ap = (const alnumARG *)argp;
- alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG));
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
return ((void *)result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_AlphaNumeric_Type(void *argp)
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
| Description : Free structure for alphanumeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_AlphaNumeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_AlphaNumeric_Field(
-| FIELD *field,
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
| const void *argp)
-|
-| Description : Validate buffer content to be a valid alphanumeric value
|
-| Return Values : TRUE - field is valid
-| FALSE - field is invalid
+| Description : Check a character for the alphanumeric type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- int width = ((const alnumARG *)argp)->width;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- int l = -1;
- unsigned char *s;
-
- while(*bp==' ')
- bp++;
- if (*bp)
- {
- s = bp;
- while(isalnum(*bp))
- bp++;
- l = (int)(bp-s);
- while(*bp==' ')
- bp++;
- }
- return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+ if (iswalnum((wint_t) c))
+ return TRUE;
+#endif
+ return (isalnum(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_AlphaNumeric_Character(
-| int c,
-| const void *argp )
-|
-| Description : Check a character for the alphanumeric type.
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
|
-| Return Values : TRUE - character is valid
-| FALSE - character is invalid
+| Description : Validate buffer content to be a valid alphanumeric value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- return (isalnum(c) ? TRUE : FALSE);
+ 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 typeALNUM = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_AlphaNumeric_Type,
- Copy_AlphaNumeric_Type,
- Free_AlphaNumeric_Type,
- Check_AlphaNumeric_Field,
- Check_AlphaNumeric_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeALNUM;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALNUM = &typeTHIS;
/* fty_alnum.c ends here */
diff --git a/lib/libform/fty_alpha.c b/lib/libform/fty_alpha.c
index 34b2a4b4fe8..3587e911138 100644
--- a/lib/libform/fty_alpha.c
+++ b/lib/libform/fty_alpha.c
@@ -1,140 +1,167 @@
-/* $OpenBSD: fty_alpha.c,v 1.7 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_alpha.c,v 1.10 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_alpha.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#define thisARG alphaARG
-typedef struct {
- int width;
-} alphaARG;
+typedef struct
+ {
+ int width;
+ }
+thisARG;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_Alpha_Type(va_list *ap)
-|
+| 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_Alpha_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- alphaARG *argp = (alphaARG *)malloc(sizeof(alphaARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
+
if (argp)
{
- argp->width = va_arg(*ap,int);
+ T((T_CREATE("thisARG %p"), argp));
+ argp->width = va_arg(*ap, int);
}
+
return ((void *)argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_Alpha_Type(const void * argp)
-|
-| Description : Copy structure for alpha type argument.
+| 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_Alpha_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const alphaARG *ap = (const alphaARG *)argp;
- alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG));
-
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = typeMalloc(thisARG, 1);
+
if (result)
{
+ T((T_CREATE("thisARG %p"), result));
*result = *ap;
}
+
return ((void *)result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_Alpha_Type( void * argp )
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void *argp)
+|
| Description : Free structure for alpha type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Alpha_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Alpha_Field(
-| FIELD * field,
-| const void * argp)
-|
-| Description : Validate buffer content to be a valid alpha value
+| Facility : libnform
+| Function : static bool Check_This_Character(
+| int c,
+| const void *argp)
|
-| Return Values : TRUE - field is valid
-| FALSE - field is invalid
+| Description : Check a character for the alpha type.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Alpha_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- int width = ((const alphaARG *)argp)->width;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- int l = -1;
- unsigned char *s;
-
- while(*bp==' ')
- bp++;
- if (*bp)
- {
- s = bp;
- while(isalpha(*bp))
- bp++;
- l = (int)(bp-s);
- while(*bp==' ')
- bp++;
- }
- return ((*bp || (l < width)) ? FALSE : TRUE);
+#if USE_WIDEC_SUPPORT
+ if (iswalpha((wint_t) c))
+ return TRUE;
+#endif
+ return (isalpha(UChar(c)) ? TRUE : FALSE);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Alpha_Character(
-| int c,
-| const void * argp)
-|
-| Description : Check a character for the alpha type.
+| Facility : libnform
+| Function : static bool Check_This_Field(
+| FIELD *field,
+| const void *argp)
|
-| Return Values : TRUE - character is valid
-| FALSE - character is invalid
+| Description : Validate buffer content to be a valid alpha value
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- return (isalpha(c) ? TRUE : FALSE);
+ 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 typeALPHA = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Alpha_Type,
- Copy_Alpha_Type,
- Free_Alpha_Type,
- Check_Alpha_Field,
- Check_Alpha_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeALPHA;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ALPHA = &typeTHIS;
/* fty_alpha.c ends here */
diff --git a/lib/libform/fty_enum.c b/lib/libform/fty_enum.c
index adf61a7c384..4c9201b4cf0 100644
--- a/lib/libform/fty_enum.c
+++ b/lib/libform/fty_enum.c
@@ -1,28 +1,49 @@
-/* $OpenBSD: fty_enum.c,v 1.9 2001/01/22 18:02:17 millert Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_enum.c,v 1.15 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_enum.c,v 1.10 2010/01/12 23:22:07 nicm Exp $")
-typedef struct {
- char **kwds;
- int count;
- bool checkcase;
- bool checkunique;
-} enumARG;
+typedef struct
+ {
+ char **kwds;
+ int count;
+ bool checkcase;
+ bool checkunique;
+ }
+enumARG;
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -32,9 +53,10 @@ typedef struct {
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_Enum_Type(va_list * ap)
+static void *
+Make_Enum_Type(va_list *ap)
{
- enumARG *argp = (enumARG *)malloc(sizeof(enumARG));
+ enumARG *argp = typeMalloc(enumARG, 1);
if (argp)
{
@@ -42,14 +64,17 @@ static void *Make_Enum_Type(va_list * ap)
char **kp = (char **)0;
int ccase, cunique;
- argp->kwds = va_arg(*ap,char **);
- ccase = va_arg(*ap,int);
- cunique = va_arg(*ap,int);
- argp->checkcase = ccase ? TRUE : FALSE;
+ T((T_CREATE("enumARG %p"), argp));
+ argp->kwds = va_arg(*ap, char **);
+ ccase = va_arg(*ap, int);
+ cunique = va_arg(*ap, int);
+
+ argp->checkcase = ccase ? TRUE : FALSE;
argp->checkunique = cunique ? TRUE : FALSE;
kp = argp->kwds;
- while( kp && (*kp++) ) cnt++;
+ while (kp && (*kp++))
+ cnt++;
argp->count = cnt;
}
return (void *)argp;
@@ -63,7 +88,8 @@ static void *Make_Enum_Type(va_list * ap)
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_Enum_Type(const void * argp)
+static void *
+Copy_Enum_Type(const void *argp)
{
enumARG *result = (enumARG *)0;
@@ -71,9 +97,13 @@ static void *Copy_Enum_Type(const void * argp)
{
const enumARG *ap = (const enumARG *)argp;
- result = (enumARG *)malloc(sizeof(enumARG));
+ result = typeMalloc(enumARG, 1);
+
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("enumARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
@@ -86,9 +116,10 @@ static void *Copy_Enum_Type(const void * argp)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Enum_Type(void * argp)
+static void
+Free_Enum_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
@@ -103,37 +134,40 @@ static void Free_Enum_Type(void * argp)
| const unsigned char * buf,
| bool ccase )
|
-| Description : Check wether or not the text in 'buf' matches the
+| 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)
+static int
+Compare(const unsigned char *s, const unsigned char *buf,
+ bool ccase)
{
- SKIP_SPACE(buf); /* Skip leading spaces in both texts */
+ SKIP_SPACE(buf); /* Skip leading spaces in both texts */
SKIP_SPACE(s);
- if (*buf=='\0')
+ if (*buf == '\0')
{
- return (((*s)!='\0') ? NOMATCH : EXACT);
- }
- else
+ return (((*s) != '\0') ? NOMATCH : EXACT);
+ }
+ else
{
if (ccase)
{
- while(*s++ == *buf)
+ while (*s++ == *buf)
{
- if (*buf++=='\0') return EXACT;
- }
- }
- else
+ if (*buf++ == '\0')
+ return EXACT;
+ }
+ }
+ else
{
- while(toupper(*s++)==toupper(*buf))
+ while (toupper(*s++) == toupper(*buf))
{
- if (*buf++=='\0') return EXACT;
+ if (*buf++ == '\0')
+ return EXACT;
}
}
}
@@ -141,12 +175,12 @@ static int Compare(const unsigned char *s, const unsigned char *buf,
matches with s. So if only blanks are following, we have a partial
match otherwise there is no match */
SKIP_SPACE(buf);
- if (*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);
+ return ((s[-1] != '\0') ? PARTIAL : EXACT);
}
/*---------------------------------------------------------------------------
@@ -160,27 +194,28 @@ static int Compare(const unsigned char *s, const unsigned char *buf,
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Enum_Field(FIELD * field, const void * argp)
+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 **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++)) )
+
+ while (kwds && (s = (*kwds++)))
{
- if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH)
+ if ((res = Compare((unsigned char *)s, bp, ccase)) != NOMATCH)
{
- p=t=s; /* t is at least a partial match */
- if ((unique && res!=EXACT))
+ p = t = s; /* t is at least a partial match */
+ if ((unique && res != EXACT))
{
- while( kwds && (p = *kwds++) )
+ while (kwds && (p = *kwds++))
{
- if ((res=Compare((unsigned char *)p,bp,ccase))!=NOMATCH)
+ if ((res = Compare((unsigned char *)p, bp, ccase)) != NOMATCH)
{
- if (res==EXACT)
+ if (res == EXACT)
{
t = p;
break;
@@ -189,10 +224,10 @@ static bool Check_Enum_Field(FIELD * field, const void * argp)
t = (char *)0;
}
}
- }
+ }
if (t)
{
- set_field_buffer(field,0,t);
+ set_field_buffer(field, 0, t);
return TRUE;
}
if (!p)
@@ -202,7 +237,8 @@ static bool Check_Enum_Field(FIELD * field, const void * argp)
return FALSE;
}
-static const char *dummy[] = { (char *)0 };
+static const char *dummy[] =
+{(char *)0};
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -214,28 +250,30 @@ static const char *dummy[] = { (char *)0 };
| Return Values : TRUE - next value found and loaded
| FALSE - no next value loaded
+--------------------------------------------------------------------------*/
-static bool Next_Enum(FIELD * field, const void * argp)
+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);
+ 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;
- }
- }
+ 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;
}
@@ -250,37 +288,39 @@ static bool Next_Enum(FIELD * field, const void * argp)
| Return Values : TRUE - previous value found and loaded
| FALSE - no previous value loaded
+--------------------------------------------------------------------------*/
-static bool Previous_Enum(FIELD * field, const void * argp)
+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);
+ 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;
- }
- }
+ 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 = {
+static FIELDTYPE typeENUM =
+{
_HAS_ARGS | _HAS_CHOICE | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_Enum_Type,
@@ -292,6 +332,7 @@ static FIELDTYPE typeENUM = {
Previous_Enum
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_ENUM = &typeENUM;
+NCURSES_EXPORT_VAR(FIELDTYPE *)
+TYPE_ENUM = &typeENUM;
/* fty_enum.c ends here */
diff --git a/lib/libform/fty_int.c b/lib/libform/fty_int.c
index 5cc185e5e5c..7b7848608df 100644
--- a/lib/libform/fty_int.c
+++ b/lib/libform/fty_int.c
@@ -1,135 +1,217 @@
-/* $OpenBSD: fty_int.c,v 1.7 2003/04/05 13:41:43 espie Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_int.c,v 1.11 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_int.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
+
+#if USE_WIDEC_SUPPORT
+#define isDigit(c) (iswdigit((wint_t)(c)) || isdigit(UChar(c)))
+#else
+#define isDigit(c) isdigit(UChar(c))
+#endif
-typedef struct {
- int precision;
- long low;
- long high;
-} integerARG;
+#define thisARG integerARG
+
+typedef struct
+ {
+ int precision;
+ long low;
+ long high;
+ }
+thisARG;
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void *Make_Integer_Type( va_list * ap )
+| 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_Integer_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- integerARG *argp = (integerARG *)malloc(sizeof(integerARG));
+ thisARG *argp = typeMalloc(thisARG, 1);
if (argp)
{
- argp->precision = va_arg(*ap,int);
- argp->low = va_arg(*ap,long);
- argp->high = va_arg(*ap,long);
+ T((T_CREATE("thisARG %p"), argp));
+ argp->precision = va_arg(*ap, int);
+ argp->low = va_arg(*ap, long);
+ argp->high = va_arg(*ap, long);
}
return (void *)argp;
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void *Copy_Integer_Type(const void * argp)
+| 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_Integer_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const integerARG *ap = (const integerARG *)argp;
- integerARG *result = (integerARG *)0;
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
if (argp)
{
- result = (integerARG *)malloc(sizeof(integerARG));
+ result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static void Free_Integer_Type(void * argp)
+| Function : static void Free_This_Type(void * argp)
|
| Description : Free structure for integer type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Integer_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Integer_Field(
-| FIELD * field,
-| const void * argp)
+| 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_Integer_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- const integerARG *argi = (const integerARG *)argp;
- long low = argi->low;
- long high = argi->high;
- int prec = argi->precision;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- char *s = (char *)bp;
+ 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++;
+ while (*bp && *bp == ' ')
+ bp++;
if (*bp)
{
- if (*bp=='-') 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(*bp)) break;
+ if (!isdigit(UChar(*bp)))
+ break;
bp++;
}
- while(*bp && *bp==' ') bp++;
- if (*bp=='\0')
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
{
val = atol(s);
- if (low<high)
+ if (low < high)
{
- if (val<low || val>high) return FALSE;
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
+ {
+ snprintf(buf, sizeof(buf), "%.*ld", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
}
- snprintf(buf, sizeof(buf), "%.*ld",(prec>0?prec:0),val);
- set_field_buffer(field,0,buf);
- return TRUE;
}
}
- return FALSE;
+ return (result);
}
/*---------------------------------------------------------------------------
| Facility : libnform
-| Function : static bool Check_Integer_Character(
+| Function : static bool Check_This_Character(
| int c,
| const void * argp)
|
@@ -138,25 +220,27 @@ static bool Check_Integer_Field(FIELD * field, const void * argp)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_This_Character(int c, const void *argp GCC_UNUSED)
{
- return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
+ return ((isDigit(UChar(c)) || (c == '-')) ? TRUE : FALSE);
}
-static FIELDTYPE typeINTEGER = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Integer_Type,
- Copy_Integer_Type,
- Free_Integer_Type,
- Check_Integer_Field,
- Check_Integer_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeINTEGER;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_INTEGER = &typeTHIS;
/* fty_int.c ends here */
diff --git a/lib/libform/fty_ipv4.c b/lib/libform/fty_ipv4.c
index 0cd429fdefa..d47655ef7cb 100644
--- a/lib/libform/fty_ipv4.c
+++ b/lib/libform/fty_ipv4.c
@@ -1,12 +1,31 @@
-/* $OpenBSD: fty_ipv4.c,v 1.5 2007/03/20 03:40:05 tedu Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2004,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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
* Author : Per Foreby, perf@efd.lth.se *
@@ -15,7 +34,7 @@
#include "form.priv.h"
-MODULE_ID("$From: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_ipv4.c,v 1.6 2010/01/12 23:22:07 nicm Exp $")
/*---------------------------------------------------------------------------
| Facility : libnform
@@ -28,24 +47,25 @@ MODULE_ID("$From: fty_ipv4.c,v 1.4 2000/12/09 23:46:12 tom Exp $")
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Field(FIELD *field, const void *argp GCC_UNUSED)
{
- char *bp = field_buffer(field,0);
+ char *bp = field_buffer(field, 0);
int num = 0, len;
unsigned int d1, d2, d3, d4;
- if(isdigit((unsigned char)*bp)) /* Must start with digit */
+ 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((unsigned char)*bp))
- bp++; /* Allow trailing whitespace */
- }
+ {
+ 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);
+ || d3 > 255 || d4 > 255) ? FALSE : TRUE);
}
/*---------------------------------------------------------------------------
@@ -59,14 +79,16 @@ static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
+static bool
+Check_IPV4_Character(int c, const void *argp GCC_UNUSED)
{
- return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
+ return ((isdigit(UChar(c)) || (c == '.')) ? TRUE : FALSE);
}
-static FIELDTYPE typeIPV4 = {
+static FIELDTYPE typeIPV4 =
+{
_RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
NULL,
diff --git a/lib/libform/fty_num.c b/lib/libform/fty_num.c
index c3bf889dc29..cafd6a504ce 100644
--- a/lib/libform/fty_num.c
+++ b/lib/libform/fty_num.c
@@ -1,197 +1,290 @@
-/* $OpenBSD: fty_num.c,v 1.7 2003/04/05 13:41:43 espie Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_num.c,v 1.14 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_num.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
#if HAVE_LOCALE_H
#include <locale.h>
#endif
-typedef struct {
- int precision;
- double low;
- double high;
- struct lconv* L;
-} numericARG;
+#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;
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Make_Numeric_Type(va_list * ap)
-|
+| 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_Numeric_Type(va_list * ap)
+static void *
+Make_This_Type(va_list *ap)
{
- numericARG *argn = (numericARG *)malloc(sizeof(numericARG));
+ thisARG *argn = typeMalloc(thisARG, 1);
if (argn)
{
- argn->precision = va_arg(*ap,int);
- argn->low = va_arg(*ap,double);
- argn->high = va_arg(*ap,double);
+ T((T_CREATE("thisARG %p"), argn));
+ argn->precision = va_arg(*ap, int);
+ argn->low = va_arg(*ap, double);
+ argn->high = va_arg(*ap, double);
+
#if HAVE_LOCALE_H
- argn->L = localeconv();
+ argn->L = localeconv();
#else
- argn->L = NULL;
+ argn->L = NULL;
#endif
}
return (void *)argn;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void *Copy_Numeric_Type(const void * argp)
-|
-| Description : Copy structure for numeric type argument.
+| 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_Numeric_Type(const void * argp)
+static void *
+Copy_This_Type(const void *argp)
{
- const numericARG *ap = (const numericARG *)argp;
- numericARG *result = (numericARG *)0;
+ const thisARG *ap = (const thisARG *)argp;
+ thisARG *result = (thisARG *) 0;
if (argp)
{
- result = (numericARG *)malloc(sizeof(numericARG));
+ result = typeMalloc(thisARG, 1);
if (result)
- *result = *ap;
+ {
+ T((T_CREATE("thisARG %p"), result));
+ *result = *ap;
+ }
}
return (void *)result;
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static void Free_Numeric_Type(void * argp)
-|
+| Facility : libnform
+| Function : static void Free_This_Type(void * argp)
+|
| Description : Free structure for numeric type argument.
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_Numeric_Type(void * argp)
+static void
+Free_This_Type(void *argp)
{
- if (argp)
+ if (argp)
free(argp);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Numeric_Field(FIELD * field,
-| const void * 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_Numeric_Field(FIELD * field, const void * argp)
+static bool
+Check_This_Field(FIELD *field, const void *argp)
{
- const numericARG *argn = (const numericARG *)argp;
- double low = argn->low;
- double high = argn->high;
- int prec = argn->precision;
- unsigned char *bp = (unsigned char *)field_buffer(field,0);
- char *s = (char *)bp;
- double val = 0.0;
- struct lconv* L = argn->L;
+ 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++;
+ while (*bp && *bp == ' ')
+ bp++;
if (*bp)
{
- if (*bp=='-' || *bp=='+')
+ if (*bp == '-' || *bp == '+')
bp++;
- while(*bp)
+#if USE_WIDEC_SUPPORT
+ if (*bp)
{
- if (!isdigit(*bp)) break;
+ 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 (*bp==(
-#if HAVE_LOCALE_H
- (L && L->decimal_point) ? *(L->decimal_point) :
-#endif
- '.'))
+ if (isDecimalPoint(*bp))
{
bp++;
- while(*bp)
+ while (*bp)
{
- if (!isdigit(*bp)) break;
+ if (!isdigit(UChar(*bp)))
+ break;
bp++;
}
}
- while(*bp && *bp==' ') bp++;
- if (*bp=='\0')
+ while (*bp && *bp == ' ')
+ bp++;
+ result = (*bp == '\0');
+#endif
+ if (result)
{
val = atof(s);
- if (low<high)
+ if (low < high)
+ {
+ if (val < low || val > high)
+ result = FALSE;
+ }
+ if (result)
{
- if (val<low || val>high) return FALSE;
+ snprintf(buf, sizeof(buf), "%.*f", (prec > 0 ? prec : 0), val);
+ set_field_buffer(field, 0, buf);
}
- snprintf(buf, sizeof(buf), "%.*f",(prec>0?prec:0),val);
- set_field_buffer(field,0,buf);
- return TRUE;
}
}
- return FALSE;
+ return (result);
}
/*---------------------------------------------------------------------------
-| Facility : libnform
-| Function : static bool Check_Numeric_Character(
+| 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_Numeric_Character(int c, const void * argp)
+static bool
+Check_This_Character(int c, const void *argp)
{
- const numericARG *argn = (const numericARG *)argp;
- struct lconv* L = argn->L;
+ const thisARG *argn = (const thisARG *)argp;
+ struct lconv *L = argn->L;
- return (isdigit(c) ||
- c == '+' ||
- c == '-' ||
- c == (
-#if HAVE_LOCALE_H
- (L && L->decimal_point) ? *(L->decimal_point) :
-#endif
- '.')
- ) ? TRUE : FALSE;
+ return ((isDigit(c) ||
+ c == '+' ||
+ c == '-' ||
+ isDecimalPoint(c))
+ ? TRUE
+ : FALSE);
}
-static FIELDTYPE typeNUMERIC = {
+static FIELDTYPE typeTHIS =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
- Make_Numeric_Type,
- Copy_Numeric_Type,
- Free_Numeric_Type,
- Check_Numeric_Field,
- Check_Numeric_Character,
+ Make_This_Type,
+ Copy_This_Type,
+ Free_This_Type,
+ Check_This_Field,
+ Check_This_Character,
NULL,
NULL
};
-NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeNUMERIC;
+NCURSES_EXPORT_VAR(FIELDTYPE*) TYPE_NUMERIC = &typeTHIS;
/* fty_num.c ends here */
diff --git a/lib/libform/fty_regex.c b/lib/libform/fty_regex.c
index 8910777da19..28b94e42731 100644
--- a/lib/libform/fty_regex.c
+++ b/lib/libform/fty_regex.c
@@ -1,45 +1,67 @@
-/* $OpenBSD: fty_regex.c,v 1.7 2001/01/22 18:02:17 millert Exp $ */
+/****************************************************************************
+ * Copyright (c) 1998-2006,2007 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. *
+ ****************************************************************************/
-
-/*
- * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
- * You may freely copy it for use as a template for your own field types.
- * If you develop a field type that might be of general use, please send
- * it back to the ncurses maintainers for inclusion in the next version.
- */
/***************************************************************************
* *
-* Author : Juergen Pfeifer, juergen.pfeifer@gmx.net *
+* Author : Juergen Pfeifer *
* *
***************************************************************************/
#include "form.priv.h"
-MODULE_ID("$From: fty_regex.c,v 1.15 2000/12/09 23:46:12 tom Exp $")
+MODULE_ID("$Id: fty_regex.c,v 1.8 2010/01/12 23:22:07 nicm Exp $")
-#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
+#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */
#include <regex.h>
typedef struct
-{
- regex_t *pRegExp;
- unsigned long *refCount;
-} RegExp_Arg;
+ {
+ 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)
+static char *
+RegEx_Init(char *instring)
{
- reg_errno = 0;
- return instring;
+ reg_errno = 0;
+ return instring;
}
-static char *RegEx_Error(int code)
+static char *
+RegEx_Error(int code)
{
- reg_errno = code;
- return 0;
+ reg_errno = code;
+ return 0;
}
#define INIT register char *sp = RegEx_Init(instring);
@@ -59,7 +81,8 @@ typedef struct
{
char *compiled_expression;
unsigned long *refCount;
-} RegExp_Arg;
+}
+RegExp_Arg;
/* Maximum Length we allow for a compiled regular expression */
#define MAX_RX_LEN (2048)
@@ -75,20 +98,25 @@ typedef struct
|
| Return Values : Pointer to argument structure or NULL on error
+--------------------------------------------------------------------------*/
-static void *Make_RegularExpression_Type(va_list * ap)
+static void *
+Make_RegularExpression_Type(va_list *ap)
{
#if HAVE_REGEX_H_FUNCS
- char *rx = va_arg(*ap,char *);
+ char *rx = va_arg(*ap, char *);
RegExp_Arg *preg;
- preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
+ preg = typeMalloc(RegExp_Arg, 1);
+
if (preg)
{
- if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
- && !regcomp(preg->pRegExp,rx,
- (REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
+ T((T_CREATE("RegExp_Arg %p"), preg));
+ if (((preg->pRegExp = typeMalloc(regex_t, 1)) != 0)
+ && !regcomp(preg->pRegExp, rx,
+ (REG_EXTENDED | REG_NOSUB | REG_NEWLINE)))
{
- preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ T((T_CREATE("regex_t %p"), preg->pRegExp));
+ preg->refCount = typeMalloc(unsigned long, 1);
+
*(preg->refCount) = 1;
}
else
@@ -96,51 +124,58 @@ static void *Make_RegularExpression_Type(va_list * ap)
if (preg->pRegExp)
free(preg->pRegExp);
free(preg);
- preg = (RegExp_Arg*)0;
+ preg = (RegExp_Arg *)0;
}
}
- return((void *)preg);
+ return ((void *)preg);
#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
- char *rx = va_arg(*ap,char *);
+ char *rx = va_arg(*ap, char *);
RegExp_Arg *pArg;
- pArg = (RegExp_Arg *)malloc(sizeof(RegExp_Arg));
+ pArg = typeMalloc(RegExp_Arg, 1);
if (pArg)
{
int blen = RX_INCREMENT;
+
+ T((T_CREATE("RegExp_Arg %p"), pArg));
pArg->compiled_expression = NULL;
- pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ pArg->refCount = typeMalloc(unsigned long, 1);
+
*(pArg->refCount) = 1;
- do {
- char *buf = (char *)malloc(blen);
- if (buf)
- {
+ do
+ {
+ char *buf = typeMalloc(char, blen);
+
+ if (buf)
+ {
#if HAVE_REGEXP_H_FUNCS
- char *last_pos = compile (rx, buf, &buf[blen], '\0');
+ char *last_pos = compile(rx, buf, &buf[blen], '\0');
+
#else /* HAVE_REGEXPR_H_FUNCS */
- char *last_pos = compile (rx, buf, &buf[blen]);
+ 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 (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)
{
@@ -162,7 +197,8 @@ static void *Make_RegularExpression_Type(va_list * ap)
|
| Return Values : Pointer to argument structure or NULL on error.
+--------------------------------------------------------------------------*/
-static void *Copy_RegularExpression_Type(const void * argp)
+static void *
+Copy_RegularExpression_Type(const void *argp)
{
#if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS)
const RegExp_Arg *ap = (const RegExp_Arg *)argp;
@@ -187,10 +223,12 @@ static void *Copy_RegularExpression_Type(const void * argp)
|
| Return Values : -
+--------------------------------------------------------------------------*/
-static void Free_RegularExpression_Type(void * argp)
+static void
+Free_RegularExpression_Type(void *argp)
{
#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS
RegExp_Arg *ap = (RegExp_Arg *)argp;
+
if (ap)
{
if (--(*(ap->refCount)) == 0)
@@ -225,24 +263,33 @@ static void Free_RegularExpression_Type(void * argp)
| Return Values : TRUE - field is valid
| FALSE - field is invalid
+--------------------------------------------------------------------------*/
-static bool Check_RegularExpression_Field(FIELD * field, const void * argp)
+static bool
+Check_RegularExpression_Field(FIELD *field, const void *argp)
{
bool match = FALSE;
+
#if HAVE_REGEX_H_FUNCS
- const RegExp_Arg *ap = (const RegExp_Arg*)argp;
+ 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);
+ 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);
+ match = (step(field_buffer(field, 0), ap->compiled_expression)
+ ? TRUE
+ : FALSE);
#endif
return match;
}
-static FIELDTYPE typeREGEXP = {
+static FIELDTYPE typeREGEXP =
+{
_HAS_ARGS | _RESIDENT,
- 1, /* this is mutable, so we can't be const */
+ 1, /* this is mutable, so we can't be const */
(FIELDTYPE *)0,
(FIELDTYPE *)0,
Make_RegularExpression_Type,
diff --git a/lib/libform/shlib_version b/lib/libform/shlib_version
index 012c14171d3..d9961ea9fef 100644
--- a/lib/libform/shlib_version
+++ b/lib/libform/shlib_version
@@ -1,2 +1,2 @@
-major=3
+major=4
minor=0