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