00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "lwoScan.h"
00016
00017 #include "lwoInputFile.h"
00018 #include "lwoChunk.h"
00019 #include "config_lwo.h"
00020 #include "pystub.h"
00021
00022
00023
00024
00025
00026
00027 LwoScan::
00028 LwoScan() {
00029 clear_runlines();
00030 add_runline("[opts] input.lwo");
00031
00032 set_program_description
00033 ("This program simply reads a Lightwave object file and dumps its "
00034 "contents to standard output. It's mainly useful for debugging "
00035 "problems with lwo2egg.");
00036 }
00037
00038
00039
00040
00041
00042
00043 void LwoScan::
00044 run() {
00045 LwoInputFile in;
00046 if (!in.open_read(_input_filename)) {
00047 nout << "Unable to open " << _input_filename << "\n";
00048 exit(1);
00049 }
00050
00051 PT(IffChunk) chunk = in.get_chunk();
00052 if (chunk == (IffChunk *)NULL) {
00053 nout << "Unable to read file.\n";
00054 } else {
00055 while (chunk != (IffChunk *)NULL) {
00056 chunk->write(cout, 0);
00057 chunk = in.get_chunk();
00058 }
00059 }
00060 }
00061
00062
00063
00064
00065
00066
00067 bool LwoScan::
00068 handle_args(ProgramBase::Args &args) {
00069 if (args.empty()) {
00070 nout << "You must specify the Lightwave object file to read on the command line.\n";
00071 return false;
00072 }
00073 if (args.size() != 1) {
00074 nout << "You may specify only one Lightwave object file to read on the command line.\n";
00075 return false;
00076 }
00077
00078 _input_filename = args[0];
00079
00080 return true;
00081 }
00082
00083
00084 int
00085 main(int argc, char *argv[]) {
00086
00087 pystub();
00088
00089 init_liblwo();
00090 LwoScan prog;
00091 prog.parse_command_line(argc, argv);
00092 prog.run();
00093 return 0;
00094 }