1doc::unibi_format(3)               unibilium              doc::unibi_format(3)
2
3
4

NAME

6       unibi_format, unibi_run - interpret a terminfo format string
7

SYNOPSIS

9         #include <unibilium.h>
10
11         void unibi_format(
12             unibi_var_t var_dyn[26],
13             unibi_var_t var_static[26],
14             const char *fmt,
15             unibi_var_t param[9],
16             void (*out)(void *, const char *, size_t),
17             void *ctx1,
18             void (*pad)(void *, size_t, int, int),
19             void *ctx2
20         );
21
22         size_t unibi_run(const char *fmt, unibi_var_t param[9], char *p, size_t n);
23

DESCRIPTION

25       "unibi_format" takes a format string fmt and executes it. All output is
26       done by (possibly repeated) calls to out. In the calls to out the first
27       argument is always ctx1, the second argument is a pointer to a chunk of
28       data, and the third argument is a count specifying the size of the
29       chunk in bytes.
30
31       pad is used when the format string contains "$<...>" padding
32       instructions. In the calls to pad the first argument is always ctx2,
33       the second argument is the delay in tenths of milliseconds, the third
34       argument is a boolean flag indicating whether "*" (proportional delay)
35       was specified in the format string, and the fourth argument is a
36       boolean flag indicating whether "/" (forced padding) was specified in
37       the format string. Thus a format string of "$<5/>" would translate into
38       "pad(ctx2, 50, 0, 1)". You may pass a null pointer for pad; in that
39       case padding instructions are silently skipped.
40
41       The values of param are used for the format codes %p1 .. %p9; the
42       values of var_dyn and var_static are used for the so-called
43       dynamic/static variables %Pa .. %Pz and %PA .. %PZ, respectively.
44
45       "unibi_run" is a wrapper around "unibi_format". It passes two arrays
46       (each initialized to 26 zeroes) as var_dyn and var_static. fmt and
47       param are passed on unchanged. It ignores padding and places all normal
48       output in the buffer pointed to by p. n is the size of the buffer; at
49       most n bytes will be written to p.
50

RETURN VALUE

52       "unibi_run" returns the number of bytes that would have been written if
53       the buffer was big enough. Thus the number of valid bytes in p after a
54       call to "unibi_run" is the minimum of n and the return value of
55       "unibi_run".
56

SEE ALSO

58       unibi_var_from_num(3), unibi_var_from_str(3), unibilium.h(3)
59
60
61
62unibilium-2.1.1                   2022-07-23              doc::unibi_format(3)
Impressum