]> ncurses.scripts.mit.edu Git - ncurses.git/blob - doc/html/man/form_field_validation.3x.html
ncurses 5.2
[ncurses.git] / doc / html / man / form_field_validation.3x.html
1 <HTML>
2 <BODY>
3 <PRE>
4 <!-- Manpage converted by man2html 3.0.1 -->
5
6 </PRE>
7 <H2>NAME</H2><PRE>
8        <B>form_field_validation</B> - data type validation for fields
9
10
11 </PRE>
12 <H2>SYNOPSIS</H2><PRE>
13        <B>#include</B> <B>&lt;form.h&gt;</B>
14        int set_field_type(FIELD *field, FIELDTYPE *type, ...);
15        FIELDTYPE *field_type(const FIELD *field);
16        void *field_arg(const FIELD *field);
17
18
19 </PRE>
20 <H2>DESCRIPTION</H2><PRE>
21        The  function  <B>set_field_type</B>  declares  a data type for a
22        given form field.  This is the type checked by  validation
23        functions.  The types are as follows:
24
25        TYPE_ALNUM
26             Alphanumeric  data.  Requires a third <B>int</B> argument, a
27             minimum field width.
28
29        TYPE_ALPHA
30             Character data.  Requires a  third  <B>int</B>  argument,  a
31             minimum field width.
32
33        TYPE_ENUM
34             Accept one of a specified set of strings.  Requires a
35             third <B>(char</B> <B>**)</B> argument pointing to a string list; a
36             fourth  <B>int</B> flag argument to enable case-sensitivity;
37             and a fifth <B>int</B> flag argument  specifying  whether  a
38             partial  match  must be a unique one (if this flag is
39             off, a prefix matches the first of any  set  of  more
40             than  one  list  elements  with  that prefix). Please
41             notice that the string list is  not  copied,  only  a
42             reference to it is stored in the field. So you should
43             avoid to use a list that lives in automatic variables
44             on the stack.
45
46        TYPE_INTEGER
47             Integer  data,  parsable  to  an  integer by <B>atoi(3)</B>.
48             Requires a third <B>int</B> argument controlling the  preci-
49             sion,  a  fourth  <B>long</B>  argument constraining minimum
50             value, and a fifth <B>long</B> constraining  maximum  value.
51             If  the  maximum  value  is less or equal the minimum
52             value, the range is simply  ignored.  On  return  the
53             field  buffer  is  formatted  according to the <B>printf</B>
54             format  specification  ".*ld",  where  the   '*'   is
55             replaced  by  the precision argument.  For details of
56             the precision handling see <B>printf's</B> man-page.
57
58        TYPE_NUMERIC
59             Numeric  data  (may  have  a   decimal-point   part).
60             Requires  a third <B>int</B> argument controlling the preci-
61             sion, a fourth <B>double</B> argument  constraining  minimum
62             value, and a fifth <B>double</B> constraining maximum value.
63             If your system supports locale's, the  decimal  point
64             character  to  be  used  must be the one specified by
65             your locale.  If the maximum value is less  or  equal
66             the  minimum  value,  the range is simply ignored. On
67             return the field buffer is formatted according to the
68             <B>printf</B>  format  specification ".*f", where the '*' is
69             replaced by the precision argument.  For  details  of
70             the precision handling see <B>printf's</B> man-page.
71
72        TYPE_REGEXP
73             Regular  expression data.  Requires a regular expres-
74             sion <B>(char</B> <B>*)</B> third argument; the data  is  valid  if
75             the  regular  expression matches it.  Regular expres-
76             sions  are  in  the   format   of   <B><A HREF="regcomp.3x.html">regcomp(3x)</A></B>   and
77             <B><A HREF="regexec.3x.html">regexec(3x)</A></B>.  Please  notice that the regular expres-
78             sion must match the whole  field.  If  you  have  for
79             example  an  eight  character  wide  field, a regular
80             expression "^[0-9]*$" always means that you  have  to
81             fill  all eight positions with digits. If you want to
82             allow fewer digits, you may use for example  "^[0-9]*
83             *$" which is good for trailing spaces (up to an empty
84             field), or "^ *[0-9]* *$" which is good  for  leading
85             and trailing spaces around the digits.
86
87        TYPE_IPV4
88             An Internet Protocol Version 4 address. This requires
89             no additional argument. It is checked whether or  not
90             the  buffer  has  the form a.b.c.d, where a,b,c and d
91             are numbers between 0 and 255. Trailing blanks in the
92             buffer  are  ignored. The address itself is not vali-
93             dated. Please note that this is an ncurses extension.
94             This  field type may not be available in other curses
95             implementations.
96
97             It is possible to set up new programmer-defined field
98             types.  See the <B><A HREF="form_fieldtype.3x.html">form_fieldtype(3x)</A></B> manual page.
99
100
101 </PRE>
102 <H2>RETURN VALUE</H2><PRE>
103        The  functions  <B>field_type</B>  and  <B>field_arg</B>  return <B>NULL</B> on
104        error. The function <B>set_field_type</B> returns one of the fol-
105        lowing:
106
107        <B>E_OK</B> The routine succeeded.
108
109        <B>E_SYSTEM_ERROR</B>
110             System error occurred (see <B>errno</B>).
111
112
113 </PRE>
114 <H2>SEE ALSO</H2><PRE>
115        <B><A HREF="ncurses.3x.html">curses(3x)</A></B>, <B><A HREF="form.3x.html">form(3x)</A></B>.
116
117
118 </PRE>
119 <H2>NOTES</H2><PRE>
120        The header file <B>&lt;form.h&gt;</B> automatically includes the header
121        file <B>&lt;curses.h&gt;</B>.
122
123
124 </PRE>
125 <H2>PORTABILITY</H2><PRE>
126        These routines emulate the System V forms  library.   They
127        were not supported on Version 7 or BSD versions.
128
129
130 </PRE>
131 <H2>AUTHORS</H2><PRE>
132        Juergen  Pfeifer.   Manual  pages  and  adaptation for new
133        curses by Eric S. Raymond.
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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>