1form_fieldtype(3X)                                          form_fieldtype(3X)
2
3
4

NAME

6       form_fieldtype - define validation-field types
7

SYNOPSIS

9       #include <form.h>
10       FIELDTYPE *new_fieldtype(
11           bool (* const field_check)(FIELD *, const void *),
12           bool (* const char_check)(int, const void *));
13       int free_fieldtype(FIELDTYPE *fieldtype);
14       int set_fieldtype_arg(
15           FIELDTYPE *fieldtype,
16           void *(* const make_arg)(va_list *),
17           void *(* const copy_arg)(const void *),
18           void  (* const free_arg)(void *));
19       int set_fieldtype_choice(
20           FIELDTYPE *fieldtype,
21           bool (* const next_choice)(FIELD *, const void *),
22           bool (* const prev_choice)(FIELD *, const void *));
23       FIELDTYPE *link_fieldtype(FIELDTYPE *type1,
24                                 FIELDTYPE *type2);
25

DESCRIPTION

27       The  function  new_fieldtype  creates  a new field type usable for data
28       validation.  You supply it with field_check, a predicate to  check  the
29       validity  of an entered data string whenever the user attempts to leave
30       a field.  The (FIELD *) argument is passed in so the validation  predi‐
31       cate can see the field's buffer, sizes and other attributes; the second
32       argument is an argument-block structure, about which more below.
33
34       You also supply new_fieldtype with char_check, a function  to  validate
35       input  characters  as they are entered; it will be passed the character
36       to be checked and a pointer to an argument-block structure.
37
38       The function free_fieldtype frees the space allocated for a given vali‐
39       dation type.
40
41       The  function  set_fieldtype_arg  associates  three  storage-management
42       functions with a field type.  The make_arg  function  is  automatically
43       applied to the list of arguments you give set_field_type when attaching
44       validation to a field; its job is to bundle  these  into  an  allocated
45       argument-block  object  which  can later be passed to validation predi‐
46       cated.  The other two hook arguments should  copy  and  free  argument-
47       block  structures.   They  will  be used by the forms-driver code.  You
48       must supply the make_arg function, the other two are optional, you  may
49       supply  NULL  for  them.  In this case it is assumed that make_arg does
50       not allocate memory but simply loads the argument into a single  scalar
51       value.
52
53       The function link_fieldtype creates a new field type from the two given
54       types.  They are connected by an logical 'OR'.
55
56       The form driver requests  REQ_NEXT_CHOICE  and  REQ_PREV_CHOICE  assume
57       that  the  possible  values of a field form an ordered set, and provide
58       the forms user with a way to move  through  the  set.   The  set_field‐
59       type_choice  function  allows forms programmers to define successor and
60       predecessor functions for the field type.   These  functions  take  the
61       field pointer and an argument-block structure as arguments.
62

RETURN VALUE

64       The  pointer-valued  routines  return  NULL  on  error.  They set errno
65       according to their success:
66
67       E_OK The routine succeeded.
68
69       E_BAD_ARGUMENT
70            Routine detected an incorrect or out-of-range argument.
71
72       E_SYSTEM_ERROR
73            System error occurred, e.g., malloc failure.
74
75       The integer-valued routines return one of the following codes on error:
76
77       E_OK The routine succeeded.
78
79       E_BAD_ARGUMENT
80            Routine detected an incorrect or out-of-range argument.
81
82       E_CONNECTED
83            The field is already connected to a form.
84
85       E_CURRENT
86            The field is the current field.
87
88       E_SYSTEM_ERROR
89            System error occurred (see errno).
90

SEE ALSO

92       curses(3X), form(3X).
93

NOTES

95       The  header  file  <form.h>  automatically  includes  the  header  file
96       <curses.h>.
97
98       All  of  the  (char  *) arguments of these functions should actually be
99       (void *).  The type has been left uncorrected for strict  compatibility
100       with System V.
101

PORTABILITY

103       These  routines emulate the System V forms library.  They were not sup‐
104       ported on Version 7 or BSD versions.
105

AUTHORS

107       Juergen Pfeifer.  Manual pages and adaptation for new curses by Eric S.
108       Raymond.
109
110
111
112                                                            form_fieldtype(3X)
Impressum