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