]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/form_fieldtype.3x.html
ncurses 5.6 - patch 20070303
[ncurses.git] / doc / html / man / form_fieldtype.3x.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
2 <!-- 
3   * t
4   ****************************************************************************
5   * Copyright (c) 1998-2003,2006 Free Software Foundation, Inc.              *
6   *                                                                          *
7   * Permission is hereby granted, free of charge, to any person obtaining a  *
8   * copy of this software and associated documentation files (the            *
9   * "Software"), to deal in the Software without restriction, including      *
10   * without limitation the rights to use, copy, modify, merge, publish,      *
11   * distribute, distribute with modifications, sublicense, and/or sell       *
12   * copies of the Software, and to permit persons to whom the Software is    *
13   * furnished to do so, subject to the following conditions:                 *
14   *                                                                          *
15   * The above copyright notice and this permission notice shall be included  *
16   * in all copies or substantial portions of the Software.                   *
17   *                                                                          *
18   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
19   * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
20   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
21   * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
22   * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
23   * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
24   * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
25   *                                                                          *
26   * Except as contained in this notice, the name(s) of the above copyright   *
27   * holders shall not be used in advertising or otherwise to promote the     *
28   * sale, use or other dealings in this Software without prior written       *
29   * authorization.                                                           *
30   ****************************************************************************
31   * @Id: form_fieldtype.3x,v 1.14 2006/11/04 17:12:00 tom Exp @
32 -->
33 <HTML>
34 <HEAD>
35 <TITLE>form_fieldtype 3x</TITLE>
36 <link rev=made href="mailto:bug-ncurses@gnu.org">
37 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
38 </HEAD>
39 <BODY>
40 <H1>form_fieldtype 3x</H1>
41 <HR>
42 <PRE>
43 <!-- Manpage converted by man2html 3.0.1 -->
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>
45
46
47
48
49 </PRE>
50 <H2>NAME</H2><PRE>
51        <STRONG>form_fieldtype</STRONG> - define validation-field types
52
53
54 </PRE>
55 <H2>SYNOPSIS</H2><PRE>
56        <STRONG>#include</STRONG> <STRONG>&lt;form.h&gt;</STRONG>
57        FIELDTYPE *new_fieldtype(
58            bool (* const field_check)(FIELD *, const void *),
59            bool (* const char_check)(int, const void *));
60        int free_fieldtype(FIELDTYPE *fieldtype);
61        int set_fieldtype_arg(
62            FIELDTYPE *fieldtype,
63            void *(* const make_arg)(va_list *),
64            void *(* const copy_arg)(const void *),
65            void  (* const free_arg)(void *));
66        int set_fieldtype_choice(
67            FIELDTYPE *fieldtype,
68            bool (* const next_choice)(FIELD *, const void *),
69            bool (* const prev_choice)(FIELD *, const void *));
70        FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
71                                  FIELDTYPE *type2);
72
73
74 </PRE>
75 <H2>DESCRIPTION</H2><PRE>
76        The function <STRONG>new_fieldtype</STRONG> creates a new field type usable
77        for data validation.  You supply it  with  <EM>field</EM><STRONG>_</STRONG><EM>check</EM>,  a
78        predicate  to check the validity of an entered data string
79        whenever the user attempts to leave a field.   The  (FIELD
80        *)  argument  is passed in so the validation predicate can
81        see the field's buffer, sizes and  other  attributes;  the
82        second  argument  is  an  argument-block  structure, about
83        which more below.
84
85        You also supply <STRONG>new_fieldtype</STRONG> with <EM>char</EM><STRONG>_</STRONG><EM>check</EM>, a  function
86        to  validate input characters as they are entered; it will
87        be passed the character to be checked and a pointer to  an
88        argument-block structure.
89
90        The  function <STRONG>free_fieldtype</STRONG> frees the space allocated for
91        a given validation type.
92
93        The function <STRONG>set_fieldtype_arg</STRONG> associates  three  storage-
94        management  functions  with  a  field  type.  The <EM>make</EM><STRONG>_</STRONG><EM>arg</EM>
95        function is automatically applied to the list of arguments
96        you  give  <STRONG>set_field_type</STRONG>  when  attaching validation to a
97        field; its job is to bundle these into an allocated  argu-
98        ment-block  object which can later be passed to validation
99        predicated.  The other two hook arguments should copy  and
100        free  argument-block structures.  They will be used by the
101        forms-driver code.  You must supply the <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function,
102        the  other two are optional, you may supply NULL for them.
103        In this case it is assumed that <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> does not allocate
104        memory  but simply loads the argument into a single scalar
105        value.
106
107        The function <STRONG>link_fieldtype</STRONG> creates a new field type  from
108        the  two  given  types.   They are connected by an logical
109        'OR'.
110
111        The   form    driver    requests    <STRONG>REQ_NEXT_CHOICE</STRONG>    and
112        <STRONG>REQ_PREV_CHOICE</STRONG> assume that the possible values of a field
113        form an ordered set, and provide the forms user with a way
114        to  move  through the set.  The <STRONG>set_fieldtype_choice</STRONG> func-
115        tion allows forms  programmers  to  define  successor  and
116        predecessor functions for the field type.  These functions
117        take the field pointer and an argument-block structure  as
118        arguments.
119
120
121 </PRE>
122 <H2>RETURN VALUE</H2><PRE>
123        The  pointer-valued  routines  return NULL on error.  They
124        set errno according to their success:
125
126        <STRONG>E_OK</STRONG> The routine succeeded.
127
128        <STRONG>E_BAD_ARGUMENT</STRONG>
129             Routine detected an incorrect or  out-of-range  argu-
130             ment.
131
132        <STRONG>E_SYSTEM_ERROR</STRONG>
133             System error occurred, e.g., malloc failure.
134
135        The  integer-valued  routines  return one of the following
136        codes on error:
137
138        <STRONG>E_OK</STRONG> The routine succeeded.
139
140        <STRONG>E_BAD_ARGUMENT</STRONG>
141             Routine detected an incorrect or  out-of-range  argu-
142             ment.
143
144        <STRONG>E_CONNECTED</STRONG>
145             The field is already connected to a form.
146
147        <STRONG>E_CURRENT</STRONG>
148             The field is the current field.
149
150        <STRONG>E_SYSTEM_ERROR</STRONG>
151             System error occurred (see <STRONG>errno</STRONG>).
152
153
154 </PRE>
155 <H2>SEE ALSO</H2><PRE>
156        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>.
157
158
159 </PRE>
160 <H2>NOTES</H2><PRE>
161        The header file <STRONG>&lt;form.h&gt;</STRONG> automatically includes the header
162        file <STRONG>&lt;curses.h&gt;</STRONG>.
163
164        All of the <STRONG>(char</STRONG> <STRONG>*)</STRONG> arguments of  these  functions  should
165        actually  be <STRONG>(void</STRONG> <STRONG>*)</STRONG>.  The type has been left uncorrected
166        for strict compatibility with System V.
167
168
169 </PRE>
170 <H2>PORTABILITY</H2><PRE>
171        These routines emulate the System V forms  library.   They
172        were not supported on Version 7 or BSD versions.
173
174
175 </PRE>
176 <H2>AUTHORS</H2><PRE>
177        Juergen  Pfeifer.   Manual  pages  and  adaptation for new
178        curses by Eric S. Raymond.
179
180
181
182                                                      <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
183 </PRE>
184 <HR>
185 <ADDRESS>
186 Man(1) output converted with
187 <a href="http://www.oac.uci.edu/indiv/ehood/man2html.html">man2html</a>
188 </ADDRESS>
189 </BODY>
190 </HTML>