43
43
, STRING *ptag, STRING *pval, STRING *pmsg);
44
44
static NODE do_first_fp_to_node(FILE *fp, BOOLEAN list, XLAT tt
45
45
, STRING *pmsg, BOOLEAN *peof);
46
static void prefix_file(FILE *fp, XLAT tt);
46
47
static BOOLEAN string_to_line(STRING *ps, INT *plev, STRING *pxref,
47
48
STRING *ptag, STRING *pval, STRING *pmsg);
48
49
static STRING swrite_node(INT levl, NODE node, STRING p);
49
50
static STRING swrite_nodes(INT levl, NODE node, STRING p);
50
static BOOLEAN write_bom(void);
51
static void write_fam_to_file(NODE fam, CNSTRING file, BOOLEAN bom);
52
static void write_indi_to_file(NODE indi, CNSTRING file, BOOLEAN bom);
51
static BOOLEAN should_write_bom(void);
52
static void write_fam_to_file(NODE fam, CNSTRING file);
53
static void write_indi_to_file(NODE indi, CNSTRING file);
53
54
static void write_node(INT levl, FILE *fp, XLAT ttm,
54
55
NODE node, BOOLEAN indent);
645
646
/*=====================================
647
* prefix_file_for_edit - write BOM prefix to file if appropriate
648
* This handles prepending BOM (byte order mark) to UTF-8 files
649
*===================================*/
651
prefix_file_for_edit (FILE *fp)
653
XLAT ttmo = transl_get_predefined_xlat(MINED);
654
prefix_file(fp, ttmo);
656
/*=====================================
657
* prefix_file_for_gedcom - write BOM prefix to file if appropriate
658
* This handles prepending BOM (byte order mark) to UTF-8 files
659
*===================================*/
661
prefix_file_for_gedcom (FILE *fp)
663
XLAT ttmo = transl_get_predefined_xlat(MINGD);
664
prefix_file(fp, ttmo);
666
/*=====================================
667
* prefix_file_for_report - write BOM prefix to file if appropriate
668
* This handles prepending BOM (byte order mark) to UTF-8 files
669
*===================================*/
671
prefix_file_for_report (FILE *fp)
673
XLAT ttmo = transl_get_predefined_xlat(MINRP);
674
prefix_file(fp, ttmo);
677
/*=====================================
678
* prefix_file - write BOM prefix to file if appropriate
679
* This handles prepending BOM (byte order mark) to UTF-8 files
680
*===================================*/
682
prefix_file (FILE *fp, XLAT tt)
684
if (!should_write_bom())
686
if (is_codeset_utf8(xl_get_dest_codeset(tt)))
688
/* 3-byte UTF-8 byte order mark */
689
char bom[] = "\xEF\xBB\xBF";
690
fwrite(bom, strlen(bom), 1, fp);
693
/*=====================================
646
694
* write_indi_to_file - write node tree into GEDCOM
647
695
* (no user interaction)
648
696
*===================================*/
650
write_indi_to_file (NODE indi, CNSTRING file, BOOLEAN bom)
698
write_indi_to_file (NODE indi, CNSTRING file)
653
701
XLAT ttmo = transl_get_predefined_xlat(MINED);
654
702
NODE name, refn, sex, body, famc, fams;
656
704
ASSERT(fp = fopen(file, LLWRITETEXT));
657
if (bom && is_codeset_utf8(xl_get_dest_codeset(ttmo))) {
658
char bom[] = "\xEF\xBB\xBF";
659
fwrite(bom, strlen(bom), 1, fp);
705
prefix_file(fp, ttmo);
661
707
split_indi_old(indi, &name, &refn, &sex, &body, &famc, &fams);
662
708
write_nodes(0, fp, ttmo, indi, TRUE, TRUE, TRUE);
663
709
write_nodes(1, fp, ttmo, name, TRUE, TRUE, TRUE);
691
737
write_indi_to_file_for_edit (NODE indi, CNSTRING file, RFMT rfmt)
693
BOOLEAN bom = write_bom();
694
739
annotate_with_supplemental(indi, rfmt);
695
write_indi_to_file(indi, file, bom);
740
write_indi_to_file(indi, file);
696
741
resolve_refn_links(indi);
698
743
/*=====================================
704
749
write_fam_to_file_for_edit (NODE fam, CNSTRING file, RFMT rfmt)
706
BOOLEAN bom = write_bom();
707
751
annotate_with_supplemental(fam, rfmt);
708
write_fam_to_file(fam, file, bom);
752
write_fam_to_file(fam, file);
709
753
resolve_refn_links(fam);
711
755
/*=====================================
713
757
* (no user interaction)
714
758
*===================================*/
716
write_fam_to_file (NODE fam, CNSTRING file, BOOLEAN bom)
760
write_fam_to_file (NODE fam, CNSTRING file)
719
763
XLAT ttmo = transl_get_predefined_xlat(MINED);
720
764
NODE refn, husb, wife, chil, body;
721
bom = bom; /* unused */
723
766
ASSERT(fp = fopen(file, LLWRITETEXT));
767
prefix_file(fp, ttmo);
724
769
split_fam(fam, &refn, &husb, &wife, &chil, &body);
725
770
write_nodes(0, fp, ttmo, fam, TRUE, TRUE, TRUE);
726
771
write_nodes(1, fp, ttmo, refn, TRUE, TRUE, TRUE);