+int compat_matrix[] =
+{
+ /* C_NO_SUBMITTER */ C_FTREE | C_LIFELINES,
+ /* C_INDI_ADDR */ C_FTREE,
+ /* C_NOTE_NO_VALUE */ C_FTREE,
+ /* C_NO_GEDC */ C_LIFELINES,
+ /* C_NO_CHAR */ C_LIFELINES,
+ /* C_HEAD_TIME */ C_LIFELINES,
+ /* C_NO_DOUBLE_AT */ C_LIFELINES | C_PAF,
+ /* C_NO_REQUIRED_VALUES */ C_LIFELINES,
+ /* C_551_TAGS */ C_PAF,
+ /* C_NO_SLGC_FAMC */ C_PAF,
+ /* C_NR_OF_RULES */ 0
+};
+
+int compat_state[] =
+{
+ /* C_NO_SUBMITTER */ 0,
+ /* C_INDI_ADDR */ 0,
+ /* C_NOTE_NO_VALUE */ 0,
+ /* C_NO_GEDC */ 0,
+ /* C_NO_CHAR */ 0,
+ /* C_HEAD_TIME */ 0,
+ /* C_NO_DOUBLE_AT */ 0,
+ /* C_NO_REQUIRED_VALUES */ 0,
+ /* C_551_TAGS */ 0,
+ /* C_NO_SLGC_FAMC */ 0,
+ /* C_NR_OF_RULES */ 0
+};
+
+/* Compatibility handling */
+
+void gedcom_set_compat_handling(int enable_compat)
+{
+ compat_enabled = enable_compat;
+}
+
+void enable_compat_msg(const char* program_name)
+{
+ gedcom_warning(_("Enabling compatibility with '%s'"), program_name);
+}
+
+void set_compatibility(const char* program)
+{
+ /* Reinitialize compatibility */
+ int i;
+ default_charset = "";
+ compatibility = 0;
+ for (i = 0; i < C_NR_OF_RULES; i++)
+ compat_state[i] = 0;
+
+ if (compat_enabled) {
+ if (! strncmp(program, "ftree", 6)) {
+ enable_compat_msg("ftree");
+ compatibility = C_FTREE;
+ }
+ else if (! strncmp(program, "LIFELINES", 9)) {
+ /* Matches "LIFELINES 3.0.2" */
+ enable_compat_msg("Lifelines");
+ compatibility = C_LIFELINES;
+ default_charset = "ANSI";
+ }
+ else if (! strncmp(program, "PAF", 4)) {
+ enable_compat_msg("Personal Ancestral File");
+ compatibility = C_PAF;
+ }
+ }
+}
+
+int compat_mode(Compat_rule rule)
+{
+ return (compat_matrix[rule] & compatibility);
+}
+