NAME
ffoorrmmffiieellddttyyppee - define validation-field types
SYNOPSIS
##iinncclluuddee <
FIELDTYPE *newfieldtype( bool (* const fieldcheck)(FIELD *, const void *), bool (* const charcheck)(int, const void *)); int freefieldtype(FIELDTYPE *fieldtype); int setfieldtypearg( FIELDTYPE *fieldtype, void *(* const makearg)(valist *), void *(* const copyarg)(const void *), void (* const freearg)(void *)); int setfieldtypechoice( FIELDTYPE *fieldtype, bool (* const nextchoice)(FIELD *, const void *), bool (* const prevchoice)(FIELD *, const void *)); FIELDTYPE *linkfieldtype(FIELDTYPE *type1, FIELDTYPE *type2);> DESCRIPTION
The function nneewwffiieellddttyyppee creates a new field type usable for data validation. You supply it with fieldcheck, a predicate to check the validity of an entered data string whenever the user attempts to leavea field. The (FIELD *) argument is passed in so the validation predi-
cate can see the field's buffer, sizes and other attributes; the secondargument is an argument-block structure, about which more below.
You also supply nneewwffiieellddttyyppee with charcheck, a function to validate input characters as they are entered; it will be passed the characterto be checked and a pointer to an argument-block structure.
The function ffrreeeeffiieellddttyyppee frees the space allocated for a given vali-
dation type.The function sseettffiieellddttyyppeeaarrgg associates three storage-management
functions with a field type. The makearg function is automatically applied to the list of arguments you give sseettffiieellddttyyppee when attaching validation to a field; its job is to bundle these into an allocatedargument-block object which can later be passed to validation predi-
cated. The other two hook arguments should copy and free argument-
block structures. They will be used by the forms-driver code. You
must supply the makearg function, the other two are optional, you may supply NULL for them. In this case it is assumed that makearg does not allocate memory but simply loads the argument into a single scalar value. The function lliinnkkffiieellddttyyppee creates a new field type from the two given types. They are connected by an logical 'OR'. The form driver requests RREEQQNNEEXXTTCCHHOOIICCEE and RREEQQPPRREEVVCCHHOOIICCEE assume that the possible values of a field form an ordered set, and providethe forms user with a way to move through the set. The sseettffiieelldd-
ttyyppeecchhooiiccee function allows forms programmers to define successor and predecessor functions for the field type. These functions take thefield pointer and an argument-block structure as arguments.
RREETTUURRNN VVAALLUUEEThe pointer-valued routines return NULL on error.
The integer-valued routines return one of the following codes on error:
EEOOKK The routine succeeded. EESSYYSSTTEEMMEERRRROORR System error occurred (see eerrrrnnoo). EEBBAADDAARRGGUUMMEENNTTRoutine detected an incorrect or out-of-range argument.
EECCOONNNNEECCTTEEDD The field is already connected to a form.SEE ALSO
ccuurrsseess(3X), ffoorrmm(3X). NNOOTTEESS The header file <> automatically includes the header file < >. All of the ((cchhaarr **)) arguments of these functions should actually be ((vvooiidd **)). The type has been left uncorrected for strict compatibility with System V. PPOORRTTAABBIILLIITTYY These routines emulate the System V forms library. They were not sup-
ported on Version 7 or BSD versions. AUTHORS Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. formfieldtype(3X)