diff options
68 files changed, 2087 insertions, 1300 deletions
diff --git a/lib/libform/Makefile b/lib/libform/Makefile index d3d20c7765e..0f3eafacbdb 100644 --- a/lib/libform/Makefile +++ b/lib/libform/Makefile @@ -1,8 +1,11 @@ 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_ipv4.c \ - frm_req_name.c +SRCS= fld_arg.c fld_attr.c fld_current.c fld_def.c fld_dup.c fld_ftchoice.c \ + fld_ftlink.c fld_info.c fld_just.c fld_link.c fld_max.c fld_move.c \ + fld_newftyp.c fld_opts.c fld_pad.c fld_page.c fld_stat.c fld_type.c \ + fld_user.c frm_adabind.c frm_cursor.c frm_data.c frm_def.c \ + frm_driver.c frm_hook.c frm_opts.c frm_page.c frm_post.c \ + frm_req_name.c frm_scale.c frm_sub.c frm_user.c frm_win.c fty_alnum.c \ + fty_alpha.c fty_enum.c fty_int.c fty_ipv4.c fty_num.c fty_regex.c HDRS= form.h 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 \ diff --git a/lib/libform/READ.ME b/lib/libform/READ.ME index bb26b1cb7de..12a540ea615 100644 --- a/lib/libform/READ.ME +++ b/lib/libform/READ.ME @@ -2,13 +2,9 @@ This is a clone of the form library that is available with typical System V curses implementations (ETI). It is modelled after the documentation that comes for this library with -a 386 based SVR4 implementation (ESIX). This system was used together -with an NCR3000 system to compile the clone using original curses -implementation and to run various programs to check the compatibility of -this clone with the original libform library. +a 386 based SVR4 implementation (ESIX). -The development environment was an ELF based Linux system, the German -Unifix distribution (aka Linux FT). +The development environment was and is an ELF based Linux system. For things that still need doing, see the TO-DO file in the top-level directory. diff --git a/lib/libform/fld_arg.c b/lib/libform/fld_arg.c new file mode 100644 index 00000000000..7b1bb6df06e --- /dev/null +++ b/lib/libform/fld_arg.c @@ -0,0 +1,83 @@ +/* $OpenBSD: fld_arg.c,v 1.1 1997/12/03 05:39:50 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_arg.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_fieldtype_arg( +| FIELDTYPE *typ, +| void * (* const make_arg)(va_list *), +| void * (* const copy_arg)(const void *), +| void (* const free_arg)(void *) ) +| +| Description : Connects to the type additional arguments necessary +| for a set_field_type call. The various function pointer +| arguments are: +| make_arg : allocates a structure for the field +| specific parameters. +| copy_arg : duplicate the structure created by +| make_arg +| free_arg : Release the memory allocated by make_arg +| or copy_arg +| +| At least make_arg must be non-NULL. +| You may pass NULL for copy_arg and free_arg if your +| make_arg function doesn't allocate memory and your +| arg fits into the storage for a (void*). +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid argument ++--------------------------------------------------------------------------*/ +int set_fieldtype_arg(FIELDTYPE * typ, + void * (* const make_arg)(va_list *), + void * (* const copy_arg)(const void *), + void (* const free_arg)(void *)) +{ + if ( !typ || !make_arg ) + RETURN(E_BAD_ARGUMENT); + + typ->status |= _HAS_ARGS; + typ->makearg = make_arg; + typ->copyarg = copy_arg; + typ->freearg = free_arg; + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : void *field_arg(const FIELD *field) +| +| Description : Retrieve pointer to the fields argument structure. +| +| Return Values : Pointer to structure or NULL if none is defined. ++--------------------------------------------------------------------------*/ +void *field_arg(const FIELD * field) +{ + return Normalize_Field(field)->arg; +} + +/* fld_arg.c ends here */ diff --git a/lib/libform/fld_attr.c b/lib/libform/fld_attr.c new file mode 100644 index 00000000000..ebe0e17e3e8 --- /dev/null +++ b/lib/libform/fld_attr.c @@ -0,0 +1,103 @@ +/* $OpenBSD: fld_attr.c,v 1.1 1997/12/03 05:39:51 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_attr.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*---------------------------------------------------------------------------- + Field-Attribute manipulation routines + --------------------------------------------------------------------------*/ +/* "Template" macro to generate a function to set a fields attribute */ +#define GEN_FIELD_ATTR_SET_FCT( name ) \ +int set_field_ ## name (FIELD * field, chtype attr)\ +{\ + int res = E_BAD_ARGUMENT;\ + if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\ + {\ + Normalize_Field( field );\ + if ((field -> name) != attr)\ + {\ + field -> name = attr;\ + res = _nc_Synchronize_Attributes( field );\ + }\ + else\ + res = E_OK;\ + }\ + RETURN(res);\ +} + +/* "Template" macro to generate a function to get a fields attribute */ +#define GEN_FIELD_ATTR_GET_FCT( name ) \ +chtype field_ ## name (const FIELD * field)\ +{\ + return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\ +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_field_fore(FIELD *field, chtype attr) +| +| Description : Sets the foreground of the field used to display the +| field contents. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid attributes +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +GEN_FIELD_ATTR_SET_FCT( fore ) + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : chtype field_fore(const FIELD *) +| +| Description : Retrieve fields foreground attribute +| +| Return Values : The foreground attribute ++--------------------------------------------------------------------------*/ +GEN_FIELD_ATTR_GET_FCT( fore ) + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_field_back(FIELD *field, chtype attr) +| +| Description : Sets the background of the field used to display the +| fields extend. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid attributes +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +GEN_FIELD_ATTR_SET_FCT( back ) + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : chtype field_back(const +| +| Description : Retrieve fields background attribute +| +| Return Values : The background attribute ++--------------------------------------------------------------------------*/ +GEN_FIELD_ATTR_GET_FCT( back ) + +/* fld_attr.c ends here */ diff --git a/lib/libform/fld_current.c b/lib/libform/fld_current.c new file mode 100644 index 00000000000..e34affe9c6a --- /dev/null +++ b/lib/libform/fld_current.c @@ -0,0 +1,116 @@ +/* $OpenBSD: fld_current.c,v 1.1 1997/12/03 05:39:51 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_current.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_current_field(FORM * form,FIELD * field) +| +| Description : Set the current field of the form to the specified one. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid form or field pointer +| E_REQUEST_DENIED - field not selectable +| E_BAD_STATE - called from a hook routine +| E_INVALID_FIELD - current field can't be left +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int set_current_field(FORM * form, FIELD * field) +{ + int err = E_OK; + + if ( !form || !field ) + RETURN(E_BAD_ARGUMENT); + + if ( (form != field->form) || Field_Is_Not_Selectable(field) ) + RETURN(E_REQUEST_DENIED); + + if (!(form->status & _POSTED)) + { + form->current = field; + form->curpage = field->page; + } + else + { + if (form->status & _IN_DRIVER) + err = E_BAD_STATE; + else + { + if (form->current != field) + { + if (!_nc_Internal_Validation(form)) + err = E_INVALID_FIELD; + else + { + Call_Hook(form,fieldterm); + if (field->page != form->curpage) + { + Call_Hook(form,formterm); + err = _nc_Set_Form_Page(form,field->page,field); + Call_Hook(form,forminit); + } + else + { + err = _nc_Set_Current_Field(form,field); + } + Call_Hook(form,fieldinit); + _nc_Refresh_Current_Field(form); + } + } + } + } + RETURN(err); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : FIELD *current_field(const FORM * form) +| +| Description : Return the current field. +| +| Return Values : Pointer to the current field. ++--------------------------------------------------------------------------*/ +FIELD *current_field(const FORM * form) +{ + return Normalize_Form(form)->current; +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_index(const FIELD * field) +| +| Description : Return the index of the field in the field-array of +| the form. +| +| Return Values : >= 0 : field index +| -1 : fieldpointer invalid or field not connected ++--------------------------------------------------------------------------*/ +int field_index(const FIELD * field) +{ + return ( (field && field->form) ? field->index : -1 ); +} + +/* fld_current.c ends here */ diff --git a/lib/libform/fld_def.c b/lib/libform/fld_def.c index d18f9ed6b82..ae1cc79b5b9 100644 --- a/lib/libform/fld_def.c +++ b/lib/libform/fld_def.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fld_def.c,v 1.3 1997/12/03 05:39:52 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,7 +24,7 @@ #include "form.priv.h" -MODULE_ID("Id: fld_def.c,v 1.6 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: fld_def.c,v 1.9 1997/10/21 13:24:19 juergen Exp $") /* this can't be readonly */ static FIELD default_field = { @@ -57,7 +59,7 @@ FIELD *_nc_Default_Field = &default_field; /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static TypeArgument *Make_Argument( +| Function : TypeArgument *_nc_Make_Argument( | const FIELDTYPE *typ, | va_list *ap, | int *err ) @@ -69,7 +71,8 @@ FIELD *_nc_Default_Field = &default_field; | Return Values : Pointer to argument structure. Maybe NULL. | In case of an error in *err an errorcounter is increased. +--------------------------------------------------------------------------*/ -static TypeArgument* Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err) +TypeArgument* +_nc_Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err) { TypeArgument *res = (TypeArgument *)0; TypeArgument *p; @@ -82,14 +85,15 @@ static TypeArgument* Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err) p = (TypeArgument *)malloc(sizeof(TypeArgument)); if (p) { - p->left = Make_Argument(typ->left ,ap,err); - p->right = Make_Argument(typ->right,ap,err); + p->left = _nc_Make_Argument(typ->left ,ap,err); + p->right = _nc_Make_Argument(typ->right,ap,err); return p; } else *err += 1; } else { + assert(typ->makearg); if ( !(res=(TypeArgument *)typ->makearg(ap)) ) *err += 1; } @@ -99,10 +103,9 @@ static TypeArgument* Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static TypeArgument *Copy_Argument( -| const FIELDTYPE *typ, -| const TypeArgument *argp, -| int *err ) +| Function : TypeArgument *_nc_Copy_Argument(const FIELDTYPE *typ, +| const TypeArgument *argp, +| int *err ) | | Description : Create a copy of an argument structure for the specified | type. @@ -110,8 +113,9 @@ static TypeArgument* Make_Argument(const FIELDTYPE *typ, va_list *ap, int *err) | Return Values : Pointer to argument structure. Maybe NULL. | In case of an error in *err an errorcounter is increased. +--------------------------------------------------------------------------*/ -static TypeArgument *Copy_Argument(const FIELDTYPE *typ, - const TypeArgument *argp, int *err) +TypeArgument* +_nc_Copy_Argument(const FIELDTYPE *typ, + const TypeArgument *argp, int *err) { TypeArgument *res = (TypeArgument *)0; TypeArgument *p; @@ -124,16 +128,21 @@ static TypeArgument *Copy_Argument(const FIELDTYPE *typ, p = (TypeArgument *)malloc(sizeof(TypeArgument)); if (p) { - p->left = Copy_Argument(typ,argp->left ,err); - p->right = Copy_Argument(typ,argp->right,err); + p->left = _nc_Copy_Argument(typ,argp->left ,err); + p->right = _nc_Copy_Argument(typ,argp->right,err); return p; } *err += 1; } else { - if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp)))) - *err += 1; + if (typ->copyarg) + { + if (!(res = (TypeArgument *)(typ->copyarg((const void *)argp)))) + *err += 1; + } + else + res = (TypeArgument *)argp; } } return res; @@ -141,16 +150,16 @@ static TypeArgument *Copy_Argument(const FIELDTYPE *typ, /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static void Free_Argument( -| const FIELDTYPE *typ, -| TypeArgument * argp ) +| Function : void _nc_Free_Argument(const FIELDTYPE *typ, +| TypeArgument * argp ) | | Description : Release memory associated with the argument structure | for the given fieldtype. | | Return Values : - +--------------------------------------------------------------------------*/ -static void Free_Argument(const FIELDTYPE * typ, TypeArgument * argp) +void +_nc_Free_Argument(const FIELDTYPE * typ, TypeArgument * argp) { if (!typ || !(typ->status & _HAS_ARGS)) return; @@ -158,63 +167,66 @@ static void Free_Argument(const FIELDTYPE * typ, TypeArgument * argp) if (typ->status & _LINKED_TYPE) { assert(argp); - Free_Argument(typ->left ,argp->left ); - Free_Argument(typ->right,argp->right); + _nc_Free_Argument(typ->left ,argp->left ); + _nc_Free_Argument(typ->right,argp->right); free(argp); } else { - typ->freearg((void *)argp); + if (typ->freearg) + typ->freearg((void *)argp); } } /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static bool Copy_Type( FIELD *new, FIELD const *old ) +| Function : bool _nc_Copy_Type( FIELD *dst, FIELD const *src ) | -| Description : Copy argument structure of field old to field new +| Description : Copy argument structure of field src to field dst | | Return Values : TRUE - copy worked | FALSE - error occured +--------------------------------------------------------------------------*/ -static bool Copy_Type(FIELD *new, FIELD const *old) +bool +_nc_Copy_Type(FIELD *dst, FIELD const *src) { int err = 0; - assert(new && old); + assert(dst && src); - new->type = old->type; - new->arg = (void *)Copy_Argument(old->type,(TypeArgument *)(old->arg),&err); + dst->type = src->type; + dst->arg = (void *)_nc_Copy_Argument(src->type,(TypeArgument *)(src->arg),&err); if (err) { - Free_Argument(new->type,(TypeArgument *)(new->arg)); - new->type = (FIELDTYPE *)0; - new->arg = (void *)0; + _nc_Free_Argument(dst->type,(TypeArgument *)(dst->arg)); + dst->type = (FIELDTYPE *)0; + dst->arg = (void *)0; return FALSE; } else { - if (new->type) - new->type->ref++; + if (dst->type) + dst->type->ref++; return TRUE; } } /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static void Free_Type( FIELD *field ) +| Function : void _nc_Free_Type( FIELD *field ) | | Description : Release Argument structure for this field | | Return Values : - +--------------------------------------------------------------------------*/ -INLINE static void Free_Type(FIELD *field) +void +_nc_Free_Type(FIELD *field) { assert(field); if (field->type) field->type->ref--; - Free_Argument(field->type,(TypeArgument *)(field->arg)); + _nc_Free_Argument(field->type,(TypeArgument *)(field->arg)); } /*--------------------------------------------------------------------------- @@ -258,7 +270,7 @@ FIELD *new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf) New_Field->nbuf = nbuf; New_Field->link = New_Field; - if (Copy_Type(New_Field,&default_field)) + if (_nc_Copy_Type(New_Field,&default_field)) { size_t len; @@ -289,119 +301,6 @@ FIELD *new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : FIELD *dup_field(FIELD *field, int frow, int fcol) -| -| Description : Duplicates the field at the specified position. All -| field attributes and the buffers are copied. -| If an error occurs, errno is set to -| -| E_BAD_ARGUMENT - invalid argument -| E_SYSTEM_ERROR - system error -| -| Return Values : Pointer to the new field or NULL if failure -+--------------------------------------------------------------------------*/ -FIELD *dup_field(FIELD * field, int frow, int fcol) -{ - FIELD *New_Field = (FIELD *)0; - int err = E_BAD_ARGUMENT; - - if (field && (frow>=0) && (fcol>=0) && - ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */ - (New_Field=(FIELD *)malloc(sizeof(FIELD))) ) - { - *New_Field = default_field; - New_Field->frow = frow; - New_Field->fcol = fcol; - New_Field->link = New_Field; - New_Field->rows = field->rows; - New_Field->cols = field->cols; - New_Field->nrow = field->nrow; - New_Field->drows = field->drows; - New_Field->dcols = field->dcols; - New_Field->maxgrow = field->maxgrow; - New_Field->nbuf = field->nbuf; - New_Field->just = field->just; - New_Field->fore = field->fore; - New_Field->back = field->back; - New_Field->pad = field->pad; - New_Field->opts = field->opts; - New_Field->usrptr = field->usrptr; - - if (Copy_Type(New_Field,field)) - { - size_t len; - - len = Total_Buffer_Size(New_Field); - if ( (New_Field->buf=(char *)malloc(len)) ) - { - memcpy(New_Field->buf,field->buf,len); - return New_Field; - } - } - } - - if (New_Field) - free_field(New_Field); - - SET_ERROR(err); - return (FIELD *)0; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : FIELD *link_field(FIELD *field, int frow, int fcol) -| -| Description : Duplicates the field at the specified position. The -| new field shares its buffers with the original one, -| the attributes are independent. -| If an error occurs, errno is set to -| -| E_BAD_ARGUMENT - invalid argument -| E_SYSTEM_ERROR - system error -| -| Return Values : Pointer to the new field or NULL if failure -+--------------------------------------------------------------------------*/ -FIELD *link_field(FIELD * field, int frow, int fcol) -{ - FIELD *New_Field = (FIELD *)0; - int err = E_BAD_ARGUMENT; - - if (field && (frow>=0) && (fcol>=0) && - ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */ - (New_Field = (FIELD *)malloc(sizeof(FIELD))) ) - { - *New_Field = default_field; - New_Field->frow = frow; - New_Field->fcol = fcol; - New_Field->link = field->link; - field->link = New_Field; - New_Field->buf = field->buf; - New_Field->rows = field->rows; - New_Field->cols = field->cols; - New_Field->nrow = field->nrow; - New_Field->nbuf = field->nbuf; - New_Field->drows = field->drows; - New_Field->dcols = field->dcols; - New_Field->maxgrow= field->maxgrow; - New_Field->just = field->just; - New_Field->fore = field->fore; - New_Field->back = field->back; - New_Field->pad = field->pad; - New_Field->opts = field->opts; - New_Field->usrptr = field->usrptr; - if (Copy_Type(New_Field,field)) - return New_Field; - } - - if (New_Field) - free_field(New_Field); - - SET_ERROR( err ); - return (FIELD *)0; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform | Function : int free_field( FIELD *field ) | | Description : Frees the storage allocated for the field. @@ -431,231 +330,9 @@ int free_field(FIELD * field) {} f->link = field->link; } - Free_Type(field); + _nc_Free_Type(field); free(field); RETURN(E_OK); } -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_info(const FIELD *field, -| int *rows, int *cols, -| int *frow, int *fcol, -| int *nrow, int *nbuf) -| -| Description : Retrieve infos about the fields creation parameters. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid field pointer -+--------------------------------------------------------------------------*/ -int field_info(const FIELD *field, - int *rows, int *cols, - int *frow, int *fcol, - int *nrow, int *nbuf) -{ - if (!field) - RETURN(E_BAD_ARGUMENT); - - if (rows) *rows = field->rows; - if (cols) *cols = field->cols; - if (frow) *frow = field->frow; - if (fcol) *fcol = field->fcol; - if (nrow) *nrow = field->nrow; - if (nbuf) *nbuf = field->nbuf; - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int move_field(FIELD *field,int frow, int fcol) -| -| Description : Moves the disconnected field to the new location in -| the forms subwindow. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid argument passed -| E_CONNECTED - field is connected -+--------------------------------------------------------------------------*/ -int move_field(FIELD *field, int frow, int fcol) -{ - if ( !field || (frow<0) || (fcol<0) ) - RETURN(E_BAD_ARGUMENT); - - if (field->form) - RETURN(E_CONNECTED); - - field->frow = frow; - field->fcol = fcol; - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_type(FIELD *field, FIELDTYPE *type,...) -| -| Description : Associate the specified fieldtype with the field. -| Certain field types take additional arguments. Look -| at the spec of the field types ! -| -| Return Values : E_OK - success -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_field_type(FIELD *field,FIELDTYPE *type, ...) -{ - va_list ap; - int res = E_SYSTEM_ERROR; - int err = 0; - - va_start(ap,type); - - Normalize_Field(field); - Free_Type(field); - - field->type = type; - field->arg = (void *)Make_Argument(field->type,&ap,&err); - - if (err) - { - Free_Argument(field->type,(TypeArgument *)(field->arg)); - field->type = (FIELDTYPE *)0; - field->arg = (void *)0; - } - else - { - res = E_OK; - if (field->type) - field->type->ref++; - } - - va_end(ap); - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : FIELDTYPE *field_type(const FIELD *field) -| -| Description : Retrieve the associated fieldtype for this field. -| -| Return Values : Pointer to fieldtype of NULL if none is defined. -+--------------------------------------------------------------------------*/ -FIELDTYPE *field_type(const FIELD * field) -{ - return Normalize_Field(field)->type; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : void *field_arg(const FIELD *field) -| -| Description : Retrieve pointer to the fields argument structure. -| -| Return Values : Pointer to structure or NULL if none is defined. -+--------------------------------------------------------------------------*/ -void *field_arg(const FIELD * field) -{ - return Normalize_Field(field)->arg; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_max_field(FIELD *field, int maxgrow) -| -| Description : Set the maximum growth for a dynamic field. If maxgrow=0 -| the field may grow to any possible size. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid argument -+--------------------------------------------------------------------------*/ -int set_max_field(FIELD *field, int maxgrow) -{ - if (!field || (maxgrow<0)) - RETURN(E_BAD_ARGUMENT); - else - { - bool single_line_field = Single_Line_Field(field); - - if (maxgrow>0) - { - if (( single_line_field && (maxgrow < field->dcols)) || - (!single_line_field && (maxgrow < field->drows))) - RETURN(E_BAD_ARGUMENT); - } - field->maxgrow = maxgrow; - field->status &= ~_MAY_GROW; - if (!(field->opts & O_STATIC)) - { - if ((maxgrow==0) || - ( single_line_field && (field->dcols < maxgrow)) || - (!single_line_field && (field->drows < maxgrow))) - field->status |= _MAY_GROW; - } - } - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int dynamic_field_info(const FIELD *field, -| int *drows, int *dcols, -| int *maxgrow) -| -| Description : Retrieve informations about a dynamic fields current -| dynamic parameters. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid argument -+--------------------------------------------------------------------------*/ -int dynamic_field_info(const FIELD *field, - int *drows, int *dcols, int *maxgrow) -{ - if (!field) - RETURN(E_BAD_ARGUMENT); - - if (drows) *drows = field->drows; - if (dcols) *dcols = field->dcols; - if (maxgrow) *maxgrow = field->maxgrow; - - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_new_page(FIELD *field, bool new_page_flag) -| -| Description : Marks the field as the beginning of a new page of -| the form. -| -| Return Values : E_OK - success -| E_CONNECTED - field is connected -+--------------------------------------------------------------------------*/ -int set_new_page(FIELD * field, bool new_page_flag) -{ - Normalize_Field(field); - if (field->form) - RETURN(E_CONNECTED); - - if (new_page_flag) - field->status |= _NEWPAGE; - else - field->status &= ~_NEWPAGE; - - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : bool new_page(const FIELD *field) -| -| Description : Retrieve the info whether or not the field starts a -| new page on the form. -| -| Return Values : TRUE - field starts a new page -| FALSE - field doesn't start a new page -+--------------------------------------------------------------------------*/ -bool new_page(const FIELD * field) -{ - return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE; -} - /* fld_def.c ends here */ diff --git a/lib/libform/fld_dup.c b/lib/libform/fld_dup.c new file mode 100644 index 00000000000..46bfdb4c6a6 --- /dev/null +++ b/lib/libform/fld_dup.c @@ -0,0 +1,89 @@ +/* $OpenBSD: fld_dup.c,v 1.1 1997/12/03 05:39:52 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_dup.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : FIELD *dup_field(FIELD *field, int frow, int fcol) +| +| Description : Duplicates the field at the specified position. All +| field attributes and the buffers are copied. +| If an error occurs, errno is set to +| +| E_BAD_ARGUMENT - invalid argument +| E_SYSTEM_ERROR - system error +| +| Return Values : Pointer to the new field or NULL if failure ++--------------------------------------------------------------------------*/ +FIELD *dup_field(FIELD * field, int frow, int fcol) +{ + FIELD *New_Field = (FIELD *)0; + int err = E_BAD_ARGUMENT; + + if (field && (frow>=0) && (fcol>=0) && + ((err=E_SYSTEM_ERROR) != 0) && /* trick : this resets the default error */ + (New_Field=(FIELD *)malloc(sizeof(FIELD))) ) + { + *New_Field = *_nc_Default_Field; + New_Field->frow = frow; + New_Field->fcol = fcol; + New_Field->link = New_Field; + New_Field->rows = field->rows; + New_Field->cols = field->cols; + New_Field->nrow = field->nrow; + New_Field->drows = field->drows; + New_Field->dcols = field->dcols; + New_Field->maxgrow = field->maxgrow; + New_Field->nbuf = field->nbuf; + New_Field->just = field->just; + New_Field->fore = field->fore; + New_Field->back = field->back; + New_Field->pad = field->pad; + New_Field->opts = field->opts; + New_Field->usrptr = field->usrptr; + + if (_nc_Copy_Type(New_Field,field)) + { + size_t len; + + len = Total_Buffer_Size(New_Field); + if ( (New_Field->buf=(char *)malloc(len)) ) + { + memcpy(New_Field->buf,field->buf,len); + return New_Field; + } + } + } + + if (New_Field) + free_field(New_Field); + + SET_ERROR(err); + return (FIELD *)0; +} + +/* fld_dup.c ends here */ diff --git a/lib/libform/fld_ftchoice.c b/lib/libform/fld_ftchoice.c new file mode 100644 index 00000000000..a70cfe6e93b --- /dev/null +++ b/lib/libform/fld_ftchoice.c @@ -0,0 +1,54 @@ +/* $OpenBSD: fld_ftchoice.c,v 1.1 1997/12/03 05:39:53 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_ftchoice.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_fieldtype_choice( +| FIELDTYPE *typ, +| bool (* const next_choice)(FIELD *,const void *), +| bool (* const prev_choice)(FIELD *,const void *)) +| +| Description : Define implementation of enumeration requests. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid arguments ++--------------------------------------------------------------------------*/ +int set_fieldtype_choice(FIELDTYPE * typ, + bool (* const next_choice) (FIELD *,const void *), + bool (* const prev_choice) (FIELD *,const void *)) +{ + if ( !typ || !next_choice || !prev_choice ) + RETURN(E_BAD_ARGUMENT); + + typ->status |= _HAS_CHOICE; + typ->next = next_choice; + typ->prev = prev_choice; + RETURN(E_OK); +} + +/* fld_ftchoice.c ends here */ diff --git a/lib/libform/fld_ftlink.c b/lib/libform/fld_ftlink.c new file mode 100644 index 00000000000..933086acde1 --- /dev/null +++ b/lib/libform/fld_ftlink.c @@ -0,0 +1,75 @@ +/* $OpenBSD: fld_ftlink.c,v 1.1 1997/12/03 05:39:53 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_ftlink.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : FIELDTYPE *link_fieldtype( +| FIELDTYPE *type1, +| FIELDTYPE *type2) +| +| Description : Create a new fieldtype built from the two given types. +| They are connected by an logical 'OR'. +| If an error occurs, errno is set to +| E_BAD_ARGUMENT - invalid arguments +| E_SYSTEM_ERROR - system error (no memory) +| +| Return Values : Fieldtype pointer or NULL if error occured. ++--------------------------------------------------------------------------*/ +FIELDTYPE *link_fieldtype(FIELDTYPE * type1, FIELDTYPE * type2) +{ + FIELDTYPE *nftyp = (FIELDTYPE *)0; + + if ( type1 && type2 ) + { + nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE)); + if (nftyp) + { + *nftyp = *_nc_Default_FieldType; + nftyp->status |= _LINKED_TYPE; + if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) ) + nftyp->status |= _HAS_ARGS; + if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) ) + nftyp->status |= _HAS_CHOICE; + nftyp->left = type1; + nftyp->right = type2; + type1->ref++; + type2->ref++; + } + else + { + SET_ERROR( E_SYSTEM_ERROR ); + } + } + else + { + SET_ERROR( E_BAD_ARGUMENT ); + } + return nftyp; +} + +/* fld_ftlink.c ends here */ diff --git a/lib/libform/fld_info.c b/lib/libform/fld_info.c new file mode 100644 index 00000000000..6150de0e131 --- /dev/null +++ b/lib/libform/fld_info.c @@ -0,0 +1,83 @@ +/* $OpenBSD: fld_info.c,v 1.1 1997/12/03 05:39:53 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_info.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_info(const FIELD *field, +| int *rows, int *cols, +| int *frow, int *fcol, +| int *nrow, int *nbuf) +| +| Description : Retrieve infos about the fields creation parameters. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid field pointer ++--------------------------------------------------------------------------*/ +int field_info(const FIELD *field, + int *rows, int *cols, + int *frow, int *fcol, + int *nrow, int *nbuf) +{ + if (!field) + RETURN(E_BAD_ARGUMENT); + + if (rows) *rows = field->rows; + if (cols) *cols = field->cols; + if (frow) *frow = field->frow; + if (fcol) *fcol = field->fcol; + if (nrow) *nrow = field->nrow; + if (nbuf) *nbuf = field->nbuf; + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int dynamic_field_info(const FIELD *field, +| int *drows, int *dcols, +| int *maxgrow) +| +| Description : Retrieve informations about a dynamic fields current +| dynamic parameters. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid argument ++--------------------------------------------------------------------------*/ +int dynamic_field_info(const FIELD *field, + int *drows, int *dcols, int *maxgrow) +{ + if (!field) + RETURN(E_BAD_ARGUMENT); + + if (drows) *drows = field->drows; + if (dcols) *dcols = field->dcols; + if (maxgrow) *maxgrow = field->maxgrow; + + RETURN(E_OK); +} + +/* fld_info.c ends here */ diff --git a/lib/libform/fld_just.c b/lib/libform/fld_just.c new file mode 100644 index 00000000000..705641d17fc --- /dev/null +++ b/lib/libform/fld_just.c @@ -0,0 +1,73 @@ +/* $OpenBSD: fld_just.c,v 1.1 1997/12/03 05:39:54 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_just.c,v 1.2 1997/10/26 11:20:59 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_field_just(FIELD *field, int just) +| +| Description : Set the fields type of justification. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - one of the arguments was incorrect +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int set_field_just(FIELD * field, int just) +{ + int res = E_BAD_ARGUMENT; + + if ((just==NO_JUSTIFICATION) || + (just==JUSTIFY_LEFT) || + (just==JUSTIFY_CENTER) || + (just==JUSTIFY_RIGHT) ) + { + Normalize_Field( field ); + if (field->just != just) + { + field->just = just; + res = _nc_Synchronize_Attributes( field ); + } + else + res = E_OK; + } + RETURN(res); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_just( const FIELD *field ) +| +| Description : Retrieve the fields type of justification +| +| Return Values : The justification type. ++--------------------------------------------------------------------------*/ +int field_just(const FIELD * field) +{ + return Normalize_Field( field )->just; +} + +/* fld_just.c ends here */ diff --git a/lib/libform/fld_link.c b/lib/libform/fld_link.c new file mode 100644 index 00000000000..782d00547dd --- /dev/null +++ b/lib/libform/fld_link.c @@ -0,0 +1,82 @@ +/* $OpenBSD: fld_link.c,v 1.1 1997/12/03 05:39:54 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_link.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : FIELD *link_field(FIELD *field, int frow, int fcol) +| +| Description : Duplicates the field at the specified position. The +| new field shares its buffers with the original one, +| the attributes are independent. +| If an error occurs, errno is set to +| +| E_BAD_ARGUMENT - invalid argument +| E_SYSTEM_ERROR - system error +| +| Return Values : Pointer to the new field or NULL if failure ++--------------------------------------------------------------------------*/ +FIELD *link_field(FIELD * field, int frow, int fcol) +{ + FIELD *New_Field = (FIELD *)0; + int err = E_BAD_ARGUMENT; + + if (field && (frow>=0) && (fcol>=0) && + ((err=E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */ + (New_Field = (FIELD *)malloc(sizeof(FIELD))) ) + { + *New_Field = *_nc_Default_Field; + New_Field->frow = frow; + New_Field->fcol = fcol; + New_Field->link = field->link; + field->link = New_Field; + New_Field->buf = field->buf; + New_Field->rows = field->rows; + New_Field->cols = field->cols; + New_Field->nrow = field->nrow; + New_Field->nbuf = field->nbuf; + New_Field->drows = field->drows; + New_Field->dcols = field->dcols; + New_Field->maxgrow= field->maxgrow; + New_Field->just = field->just; + New_Field->fore = field->fore; + New_Field->back = field->back; + New_Field->pad = field->pad; + New_Field->opts = field->opts; + New_Field->usrptr = field->usrptr; + if (_nc_Copy_Type(New_Field,field)) + return New_Field; + } + + if (New_Field) + free_field(New_Field); + + SET_ERROR( err ); + return (FIELD *)0; +} + +/* fld_link.c ends here */ diff --git a/lib/libform/fld_max.c b/lib/libform/fld_max.c new file mode 100644 index 00000000000..2846f81a434 --- /dev/null +++ b/lib/libform/fld_max.c @@ -0,0 +1,66 @@ +/* $OpenBSD: fld_max.c,v 1.1 1997/12/03 05:39:55 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_max.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_max_field(FIELD *field, int maxgrow) +| +| Description : Set the maximum growth for a dynamic field. If maxgrow=0 +| the field may grow to any possible size. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid argument ++--------------------------------------------------------------------------*/ +int set_max_field(FIELD *field, int maxgrow) +{ + if (!field || (maxgrow<0)) + RETURN(E_BAD_ARGUMENT); + else + { + bool single_line_field = Single_Line_Field(field); + + if (maxgrow>0) + { + if (( single_line_field && (maxgrow < field->dcols)) || + (!single_line_field && (maxgrow < field->drows))) + RETURN(E_BAD_ARGUMENT); + } + field->maxgrow = maxgrow; + field->status &= ~_MAY_GROW; + if (!(field->opts & O_STATIC)) + { + if ((maxgrow==0) || + ( single_line_field && (field->dcols < maxgrow)) || + (!single_line_field && (field->drows < maxgrow))) + field->status |= _MAY_GROW; + } + } + RETURN(E_OK); +} + +/* fld_max.c ends here */ diff --git a/lib/libform/fld_move.c b/lib/libform/fld_move.c new file mode 100644 index 00000000000..86326afec83 --- /dev/null +++ b/lib/libform/fld_move.c @@ -0,0 +1,54 @@ +/* $OpenBSD: fld_move.c,v 1.1 1997/12/03 05:39:55 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_move.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int move_field(FIELD *field,int frow, int fcol) +| +| Description : Moves the disconnected field to the new location in +| the forms subwindow. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid argument passed +| E_CONNECTED - field is connected ++--------------------------------------------------------------------------*/ +int move_field(FIELD *field, int frow, int fcol) +{ + if ( !field || (frow<0) || (fcol<0) ) + RETURN(E_BAD_ARGUMENT); + + if (field->form) + RETURN(E_CONNECTED); + + field->frow = frow; + field->fcol = fcol; + RETURN(E_OK); +} + +/* fld_move.c ends here */ + diff --git a/lib/libform/fld_newftyp.c b/lib/libform/fld_newftyp.c new file mode 100644 index 00000000000..1dbc3541d21 --- /dev/null +++ b/lib/libform/fld_newftyp.c @@ -0,0 +1,117 @@ +/* $OpenBSD: fld_newftyp.c,v 1.1 1997/12/03 05:39:56 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_newftyp.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +static FIELDTYPE const default_fieldtype = { + 0, /* status */ + 0L, /* reference count */ + (FIELDTYPE *)0, /* pointer to left operand */ + (FIELDTYPE *)0, /* pointer to right operand */ + NULL, /* makearg function */ + NULL, /* copyarg function */ + NULL, /* freearg function */ + NULL, /* field validation function */ + NULL, /* Character check function */ + NULL, /* enumerate next function */ + NULL /* enumerate previous function */ +}; + +const FIELDTYPE* _nc_Default_FieldType = &default_fieldtype; + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : FIELDTYPE *new_fieldtype( +| bool (* const field_check)(FIELD *,const void *), +| bool (* const char_check) (int, const void *) ) +| +| Description : Create a new fieldtype. The application programmer must +| write a field_check and a char_check function and give +| them as input to this call. +| If an error occurs, errno is set to +| E_BAD_ARGUMENT - invalid arguments +| E_SYSTEM_ERROR - system error (no memory) +| +| Return Values : Fieldtype pointer or NULL if error occured ++--------------------------------------------------------------------------*/ +FIELDTYPE *new_fieldtype( + bool (* const field_check)(FIELD *,const void *), + bool (* const char_check) (int,const void *) ) +{ + FIELDTYPE *nftyp = (FIELDTYPE *)0; + + if ( (field_check) && (char_check) ) + { + nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE)); + if (nftyp) + { + *nftyp = default_fieldtype; + nftyp->fcheck = field_check; + nftyp->ccheck = char_check; + } + else + { + SET_ERROR( E_SYSTEM_ERROR ); + } + } + else + { + SET_ERROR( E_BAD_ARGUMENT ); + } + return nftyp; +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int free_fieldtype(FIELDTYPE *typ) +| +| Description : Release the memory associated with this fieldtype. +| +| Return Values : E_OK - success +| E_CONNECTED - there are fields referencing the type +| E_BAD_ARGUMENT - invalid fieldtype pointer ++--------------------------------------------------------------------------*/ +int free_fieldtype(FIELDTYPE *typ) +{ + if (!typ) + RETURN(E_BAD_ARGUMENT); + + if (typ->ref!=0) + RETURN(E_CONNECTED); + + if (typ->status & _RESIDENT) + RETURN(E_CONNECTED); + + if (typ->status & _LINKED_TYPE) + { + if (typ->left ) typ->left->ref--; + if (typ->right) typ->right->ref--; + } + free(typ); + RETURN(E_OK); +} + +/* fld_newftyp.c ends here */ diff --git a/lib/libform/fld_opts.c b/lib/libform/fld_opts.c new file mode 100644 index 00000000000..00816273f06 --- /dev/null +++ b/lib/libform/fld_opts.c @@ -0,0 +1,113 @@ +/* $OpenBSD: fld_opts.c,v 1.1 1997/12/03 05:39:56 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_opts.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*---------------------------------------------------------------------------- + Field-Options manipulation routines + --------------------------------------------------------------------------*/ + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_field_opts(FIELD *field, Field_Options opts) +| +| Description : Turns on the named options for this field and turns +| off all the remaining options. +| +| Return Values : E_OK - success +| E_CURRENT - the field is the current field +| E_BAD_ARGUMENT - invalid options +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int set_field_opts(FIELD * field, Field_Options opts) +{ + int res = E_BAD_ARGUMENT; + if (!(opts & ~ALL_FIELD_OPTS)) + res = _nc_Synchronize_Options( Normalize_Field(field), opts ); + RETURN(res); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : Field_Options field_opts(const FIELD *field) +| +| Description : Retrieve the fields options. +| +| Return Values : The options. ++--------------------------------------------------------------------------*/ +Field_Options field_opts(const FIELD * field) +{ + return ALL_FIELD_OPTS & Normalize_Field( field )->opts; +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_opts_on(FIELD *field, Field_Options opts) +| +| Description : Turns on the named options for this field and all the +| remaining options are unchanged. +| +| Return Values : E_OK - success +| E_CURRENT - the field is the current field +| E_BAD_ARGUMENT - invalid options +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int field_opts_on(FIELD * field, Field_Options opts) +{ + int res = E_BAD_ARGUMENT; + + if (!(opts & ~ALL_FIELD_OPTS)) + { + Normalize_Field( field ); + res = _nc_Synchronize_Options( field, field->opts | opts ); + } + RETURN(res); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_opts_off(FIELD *field, Field_Options opts) +| +| Description : Turns off the named options for this field and all the +| remaining options are unchanged. +| +| Return Values : E_OK - success +| E_CURRENT - the field is the current field +| E_BAD_ARGUMENT - invalid options +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int field_opts_off(FIELD * field, Field_Options opts) +{ + int res = E_BAD_ARGUMENT; + + if (!(opts & ~ALL_FIELD_OPTS)) + { + Normalize_Field( field ); + res = _nc_Synchronize_Options( field, field->opts & ~opts ); + } + RETURN(res); +} + +/* fld_opts.c ends here */ diff --git a/lib/libform/fld_pad.c b/lib/libform/fld_pad.c new file mode 100644 index 00000000000..92e12185b56 --- /dev/null +++ b/lib/libform/fld_pad.c @@ -0,0 +1,70 @@ +/* $OpenBSD: fld_pad.c,v 1.1 1997/12/03 05:39:56 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_pad.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_field_pad(FIELD *field, int ch) +| +| Description : Set the pad character used to fill the field. This must +| be a printable character. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid field pointer or pad character +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int set_field_pad(FIELD * field, int ch) +{ + int res = E_BAD_ARGUMENT; + + Normalize_Field( field ); + if (isprint((unsigned char)ch)) + { + if (field->pad != ch) + { + field->pad = ch; + res = _nc_Synchronize_Attributes( field ); + } + else + res = E_OK; + } + RETURN(res); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int field_pad(const FIELD *field) +| +| Description : Retrieve the fields pad character. +| +| Return Values : The pad character. ++--------------------------------------------------------------------------*/ +int field_pad(const FIELD * field) +{ + return Normalize_Field( field )->pad; +} + +/* fld_pad.c ends here */ diff --git a/lib/libform/fld_page.c b/lib/libform/fld_page.c new file mode 100644 index 00000000000..9702fe875c9 --- /dev/null +++ b/lib/libform/fld_page.c @@ -0,0 +1,68 @@ +/* $OpenBSD: fld_page.c,v 1.1 1997/12/03 05:39:57 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_page.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_new_page(FIELD *field, bool new_page_flag) +| +| Description : Marks the field as the beginning of a new page of +| the form. +| +| Return Values : E_OK - success +| E_CONNECTED - field is connected ++--------------------------------------------------------------------------*/ +int set_new_page(FIELD * field, bool new_page_flag) +{ + Normalize_Field(field); + if (field->form) + RETURN(E_CONNECTED); + + if (new_page_flag) + field->status |= _NEWPAGE; + else + field->status &= ~_NEWPAGE; + + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : bool new_page(const FIELD *field) +| +| Description : Retrieve the info whether or not the field starts a +| new page on the form. +| +| Return Values : TRUE - field starts a new page +| FALSE - field doesn't start a new page ++--------------------------------------------------------------------------*/ +bool new_page(const FIELD * field) +{ + return (Normalize_Field(field)->status & _NEWPAGE) ? TRUE : FALSE; +} + +/* fld_page.c ends here */ diff --git a/lib/libform/fld_stat.c b/lib/libform/fld_stat.c index 04c877fc88e..df2c8091ad6 100644 --- a/lib/libform/fld_stat.c +++ b/lib/libform/fld_stat.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fld_stat.c,v 1.3 1997/12/03 05:39:57 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | diff --git a/lib/libform/fld_type.c b/lib/libform/fld_type.c index 6c30a432ac1..073849c3cad 100644 --- a/lib/libform/fld_type.c +++ b/lib/libform/fld_type.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fld_type.c,v 1.3 1997/12/03 05:39:58 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,201 +24,61 @@ #include "form.priv.h" -MODULE_ID("Id: fld_type.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: fld_type.c,v 1.6 1997/10/21 13:24:19 juergen Exp $") -static FIELDTYPE const default_fieldtype = { - 0, /* status */ - 0L, /* reference count */ - (FIELDTYPE *)0, /* pointer to left operand */ - (FIELDTYPE *)0, /* pointer to right operand */ - NULL, /* makearg function */ - NULL, /* copyarg function */ - NULL, /* freearg function */ - NULL, /* field validation function */ - NULL, /* Character check function */ - NULL, /* enumerate next function */ - NULL /* enumerate previous function */ -}; - /*--------------------------------------------------------------------------- | Facility : libnform -| Function : FIELDTYPE *new_fieldtype( -| bool (* const field_check)(FIELD *,const void *), -| bool (* const char_check) (int, const void *) ) +| Function : int set_field_type(FIELD *field, FIELDTYPE *type,...) | -| Description : Create a new fieldtype. The application programmer must -| write a field_check and a char_check function and give -| them as input to this call. -| If an error occurs, errno is set to -| E_BAD_ARGUMENT - invalid arguments -| E_SYSTEM_ERROR - system error (no memory) +| Description : Associate the specified fieldtype with the field. +| Certain field types take additional arguments. Look +| at the spec of the field types ! | -| Return Values : Fieldtype pointer or NULL if error occured +| Return Values : E_OK - success +| E_SYSTEM_ERROR - system error +--------------------------------------------------------------------------*/ -FIELDTYPE *new_fieldtype( - bool (* const field_check)(FIELD *,const void *), - bool (* const char_check) (int,const void *) ) +int set_field_type(FIELD *field,FIELDTYPE *type, ...) { - FIELDTYPE *nftyp = (FIELDTYPE *)0; - - if ( (field_check) && (char_check) ) - { - nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE)); - if (nftyp) - { - *nftyp = default_fieldtype; - nftyp->fcheck = field_check; - nftyp->ccheck = char_check; - } - else - { - SET_ERROR( E_SYSTEM_ERROR ); - } - } - else - { - SET_ERROR( E_BAD_ARGUMENT ); - } - return nftyp; -} + va_list ap; + int res = E_SYSTEM_ERROR; + int err = 0; -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : FIELDTYPE *link_fieldtype( -| FIELDTYPE *type1, -| FIELDTYPE *type2) -| -| Description : Create a new fieldtype built from the two given types. -| They are connected by an logical 'OR'. -| If an error occurs, errno is set to -| E_BAD_ARGUMENT - invalid arguments -| E_SYSTEM_ERROR - system error (no memory) -| -| Return Values : Fieldtype pointer or NULL if error occured. -+--------------------------------------------------------------------------*/ -FIELDTYPE *link_fieldtype(FIELDTYPE * type1, FIELDTYPE * type2) -{ - FIELDTYPE *nftyp = (FIELDTYPE *)0; + va_start(ap,type); + + Normalize_Field(field); + _nc_Free_Type(field); + + field->type = type; + field->arg = (void *)_nc_Make_Argument(field->type,&ap,&err); - if ( type1 && type2 ) + if (err) { - nftyp = (FIELDTYPE *)malloc(sizeof(FIELDTYPE)); - if (nftyp) - { - *nftyp = default_fieldtype; - nftyp->status |= _LINKED_TYPE; - if ((type1->status & _HAS_ARGS) || (type2->status & _HAS_ARGS) ) - nftyp->status |= _HAS_ARGS; - if ((type1->status & _HAS_CHOICE) || (type2->status & _HAS_CHOICE) ) - nftyp->status |= _HAS_CHOICE; - nftyp->left = type1; - nftyp->right = type2; - type1->ref++; - type2->ref++; - } - else - { - SET_ERROR( E_SYSTEM_ERROR ); - } + _nc_Free_Argument(field->type,(TypeArgument *)(field->arg)); + field->type = (FIELDTYPE *)0; + field->arg = (void *)0; } else { - SET_ERROR( E_BAD_ARGUMENT ); + res = E_OK; + if (field->type) + field->type->ref++; } - return nftyp; -} -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int free_fieldtype(FIELDTYPE *typ) -| -| Description : Release the memory associated with this fieldtype. -| -| Return Values : E_OK - success -| E_CONNECTED - there are fields referencing the type -| E_BAD_ARGUMENT - invalid fieldtype pointer -+--------------------------------------------------------------------------*/ -int free_fieldtype(FIELDTYPE *typ) -{ - if (!typ) - RETURN(E_BAD_ARGUMENT); - - if (typ->ref!=0) - RETURN(E_CONNECTED); - - if (typ->status & _RESIDENT) - RETURN(E_CONNECTED); - - if (typ->status & _LINKED_TYPE) - { - if (typ->left ) typ->left->ref--; - if (typ->right) typ->right->ref--; - } - free(typ); - RETURN(E_OK); + va_end(ap); + RETURN(res); } /*--------------------------------------------------------------------------- | Facility : libnform -| Function : int set_fieldtype_arg( -| FIELDTYPE *typ, -| void * (* const make_arg)(va_list *), -| void * (* const copy_arg)(const void *), -| void (* const free_arg)(void *) ) +| Function : FIELDTYPE *field_type(const FIELD *field) | -| Description : Connects to the type additional arguments necessary -| for a set_field_type call. The various function pointer -| arguments are: -| make_arg : allocates a structure for the field -| specific parameters. -| copy_arg : duplicate the structure created by -| make_arg -| free_arg : Release the memory allocated by make_arg -| or copy_arg -| -| At least one of those functions must be non-NULL. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid argument -+--------------------------------------------------------------------------*/ -int set_fieldtype_arg(FIELDTYPE * typ, - void * (* const make_arg)(va_list *), - void * (* const copy_arg)(const void *), - void (* const free_arg)(void *)) -{ - if ( !typ || !make_arg || !copy_arg || !free_arg ) - RETURN(E_BAD_ARGUMENT); - - typ->status |= _HAS_ARGS; - typ->makearg = make_arg; - typ->copyarg = copy_arg; - typ->freearg = free_arg; - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_fieldtype_choice( -| FIELDTYPE *typ, -| bool (* const next_choice)(FIELD *,const void *), -| bool (* const prev_choice)(FIELD *,const void *)) -| -| Description : Define implementation of enumeration requests. +| Description : Retrieve the associated fieldtype for this field. | -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid arguments +| Return Values : Pointer to fieldtype of NULL if none is defined. +--------------------------------------------------------------------------*/ -int set_fieldtype_choice(FIELDTYPE * typ, - bool (* const next_choice) (FIELD *,const void *), - bool (* const prev_choice) (FIELD *,const void *)) +FIELDTYPE *field_type(const FIELD * field) { - if ( !typ || !next_choice || !prev_choice ) - RETURN(E_BAD_ARGUMENT); - - typ->status |= _HAS_CHOICE; - typ->next = next_choice; - typ->prev = prev_choice; - RETURN(E_OK); + return Normalize_Field(field)->type; } /* fld_type.c ends here */ diff --git a/lib/libform/fld_user.c b/lib/libform/fld_user.c index dd90483d959..21a1b85f095 100644 --- a/lib/libform/fld_user.c +++ b/lib/libform/fld_user.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fld_user.c,v 1.3 1997/12/03 05:39:58 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,7 +24,7 @@ #include "form.priv.h" -MODULE_ID("Id: fld_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: fld_user.c,v 1.5 1997/05/23 23:31:29 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnform @@ -33,7 +35,7 @@ MODULE_ID("Id: fld_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ -int set_field_userptr(FIELD * field, const void *usrptr) +int set_field_userptr(FIELD * field, void *usrptr) { Normalize_Field( field )->usrptr = usrptr; RETURN(E_OK); @@ -49,7 +51,7 @@ int set_field_userptr(FIELD * field, const void *usrptr) | Return Values : Value of pointer. If no such pointer has been set, | NULL is returned +--------------------------------------------------------------------------*/ -const void *field_userptr(const FIELD *field) +void *field_userptr(const FIELD *field) { return Normalize_Field( field )->usrptr; } diff --git a/lib/libform/form.3 b/lib/libform/form.3 index 69ef1c02b99..43ca979d095 100644 --- a/lib/libform/form.3 +++ b/lib/libform/form.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form.3,v 1.3 1997/12/03 05:39:58 millert Exp $ '\" t .TH forms 3X "" .SH NAME diff --git a/lib/libform/form.h b/lib/libform/form.h index 6e2eabe209d..a5a767d2f07 100644 --- a/lib/libform/form.h +++ b/lib/libform/form.h @@ -1,3 +1,5 @@ +/* $OpenBSD: form.h,v 1.3 1997/12/03 05:39:59 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -73,7 +75,7 @@ typedef struct fieldnode { struct typenode * type; /* field type */ void * arg; /* argument for type */ char * buf; /* field buffers */ - const void * usrptr; /* user pointer */ + void * usrptr; /* user pointer */ } FIELD; /************** @@ -120,7 +122,7 @@ typedef struct formnode { FIELD ** field; /* field [maxfield] */ FIELD * current; /* current field */ _PAGE * page; /* page [maxpage] */ - const void * usrptr; /* user pointer */ + void * usrptr; /* user pointer */ void (*forminit)(struct formnode *); void (*formterm)(struct formnode *); @@ -296,7 +298,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 *,const void *), + set_field_userptr(FIELD *, void *), set_field_opts(FIELD *,Field_Options), field_opts_on(FIELD *,Field_Options), field_opts_off(FIELD *,Field_Options); @@ -309,8 +311,7 @@ extern bool new_page(const FIELD *), extern void *field_arg(const FIELD *); -extern const void - *field_userptr(const FIELD *); +extern void *field_userptr(const FIELD *); extern FIELDTYPE *field_type(const FIELD *); @@ -355,7 +356,7 @@ extern int free_form(FORM *), unpost_form(FORM *), pos_form_cursor(FORM *), form_driver(FORM *,int), - set_form_userptr(FORM *,const void *), + set_form_userptr(FORM *,void *), set_form_opts(FORM *,Form_Options), form_opts_on(FORM *,Form_Options), form_opts_off(FORM *,Form_Options), @@ -364,8 +365,7 @@ extern int free_form(FORM *), extern const char *form_request_name(int); -extern const void - *form_userptr(const FORM *); +extern 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 b08d70d6e35..e8edf801ca6 100644 --- a/lib/libform/form.priv.h +++ b/lib/libform/form.priv.h @@ -1,3 +1,5 @@ +/* $OpenBSD: form.priv.h,v 1.3 1997/12/03 05:39:59 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -40,6 +42,10 @@ #define _HAS_CHOICE (0x04) /* Type has choice methods */ #define _RESIDENT (0x08) /* Type is builtin */ +/* This are the field options required to be a selectable field in field + navigation requests */ +#define O_SELECTABLE (O_ACTIVE | O_VISIBLE) + /* If form is NULL replace form argument by default-form */ #define Normalize_Form(form) ((form)=(form)?(form):_nc_Default_Form) @@ -61,6 +67,9 @@ #define Single_Line_Field(field) \ (((field)->rows + (field)->nrow) == 1) +/* Logic to determine whether or not a field is selectable */ +#define Field_Is_Selectable(f) (((f)->opts & O_SELECTABLE)==O_SELECTABLE) +#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE) typedef struct typearg { struct typearg *left; @@ -92,3 +101,20 @@ typedef struct typearg { #define C_BLANK ' ' #define is_blank(c) ((c)==C_BLANK) + +extern const FIELDTYPE* _nc_Default_FieldType; + +extern TypeArgument* _nc_Make_Argument(const FIELDTYPE*,va_list*,int*); +extern TypeArgument *_nc_Copy_Argument(const FIELDTYPE*,const TypeArgument*, int*); +extern void _nc_Free_Argument(const FIELDTYPE*,TypeArgument*); +extern bool _nc_Copy_Type(FIELD*, FIELD const *); +extern void _nc_Free_Type(FIELD *); + +extern int _nc_Synchronize_Attributes(FIELD*); +extern int _nc_Synchronize_Options(FIELD*,Field_Options); +extern int _nc_Set_Form_Page(FORM*,int,FIELD*); +extern int _nc_Refresh_Current_Field(FORM*); +extern FIELD* _nc_First_Active_Field(FORM*); +extern bool _nc_Internal_Validation(FORM*); +extern int _nc_Set_Current_Field(FORM*,FIELD*); +extern int _nc_Position_Form_Cursor(FORM*); diff --git a/lib/libform/form_cursor.3 b/lib/libform/form_cursor.3 index 1e9a1d90e2b..6ff43f4c702 100644 --- a/lib/libform/form_cursor.3 +++ b/lib/libform/form_cursor.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_cursor.3,v 1.2 1997/12/03 05:40:00 millert Exp $ '\" t .TH form_cursor 3X "" .SH NAME diff --git a/lib/libform/form_data.3 b/lib/libform/form_data.3 index bf8a240467d..7fac821cd5d 100644 --- a/lib/libform/form_data.3 +++ b/lib/libform/form_data.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_data.3,v 1.3 1997/12/03 05:40:00 millert Exp $ '\" t .TH form_data 3X "" .SH NAME diff --git a/lib/libform/form_driver.3 b/lib/libform/form_driver.3 index 6a6acc7b66c..2e504193d1e 100644 --- a/lib/libform/form_driver.3 +++ b/lib/libform/form_driver.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_driver.3,v 1.3 1997/12/03 05:40:01 millert Exp $ '\" t .TH form_driver 3X "" .SH NAME diff --git a/lib/libform/form_field.3 b/lib/libform/form_field.3 index 3e651a5a5d3..6412da0f173 100644 --- a/lib/libform/form_field.3 +++ b/lib/libform/form_field.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field.3,v 1.3 1997/12/03 05:40:01 millert Exp $ '\" t .TH form_field 3X "" .SH NAME diff --git a/lib/libform/form_field_attributes.3 b/lib/libform/form_field_attributes.3 index 610bef2d6f4..5b3b485f072 100644 --- a/lib/libform/form_field_attributes.3 +++ b/lib/libform/form_field_attributes.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_attributes.3,v 1.3 1997/12/03 05:40:02 millert Exp $ '\" t .TH form_field_attributes 3X "" .SH NAME diff --git a/lib/libform/form_field_buffer.3 b/lib/libform/form_field_buffer.3 index d1a32aaa11c..a455aa16ddf 100644 --- a/lib/libform/form_field_buffer.3 +++ b/lib/libform/form_field_buffer.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_buffer.3,v 1.3 1997/12/03 05:40:02 millert Exp $ '\" t .TH form_field_buffer 3X "" .SH NAME diff --git a/lib/libform/form_field_info.3 b/lib/libform/form_field_info.3 index aca06fb7862..74ab926e8ae 100644 --- a/lib/libform/form_field_info.3 +++ b/lib/libform/form_field_info.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_info.3,v 1.3 1997/12/03 05:40:03 millert Exp $ '\" t .TH form_field_info 3X "" .SH NAME diff --git a/lib/libform/form_field_just.3 b/lib/libform/form_field_just.3 index cbe2102b223..815c259c364 100644 --- a/lib/libform/form_field_just.3 +++ b/lib/libform/form_field_just.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_just.3,v 1.3 1997/12/03 05:40:03 millert Exp $ '\" t .TH form_field_just 3X "" .SH NAME diff --git a/lib/libform/form_field_new.3 b/lib/libform/form_field_new.3 index af2dcad5325..8e084ccbfe8 100644 --- a/lib/libform/form_field_new.3 +++ b/lib/libform/form_field_new.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_new.3,v 1.3 1997/12/03 05:40:03 millert Exp $ '\" t .TH form_field_new 3X "" .SH NAME diff --git a/lib/libform/form_field_opts.3 b/lib/libform/form_field_opts.3 index d3dc8db1f1b..53efc3b4b8f 100644 --- a/lib/libform/form_field_opts.3 +++ b/lib/libform/form_field_opts.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_opts.3,v 1.3 1997/12/03 05:40:04 millert Exp $ '\" t .TH form_field_opts 3X "" .SH NAME diff --git a/lib/libform/form_field_userptr.3 b/lib/libform/form_field_userptr.3 index f2d7bd9d978..78bf296a5e7 100644 --- a/lib/libform/form_field_userptr.3 +++ b/lib/libform/form_field_userptr.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_userptr.3,v 1.3 1997/12/03 05:40:05 millert Exp $ '\" t .TH form_field_userptr 3X "" .SH NAME @@ -5,9 +6,9 @@ .SH SYNOPSIS \fB#include <form.h>\fR .br -int set_field_userptr(FIELD *field, const void*userptr); +int set_field_userptr(FIELD *field, void*userptr); .br -const void *field_userptr(const FIELD *field); +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 8fee91d0f24..863855429c6 100644 --- a/lib/libform/form_field_validation.3 +++ b/lib/libform/form_field_validation.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_field_validation.3,v 1.3 1997/12/03 05:40:05 millert Exp $ '\" t .TH form_field_validation 3X "" .SH NAME diff --git a/lib/libform/form_fieldtype.3 b/lib/libform/form_fieldtype.3 index a6697eedbfb..a58855d0d40 100644 --- a/lib/libform/form_fieldtype.3 +++ b/lib/libform/form_fieldtype.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_fieldtype.3,v 1.3 1997/12/03 05:40:06 millert Exp $ '\" t .TH form_field 3X "" .SH NAME @@ -22,9 +23,9 @@ int set_fieldtype_choice( bool (* const next_choice)(FIELD *, const void *), bool (* const prev_choice)(FIELD *, const void *)); .br -FIELDTYPE *link_fieldtype(FIELDTYPE *type1, +FIELDTYPE *link_fieldtype(FIELDTYPE *type1, FIELDTYPE *type2); -.br +.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 @@ -40,13 +41,16 @@ the character to be checked and a pointer to an argument-block structure. The function \fBfree_fieldtype\fR frees the space allocated for a given validation type. -The function \fBset_fieldtype\fR associates three storage-management functions +The function \fBset_fieldtype\fR associates three storage-management functions with a field type. The \fImak_arg\fR function is automatically applied to the list of arguments you give \fBset_field_type\fR when attaching validation -to a field; its job is to bundle these into an allocated argument-block +to a field; its job is to bundle these into an allocated argument-block object which can later be passed to validation predicated. The other two hook arguments should copy and free argument-block structures. They will -be used by the forms-driver code. +be used by the forms-driver code. You must supply the \fImak_arg\fR function, +the other two are optional, you may supply NULL for them. In this case it +is assumed, that \fImak_arg\fR doesn't allocate memory but simply loads the +argument into a single scalar value. The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume that the possible values of a field form an ordered set, and provide the forms diff --git a/lib/libform/form_hook.3 b/lib/libform/form_hook.3 index 3ed7d8c38ca..64c638ccd58 100644 --- a/lib/libform/form_hook.3 +++ b/lib/libform/form_hook.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_hook.3,v 1.3 1997/12/03 05:40:06 millert Exp $ '\" t .TH form_hook 3X "" .SH NAME diff --git a/lib/libform/form_new.3 b/lib/libform/form_new.3 index af85586d2a0..54074ffcb3f 100644 --- a/lib/libform/form_new.3 +++ b/lib/libform/form_new.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_new.3,v 1.3 1997/12/03 05:40:06 millert Exp $ '\" t .TH form_new 3X "" .SH NAME diff --git a/lib/libform/form_new_page.3 b/lib/libform/form_new_page.3 index c3d4a1809e1..854dff78935 100644 --- a/lib/libform/form_new_page.3 +++ b/lib/libform/form_new_page.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_new_page.3,v 1.3 1997/12/03 05:40:07 millert Exp $ '\" t .TH form_new_page 3X "" .SH NAME diff --git a/lib/libform/form_opts.3 b/lib/libform/form_opts.3 index dc0e0c45de7..96ca4d8a242 100644 --- a/lib/libform/form_opts.3 +++ b/lib/libform/form_opts.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_opts.3,v 1.3 1997/12/03 05:40:07 millert Exp $ '\" t .TH form_opts 3X "" .SH NAME diff --git a/lib/libform/form_page.3 b/lib/libform/form_page.3 index 27beb3d1801..97eb060ed9f 100644 --- a/lib/libform/form_page.3 +++ b/lib/libform/form_page.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_page.3,v 1.3 1997/12/03 05:40:08 millert Exp $ '\" t .TH form_page 3X "" .SH NAME diff --git a/lib/libform/form_post.3 b/lib/libform/form_post.3 index 42de332c152..cce0b0dd7f2 100644 --- a/lib/libform/form_post.3 +++ b/lib/libform/form_post.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_post.3,v 1.2 1997/12/03 05:40:08 millert Exp $ '\" t .TH form_post 3X "" .SH NAME diff --git a/lib/libform/form_requestname.3 b/lib/libform/form_requestname.3 index 10824d3a704..e8029746480 100644 --- a/lib/libform/form_requestname.3 +++ b/lib/libform/form_requestname.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_requestname.3,v 1.2 1997/12/03 05:40:09 millert Exp $ '\" t .TH form_requestname 3X "" .SH NAME diff --git a/lib/libform/form_userptr.3 b/lib/libform/form_userptr.3 index b32963d4eb9..05e802cc001 100644 --- a/lib/libform/form_userptr.3 +++ b/lib/libform/form_userptr.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_userptr.3,v 1.3 1997/12/03 05:40:09 millert Exp $ '\" t .TH form_userptr 3X "" .SH NAME @@ -5,9 +6,9 @@ .SH SYNOPSIS \fB#include <form.h>\fR .br -int set_form_userptr(FORM *form, const void *userptr); +int set_form_userptr(FORM *form, void *userptr); .br -const void* form_userptr(const FORM *form); +void* form_userptr(const FORM *form); .br .SH DESCRIPTION Every form and every form item has a field that can be used to hold diff --git a/lib/libform/form_win.3 b/lib/libform/form_win.3 index a43f9c08739..67a8ffcf2f7 100644 --- a/lib/libform/form_win.3 +++ b/lib/libform/form_win.3 @@ -1,3 +1,4 @@ +.\" $OpenBSD: form_win.3,v 1.3 1997/12/03 05:40:10 millert Exp $ '\" t .TH form_win 3X "" .SH NAME diff --git a/lib/libform/frm_adabind.c b/lib/libform/frm_adabind.c new file mode 100644 index 00000000000..bbb95e5a968 --- /dev/null +++ b/lib/libform/frm_adabind.c @@ -0,0 +1,73 @@ +/* $OpenBSD: frm_adabind.c,v 1.1 1997/12/03 05:40:10 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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 frm_adabind.c * +* Helper routines to ease the implementation of an Ada95 binding to * +* ncurses. For details and copyright of the binding see the ../Ada95 * +* subdirectory. * +***************************************************************************/ +#include "form.priv.h" + +MODULE_ID("Id: frm_adabind.c,v 1.4 1997/09/05 23:04:11 juergen Exp $") + +/* Prototypes for the functions in this module */ +void _nc_ada_normalize_field_opts (int *opt); +void _nc_ada_normalize_form_opts (int *opt); +void* _nc_ada_getvarg(va_list *); +FIELD* _nc_get_field(const FORM*, int); + + +void _nc_ada_normalize_field_opts (int *opt) +{ + *opt = ALL_FIELD_OPTS & (*opt); +} + +void _nc_ada_normalize_form_opts (int *opt) +{ + *opt = ALL_FORM_OPTS & (*opt); +} + + +/* This tiny stub helps us to get a void pointer from an argument list. +// The mechanism for libform to handle arguments to field types uses +// unfortunately functions with variable argument lists. In the Ada95 +// binding we replace this by a mechanism that only uses one argument +// that is a pointer to a record describing all the specifics of an +// user defined field type. So we need only this simple generic +// procedure to get the pointer from the arglist. +*/ +void *_nc_ada_getvarg(va_list *ap) +{ + return va_arg(*ap,void*); +} + +FIELD* _nc_get_field(const FORM* frm, int idx) { + if (frm && frm->field && idx>=0 && (idx<frm->maxfield)) + { + return frm->field[idx]; + } + else + return (FIELD*)0; +} diff --git a/lib/libform/frm_cursor.c b/lib/libform/frm_cursor.c new file mode 100644 index 00000000000..1082bcd60c9 --- /dev/null +++ b/lib/libform/frm_cursor.c @@ -0,0 +1,58 @@ +/* $OpenBSD: frm_cursor.c,v 1.1 1997/12/03 05:40:10 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_cursor.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int pos_form_cursor(FORM * form) +| +| Description : Moves the form window cursor to the location required +| by the form driver to resume form processing. This may +| be needed after the application calls a curses library +| I/O routine that modifies the cursor position. +| +| Return Values : E_OK - Success +| E_SYSTEM_ERROR - System error. +| E_BAD_ARGUMENT - Invalid form pointer +| E_NOT_POSTED - Form is not posted ++--------------------------------------------------------------------------*/ +int pos_form_cursor(FORM * form) +{ + int res; + + if (!form) + res = E_BAD_ARGUMENT; + else + { + if (!(form->status & _POSTED)) + res = E_NOT_POSTED; + else + res = _nc_Position_Form_Cursor(form); + } + RETURN(res); +} + +/* frm_cursor.c ends here */ diff --git a/lib/libform/frm_data.c b/lib/libform/frm_data.c index a55a1f02edf..1db2b6163fa 100644 --- a/lib/libform/frm_data.c +++ b/lib/libform/frm_data.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_data.c,v 1.3 1997/12/03 05:40:11 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | diff --git a/lib/libform/frm_def.c b/lib/libform/frm_def.c index 3d60df4b384..09598ea9640 100644 --- a/lib/libform/frm_def.c +++ b/lib/libform/frm_def.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_def.c,v 1.3 1997/12/03 05:40:11 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,7 +24,7 @@ #include "form.priv.h" -MODULE_ID("Id: frm_def.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: frm_def.c,v 1.6 1997/10/21 13:24:19 juergen Exp $") /* this can't be readonly */ static FORM default_form = { @@ -109,23 +111,24 @@ static FIELD *Insert_Field_By_Position(FIELD *newfield, FIELD *head) +--------------------------------------------------------------------------*/ static void Disconnect_Fields( FORM * form ) { - FIELD **fields; - - assert(form && form->field); - - for(fields=form->field;*fields;fields++) + if (form->field) { - if (form == (*fields)->form) - (*fields)->form = (FORM *)0; - } - - form->rows = form->cols = 0; - form->maxfield = form->maxpage = -1; - form->field = (FIELD **)0; - if (form->page) - free(form->page); - form->page = (_PAGE *)0; -} + FIELD **fields; + + for(fields=form->field;*fields;fields++) + { + if (form == (*fields)->form) + (*fields)->form = (FORM *)0; + } + + form->rows = form->cols = 0; + form->maxfield = form->maxpage = -1; + form->field = (FIELD **)0; + if (form->page) + free(form->page); + form->page = (_PAGE *)0; + } +} /*--------------------------------------------------------------------------- | Facility : libnform @@ -362,30 +365,4 @@ int field_count(const FORM * form) return (Normalize_Form( form )->maxfield); } -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int scale_form( const FORM *form, int *rows, int *cols ) -| -| Description : Retrieve size of form -| -| Return Values : E_OK - no error -| E_BAD_ARGUMENT - invalid form pointer -| E_NOT_CONNECTED - no fields connected to form -+--------------------------------------------------------------------------*/ -int scale_form(const FORM * form, int * rows, int * cols) -{ - if ( !form ) - RETURN(E_BAD_ARGUMENT); - - if ( !(form->field) ) - RETURN(E_NOT_CONNECTED); - - if (rows) - *rows = form->rows; - if (cols) - *cols = form->cols; - - RETURN(E_OK); -} - /* frm_def.c ends here */ diff --git a/lib/libform/frm_driver.c b/lib/libform/frm_driver.c index 1642773c326..7bf4365bdf5 100644 --- a/lib/libform/frm_driver.c +++ b/lib/libform/frm_driver.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_driver.c,v 1.4 1997/12/03 05:40:12 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -19,6 +21,9 @@ | 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_driver.c,v 1.28 1997/10/21 13:24:19 juergen Exp $") /*---------------------------------------------------------------------------- This is the core module of the form library. It contains the majority @@ -63,10 +68,6 @@ routines I omit them mostly. --------------------------------------------------------------------------*/ -#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 @@ -85,6 +86,8 @@ Perhaps at some time we will make this configurable at runtime. #define FRIENDLY_PREV_NEXT_WORD (1) /* Fix the wrong behaviour for forms with all fields inactive */ #define FIX_FORM_INACTIVE_BUG (1) +/* Allow dynamic field growth also when navigating past the end */ +#define GROW_IF_NAVIGATE (1) /*---------------------------------------------------------------------------- Forward references to some internally used static functions @@ -180,13 +183,6 @@ static int FE_Delete_Previous(FORM *); #define First_Position_In_Current_Field(form) \ (((form)->currow==0) && ((form)->curcol==0)) -/* This are the field options required to be a selectable field in field - navigation requests */ -#define O_SELECTABLE (O_ACTIVE | O_VISIBLE) - -/* Logic to determine whether or not a field is selectable */ -#define Field_Is_Selectable(f) (((f)->opts & O_SELECTABLE)==O_SELECTABLE) -#define Field_Is_Not_Selectable(f) (((f)->opts & O_SELECTABLE)!=O_SELECTABLE) #define Minimum(a,b) (((a)<=(b)) ? (a) : (b)) #define Maximum(a,b) (((a)>=(b)) ? (a) : (b)) @@ -545,9 +541,9 @@ static bool Field_Grown(FIELD * field, int amount) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Position_Form_Cursor(FORM * form) +| Function : int _nc_Position_Form_Cursor(FORM * form) | -| Description : Position the currsor in the window for the current +| Description : Position the cursor in the window for the current | field to be in sync. with the currow and curcol | values. | @@ -556,7 +552,8 @@ static bool Field_Grown(FIELD * field, int amount) | E_SYSTEM_ERROR - form has no current field or | field-window +--------------------------------------------------------------------------*/ -static int Position_Form_Cursor(FORM * form) +int +_nc_Position_Form_Cursor(FORM * form) { FIELD *field; WINDOW *formwin; @@ -587,7 +584,7 @@ static int Position_Form_Cursor(FORM * form) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Refresh_Current_Field(FORM * form) +| Function : int _nc_Refresh_Current_Field(FORM * form) | | Description : Propagate the changes in the fields window to the | window of the form. @@ -596,7 +593,8 @@ static int Position_Form_Cursor(FORM * form) | E_BAD_ARGUMENT - invalid form pointer | E_SYSTEM_ERROR - general error +--------------------------------------------------------------------------*/ -static int Refresh_Current_Field(FORM * form) +int +_nc_Refresh_Current_Field(FORM * form) { WINDOW *formwin; FIELD *field; @@ -703,7 +701,7 @@ static int Refresh_Current_Field(FORM * form) } } untouchwin(form->w); - return Position_Form_Cursor(form); + return _nc_Position_Form_Cursor(form); } /*--------------------------------------------------------------------------- @@ -805,7 +803,7 @@ static bool Check_Char(FIELDTYPE * typ, int ch, TypeArgument *argp) return typ->ccheck(ch,(void *)argp); } } - return isprint((unsigned char)ch); + return (isprint((unsigned char)ch) ? TRUE : FALSE); } /*--------------------------------------------------------------------------- @@ -892,7 +890,7 @@ static int Synchronize_Field(FIELD * field) Buffer_To_Window( field, form->w ); field->status |= _NEWTOP; - res = Refresh_Current_Field( form ); + res = _nc_Refresh_Current_Field( form ); } else res = Display_Field( field ); @@ -938,7 +936,7 @@ static int Synchronize_Linked_Fields(FIELD * field) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Synchronize_Attributes(FIELD * field) +| Function : int _nc_Synchronize_Attributes(FIELD * field) | | Description : If a fields visual attributes have changed, this | routine is called to propagate those changes to the @@ -948,7 +946,7 @@ static int Synchronize_Linked_Fields(FIELD * field) | E_BAD_ARGUMENT - invalid field pointer | E_SYSTEM_ERROR - some severe basic error +--------------------------------------------------------------------------*/ -static int Synchronize_Attributes(FIELD * field) +int _nc_Synchronize_Attributes(FIELD * field) { FORM *form; int res = E_OK; @@ -982,7 +980,7 @@ static int Synchronize_Attributes(FIELD * field) wsyncup(formwin); Buffer_To_Window(field,form->w); field->status |= _NEWTOP; /* fake refresh to paint all */ - Refresh_Current_Field(form); + _nc_Refresh_Current_Field(form); } } else @@ -995,8 +993,8 @@ static int Synchronize_Attributes(FIELD * field) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Synchronize_Options(FIELD * field, -| Field_Options newopts) +| Function : int _nc_Synchronize_Options(FIELD * field, +| Field_Options newopts) | | Description : If a fields options have changed, this routine is | called to propagate these changes to the screen and @@ -1006,7 +1004,8 @@ static int Synchronize_Attributes(FIELD * field) | E_BAD_ARGUMENT - invalid field pointer | E_SYSTEM_ERROR - some severe basic error +--------------------------------------------------------------------------*/ -static int Synchronize_Options(FIELD *field, Field_Options newopts) +int +_nc_Synchronize_Options(FIELD *field, Field_Options newopts) { Field_Options oldopts; Field_Options changed_opts; @@ -1036,9 +1035,9 @@ static int Synchronize_Options(FIELD *field, Field_Options newopts) if (changed_opts & O_VISIBLE) { if (newopts & O_VISIBLE) - res = Erase_Field(field); - else res = Display_Field(field); + else + res = Erase_Field(field); } else { @@ -1094,9 +1093,8 @@ static int Synchronize_Options(FIELD *field, Field_Options newopts) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Set_Current_Field( -| FORM * form, -| FIELD * newfield) +| Function : int _nc_Set_Current_Field(FORM * form, +| FIELD * newfield) | | Description : Make the newfield the new current field. | @@ -1104,7 +1102,8 @@ static int Synchronize_Options(FIELD *field, Field_Options newopts) | E_BAD_ARGUMENT - invalid form or field pointer | E_SYSTEM_ERROR - some severe basic error +--------------------------------------------------------------------------*/ -static int Set_Current_Field(FORM *form, FIELD *newfield) +int +_nc_Set_Current_Field(FORM *form, FIELD *newfield) { FIELD *field; WINDOW *new_window; @@ -1127,7 +1126,7 @@ static int Set_Current_Field(FORM *form, FIELD *newfield) (field->opts & O_VISIBLE) && (field->form->curpage == field->page)) { - Refresh_Current_Field(form); + _nc_Refresh_Current_Field(form); if (field->opts & O_PUBLIC) { if (field->drows > field->rows) @@ -1198,7 +1197,7 @@ static int Set_Current_Field(FORM *form, FIELD *newfield) | Function : static int IFN_Next_Character(FORM * form) | | Description : Move to the next character in the field. In a multiline -| field this wraps and the end of the line. +| field this wraps at the end of the line. | | Return Values : E_OK - success | E_REQUEST_DENIED - at the rightmost position @@ -1211,7 +1210,17 @@ static int IFN_Next_Character(FORM * form) { if ((++(form->currow))==field->drows) { +#if GROW_IF_NAVIGATE + if (!Single_Line_Field(field) && Field_Grown(field,1)) { + form->curcol = 0; + return(E_OK); + } +#endif form->currow--; +#if GROW_IF_NAVIGATE + if (Single_Line_Field(field) && Field_Grown(field,1)) + return(E_OK); +#endif form->curcol--; return(E_REQUEST_DENIED); } @@ -1261,6 +1270,10 @@ static int IFN_Next_Line(FORM * form) if ((++(form->currow))==field->drows) { +#if GROW_IF_NAVIGATE + if (!Single_Line_Field(field) && Field_Grown(field,1)) + return(E_OK); +#endif form->currow--; return(E_REQUEST_DENIED); } @@ -1500,6 +1513,11 @@ static int IFN_Right_Character(FORM * form) { if ( (++(form->curcol)) == form->current->dcols ) { +#if GROW_IF_NAVIGATE + FIELD *field = form->current; + if (Single_Line_Field(field) && Field_Grown(field,1)) + return(E_OK); +#endif --(form->curcol); return(E_REQUEST_DENIED); } @@ -1542,6 +1560,10 @@ static int IFN_Down_Character(FORM * form) if ( (++(form->currow)) == field->drows ) { +#if GROW_IF_NAVIGATE + if (!Single_Line_Field(field) && Field_Grown(field,1)) + return(E_OK); +#endif --(form->currow); return(E_REQUEST_DENIED); } @@ -2025,7 +2047,7 @@ static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form) if ( (field->opts & O_WRAP) && /* wrapping wanted */ (!Single_Line_Field(field)) && /* must be multi-line */ - (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line id full */ + (There_Is_No_Room_For_A_Char_In_Line(form)) && /* line is full */ (!Last_Row || Growable(field)) ) /* there are more lines*/ { char *bp; @@ -2060,6 +2082,8 @@ static int Wrapping_Not_Necessary_Or_Wrapping_Ok(FORM * form) return E_OK; } } + else + return E_OK; if (result!=E_OK) { wmove(form->w,form->currow,form->curcol); @@ -2644,14 +2668,15 @@ static bool Check_Field(FIELDTYPE *typ, FIELD *field, TypeArgument *argp) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static bool Internal_Validation(FORM * form ) +| Function : bool _nc_Internal_Validation(FORM * form ) | | Description : Validate the current field of the form. | | Return Values : TRUE - field is valid | FALSE - field is invalid +--------------------------------------------------------------------------*/ -static bool Internal_Validation(FORM *form) +bool +_nc_Internal_Validation(FORM *form) { FIELD *field; @@ -2688,7 +2713,7 @@ static bool Internal_Validation(FORM *form) +--------------------------------------------------------------------------*/ static int FV_Validation(FORM * form) { - if (Internal_Validation(form)) + if (_nc_Internal_Validation(form)) return E_OK; else return E_INVALID_FIELD; @@ -2731,7 +2756,7 @@ INLINE static FIELD *Next_Field_On_Page(FIELD * field) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static FIELD * First_Active_Field(FORM * form) +| Function : FIELD* _nc_First_Active_Field(FORM * form) | | Description : Get the first active field on the current page, | if there are such. If there are none, get the first @@ -2740,7 +2765,8 @@ INLINE static FIELD *Next_Field_On_Page(FIELD * field) | | Return Values : Pointer to calculated field. +--------------------------------------------------------------------------*/ -static FIELD * First_Active_Field(FORM * form) +FIELD* +_nc_First_Active_Field(FORM * form) { FIELD **last_on_page = &form->field[form->page[form->curpage].pmax]; FIELD *proposed = Next_Field_On_Page(*last_on_page); @@ -3019,7 +3045,7 @@ static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form) { int res; - if (!Internal_Validation(form)) + if (!_nc_Internal_Validation(form)) res = E_INVALID_FIELD; else { @@ -3041,8 +3067,8 @@ static int Inter_Field_Navigation(int (* const fct) (FORM *),FORM *form) +--------------------------------------------------------------------------*/ static int FN_Next_Field(FORM * form) { - return Set_Current_Field(form, - Next_Field_On_Page(form->current)); + return _nc_Set_Current_Field(form, + Next_Field_On_Page(form->current)); } /*--------------------------------------------------------------------------- @@ -3057,8 +3083,8 @@ static int FN_Next_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Previous_Field(FORM * form) { - return Set_Current_Field(form, - Previous_Field_On_Page(form->current)); + return _nc_Set_Current_Field(form, + Previous_Field_On_Page(form->current)); } /*--------------------------------------------------------------------------- @@ -3072,9 +3098,8 @@ static int FN_Previous_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_First_Field(FORM * form) { - return - Set_Current_Field(form, - Next_Field_On_Page(form->field[form->page[form->curpage].pmax])); + return _nc_Set_Current_Field(form, + Next_Field_On_Page(form->field[form->page[form->curpage].pmax])); } /*--------------------------------------------------------------------------- @@ -3089,7 +3114,7 @@ static int FN_First_Field(FORM * form) static int FN_Last_Field(FORM * form) { return - Set_Current_Field(form, + _nc_Set_Current_Field(form, Previous_Field_On_Page(form->field[form->page[form->curpage].pmin])); } @@ -3105,8 +3130,8 @@ static int FN_Last_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Sorted_Next_Field(FORM * form) { - return Set_Current_Field(form, - Sorted_Next_Field(form->current)); + return _nc_Set_Current_Field(form, + Sorted_Next_Field(form->current)); } /*--------------------------------------------------------------------------- @@ -3121,8 +3146,8 @@ static int FN_Sorted_Next_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Sorted_Previous_Field(FORM * form) { - return Set_Current_Field(form, - Sorted_Previous_Field(form->current)); + return _nc_Set_Current_Field(form, + Sorted_Previous_Field(form->current)); } /*--------------------------------------------------------------------------- @@ -3137,8 +3162,8 @@ static int FN_Sorted_Previous_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Sorted_First_Field(FORM * form) { - return Set_Current_Field(form, - Sorted_Next_Field(form->field[form->page[form->curpage].smax])); + return _nc_Set_Current_Field(form, + Sorted_Next_Field(form->field[form->page[form->curpage].smax])); } /*--------------------------------------------------------------------------- @@ -3153,7 +3178,7 @@ static int FN_Sorted_First_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Sorted_Last_Field(FORM * form) { - return Set_Current_Field(form, + return _nc_Set_Current_Field(form, Sorted_Previous_Field(form->field[form->page[form->curpage].smin])); } @@ -3169,8 +3194,8 @@ static int FN_Sorted_Last_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Left_Field(FORM * form) { - return Set_Current_Field(form, - Left_Neighbour_Field(form->current)); + return _nc_Set_Current_Field(form, + Left_Neighbour_Field(form->current)); } /*--------------------------------------------------------------------------- @@ -3185,8 +3210,8 @@ static int FN_Left_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Right_Field(FORM * form) { - return Set_Current_Field(form, - Right_Neighbour_Field(form->current)); + return _nc_Set_Current_Field(form, + Right_Neighbour_Field(form->current)); } /*--------------------------------------------------------------------------- @@ -3203,8 +3228,8 @@ static int FN_Right_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Up_Field(FORM * form) { - return Set_Current_Field(form, - Upper_Neighbour_Field(form->current)); + return _nc_Set_Current_Field(form, + Upper_Neighbour_Field(form->current)); } /*--------------------------------------------------------------------------- @@ -3221,8 +3246,8 @@ static int FN_Up_Field(FORM * form) +--------------------------------------------------------------------------*/ static int FN_Down_Field(FORM * form) { - return Set_Current_Field(form, - Down_Neighbour_Field(form->current)); + return _nc_Set_Current_Field(form, + Down_Neighbour_Field(form->current)); } /*---------------------------------------------------------------------------- END of Field Navigation routines @@ -3234,9 +3259,9 @@ static int FN_Down_Field(FORM * form) /*--------------------------------------------------------------------------- | Facility : libnform -| Function : static int Set_Form_Page(FORM * form, -| int page, -| FIELD * field) +| Function : int _nc_Set_Form_Page(FORM * form, +| int page, +| FIELD * field) | | Description : Make the given page nr. the current page and make | the given field the current field on the page. If @@ -3247,7 +3272,8 @@ static int FN_Down_Field(FORM * form) | Return Values : E_OK - success | != E_OK - error from subordinate call +--------------------------------------------------------------------------*/ -static int Set_Form_Page(FORM * form, int page, FIELD * field) +int +_nc_Set_Form_Page(FORM * form, int page, FIELD * field) { int res = E_OK; @@ -3267,7 +3293,7 @@ static int Set_Form_Page(FORM * form, int page, FIELD * field) } while(field_on_page != last_field); if (field) - res = Set_Current_Field(form,field); + res = _nc_Set_Current_Field(form,field); else /* N.B.: we don't encapsulate this by Inter_Field_Navigation(), because this is already executed in a page navigation @@ -3332,7 +3358,7 @@ static int Page_Navigation(int (* const fct) (FORM *), FORM * form) { int res; - if (!Internal_Validation(form)) + if (!_nc_Internal_Validation(form)) res = E_INVALID_FIELD; else { @@ -3356,7 +3382,7 @@ static int Page_Navigation(int (* const fct) (FORM *), FORM * form) +--------------------------------------------------------------------------*/ static int PN_Next_Page(FORM * form) { - return Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0); + return _nc_Set_Form_Page(form,Next_Page_Number(form),(FIELD *)0); } /*--------------------------------------------------------------------------- @@ -3370,7 +3396,7 @@ static int PN_Next_Page(FORM * form) +--------------------------------------------------------------------------*/ static int PN_Previous_Page(FORM * form) { - return Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0); + return _nc_Set_Form_Page(form,Previous_Page_Number(form),(FIELD *)0); } /*--------------------------------------------------------------------------- @@ -3384,7 +3410,7 @@ static int PN_Previous_Page(FORM * form) +--------------------------------------------------------------------------*/ static int PN_First_Page(FORM * form) { - return Set_Form_Page(form,0,(FIELD *)0); + return _nc_Set_Form_Page(form,0,(FIELD *)0); } /*--------------------------------------------------------------------------- @@ -3398,7 +3424,7 @@ static int PN_First_Page(FORM * form) +--------------------------------------------------------------------------*/ static int PN_Last_Page(FORM * form) { - return Set_Form_Page(form,form->maxpage-1,(FIELD *)0); + return _nc_Set_Form_Page(form,form->maxpage-1,(FIELD *)0); } /*---------------------------------------------------------------------------- END of Field Navigation routines @@ -3423,7 +3449,6 @@ static int Data_Entry(FORM * form, int c) { FIELD *field = form->current; int result = E_REQUEST_DENIED; - bool End_Of_Field; if ( (field->opts & O_EDIT) #if FIX_FORM_INACTIVE_BUG @@ -3457,9 +3482,9 @@ static int Data_Entry(FORM * form, int c) if ((result=Wrapping_Not_Necessary_Or_Wrapping_Ok(form))==E_OK) { + bool End_Of_Field= (((field->drows-1)==form->currow) && + ((field->dcols-1)==form->curcol)); form->status |= _WINDOW_MODIFIED; - End_Of_Field= (((field->drows-1)==form->currow) && - ((field->dcols-1)==form->curcol)); if (End_Of_Field && !Growable(field) && (field->opts & O_AUTOSKIP)) result = Inter_Field_Navigation(FN_Next_Field,form); else @@ -3616,7 +3641,7 @@ int form_driver(FORM * form, int c) if (c==FIRST_ACTIVE_MAGIC) { - form->current = First_Active_Field(form); + form->current = _nc_First_Active_Field(form); return E_OK; } @@ -3650,10 +3675,10 @@ int form_driver(FORM * form, int c) NULL, /* Field Validation is generic */ NULL /* Choice Request is generic */ }; - int nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0])); - int method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff; + size_t nMethods = (sizeof(Generic_Methods)/sizeof(Generic_Methods[0])); + size_t method = ((BI->keycode & ID_Mask) >> ID_Shft) & 0xffff; - if ( (method < 0) || (method >= nMethods) || !(BI->cmd) ) + if ( (method >= nMethods) || !(BI->cmd) ) res = E_SYSTEM_ERROR; else { @@ -3672,274 +3697,15 @@ int form_driver(FORM * form, int c) (TypeArgument *)(form->current->arg))) res = Data_Entry(form,c); } - Refresh_Current_Field(form); + _nc_Refresh_Current_Field(form); RETURN(res); } -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int post_form(FORM * form) -| -| Description : Writes the form into its associated subwindow. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid form pointer -| E_POSTED - form already posted -| E_NOT_CONNECTED - no fields connected to form -| E_NO_ROOM - form doesn't fit into subwindow -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int post_form(FORM * form) -{ - WINDOW *formwin; - int err; - int page; - - if (!form) - RETURN(E_BAD_ARGUMENT); - - if (form->status & _POSTED) - RETURN(E_POSTED); - - if (!(form->field)) - RETURN(E_NOT_CONNECTED); - - formwin = Get_Form_Window(form); - if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin))) - RETURN(E_NO_ROOM); - - /* reset form->curpage to an invald value. This forces Set_Form_Page - to do the page initialization which is required by post_form. - */ - page = form->curpage; - form->curpage = -1; - if ((err = Set_Form_Page(form,page,form->current))!=E_OK) - RETURN(err); - - form->status |= _POSTED; - - Call_Hook(form,forminit); - Call_Hook(form,fieldinit); - - Refresh_Current_Field(form); - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int unpost_form(FORM * form) -| -| Description : Erase form from its associated subwindow. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid form pointer -| E_NOT_POSTED - form isn't posted -| E_BAD_STATE - called from a hook routine -+--------------------------------------------------------------------------*/ -int unpost_form(FORM * form) -{ - if (!form) - RETURN(E_BAD_ARGUMENT); - - if (!(form->status & _POSTED)) - RETURN(E_NOT_POSTED); - - if (form->status & _IN_DRIVER) - RETURN(E_BAD_STATE); - - Call_Hook(form,fieldterm); - Call_Hook(form,formterm); - - werase(Get_Form_Window(form)); - delwin(form->w); - form->w = (WINDOW *)0; - form->status &= ~_POSTED; - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int pos_form_cursor(FORM * form) -| -| Description : Moves the form window cursor to the location required -| by the form driver to resume form processing. This may -| be needed after the application calls a curses library -| I/O routine that modifies the cursor position. -| -| Return Values : E_OK - Success -| E_SYSTEM_ERROR - System error. -| E_BAD_ARGUMENT - Invalid form pointer -| E_NOT_POSTED - Form is not posted -+--------------------------------------------------------------------------*/ -int pos_form_cursor(FORM * form) -{ - int res; - - if (!form) - res = E_BAD_ARGUMENT; - else - { - if (!(form->status & _POSTED)) - res = E_NOT_POSTED; - else - res = Position_Form_Cursor(form); - } - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_current_field(FORM * form,FIELD * field) -| -| Description : Set the current field of the form to the specified one. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid form or field pointer -| E_REQUEST_DENIED - field not selectable -| E_BAD_STATE - called from a hook routine -| E_INVALID_FIELD - current field can't be left -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_current_field(FORM * form, FIELD * field) -{ - int err = E_OK; - - if ( !form || !field ) - RETURN(E_BAD_ARGUMENT); - - if ( (form != field->form) || Field_Is_Not_Selectable(field) ) - RETURN(E_REQUEST_DENIED); - - if (!(form->status & _POSTED)) - { - form->current = field; - form->curpage = field->page; - } - else - { - if (form->status & _IN_DRIVER) - err = E_BAD_STATE; - else - { - if (form->current != field) - { - if (!Internal_Validation(form)) - err = E_INVALID_FIELD; - else - { - Call_Hook(form,fieldterm); - if (field->page != form->curpage) - { - Call_Hook(form,formterm); - err = Set_Form_Page(form,field->page,field); - Call_Hook(form,forminit); - } - else - { - err = Set_Current_Field(form,field); - } - Call_Hook(form,fieldinit); - Refresh_Current_Field(form); - } - } - } - } - RETURN(err); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : FIELD *current_field(const FORM * form) -| -| Description : Return the current field. -| -| Return Values : Pointer to the current field. -+--------------------------------------------------------------------------*/ -FIELD *current_field(const FORM * form) -{ - return Normalize_Form(form)->current; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_index(const FIELD * field) -| -| Description : Return the index of the field in the field-array of -| the form. -| -| Return Values : >= 0 : field index -| -1 : fieldpointer invalid or field not connected -+--------------------------------------------------------------------------*/ -int field_index(const FIELD * field) -{ - return ( (field && field->form) ? field->index : -1 ); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_form_page(FORM * form,int page) -| -| Description : Set the page number of the form. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid form pointer or page number -| E_BAD_STATE - called from a hook routine -| E_INVALID_FIELD - current field can't be left -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_form_page(FORM * form, int page) -{ - int err = E_OK; - - if ( !form || (page<0) || (page>=form->maxpage) ) - RETURN(E_BAD_ARGUMENT); - - if (!(form->status & _POSTED)) - { - form->curpage = page; - form->current = First_Active_Field(form); - } - else - { - if (form->status & _IN_DRIVER) - err = E_BAD_STATE; - else - { - if (form->curpage != page) - { - if (!Internal_Validation(form)) - err = E_INVALID_FIELD; - else - { - Call_Hook(form,fieldterm); - Call_Hook(form,formterm); - err = Set_Form_Page(form,page,(FIELD *)0); - Call_Hook(form,forminit); - Call_Hook(form,fieldinit); - Refresh_Current_Field(form); - } - } - } - } - RETURN(err); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int form_page(const FORM * form) -| -| Description : Return the current page of the form. -| -| Return Values : >= 0 : current page number -| -1 : invalid form pointer -+--------------------------------------------------------------------------*/ -int form_page(const FORM * form) -{ - return Normalize_Form(form)->curpage; -} - /*---------------------------------------------------------------------------- - Field-Buffer manipulation routines + Field-Buffer manipulation routines. + The effects of setting a buffer is tightly coupled to the core of the form + driver logic. This is especially true in the case of growable fields. + So I don't separate this into an own module. --------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------- @@ -4016,14 +3782,19 @@ int set_field_buffer(FIELD * field, int buffer, const char * value) for(s=(char *)value; *s && (s < (value+len)); s++) p[s-value] = *s; if (s < (value+len)) - p[s-value] = *s++; + { + p[s-value] = *s++; + s = p + (s-value); + } 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 */ + buffer. We have to pad with blanks. Please note that due to memccpy + logic s points after the terminating null. */ + s--; /* now we point to the terminator. */ assert(len >= (unsigned int)(s-p)); if (len > (unsigned int)(s-p)) memset(s,C_BLANK,len-(unsigned int)(s-p)); @@ -4057,251 +3828,5 @@ char *field_buffer(const FIELD * field, int buffer) else return (char *)0; } - -/*---------------------------------------------------------------------------- - Field-Options manipulation routines - --------------------------------------------------------------------------*/ - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_opts(FIELD *field, Field_Options opts) -| -| Description : Turns on the named options for this field and turns -| off all the remaining options. -| -| Return Values : E_OK - success -| E_CURRENT - the field is the current field -| E_BAD_ARGUMENT - invalid options -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_field_opts(FIELD * field, Field_Options opts) -{ - int res = E_BAD_ARGUMENT; - if (!(opts & ~ALL_FIELD_OPTS)) - res = Synchronize_Options( Normalize_Field(field), opts ); - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : Field_Options field_opts(const FIELD *field) -| -| Description : Retrieve the fields options. -| -| Return Values : The options. -+--------------------------------------------------------------------------*/ -Field_Options field_opts(const FIELD * field) -{ - return ALL_FIELD_OPTS & Normalize_Field( field )->opts; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_opts_on(FIELD *field, Field_Options opts) -| -| Description : Turns on the named options for this field and all the -| remaining options are unchanged. -| -| Return Values : E_OK - success -| E_CURRENT - the field is the current field -| E_BAD_ARGUMENT - invalid options -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int field_opts_on(FIELD * field, Field_Options opts) -{ - int res = E_BAD_ARGUMENT; - - if (!(opts & ~ALL_FIELD_OPTS)) - { - Normalize_Field( field ); - res = Synchronize_Options( field, field->opts | opts ); - } - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_opts_off(FIELD *field, Field_Options opts) -| -| Description : Turns off the named options for this field and all the -| remaining options are unchanged. -| -| Return Values : E_OK - success -| E_CURRENT - the field is the current field -| E_BAD_ARGUMENT - invalid options -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int field_opts_off(FIELD * field, Field_Options opts) -{ - int res = E_BAD_ARGUMENT; - - if (!(opts & ~ALL_FIELD_OPTS)) - { - Normalize_Field( field ); - res = Synchronize_Options( field, field->opts & ~opts ); - } - RETURN(res); -} - -/*---------------------------------------------------------------------------- - Field-Attribute manipulation routines - --------------------------------------------------------------------------*/ -/* "Template" macro to generate a function to set a fields attribute */ -#define GEN_FIELD_ATTR_SET_FCT( name ) \ -int set_field_ ## name (FIELD * field, chtype attr)\ -{\ - int res = E_BAD_ARGUMENT;\ - if ( attr==A_NORMAL || ((attr & A_ATTRIBUTES)==attr) )\ - {\ - Normalize_Field( field );\ - if ((field -> name) != attr)\ - {\ - field -> name = attr;\ - res = Synchronize_Attributes( field );\ - }\ - else\ - res = E_OK;\ - }\ - RETURN(res);\ -} - -/* "Template" macro to generate a function to get a fields attribute */ -#define GEN_FIELD_ATTR_GET_FCT( name ) \ -chtype field_ ## name (const FIELD * field)\ -{\ - return ( A_ATTRIBUTES & (Normalize_Field( field ) -> name) );\ -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_fore(FIELD *field, chtype attr) -| -| Description : Sets the foreground of the field used to display the -| field contents. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid attributes -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -GEN_FIELD_ATTR_SET_FCT( fore ) - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : chtype field_fore(const FIELD *) -| -| Description : Retrieve fields foreground attribute -| -| Return Values : The foreground attribute -+--------------------------------------------------------------------------*/ -GEN_FIELD_ATTR_GET_FCT( fore ) - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_back(FIELD *field, chtype attr) -| -| Description : Sets the background of the field used to display the -| fields extend. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid attributes -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -GEN_FIELD_ATTR_SET_FCT( back ) - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : chtype field_back(const -| -| Description : Retrieve fields background attribute -| -| Return Values : The background attribute -+--------------------------------------------------------------------------*/ -GEN_FIELD_ATTR_GET_FCT( back ) - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_pad(FIELD *field, int ch) -| -| Description : Set the pad character used to fill the field. This must -| be a printable character. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - invalid field pointer or pad character -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_field_pad(FIELD * field, int ch) -{ - int res = E_BAD_ARGUMENT; - - Normalize_Field( field ); - if (isprint((unsigned char)ch)) - { - if (field->pad != ch) - { - field->pad = ch; - res = Synchronize_Attributes( field ); - } - else - res = E_OK; - } - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_pad(const FIELD *field) -| -| Description : Retrieve the fields pad character. -| -| Return Values : The pad character. -+--------------------------------------------------------------------------*/ -int field_pad(const FIELD * field) -{ - return Normalize_Field( field )->pad; -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_field_just(FIELD *field, int just) -| -| Description : Set the fields type of justification. -| -| Return Values : E_OK - success -| E_BAD_ARGUMENT - one of the arguments was incorrect -| E_SYSTEM_ERROR - system error -+--------------------------------------------------------------------------*/ -int set_field_just(FIELD * field, int just) -{ - int res = E_BAD_ARGUMENT; - - if ((just==NO_JUSTIFICATION) || - (just==JUSTIFY_LEFT) || - (just==JUSTIFY_CENTER) || - (just==JUSTIFY_RIGHT) ) - { - Normalize_Field( field ); - if (field->just != just) - { - field->just = just; - res = Synchronize_Attributes( field ); - } - else - res = E_OK; - } - RETURN(res); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int field_just( const FIELD *field ) -| -| Description : Retrieve the fields type of justification -| -| Return Values : The justification type. -+--------------------------------------------------------------------------*/ -int field_just(const FIELD * field) -{ - return Normalize_Field( field )->just; -} /* frm_driver.c ends here */ diff --git a/lib/libform/frm_hook.c b/lib/libform/frm_hook.c index b68647e9819..001f93218ac 100644 --- a/lib/libform/frm_hook.c +++ b/lib/libform/frm_hook.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_hook.c,v 1.3 1997/12/03 05:40:13 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | diff --git a/lib/libform/frm_opts.c b/lib/libform/frm_opts.c index 738f2341ed6..2b599a6ea27 100644 --- a/lib/libform/frm_opts.c +++ b/lib/libform/frm_opts.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_opts.c,v 1.3 1997/12/03 05:40:13 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | diff --git a/lib/libform/frm_page.c b/lib/libform/frm_page.c new file mode 100644 index 00000000000..40ef622a96d --- /dev/null +++ b/lib/libform/frm_page.c @@ -0,0 +1,92 @@ +/* $OpenBSD: frm_page.c,v 1.1 1997/12/03 05:40:14 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_page.c,v 1.2 1997/10/26 11:21:04 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_form_page(FORM * form,int page) +| +| Description : Set the page number of the form. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid form pointer or page number +| E_BAD_STATE - called from a hook routine +| E_INVALID_FIELD - current field can't be left +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int set_form_page(FORM * form, int page) +{ + int err = E_OK; + + if ( !form || (page<0) || (page>=form->maxpage) ) + RETURN(E_BAD_ARGUMENT); + + if (!(form->status & _POSTED)) + { + form->curpage = page; + form->current = _nc_First_Active_Field(form); + } + else + { + if (form->status & _IN_DRIVER) + err = E_BAD_STATE; + else + { + if (form->curpage != page) + { + if (!_nc_Internal_Validation(form)) + err = E_INVALID_FIELD; + else + { + Call_Hook(form,fieldterm); + Call_Hook(form,formterm); + err = _nc_Set_Form_Page(form,page,(FIELD *)0); + Call_Hook(form,forminit); + Call_Hook(form,fieldinit); + _nc_Refresh_Current_Field(form); + } + } + } + } + RETURN(err); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int form_page(const FORM * form) +| +| Description : Return the current page of the form. +| +| Return Values : >= 0 : current page number +| -1 : invalid form pointer ++--------------------------------------------------------------------------*/ +int form_page(const FORM * form) +{ + return Normalize_Form(form)->curpage; +} + +/* frm_page.c ends here */ diff --git a/lib/libform/frm_post.c b/lib/libform/frm_post.c new file mode 100644 index 00000000000..8a51bcc2194 --- /dev/null +++ b/lib/libform/frm_post.c @@ -0,0 +1,109 @@ +/* $OpenBSD: frm_post.c,v 1.1 1997/12/03 05:40:14 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_post.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int post_form(FORM * form) +| +| Description : Writes the form into its associated subwindow. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid form pointer +| E_POSTED - form already posted +| E_NOT_CONNECTED - no fields connected to form +| E_NO_ROOM - form doesn't fit into subwindow +| E_SYSTEM_ERROR - system error ++--------------------------------------------------------------------------*/ +int post_form(FORM * form) +{ + WINDOW *formwin; + int err; + int page; + + if (!form) + RETURN(E_BAD_ARGUMENT); + + if (form->status & _POSTED) + RETURN(E_POSTED); + + if (!(form->field)) + RETURN(E_NOT_CONNECTED); + + formwin = Get_Form_Window(form); + if ((form->cols > getmaxx(formwin)) || (form->rows > getmaxy(formwin))) + RETURN(E_NO_ROOM); + + /* reset form->curpage to an invald value. This forces Set_Form_Page + to do the page initialization which is required by post_form. + */ + page = form->curpage; + form->curpage = -1; + if ((err = _nc_Set_Form_Page(form,page,form->current))!=E_OK) + RETURN(err); + + form->status |= _POSTED; + + Call_Hook(form,forminit); + Call_Hook(form,fieldinit); + + _nc_Refresh_Current_Field(form); + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int unpost_form(FORM * form) +| +| Description : Erase form from its associated subwindow. +| +| Return Values : E_OK - success +| E_BAD_ARGUMENT - invalid form pointer +| E_NOT_POSTED - form isn't posted +| E_BAD_STATE - called from a hook routine ++--------------------------------------------------------------------------*/ +int unpost_form(FORM * form) +{ + if (!form) + RETURN(E_BAD_ARGUMENT); + + if (!(form->status & _POSTED)) + RETURN(E_NOT_POSTED); + + if (form->status & _IN_DRIVER) + RETURN(E_BAD_STATE); + + Call_Hook(form,fieldterm); + Call_Hook(form,formterm); + + werase(Get_Form_Window(form)); + delwin(form->w); + form->w = (WINDOW *)0; + form->status &= ~_POSTED; + RETURN(E_OK); +} + +/* frm_post.c ends here */ diff --git a/lib/libform/frm_req_name.c b/lib/libform/frm_req_name.c index d5beaa0c375..2542d3db9c3 100644 --- a/lib/libform/frm_req_name.c +++ b/lib/libform/frm_req_name.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_req_name.c,v 1.2 1997/12/03 05:40:14 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -27,7 +29,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_req_name.c,v 1.1 1997/11/26 04:01:19 millert Exp $") +MODULE_ID("Id: frm_req_name.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") static const char *request_names[ MAX_FORM_COMMAND - MIN_FORM_COMMAND + 1 ] = { "NEXT_PAGE" , diff --git a/lib/libform/frm_scale.c b/lib/libform/frm_scale.c new file mode 100644 index 00000000000..6a62f596ce3 --- /dev/null +++ b/lib/libform/frm_scale.c @@ -0,0 +1,55 @@ +/* $OpenBSD: frm_scale.c,v 1.1 1997/12/03 05:40:15 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_scale.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int scale_form( const FORM *form, int *rows, int *cols ) +| +| Description : Retrieve size of form +| +| Return Values : E_OK - no error +| E_BAD_ARGUMENT - invalid form pointer +| E_NOT_CONNECTED - no fields connected to form ++--------------------------------------------------------------------------*/ +int scale_form(const FORM * form, int * rows, int * cols) +{ + if ( !form ) + RETURN(E_BAD_ARGUMENT); + + if ( !(form->field) ) + RETURN(E_NOT_CONNECTED); + + if (rows) + *rows = form->rows; + if (cols) + *cols = form->cols; + + RETURN(E_OK); +} + +/* frm_scale.c ends here */ diff --git a/lib/libform/frm_sub.c b/lib/libform/frm_sub.c new file mode 100644 index 00000000000..4ad410857f9 --- /dev/null +++ b/lib/libform/frm_sub.c @@ -0,0 +1,61 @@ +/* $OpenBSD: frm_sub.c,v 1.1 1997/12/03 05:40:15 millert Exp $ */ + +/*-----------------------------------------------------------------------------+ +| 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_sub.c,v 1.1 1997/10/21 13:24:19 juergen Exp $") + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : int set_form_sub(FORM *form, WINDOW *win) +| +| Description : Set the subwindow of the form to win. +| +| Return Values : E_OK - success +| E_POSTED - form is posted ++--------------------------------------------------------------------------*/ +int set_form_sub(FORM * form, WINDOW * win) +{ + if (form && (form->status & _POSTED)) + RETURN(E_POSTED); + + Normalize_Form( form )->sub = win; + RETURN(E_OK); +} + +/*--------------------------------------------------------------------------- +| Facility : libnform +| Function : WINDOW *form_sub(const FORM *) +| +| Description : Retrieve the window of the form. +| +| Return Values : The pointer to the Subwindow. ++--------------------------------------------------------------------------*/ +WINDOW *form_sub(const FORM * form) +{ + const FORM* f = Normalize_Form( form ); + return Get_Form_Window(f); +} + +/* frm_sub.c ends here */ diff --git a/lib/libform/frm_user.c b/lib/libform/frm_user.c index 17d12869d2e..8db26a090fe 100644 --- a/lib/libform/frm_user.c +++ b/lib/libform/frm_user.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_user.c,v 1.3 1997/12/03 05:40:16 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,7 +24,7 @@ #include "form.priv.h" -MODULE_ID("Id: frm_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: frm_user.c,v 1.5 1997/05/23 23:31:29 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnform @@ -33,7 +35,7 @@ MODULE_ID("Id: frm_user.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") | | Return Values : E_OK - on success +--------------------------------------------------------------------------*/ -int set_form_userptr(FORM * form, const void *usrptr) +int set_form_userptr(FORM * form, void *usrptr) { Normalize_Form(form)->usrptr = usrptr; RETURN(E_OK); @@ -49,7 +51,7 @@ int set_form_userptr(FORM * form, const void *usrptr) | Return Values : Value of pointer. If no such pointer has been set, | NULL is returned +--------------------------------------------------------------------------*/ -const void *form_userptr(const FORM * form) +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 05162829bc8..286fdee0f6b 100644 --- a/lib/libform/frm_win.c +++ b/lib/libform/frm_win.c @@ -1,3 +1,5 @@ +/* $OpenBSD: frm_win.c,v 1.3 1997/12/03 05:40:16 millert Exp $ */ + /*-----------------------------------------------------------------------------+ | The ncurses form library is Copyright (C) 1995-1997 | | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | @@ -22,7 +24,7 @@ #include "form.priv.h" -MODULE_ID("Id: frm_win.c,v 1.4 1997/05/01 16:47:54 juergen Exp $") +MODULE_ID("Id: frm_win.c,v 1.5 1997/10/21 13:24:19 juergen Exp $") /*--------------------------------------------------------------------------- | Facility : libnform @@ -56,36 +58,5 @@ WINDOW *form_win(const FORM * form) return (f->win ? f->win : stdscr); } -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : int set_form_sub(FORM *form, WINDOW *win) -| -| Description : Set the subwindow of the form to win. -| -| Return Values : E_OK - success -| E_POSTED - form is posted -+--------------------------------------------------------------------------*/ -int set_form_sub(FORM * form, WINDOW * win) -{ - if (form && (form->status & _POSTED)) - RETURN(E_POSTED); - - Normalize_Form( form )->sub = win; - RETURN(E_OK); -} - -/*--------------------------------------------------------------------------- -| Facility : libnform -| Function : WINDOW *form_sub(const FORM *) -| -| Description : Retrieve the window of the form. -| -| Return Values : The pointer to the Subwindow. -+--------------------------------------------------------------------------*/ -WINDOW *form_sub(const FORM * form) -{ - const FORM* f = Normalize_Form( form ); - return Get_Form_Window(f); -} - /* frm_win.c ends here */ + diff --git a/lib/libform/fty_alnum.c b/lib/libform/fty_alnum.c index 1b05396d740..3b6da9f93ac 100644 --- a/lib/libform/fty_alnum.c +++ b/lib/libform/fty_alnum.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_alnum.c,v 1.3 1997/12/03 05:40:17 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("Id: fty_alnum.c,v 1.6 1997/02/15 17:31:21 tom Exp $") +MODULE_ID("Id: fty_alnum.c,v 1.7 1997/10/18 19:33:55 tom Exp $") typedef struct { int width; @@ -48,12 +50,12 @@ static void *Make_AlphaNumeric_Type(va_list * ap) static void *Copy_AlphaNumeric_Type(const void *argp) { const alnumARG *ap = (const alnumARG *)argp; - alnumARG *new = (alnumARG *)malloc(sizeof(alnumARG)); + alnumARG *result = (alnumARG *)malloc(sizeof(alnumARG)); - if (new) - *new = *ap; + if (result) + *result = *ap; - return ((void *)new); + return ((void *)result); } /*--------------------------------------------------------------------------- diff --git a/lib/libform/fty_alpha.c b/lib/libform/fty_alpha.c index f36a03c8988..c20f02b52c1 100644 --- a/lib/libform/fty_alpha.c +++ b/lib/libform/fty_alpha.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_alpha.c,v 1.3 1997/12/03 05:40:17 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("Id: fty_alpha.c,v 1.6 1997/02/15 17:31:08 tom Exp $") +MODULE_ID("Id: fty_alpha.c,v 1.7 1997/10/18 19:33:38 tom Exp $") typedef struct { int width; @@ -48,13 +50,13 @@ static void *Make_Alpha_Type(va_list * ap) static void *Copy_Alpha_Type(const void * argp) { const alphaARG *ap = (const alphaARG *)argp; - alphaARG *new = (alphaARG *)malloc(sizeof(alphaARG)); + alphaARG *result = (alphaARG *)malloc(sizeof(alphaARG)); - if (new) + if (result) { - *new = *ap; + *result = *ap; } - return ((void *)new); + return ((void *)result); } /*--------------------------------------------------------------------------- diff --git a/lib/libform/fty_enum.c b/lib/libform/fty_enum.c index 7d54e7779b2..dc623114fb1 100644 --- a/lib/libform/fty_enum.c +++ b/lib/libform/fty_enum.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_enum.c,v 1.3 1997/12/03 05:40:17 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("Id: fty_enum.c,v 1.5 1997/02/15 17:33:59 tom Exp $") +MODULE_ID("Id: fty_enum.c,v 1.8 1997/10/18 19:33:20 tom Exp $") typedef struct { char **kwds; @@ -63,15 +65,15 @@ static void *Make_Enum_Type(va_list * ap) static void *Copy_Enum_Type(const void * argp) { const enumARG *ap = (const enumARG *)argp; - enumARG *new = (enumARG *)0; + enumARG *result = (enumARG *)0; if (argp) { - new = (enumARG *)malloc(sizeof(enumARG)); - if (new) - *new = *ap; + result = (enumARG *)malloc(sizeof(enumARG)); + if (result) + *result = *ap; } - return (void *)new; + return (void *)result; } /*--------------------------------------------------------------------------- @@ -127,9 +129,8 @@ static int Compare(const unsigned char *s, const unsigned char *buf, } else { - while(toupper(*s)==toupper(*buf)) + while(toupper(*s++)==toupper(*buf)) { - s++; if (*buf++=='\0') return EXACT; } } @@ -170,7 +171,7 @@ static bool Check_Enum_Field(FIELD * field, const void * argp) { if ((res=Compare((unsigned char *)s,bp,ccase))!=NOMATCH) { - t=s; + p=t=s; /* t is at least a partial match */ if ((unique && res!=EXACT)) { while( (p = *kwds++) ) @@ -181,16 +182,19 @@ static bool Check_Enum_Field(FIELD * field, const void * argp) { t = p; break; - } - t = (char *)0; + } + else + t = (char *)0; } } - } + } if (t) { set_field_buffer(field,0,t); return TRUE; } + if (!p) + break; } } return FALSE; diff --git a/lib/libform/fty_int.c b/lib/libform/fty_int.c index e4238d8bc38..9ce3ea8306d 100644 --- a/lib/libform/fty_int.c +++ b/lib/libform/fty_int.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_int.c,v 1.3 1997/12/03 05:40:18 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("Id: fty_int.c,v 1.7 1997/04/19 15:22:40 juergen Exp $") +MODULE_ID("Id: fty_int.c,v 1.8 1997/10/18 19:32:50 tom Exp $") typedef struct { int precision; @@ -53,15 +55,15 @@ static void *Make_Integer_Type(va_list * ap) static void *Copy_Integer_Type(const void * argp) { const integerARG *ap = (const integerARG *)argp; - integerARG *new = (integerARG *)0; + integerARG *result = (integerARG *)0; if (argp) { - new = (integerARG *)malloc(sizeof(integerARG)); - if (new) - *new = *ap; + result = (integerARG *)malloc(sizeof(integerARG)); + if (result) + *result = *ap; } - return (void *)new; + return (void *)result; } /*--------------------------------------------------------------------------- diff --git a/lib/libform/fty_ipv4.c b/lib/libform/fty_ipv4.c index f3b18db0472..95b73267fdf 100644 --- a/lib/libform/fty_ipv4.c +++ b/lib/libform/fty_ipv4.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_ipv4.c,v 1.2 1997/12/03 05:40:18 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("$Id: fty_ipv4.c,v 1.1 1997/11/26 04:01:25 millert Exp $") +MODULE_ID("Id: fty_ipv4.c,v 1.2 1997/04/26 22:06:00 tom Exp $") /*--------------------------------------------------------------------------- | Facility : libnform diff --git a/lib/libform/fty_num.c b/lib/libform/fty_num.c index af72a68c662..20fabaff283 100644 --- a/lib/libform/fty_num.c +++ b/lib/libform/fty_num.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_num.c,v 1.3 1997/12/03 05:40:19 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,7 +15,7 @@ #include "form.priv.h" -MODULE_ID("Id: fty_num.c,v 1.9 1997/04/19 17:26:38 juergen Exp $") +MODULE_ID("Id: fty_num.c,v 1.11 1997/10/18 19:32:58 tom Exp $") #if HAVE_LOCALE_H #include <locale.h> @@ -63,15 +65,15 @@ static void *Make_Numeric_Type(va_list * ap) static void *Copy_Numeric_Type(const void * argp) { const numericARG *ap = (const numericARG *)argp; - numericARG *new = (numericARG *)0; + numericARG *result = (numericARG *)0; if (argp) { - new = (numericARG *)malloc(sizeof(numericARG)); - if (new) - *new = *ap; + result = (numericARG *)malloc(sizeof(numericARG)); + if (result) + *result = *ap; } - return (void *)new; + return (void *)result; } /*--------------------------------------------------------------------------- @@ -169,7 +171,7 @@ static bool Check_Numeric_Character(int c, const void * argp) c == '+' || c == '-' || c == ( -#ifdef HAVE_LOCALE_H +#if HAVE_LOCALE_H (L && L->decimal_point) ? *(L->decimal_point) : #endif '.') diff --git a/lib/libform/fty_regex.c b/lib/libform/fty_regex.c index 6ba9f7c2180..b7216c10002 100644 --- a/lib/libform/fty_regex.c +++ b/lib/libform/fty_regex.c @@ -1,3 +1,5 @@ +/* $OpenBSD: fty_regex.c,v 1.3 1997/12/03 05:40:19 millert Exp $ */ + /* * THIS CODE IS SPECIFICALLY EXEMPTED FROM THE NCURSES PACKAGE COPYRIGHT. @@ -13,9 +15,9 @@ #include "form.priv.h" -MODULE_ID("Id: fty_regex.c,v 1.9 1997/05/01 16:03:17 tom Exp $") +MODULE_ID("Id: fty_regex.c,v 1.11 1997/10/18 19:32:35 tom Exp $") -#if HAVE_REGEX_H /* We prefer POSIX regex */ +#if HAVE_REGEX_H_FUNCS /* We prefer POSIX regex */ #include <regex.h> typedef struct @@ -24,7 +26,7 @@ typedef struct unsigned long *refCount; } RegExp_Arg; -#elif HAVE_REGEXP_H | HAVE_REGEXPR_H +#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS #undef RETURN static int reg_errno; @@ -47,7 +49,7 @@ static char *RegEx_Error(int code) #define RETURN(c) return(c) #define ERROR(c) return RegEx_Error(c) -#if HAVE_REGEXP_H +#if HAVE_REGEXP_H_FUNCS #include <regexp.h> #else #include <regexpr.h> @@ -75,7 +77,7 @@ typedef struct +--------------------------------------------------------------------------*/ static void *Make_RegularExpression_Type(va_list * ap) { -#if HAVE_REGEX_H +#if HAVE_REGEX_H_FUNCS char *rx = va_arg(*ap,char *); RegExp_Arg *preg; @@ -98,7 +100,7 @@ static void *Make_RegularExpression_Type(va_list * ap) } } return((void *)preg); -#elif HAVE_REGEXP_H | HAVE_REGEXPR_H +#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS char *rx = va_arg(*ap,char *); RegExp_Arg *pArg; @@ -115,7 +117,7 @@ static void *Make_RegularExpression_Type(va_list * ap) char *buf = (char *)malloc(blen); if (buf) { -#if HAVE_REGEXP_H +#if HAVE_REGEXP_H_FUNCS char *last_pos = compile (rx, buf, &buf[blen], '\0'); #else char *last_pos = compile (rx, buf, &buf[blen], '\0'); @@ -162,16 +164,16 @@ static void *Make_RegularExpression_Type(va_list * ap) +--------------------------------------------------------------------------*/ static void *Copy_RegularExpression_Type(const void * argp) { -#if (HAVE_REGEX_H | HAVE_REGEXP_H | HAVE_REGEXPR_H) +#if (HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS) const RegExp_Arg *ap = (const RegExp_Arg *)argp; - const RegExp_Arg *new = (const RegExp_Arg *)0; + const RegExp_Arg *result = (const RegExp_Arg *)0; if (ap) { *(ap->refCount) += 1; - new = ap; + result = ap; } - return (void *)new; + return (void *)result; #else return 0; #endif @@ -187,19 +189,19 @@ static void *Copy_RegularExpression_Type(const void * argp) +--------------------------------------------------------------------------*/ static void Free_RegularExpression_Type(void * argp) { -#if HAVE_REGEX_H | HAVE_REGEXP_H | HAVE_REGEXPR_H +#if HAVE_REGEX_H_FUNCS | HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS RegExp_Arg *ap = (RegExp_Arg *)argp; if (ap) { if (--(*(ap->refCount)) == 0) { -#if HAVE_REGEX_H +#if HAVE_REGEX_H_FUNCS if (ap->pRegExp) { free(ap->refCount); regfree(ap->pRegExp); } -#elif HAVE_REGEXP_H | HAVE_REGEXPR_H +#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS if (ap->compiled_expression) { free(ap->refCount); @@ -226,11 +228,11 @@ static void Free_RegularExpression_Type(void * argp) static bool Check_RegularExpression_Field(FIELD * field, const void * argp) { bool match = FALSE; -#if HAVE_REGEX_H +#if HAVE_REGEX_H_FUNCS const RegExp_Arg *ap = (const RegExp_Arg*)argp; if (ap && ap->pRegExp) match = (regexec(ap->pRegExp,field_buffer(field,0),0,NULL,0) ? FALSE:TRUE); -#elif HAVE_REGEXP_H | HAVE_REGEXPR_H +#elif HAVE_REGEXP_H_FUNCS | HAVE_REGEXPR_H_FUNCS RegExp_Arg *ap = (RegExp_Arg *)argp; if (ap && ap->compiled_expression) match = (step(field_buffer(field,0),ap->compiled_expression) ? TRUE:FALSE); diff --git a/lib/libform/shlib_version b/lib/libform/shlib_version index 1edea46de91..893819d18ff 100644 --- a/lib/libform/shlib_version +++ b/lib/libform/shlib_version @@ -1,2 +1,2 @@ major=1 -minor=0 +minor=1 |