Skip to main content

Module globals

Module globals 

Source
Expand description

Global state management (§57, §85 Phase 1).

Manages all library-wide global state:

  • Parser defaults (validity checking, entity substitution, blanks, etc.)
  • Generic and structured error callbacks
  • Catalog defaults
  • Memory hooks (connects to allocator.rs)
  • Thread-local state for errors
  • Initialization/cleanup reference counting

§UPSTREAM-PARITY

libxml2 has many global variables that control default parser behavior. These are exposed as public ABI symbols that applications can read/write directly. We use atomic operations for thread safety while maintaining the same observable semantics.

§Thread safety

All global state uses atomic operations or parking_lot locks. Error state is thread-local via thread_local!.

§Phase 1 status

Complete — all global state management is implemented. Future phases may add historical version-specific behavior.

Functions§

cleanup_parser
Clean up the parser library.
cleanup_threads
Clean up threading support.
get_catalog_defaults
Get the catalog default allow value.
get_do_warnings_default
Get the default warnings value.
get_generic_error_ctx
Get the generic error handler context.
get_generic_error_func
Get the generic error handler function pointer.
get_get_warnings_default
Get the get warnings default.
get_indent_tree_output
Get the indent tree output default.
get_keep_blanks_default
Get the keep blanks default value.
get_last_error
Get the last error for this thread.
get_load_ext_dtd_default
Get the load external DTD default value.
get_pedantic_parser_default
Get the pedantic parser default.
get_save_no_empty_tags
Get the save no empty tags default.
get_structured_error_ctx
Get the structured error handler context.
get_structured_error_func
Get the structured error handler function pointer.
get_substitute_entities_default
Get the substitute entities default.
get_validity_checking_default
Get the default validity checking value.
init_parser
Initialize the parser library.
init_ref_count
Get the current initialization reference count.
init_threads
Initialize threading support.
reset_last_error
Reset the last error for this thread.
set_catalog_defaults
Set the catalog default allow value.
set_do_warnings_default
Set the default warnings value.
set_generic_error_func
Set the generic error handler.
set_get_warnings_default
Set the get warnings default.
set_indent_tree_output
Set the indent tree output default.
set_keep_blanks_default
Set the keep blanks default value.
set_last_error
Set the last error for this thread.
set_load_ext_dtd_default
Set the load external DTD default value.
set_pedantic_parser_default
Set the pedantic parser default.
set_save_no_empty_tags
Set the save no empty tags default.
set_structured_error_func
Set the structured error handler.
set_substitute_entities_default
Set the substitute entities default.
set_validity_checking_default
Set the default validity checking value.
threads_initialized
Check whether threads have been initialized.
with_last_error
Get a reference to the last error (for structured error callback).