forked from klayoutmatthias/dump_oas_gds2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dump_oas.cc
98 lines (79 loc) · 2.57 KB
/
dump_oas.cc
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
/*
KLayout Layout Viewer
Copyright (C) 2013-2018 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dbOASISDumper.h"
#include <iostream>
const char *version = "0.2";
/**
* @brief Print usage
*/
void syntax ()
{
std::cout <<
"dump_oas - An OASIS file disassembly tool" << std::endl <<
std::endl <<
"Usage: dump_oas [options] [OASIS file]" << std::endl <<
std::endl <<
"Options:" << std::endl <<
" -n <width> number of bytes to print per line" << std::endl <<
" -s short: abbreviate hex dump with more than \"width\" bytes" << std::endl <<
std::endl <<
"Version " << version << std::endl <<
std::endl <<
"Author: Matthias Köfferlein, 2013" << std::endl <<
"Distributed under GPL V2 or later" << std::endl;
}
/**
* @brief The main function
*/
int main (int argc, const char *argv[])
{
try {
bool short_mode = false;
int width = 8;
std::string input;
for (int i = 1; i < argc; ++i) {
std::string a = argv [i];
if (a == "-h" || a == "--help") {
syntax ();
return 1;
} else if (a == "-n" && i < argc - 1) {
++i;
tl::from_string (argv [i], width);
if (width < 1 || width > 100000) {
throw tl::Exception (tl::translate ("Invalid width specification for -n command line option"));
}
} else if (a == "-s") {
short_mode = true;
} else if (a [0] == '-') {
throw tl::Exception (tl::translate ("Unknown option ") + a);
} else {
input = a;
}
}
if (input.empty ()) {
throw tl::Exception (tl::translate ("Input file missing"));
}
tl::InputZLibFile file (input);
db::OASISDumper dumper (file);
dumper.short_mode (short_mode);
dumper.set_width (width);
dumper.dump ();
} catch (tl::Exception &ex) {
std::cerr << "*** ERROR: " << ex.msg () << std::endl;
return 2;
}
return 0;
}