| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use crate::bindings; |
| 5 |
|
| 6 |
use crate::error::StructuredError; |
| 7 |
|
| 8 |
use std::ffi::c_void; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
#[cfg(libxml_older_than_2_12)] |
| 13 |
pub unsafe extern "C" fn structured_error_handler(ctx: *mut c_void, error: bindings::xmlErrorPtr) { |
| 14 |
assert!(!ctx.is_null()); |
| 15 |
let errlog = unsafe { &mut *{ ctx as *mut Vec<StructuredError> } }; |
| 16 |
|
| 17 |
let error = unsafe { StructuredError::from_raw(error) }; |
| 18 |
|
| 19 |
errlog.push(error); |
| 20 |
} |
| 21 |
|
| 22 |
#[cfg(not(libxml_older_than_2_12))] |
| 23 |
pub unsafe extern "C" fn structured_error_handler(ctx: *mut c_void, error: *const bindings::xmlError) { |
| 24 |
assert!(!ctx.is_null()); |
| 25 |
let errlog = unsafe { &mut *{ ctx as *mut Vec<StructuredError> } }; |
| 26 |
|
| 27 |
let error = unsafe { StructuredError::from_raw(error) }; |
| 28 |
|
| 29 |
errlog.push(error); |
| 30 |
} |