2 ****************************************************************************
3 * Copyright 2018-2023,2024 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 ****************************************************************************
30 * @Id: form_fieldtype.3x,v 1.46 2024/03/16 15:35:01 tom Exp @
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see https://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>form_fieldtype 3x 2024-03-16 ncurses 6.5 Library calls</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
42 <H1 class="no-header">form_fieldtype 3x 2024-03-16 ncurses 6.5 Library calls</H1>
44 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG> Library calls <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
49 </PRE><H2><a name="h2-NAME">NAME</a></H2><PRE>
50 <STRONG>form_fieldtype</STRONG> - define validation-field types
53 </PRE><H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
54 <STRONG>#include</STRONG> <STRONG><form.h></STRONG>
56 <STRONG>FIELDTYPE</STRONG> <STRONG>*new_fieldtype(</STRONG>
57 <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>field</EM><STRONG>_</STRONG><EM>check</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
58 <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>char</EM><STRONG>_</STRONG><EM>check</EM><STRONG>)(int,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*));</STRONG>
59 <STRONG>int</STRONG> <STRONG>free_fieldtype(FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>);</STRONG>
61 <STRONG>int</STRONG> <STRONG>set_fieldtype_arg(</STRONG>
62 <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>,</STRONG>
63 <STRONG>void</STRONG> <STRONG>*(*</STRONG> <STRONG>const</STRONG> <EM>make</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(va_list</STRONG> <STRONG>*),</STRONG>
64 <STRONG>void</STRONG> <STRONG>*(*</STRONG> <STRONG>const</STRONG> <EM>copy</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
65 <STRONG>void</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>free</EM><STRONG>_</STRONG><EM>arg</EM><STRONG>)(void</STRONG> <STRONG>*));</STRONG>
66 <STRONG>int</STRONG> <STRONG>set_fieldtype_choice(</STRONG>
67 <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>fieldtype</EM><STRONG>,</STRONG>
68 <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>next</EM><STRONG>_</STRONG><EM>choice</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*),</STRONG>
69 <STRONG>bool</STRONG> <STRONG>(*</STRONG> <STRONG>const</STRONG> <EM>prev</EM><STRONG>_</STRONG><EM>choice</EM><STRONG>)(FIELD</STRONG> <STRONG>*,</STRONG> <STRONG>const</STRONG> <STRONG>void</STRONG> <STRONG>*));</STRONG>
71 <STRONG>FIELDTYPE</STRONG> <STRONG>*link_fieldtype(FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>type1</EM><STRONG>,</STRONG>
72 <STRONG>FIELDTYPE</STRONG> <STRONG>*</STRONG><EM>type2</EM><STRONG>);</STRONG>
75 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
77 </PRE><H3><a name="h3-new_fieldtype">new_fieldtype</a></H3><PRE>
78 The function <STRONG>new_fieldtype</STRONG> creates a new field type usable for data
79 validation. Its parameters are function pointers:
81 <EM>field</EM><STRONG>_</STRONG><EM>check</EM>
82 This function checks the validity of an entered data string
83 whenever the user attempts to leave a field. It has two
86 <STRONG>o</STRONG> The (FIELD *) argument is passed in so the validation
87 predicate can see the field's buffer, sizes and other
90 <STRONG>o</STRONG> The second argument is an argument-block structure, about
93 <EM>char</EM><STRONG>_</STRONG><EM>check</EM>
94 This function validates input characters as they are entered. The
95 form library passes it the character to be checked and a pointer
96 to an argument-block structure.
99 </PRE><H3><a name="h3-free_fieldtype">free_fieldtype</a></H3><PRE>
100 The <STRONG>free_fieldtype</STRONG> function frees the space allocated for a given
101 validation type by <STRONG>new_fieldtype</STRONG>.
104 </PRE><H3><a name="h3-set_fieldtype_arg">set_fieldtype_arg</a></H3><PRE>
105 The function <STRONG>set_fieldtype_arg</STRONG> associates three storage-management
106 functions with a field type:
108 <EM>make</EM><STRONG>_</STRONG><EM>arg</EM>
109 This function is automatically applied to the list of arguments
110 you give <STRONG>set_field_type</STRONG> when attaching validation to a field. It
111 stores the arguments in an allocated argument-block object which
112 is used when validating input.
114 <EM>copy</EM><STRONG>_</STRONG><EM>arg</EM>
115 This function may be used by applications to copy argument-blocks.
117 <EM>free</EM><STRONG>_</STRONG><EM>arg</EM>
118 Frees an argument-block structure.
120 You must supply the <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function. The other two are optional: you
121 may supply NULL for them. In this case, the form library assumes that
122 <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> does not allocate memory but simply loads the argument into a
126 </PRE><H3><a name="h3-set_fieldtype_choice">set_fieldtype_choice</a></H3><PRE>
127 The form driver requests <STRONG>REQ_NEXT_CHOICE</STRONG> and <STRONG>REQ_PREV_CHOICE</STRONG> assume
128 that the possible values of a field form an ordered set, and provide
129 the forms user with a way to move through the set.
131 The <STRONG>set_fieldtype_choice</STRONG> function allows forms programmers to define
132 successor and predecessor functions for the field type. These
133 functions take the field pointer and an argument-block structure as
137 </PRE><H3><a name="h3-link_fieldtype">link_fieldtype</a></H3><PRE>
138 The function <STRONG>link_fieldtype</STRONG> creates a new field type from the two given
139 types. They are connected by an logical 'OR'.
142 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
143 The pointer-valued routines return NULL on error. They set <STRONG>errno</STRONG>
144 according to their success:
146 <STRONG>E_OK</STRONG> The routine succeeded.
148 <STRONG>E_BAD_ARGUMENT</STRONG>
149 Routine detected an incorrect or out-of-range argument.
151 <STRONG>E_SYSTEM_ERROR</STRONG>
152 System error occurred, e.g., malloc failure.
154 The integer-valued routines return one of the following codes on error:
156 <STRONG>E_OK</STRONG> The routine succeeded.
158 <STRONG>E_BAD_ARGUMENT</STRONG>
159 Routine detected an incorrect or out-of-range argument.
161 <STRONG>E_CONNECTED</STRONG>
162 The field is already connected to a form.
164 <STRONG>E_CURRENT</STRONG>
165 The field is the current field.
167 <STRONG>E_SYSTEM_ERROR</STRONG>
168 System error occurred (see <STRONG>errno(3)</STRONG>).
171 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
172 These routines emulate the System V forms library. They were not
173 supported on Version 7 or BSD versions.
176 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
177 Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S.
181 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
182 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>, <STRONG><A HREF="form_field_validation.3x.html">form_field_validation(3x)</A></STRONG>
186 ncurses 6.5 2024-03-16 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
190 <li><a href="#h2-NAME">NAME</a></li>
191 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
192 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a>
194 <li><a href="#h3-new_fieldtype">new_fieldtype</a></li>
195 <li><a href="#h3-free_fieldtype">free_fieldtype</a></li>
196 <li><a href="#h3-set_fieldtype_arg">set_fieldtype_arg</a></li>
197 <li><a href="#h3-set_fieldtype_choice">set_fieldtype_choice</a></li>
198 <li><a href="#h3-link_fieldtype">link_fieldtype</a></li>
201 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
202 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
203 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
204 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>