]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/form_fieldtype.3x.html
de3200e711ace69d6c63f7d4b9cd57a3be270fd5
[ncurses.git] / doc / html / man / form_fieldtype.3x.html
1 <!-- 
2   * t
3   ****************************************************************************
4   * Copyright (c) 1998-2006,2010 Free Software Foundation, Inc.              *
5   *                                                                          *
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:                 *
13   *                                                                          *
14   * The above copyright notice and this permission notice shall be included  *
15   * in all copies or substantial portions of the Software.                   *
16   *                                                                          *
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.                               *
24   *                                                                          *
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       *
28   * authorization.                                                           *
29   ****************************************************************************
30   * @Id: form_fieldtype.3x,v 1.16 2010/12/04 18:40:45 tom Exp @
31 -->
32 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
33 <HTML>
34 <HEAD>
35 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
36 <meta name="generator" content="Manpage converted by man2html - see http://invisible-island.net/scripts/readme.html#others_scripts">
37 <TITLE>form_fieldtype 3x</TITLE>
38 <link rev=made href="mailto:bug-ncurses@gnu.org">
39 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
40 </HEAD>
41 <BODY>
42 <H1>form_fieldtype 3x</H1>
43 <HR>
44 <PRE>
45 <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>                                   <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
46
47
48
49
50 </PRE>
51 <H2><a name="h2-NAME">NAME</a></H2><PRE>
52        <STRONG>form_fieldtype</STRONG> - define validation-field types
53
54
55 </PRE>
56 <H2><a name="h2-SYNOPSIS">SYNOPSIS</a></H2><PRE>
57        <STRONG>#include</STRONG> <STRONG>&lt;form.h&gt;</STRONG>
58        FIELDTYPE *new_fieldtype(
59            bool (* const field_check)(FIELD *, const void *),
60            bool (* const char_check)(int, const void *));
61        int free_fieldtype(FIELDTYPE *fieldtype);
62        int set_fieldtype_arg(
63            FIELDTYPE *fieldtype,
64            void *(* const make_arg)(va_list *),
65            void *(* const copy_arg)(const void *),
66            void  (* const free_arg)(void *));
67        int set_fieldtype_choice(
68            FIELDTYPE *fieldtype,
69            bool (* const next_choice)(FIELD *, const void *),
70            bool (* const prev_choice)(FIELD *, const void *));
71        FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
72                                  FIELDTYPE *type2);
73
74
75 </PRE>
76 <H2><a name="h2-DESCRIPTION">DESCRIPTION</a></H2><PRE>
77        The function <STRONG>new_fieldtype</STRONG> creates a new field type usable
78        for data validation.  You supply it  with  <EM>field</EM><STRONG>_</STRONG><EM>check</EM>,  a
79        predicate  to check the validity of an entered data string
80        whenever the user attempts to leave a field.   The  (FIELD
81        *)  argument  is passed in so the validation predicate can
82        see the field's buffer, sizes and  other  attributes;  the
83        second  argument  is  an  argument-block  structure, about
84        which more below.
85
86        You also supply <STRONG>new_fieldtype</STRONG> with <EM>char</EM><STRONG>_</STRONG><EM>check</EM>, a  function
87        to  validate input characters as they are entered; it will
88        be passed the character to be checked and a pointer to  an
89        argument-block structure.
90
91        The  function <STRONG>free_fieldtype</STRONG> frees the space allocated for
92        a given validation type.
93
94        The function <STRONG>set_fieldtype_arg</STRONG> associates  three  storage-
95        management  functions  with  a  field  type.  The <EM>make</EM><STRONG>_</STRONG><EM>arg</EM>
96        function is automatically applied to the list of arguments
97        you  give  <STRONG>set_field_type</STRONG>  when  attaching validation to a
98        field; its job is to bundle these into an allocated  argu-
99        ment-block  object which can later be passed to validation
100        predicated.  The other two hook arguments should copy  and
101        free  argument-block structures.  They will be used by the
102        forms-driver code.  You must supply the <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> function,
103        the  other two are optional, you may supply NULL for them.
104        In this case it is assumed that <EM>make</EM><STRONG>_</STRONG><EM>arg</EM> does not allocate
105        memory  but simply loads the argument into a single scalar
106        value.
107
108        The function <STRONG>link_fieldtype</STRONG> creates a new field type  from
109        the  two  given  types.   They are connected by an logical
110        'OR'.
111
112        The   form    driver    requests    <STRONG>REQ_NEXT_CHOICE</STRONG>    and
113        <STRONG>REQ_PREV_CHOICE</STRONG> assume that the possible values of a field
114        form an ordered set, and provide the forms user with a way
115        to  move  through the set.  The <STRONG>set_fieldtype_choice</STRONG> func-
116        tion allows forms programmers to define successor and pre-
117        decessor  functions  for  the field type.  These functions
118        take the field pointer and an argument-block structure  as
119        arguments.
120
121
122 </PRE>
123 <H2><a name="h2-RETURN-VALUE">RETURN VALUE</a></H2><PRE>
124        The  pointer-valued  routines  return NULL on error.  They
125        set errno according to their success:
126
127        <STRONG>E_OK</STRONG> The routine succeeded.
128
129        <STRONG>E_BAD_ARGUMENT</STRONG>
130             Routine detected an incorrect or  out-of-range  argu-
131             ment.
132
133        <STRONG>E_SYSTEM_ERROR</STRONG>
134             System error occurred, e.g., malloc failure.
135
136        The  integer-valued  routines  return one of the following
137        codes on error:
138
139        <STRONG>E_OK</STRONG> The routine succeeded.
140
141        <STRONG>E_BAD_ARGUMENT</STRONG>
142             Routine detected an incorrect or  out-of-range  argu-
143             ment.
144
145        <STRONG>E_CONNECTED</STRONG>
146             The field is already connected to a form.
147
148        <STRONG>E_CURRENT</STRONG>
149             The field is the current field.
150
151        <STRONG>E_SYSTEM_ERROR</STRONG>
152             System error occurred (see <STRONG>errno</STRONG>).
153
154
155 </PRE>
156 <H2><a name="h2-SEE-ALSO">SEE ALSO</a></H2><PRE>
157        <STRONG><A HREF="ncurses.3x.html">curses(3x)</A></STRONG>, <STRONG><A HREF="form.3x.html">form(3x)</A></STRONG>.
158
159
160 </PRE>
161 <H2><a name="h2-NOTES">NOTES</a></H2><PRE>
162        The header file <STRONG>&lt;form.h&gt;</STRONG> automatically includes the header
163        file <STRONG>&lt;curses.h&gt;</STRONG>.
164
165        All of the <STRONG>(char</STRONG> <STRONG>*)</STRONG> arguments of  these  functions  should
166        actually  be <STRONG>(void</STRONG> <STRONG>*)</STRONG>.  The type has been left uncorrected
167        for strict compatibility with System V.
168
169
170 </PRE>
171 <H2><a name="h2-PORTABILITY">PORTABILITY</a></H2><PRE>
172        These routines emulate the System V forms  library.   They
173        were not supported on Version 7 or BSD versions.
174
175
176 </PRE>
177 <H2><a name="h2-AUTHORS">AUTHORS</a></H2><PRE>
178        Juergen  Pfeifer.   Manual  pages  and  adaptation for new
179        curses by Eric S. Raymond.
180
181
182
183                                                      <STRONG><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></STRONG>
184 </PRE>
185 <div class="nav">
186 <ul>
187 <li><a href="#h2-NAME">NAME</a></li>
188 <li><a href="#h2-SYNOPSIS">SYNOPSIS</a></li>
189 <li><a href="#h2-DESCRIPTION">DESCRIPTION</a></li>
190 <li><a href="#h2-RETURN-VALUE">RETURN VALUE</a></li>
191 <li><a href="#h2-SEE-ALSO">SEE ALSO</a></li>
192 <li><a href="#h2-NOTES">NOTES</a></li>
193 <li><a href="#h2-PORTABILITY">PORTABILITY</a></li>
194 <li><a href="#h2-AUTHORS">AUTHORS</a></li>
195 </ul>
196 </div>
197 </BODY>
198 </HTML>