2 .\"***************************************************************************
3 .\" Copyright 2018-2021,2022 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.31 2022/02/12 20:03:40 tom Exp $
36 .TH form_fieldtype 3X ""
38 \fBform_fieldtype\fP \- define validation-field types
40 \fB#include <form.h>\fP
42 \fBFIELDTYPE *new_fieldtype(\fP
43 \fBbool (* const \fIfield_check\fB)(FIELD *, const void *),\fR
44 \fBbool (* const \fIchar_check\fB)(int, const void *));\fR
46 \fBint free_fieldtype(FIELDTYPE *\fIfieldtype\fB);\fR
48 \fBint set_fieldtype_arg(\fP
49 \fBFIELDTYPE *\fIfieldtype\fB,\fR
50 \fBvoid *(* const \fImake_arg\fB)(va_list *),\fR
51 \fBvoid *(* const \fIcopy_arg\fB)(const void *),\fR
52 \fBvoid (* const \fIfree_arg\fB)(void *));\fR
54 \fBint set_fieldtype_choice(\fP
55 \fBFIELDTYPE *\fIfieldtype\fB,\fR
56 \fBbool (* const \fInext_choice\fB)(FIELD *, const void *),\fR
57 \fBbool (* const \fIprev_choice\fB)(FIELD *, const void *));\fR
59 \fBFIELDTYPE *link_fieldtype(FIELDTYPE *\fItype1\fB,\fR
60 \fBFIELDTYPE *\fItype2\fB);\fR
63 The function \fBnew_fieldtype\fP 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\fP function
87 frees the space allocated for a given validation type by \fBnew_fieldtype\fP.
90 The function \fBset_fieldtype_arg\fP 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\fP 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\fP 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\fP 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\fP and \fBREQ_PREV_CHOICE\fP 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\fP
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\fP 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\fP(3)).
160 \fBform_field_validation\fP(3X).
162 The header file \fB<form.h>\fP 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.