1 /*
2 * Copyright (c) 2014-2018, Juniper Networks, Inc.
3 * All rights reserved.
4 * This SOFTWARE is licensed under the LICENSE provided in the
5 * ../Copyright file. By downloading, installing, copying, or otherwise
6 * using the SOFTWARE, you agree to be bound by the terms of that
7 * LICENSE.
8 * Phil Shafer, July 2014
9 */
10
11 /**
12 * libxo provides a means of generating text, XML, JSON, and HTML output
13 * using a single set of function calls, maximizing the value of output
14 * while minimizing the cost/impact on the code.
15 *
16 * Full documentation is available in ./doc/libxo.txt or online at:
17 * http://juniper.github.io/libxo/libxo-manual.html
18 */
19
20 #ifndef INCLUDE_XO_H
21 #define INCLUDE_XO_H
22
23 #include <stdio.h>
24 #include <sys/types.h>
25 #include <stdarg.h>
26 #include <limits.h>
27 #include <stdlib.h>
28 #include <errno.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif /* __cplusplus */
33
34 #ifdef __dead2
35 #define NORETURN __dead2
36 #else
37 #define NORETURN
38 #endif /* __dead2 */
39
40 /*
41 * Normally we'd use the HAVE_PRINTFLIKE define triggered by the
42 * --enable-printflike option to configure, but we don't install
43 * our internal "xoconfig.h", and I'd rather not. Taking the
44 * coward's path, we'll turn it on inside a #if that allows
45 * others to turn it off where needed. Not ideal, but functional.
46 */
47 #if !defined(NO_PRINTFLIKE)
48 #if defined(__linux) && !defined(__printflike)
49 #define __printflike(_x, _y) __attribute__((__format__ (__printf__, _x, _y)))
50 #endif
51 #define PRINTFLIKE(_x, _y) __printflike(_x, _y)
52 #else
53 #define PRINTFLIKE(_x, _y)
54 #endif /* NO_PRINTFLIKE */
55
56 /** Formatting types */
57 typedef unsigned short xo_style_t;
58 #define XO_STYLE_TEXT 0 /** Generate text output */
59 #define XO_STYLE_XML 1 /** Generate XML output */
60 #define XO_STYLE_JSON 2 /** Generate JSON output */
61 #define XO_STYLE_HTML 3 /** Generate HTML output */
62 #define XO_STYLE_SDPARAMS 4 /* Generate syslog structured data params */
63 #define XO_STYLE_ENCODER 5 /* Generate calls to external encoder */
64
65 /** Flags for libxo */
66 typedef unsigned long long xo_xof_flags_t;
67 #define XOF_BIT(_n) ((xo_xof_flags_t) 1 << (_n))
68 #define XOF_CLOSE_FP XOF_BIT(0) /** Close file pointer on xo_close() */
69 #define XOF_PRETTY XOF_BIT(1) /** Make 'pretty printed' output */
70 #define XOF_LOG_SYSLOG XOF_BIT(2) /** Log (on stderr) our syslog content */
71 #define XOF_RESV3 XOF_BIT(3) /* Unused */
72
73 #define XOF_WARN XOF_BIT(4) /** Generate warnings for broken calls */
74 #define XOF_XPATH XOF_BIT(5) /** Emit XPath attributes in HTML */
75 #define XOF_INFO XOF_BIT(6) /** Emit additional info fields (HTML) */
76 #define XOF_WARN_XML XOF_BIT(7) /** Emit warnings in XML (on stdout) */
77
78 #define XOF_NO_ENV XOF_BIT(8) /** Don't look at LIBXO_OPTIONS env var */
79 #define XOF_NO_VA_ARG XOF_BIT(9) /** Don't advance va_list w/ va_arg() */
80 #define XOF_DTRT XOF_BIT(10) /** Enable "do the right thing" mode */
81 #define XOF_KEYS XOF_BIT(11) /** Flag 'key' fields for xml and json */
82
83 #define XOF_IGNORE_CLOSE XOF_BIT(12) /** Ignore errors on close tags */
84 #define XOF_NOT_FIRST XOF_BIT(13) /* Not the first item (JSON) */
85 #define XOF_NO_LOCALE XOF_BIT(14) /** Don't bother with locale */
86 #define XOF_RESV15 XOF_BIT(15) /* Unused */
87
88 #define XOF_NO_TOP XOF_BIT(16) /** Don't emit the top braces in JSON */
89 #define XOF_RESV17 XOF_BIT(17) /* Unused */
90 #define XOF_UNITS XOF_BIT(18) /** Encode units in XML */
91 #define XOF_RESV19 XOF_BIT(19) /* Unused */
92
93 #define XOF_UNDERSCORES XOF_BIT(20) /** Replace dashes with underscores (JSON)*/
94 #define XOF_COLUMNS XOF_BIT(21) /** xo_emit should return a column count */
95 #define XOF_FLUSH XOF_BIT(22) /** Flush after each xo_emit call */
96 #define XOF_FLUSH_LINE XOF_BIT(23) /** Flush after each newline */
97
98 #define XOF_NO_CLOSE XOF_BIT(24) /** xo_finish won't close open elements */
99 #define XOF_COLOR_ALLOWED XOF_BIT(25) /** Allow color/effects to be enabled */
100 #define XOF_COLOR XOF_BIT(26) /** Enable color and effects */
101 #define XOF_NO_HUMANIZE XOF_BIT(27) /** Block the {h:} modifier */
102
103 #define XOF_LOG_GETTEXT XOF_BIT(28) /** Log (stderr) gettext lookup strings */
104 #define XOF_UTF8 XOF_BIT(29) /** Force text output to be UTF8 */
105 #define XOF_RETAIN_ALL XOF_BIT(30) /** Force use of XOEF_RETAIN */
106 #define XOF_RETAIN_NONE XOF_BIT(31) /** Prevent use of XOEF_RETAIN */
107
108 #define XOF_COLOR_MAP XOF_BIT(32) /** Color map has been initialized */
109 #define XOF_CONTINUATION XOF_BIT(33) /** Continuation of previous line */
110
111 typedef unsigned xo_emit_flags_t; /* Flags to xo_emit() and friends */
112 #define XOEF_RETAIN (1<<0) /* Retain parsed formatting information */
113
114 /*
115 * The xo_info_t structure provides a mapping between names and
116 * additional data emitted via HTML.
117 */
118 typedef struct xo_info_s {
119 const char *xi_name; /* Name of the element */
120 const char *xi_type; /* Type of field */
121 const char *xi_help; /* Description of field */
122 } xo_info_t;
123
124 #define XO_INFO_NULL NULL, NULL, NULL /* Use '{ XO_INFO_NULL }' to end lists */
125
126 struct xo_handle_s; /* Opaque structure forward */
127 typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
128
129 /*
130 * Early versions of the API used "int" instead of "size_t" for buffer
131 * sizes. We want to fix this but allow for backwards compatibility
132 * where needed.
133 */
134 #ifdef XO_USE_INT_RETURN_CODES
135 typedef int xo_ssize_t; /* Buffer size */
136 #else /* XO_USE_INT_RETURN_CODES */
137 typedef ssize_t xo_ssize_t; /* Buffer size */
138 #endif /* XO_USE_INT_RETURN_CODES */
139
140 typedef xo_ssize_t (*xo_write_func_t)(void *, const char *);
141 typedef void (*xo_close_func_t)(void *);
142 typedef int (*xo_flush_func_t)(void *);
143 typedef void *(*xo_realloc_func_t)(void *, size_t);
144 typedef void (*xo_free_func_t)(void *);
145
146 /*
147 * The formatter function mirrors "vsnprintf", with an additional argument
148 * of the xo handle. The caller should return the number of bytes _needed_
149 * to fit the data, even if this exceeds 'len'.
150 */
151 typedef xo_ssize_t (*xo_formatter_t)(xo_handle_t *, char *, xo_ssize_t,
152 const char *, va_list);
153 typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
154
155 xo_handle_t *
156 xo_create (xo_style_t style, xo_xof_flags_t flags);
157
158 xo_handle_t *
159 xo_create_to_file (FILE *fp, xo_style_t style, xo_xof_flags_t flags);
160
161 void
162 xo_destroy (xo_handle_t *xop);
163
164 void
165 xo_set_writer (xo_handle_t *xop, void *opaque, xo_write_func_t write_func,
166 xo_close_func_t close_func, xo_flush_func_t flush_func);
167
168 void
169 xo_set_allocator (xo_realloc_func_t realloc_func, xo_free_func_t free_func);
170
171 void
172 xo_set_style (xo_handle_t *xop, xo_style_t style);
173
174 xo_style_t
175 xo_get_style (xo_handle_t *xop);
176
177 int
178 xo_set_style_name (xo_handle_t *xop, const char *style);
179
180 int
181 xo_set_options (xo_handle_t *xop, const char *input);
182
183 xo_xof_flags_t
184 xo_get_flags (xo_handle_t *xop);
185
186 void
187 xo_set_flags (xo_handle_t *xop, xo_xof_flags_t flags);
188
189 void
190 xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
191
192 int
193 xo_set_file_h (xo_handle_t *xop, FILE *fp);
194
195 int
196 xo_set_file (FILE *fp);
197
198 void
199 xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
200
201 void
202 xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
203
204 void
205 xo_set_depth (xo_handle_t *xop, int depth);
206
207 xo_ssize_t
208 xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
209
210 xo_ssize_t
211 xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
212
213 xo_ssize_t
214 xo_emit (const char *fmt, ...);
215
216 xo_ssize_t
217 xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
218 const char *fmt, va_list vap);
219
220 xo_ssize_t
221 xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
222
223 xo_ssize_t
224 xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
225
226 PRINTFLIKE(2, 0)
227 static inline xo_ssize_t
xo_emit_hvp(xo_handle_t * xop,const char * fmt,va_list vap)228 xo_emit_hvp (xo_handle_t *xop, const char *fmt, va_list vap)
229 {
230 return xo_emit_hv(xop, fmt, vap);
231 }
232
233 PRINTFLIKE(2, 3)
234 static inline xo_ssize_t
xo_emit_hp(xo_handle_t * xop,const char * fmt,...)235 xo_emit_hp (xo_handle_t *xop, const char *fmt, ...)
236 {
237 va_list vap;
238 va_start(vap, fmt);
239 xo_ssize_t rc = xo_emit_hv(xop, fmt, vap);
240 va_end(vap);
241 return rc;
242 }
243
244 PRINTFLIKE(1, 2)
245 static inline xo_ssize_t
xo_emit_p(const char * fmt,...)246 xo_emit_p (const char *fmt, ...)
247 {
248 va_list vap;
249 va_start(vap, fmt);
250 xo_ssize_t rc = xo_emit_hv(NULL, fmt, vap);
251 va_end(vap);
252 return rc;
253 }
254
255 PRINTFLIKE(3, 0)
256 static inline xo_ssize_t
xo_emit_hvfp(xo_handle_t * xop,xo_emit_flags_t flags,const char * fmt,va_list vap)257 xo_emit_hvfp (xo_handle_t *xop, xo_emit_flags_t flags,
258 const char *fmt, va_list vap)
259 {
260 return xo_emit_hvf(xop, flags, fmt, vap);
261 }
262
263 PRINTFLIKE(3, 4)
264 static inline xo_ssize_t
xo_emit_hfp(xo_handle_t * xop,xo_emit_flags_t flags,const char * fmt,...)265 xo_emit_hfp (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
266 {
267 va_list vap;
268 va_start(vap, fmt);
269 xo_ssize_t rc = xo_emit_hvf(xop, flags, fmt, vap);
270 va_end(vap);
271 return rc;
272 }
273
274 PRINTFLIKE(2, 3)
275 static inline xo_ssize_t
xo_emit_fp(xo_emit_flags_t flags,const char * fmt,...)276 xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
277 {
278 va_list vap;
279 va_start(vap, fmt);
280 xo_ssize_t rc = xo_emit_hvf(NULL, flags, fmt, vap);
281 va_end(vap);
282 return rc;
283 }
284
285 xo_ssize_t
286 xo_open_container_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name);
287
288 xo_ssize_t
289 xo_open_container_h (xo_handle_t *xop, const char *name);
290
291 xo_ssize_t
292 xo_open_container (const char *name);
293
294 xo_ssize_t
295 xo_open_container_hd (xo_handle_t *xop, const char *name);
296
297 xo_ssize_t
298 xo_open_container_d (const char *name);
299
300 xo_ssize_t
301 xo_close_container_h (xo_handle_t *xop, const char *name);
302
303 xo_ssize_t
304 xo_close_container (const char *name);
305
306 xo_ssize_t
307 xo_close_container_hd (xo_handle_t *xop);
308
309 xo_ssize_t
310 xo_close_container_d (void);
311
312 xo_ssize_t
313 xo_open_list_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name);
314
315 xo_ssize_t
316 xo_open_list_h (xo_handle_t *xop, const char *name);
317
318 xo_ssize_t
319 xo_open_list (const char *name);
320
321 xo_ssize_t
322 xo_open_list_hd (xo_handle_t *xop, const char *name);
323
324 xo_ssize_t
325 xo_open_list_d (const char *name);
326
327 xo_ssize_t
328 xo_close_list_h (xo_handle_t *xop, const char *name);
329
330 xo_ssize_t
331 xo_close_list (const char *name);
332
333 xo_ssize_t
334 xo_close_list_hd (xo_handle_t *xop);
335
336 xo_ssize_t
337 xo_close_list_d (void);
338
339 xo_ssize_t
340 xo_open_instance_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name);
341
342 xo_ssize_t
343 xo_open_instance_h (xo_handle_t *xop, const char *name);
344
345 xo_ssize_t
346 xo_open_instance (const char *name);
347
348 xo_ssize_t
349 xo_open_instance_hd (xo_handle_t *xop, const char *name);
350
351 xo_ssize_t
352 xo_open_instance_d (const char *name);
353
354 xo_ssize_t
355 xo_close_instance_h (xo_handle_t *xop, const char *name);
356
357 xo_ssize_t
358 xo_close_instance (const char *name);
359
360 xo_ssize_t
361 xo_close_instance_hd (xo_handle_t *xop);
362
363 xo_ssize_t
364 xo_close_instance_d (void);
365
366 xo_ssize_t
367 xo_open_marker_h (xo_handle_t *xop, const char *name);
368
369 xo_ssize_t
370 xo_open_marker (const char *name);
371
372 xo_ssize_t
373 xo_close_marker_h (xo_handle_t *xop, const char *name);
374
375 xo_ssize_t
376 xo_close_marker (const char *name);
377
378 xo_ssize_t
379 xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
380
381 xo_ssize_t
382 xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
383
384 xo_ssize_t
385 xo_attr (const char *name, const char *fmt, ...);
386
387 void
388 xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap);
389
390 void
391 xo_error_h (xo_handle_t *xop, const char *fmt, ...);
392
393 void
394 xo_error (const char *fmt, ...);
395
396 void
397 xo_errorn_hv (xo_handle_t *xop, int need_newline, const char *fmt, va_list vap);
398
399 void
400 xo_errorn_h (xo_handle_t *xop, const char *fmt, ...);
401
402 void
403 xo_errorn (const char *fmt, ...);
404
405 xo_ssize_t
406 xo_flush_h (xo_handle_t *xop);
407
408 xo_ssize_t
409 xo_flush (void);
410
411 xo_ssize_t
412 xo_finish_h (xo_handle_t *xop);
413
414 xo_ssize_t
415 xo_finish (void);
416
417 void
418 xo_finish_atexit (void);
419
420 void
421 xo_set_leading_xpath (xo_handle_t *xop, const char *path);
422
423 void
424 xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
425
426 void
427 xo_warn_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
428
429 void
430 xo_warn (const char *fmt, ...) PRINTFLIKE(1, 2);
431
432 void
433 xo_warnx (const char *fmt, ...) PRINTFLIKE(1, 2);
434
435 void
436 xo_err (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
437
438 void
439 xo_errx (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3);
440
441 void
442 xo_errc (int eval, int code, const char *fmt, ...) NORETURN PRINTFLIKE(3, 4);
443
444 void
445 xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) PRINTFLIKE(3, 0);
446
447 void
448 xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4);
449
450 void
451 xo_message_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3);
452
453 void
454 xo_message_e (const char *fmt, ...) PRINTFLIKE(1, 2);
455
456 void
457 xo_message (const char *fmt, ...) PRINTFLIKE(1, 2);
458
459 void
460 xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code,
461 const char *fmt, va_list vap);
462
463 void
464 xo_emit_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...);
465
466 void
467 xo_emit_warn_c (int code, const char *fmt, ...);
468
469 void
470 xo_emit_warn (const char *fmt, ...);
471
472 void
473 xo_emit_warnx (const char *fmt, ...);
474
475 void
476 xo_emit_err (int eval, const char *fmt, ...) NORETURN;
477
478 void
479 xo_emit_errx (int eval, const char *fmt, ...) NORETURN;
480
481 void
482 xo_emit_errc (int eval, int code, const char *fmt, ...) NORETURN;
483
484 PRINTFLIKE(4, 0)
485 static inline void
xo_emit_warn_hcvp(xo_handle_t * xop,int as_warning,int code,const char * fmt,va_list vap)486 xo_emit_warn_hcvp (xo_handle_t *xop, int as_warning, int code,
487 const char *fmt, va_list vap)
488 {
489 xo_emit_warn_hcv(xop, as_warning, code, fmt, vap);
490 }
491
492 PRINTFLIKE(3, 4)
493 static inline void
xo_emit_warn_hcp(xo_handle_t * xop,int code,const char * fmt,...)494 xo_emit_warn_hcp (xo_handle_t *xop, int code, const char *fmt, ...)
495 {
496 va_list vap;
497 va_start(vap, fmt);
498 xo_emit_warn_hcv(xop, 1, code, fmt, vap);
499 va_end(vap);
500 }
501
502 PRINTFLIKE(2, 3)
503 static inline void
xo_emit_warn_cp(int code,const char * fmt,...)504 xo_emit_warn_cp (int code, const char *fmt, ...)
505 {
506 va_list vap;
507 va_start(vap, fmt);
508 xo_emit_warn_hcv(NULL, 1, code, fmt, vap);
509 va_end(vap);
510 }
511
512 PRINTFLIKE(1, 2)
513 static inline void
xo_emit_warn_p(const char * fmt,...)514 xo_emit_warn_p (const char *fmt, ...)
515 {
516 int code = errno;
517 va_list vap;
518 va_start(vap, fmt);
519 xo_emit_warn_hcv(NULL, 1, code, fmt, vap);
520 va_end(vap);
521 }
522
523 PRINTFLIKE(1, 2)
524 static inline void
xo_emit_warnx_p(const char * fmt,...)525 xo_emit_warnx_p (const char *fmt, ...)
526 {
527 va_list vap;
528 va_start(vap, fmt);
529 xo_emit_warn_hcv(NULL, 1, -1, fmt, vap);
530 va_end(vap);
531 }
532
533 NORETURN PRINTFLIKE(2, 3)
534 static inline void
xo_emit_err_p(int eval,const char * fmt,...)535 xo_emit_err_p (int eval, const char *fmt, ...)
536 {
537 int code = errno;
538 va_list vap;
539 va_start(vap, fmt);
540 xo_emit_warn_hcv(NULL, 0, code, fmt, vap);
541 va_end(vap);
542
543 exit(eval);
544 }
545
546 PRINTFLIKE(2, 3)
547 static inline void
xo_emit_errx_p(int eval,const char * fmt,...)548 xo_emit_errx_p (int eval, const char *fmt, ...)
549 {
550 va_list vap;
551 va_start(vap, fmt);
552 xo_emit_warn_hcv(NULL, 0, -1, fmt, vap);
553 va_end(vap);
554 exit(eval);
555 }
556
557 PRINTFLIKE(3, 4)
558 static inline void
xo_emit_errc_p(int eval,int code,const char * fmt,...)559 xo_emit_errc_p (int eval, int code, const char *fmt, ...)
560 {
561 va_list vap;
562 va_start(vap, fmt);
563 xo_emit_warn_hcv(NULL, 0, code, fmt, vap);
564 va_end(vap);
565 exit(eval);
566 }
567
568 void
569 xo_emit_err_v (int eval, int code, const char *fmt, va_list vap) NORETURN PRINTFLIKE(3, 0);
570
571 void
572 xo_no_setlocale (void);
573
574 /**
575 * @brief Lift libxo-specific arguments from a set of arguments
576 *
577 * libxo-enable programs typically use command line options to enable
578 * all the nifty-cool libxo features. xo_parse_args() makes this simple
579 * by pre-processing the command line arguments given to main(), handling
580 * and removing the libxo-specific ones, meaning anything starting with
581 * "--libxo". A full description of these arguments is in the base
582 * documentation.
583 * @param[in] argc Number of arguments (ala #main())
584 * @param[in] argc Array of argument strings (ala #main())
585 * @return New number of arguments, or -1 for failure.
586 */
587 int
588 xo_parse_args (int argc, char **argv);
589
590 /**
591 * This is the "magic" number returned by libxo-supporting commands
592 * when passed the equally magic "--libxo-check" option. If you
593 * return this, we can (unsafely) assume that since you know the magic
594 * handshake, you'll happily handle future --libxo options and not do
595 * something violent like reboot the box or create another hole in the
596 * ozone layer.
597 */
598 #define XO_HAS_LIBXO 121
599
600 /**
601 * externs for libxo's version number strings
602 */
603 extern const char xo_version[]; /** Base version triple string */
604 extern const char xo_version_extra[]; /** Extra version magic content */
605
606 /**
607 * @brief Dump the internal stack of a libxo handle.
608 *
609 * This diagnostic function is something I will ask you to call from
610 * your program when you write to tell me libxo has gone bat-stink
611 * crazy and has discarded your list or container or content. Output
612 * content will be what we lovingly call "developer entertainment".
613 * @param[in] xop A valid libxo handle, or NULL for the default handle
614 */
615 void
616 xo_dump_stack (xo_handle_t *xop);
617
618 /**
619 * @brief Recode the name of the program, suitable for error output.
620 *
621 * libxo will record the given name for use while generating error
622 * messages. The contents are not copied, so the value must continue
623 * to point to a valid memory location. This allows the caller to change
624 * the value, but requires the caller to manage the memory. Typically
625 * this is called with argv[0] from main().
626 * @param[in] name The name of the current application program
627 */
628 void
629 xo_set_program (const char *name);
630
631 /**
632 * @brief Add a version string to the output, where possible.
633 *
634 * Adds a version number to the output, suitable for tracking
635 * changes in the content. This is only important for the "encoding"
636 * format styles (XML and JSON) and allows a user of the data to
637 * discern which version of the data model is in use.
638 * @param[in] version The version number, encoded as a string
639 */
640 void
641 xo_set_version (const char *version);
642
643 /**
644 * #xo_set_version with a handle.
645 * @param[in] xop A valid libxo handle, or NULL for the default handle
646 * @param[in] version The version number, encoded as a string
647 */
648 void
649 xo_set_version_h (xo_handle_t *xop, const char *version);
650
651 void
652 xo_open_log (const char *ident, int logopt, int facility);
653
654 void
655 xo_close_log (void);
656
657 int
658 xo_set_logmask (int maskpri);
659
660 void
661 xo_set_unit_test_mode (int value);
662
663 void
664 xo_syslog (int priority, const char *name, const char *message, ...);
665
666 void
667 xo_vsyslog (int priority, const char *name, const char *message, va_list args);
668
669 typedef void (*xo_syslog_open_t)(void);
670 typedef void (*xo_syslog_send_t)(const char *full_msg,
671 const char *v0_hdr, const char *text_only);
672 typedef void (*xo_syslog_close_t)(void);
673
674 void
675 xo_set_syslog_handler (xo_syslog_open_t open_func, xo_syslog_send_t send_func,
676 xo_syslog_close_t close_func);
677
678 void
679 xo_set_syslog_enterprise_id (unsigned short eid);
680
681 typedef void (*xo_simplify_field_func_t)(const char *, unsigned, int);
682
683 char *
684 xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
685 xo_simplify_field_func_t field_cb);
686
687 xo_ssize_t
688 xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
689 const char *fmt, const char *efmt,
690 va_list vap);
691
692 xo_ssize_t
693 xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
694 const char *fmt, const char *efmt, ...);
695
696 xo_ssize_t
697 xo_emit_field (const char *rolmod, const char *contents,
698 const char *fmt, const char *efmt, ...);
699
700 void
701 xo_retain_clear_all (void);
702
703 void
704 xo_retain_clear (const char *fmt);
705
706 #ifdef __cplusplus
707 }
708 #endif /* __cplusplus */
709
710 #endif /* INCLUDE_XO_H */
711