19 fprintf(stderr,
"arb_2_ascii - ARB database binary to ascii converter\n");
21 bool recovery =
false;
22 char compressionFlag[] =
"\0x";
23 bool help_requested =
false;
26 if (strcmp(argv[1],
"-r") == 0) {
30 else if (strcmp(argv[1],
"-h") == 0 || strcmp(argv[1],
"--help") == 0) {
31 help_requested =
true;
34 else if (strncmp(argv[1],
"-C", 2) == 0) {
35 compressionFlag[0] = argv[1][2];
36 compressionFlag[1] = 0;
42 if (!argv[1]) help_requested =
true;
47 "Usage: arb_2_ascii [-r] [-C<type>] <source.arb> [<dest.arb>|-]\n"
48 "Purpose: Converts a database to ascii format\n"
50 "if '-r' (=recovery) is specified, try to fix problems while reading <source.arb>.\n"
52 "if '-C' (=Compress) is specified, use extra compression\n"
53 " known <type>s: %s\n"
55 "if <dest.arb> is set, write to <dest.arb>\n"
56 "if the second parameter is '-' write to console.\n"
57 "else replace <source.arb> by ascii version (backup first)\n"
62 const char *readflags = recovery ?
"rwR" :
"rw";
63 char saveflags[] =
"a\0xx";
65 strcat(saveflags, compressionFlag);
70 const char *in = argv[1];
71 const char *out =
NULp;
79 if (!out || strcmp(out,
"-") == 0) {
80 strcat(saveflags,
"S");
85 error =
"Missing parameters";
94 error =
GB_save(gb_main, out, saveflags);
102 fprintf(stderr,
"arb_2_ascii: Error: %s\n", error);
GBDATA * GB_open(const char *path, const char *opent)
int ARB_main(int argc, char *argv[])
GB_ERROR GB_save(GBDATA *gb, const char *path, const char *savetype)
const char * GBS_global_string(const char *templat,...)
GB_ERROR GB_await_error()
static void error(const char *msg)
const char * GB_get_supported_compression_flags(bool verboose)
void ARB_redirect_handlers_to(FILE *errStream, FILE *outStream)
void GB_close(GBDATA *gbd)