---
name: "libressl-UI_create_method"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-UI_create_method"
---

# libressl-UI\_create\_method(3)

user interface method creation and destruction

## NAME

**UI\_create\_method**, **UI\_destroy\_method**, **UI\_method\_set\_opener**, **UI\_method\_set\_writer**, **UI\_method\_set\_flusher**, **UI\_method\_set\_reader**, **UI\_method\_set\_closer**, **UI\_method\_set\_prompt\_constructor**, **UI\_method\_get\_opener**, **UI\_method\_get\_writer**, **UI\_method\_get\_flusher**, **UI\_method\_get\_reader**, **UI\_method\_get\_closer**, **UI\_method\_get\_prompt\_constructor** – user interface method creation and destruction

## SYNOPSIS

Crypto Library (libcrypto, -lcrypto)

**#include \<openssl/ui.h\>**

*UI\_METHOD* *\**\

**UI\_create\_method**(*const char \*name*);

*void*\

**UI\_destroy\_method**(*UI\_METHOD \*ui\_method*);

*int*\

**UI\_method\_set\_opener**(*UI\_METHOD \*method*, *int (\*opener)(UI \*ui)*);

*int*\

**UI\_method\_set\_writer**(*UI\_METHOD \*method*, *int (\*writer)(UI \*ui, UI\_STRING \*uis)*);

*int*\

**UI\_method\_set\_flusher**(*UI\_METHOD \*method*, *int (\*flusher)(UI \*ui)*);

*int*\

**UI\_method\_set\_reader**(*UI\_METHOD \*method*, *int (\*reader)(UI \*ui, UI\_STRING \*uis)*);

*int*\

**UI\_method\_set\_closer**(*UI\_METHOD \*method*, *int (\*closer)(UI \*ui)*);

*int*\

**UI\_method\_set\_prompt\_constructor**(*UI\_METHOD \*method*, *char \*(\*prompt\_constructor)(UI \*ui, const char \*object\_desc, const char \*object\_name)*);

*int*\

**(\*UI\_method\_get\_opener(const UI\_METHOD \*method))**(*UI \**);

*int*\

**(\*UI\_method\_get\_writer(const UI\_METHOD \*method))**(*UI \**, *UI\_STRING \**);

*int*\

**(\*UI\_method\_get\_flusher(const UI\_METHOD \*method))**(*UI \**);

*int*\

**(\*UI\_method\_get\_reader(const UI\_METHOD \*method))**(*UI \**, *UI\_STRING \**);

*int*\

**(\*UI\_method\_get\_closer(const UI\_METHOD \*method))**(*UI \**);

*char* *\**\

**(\*UI\_method\_get\_prompt\_constructor(UI\_METHOD \*method))**(*UI \**, *const char \**, *const char \**);

## DESCRIPTION

A method contains a few functions that implement the low level of the User Interface. These functions are:

- an opener

  This function takes a reference to a UI and starts a session, for example by opening a channel to a tty, or by creating a dialog box.

- a writer

  This function takes a reference to a UI and a UI String, and writes the string where appropriate, maybe to the tty, maybe added as a field label in a dialog box. Note that this gets fed all strings associated with a UI, one after the other, so care must be taken which ones it actually uses.

- a flusher

  This function takes a reference to a UI, and flushes everything that has been output so far. For example, if the method builds up a dialog box, this can be used to actually display it and accepting input ended with a pressed button.

- a reader

  This function takes a reference to a UI and a UI string and reads off the given prompt, maybe from the tty, maybe from a field in a dialog box. Note that this gets fed all strings associated with a UI, one after the other, so care must be taken which ones it actually uses.

- a closer

  This function takes a reference to a UI, and closes the session, maybe by closing the channel to the tty, maybe by destroying a dialog box.

All of these functions are expected to return 0 on error, 1 on success, or -1 on out-off-band events, for example if some prompting has been cancelled (by pressing Ctrl-C, for example). Only the flusher or the reader are expected to return -1. If returned by another of the functions, it's treated as if 0 was returned.

Regarding the writer and the reader, don't assume the former should only write and don't assume the latter should only read. This depends on the needs of the method.

For example, a typical tty reader wouldn't write the prompts in the write, but would rather do so in the reader, because of the sequential nature of prompting on a tty. This is how the UI\_OpenSSL(3) method does it.

In contrast, a method that builds up a dialog box would add all prompt text in the writer, have all input read in the flusher and store the results in some temporary buffer, and finally have the reader just fetch those results.

The central function that uses these method functions is UI\_process(3), and it does it in five steps:

1. Open the session using the opener function if that one is defined. If an error occurs, jump to 5.

2. For every UI String associated with the UI, call the writer function if that one is defined. If an error occurs, jump to 5.

3. Flush everything using the flusher function if that one is defined. If an error occurs, jump to 5.

4. For every UI String associated with the UI, call the reader function if that one is defined. If an error occurs, jump to 5.

5. Close the session using the closer function if that one is defined.

**UI\_create\_method**() creates a new UI method with a given *name*.

**UI\_destroy\_method**() destroys the given *ui\_method*.

**UI\_method\_set\_opener**(), **UI\_method\_set\_writer**(), **UI\_method\_set\_flusher**(), **UI\_method\_set\_reader**() and **UI\_method\_set\_closer**() set one of the five main methods to the given function pointer.

**UI\_method\_set\_prompt\_constructor**() sets the prompt constructor, see UI\_construct\_prompt(3).

## RETURN VALUES

**UI\_create\_method**() returns a *UI\_METHOD* pointer on success or NULL on error.

**UI\_method\_set\_opener**(), **UI\_method\_set\_writer**(), **UI\_method\_set\_flusher**(), **UI\_method\_set\_reader**(), **UI\_method\_set\_closer**(), and **UI\_method\_set\_prompt\_constructor**() return 0 on success or -1 if the given method is NULL.

**UI\_method\_get\_opener**(), **UI\_method\_get\_writer**(), **UI\_method\_get\_flusher**(), **UI\_method\_get\_reader**(), **UI\_method\_get\_closer**(), and **UI\_method\_get\_prompt\_constructor**() return the requested function pointer if it is set in the method, or otherwise NULL.

## SEE ALSO

UI\_get\_string\_type(3), UI\_new(3)

## HISTORY

**UI\_create\_method**(), **UI\_destroy\_method**(), **UI\_method\_set\_opener**(), **UI\_method\_set\_writer**(), **UI\_method\_set\_flusher**(), **UI\_method\_set\_reader**(), **UI\_method\_set\_closer**(), **UI\_method\_get\_opener**(), **UI\_method\_get\_writer**(), **UI\_method\_get\_flusher**(), **UI\_method\_get\_reader**(), and **UI\_method\_get\_closer**() first appeared in OpenSSL 0.9.7 and have been available since OpenBSD 3.2.

**UI\_method\_set\_prompt\_constructor**() and **UI\_method\_get\_prompt\_constructor**() first appeared in OpenSSL 1.0.0 and have been available since OpenBSD 4.9.
