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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use ansi_term::Color;
use std::process;
//use super::report_d88::ReportD88;
use crate::report_d88::ReportD88;
/// Print Error Message
///
#[allow(non_snake_case)]
pub fn ERROR(err_mes: &str) {
println!("[ERROR] {}", err_mes);
process::exit(0);
}
impl ReportD88 {
/// Print D88 File Header Titke Bar(Helper function)
///
/// タイトルバーを表示(D88ファイルヘッダ)
///
pub fn print_d88_file_header_title_bar(&self) {
println!("D88 File Header Summary");
}
/// Print Track Offset Table Bar(Helper function)
///
/// タイトルバーを表示(Track)
///
pub fn print_track_offset_table_bar(&self) {
println!("Track Offset Table");
println!();
println!("Track No.");
println!("hex dec +0 +1 +2 +3 +4 +5 +6 +7 ");
print!("--- ---- ------ ------ ------ ------ ------ ------ ------ ------");
}
/// Print Sector Summary Bar(Helper function)
///
/// タイトルバーを表示(Sector)
///
pub fn print_sector_summary_bar(&self) {
println!("Sector Summary");
println!();
println!("Track Side Sector Data Header Parameter");
println!("hex dec No. No. Num Offset ");
println!("--- ---- --- --- --- ------- ---------------------------------- ...");
}
/// Print Offset Bar(Helper function)
///
/// タイトルバーを表示(Sector)
///
pub fn print_offset_bar(&self) {
println!("Offset +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f ");
println!("------ ----------------------------------------------- ");
}
/// Print 16byte (Helper function)
///
/// 16byte表示
/// D88ファイルのオフセット情報`offset` と 16byte生データ`buf16`から、16byteを整形して表示する。
///
/// # Argument
///
/// * `buf16` Slice to 16 byte Buffer
/// * `offset` Offset at D88 Disk File
/// * `color` Color
///
/// # Return
///
/// * Return the value of `offset` plus 16.
///
pub fn print_16byte(&self, buf16: &[u8], offset: u64, color: ansi_term::Color) -> u64 {
self.print_16byte_len(buf16, offset, color, 16)
}
/// Print 16byte (Helper function)
///
/// 16byte表示
/// D88ファイルのオフセット情報`offset` と 16byte生データ`buf16`から、(length)byteを整形して表示する。
///
/// # Argument
///
/// * `buf16` Slice to 16 byte Buffer
/// * `offset` Offset at D88 Disk File
/// * `color` Color
/// * `length`
///
/// # Return
///
/// * Return the value of `offset` plus 16.
///
#[allow(clippy::format_in_format_args)]
pub fn print_16byte_len(
&self,
buf16: &[u8],
offset: u64,
color: ansi_term::Color,
length: usize,
) -> u64 {
let mut char_pat = [
'.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.',
];
assert!(length <= 16); // length = 0-16
// Offset Address
//
if !self.nocolor_flg {
print!("{} ", Color::Cyan.paint(&(format!("{:06x}", offset))));
} else {
//#[allow(clippy::format_in_format_args)]
print!("{} ", format!("{:06x}", offset));
}
// 16 byte
//
let mut byte16_str = String::from("");
for i in 0..length {
unsafe {
if libc::isprint(buf16[i] as libc::c_int) != 0 {
char_pat[i] = buf16[i] as char;
}
}
byte16_str.push_str(&(format!("{:02x} ", buf16[i])));
}
//print!("{}", Color::White.paint(byte16_str));
if !self.nocolor_flg {
print!("{}", color.paint(byte16_str));
} else {
print!("{}", byte16_str);
}
// Character
//
for p in char_pat.iter() {
print!("{}", p);
}
print!(" ");
//
//
offset + length as u64
}
}