summaryrefslogtreecommitdiff
path: root/lib/libform
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1997-11-26 04:01:29 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1997-11-26 04:01:29 +0000
commitcd15e61d557c4704743905eae7b88ae927cf0394 (patch)
tree24ae93cd3ef24948fe6cc4049d94433f3ed28919 /lib/libform
parent65d9e3fdab3ed1511a98387720e59db078fc3d46 (diff)
libform from ncurses 4.1. Post 4.1 patches to be applied in a separate commit.
Diffstat (limited to 'lib/libform')
-rw-r--r--lib/libform/Makefile17
-rw-r--r--lib/libform/fld_def.c45
-rw-r--r--lib/libform/fld_stat.c43
-rw-r--r--lib/libform/fld_type.c43
-rw-r--r--lib/libform/fld_user.c47
-rw-r--r--lib/libform/form.3156
-rw-r--r--lib/libform/form.h78
-rw-r--r--lib/libform/form.priv.h41
-rw-r--r--lib/libform/form_data.34
-rw-r--r--lib/libform/form_driver.311
-rw-r--r--lib/libform/form_field.34
-rw-r--r--lib/libform/form_field_attributes.36
-rw-r--r--lib/libform/form_field_buffer.38
-rw-r--r--lib/libform/form_field_info.34
-rw-r--r--lib/libform/form_field_just.32
-rw-r--r--lib/libform/form_field_new.37
-rw-r--r--lib/libform/form_field_opts.36
-rw-r--r--lib/libform/form_field_userptr.34
-rw-r--r--lib/libform/form_field_validation.357
-rw-r--r--lib/libform/form_fieldtype.330
-rw-r--r--lib/libform/form_hook.38
-rw-r--r--lib/libform/form_new.34
-rw-r--r--lib/libform/form_new_page.310
-rw-r--r--lib/libform/form_opts.34
-rw-r--r--lib/libform/form_page.312
-rw-r--r--lib/libform/form_requestname.340
-rw-r--r--lib/libform/form_userptr.38
-rw-r--r--lib/libform/form_win.38
-rw-r--r--lib/libform/frm_data.c43
-rw-r--r--lib/libform/frm_def.c43
-rw-r--r--lib/libform/frm_driver.c321
-rw-r--r--lib/libform/frm_hook.c43
-rw-r--r--lib/libform/frm_opts.c43
-rw-r--r--lib/libform/frm_req_name.c153
-rw-r--r--lib/libform/frm_user.c47
-rw-r--r--lib/libform/frm_win.c53
-rw-r--r--lib/libform/fty_alnum.c13
-rw-r--r--lib/libform/fty_alpha.c13
-rw-r--r--lib/libform/fty_enum.c19
-rw-r--r--lib/libform/fty_int.c27
-rw-r--r--lib/libform/fty_ipv4.c81
-rw-r--r--lib/libform/fty_num.c36
-rw-r--r--lib/libform/fty_regex.c61
-rw-r--r--lib/libform/shlib_version2
44 files changed, 1097 insertions, 608 deletions
diff --git a/lib/libform/Makefile b/lib/libform/Makefile
index 1568bb10a7b..d3d20c7765e 100644
--- a/lib/libform/Makefile
+++ b/lib/libform/Makefile
@@ -1,15 +1,16 @@
LIB= form
SRCS= fld_def.c fld_stat.c fld_type.c fld_user.c frm_data.c frm_def.c \
frm_driver.c frm_hook.c frm_opts.c frm_user.c frm_win.c fty_alnum.c \
- fty_alpha.c fty_enum.c fty_int.c fty_num.c fty_regex.c
+ fty_alpha.c fty_enum.c fty_int.c fty_num.c fty_regex.c fty_ipv4.c \
+ frm_req_name.c
HDRS= form.h
-CFLAGS+=-I. -I${.CURDIR} -I${.CURDIR}/../libmenu
-MAN= form.3 form_field_userptr.3 form_cursor.3 form_field_validation.3 \
- form_data.3 form_fieldtype.3 form_driver.3 form_hook.3 form_field.3 \
- form_new.3 form_field_attributes.3 form_new_page.3 form_field_buffer.3 \
- form_opts.3 form_field_info.3 form_page.3 form_field_just.3 \
- form_post.3 form_field_new.3 form_userptr.3 form_field_opts.3 \
- form_win.3
+CFLAGS+=-I${.CURDIR}/../libmenu -I${.CURDIR}/../libcurses -DHAVE_CONFIG_H
+MAN= form.3 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 \
+ form_field_userptr.3 form_field_validation.3 form_fieldtype.3 \
+ form_hook.3 form_new.3 form_new_page.3 form_opts.3 form_page.3 \
+ form_post.3 form_requestname.3 form_userptr.3 form_win.3
includes:
@cd ${.CURDIR}; for i in ${HDRS}; do \
diff --git a/lib/libform/fld_def.c b/lib/libform/fld_def.c
index 6b1056ca55d..d18f9ed6b82 100644
--- a/lib/libform/fld_def.c
+++ b/lib/libform/fld_def.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: fld_def.c,v 1.6 1997/05/01 16:47:54 juergen Exp $")
+
/* this can't be readonly */
static FIELD default_field = {
0, /* status */
@@ -129,7 +132,7 @@ static TypeArgument *Copy_Argument(const FIELDTYPE *typ,
}
else
{
- if (!(res = (TypeArgument *)(typ->copyarg((void *)argp))))
+ if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp))))
*err += 1;
}
}
diff --git a/lib/libform/fld_stat.c b/lib/libform/fld_stat.c
index 0ac10d4914a..04c877fc88e 100644
--- a/lib/libform/fld_stat.c
+++ b/lib/libform/fld_stat.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: fld_stat.c,v 1.3 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_status(FIELD *field, bool status)
diff --git a/lib/libform/fld_type.c b/lib/libform/fld_type.c
index dec98ea7651..6c30a432ac1 100644
--- a/lib/libform/fld_type.c
+++ b/lib/libform/fld_type.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: fld_type.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
+
static FIELDTYPE const default_fieldtype = {
0, /* status */
0L, /* reference count */
diff --git a/lib/libform/fld_user.c b/lib/libform/fld_user.c
index 2f5129a21b3..dd90483d959 100644
--- a/lib/libform/fld_user.c
+++ b/lib/libform/fld_user.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: fld_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_field_userptr(FIELD *field, void *usrptr)
@@ -30,7 +33,7 @@
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
-int set_field_userptr(FIELD * field, void *usrptr)
+int set_field_userptr(FIELD * field, const void *usrptr)
{
Normalize_Field( field )->usrptr = usrptr;
RETURN(E_OK);
@@ -46,7 +49,7 @@ int set_field_userptr(FIELD * field, void *usrptr)
| Return Values : Value of pointer. If no such pointer has been set,
| NULL is returned
+--------------------------------------------------------------------------*/
-void *field_userptr(const FIELD *field)
+const void *field_userptr(const FIELD *field)
{
return Normalize_Field( field )->usrptr;
}
diff --git a/lib/libform/form.3 b/lib/libform/form.3
index 5f15fd95595..69ef1c02b99 100644
--- a/lib/libform/form.3
+++ b/lib/libform/form.3
@@ -14,7 +14,7 @@ user.
The \fBforms\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 \Bforms\fR library, link with the options
+these functions. To use the \fBforms\fR library, link with the options
\fB-lform -lcurses\fR.
.SS Current Default Values for Field Attributes
@@ -30,79 +30,83 @@ rendering of fields already created.
The following table lists each \fBform\fR routine and the name of
the manual page on which it is described.
-.nf
-\fBcurses\fR Routine Name Manual Page Name
-_________________________________________________________
-\fBcurrent_field\fR form_page(3X)
-\fBdata_ahead\fR form_data(3X)
-\fBdata_behind\fR form_data(3X)
-\fBdup_field\fR form_field_new(3X)
-\fBdynamic_fieldinfo\fR form_field_info(3X)
-\fBfield_arg\fR form_field_validation(3X)
-\fBfield_back\fR form_field_attributes(3X)
-\fBfield_buffer\fR form_field_buffer(3X)
-\fBfield_count\fR form_field(3X)
-\fBfield_fore\fR form_field_attributes(3X)
-\fBfield_index\fR form_page(3X)
-\fBfield_info\fR form_field_info(3X)
-\fBfield_init\fR form_hook(3X)
-\fBfield_just\fR form_field_just(3X)
-\fBfield_opts\fR form_field_opts(3X)
-\fBfield_opts_off\fR form_field_opts(3X)
-\fBfield_opts_on\fR form_field_opts(3X)
-\fBfield_pad\fR form_field_attributes(3X)
-\fBfield_status\fR form_field_buffer(3X)
-\fBfield_term\fR form_hook(3X)
-\fBfield_type\fR form_field_validation(3X)
-\fBfield_userptr\fR form_field_userptr(3X)
-\fBform_driver\fR form_driver(3X)
-\fBform_fields\fR form_field(3X)
-\fBform_init\fR form_hook(3X)
-\fBform_opts\fR form_opts(3X)
-\fBform_opts_off\fR form_opts(3X)
-\fBform_opts_on\fR form_opts(3X)
-\fBform_page\fR form_page(3X)
-\fBform_sub\fR form_win(3X)
-\fBform_term\fR form_hook(3X)
-\fBform_userptr\fR form_userptr(3X)
-\fBform_win\fR form_win(3X)
-\fBfree_field\fR form_field_new(3X)
-\fBfree_form\fR form_new(3X)
-\fBlink_field\fR form_field_new(3X)
-\fBlink_fieldtype\fR link_fieldtype(3X)
-\fBmove_field\fR form_field(3X)
-\fBnew_field\fR form_field_new(3X)
-\fBnew_form\fR form_new(3X)
-\fBnew_page\fR form_new_page(3X)
-\fBpos_form_cursor\fR form_cursor(3X)
-\fBpost_form\fR form_post(3X)
-\fBscale_form\fR form_win(3X)
-\fBset_current_field\fR form_page(3X)
-\fBset_field_back\fR form_field_attributes(3X)
-\fBset_field_buffer\fR form_field_buffer(3X)
-\fBset_field_fore\fR form_field_attributes(3X)
-\fBset_field_init\fR form_hook(3X)
-\fBset_field_just\fR form_field_just(3X)
-\fBset_field_opts\fR form_field_opts(3X)
-\fBset_field_pad\fR form_field_attributes(3X)
-\fBset_field_status\fR form_field_buffer(3X)
-\fBset_field_term\fR form_hook(3X)
-\fBset_field_type\fR form_field_validation(3X)
-\fBset_field_userptr\fR form_field_userptr(3X)
-\fBset_fieldtype_arg\fR form_fieldtype(3X)
-\fBset_fieldtype_choice\fR form_fieldtype(3X)
-\fBset_form_fields\fR form_field(3X)
-\fBset_form_init\fR form_hook(3X)
-\fBset_form_opts\fR form_field_opts(3X)
-\fBset_form_page\fR form_page(3X)
-\fBset_form_sub\fR form_win(3X)
-\fBset_form_term\fR form_hook(3X)
-\fBset_form_userptr\fR form_userptr(3X)
-\fBset_form_win\fR form_win(3X)
-\fBset_max_field\fR form_field_buffer(3X)
-\fBset_new_page\fR form_new_page(3X)
-\fBunpost_form\fR form_post(3X)
-.fi
+.TS
+l l
+l l .
+\fBcurses\fR Routine Name Manual Page Name
+=
+\fBcurrent_field\fR form_page(3X)
+\fBdata_ahead\fR form_data(3X)
+\fBdata_behind\fR form_data(3X)
+\fBdup_field\fR form_field_new(3X)
+\fBdynamic_fieldinfo\fR form_field_info(3X)
+\fBfield_arg\fR form_field_validation(3X)
+\fBfield_back\fR form_field_attributes(3X)
+\fBfield_buffer\fR form_field_buffer(3X)
+\fBfield_count\fR form_field(3X)
+\fBfield_fore\fR form_field_attributes(3X)
+\fBfield_index\fR form_page(3X)
+\fBfield_info\fR form_field_info(3X)
+\fBfield_init\fR form_hook(3X)
+\fBfield_just\fR form_field_just(3X)
+\fBfield_opts\fR form_field_opts(3X)
+\fBfield_opts_off\fR form_field_opts(3X)
+\fBfield_opts_on\fR form_field_opts(3X)
+\fBfield_pad\fR form_field_attributes(3X)
+\fBfield_status\fR form_field_buffer(3X)
+\fBfield_term\fR form_hook(3X)
+\fBfield_type\fR form_field_validation(3X)
+\fBfield_userptr\fR form_field_userptr(3X)
+\fBform_driver\fR form_driver(3X)
+\fBform_fields\fR form_field(3X)
+\fBform_init\fR form_hook(3X)
+\fBform_opts\fR form_opts(3X)
+\fBform_opts_off\fR form_opts(3X)
+\fBform_opts_on\fR form_opts(3X)
+\fBform_page\fR form_page(3X)
+\fBform_request_by_name\fR form_requestname(3X)
+\fBform_request_name\fR form_requestname(3X)
+\fBform_sub\fR form_win(3X)
+\fBform_term\fR form_hook(3X)
+\fBform_userptr\fR form_userptr(3X)
+\fBform_win\fR form_win(3X)
+\fBfree_field\fR form_field_new(3X)
+\fBfree_form\fR form_new(3X)
+\fBlink_field\fR form_field_new(3X)
+\fBlink_fieldtype\fR link_fieldtype(3X)
+\fBmove_field\fR form_field(3X)
+\fBnew_field\fR form_field_new(3X)
+\fBnew_form\fR form_new(3X)
+\fBnew_page\fR form_new_page(3X)
+\fBpos_form_cursor\fR form_cursor(3X)
+\fBpost_form\fR form_post(3X)
+\fBscale_form\fR form_win(3X)
+\fBset_current_field\fR form_page(3X)
+\fBset_field_back\fR form_field_attributes(3X)
+\fBset_field_buffer\fR form_field_buffer(3X)
+\fBset_field_fore\fR form_field_attributes(3X)
+\fBset_field_init\fR form_hook(3X)
+\fBset_field_just\fR form_field_just(3X)
+\fBset_field_opts\fR form_field_opts(3X)
+\fBset_field_pad\fR form_field_attributes(3X)
+\fBset_field_status\fR form_field_buffer(3X)
+\fBset_field_term\fR form_hook(3X)
+\fBset_field_type\fR form_field_validation(3X)
+\fBset_field_userptr\fR form_field_userptr(3X)
+\fBset_fieldtype_arg\fR form_fieldtype(3X)
+\fBset_fieldtype_choice\fR form_fieldtype(3X)
+\fBset_form_fields\fR form_field(3X)
+\fBset_form_init\fR form_hook(3X)
+\fBset_form_opts\fR form_field_opts(3X)
+\fBset_form_page\fR form_page(3X)
+\fBset_form_sub\fR form_win(3X)
+\fBset_form_term\fR form_hook(3X)
+\fBset_form_userptr\fR form_userptr(3X)
+\fBset_form_win\fR form_win(3X)
+\fBset_max_field\fR form_field_buffer(3X)
+\fBset_new_page\fR form_new_page(3X)
+\fBunpost_form\fR form_post(3X)
+.TE
.SH RETURN VALUE
Routines that return pointers return \fBNULL\fR on error. Routines that return
an integer return one of the following error codes:
@@ -149,8 +153,8 @@ descriptions of the entry points.
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 libncurses.a; that is,
-you want to say `-lform -lncurses', not the other way around (which would
+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).
.SH PORTABILITY
These routines emulate the System V forms library. They were not supported on
diff --git a/lib/libform/form.h b/lib/libform/form.h
index ad9e40475bc..6e2eabe209d 100644
--- a/lib/libform/form.h
+++ b/lib/libform/form.h
@@ -1,23 +1,24 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#ifndef FORM_H
#define FORM_H
@@ -72,7 +73,7 @@ typedef struct fieldnode {
struct typenode * type; /* field type */
void * arg; /* argument for type */
char * buf; /* field buffers */
- void * usrptr; /* user pointer */
+ const void * usrptr; /* user pointer */
} FIELD;
/**************
@@ -119,7 +120,7 @@ typedef struct formnode {
FIELD ** field; /* field [maxfield] */
FIELD * current; /* current field */
_PAGE * page; /* page [maxpage] */
- void * usrptr; /* user pointer */
+ const void * usrptr; /* user pointer */
void (*forminit)(struct formnode *);
void (*formterm)(struct formnode *);
@@ -222,8 +223,14 @@ typedef void (*Form_Hook)(FORM *);
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
-#if defined(MAX_COMMAND) && (MAX_FORM_COMMAND > MAX_COMMAND)
-#error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
+#if defined(MAX_COMMAND)
+# if (MAX_FORM_COMMAND > MAX_COMMAND)
+# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
+# elif (MAX_COMMAND != (KEY_MAX + 128))
+# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
+# endif
+#else
+# define MAX_COMMAND (KEY_MAX + 128)
#endif
/*************************
@@ -236,6 +243,12 @@ extern FIELDTYPE *TYPE_ALPHA,
*TYPE_NUMERIC,
*TYPE_REGEXP;
+ /************************************
+ * built-in additional field types *
+ * They are not defined in SVr4 *
+ ************************************/
+extern FIELDTYPE *TYPE_IPV4; /* Internet IP Version 4 address */
+
/***********************
* Default objects *
***********************/
@@ -283,7 +296,7 @@ extern int free_field(FIELD *),
field_pad(const FIELD *),
set_field_buffer(FIELD *,int,const char *),
set_field_status(FIELD *,bool),
- set_field_userptr(FIELD *,void *),
+ set_field_userptr(FIELD *,const void *),
set_field_opts(FIELD *,Field_Options),
field_opts_on(FIELD *,Field_Options),
field_opts_off(FIELD *,Field_Options);
@@ -294,7 +307,9 @@ extern chtype field_fore(const FIELD *),
extern bool new_page(const FIELD *),
field_status(const FIELD *);
-extern void *field_arg(const FIELD *),
+extern void *field_arg(const FIELD *);
+
+extern const void
*field_userptr(const FIELD *);
extern FIELDTYPE
@@ -340,12 +355,17 @@ extern int free_form(FORM *),
unpost_form(FORM *),
pos_form_cursor(FORM *),
form_driver(FORM *,int),
- set_form_userptr(FORM *,void *),
+ set_form_userptr(FORM *,const void *),
set_form_opts(FORM *,Form_Options),
form_opts_on(FORM *,Form_Options),
- form_opts_off(FORM *,Form_Options);
+ form_opts_off(FORM *,Form_Options),
+ form_request_by_name(const char *);
+
+extern const char
+ *form_request_name(int);
-extern void *form_userptr(const FORM *);
+extern const void
+ *form_userptr(const FORM *);
extern Form_Options
form_opts(const FORM *);
diff --git a/lib/libform/form.priv.h b/lib/libform/form.priv.h
index 40c0cc6a2e8..b08d70d6e35 100644
--- a/lib/libform/form.priv.h
+++ b/lib/libform/form.priv.h
@@ -1,23 +1,24 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "mf_common.h"
#include "form.h"
diff --git a/lib/libform/form_data.3 b/lib/libform/form_data.3
index 0aadfa78cf6..bf8a240467d 100644
--- a/lib/libform/form_data.3
+++ b/lib/libform/form_data.3
@@ -5,9 +5,9 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-bool data_ahead(FORM *form);
+bool data_ahead(const FORM *form);
.br
-bool data_ahead(FORM *form);
+bool data_behind(const FORM *form);
.br
.SH DESCRIPTION
The function \fBdata_ahead\fR tests whether there is off-screen data
diff --git a/lib/libform/form_driver.3 b/lib/libform/form_driver.3
index e501c6ca008..6a6acc7b66c 100644
--- a/lib/libform/form_driver.3
+++ b/lib/libform/form_driver.3
@@ -133,6 +133,9 @@ Clear to end of line from cursor.
REQ_CLR_EOF
Clear to end of field from cursor.
.TP 5
+REQ_CLR_FIELD
+Clear the entire field.
+.TP 5
REQ_OVL_MODE
Enter overlay mode.
.TP 5
@@ -181,18 +184,18 @@ Horizontal scroll the field backward half a line.
REQ_VALIDATION
Validate field.
.TP
-REQ_PREV_CHOICE
-Display previous field choice.
-.TP
REQ_NEXT_CHOICE
Display next field choice.
+.TP
+REQ_PREV_CHOICE
+Display previous field choice.
.PP
If the second argument is a printable ASCII 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.
.PP
If the second argument is neither printable ASCII nor one of the above
-pre-defined form requests, the drive asumes it is an application-specific
+pre-defined form requests, the drive 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.
diff --git a/lib/libform/form_field.3 b/lib/libform/form_field.3
index 9db3790ebd2..3e651a5a5d3 100644
--- a/lib/libform/form_field.3
+++ b/lib/libform/form_field.3
@@ -7,9 +7,9 @@
.br
int set_form_fields(FORM *form, FIELD **fields);
.br
-FIELD **form_fields(FORM *form);
+FIELD **form_fields(const FORM *form);
.br
-int field_count(FORM *form);
+int field_count(const FORM *form);
.br
int move_field(FIELD *field, int frow, int fcol);
.br
diff --git a/lib/libform/form_field_attributes.3 b/lib/libform/form_field_attributes.3
index baaf77c6194..610bef2d6f4 100644
--- a/lib/libform/form_field_attributes.3
+++ b/lib/libform/form_field_attributes.3
@@ -7,15 +7,15 @@
.br
int set_field_fore(FIELD *field, chtype attr);
.br
-chtype field_fore(FIELD *field);
+chtype field_fore(const FIELD *field);
.br
int set_field_back(FIELD *field, chtype attr);
.br
-chtype field_back(FIELD *field);
+chtype field_back(const FIELD *field);
.br
int set_field_pad(FIELD *field, int pad);
.br
-chtype field_pad(FIELD *field);
+chtype field_pad(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_fore\fR sets the foreground attribute of
diff --git a/lib/libform/form_field_buffer.3 b/lib/libform/form_field_buffer.3
index 61c5047bc6b..d1a32aaa11c 100644
--- a/lib/libform/form_field_buffer.3
+++ b/lib/libform/form_field_buffer.3
@@ -5,13 +5,13 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_buffer(FIELD *field, int buf, char *value);
+int set_field_buffer(FIELD *field, int buf, const char *value);
.br
-char *field_buffer(FIELD *field, int buffer);
+char *field_buffer(const FIELD *field, int buffer);
.br
-int set_field_status(FIELD *field, int status);
+int set_field_status(FIELD *field, bool status);
.br
-int field_status(FIELD *field);
+bool field_status(const FIELD *field);
.br
int set_max_field(FIELD *field, int max);
.br
diff --git a/lib/libform/form_field_info.3 b/lib/libform/form_field_info.3
index c01a796421e..aca06fb7862 100644
--- a/lib/libform/form_field_info.3
+++ b/lib/libform/form_field_info.3
@@ -5,10 +5,10 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int field_info(FIELD *field, int *rows, int *cols,
+int field_info(const FIELD *field, int *rows, int *cols,
int *frow, int *fcol, int *nrow, int *nbuf);
.br
-int dynamic_field_info(FIELD *field, int *rows, int *cols, *max);
+int dynamic_field_info(const FIELD *field, int *rows, int *cols, *max);
.br
.SH DESCRIPTION
The function \fBfield_info\fR returns the sizes and other attributes passed in
diff --git a/lib/libform/form_field_just.3 b/lib/libform/form_field_just.3
index dffc8143d2b..cbe2102b223 100644
--- a/lib/libform/form_field_just.3
+++ b/lib/libform/form_field_just.3
@@ -7,7 +7,7 @@
.br
int set_field_just(FIELD *field, int justification);
.br
-int field_just(FIELD *field);
+int field_just(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_field_just\fR sets the justification attribute of
diff --git a/lib/libform/form_field_new.3 b/lib/libform/form_field_new.3
index a65bceed28c..af2dcad5325 100644
--- a/lib/libform/form_field_new.3
+++ b/lib/libform/form_field_new.3
@@ -6,7 +6,8 @@
\fB#include <form.h>\fR
.br
FIELD *new_field(int height, int width,
- int toprow, int leftcol, int offscreen, int nbuffers);
+ int toprow, int leftcol,
+ int offscreen, int nbuffers);
.br
FIELD *dup_field(FIELD *field, int toprow, int leftcol);
.br
@@ -17,11 +18,11 @@ int free_field(FIELD *field);
.SH DESCRIPTION
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 working buffers.
+corner, number off-screen rows, and number of additional working buffers.
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, fireground, background, padd character,
+growth threshold, justification, foreground, background, pad character,
options, and user pointer) are copied. Field status and the field page bit are
not copied.
diff --git a/lib/libform/form_field_opts.3 b/lib/libform/form_field_opts.3
index 8fce036dae2..d3dc8db1f1b 100644
--- a/lib/libform/form_field_opts.3
+++ b/lib/libform/form_field_opts.3
@@ -11,11 +11,11 @@ int field_opts_on(FIELD *field, OPTIONS opts);
.br
int field_opts_off(FIELD *field, OPTIONS opts);
.br
-OPTIONS field_opts(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-ored together).
+option bits may be logically-OR'ed together).
The function \fBfield_opts_on\fR turns on the given option bits, and leaves
others alone.
@@ -58,7 +58,7 @@ O_STATIC
Field buffers are fixed to field's original size.
.TP 5
O_PASSOK
-Validate field omly if modified by user.
+Validate field only if modified by user.
.SH RETURN VALUE
Except for \fBfield_opts\fR, each routine returns one of the following:
.TP 5
diff --git a/lib/libform/form_field_userptr.3 b/lib/libform/form_field_userptr.3
index 04930f76184..f2d7bd9d978 100644
--- a/lib/libform/form_field_userptr.3
+++ b/lib/libform/form_field_userptr.3
@@ -5,9 +5,9 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_field_userptr(FIELD *field, char *userptr);
+int set_field_userptr(FIELD *field, const void*userptr);
.br
-char field_userptr(FIELD *field);
+const void *field_userptr(const FIELD *field);
.br
.SH DESCRIPTION
Every form field has a field that can be used to hold application-specific data
diff --git a/lib/libform/form_field_validation.3 b/lib/libform/form_field_validation.3
index 682b21296b1..8fee91d0f24 100644
--- a/lib/libform/form_field_validation.3
+++ b/lib/libform/form_field_validation.3
@@ -7,45 +7,72 @@
.br
int set_field_type(FIELD *field, FIELDTYPE *type, ...);
.br
-FIELDTYPE *field_type(FIELD *field);
+FIELDTYPE *field_type(const FIELD *field);
.br
-char *field_arg(FIELD *field);
+void *field_arg(const FIELD *field);
.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:
.TP 5
TYPE_ALNUM
-Alphanumeric data. Requires a third argument, a minimum field width.
+Alphanumeric data. Requires a third \fBint\fR argument, a minimum field width.
.TP 5
TYPE_ALPHA
-Character data. Requires a third argument, a minimum field width.
+Character data. Requires a third \fBint\fR argument, a minimum field width.
.TP 5
TYPE_ENUM
-Accept one of a specified set of strings. Requires a third (char **)
-argument pointing to a string list; a fourth flag argument to enable
-case-sensitivity; and a fifth flag argument specifying whether a partial
+Accept one of a specified set of strings. Requires a third \fB(char **)\fR
+argument pointing to a string list; a fourth \fBint\fR flag argument to enable
+case-sensitivity; and a fifth \fBint\fR flag argument specifying whether a partial
match must be a unique one (if this flag is off, a prefix matches the first
-of any set of more than one list elements with that prefix).
+of any set of more than one list elements with that prefix). Please notice
+that the string list is not copied, only a reference to it is stored in the
+field. So you should avoid to use a list that lives in automatic variables
+on the stack.
.TP 5
TYPE_INTEGER
Integer data, parsable to an integer by \fBatoi(3)\fR. Requires a third
-integer precision argument that sets zero-padding, a fourth argument
-constraining minimum value, and a fifth constraining maximum value.
+\fBint\fR argument controlling the precision, a fourth \fBlong\fR argument
+constraining minimum value, and a fifth \fBlong\fR constraining maximum value.
+If the maximum value is less or equal the minimum value, the range is simply
+ignored. On return the field buffer is formatted according to the \fBprintf\fR
+format specification ".*ld", where the '*' is replaced by the precision argument.
+For details of the precision handling see \fBprintf's\fR man-page.
.TP 5
TYPE_NUMERIC
-Numeric data (may have a decimal-point part). Requires following
-arguments as for TYPE_INTEGER data.
+Numeric data (may have a decimal-point part). Requires a third
+\fBint\fR argument controlling the precision, a fourth \fBdouble\fR
+argument constraining minimum value, and a fifth \fBdouble\fR constraining
+maximum value. If your system supports locale's, the decimal point character
+to be used must be the one specified by your locale.
+If the maximum value is less or equal the minimum value, the range is simply
+ignored. On return the field buffer is formatted according to the \fBprintf\fR
+format specification ".*f", where the '*' is replaced by the precision argument.
+For details of the precision handling see \fBprintf's\fR man-page.
.TP 5
TYPE_REGEXP
-Regular expression data. Requires a regular expression third argument;
+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(3x) and \fBregexec\fR(3X).
+are in the format of \fBregcomp\fR(3x) and \fBregexec\fR(3X). 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
+allow fewer digits, you may use for example "^[0-9]* *$" which is good for
+trailing spaces (up to an empty field), or "^ *[0-9]* *$" which is good for
+leading and trailing spaces around the digits.
+.TP 5
+TYPE_IPV4
+An Internet Protocol Version 4 address. This requires no additional argument. It
+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.
It is possible to set up new programmer-defined field types. See the
\fBform_fieldtype\fR(3X) manual page.
.SH RETURN VALUE
-The functions \fBfield_type\fR and \fB\field_argfR return \fBNULL\fR on
+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
diff --git a/lib/libform/form_fieldtype.3 b/lib/libform/form_fieldtype.3
index d6dee84ff1d..a6697eedbfb 100644
--- a/lib/libform/form_fieldtype.3
+++ b/lib/libform/form_fieldtype.3
@@ -5,27 +5,31 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-FIELDTYPE *new_fieldtype(int (*field_check)(FIELD *, char *),
- int (*char_check)(int, char *));
+FIELDTYPE *new_fieldtype(
+ bool (* const field_check)(FIELD *, const void *),
+ bool (* const char_check)(int, const void *));
.br
int free_fieldtype(FIELDTYPE *fieldtype);
.br
-in set_fieldtype_arg(FIELDTYPE *fieldtype
- char *(*mak_arg)(va_list *),
- char *(*copy_arg)(char *),
- void (*free_arg)(char *));
+int set_fieldtype_arg(
+ FIELDTYPE *fieldtype,
+ void *(* const make_arg)(va_list *),
+ void *(* const copy_arg)(const void *),
+ void (* const free_arg)(void *));
.br
-in set_fieldtype_choice(FIELDTYPE *fieldtype
- int (*next_choice)(FIELD *, char *),
- int (*prev_choice)(FIELD *, char *));
-.br
-FIELDTYPE *link_fieldtype(FIELDYPE *type1, FIELDTYPE *type2);
+int set_fieldtype_choice(
+ FIELDTYPE *fieldtype
+ bool (* const next_choice)(FIELD *, const void *),
+ bool (* const prev_choice)(FIELD *, const void *));
.br
+FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
+ FIELDTYPE *type2);
+.br
.SH DESCRIPTION
The function \fBnew_fieldtype\fR creates a new field type usable for data
validation. You supply it with \fIfield_check\fR, a predicate to check the
validity of an entered data string whenever the user attempt to leave a field.
-Thhe (FIELD *) argument is passed in so the validation predicate can see the
+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.
@@ -51,7 +55,7 @@ function allows forms programmers to define successor and predecessor functions
for the field type. These functions take the field pointer and an
argument-block structure as arguments.
.SH RETURN VALUE
-The character-pointer-valued routines return NULL on error.
+The pointer-valued routines return NULL on error.
The integer-valued routines return one of the following codes on
error:
diff --git a/lib/libform/form_hook.3 b/lib/libform/form_hook.3
index 6fba5669ae7..3ed7d8c38ca 100644
--- a/lib/libform/form_hook.3
+++ b/lib/libform/form_hook.3
@@ -7,19 +7,19 @@
.br
int set_field_init(FORM *form, void (*func)(FORM *));
.br
-void (*)(FORM *) field_init(MWNU *form);
+void (*)(FORM *) field_init(const FORM *form);
.br
int set_field_term(FORM *form, void (*func)(FORM *));
.br
-void (*)(FORM *) field_term(MWNU *form);
+void (*)(FORM *) field_term(const FORM *form);
.br
int set_form_init(FORM *form, void (*func)(FORM *));
.br
-void (*)(FORM *) form_init(MWNU *form);
+void (*)(FORM *) form_init(const FORM *form);
.br
int set_form_term(FORM *form, void (*func)(FORM *));
.br
-void (*)(FORM *) form_term(MWNU *form);
+void (*)(FORM *) form_term(const FORM *form);
.br
.SH DESCRIPTION
These functions make it possible to set hook functions to be called at various
diff --git a/lib/libform/form_new.3 b/lib/libform/form_new.3
index 50fbd48d5c1..af85586d2a0 100644
--- a/lib/libform/form_new.3
+++ b/lib/libform/form_new.3
@@ -7,13 +7,13 @@
.br
FORM *new_form(FIELD **fields);
.br
-char *free_form(FORM *form);
+int free_form(FORM *form);
.br
.SH DESCRIPTION
The function \fBnew_form\fR creates a new form connected to a specified field
pointer array (which must be \fBNULL\fR-terminated).
-The function \fBfree_form\fR discomnnects \fIform\fR from its field array
+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.
diff --git a/lib/libform/form_new_page.3 b/lib/libform/form_new_page.3
index e01e91842ee..c3d4a1809e1 100644
--- a/lib/libform/form_new_page.3
+++ b/lib/libform/form_new_page.3
@@ -5,15 +5,15 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_new_page(FIELD *field, int justification);
+int set_new_page(FIELD *field, bool new_page_flag);
.br
-int new_page(FIELD *field);
+bool new_page(const FIELD *field);
.br
.SH DESCRIPTION
-The function \fBset_new_page\fR marks the given field as the beginning of a
-new page on its form.
+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.
-The function \fBne_page\fR is a predicate which tests if a given field marks
+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.
diff --git a/lib/libform/form_opts.3 b/lib/libform/form_opts.3
index 5b3f97923ef..dc0e0c45de7 100644
--- a/lib/libform/form_opts.3
+++ b/lib/libform/form_opts.3
@@ -11,11 +11,11 @@ int form_opts_on(FORM *form, OPTIONS opts);
.br
int form_opts_off(FORM *form, OPTIONS opts);
.br
-OPTIONS form_opts(FORM *form);
+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-ored together).
+option bits may be logically-OR'ed together).
The function \fBform_opts_on\fR turns on the given option bits, and leaves
others alone.
diff --git a/lib/libform/form_page.3 b/lib/libform/form_page.3
index 99f1686c795..27beb3d1801 100644
--- a/lib/libform/form_page.3
+++ b/lib/libform/form_page.3
@@ -5,13 +5,15 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_current_field(FORM *form, int page);
+int set_current_field(FORM *form, FIELD *field);
.br
-FIELD *current_field(FORM *);
+FIELD *current_field(const FORM *);
.br
int set_form_page(FORM *form, int n);
.br
-int form_page(FORM *form);
+int form_page(const FORM *form);
+.br
+int field_index(const FIELD *field);
.br
.SH DESCRIPTION
The function \fBset_current field\fR sets the current field of the given
@@ -21,6 +23,10 @@ The function \fBset_form_page\fR sets the form's page number (goes to page
\fIn\fR of the form).
.PP
The function \fBform_page\fR returns the form's current page number.
+.PP
+The function \fBfield_index\fR returns the index of the field in the
+field array of the form it is connected to. It returns \fBERR\fR if
+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
diff --git a/lib/libform/form_requestname.3 b/lib/libform/form_requestname.3
new file mode 100644
index 00000000000..10824d3a704
--- /dev/null
+++ b/lib/libform/form_requestname.3
@@ -0,0 +1,40 @@
+'\" t
+.TH form_requestname 3X ""
+.SH NAME
+\fBform_requestname\fR - handle printable form request names
+.SH SYNOPSIS
+\fB#include <form.h>\fR
+.br
+const char *form_request_name(int request);
+.br
+int form_request_by_name(const char *name);
+.br
+.SH DESCRIPTION
+The function \fBform_request_name\fR returns the printable name of a form
+request code.
+.br
+The function \fBform_request_by_name\fR searches in the name-table for a request
+with the given name and returns its request code. Otherwise E_NO_MATCH is returned.
+.SH RETURN VALUE
+\fBform_request_name\fR returns \fBNULL\fR on error and sets errno
+to \fBE_BAD_ARGUMENT\fR.
+.br
+\fBform_request_by_name\fR returns \fBE_NO_MATCH\fR on error.
+.SH SEE ALSO
+\fBcurses\fR(3X), \fBform\fR(3X).
+.SH NOTES
+The header file \fB<form.h>\fR automatically includes the header file
+\fB<curses.h>\fR.
+.SH PORTABILITY
+These routines are specific to ncurses. They were not supported on
+Version 7, BSD or System V implementations. It is recommended that
+any code depending on them be conditioned using NCURSES_VERSION.
+.SH AUTHORS
+Juergen Pfeifer. Manual pages and adaptation for new curses by Eric
+S. Raymond.
+.\"#
+.\"# The following sets edit modes for GNU EMACS
+.\"# Local Variables:
+.\"# mode:nroff
+.\"# fill-column:79
+.\"# End:
diff --git a/lib/libform/form_userptr.3 b/lib/libform/form_userptr.3
index 78ef4f8cc64..b32963d4eb9 100644
--- a/lib/libform/form_userptr.3
+++ b/lib/libform/form_userptr.3
@@ -5,17 +5,17 @@
.SH SYNOPSIS
\fB#include <form.h>\fR
.br
-int set_form_userptr(FORM *form, char *userptr);
+int set_form_userptr(FORM *form, const void *userptr);
.br
-char form_userptr(FORM *form);
+const void* form_userptr(const FORM *form);
.br
.SH DESCRIPTION
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 each
-function \fB\set_form_userptrfR returns one of the following:
+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.
diff --git a/lib/libform/form_win.3 b/lib/libform/form_win.3
index 08b64547427..a43f9c08739 100644
--- a/lib/libform/form_win.3
+++ b/lib/libform/form_win.3
@@ -7,13 +7,13 @@
.br
int set_form_win(FORM *form, WINDOW *win);
.br
-WINDOW *form_win(FORM *form);
+WINDOW *form_win(const FORM *form);
.br
int set_form_sub(FORM *form, WINDOW *sub);
.br
-WINDOW *form_sub(FORM *form);
+WINDOW *form_sub(const FORM *form);
.br
-int scale_form(FORM *form, int *rows, int *columns);
+int scale_form(const FORM *form, int *rows, int *columns);
.br
.SH DESCRIPTION
Every form has an associated pair of \fBcurses\fR windows. The form window
@@ -23,7 +23,7 @@ displays the items of the form that are currently available for selection.
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.
-In the \fBset_\fR functions, window argument of \fBNULL\fR is treated as tbough
+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.
diff --git a/lib/libform/frm_data.c b/lib/libform/frm_data.c
index 53514ddf562..a55a1f02edf 100644
--- a/lib/libform/frm_data.c
+++ b/lib/libform/frm_data.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_data.c,v 1.3 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : bool data_behind(const FORM *form)
diff --git a/lib/libform/frm_def.c b/lib/libform/frm_def.c
index af555827d8e..3d60df4b384 100644
--- a/lib/libform/frm_def.c
+++ b/lib/libform/frm_def.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_def.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
+
/* this can't be readonly */
static FORM default_form = {
0, /* status */
diff --git a/lib/libform/frm_driver.c b/lib/libform/frm_driver.c
index 07bb76c1c4e..1642773c326 100644
--- a/lib/libform/frm_driver.c
+++ b/lib/libform/frm_driver.c
@@ -1,23 +1,24 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------
This is the core module of the form library. It contains the majority
@@ -64,6 +65,8 @@
#include "form.priv.h"
+MODULE_ID("Id: frm_driver.c,v 1.20 1997/05/01 16:47:54 juergen 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
@@ -80,6 +83,8 @@ Perhaps at some time we will make this configurable at runtime.
/* Implement a more user-friendly previous/next word behaviour */
#define FRIENDLY_PREV_NEXT_WORD (1)
+/* Fix the wrong behaviour for forms with all fields inactive */
+#define FIX_FORM_INACTIVE_BUG (1)
/*----------------------------------------------------------------------------
Forward references to some internally used static functions
@@ -425,7 +430,6 @@ static bool Field_Grown(FIELD * field, int amount)
if (field && Growable(field))
{
- FORM *form;
bool single_line_field = Single_Line_Field(field);
int old_buflen = Buffer_Length(field);
int new_buflen;
@@ -434,105 +438,107 @@ static bool Field_Grown(FIELD * field, int amount)
char *oldbuf = field->buf;
char *newbuf;
- if ( (form = field->form) )
+ int growth;
+ FORM *form = field->form;
+ bool need_visual_update = ((form != (FORM *)0) &&
+ (form->status & _POSTED) &&
+ (form->current==field));
+
+ if (need_visual_update)
+ Synchronize_Buffer(form);
+
+ if (single_line_field)
{
- bool need_visual_update = (form->status & _POSTED) &&
- (form->current==field);
- int growth;
-
- if (need_visual_update)
- Synchronize_Buffer(form);
+ growth = field->cols * amount;
+ if (field->maxgrow)
+ growth = Minimum(field->maxgrow - field->dcols,growth);
+ field->dcols += growth;
+ if (field->dcols == field->maxgrow)
+ field->status &= ~_MAY_GROW;
+ }
+ else
+ {
+ growth = (field->rows + field->nrow) * amount;
+ if (field->maxgrow)
+ 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));
+ if (!newbuf)
+ { /* 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)))
+ 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;
- if (single_line_field)
- {
- growth = field->cols * amount;
- if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->dcols,growth);
- field->dcols += growth;
- if (field->dcols == field->maxgrow)
- field->status &= ~_MAY_GROW;
- }
- else
+ field->buf = newbuf;
+ for(i=0;i<=field->nbuf;i++)
{
- growth = (field->rows + field->nrow) * amount;
- if (field->maxgrow)
- growth = Minimum(field->maxgrow - field->drows,growth);
- field->drows += growth;
- if (field->drows == field->maxgrow)
- field->status &= ~_MAY_GROW;
+ 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';
}
- /* 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));
- if (!newbuf)
- { /* 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)))
- 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;
- field->buf = newbuf;
- 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 + 1) = '\0';
- }
- 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;
- }
- 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);
+ 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;
}
- free(oldbuf);
- /* reflect changes in linked fields */
- if (field != field->link)
+ 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);
+ }
+
+ free(oldbuf);
+ /* reflect changes in linked fields */
+ if (field != field->link)
+ {
+ FIELD *linked_field;
+ for(linked_field = field->link;
+ linked_field!= field;
+ linked_field = linked_field->link)
{
- 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;
- }
+ linked_field->buf = field->buf;
+ linked_field->drows = field->drows;
+ linked_field->dcols = field->dcols;
}
- result = TRUE;
}
- }
+ result = TRUE;
+ }
}
return(result);
}
@@ -696,7 +702,6 @@ static int Refresh_Current_Field(FORM * form)
wsyncup(form->w);
}
}
- wrefresh(form->w); /* Will this catch them all? --Toby. */
untouchwin(form->w);
return Position_Form_Cursor(form);
}
@@ -873,8 +878,8 @@ static int Synchronize_Field(FIELD * field)
if (!field)
return(E_BAD_ARGUMENT);
- if ((form=field->form) &&
- Field_Really_Appears(field))
+ if (((form=field->form) != (FORM *)0)
+ && Field_Really_Appears(field))
{
if (field == form->current)
{
@@ -952,8 +957,8 @@ static int Synchronize_Attributes(FIELD * field)
if (!field)
return(E_BAD_ARGUMENT);
- if ((form=field->form) &&
- Field_Really_Appears(field))
+ if (((form=field->form) != (FORM *)0)
+ && Field_Really_Appears(field))
{
if (form->current==field)
{
@@ -1159,6 +1164,7 @@ static int Set_Current_Field(FORM *form, FIELD *newfield)
form->current = field;
form->w = new_window;
+ form->status &= ~_WINDOW_MODIFIED;
Set_Field_Window_Attributes(field,form->w);
if (Has_Invisible_Parts(field))
@@ -2103,11 +2109,16 @@ static int Field_Editing(int (* const fct) (FORM *), FORM * form)
}
else
{
- if ((fct==FE_New_Line) &&
- (form->opts & O_NL_OVERLOAD) &&
- First_Position_In_Current_Field(form) )
+ if (fct==FE_New_Line)
{
- res = Inter_Field_Navigation(FN_Next_Field,form);
+ if ((form->opts & O_NL_OVERLOAD) &&
+ First_Position_In_Current_Field(form))
+ {
+ res = Inter_Field_Navigation(FN_Next_Field,form);
+ }
+ else
+ /* FE_New_Line deals itself with the _WINDOW_MODIFIED flag */
+ res = fct(form);
}
else
{
@@ -2168,6 +2179,7 @@ static int FE_New_Line(FORM * form)
wclrtoeol(form->w);
form->currow++;
form->curcol = 0;
+ form->status |= _WINDOW_MODIFIED;
return(E_OK);
}
}
@@ -2197,6 +2209,7 @@ static int FE_New_Line(FORM * form)
wmove(form->w,form->currow,form->curcol);
winsertln(form->w);
waddnstr(form->w,bp,(int)(t-bp));
+ form->status |= _WINDOW_MODIFIED;
return E_OK;
}
}
@@ -3412,13 +3425,16 @@ static int Data_Entry(FORM * form, int c)
int result = E_REQUEST_DENIED;
bool End_Of_Field;
- if (field->opts & O_EDIT)
+ if ( (field->opts & O_EDIT)
+#if FIX_FORM_INACTIVE_BUG
+ && (field->opts & O_ACTIVE)
+#endif
+ )
{
- if ( (form->currow==0) &&
- (form->curcol==0) &&
- (field->opts & O_BLANK) &&
- !(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)
@@ -3936,6 +3952,8 @@ int form_page(const FORM * form)
| 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.
|
| Return Values : E_OK - success
| E_BAD_ARGUMENT - invalid argument
@@ -3946,44 +3964,69 @@ int set_field_buffer(FIELD * field, int buffer, const char * value)
char *s, *p;
int res = E_OK;
unsigned int len;
- unsigned int vlen;
if ( !field || !value || ((buffer < 0)||(buffer > field->nbuf)) )
RETURN(E_BAD_ARGUMENT);
+ len = Buffer_Length(field);
+
if (buffer==0)
{
const char *v;
+ unsigned int i = 0;
- for(v=value;*v;v++)
+ for(v=value; *v && (i<len); v++,i++)
{
if (!isprint((unsigned char)*v))
RETURN(E_BAD_ARGUMENT);
}
}
- len = Buffer_Length(field);
- vlen = strlen(value);
- if ((vlen>len) && Growable(field))
+ if (Growable(field))
{
- if (!Field_Grown(field,
- (int)(1 + (vlen-len)/((field->rows+field->nrow)*field->cols))))
- RETURN(E_SYSTEM_ERROR);
- }
+ /* for a growable field we must assume zero terminated strings, because
+ 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))))
+ 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(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[s-value]=*s++; else s=0;
+ for(s=(char *)value; *s && (s < (value+len)); s++)
+ p[s-value] = *s;
+ if (s < (value+len))
+ p[s-value] = *s++;
+ else
+ s=(char *)0;
#endif
if (s)
- {
+ { /* this means, value was null terminated and not greater than the
+ buffer. We have to pad with blanks */
assert(len >= (unsigned int)(s-p));
- memset(s,C_BLANK,len-(unsigned int)(s-p));
+ if (len > (unsigned int)(s-p))
+ memset(s,C_BLANK,len-(unsigned int)(s-p));
}
if (buffer==0)
diff --git a/lib/libform/frm_hook.c b/lib/libform/frm_hook.c
index 3ffac64e779..b68647e9819 100644
--- a/lib/libform/frm_hook.c
+++ b/lib/libform/frm_hook.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_hook.c,v 1.5 1997/05/01 16:47:54 juergen Exp $")
+
/* "Template" macro to generate function to set application specific hook */
#define GEN_HOOK_SET_FUNCTION( typ, name ) \
int set_ ## typ ## _ ## name (FORM *form, Form_Hook func)\
diff --git a/lib/libform/frm_opts.c b/lib/libform/frm_opts.c
index dfd27e6090b..738f2341ed6 100644
--- a/lib/libform/frm_opts.c
+++ b/lib/libform/frm_opts.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_opts.c,v 1.3 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_opts(FORM *form, Form_Options opts)
diff --git a/lib/libform/frm_req_name.c b/lib/libform/frm_req_name.c
new file mode 100644
index 00000000000..d5beaa0c375
--- /dev/null
+++ b/lib/libform/frm_req_name.c
@@ -0,0 +1,153 @@
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
+
+/***************************************************************************
+* Module form_request_name *
+* Routines to handle external names of menu requests *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: frm_req_name.c,v 1.1 1997/11/26 04:01:19 millert Exp $")
+
+static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = {
+ "NEXT_PAGE" ,
+ "PREV_PAGE" ,
+ "FIRST_PAGE" ,
+ "LAST_PAGE" ,
+
+ "NEXT_FIELD" ,
+ "PREV_FIELD" ,
+ "FIRST_FIELD" ,
+ "LAST_FIELD" ,
+ "SNEXT_FIELD" ,
+ "SPREV_FIELD" ,
+ "SFIRST_FIELD" ,
+ "SLAST_FIELD" ,
+ "LEFT_FIELD" ,
+ "RIGHT_FIELD" ,
+ "UP_FIELD" ,
+ "DOWN_FIELD" ,
+
+ "NEXT_CHAR" ,
+ "PREV_CHAR" ,
+ "NEXT_LINE" ,
+ "PREV_LINE" ,
+ "NEXT_WORD" ,
+ "PREV_WORD" ,
+ "BEG_FIELD" ,
+ "END_FIELD" ,
+ "BEG_LINE" ,
+ "END_LINE" ,
+ "LEFT_CHAR" ,
+ "RIGHT_CHAR" ,
+ "UP_CHAR" ,
+ "DOWN_CHAR" ,
+
+ "NEW_LINE" ,
+ "INS_CHAR" ,
+ "INS_LINE" ,
+ "DEL_CHAR" ,
+ "DEL_PREV" ,
+ "DEL_LINE" ,
+ "DEL_WORD" ,
+ "CLR_EOL" ,
+ "CLR_EOF" ,
+ "CLR_FIELD" ,
+ "OVL_MODE" ,
+ "INS_MODE" ,
+ "SCR_FLINE" ,
+ "SCR_BLINE" ,
+ "SCR_FPAGE" ,
+ "SCR_BPAGE" ,
+ "SCR_FHPAGE" ,
+ "SCR_BHPAGE" ,
+ "SCR_FCHAR" ,
+ "SCR_BCHAR" ,
+ "SCR_HFLINE" ,
+ "SCR_HBLINE" ,
+ "SCR_HFHALF" ,
+ "SCR_HBHALF" ,
+
+ "VALIDATION" ,
+ "NEXT_CHOICE" ,
+ "PREV_CHOICE"
+};
+#define A_SIZE (sizeof(request_names)/sizeof(request_names[0]))
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : const char * form_request_name (int request);
+|
+| Description : Get the external name of a form request.
+|
+| Return Values : Pointer to name - on success
+| NULL - on invalid request code
++--------------------------------------------------------------------------*/
+const char *form_request_name( int request )
+{
+ if ( (request < MIN_FORM_COMMAND) || (request > MAX_FORM_COMMAND) )
+ {
+ SET_ERROR (E_BAD_ARGUMENT);
+ return (const char *)0;
+ }
+ else
+ return request_names[ request - MIN_FORM_COMMAND ];
+}
+
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : int form_request_by_name (const char *str);
+|
+| Description : Search for a request with this name.
+|
+| Return Values : Request Id - on success
+| E_NO_MATCH - request not found
++--------------------------------------------------------------------------*/
+int form_request_by_name( const char *str )
+{
+ /* because the table is so small, it doesn't really hurt
+ to run sequentially through it.
+ */
+ unsigned int i = 0;
+ char buf[16];
+
+ if (str)
+ {
+ strncpy(buf,str,sizeof(buf));
+ while( (i<sizeof(buf)) && (buf[i] != '\0') )
+ {
+ buf[i] = toupper(buf[i]);
+ i++;
+ }
+
+ for (i=0; i < A_SIZE; i++)
+ {
+ if (strncmp(request_names[i],buf,sizeof(buf))==0)
+ return MIN_FORM_COMMAND + i;
+ }
+ }
+ RETURN(E_NO_MATCH);
+}
+
+/* frm_req_name.c ends here */
diff --git a/lib/libform/frm_user.c b/lib/libform/frm_user.c
index 5ef97a78f26..17d12869d2e 100644
--- a/lib/libform/frm_user.c
+++ b/lib/libform/frm_user.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_userptr(FORM *form, void *usrptr)
@@ -30,7 +33,7 @@
|
| Return Values : E_OK - on success
+--------------------------------------------------------------------------*/
-int set_form_userptr(FORM * form, void *usrptr)
+int set_form_userptr(FORM * form, const void *usrptr)
{
Normalize_Form(form)->usrptr = usrptr;
RETURN(E_OK);
@@ -46,7 +49,7 @@ int set_form_userptr(FORM * form, void *usrptr)
| Return Values : Value of pointer. If no such pointer has been set,
| NULL is returned
+--------------------------------------------------------------------------*/
-void *form_userptr(const FORM * form)
+const void *form_userptr(const FORM * form)
{
return Normalize_Form(form)->usrptr;
}
diff --git a/lib/libform/frm_win.c b/lib/libform/frm_win.c
index 81a18ab13f7..05162829bc8 100644
--- a/lib/libform/frm_win.c
+++ b/lib/libform/frm_win.c
@@ -1,26 +1,29 @@
-
-/***************************************************************************
-* COPYRIGHT NOTICE *
-****************************************************************************
-* ncurses is copyright (C) 1992-1995 *
-* Zeyd M. Ben-Halim *
-* zmbenhal@netcom.com *
-* Eric S. Raymond *
-* esr@snark.thyrsus.com *
-* *
-* Permission is hereby granted to reproduce and distribute ncurses *
-* by any means and for any fee, whether alone or as part of a *
-* larger distribution, in source or in binary form, PROVIDED *
-* this notice is included with any such distribution, and is not *
-* removed from any of its header files. Mention of ncurses in any *
-* applications linked with it is highly appreciated. *
-* *
-* ncurses comes AS IS with no warranty, implied or expressed. *
-* *
-***************************************************************************/
+/*-----------------------------------------------------------------------------+
+| The ncurses form library is Copyright (C) 1995-1997 |
+| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
+| All Rights Reserved. |
+| |
+| Permission to use, copy, modify, and distribute this software and its |
+| documentation for any purpose and without fee is hereby granted, provided |
+| that the above copyright notice appear in all copies and that both that |
+| copyright notice and this permission notice appear in supporting |
+| documentation, and that the name of the above listed copyright holder(s) not |
+| be used in advertising or publicity pertaining to distribution of the |
+| software without specific, written prior permission. |
+| |
+| THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
+| THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
+| NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
+| ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
+| SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
+| NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
+| THE USE OR PERFORMANCE OF THIS SOFTWARE. |
++-----------------------------------------------------------------------------*/
#include "form.priv.h"
+MODULE_ID("Id: frm_win.c,v 1.4 1997/05/01 16:47:54 juergen Exp $")
+
/*---------------------------------------------------------------------------
| Facility : libnform
| Function : int set_form_win(FORM *form,WINDOW *win)
@@ -45,11 +48,12 @@ int set_form_win(FORM * form, WINDOW * win)
|
| Description : Retrieve the window of the form.
|
-| Return Values : The pointer to the Window or NULL if there is none.
+| Return Values : The pointer to the Window or stdscr if there is none.
+--------------------------------------------------------------------------*/
WINDOW *form_win(const FORM * form)
{
- return Normalize_Form( form )->win;
+ const FORM* f = Normalize_Form( form );
+ return (f->win ? f->win : stdscr);
}
/*---------------------------------------------------------------------------
@@ -76,11 +80,12 @@ int set_form_sub(FORM * form, WINDOW * win)
|
| Description : Retrieve the window of the form.
|
-| Return Values : The pointer to the Window or NULL if there is none.
+| Return Values : The pointer to the Subwindow.
+--------------------------------------------------------------------------*/
WINDOW *form_sub(const FORM * form)
{
- return Normalize_Form( form )->sub;
+ const FORM* f = Normalize_Form( form );
+ return Get_Form_Window(f);
}
/* frm_win.c ends here */
diff --git a/lib/libform/fty_alnum.c b/lib/libform/fty_alnum.c
index 5d6acec0fee..1b05396d740 100644
--- a/lib/libform/fty_alnum.c
+++ b/lib/libform/fty_alnum.c
@@ -5,9 +5,16 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+MODULE_ID("Id: fty_alnum.c,v 1.6 1997/02/15 17:31:21 tom Exp $")
+
typedef struct {
int width;
} alnumARG;
@@ -40,7 +47,7 @@ static void *Make_AlphaNumeric_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_AlphaNumeric_Type(const void *argp)
{
- alnumARG *ap = (alnumARG *)argp;
+ const alnumARG *ap = (const alnumARG *)argp;
alnumARG *new = (alnumARG *)malloc(sizeof(alnumARG));
if (new)
@@ -76,7 +83,7 @@ static void Free_AlphaNumeric_Type(void * argp)
+--------------------------------------------------------------------------*/
static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
{
- int width = ((alnumARG *)argp)->width;
+ int width = ((const alnumARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
int l = -1;
unsigned char *s;
@@ -106,7 +113,7 @@ static bool Check_AlphaNumeric_Field(FIELD * field, const void * argp)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_AlphaNumeric_Character(int c, const void * argp)
+static bool Check_AlphaNumeric_Character(int c, const void * argp GCC_UNUSED)
{
return (isalnum(c) ? TRUE : FALSE);
}
diff --git a/lib/libform/fty_alpha.c b/lib/libform/fty_alpha.c
index 9471f122357..f36a03c8988 100644
--- a/lib/libform/fty_alpha.c
+++ b/lib/libform/fty_alpha.c
@@ -5,9 +5,16 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+MODULE_ID("Id: fty_alpha.c,v 1.6 1997/02/15 17:31:08 tom Exp $")
+
typedef struct {
int width;
} alphaARG;
@@ -40,7 +47,7 @@ static void *Make_Alpha_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_Alpha_Type(const void * argp)
{
- alphaARG *ap = (alphaARG *)argp;
+ const alphaARG *ap = (const alphaARG *)argp;
alphaARG *new = (alphaARG *)malloc(sizeof(alphaARG));
if (new)
@@ -77,7 +84,7 @@ static void Free_Alpha_Type(void * argp)
+--------------------------------------------------------------------------*/
static bool Check_Alpha_Field(FIELD * field, const void * argp)
{
- int width = ((alphaARG *)argp)->width;
+ int width = ((const alphaARG *)argp)->width;
unsigned char *bp = (unsigned char *)field_buffer(field,0);
int l = -1;
unsigned char *s;
@@ -107,7 +114,7 @@ static bool Check_Alpha_Field(FIELD * field, const void * argp)
| Return Values : TRUE - character is valid
| FALSE - character is invalid
+--------------------------------------------------------------------------*/
-static bool Check_Alpha_Character(int c, const void * argp)
+static bool Check_Alpha_Character(int c, const void * argp GCC_UNUSED)
{
return (isalpha(c) ? TRUE : FALSE);
}
diff --git a/lib/libform/fty_enum.c b/lib/libform/fty_enum.c
index b62f0d92faf..7d54e7779b2 100644
--- a/lib/libform/fty_enum.c
+++ b/lib/libform/fty_enum.c
@@ -5,9 +5,16 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+MODULE_ID("Id: fty_enum.c,v 1.5 1997/02/15 17:33:59 tom Exp $")
+
typedef struct {
char **kwds;
int count;
@@ -55,7 +62,7 @@ static void *Make_Enum_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_Enum_Type(const void * argp)
{
- enumARG *ap = (enumARG *)argp;
+ const enumARG *ap = (const enumARG *)argp;
enumARG *new = (enumARG *)0;
if (argp)
@@ -152,9 +159,9 @@ static int Compare(const unsigned char *s, const unsigned char *buf,
+--------------------------------------------------------------------------*/
static bool Check_Enum_Field(FIELD * field, const void * argp)
{
- char **kwds = ((enumARG *)argp)->kwds;
- bool ccase = ((enumARG *)argp)->checkcase;
- bool unique = ((enumARG *)argp)->checkunique;
+ 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;
@@ -203,7 +210,7 @@ static const char *dummy[] = { (char *)0 };
+--------------------------------------------------------------------------*/
static bool Next_Enum(FIELD * field, const void * argp)
{
- enumARG *args = (enumARG *)argp;
+ const enumARG *args = (const enumARG *)argp;
char **kwds = args->kwds;
bool ccase = args->checkcase;
int cnt = args->count;
@@ -237,7 +244,7 @@ static bool Next_Enum(FIELD * field, const void * argp)
+--------------------------------------------------------------------------*/
static bool Previous_Enum(FIELD * field, const void * argp)
{
- enumARG *args = (enumARG *)argp;
+ const enumARG *args = (const enumARG *)argp;
int cnt = args->count;
char **kwds = &args->kwds[cnt-1];
bool ccase = args->checkcase;
diff --git a/lib/libform/fty_int.c b/lib/libform/fty_int.c
index 8a713b45f74..e4238d8bc38 100644
--- a/lib/libform/fty_int.c
+++ b/lib/libform/fty_int.c
@@ -5,13 +5,20 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+MODULE_ID("Id: fty_int.c,v 1.7 1997/04/19 15:22:40 juergen Exp $")
+
typedef struct {
int precision;
- int low;
- int high;
+ long low;
+ long high;
} integerARG;
/*---------------------------------------------------------------------------
@@ -29,8 +36,8 @@ static void *Make_Integer_Type(va_list * ap)
if (argp)
{
argp->precision = va_arg(*ap,int);
- argp->low = va_arg(*ap,int);
- argp->high = va_arg(*ap,int);
+ argp->low = va_arg(*ap,long);
+ argp->high = va_arg(*ap,long);
}
return (void *)argp;
}
@@ -45,7 +52,7 @@ static void *Make_Integer_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_Integer_Type(const void * argp)
{
- integerARG *ap = (integerARG *)argp;
+ const integerARG *ap = (const integerARG *)argp;
integerARG *new = (integerARG *)0;
if (argp)
@@ -84,9 +91,9 @@ static void Free_Integer_Type(void * argp)
+--------------------------------------------------------------------------*/
static bool Check_Integer_Field(FIELD * field, const void * argp)
{
- integerARG *argi = (integerARG *)argp;
- int low = argi->low;
- int high = argi->high;
+ 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;
@@ -110,7 +117,7 @@ static bool Check_Integer_Field(FIELD * field, const void * argp)
{
if (val<low || val>high) return FALSE;
}
- sprintf(buf,"%.*ld",prec,val);
+ sprintf(buf,"%.*ld",(prec>0?prec:0),val);
set_field_buffer(field,0,buf);
return TRUE;
}
@@ -129,7 +136,7 @@ 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)
+static bool Check_Integer_Character(int c, const void * argp GCC_UNUSED)
{
return ((isdigit(c) || (c=='-')) ? TRUE : FALSE);
}
diff --git a/lib/libform/fty_ipv4.c b/lib/libform/fty_ipv4.c
new file mode 100644
index 00000000000..f3b18db0472
--- /dev/null
+++ b/lib/libform/fty_ipv4.c
@@ -0,0 +1,81 @@
+
+/*
+ * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT.
+ * You may freely copy it for use as a template for your own field types.
+ * If you develop a field type that might be of general use, please send
+ * it back to the ncurses maintainers for inclusion in the next version.
+ */
+/***************************************************************************
+* *
+* Author : Per Foreby, perf@efd.lth.se *
+* *
+***************************************************************************/
+
+#include "form.priv.h"
+
+MODULE_ID("$Id: fty_ipv4.c,v 1.1 1997/11/26 04:01:25 millert Exp $")
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_IPV4_Field(
+| FIELD * field,
+| const void * argp)
+|
+| Description : Validate buffer content to be a valid IP number (Ver. 4)
+|
+| Return Values : TRUE - field is valid
+| FALSE - field is invalid
++--------------------------------------------------------------------------*/
+static bool Check_IPV4_Field(FIELD * field, const void * argp GCC_UNUSED)
+{
+ char *bp = field_buffer(field,0);
+ int num = 0, len;
+ unsigned int d1, d2, d3, d4;
+
+ if(isdigit(*bp)) /* Must start with digit */
+ {
+ num = sscanf(bp, "%u.%u.%u.%u%n", &d1, &d2, &d3, &d4, &len);
+ if (num == 4)
+ {
+ bp += len; /* Make bp point to what sscanf() left */
+ while (*bp && isspace(*bp))
+ bp++; /* Allow trailing whitespace */
+ }
+ }
+ return ((num != 4 || *bp || d1 > 255 || d2 > 255
+ || d3 > 255 || d4 > 255) ? FALSE : TRUE);
+}
+
+/*---------------------------------------------------------------------------
+| Facility : libnform
+| Function : static bool Check_IPV4_Character(
+| int c,
+| const void *argp )
+|
+| Description : Check a character for unsigned type or period.
+|
+| Return Values : TRUE - character is valid
+| FALSE - character is invalid
++--------------------------------------------------------------------------*/
+static bool Check_IPV4_Character(int c, const void * argp GCC_UNUSED)
+{
+ return ((isdigit(c) || (c=='.')) ? TRUE : FALSE);
+}
+
+static FIELDTYPE typeIPV4 = {
+ _RESIDENT,
+ 1, /* this is mutable, so we can't be const */
+ (FIELDTYPE *)0,
+ (FIELDTYPE *)0,
+ NULL,
+ NULL,
+ NULL,
+ Check_IPV4_Field,
+ Check_IPV4_Character,
+ NULL,
+ NULL
+};
+
+FIELDTYPE* TYPE_IPV4 = &typeIPV4;
+
+/* fty_ipv4.c ends here */
diff --git a/lib/libform/fty_num.c b/lib/libform/fty_num.c
index 795cd40f1a8..af72a68c662 100644
--- a/lib/libform/fty_num.c
+++ b/lib/libform/fty_num.c
@@ -5,9 +5,19 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+
+MODULE_ID("Id: fty_num.c,v 1.9 1997/04/19 17:26:38 juergen Exp $")
+
+#if HAVE_LOCALE_H
#include <locale.h>
+#endif
typedef struct {
int precision;
@@ -33,7 +43,11 @@ static void *Make_Numeric_Type(va_list * ap)
argn->precision = va_arg(*ap,int);
argn->low = va_arg(*ap,double);
argn->high = va_arg(*ap,double);
+#if HAVE_LOCALE_H
argn->L = localeconv();
+#else
+ argn->L = NULL;
+#endif
}
return (void *)argn;
}
@@ -48,7 +62,7 @@ static void *Make_Numeric_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_Numeric_Type(const void * argp)
{
- numericARG *ap = (numericARG *)argp;
+ const numericARG *ap = (const numericARG *)argp;
numericARG *new = (numericARG *)0;
if (argp)
@@ -86,7 +100,7 @@ static void Free_Numeric_Type(void * argp)
+--------------------------------------------------------------------------*/
static bool Check_Numeric_Field(FIELD * field, const void * argp)
{
- numericARG *argn = (numericARG *)argp;
+ const numericARG *argn = (const numericARG *)argp;
double low = argn->low;
double high = argn->high;
int prec = argn->precision;
@@ -106,7 +120,11 @@ static bool Check_Numeric_Field(FIELD * field, const void * argp)
if (!isdigit(*bp)) break;
bp++;
}
- if (*bp==((L && L->decimal_point) ? *(L->decimal_point) : '.'))
+ if (*bp==(
+#if HAVE_LOCALE_H
+ (L && L->decimal_point) ? *(L->decimal_point) :
+#endif
+ '.'))
{
bp++;
while(*bp)
@@ -123,7 +141,7 @@ static bool Check_Numeric_Field(FIELD * field, const void * argp)
{
if (val<low || val>high) return FALSE;
}
- sprintf(buf,"%.*f",prec,val);
+ sprintf(buf,"%.*f",(prec>0?prec:0),val);
set_field_buffer(field,0,buf);
return TRUE;
}
@@ -144,14 +162,18 @@ static bool Check_Numeric_Field(FIELD * field, const void * argp)
+--------------------------------------------------------------------------*/
static bool Check_Numeric_Character(int c, const void * argp)
{
- numericARG *argn = (numericARG *)argp;
+ const numericARG *argn = (const numericARG *)argp;
struct lconv* L = argn->L;
return (isdigit(c) ||
c == '+' ||
c == '-' ||
- c == ((L && L->decimal_point) ? *(L->decimal_point) : '.')
- ) ? TRUE : FALSE;
+ c == (
+#ifdef HAVE_LOCALE_H
+ (L && L->decimal_point) ? *(L->decimal_point) :
+#endif
+ '.')
+ ) ? TRUE : FALSE;
}
static FIELDTYPE typeNUMERIC = {
diff --git a/lib/libform/fty_regex.c b/lib/libform/fty_regex.c
index 76b63bc7378..6ba9f7c2180 100644
--- a/lib/libform/fty_regex.c
+++ b/lib/libform/fty_regex.c
@@ -5,19 +5,26 @@
* 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@T-Online.de *
+* *
+***************************************************************************/
#include "form.priv.h"
+MODULE_ID("Id: fty_regex.c,v 1.9 1997/05/01 16:03:17 tom Exp $")
+
#if HAVE_REGEX_H /* We prefer POSIX regex */
#include <regex.h>
typedef struct
{
regex_t *pRegExp;
- unsigned long refCount;
+ unsigned long *refCount;
} RegExp_Arg;
-#elif HAVE_REGEXP_H
+#elif HAVE_REGEXP_H | HAVE_REGEXPR_H
#undef RETURN
static int reg_errno;
@@ -40,12 +47,16 @@ static char *RegEx_Error(int code)
#define RETURN(c) return(c)
#define ERROR(c) return RegEx_Error(c)
+#if HAVE_REGEXP_H
#include <regexp.h>
+#else
+#include <regexpr.h>
+#endif
typedef struct
{
char *compiled_expression;
- unsigned long refCount;
+ unsigned long *refCount;
} RegExp_Arg;
/* Maximum Length we allow for a compiled regular expression */
@@ -71,11 +82,12 @@ static void *Make_RegularExpression_Type(va_list * ap)
preg = (RegExp_Arg*)malloc(sizeof(RegExp_Arg));
if (preg)
{
- if ((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) &&
- !regcomp(preg->pRegExp,rx,
+ if (((preg->pRegExp = (regex_t*)malloc(sizeof(regex_t))) != (regex_t*)0)
+ && !regcomp(preg->pRegExp,rx,
(REG_EXTENDED | REG_NOSUB | REG_NEWLINE) ))
{
- preg->refCount = 1;
+ preg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ *(preg->refCount) = 1;
}
else
{
@@ -86,7 +98,7 @@ static void *Make_RegularExpression_Type(va_list * ap)
}
}
return((void *)preg);
-#elif HAVE_REGEXP_H
+#elif HAVE_REGEXP_H | HAVE_REGEXPR_H
char *rx = va_arg(*ap,char *);
RegExp_Arg *pArg;
@@ -96,13 +108,18 @@ static void *Make_RegularExpression_Type(va_list * ap)
{
int blen = RX_INCREMENT;
pArg->compiled_expression = NULL;
- pArg->refCount = 1;
+ pArg->refCount = (unsigned long *)malloc(sizeof(unsigned long));
+ *(pArg->refCount) = 1;
do {
char *buf = (char *)malloc(blen);
if (buf)
{
+#if HAVE_REGEXP_H
char *last_pos = compile (rx, buf, &buf[blen], '\0');
+#else
+ char *last_pos = compile (rx, buf, &buf[blen], '\0');
+#endif
if (reg_errno)
{
free(buf);
@@ -145,13 +162,13 @@ static void *Make_RegularExpression_Type(va_list * ap)
+--------------------------------------------------------------------------*/
static void *Copy_RegularExpression_Type(const void * argp)
{
-#if (HAVE_REGEX_H | HAVE_REGEXP_H)
- RegExp_Arg *ap = (RegExp_Arg *)argp;
- RegExp_Arg *new = (RegExp_Arg *)0;
+#if (HAVE_REGEX_H | HAVE_REGEXP_H | HAVE_REGEXPR_H)
+ const RegExp_Arg *ap = (const RegExp_Arg *)argp;
+ const RegExp_Arg *new = (const RegExp_Arg *)0;
if (ap)
{
- (ap->refCount)++;
+ *(ap->refCount) += 1;
new = ap;
}
return (void *)new;
@@ -170,18 +187,24 @@ static void *Copy_RegularExpression_Type(const void * argp)
+--------------------------------------------------------------------------*/
static void Free_RegularExpression_Type(void * argp)
{
-#if HAVE_REGEX_H | HAVE_REGEXP_H
+#if HAVE_REGEX_H | HAVE_REGEXP_H | HAVE_REGEXPR_H
RegExp_Arg *ap = (RegExp_Arg *)argp;
if (ap)
{
- if (--(ap->refCount) == 0)
+ if (--(*(ap->refCount)) == 0)
{
#if HAVE_REGEX_H
if (ap->pRegExp)
- regfree(ap->pRegExp);
-#elif HAVE_REGEXP_H
+ {
+ free(ap->refCount);
+ regfree(ap->pRegExp);
+ }
+#elif HAVE_REGEXP_H | HAVE_REGEXPR_H
if (ap->compiled_expression)
- free(ap->compiled_expression);
+ {
+ free(ap->refCount);
+ free(ap->compiled_expression);
+ }
#endif
free(ap);
}
@@ -204,10 +227,10 @@ static bool Check_RegularExpression_Field(FIELD * field, const void * argp)
{
bool match = FALSE;
#if HAVE_REGEX_H
- RegExp_Arg *ap = (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);
-#elif HAVE_REGEXP_H
+#elif HAVE_REGEXP_H | HAVE_REGEXPR_H
RegExp_Arg *ap = (RegExp_Arg *)argp;
if (ap && ap->compiled_expression)
match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE);
diff --git a/lib/libform/shlib_version b/lib/libform/shlib_version
index 97c9f92d6b8..1edea46de91 100644
--- a/lib/libform/shlib_version
+++ b/lib/libform/shlib_version
@@ -1,2 +1,2 @@
-major=0
+major=1
minor=0