X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=bin%2Fgedcom-sanitize.c;h=2698d41d4e7b9c0b353982c98ba9532c2d115555;hb=f8f253aa29e3c2561d325cb47cc17a727f76266e;hp=167019d68ecfc8ad3ec9669d476fdee10e401a29;hpb=bf9e55fae6324f24e55a6c155282e8f038f88c40;p=gedcom-parse.git diff --git a/bin/gedcom-sanitize.c b/bin/gedcom-sanitize.c index 167019d..2698d41 100644 --- a/bin/gedcom-sanitize.c +++ b/bin/gedcom-sanitize.c @@ -41,6 +41,8 @@ #define UNUSED #endif +#define PROG_NAME "GEDCOM_PARSE" + void show_help () { printf("Converts a GEDCOM file to strict standard GEDCOM\n\n"); @@ -50,6 +52,7 @@ void show_help () printf(" -dg Debug setting: only libgedcom debug messages\n"); printf(" -da Debug setting: libgedcom + yacc debug messages\n"); printf(" -e Extension to give to file name (default 'new')\n"); + printf(" -s Keep source string (otherwise: changed to GEDCOM_PARSE)\n"); printf("Errors, warnings, ... are sent to stdout\n"); } @@ -61,11 +64,56 @@ void gedcom_message_handler(Gedcom_msg_type type UNUSED, char *msg) printf("%s\n", converted); } +int update_header() +{ + struct header* head = NULL; + head = gom_get_header(); + if (head == NULL) + return 1; + else { + char* value; + int result, i; + + value = gom_set_string(&head->source.id, PROG_NAME); + if (value == NULL || strcmp (value, PROG_NAME)) + return 1; + + value = gom_set_string(&head->source.name, NULL); + if (value != NULL) + return 1; + + value = gom_set_string(&head->source.version, VERSION); + if (value == NULL || strcmp (value, VERSION)) + return 1; + + value = gom_set_string(&head->source.corporation.name, NULL); + if (value != NULL) + return 1; + + if (head->source.corporation.address) { + result = gom_delete_address(&head->source.corporation.address); + if (result != 0) + return 1; + } + + for (i=0; i<3; i++) { + if (head->source.corporation.phone[i]) { + value = gom_set_string(&head->source.corporation.phone[i], NULL); + if (value != NULL) + return 1; + } + } + + return 0; + } +} + int main(int argc, char* argv[]) { Gedcom_err_mech mech = DEFER_FAIL; int compat_enabled = 1; int debug_level = 0; + int keep_source = 0; char* file_name = NULL; int result; char* extension = "new"; @@ -77,6 +125,8 @@ int main(int argc, char* argv[]) debug_level = 2; else if (!strncmp(argv[i], "-dg", 4)) debug_level = 1; + else if (!strncmp(argv[i], "-s", 3)) + keep_source = 1; else if (!strncmp(argv[i], "-e", 3)) { if (i