2 This program is free software; you can redistribute it and/or modify
3 it under the terms of the GNU General Public License as published by
4 the Free Software Foundation; either version 2 of the License, or
5 (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License along
13 with this program; if not, write to the Free Software Foundation, Inc.,
14 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 #include "c1cobfile.h"
19 std::string
readpascalstring(std::istream
&s
) {
21 uint8 a
; s
.read((char *)&a
, 1);
27 boost::scoped_array
<char> x(new char[size
]);
29 s
.read(x
.get(), size
);
30 return std::string(x
.get(), size
);
33 c1cobfile::c1cobfile(std::ifstream
&s
) {
36 uint16 version
= read16(s
);
40 //QMessageBox::warning(this, tr("Failed to open"), tr("Version %1 is not supported").arg((int)version));
44 no_objects
= read16(s
);
45 expire_month
= read32(s
);
46 expire_day
= read32(s
);
47 expire_year
= read32(s
);
48 uint16 noscripts
= read16(s
);
49 uint16 noimports
= read16(s
);
50 no_objects_used
= read16(s
);
51 uint16 reserved_zero
= read16(s
);
52 assert(reserved_zero
== 0);
54 for (unsigned int i
= 0; i
< noscripts
; i
++)
55 scripts
.push_back(readpascalstring(s
));
56 for (unsigned int i
= 0; i
< noimports
; i
++)
57 imports
.push_back(readpascalstring(s
));
59 imagewidth
= read32(s
);
60 imageheight
= read32(s
);
61 uint16 secondimagewidth
= read16(s
);
62 assert(imagewidth
== secondimagewidth
);
63 imagedata
.reset(new char[imagewidth
* imageheight
]);
64 s
.read(imagedata
.get(), imagewidth
* imageheight
);
65 name
= readpascalstring(s
);