form\_fieldtype(3X) Library calls form\_fieldtype(3X)

# [NAME](#NAME)

**form\_fieldtype** - define validation-field types

# [SYNOPSIS](#SYNOPSIS)

```
#include <form.h>
```

```
FIELDTYPE *new_fieldtype(


    bool (* const field_check)(FIELD *, const void *),


    bool (* const char_check)(int, const void *));
int free_fieldtype(FIELDTYPE *fieldtype);
```

```
int set_fieldtype_arg(


    FIELDTYPE *fieldtype,


    void *(* const make_arg)(va_list *),


    void *(* const copy_arg)(const void *),


    void  (* const free_arg)(void *));
int set_fieldtype_choice(


    FIELDTYPE *fieldtype,


    bool (* const next_choice)(FIELD *, const void *),


    bool (* const prev_choice)(FIELD *, const void *));
```

```
FIELDTYPE *link_fieldtype(FIELDTYPE *type1,


                          FIELDTYPE *type2);
```

# [DESCRIPTION](#DESCRIPTION)

## [new\_fieldtype](#new_fieldtype)

The function **new\_fieldtype** creates a new field type usable for data validation. Its parameters are function pointers:

[*field\_check*](#field_check)

This function checks the validity of an entered data string whenever the user attempts to leave a field. It has two arguments:

- The (FIELD \*) argument is passed in so the validation predicate can see the field's buffer, sizes and other attributes.
- The second argument is an argument-block structure, about which more below.

[*char\_check*](#char_check)

This function validates input characters as they are entered. The form library passes it the character to be checked and a pointer to an argument-block structure.

## [free\_fieldtype](#free_fieldtype)

The **free\_fieldtype** function frees the space allocated for a given validation type by **new\_fieldtype**.

## [set\_fieldtype\_arg](#set_fieldtype_arg)

The function **set\_fieldtype\_arg** associates three storage-management functions with a field type:

[*make\_arg*](#make_arg)

This function is automatically applied to the list of arguments you give **set\_field\_type** when attaching validation to a field. It stores the arguments in an allocated argument-block object which is used when validating input.

[*copy\_arg*](#copy_arg)

This function may be used by applications to copy argument-blocks.

[*free\_arg*](#free_arg)

Frees an argument-block structure.

You must supply the *make\_arg* function. The other two are optional: you may supply *NULL* for them. In this case, the form library assumes that *make\_arg* does not allocate memory but simply loads the argument into a single scalar value.

## [set\_fieldtype\_choice](#set_fieldtype_choice)

The form driver requests **REQ\_NEXT\_CHOICE** and **REQ\_PREV\_CHOICE** assume that the possible values of a field form an ordered set, and provide the forms user with a way to move through the set.

The **set\_fieldtype\_choice** function allows forms programmers to define successor and predecessor functions for the field type. These functions take the field pointer and an argument-block structure as arguments.

## [link\_fieldtype](#link_fieldtype)

The function **link\_fieldtype** creates a new field type from the two given types. They are connected by a logical “or”.

# [RETURN VALUE](#RETURN_VALUE)

The pointer-valued routines return NULL on error. They set **errno** according to their success:

[**E\_OK**](#E_OK)

The routine succeeded.

[**E\_BAD\_ARGUMENT**](#E_BAD_ARGUMENT)

Routine detected an incorrect or out-of-range argument.

[**E\_SYSTEM\_ERROR**](#E_SYSTEM_ERROR)

System error occurred, e.g., malloc failure.

The integer-valued routines return one of the following codes on error:

[**E\_OK**](#E_OK~2)

The routine succeeded.

[**E\_BAD\_ARGUMENT**](#E_BAD_ARGUMENT~2)

Routine detected an incorrect or out-of-range argument.

[**E\_CONNECTED**](#E_CONNECTED)

The field is already connected to a form.

[**E\_CURRENT**](#E_CURRENT)

The field is the current field.

[**E\_SYSTEM\_ERROR**](#E_SYSTEM_ERROR~2)

System error occurred (see [**errno**(3)](/man/os/ncurses/errno.3)).

# [PORTABILITY](#PORTABILITY)

These routines emulate the System V forms library. They were not supported on Version 7 or BSD versions.

# [AUTHORS](#AUTHORS)

Juergen Pfeifer. Manual pages and adaptation for new curses by Eric S. Raymond.

# [SEE ALSO](#SEE_ALSO)

[**curses**(3X)](/man/os/ncurses/curses.3X), [**form**(3X)](/man/os/ncurses/form.3X), [**form\_field\_validation**(3X)](/man/os/ncurses/form_field_validation.3X)

2025-01-18 ncurses 6.6

---

Document: new_fieldtype(3x) from ncurses 6.6.20261024-r0 (Chainguard OS)
Source: https://github.com/ThomasDickey/ncurses-snapshots
