2 .\"***************************************************************************
3 .\" Copyright 2018-2019,2020 Thomas E. Dickey *
4 .\" Copyright 1998-2006,2010 Free Software Foundation, Inc. *
6 .\" Permission is hereby granted, free of charge, to any person obtaining a *
7 .\" copy of this software and associated documentation files (the *
8 .\" "Software"), to deal in the Software without restriction, including *
9 .\" without limitation the rights to use, copy, modify, merge, publish, *
10 .\" distribute, distribute with modifications, sublicense, and/or sell *
11 .\" copies of the Software, and to permit persons to whom the Software is *
12 .\" furnished to do so, subject to the following conditions: *
14 .\" The above copyright notice and this permission notice shall be included *
15 .\" in all copies or substantial portions of the Software. *
17 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
18 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
19 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
20 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
21 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
22 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
23 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 .\" Except as contained in this notice, the name(s) of the above copyright *
26 .\" holders shall not be used in advertising or otherwise to promote the *
27 .\" sale, use or other dealings in this Software without prior written *
29 .\"***************************************************************************
31 .\" $Id: form_fieldtype.3x,v 1.28 2020/12/12 17:11:21 tom Exp $
36 .TH form_fieldtype 3X ""
38 \fBform_fieldtype\fR \- define validation-field types
40 \fB#include <form.h>\fR
42 \fBFIELDTYPE *new_fieldtype(\fP
43 \fBbool (* const \fP\fIfield_check\fP\fB)(FIELD *, const void *),\fP
44 \fBbool (* const \fP\fIchar_check\fP\fB)(int, const void *));\fP
46 \fBint free_fieldtype(FIELDTYPE *\fP\fIfieldtype\fP\fB);\fP
48 \fBint set_fieldtype_arg(\fP
49 \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
50 \fBvoid *(* const \fP\fImake_arg\fP\fB)(va_list *),\fP
51 \fBvoid *(* const \fP\fIcopy_arg\fP\fB)(const void *),\fP
52 \fBvoid (* const \fP\fIfree_arg\fP\fB)(void *));\fP
54 \fBint set_fieldtype_choice(\fP
55 \fBFIELDTYPE *\fP\fIfieldtype\fP\fB,\fP
56 \fBbool (* const \fP\fInext_choice\fP\fB)(FIELD *, const void *),\fP
57 \fBbool (* const \fP\fIprev_choice\fP\fB)(FIELD *, const void *));\fP
59 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fP\fItype1\fP\fB,\fP
60 \fBFIELDTYPE *\fP\fItype2\fP\fB);\fP
63 The function \fBnew_fieldtype\fR creates a new field type usable for data
65 Its parameters are function pointers:
68 This function checks the
69 validity of an entered data string whenever the user attempts to leave a field.
73 The (FIELD *) argument is passed in so the validation predicate can see the
74 field's buffer, sizes and other attributes.
76 The second argument is an
77 argument-block structure, about which more below.
81 This function validates input characters as they are entered.
82 The form library passes it the character to be checked
83 and a pointer to an argument-block structure.
86 The \fBfree_fieldtype\fR function
87 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
90 The function \fBset_fieldtype_arg\fR associates
91 three storage-management functions with a field type:
94 This function is automatically applied to the
95 list of arguments you give \fBset_field_type\fR when attaching validation
97 It stores the arguments in an allocated argument-block
98 object which is used when validating input.
101 This function may be used by applications to copy argument-blocks.
104 Frees an argument-block structure.
106 You must supply the \fImake_arg\fR function.
107 The other two are optional: you may supply NULL for them.
108 In this case, the form library assumes
109 that \fImake_arg\fR does not allocate memory but simply loads the
110 argument into a single scalar value.
111 .SS set_fieldtype_choice
113 The form driver requests \fBREQ_NEXT_CHOICE\fR and \fBREQ_PREV_CHOICE\fR assume
114 that the possible values of a field form an ordered set, and provide the forms
115 user with a way to move through the set.
117 The \fBset_fieldtype_choice\fR
118 function allows forms programmers to define successor and predecessor functions
120 These functions take the field pointer and an
121 argument-block structure as arguments.
124 The function \fBlink_fieldtype\fR creates
125 a new field type from the two given types.
126 They are connected by an logical 'OR'.
128 The pointer-valued routines return NULL on error.
129 They set \fBerrno\fP according to their success:
132 The routine succeeded.
135 Routine detected an incorrect or out-of-range argument.
138 System error occurred, e.g., malloc failure.
140 The integer-valued routines return one of the following codes on
144 The routine succeeded.
147 Routine detected an incorrect or out-of-range argument.
150 The field is already connected to a form.
153 The field is the current field.
156 System error occurred (see \fBerrno\fR(3)).
160 \fBform_field_validation\fR(3X).
162 The header file \fB<form.h>\fR automatically includes the header file
165 These routines emulate the System V forms library.
166 They were not supported on
167 Version 7 or BSD versions.
170 Manual pages and adaptation for new curses by Eric S. Raymond.