1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use std::ffi::{CStr, CString};
use errors::{ErrorKind, Result};
use io::IoStack;
use status::StatusBackend;
use super::{IoEventBackend, ExecutionState, TectonicBridgeApi};
use super::tex::TexResult;
pub struct BibtexEngine {
}
impl BibtexEngine {
pub fn new () -> BibtexEngine {
BibtexEngine {}
}
pub fn process (&mut self, io: &mut IoStack,
events: &mut IoEventBackend,
status: &mut StatusBackend, aux: &str) -> Result<TexResult> {
let caux = CString::new(aux)?;
let state = ExecutionState::new(io, events, status);
let bridge = TectonicBridgeApi::new(&state);
unsafe {
match super::bibtex_simple_main(&bridge, caux.as_ptr()) {
0 => Ok(TexResult::Spotless),
1 => Ok(TexResult::Warnings),
2 => Ok(TexResult::Errors),
3 => {
Err(ErrorKind::Msg("unspecified fatal bibtex error".into()).into())
},
99 => {
let ptr = super::tt_get_error_message();
let msg = CStr::from_ptr(ptr).to_string_lossy().into_owned();
Err(ErrorKind::Msg(msg).into())
},
x => Err(ErrorKind::Msg(format!("internal error: unexpected 'history' value {}", x)).into())
}
}
}
}