212int 213xo_open_container_h (xo_handle_t *xop, const char *name); 214 215int 216xo_open_container (const char *name); 217 218int 219xo_open_container_hd (xo_handle_t *xop, const char *name); 220 221int 222xo_open_container_d (const char *name); 223 224int 225xo_close_container_h (xo_handle_t *xop, const char *name); 226 227int 228xo_close_container (const char *name); 229 230int 231xo_close_container_hd (xo_handle_t *xop); 232 233int 234xo_close_container_d (void); 235 236int 237xo_open_list_h (xo_handle_t *xop, const char *name); 238 239int 240xo_open_list (const char *name); 241 242int 243xo_open_list_hd (xo_handle_t *xop, const char *name); 244 245int 246xo_open_list_d (const char *name); 247 248int 249xo_close_list_h (xo_handle_t *xop, const char *name); 250 251int 252xo_close_list (const char *name); 253 254int 255xo_close_list_hd (xo_handle_t *xop); 256 257int 258xo_close_list_d (void); 259 260int 261xo_open_instance_h (xo_handle_t *xop, const char *name); 262 263int 264xo_open_instance (const char *name); 265 266int 267xo_open_instance_hd (xo_handle_t *xop, const char *name); 268 269int 270xo_open_instance_d (const char *name); 271 272int 273xo_close_instance_h (xo_handle_t *xop, const char *name); 274 275int 276xo_close_instance (const char *name); 277 278int 279xo_close_instance_hd (xo_handle_t *xop); 280 281int 282xo_close_instance_d (void); 283 284int 285xo_open_marker_h (xo_handle_t *xop, const char *name); 286 287int 288xo_open_marker (const char *name); 289 290int 291xo_close_marker_h (xo_handle_t *xop, const char *name); 292 293int 294xo_close_marker (const char *name); 295 296int 297xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...); 298 299int 300xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap); 301 302int 303xo_attr (const char *name, const char *fmt, ...); 304 305void 306xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap); 307 308void 309xo_error_h (xo_handle_t *xop, const char *fmt, ...); 310 311void 312xo_error (const char *fmt, ...); 313 314int 315xo_flush_h (xo_handle_t *xop); 316 317int 318xo_flush (void); 319 320int 321xo_finish_h (xo_handle_t *xop); 322 323int 324xo_finish (void); 325 326void 327xo_finish_atexit (void); 328 329void 330xo_set_leading_xpath (xo_handle_t *xop, const char *path); 331 332void 333xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4); 334 335void 336xo_warn_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3); 337 338void 339xo_warn (const char *fmt, ...) PRINTFLIKE(1, 2); 340 341void 342xo_warnx (const char *fmt, ...) PRINTFLIKE(1, 2); 343 344void 345xo_err (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3); 346 347void 348xo_errx (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3); 349 350void 351xo_errc (int eval, int code, const char *fmt, ...) NORETURN PRINTFLIKE(3, 4); 352 353void 354xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) PRINTFLIKE(3, 0); 355 356void 357xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4); 358 359void 360xo_message_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3); 361 362void 363xo_message_e (const char *fmt, ...) PRINTFLIKE(1, 2); 364 365void 366xo_message (const char *fmt, ...) PRINTFLIKE(1, 2); 367 368void 369xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code, 370 const char *fmt, va_list vap); 371 372void 373xo_emit_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...); 374 375void 376xo_emit_warn_c (int code, const char *fmt, ...); 377 378void 379xo_emit_warn (const char *fmt, ...); 380 381void 382xo_emit_warnx (const char *fmt, ...); 383 384void 385xo_emit_err (int eval, const char *fmt, ...) NORETURN; 386 387void 388xo_emit_errx (int eval, const char *fmt, ...) NORETURN; 389 390void 391xo_emit_errc (int eval, int code, const char *fmt, ...) NORETURN; 392 393PRINTFLIKE(4, 0) 394static inline void 395xo_emit_warn_hcvp (xo_handle_t *xop, int as_warning, int code, 396 const char *fmt, va_list vap) 397{ 398 xo_emit_warn_hcv(xop, as_warning, code, fmt, vap); 399} 400 401PRINTFLIKE(3, 4) 402static inline void 403xo_emit_warn_hcp (xo_handle_t *xop, int code, const char *fmt, ...) 404{ 405 va_list vap; 406 va_start(vap, fmt); 407 xo_emit_warn_hcv(xop, 1, code, fmt, vap); 408 va_end(vap); 409} 410 411PRINTFLIKE(2, 3) 412static inline void 413xo_emit_warn_cp (int code, const char *fmt, ...) 414{ 415 va_list vap; 416 va_start(vap, fmt); 417 xo_emit_warn_hcv(NULL, 1, code, fmt, vap); 418 va_end(vap); 419} 420 421PRINTFLIKE(1, 2) 422static inline void 423xo_emit_warn_p (const char *fmt, ...) 424{ 425 int code = errno; 426 va_list vap; 427 va_start(vap, fmt); 428 xo_emit_warn_hcv(NULL, 1, code, fmt, vap); 429 va_end(vap); 430} 431 432PRINTFLIKE(1, 2) 433static inline void 434xo_emit_warnx_p (const char *fmt, ...) 435{ 436 va_list vap; 437 va_start(vap, fmt); 438 xo_emit_warn_hcv(NULL, 1, -1, fmt, vap); 439 va_end(vap); 440} 441 442NORETURN PRINTFLIKE(2, 3) 443static inline void 444xo_emit_err_p (int eval, const char *fmt, ...) 445{ 446 int code = errno; 447 va_list vap; 448 va_start(vap, fmt); 449 xo_emit_warn_hcv(NULL, 0, code, fmt, vap); 450 va_end(vap); 451 452 exit(eval); 453} 454 455PRINTFLIKE(2, 3) 456static inline void 457xo_emit_errx_p (int eval, const char *fmt, ...) 458{ 459 va_list vap; 460 va_start(vap, fmt); 461 xo_emit_warn_hcv(NULL, 0, -1, fmt, vap); 462 va_end(vap); 463 exit(eval); 464} 465 466PRINTFLIKE(3, 4) 467static inline void 468xo_emit_errc_p (int eval, int code, const char *fmt, ...) 469{ 470 va_list vap; 471 va_start(vap, fmt); 472 xo_emit_warn_hcv(NULL, 0, code, fmt, vap); 473 va_end(vap); 474 exit(eval); 475} 476 477void 478xo_emit_err_v (int eval, int code, const char *fmt, va_list vap) NORETURN PRINTFLIKE(3, 0); 479 480void 481xo_no_setlocale (void); 482 483/** 484 * @brief Lift libxo-specific arguments from a set of arguments 485 * 486 * libxo-enable programs typically use command line options to enable 487 * all the nifty-cool libxo features. xo_parse_args() makes this simple 488 * by pre-processing the command line arguments given to main(), handling 489 * and removing the libxo-specific ones, meaning anything starting with 490 * "--libxo". A full description of these arguments is in the base 491 * documentation. 492 * @param[in] argc Number of arguments (ala #main()) 493 * @param[in] argc Array of argument strings (ala #main()) 494 * @return New number of arguments, or -1 for failure. 495 */ 496int 497xo_parse_args (int argc, char **argv); 498 499/** 500 * This is the "magic" number returned by libxo-supporting commands 501 * when passed the equally magic "--libxo-check" option. If you 502 * return this, we can (unsafely) assume that since you know the magic 503 * handshake, you'll happily handle future --libxo options and not do 504 * something violent like reboot the box or create another hole in the 505 * ozone layer. 506 */ 507#define XO_HAS_LIBXO 121 508 509/** 510 * externs for libxo's version number strings 511 */ 512extern const char xo_version[]; /** Base version triple string */ 513extern const char xo_version_extra[]; /** Extra version magic content */ 514 515/** 516 * @brief Dump the internal stack of a libxo handle. 517 * 518 * This diagnostic function is something I will ask you to call from 519 * your program when you write to tell me libxo has gone bat-stink 520 * crazy and has discarded your list or container or content. Output 521 * content will be what we lovingly call "developer entertainment". 522 * @param[in] xop A valid libxo handle, or NULL for the default handle 523 */ 524void 525xo_dump_stack (xo_handle_t *xop); 526 527/** 528 * @brief Recode the name of the program, suitable for error output. 529 * 530 * libxo will record the given name for use while generating error 531 * messages. The contents are not copied, so the value must continue 532 * to point to a valid memory location. This allows the caller to change 533 * the value, but requires the caller to manage the memory. Typically 534 * this is called with argv[0] from main(). 535 * @param[in] name The name of the current application program 536 */ 537void 538xo_set_program (const char *name); 539 540/** 541 * @brief Add a version string to the output, where possible. 542 * 543 * Adds a version number to the output, suitable for tracking 544 * changes in the content. This is only important for the "encoding" 545 * format styles (XML and JSON) and allows a user of the data to 546 * discern which version of the data model is in use. 547 * @param[in] version The version number, encoded as a string 548 */ 549void 550xo_set_version (const char *version); 551 552/** 553 * #xo_set_version with a handle. 554 * @param[in] xop A valid libxo handle, or NULL for the default handle 555 * @param[in] version The version number, encoded as a string 556 */ 557void 558xo_set_version_h (xo_handle_t *xop, const char *version); 559 560void 561xo_open_log (const char *ident, int logopt, int facility); 562 563void 564xo_close_log (void); 565 566int 567xo_set_logmask (int maskpri); 568 569void 570xo_set_unit_test_mode (int value); 571 572void 573xo_syslog (int priority, const char *name, const char *message, ...); 574 575void 576xo_vsyslog (int priority, const char *name, const char *message, va_list args); 577 578typedef void (*xo_syslog_open_t)(void); 579typedef void (*xo_syslog_send_t)(const char *full_msg, 580 const char *v0_hdr, const char *text_only); 581typedef void (*xo_syslog_close_t)(void); 582 583void 584xo_set_syslog_handler (xo_syslog_open_t open_func, xo_syslog_send_t send_func, 585 xo_syslog_close_t close_func); 586 587void 588xo_set_syslog_enterprise_id (unsigned short eid); 589 590typedef void (*xo_simplify_field_func_t)(const char *, unsigned, int); 591 592char * 593xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers, 594 xo_simplify_field_func_t field_cb); 595
| 263int 264xo_open_container_h (xo_handle_t *xop, const char *name); 265 266int 267xo_open_container (const char *name); 268 269int 270xo_open_container_hd (xo_handle_t *xop, const char *name); 271 272int 273xo_open_container_d (const char *name); 274 275int 276xo_close_container_h (xo_handle_t *xop, const char *name); 277 278int 279xo_close_container (const char *name); 280 281int 282xo_close_container_hd (xo_handle_t *xop); 283 284int 285xo_close_container_d (void); 286 287int 288xo_open_list_h (xo_handle_t *xop, const char *name); 289 290int 291xo_open_list (const char *name); 292 293int 294xo_open_list_hd (xo_handle_t *xop, const char *name); 295 296int 297xo_open_list_d (const char *name); 298 299int 300xo_close_list_h (xo_handle_t *xop, const char *name); 301 302int 303xo_close_list (const char *name); 304 305int 306xo_close_list_hd (xo_handle_t *xop); 307 308int 309xo_close_list_d (void); 310 311int 312xo_open_instance_h (xo_handle_t *xop, const char *name); 313 314int 315xo_open_instance (const char *name); 316 317int 318xo_open_instance_hd (xo_handle_t *xop, const char *name); 319 320int 321xo_open_instance_d (const char *name); 322 323int 324xo_close_instance_h (xo_handle_t *xop, const char *name); 325 326int 327xo_close_instance (const char *name); 328 329int 330xo_close_instance_hd (xo_handle_t *xop); 331 332int 333xo_close_instance_d (void); 334 335int 336xo_open_marker_h (xo_handle_t *xop, const char *name); 337 338int 339xo_open_marker (const char *name); 340 341int 342xo_close_marker_h (xo_handle_t *xop, const char *name); 343 344int 345xo_close_marker (const char *name); 346 347int 348xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...); 349 350int 351xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap); 352 353int 354xo_attr (const char *name, const char *fmt, ...); 355 356void 357xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap); 358 359void 360xo_error_h (xo_handle_t *xop, const char *fmt, ...); 361 362void 363xo_error (const char *fmt, ...); 364 365int 366xo_flush_h (xo_handle_t *xop); 367 368int 369xo_flush (void); 370 371int 372xo_finish_h (xo_handle_t *xop); 373 374int 375xo_finish (void); 376 377void 378xo_finish_atexit (void); 379 380void 381xo_set_leading_xpath (xo_handle_t *xop, const char *path); 382 383void 384xo_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4); 385 386void 387xo_warn_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3); 388 389void 390xo_warn (const char *fmt, ...) PRINTFLIKE(1, 2); 391 392void 393xo_warnx (const char *fmt, ...) PRINTFLIKE(1, 2); 394 395void 396xo_err (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3); 397 398void 399xo_errx (int eval, const char *fmt, ...) NORETURN PRINTFLIKE(2, 3); 400 401void 402xo_errc (int eval, int code, const char *fmt, ...) NORETURN PRINTFLIKE(3, 4); 403 404void 405xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap) PRINTFLIKE(3, 0); 406 407void 408xo_message_hc (xo_handle_t *xop, int code, const char *fmt, ...) PRINTFLIKE(3, 4); 409 410void 411xo_message_c (int code, const char *fmt, ...) PRINTFLIKE(2, 3); 412 413void 414xo_message_e (const char *fmt, ...) PRINTFLIKE(1, 2); 415 416void 417xo_message (const char *fmt, ...) PRINTFLIKE(1, 2); 418 419void 420xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code, 421 const char *fmt, va_list vap); 422 423void 424xo_emit_warn_hc (xo_handle_t *xop, int code, const char *fmt, ...); 425 426void 427xo_emit_warn_c (int code, const char *fmt, ...); 428 429void 430xo_emit_warn (const char *fmt, ...); 431 432void 433xo_emit_warnx (const char *fmt, ...); 434 435void 436xo_emit_err (int eval, const char *fmt, ...) NORETURN; 437 438void 439xo_emit_errx (int eval, const char *fmt, ...) NORETURN; 440 441void 442xo_emit_errc (int eval, int code, const char *fmt, ...) NORETURN; 443 444PRINTFLIKE(4, 0) 445static inline void 446xo_emit_warn_hcvp (xo_handle_t *xop, int as_warning, int code, 447 const char *fmt, va_list vap) 448{ 449 xo_emit_warn_hcv(xop, as_warning, code, fmt, vap); 450} 451 452PRINTFLIKE(3, 4) 453static inline void 454xo_emit_warn_hcp (xo_handle_t *xop, int code, const char *fmt, ...) 455{ 456 va_list vap; 457 va_start(vap, fmt); 458 xo_emit_warn_hcv(xop, 1, code, fmt, vap); 459 va_end(vap); 460} 461 462PRINTFLIKE(2, 3) 463static inline void 464xo_emit_warn_cp (int code, const char *fmt, ...) 465{ 466 va_list vap; 467 va_start(vap, fmt); 468 xo_emit_warn_hcv(NULL, 1, code, fmt, vap); 469 va_end(vap); 470} 471 472PRINTFLIKE(1, 2) 473static inline void 474xo_emit_warn_p (const char *fmt, ...) 475{ 476 int code = errno; 477 va_list vap; 478 va_start(vap, fmt); 479 xo_emit_warn_hcv(NULL, 1, code, fmt, vap); 480 va_end(vap); 481} 482 483PRINTFLIKE(1, 2) 484static inline void 485xo_emit_warnx_p (const char *fmt, ...) 486{ 487 va_list vap; 488 va_start(vap, fmt); 489 xo_emit_warn_hcv(NULL, 1, -1, fmt, vap); 490 va_end(vap); 491} 492 493NORETURN PRINTFLIKE(2, 3) 494static inline void 495xo_emit_err_p (int eval, const char *fmt, ...) 496{ 497 int code = errno; 498 va_list vap; 499 va_start(vap, fmt); 500 xo_emit_warn_hcv(NULL, 0, code, fmt, vap); 501 va_end(vap); 502 503 exit(eval); 504} 505 506PRINTFLIKE(2, 3) 507static inline void 508xo_emit_errx_p (int eval, const char *fmt, ...) 509{ 510 va_list vap; 511 va_start(vap, fmt); 512 xo_emit_warn_hcv(NULL, 0, -1, fmt, vap); 513 va_end(vap); 514 exit(eval); 515} 516 517PRINTFLIKE(3, 4) 518static inline void 519xo_emit_errc_p (int eval, int code, const char *fmt, ...) 520{ 521 va_list vap; 522 va_start(vap, fmt); 523 xo_emit_warn_hcv(NULL, 0, code, fmt, vap); 524 va_end(vap); 525 exit(eval); 526} 527 528void 529xo_emit_err_v (int eval, int code, const char *fmt, va_list vap) NORETURN PRINTFLIKE(3, 0); 530 531void 532xo_no_setlocale (void); 533 534/** 535 * @brief Lift libxo-specific arguments from a set of arguments 536 * 537 * libxo-enable programs typically use command line options to enable 538 * all the nifty-cool libxo features. xo_parse_args() makes this simple 539 * by pre-processing the command line arguments given to main(), handling 540 * and removing the libxo-specific ones, meaning anything starting with 541 * "--libxo". A full description of these arguments is in the base 542 * documentation. 543 * @param[in] argc Number of arguments (ala #main()) 544 * @param[in] argc Array of argument strings (ala #main()) 545 * @return New number of arguments, or -1 for failure. 546 */ 547int 548xo_parse_args (int argc, char **argv); 549 550/** 551 * This is the "magic" number returned by libxo-supporting commands 552 * when passed the equally magic "--libxo-check" option. If you 553 * return this, we can (unsafely) assume that since you know the magic 554 * handshake, you'll happily handle future --libxo options and not do 555 * something violent like reboot the box or create another hole in the 556 * ozone layer. 557 */ 558#define XO_HAS_LIBXO 121 559 560/** 561 * externs for libxo's version number strings 562 */ 563extern const char xo_version[]; /** Base version triple string */ 564extern const char xo_version_extra[]; /** Extra version magic content */ 565 566/** 567 * @brief Dump the internal stack of a libxo handle. 568 * 569 * This diagnostic function is something I will ask you to call from 570 * your program when you write to tell me libxo has gone bat-stink 571 * crazy and has discarded your list or container or content. Output 572 * content will be what we lovingly call "developer entertainment". 573 * @param[in] xop A valid libxo handle, or NULL for the default handle 574 */ 575void 576xo_dump_stack (xo_handle_t *xop); 577 578/** 579 * @brief Recode the name of the program, suitable for error output. 580 * 581 * libxo will record the given name for use while generating error 582 * messages. The contents are not copied, so the value must continue 583 * to point to a valid memory location. This allows the caller to change 584 * the value, but requires the caller to manage the memory. Typically 585 * this is called with argv[0] from main(). 586 * @param[in] name The name of the current application program 587 */ 588void 589xo_set_program (const char *name); 590 591/** 592 * @brief Add a version string to the output, where possible. 593 * 594 * Adds a version number to the output, suitable for tracking 595 * changes in the content. This is only important for the "encoding" 596 * format styles (XML and JSON) and allows a user of the data to 597 * discern which version of the data model is in use. 598 * @param[in] version The version number, encoded as a string 599 */ 600void 601xo_set_version (const char *version); 602 603/** 604 * #xo_set_version with a handle. 605 * @param[in] xop A valid libxo handle, or NULL for the default handle 606 * @param[in] version The version number, encoded as a string 607 */ 608void 609xo_set_version_h (xo_handle_t *xop, const char *version); 610 611void 612xo_open_log (const char *ident, int logopt, int facility); 613 614void 615xo_close_log (void); 616 617int 618xo_set_logmask (int maskpri); 619 620void 621xo_set_unit_test_mode (int value); 622 623void 624xo_syslog (int priority, const char *name, const char *message, ...); 625 626void 627xo_vsyslog (int priority, const char *name, const char *message, va_list args); 628 629typedef void (*xo_syslog_open_t)(void); 630typedef void (*xo_syslog_send_t)(const char *full_msg, 631 const char *v0_hdr, const char *text_only); 632typedef void (*xo_syslog_close_t)(void); 633 634void 635xo_set_syslog_handler (xo_syslog_open_t open_func, xo_syslog_send_t send_func, 636 xo_syslog_close_t close_func); 637 638void 639xo_set_syslog_enterprise_id (unsigned short eid); 640 641typedef void (*xo_simplify_field_func_t)(const char *, unsigned, int); 642 643char * 644xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers, 645 xo_simplify_field_func_t field_cb); 646
|