FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
oaFileParser/src/main.cpp at master · EDDRSoftware/oaFileParser · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
EDDRSoftware
/
oaFileParser
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
16
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
oaFileParser
/
src
/
main.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
199 lines (179 loc) · 8.21 KB
Breadcrumbs
oaFileParser
/
src
/
main.cpp
Copy path
File metadata and controls
199 lines (179 loc) · 8.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
* MIT License
*
* Copyright (c) 2017 EDDR Software, LLC.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/*
* Changes:
* 2017-01-01: First & Last Name: What you did.
* 2017-05-28: Kevin Nesmith: Initial contribution.
*
*/
#
include
<
stdlib.h
>
#
include
<
cstdio
>
#
include
<
iostream
>
#
include
<
iomanip
>
#
include
<
cstring
>
#
include
"
oaFileParser.h
"
using
namespace
std
;
class
MyTestParser
:
public
oafp
::oaFileParser
{
protected:
virtual
void
onParsedPreface
(
unsigned
int
testBit,
unsigned
short
type,
unsigned
short
schema,
unsigned
long
offset,
unsigned
int
size,
unsigned
int
used) {
cout <<
"
File Preface Information:
"
<< endl;
cout <<
"
\t
testBit: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << testBit << endl;
cout <<
"
\t
type: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << type << endl;
cout <<
"
\t
schema: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << schema << endl;
cout <<
"
\t
offset: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << offset << endl;
cout <<
"
\t
size:
"
<< dec << size << endl;
cout <<
"
\t
used:
"
<< dec << used << endl;
};
virtual
void
onParsedTableInformation
(
unsigned
long
ids[],
unsigned
long
offsets[],
unsigned
long
sizes[],
unsigned
int
num) {
cout <<
"
Table Information:
"
<< endl;
for
(
int
i=
0
; i<num; ++i) {
cout <<
"
\t
table #
"
<<
setw
(
3
) << i <<
"
type: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
4
) << hex << ids[i] <<
"
offset: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
16
) <<
(hex) << offsets[i] <<
"
tableSize:
"
<< (dec) << sizes[i] << endl;
}
};
virtual
void
onParsedFlags
(
unsigned
int
flags) {
cout <<
"
Database Flags: 0x
"
<<
setw
(
8
) << hex << flags << endl;
};
virtual
void
onParsedTimeStamp
(
unsigned
int
timeStamp) {
cout <<
"
Database Timestamp:
"
<< timeStamp << endl;
};
virtual
void
onParsedLastSavedTime
(
unsigned
long
lsTime) {
cout <<
"
Database Last Saved Time:
"
<< endl;
struct
tm
*timeInfo;
timeInfo =
gmtime
((
time_t
*)&lsTime);
cout <<
"
\t
Time Raw: 0x
"
<< lsTime << endl;
cout <<
"
\t
GMT:
"
<<
asctime
(
timeInfo);
//
asctime puts the EOL for you.
timeInfo =
localtime
((
time_t
*)&lsTime);
cout <<
"
\t
Local Time:
"
<<
asctime
(timeInfo);
};
virtual
void
onParsedDatabaseMap
(
unsigned
long
ids[],
unsigned
int
types[],
unsigned
int
idCount,
unsigned
long
tblIds[],
unsigned
int
tblTypes[],
unsigned
int
tblCount) {
cout <<
"
Database Map
"
<< endl;
cout <<
"
\t
Number of ids:
"
<< idCount << endl;
for
(
int
i=
0
; i<idCount; ++i) {
cout <<
"
\t\t
ids: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << ids[i] <<
"
\t
types: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << types[i] << endl;
}
cout <<
"
\t
Number of tables:
"
<< tblCount << endl;
for
(
int
i=
0
; i<tblCount; ++i) {
cout <<
"
\t\t
table ids: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << tblIds[i] <<
"
\t
table types: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << tblTypes[i] << endl;
}
};
virtual
void
onParsedStringTable
(oafp::tableIndex table,
const
char
*buffer) {
cout <<
"
Database String Table:
"
<< endl;
cout <<
"
\t
Size:
"
<< table.
size
<< endl;
cout <<
"
\t
Used:
"
<< table.
used
<< endl;
cout <<
"
\t
Deleted:
"
<< table.
deleted
<< endl;
cout <<
"
\t
First:
"
<< table.
first
<< endl;
unsigned
int
b =
0
;
unsigned
int
l =
0
;
cout <<
"
\t
Strings:
"
;
while
(b<table.
used
) {
const
char
*ptr = &buffer[b];
l =
strlen
(ptr);
cout << ptr <<
"
|
"
;
b += l +
1
;
}
cout << endl;
};
virtual
void
onParsedCreateTime
(
unsigned
long
createTime) {
cout <<
"
Database Create Time:
"
<< endl;
struct
tm
*timeInfo;
unsigned
int
downTime[
2
];
//
Something going on with time time in versions of >=22.43
memcpy
(&downTime, &createTime,
sizeof
(downTime));
time_t
tt = downTime[
0
];
if
(tt==
0
) {
tt = downTime[
1
];
}
timeInfo =
gmtime
((
time_t
*)&tt);
//
cout << "\tCreate Time Raw: 0x" << createTime << endl;
cout <<
"
\t
Create Time Raw: 0x
"
<< tt << endl;
cout <<
"
\t
Create GMT:
"
<<
asctime
(
timeInfo);
//
asctime puts the EOL for you.
timeInfo =
localtime
((
time_t
*)&tt);
cout <<
"
\t
Create Local Time:
"
<<
asctime
(timeInfo);
};
virtual
void
onParsedDMandBuildName
(
unsigned
short
dataModelRev,
const
char
*buildName) {
cout <<
"
Database Data Model Revision:
"
<< endl;
cout <<
"
\t
Data Model Revision:
"
<< dataModelRev << endl;
cout <<
"
\t
Build Name:
"
<< buildName << endl;
};
virtual
void
onParsedBuildInformation
(
unsigned
short
appDataModelRev,
unsigned
short
kitDataModelRev,
unsigned
short
appAPIMinorRev,
unsigned
short
kitReleaseNum,
const
char
*appBuildName,
const
char
*kitBuildName,
const
char
*platforName) {
cout <<
"
Database Software Build Information:
"
<< endl;
cout <<
"
\t
AppDataModelRev:
"
<< appDataModelRev << endl;
cout <<
"
\t
KitDataModelRev:
"
<< kitDataModelRev << endl;
cout <<
"
\t
AppAPIMinorRev:
"
<< appAPIMinorRev << endl;
cout <<
"
\t
KitReleaseNum:
"
<< kitReleaseNum << endl;
cout <<
"
\t
AppBuildName:
"
<< appBuildName << endl;
cout <<
"
\t
KitBuildName:
"
<< kitBuildName << endl;
cout <<
"
\t
PlatforName:
"
<< platforName << endl;
};
virtual
void
onParsedDatabaseMapD
(
unsigned
long
ids[],
unsigned
int
types[],
unsigned
long
num) {
cout <<
"
Database Data Table Map Delta
"
<< endl;
cout <<
"
\t
Number of New Data Tables:
"
<< num << endl;
for
(
int
i=
0
; i<num; ++i) {
cout <<
"
\t\t
IDs: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << ids[i] <<
"
\t
Types: 0x
"
<<
setfill
(
'
0
'
) <<
setw
(
8
) << hex <<
setfill
(
'
0
'
) <<
setw
(
8
) << hex << types[i] << endl;
};
};
virtual
void
onParsedDatabaseMarker
(
unsigned
int
bitCheck) {
cout <<
"
Database EOD Marker:
"
<< endl;
cout <<
"
\t
Marker:
"
<< bitCheck << endl;
};
virtual
void
onParsedError
(
const
char
*error) {
cerr << error << endl;
};
};
//
****************************************************************************
//
main()
//
//
This is the top level function that tests the parser.
//
****************************************************************************
int
main
(
int
argc,
char
*argv[])
{
if
(argc<
2
) {
cerr <<
"
Missing .oa file as the only parameter.
"
<< endl;
cerr <<
"
Usage: ./testParser /path/to/file.oa
"
<< endl;
return
1
;
}
MyTestParser parser;
return
parser.
parse
(argv[
1
]);
}
Back
|
FazBrowse Home
|
New Git URL