3 ****************************************************************************
4 * Copyright (c) 1998-2018,2019 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.19 2019/01/20 20:31:42 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</TITLE>
38 <link rel="author" href="mailto:bug-ncurses@gnu.org">
39 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
42 <H1 class="no-header">form_fieldtype 3x</H1>
44 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG> <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>
55 FIELDTYPE *new_fieldtype(
56 bool (* const field_check)(FIELD *, const void *),
57 bool (* const char_check)(int, const void *));
58 int free_fieldtype(FIELDTYPE *fieldtype);
59 int set_fieldtype_arg(
61 void *(* const make_arg)(va_list *),
62 void *(* const copy_arg)(const void *),
63 void (* const free_arg)(void *));
64 int set_fieldtype_choice(
66 bool (* const next_choice)(FIELD *, const void *),
67 bool (* const prev_choice)(FIELD *, const void *));
68 FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
72 </PRE><H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
73 The function <STRONG>new_fieldtype</STRONG> creates a new field type usable for data
74 validation. You supply it with <EM>field</EM><STRONG>_</STRONG><EM>check</EM>, a predicate to check the
75 validity of an entered data string whenever the user attempts to leave
76 a field. The (FIELD *) argument is passed in so the validation predi-
77 cate can see the field's buffer, sizes and other attributes; the second
78 argument is an argument-block structure, about which more below.
80 You also supply <STRONG>new_fieldtype</STRONG> with <EM>char</EM><STRONG>_</STRONG><EM>check</EM>, a function to validate
81 input characters as they are entered; it will be passed the character
82 to be checked and a pointer to an argument-block structure.
84 The function <STRONG>free_fieldtype</STRONG> frees the space allocated for a given vali-
87 The function <STRONG>set_fieldtype_arg</STRONG> associates three storage-management
88 functions with a field type. The <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function is automatically
89 applied to the list of arguments you give <STRONG>set_field_type</STRONG> when attaching
90 validation to a field; its job is to bundle these into an allocated
91 argument-block object which can later be passed to validation predi-
92 cated. The other two hook arguments should copy and free argument-
93 block structures. They will be used by the forms-driver code. You
94 must supply the <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function, the other two are optional, you may
95 supply NULL for them. In this case it is assumed that <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> does
96 not allocate memory but simply loads the argument into a single scalar
99 The function <STRONG>link_fieldtype</STRONG> creates a new field type from the two given
100 types. They are connected by an logical 'OR'.
102 The form driver requests <STRONG>REQ_NEXT_CHOICE</STRONG> and <STRONG>REQ_PREV_CHOICE</STRONG> assume
103 that the possible values of a field form an ordered set, and provide
104 the forms user with a way to move through the set. The <STRONG>set_field-</STRONG>
105 <STRONG>type_choice</STRONG> function allows forms programmers to define successor and
106 predecessor functions for the field type. These functions take the
107 field pointer and an argument-block structure as arguments.
110 </PRE><H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
111 The pointer-valued routines return NULL on error. They set errno
112 according to their success:
114 <STRONG>E_OK</STRONG> The routine succeeded.
116 <STRONG>E_BAD_ARGUMENT</STRONG>
117 Routine detected an incorrect or out-of-range argument.
119 <STRONG>E_SYSTEM_ERROR</STRONG>
120 System error occurred, e.g., malloc failure.
122 The integer-valued routines return one of the following codes on error:
124 <STRONG>E_OK</STRONG> The routine succeeded.
126 <STRONG>E_BAD_ARGUMENT</STRONG>
127 Routine detected an incorrect or out-of-range argument.
129 <STRONG>E_CONNECTED</STRONG>
130 The field is already connected to a form.
132 <STRONG>E_CURRENT</STRONG>
133 The field is the current field.
135 <STRONG>E_SYSTEM_ERROR</STRONG>
136 System error occurred (see <STRONG>errno(3)</STRONG>).
139 </PRE><H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
140 <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>.
143 </PRE><H2><a name="h2-NOTES">NOTES</a></H2><PRE>
144 The header file <STRONG><form.h></STRONG> automatically includes the header file
145 <STRONG><curses.h></STRONG>.
147 All of the <STRONG>(char</STRONG> <STRONG>*)</STRONG> arguments of these functions should actually be
148 <STRONG>(void</STRONG> <STRONG>*)</STRONG>. The type has been left uncorrected for strict compatibility
152 </PRE><H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
153 These routines emulate the System V forms library. They were not sup-
154 ported on Version 7 or BSD versions.
157 </PRE><H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
158 Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S.
163 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
167 <li><a href="#h2-NAME">NAME</a></li>
168 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
169 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
170 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
171 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
172 <li><a href="#h2-NOTES">NOTES</a></li>
173 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
174 <li><a href="#h2-AUTHORS">AUTHORS</a></li>