Files
wc3re/shapdecode.cc

57 lines
1.1 KiB
C++

#include <cstdio>
#include <cstring>
#include <unistd.h>
#include "common.hh"
#include "util.hh"
#include "ShapDecoder.hh"
#include "IffFile.hh"
#include "ResourceProvider.hh"
void usage(char *argv0) {
fprintf(stderr, "Usage: %s [-h] file\n", argv0);
fprintf(stderr, "\tAttempt to decode the object stored in file\n");
fprintf(stderr, "\t-h\tPrint this help\n");
}
int main(int argc, char *argv[]) {
std::vector<std::string> specs;
{
int opt;
while ((opt = getopt(argc, argv, "h")) != -1) {
switch (opt) {
case 'h':
usage(argv[0]);
return 0;
default:
usage(argv[0]);
return 1;
}
}
if (optind >= argc) {
usage(argv[0]);
return 1;
}
while (optind < argc)
specs.push_back(argv[optind++]);
}
try {
for(auto& spec : specs)
auto shap = std::make_unique<ShapDecoder>(spec);
} catch (POSIXException &ex) {
fflush(stdout);
fprintf(stderr, "%s\n", ex.toString().c_str());
return 2;
} catch (Exception &ex) {
fflush(stdout);
fprintf(stderr, "%s\n", ex.toString().c_str());
return 3;
}
return 0;
}