X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=t%2Fsrc%2Fgom_write.c;h=cb28844aa81f08b5d96dda6f885c992a27015f6d;hb=8a73dd117ad3bf06a89595f7cd8fdef45c231a6e;hp=cdf8b0638ed966a9c9e338b9d8069a0f7e918975;hpb=26b300c73fd81fea51f15d66c0e94d8e32728660;p=gedcom-parse.git diff --git a/t/src/gom_write.c b/t/src/gom_write.c index cdf8b06..cb28844 100644 --- a/t/src/gom_write.c +++ b/t/src/gom_write.c @@ -51,6 +51,7 @@ void show_help () printf(" -h Show this help text\n"); printf(" -q No output to standard output\n"); printf(" -o File to generate errors to (def. testgedcom.out)\n"); + printf(" -i File to read gedcom from (default: new file)\n"); printf(" -w File to write gedcom to (def. %s)\n", WRITE_GEDCOM); printf(" -e Encoding (UNICODE, ASCII, ANSEL, ...: see gedcom.enc)\n"); printf(" -u Encoding details for Unicode\n"); @@ -91,6 +92,7 @@ int main(int argc, char* argv[]) int result; int total_conv_fails = 0; char* outfilename = NULL; + char* infilename = NULL; char* gedfilename = WRITE_GEDCOM; char* encoding = "ASCII"; Encoding enc = ONE_BYTE; @@ -129,6 +131,17 @@ int main(int argc, char* argv[]) exit(1); } } + else if (!strncmp(argv[i], "-i", 3)) { + i++; + if (i < argc) { + infilename = argv[i]; + } + else { + printf ("Missing input file name\n"); + show_help(); + exit(1); + } + } else if (!strncmp(argv[i], "-e", 3)) { i++; if (i < argc) { @@ -201,10 +214,15 @@ int main(int argc, char* argv[]) gedcom_write_set_line_terminator(end); output_open(outfilename); - - result = gom_new_model(); - if (result == 0) - result |= update_header(encoding); + + if (infilename) { + result = gom_parse_file(infilename); + } + else { + result = gom_new_model(); + if (result == 0) + result |= update_header(encoding); + } if (result == 0) result |= gom_write_file(gedfilename, &total_conv_fails); if (result == 0 && total_conv_fails == 0) {