2 <BODY BGCOLOR="#99ccbb" TEXT="#000000" LINK="#4060b0" VLINK="#000080" ALINK="#ff4040">
4 <STRONG>form_fieldtype</STRONG> - define validation-field types
9 <STRONG>#include</STRONG> <STRONG><form.h></STRONG>
10 FIELDTYPE *new_fieldtype(
11 bool (* const field_check)(FIELD *, const void *),
12 bool (* const char_check)(int, const void *));
13 int free_fieldtype(FIELDTYPE *fieldtype);
14 int set_fieldtype_arg(
16 void *(* const make_arg)(va_list *),
17 void *(* const copy_arg)(const void *),
18 void (* const free_arg)(void *));
19 int set_fieldtype_choice(
21 bool (* const next_choice)(FIELD *, const void *),
22 bool (* const prev_choice)(FIELD *, const void *));
23 FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
28 <H2>DESCRIPTION</H2><PRE>
29 The function <STRONG>new_fieldtype</STRONG> creates a new field type usable
30 for data validation. You supply it with <EM>field</EM><STRONG>_</STRONG><EM>check</EM>, a
31 predicate to check the validity of an entered data string
32 whenever the user attempt to leave a field. The (FIELD *)
33 argument is passed in so the validation predicate can see
34 the field's buffer, sizes and other attributes; the second
35 argument is an argument-block structure, about which more
38 You also supply <STRONG>new_fieldtype</STRONG> with <EM>char</EM><STRONG>_</STRONG><EM>check</EM>, a function
39 to validate input characters as they are entered; it will
40 be passed the character to be checked and a pointer to an
41 argument-block structure.
43 The function <STRONG>free_fieldtype</STRONG> frees the space allocated for
44 a given validation type.
46 The function <STRONG>set_fieldtype</STRONG> associates three storage-man-
47 agement functions with a field type. The <EM>mak</EM><STRONG>_</STRONG><EM>arg</EM> function
48 is automatically applied to the list of arguments you give
49 <STRONG>set_field_type</STRONG> when attaching validation to a field; its
50 job is to bundle these into an allocated argument-block
51 object which can later be passed to validation predicated.
52 The other two hook arguments should copy and free argu-
53 ment-block structures. They will be used by the forms-
54 driver code. You must supply the <EM>mak</EM><STRONG>_</STRONG><EM>arg</EM> function, the
55 other two are optional, you may supply NULL for them. In
56 this case it is assumed, that <EM>mak</EM><STRONG>_</STRONG><EM>arg</EM> doesn't allocate
57 memory but simply loads the argument into a single scalar
60 form an ordered set, and provide the forms user with a way
61 to move through the set. The <STRONG>set_fieldtype_choice</STRONG> func-
62 tion allows forms programmers to define successor and pre-
63 decessor functions for the field type. These functions
64 take the field pointer and an argument-block structure as
69 <H2>RETURN VALUE</H2><PRE>
70 The pointer-valued routines return NULL on error.
72 The integer-valued routines return one of the following
75 <STRONG>E_OK</STRONG> The routine succeeded.
77 <STRONG>E_SYSTEM_ERROR</STRONG>
78 System error occurred (see <STRONG>errno</STRONG>).
80 <STRONG>E_BAD_ARGUMENT</STRONG>
81 Routine detected an incorrect or out-of-range argu-
84 <STRONG>E_CONNECTED</STRONG>
85 The field is already connected to a form.
89 <H2>SEE ALSO</H2><PRE>
90 <STRONG><A HREF="ncurses.3x.html">curses(3X)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3X)</A></STRONG>.
95 The header file <STRONG><form.h></STRONG> automatically includes the header
96 file <STRONG><curses.h></STRONG>.
98 All of the <STRONG>(char</STRONG> <STRONG>*)</STRONG> arguments of these functions should
99 actually be <STRONG>(void</STRONG> <STRONG>*)</STRONG>. The type has been left uncorrected
100 for strict compatibility with System V.
104 <H2>PORTABILITY</H2><PRE>
105 These routines emulate the System V forms library. They
106 were not supported on Version 7 or BSD versions.
110 <H2>AUTHORS</H2><PRE>
111 Juergen Pfeifer. Manual pages and adaptation for new
112 curses by Eric S. Raymond.