NAME
ffoorrmmffiieellddvvaalliiddaattiioonn - data type validation for fields
SYNOPSIS
##iinncclluuddee <
int setfieldtype(FIELD *field, FIELDTYPE *type, ...); FIELDTYPE *fieldtype(const FIELD *field); void *fieldarg(const FIELD *field); FIELDTYPE *TYPEALNUM; FIELDTYPE *TYPEALPHA; FIELDTYPE *TYPEENUM; FIELDTYPE *TYPEINTEGER; FIELDTYPE *TYPENUMERIC; FIELDTYPE *TYPEREGEXP; FIELDTYPE *TYPEIPV4;> DESCRIPTION
The function sseettffiieellddttyyppee declares a data type for a given formfield. This is the type checked by validation functions. The prede-
fined types are as follows: TYPEALNUM Alphanumeric data. Requires a third iinntt argument, a minimum field width. TYPEALPHA Character data. Requires a third iinntt argument, a minimum field width. TYPEENUM Accept one of a specified set of strings. Requires a third ((cchhaarr ****)) argument pointing to a string list; a fourth iinntt flag argumentto enable case-sensitivity; and a fifth iinntt flag argument specify-
ing whether a partial match must be a unique one (if this flag is off, a prefix matches the first of any set of more than one list elements with that prefix). Please notice that the string list is not copied, only a reference to it is stored in the field. So you should avoid using a list that lives in automatic variables on the stack. TYPEINTEGER Integer data, parsable to an integer by aattooii((33)). Requires a third iinntt argument controlling the precision, a fourth lloonngg argument constraining minimum value, and a fifth lloonngg constraining maximum value. If the maximum value is less than or equal to the minimum value, the range is simply ignored. On return the field buffer is formatted according to the pprriinnttff format specification ".*ld", where the '*' is replaced by the precision argument. For detailsof the precision handling see pprriinnttff''ss man-page.
TYPENUMERICNumeric data (may have a decimal-point part). Requires a third iinntt
argument controlling the precision, a fourth ddoouubbllee argument con-
straining minimum value, and a fifth ddoouubbllee constraining maximumvalue. If your system supports locales, the decimal point charac-
ter to be used must be the one specified by your locale. If the maximum value is less than or equal to the minimum value, the range is simply ignored. On return the field buffer is formatted according to the pprriinnttff format specification ".*f", where the '*'is replaced by the precision argument. For details of the preci-
sion handling see pprriinnttff''ss man-page.
TYPEREGEXP Regular expression data. Requires a regular expression ((cchhaarr **)) third argument; the data is valid if the regular expression matches it. Regular expressions are in the format of rreeggccoommpp(3X) and rreeggeexxeecc(3X). Please notice that the regular expression must match the whole field. If you have for example an eight characterwide field, a regular expression "^[0-9]*$" always means that you
have to fill all eight positions with digits. If you want to allowfewer digits, you may use for example "^[0-9]* *$" which is good
for trailing spaces (up to an empty field), or "^ *[0-9]* *$"
which is good for leading and trailing spaces around the digits. TYPEIPV4An Internet Protocol Version 4 address. This requires no addi-
tional argument. It is checked whether or not the buffer has the form a.b.c.d, where a,b,c and d are numbers between 0 and 255. Trailing blanks in the buffer are ignored. The address itself is not validated. Please note that this is an ncurses extension. This field type may not be available in other curses implementations.It is possible to set up new programmer-defined field types. See the
ffoorrmmffiieellddttyyppee(3X) manual page. RREETTUURRNN VVAALLUUEEThe functions ffiieellddttyyppee and ffiieellddaarrgg return NNUULLLL on error. The func-
tion sseettffiieellddttyyppee returns one of the following: EEOOKK The routine succeeded. EESSYYSSTTEEMMEERRRROORR System error occurred (see eerrrrnnoo).SEE ALSO
ccuurrsseess(3X), ffoorrmm(3X). NNOOTTEESS The header file <> automatically includes the header file < >. PPOORRTTAABBIILLIITTYY These routines emulate the System V forms library. They were not sup-
ported on Version 7 or BSD versions. AUTHORS Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond. formfieldvalidation(3X)