Merge branch 'vendor/TCPDUMP' (early part)
[games.git] / lib / libncurses / man / form_field_validation.3
1 .\"***************************************************************************
2 .\" Copyright (c) 1998-2002,2003 Free Software Foundation, Inc.              *
3 .\"                                                                          *
4 .\" Permission is hereby granted, free of charge, to any person obtaining a  *
5 .\" copy of this software and associated documentation files (the            *
6 .\" "Software"), to deal in the Software without restriction, including      *
7 .\" without limitation the rights to use, copy, modify, merge, publish,      *
8 .\" distribute, distribute with modifications, sublicense, and/or sell       *
9 .\" copies of the Software, and to permit persons to whom the Software is    *
10 .\" furnished to do so, subject to the following conditions:                 *
11 .\"                                                                          *
12 .\" The above copyright notice and this permission notice shall be included  *
13 .\" in all copies or substantial portions of the Software.                   *
14 .\"                                                                          *
15 .\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
16 .\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
17 .\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
18 .\" IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
19 .\" DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
20 .\" OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
21 .\" THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
22 .\"                                                                          *
23 .\" Except as contained in this notice, the name(s) of the above copyright   *
24 .\" holders shall not be used in advertising or otherwise to promote the     *
25 .\" sale, use or other dealings in this Software without prior written       *
26 .\" authorization.                                                           *
27 .\"***************************************************************************
28 .\"
29 .\" $Id: form_field_validation.3x,v 1.14 2003/05/10 20:33:49 jmc Exp $
30 .\" $DragonFly: src/lib/libncurses/man/form_field_validation.3,v 1.1 2005/03/12 19:13:54 eirikn Exp $
31 .TH form_field_validation 3X ""
32 .SH NAME
33 \fBform_field_validation\fR - data type validation for fields
34 .SH SYNOPSIS
35 \fB#include <form.h>\fR
36 .br
37 int set_field_type(FIELD *field, FIELDTYPE *type, ...);
38 .br
39 FIELDTYPE *field_type(const FIELD *field);
40 .br
41 void *field_arg(const FIELD *field);
42 .sp
43 FIELDTYPE *TYPE_ALNUM;
44 .br
45 FIELDTYPE *TYPE_ALPHA;
46 .br
47 FIELDTYPE *TYPE_ENUM;
48 .br
49 FIELDTYPE *TYPE_INTEGER;
50 .br
51 FIELDTYPE *TYPE_NUMERIC;
52 .br
53 FIELDTYPE *TYPE_REGEXP;
54 .br
55 FIELDTYPE *TYPE_IPV4;
56 .br
57 .SH DESCRIPTION
58 The function \fBset_field_type\fR declares a data type for a given form field.
59 This is the type checked by validation functions.
60 The predefined types are as follows:
61 .TP 5
62 TYPE_ALNUM
63 Alphanumeric data.  Requires a third \fBint\fR argument, a minimum field width.
64 .TP 5
65 TYPE_ALPHA
66 Character data.  Requires a third \fBint\fR argument, a minimum field width.
67 .TP 5
68 TYPE_ENUM
69 Accept one of a specified set of strings.  Requires a third \fB(char **)\fR
70 argument pointing to a string list; a fourth \fBint\fR flag argument to enable
71 case-sensitivity; and a fifth \fBint\fR flag argument specifying whether a partial
72 match must be a unique one (if this flag is off, a prefix matches the first
73 of any set of more than one list elements with that prefix). Please notice
74 that the string list is not copied, only a reference to it is stored in the
75 field. So you should avoid using a list that lives in automatic variables
76 on the stack.
77 .TP 5
78 TYPE_INTEGER
79 Integer data, parsable to an integer by \fBatoi(3)\fR.  Requires a third
80 \fBint\fR argument controlling the precision, a fourth \fBlong\fR argument
81 constraining minimum value, and a fifth \fBlong\fR constraining maximum value.
82 If the maximum value is less than or equal to the minimum value, the range is
83 simply ignored. On return the field buffer is formatted according to the
84 \fBprintf\fR format specification ".*ld", where the '*' is replaced by the
85 precision argument.
86 For details of the precision handling see \fBprintf's\fR man-page.
87 .TP 5
88 TYPE_NUMERIC
89 Numeric data (may have a decimal-point part). Requires a third
90 \fBint\fR argument controlling the precision, a fourth \fBdouble\fR
91 argument constraining minimum value, and a fifth \fBdouble\fR constraining
92 maximum value. If your system supports locales, the decimal point character
93 to be used must be the one specified by your locale.
94 If the maximum value is less than or equal to the minimum value, the range is
95 simply ignored. On return the field buffer is formatted according to the
96 \fBprintf\fR format specification ".*f", where the '*' is replaced by the
97 precision argument.
98 For details of the precision handling see \fBprintf's\fR man-page.
99 .TP 5
100 TYPE_REGEXP
101 Regular expression data.  Requires a regular expression \fB(char *)\fR third argument;
102 the data is valid if the regular expression matches it.  Regular expressions
103 are in the format of \fBregcomp\fR(3X) and \fBregexec\fR(3X). Please notice
104 that the regular expression must match the whole field. If you have for
105 example an eight character wide field, a regular expression "^[0-9]*$" always
106 means that you have to fill all eight positions with digits. If you want to
107 allow fewer digits, you may use for example "^[0-9]* *$" which is good for
108 trailing spaces (up to an empty field), or "^ *[0-9]* *$" which is good for
109 leading and trailing spaces around the digits.
110 .TP 5
111 TYPE_IPV4
112 An Internet Protocol Version 4 address. This requires no additional argument. It
113 is checked whether or not the buffer has the form a.b.c.d, where a,b,c and d are
114 numbers between 0 and 255. Trailing blanks in the buffer are ignored. The address
115 itself is not validated. Please note that this is an ncurses extension. This
116 field type may not be available in other curses implementations.
117 .PP
118 It is possible to set up new programmer-defined field types.  See the
119 \fBform_fieldtype\fR(3X) manual page.
120 .SH RETURN VALUE
121 The functions \fBfield_type\fR and \fBfield_arg\fR return \fBNULL\fR on
122 error. The function \fBset_field_type\fR returns one of the following:
123 .TP 5
124 \fBE_OK\fR
125 The routine succeeded.
126 .TP 5
127 \fBE_SYSTEM_ERROR\fR
128 System error occurred (see \fBerrno\fR).
129 .SH SEE ALSO
130 \fBcurses\fR(3X), \fBform\fR(3X).
131 .SH NOTES
132 The header file \fB<form.h>\fR automatically includes the header file
133 \fB<curses.h>\fR.
134 .SH PORTABILITY
135 These routines emulate the System V forms library.  They were not supported on
136 Version 7 or BSD versions.
137 .SH AUTHORS
138 Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric
139 S. Raymond.
140 .\"#
141 .\"# The following sets edit modes for GNU EMACS
142 .\"# Local Variables:
143 .\"# mode:nroff
144 .\"# fill-column:79
145 .\"# End: