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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use nom::{bytes::streaming::take, number::complete::be_u16, IResult};
use crate::util::{Bytes16, Bytes32};
use super::{bytes16, bytes32};
#[derive(Debug)]
pub struct SysP {
space_width: u16,
letter_spacing: u16,
line_distance: u16,
index_distance: u16,
margin_left: u16,
margin_right: u16,
header: u16,
footer: u16,
page_length: u16,
page_numbering: Bytes16,
format_options: Bytes16,
opts_2: Bytes16,
opts_3: Bytes16,
opts_4: Bytes32,
}
pub fn parse_sysp(input: &[u8]) -> IResult<&[u8], SysP> {
let (input, _) = take(0x50usize)(input)?;
let (input, space_width) = be_u16(input)?;
let (input, letter_spacing) = be_u16(input)?;
let (input, line_distance) = be_u16(input)?;
let (input, index_distance) = be_u16(input)?;
let (input, margin_left) = be_u16(input)?;
let (input, margin_right) = be_u16(input)?;
let (input, header) = be_u16(input)?;
let (input, footer) = be_u16(input)?;
let (input, page_length) = be_u16(input)?;
let (input, page_numbering) = bytes16(input)?;
let (input, format_options) = bytes16(input)?;
let (input, opts_2) = bytes16(input)?;
let (input, opts_3) = bytes16(input)?;
let (input, opts_4) = bytes32(input)?;
Ok((
input,
SysP {
space_width,
letter_spacing,
line_distance,
index_distance,
margin_left,
margin_right,
header,
footer,
page_length,
page_numbering,
format_options,
opts_2,
opts_3,
opts_4,
},
))
}