5 .Nm copy_printf_domain , free_printf_domain , new_printf_domain ,
6 .Nm register_printf_domain_function , register_printf_domain_render_std
7 .Nd extensible printf domains
11 .Fn copy_printf_domain "printf_domain_t domain"
13 .Fn free_printf_domain "printf_domain_t domain"
15 .Fn new_printf_domain void
17 .Fn register_printf_domain_function "printf_domain_t domain" "int spec" "printf_function *render" "printf_arginfo_function *arginfo", "void *context"
19 .Fn register_printf_domain_render_std "printf_domain_t domain" "const char *specs"
21 A printf domain is an extensible printf (see
23 structure defining a set of conversion specifiers that
24 will be used in calls to the routines discussed in
28 Domains can be modified independently of one another, and do not affect the
29 behavior of the normal printf calls in
32 To create a new domain, call
33 .Fn new_printf_domain ;
34 the standard POSIX conversion specifiers are defined by default.
35 To make a copy of an existing domain, use
36 .Fn copy_printf_domain .
37 When a domain is no longer needed, call
38 .Fn free_printf_domain
39 to release the associated memory.
42 .Fn register_printf_domain_function
43 function is used to add, modify or remove conversion specifiers for a
47 argument is the specifier character, which can be any printable (non-control)
49 except for those characters that are used as flag/option characters.
50 The set of flag/option characters includes the space character, and the
53 .Dl # $ ' * + \&, - \&. 0 1 2 3 4 5 6 7 8 9 \&: \&; L _ h j l q t v z
55 Two user-defined callback function must also be given; see
57 for a description of these callback functions and an example of use.
58 Setting either or both callbacks to
60 deletes the given specifier from the domain.
61 Note that while it is permissible to redefine the standard conversion
62 specifiers, it is not usually recommended as it may cause confusion.
65 .Fn register_printf_domain_render_std
66 function is used to add pre-defined conversion specifiers to the given domain.
69 argument is a null-terminated C string containing one or more of the following
71 .Bl -tag -width ".Li H"
76 specifier takes two arguments; the first is a pointer to the data to
77 dump, while the second argument is the length of the data, given as type
79 Normally, 16 characters are displayed per line, as pairs of hex characters
81 Specifying a field width less than 16 will display that number of characters
85 (showsign) flag will prefix each line with the hex offset of the beginning
86 character in that line.
89 (alternate form) flag will postfix an ASCII representation to each line, with
91 representing non-printable characters.
96 specifier displayed the text representation of the given
98 argument, expected to be a valid
100 value (as returned by
102 Invalid errno values are represent by the
104 string followed by the decimal and hex values of the argument.
109 specifier displays a null-terminated string argument as a C string, with
110 leading and trailing double quotes.
111 Newlines, carriage-returns and tabs are represented by
116 respectively, while backslashes and double quotes are preceeded with a
118 All other whitespace characters not including space itself (those in which
120 returns true) are displayed as octal escape sequences (a backslash followed by
122 All other characters print as themselves.
124 time_t/timeval/timespec.
127 specifier displays the three types of time values as a single decimal value.
128 The argument should be a pointer to the time value to be converted.
129 Setting the appropriate flags indicates which type is indicated:
130 .Bl -tag -width ".Pq none"
134 (long long) flag indicates the argument points to a
137 The default precision is 9.
141 (long) flag indicates the argument points to a
144 The default precision is 6.
146 By default, the argument points to a
149 The default precision is 0 (the fractional part is not displayed).
154 (alternate form) flag is specified, the value is displayed in years, days,
155 hours, minutes and seconds, as in:
156 .Dq Li 3y123d21h59m59s.987654
157 (zero values are not displayed at all).
158 Note that the years are 365 days (no leap days).
165 to display the null-terminated C string argument.
166 The precision value can be used to limit the amount of the string that is
167 processed (defaults to the entire string).
169 Flag values can be used to obtain different encodings:
170 .Bl -tag -width "(none)"
174 (showsign) flag uses the
175 .Dq Li VIS_WHITE | VIS_HTTPSTYLE
181 (leading zero) flag uses the
182 .Dq Li VIS_WHITE | VIS_OCTAL
188 (alternate form) flag uses the
193 The default flag value to
196 .Dq Li VIS_WHITE | VIS_CSTYLE | VIS_OCTAL .
201 .Fn new_printf_domain
203 .Fn copy_printf_domain
204 functions return the new domain, or
206 on failure (usually out of memory condition).
209 .Fn register_printf_domain_function
211 .Fn register_printf_domain_render_std
212 return zero on success and \-1 on failure (usually due to an improper specifier
213 character or out of memory condition).