src/liflines/edit.c
/*====================================
 * edit_fam -- Edit family in database
 * (with user interaction)
 *==================================*/
- Edit family in database
(with user interaction)
- Edit family in database ( with user interaction )
BOOLEAN
edit_family (RECORD frec1, RFMT rfmt) 
{
	NODE fam1=0, fam2=0;
	RECORD irec=0;
	XLAT ttmi = transl_get_predefined_xlat(MEDIN);
	STRING msg;
	BOOLEAN changed = FALSE;
	if (!frec1) {
		irec = ask_for_indi(_(qSidspse), NOASK1);
		if (!irec) return FALSE;
		if (!FAMS(nztop(irec))) {
			message("%s", _(qSntprnt));
			goto end_edit_fam;
		} 
		frec1 = choose_family(irec, _(qSparadox), _(qSidfbys), TRUE);
		if (!frec1) return FALSE; 
	}
	fam1 = nztop(frec1);
	write_fam_to_file_for_edit(fam1, editfile, rfmt);
	do_edit();
	if (readonly) {
		BOOLEAN emp;
		fam2 = file_to_node(editfile, ttmi, &msg, &emp);
		if (!equal_tree(fam1, fam2))
			message("%s", _(qSronlye));
		goto end_edit_fam;
	}
	while (TRUE) {
		INT cnt;
		BOOLEAN emp;
		fam2 = file_to_node(editfile, ttmi, &msg, &emp);
		if (!fam2) {
			if (ask_yes_or_no_msg(msg, _(qSfredit))) {
				do_edit();
				continue;
			}
			break;
		}
		cnt = resolve_refn_links(fam2);
		if (!valid_fam_tree(fam2, &msg, fam1)) {
			if (ask_yes_or_no_msg(msg, _(qSfredit))) {
				do_edit();
				continue;
			}
			free_nodes(fam2);
			fam2 = NULL;
			break;
		}
		if (cnt > 0) {
			char msgb[120];
			snprintf(msgb, sizeof(msgb)
				, get_unresolved_ref_error_string(cnt), cnt);
			if (ask_yes_or_no_msg(msgb, _(qSfreditopt))) {
				write_fam_to_file_for_edit(fam2, editfile, rfmt);
				do_edit();
				continue;
			}
		}
		break;
	}
	if (!fam2) return FALSE;
	if (equal_tree(fam1, fam2) || !ask_yes_or_no(_(qScffupt)))
		goto end_edit_fam;
	replace_fam(fam1, fam2);
	fam2 = NULL;
	msg_status("%s", _(qSgdfmod));
	changed = TRUE;
end_edit_fam:
	if (fam2)
		free_nodes(fam2); 
	return changed;
}
BOOLEAN edit_family ( RECORD frec1 , RFMT rfmt ) { NODE fam1 = 0 , fam2 = 0 ; RECORD irec = 0 ; XLAT ttmi = transl_get_predefined_xlat ( MEDIN ) ; STRING msg ; BOOLEAN changed = FALSE ; if ( ! frec1 ) { irec = ask_for_indi ( _ ( qSidspse ) , NOASK1 ) ; if ( ! irec ) return FALSE ; if ( ! FAMS ( nztop ( irec ) ) ) { message ( " " , _ ( qSntprnt ) ) ; goto end_edit_fam ; } frec1 = choose_family ( irec , _ ( qSparadox ) , _ ( qSidfbys ) , TRUE ) ; if ( ! frec1 ) return FALSE ; } fam1 = nztop ( frec1 ) ; write_fam_to_file_for_edit ( fam1 , editfile , rfmt ) ; do_edit ( ) ; if ( readonly ) { BOOLEAN emp ; fam2 = file_to_node ( editfile , ttmi , & msg , & emp ) ; if ( ! equal_tree ( fam1 , fam2 ) ) message ( " " , _ ( qSronlye ) ) ; goto end_edit_fam ; } while ( TRUE ) { INT cnt ; BOOLEAN emp ; fam2 = file_to_node ( editfile , ttmi , & msg , & emp ) ; if ( ! fam2 ) { if ( ask_yes_or_no_msg ( msg , _ ( qSfredit ) ) ) { do_edit ( ) ; continue ; } break ; } cnt = resolve_refn_links ( fam2 ) ; if ( ! valid_fam_tree ( fam2 , & msg , fam1 ) ) { if ( ask_yes_or_no_msg ( msg , _ ( qSfredit ) ) ) { do_edit ( ) ; continue ; } free_nodes ( fam2 ) ; fam2 = NULL ; break ; } if ( cnt > 0 ) { char msgb [ 120 ] ; snprintf ( msgb , sizeof ( msgb ) , get_unresolved_ref_error_string ( cnt ) , cnt ) ; if ( ask_yes_or_no_msg ( msgb , _ ( qSfreditopt ) ) ) { write_fam_to_file_for_edit ( fam2 , editfile , rfmt ) ; do_edit ( ) ; continue ; } } break ; } if ( ! fam2 ) return FALSE ; if ( equal_tree ( fam1 , fam2 ) || ! ask_yes_or_no ( _ ( qScffupt ) ) ) goto end_edit_fam ; replace_fam ( fam1 , fam2 ) ; fam2 = NULL ; msg_status ( " " , _ ( qSgdfmod ) ) ; changed = TRUE ; end_edit_fam : if ( fam2 ) free_nodes ( fam2 ) ; return changed ; }
edit_fam -- Edit family in database
 (with user interaction)
edit_fam -- Edit family in database ( with user interaction )
/* may be NULL */ /* Identify family if necessary */ /* Prepare file for user to edit */ /* Have user edit record */ /* check validation & allow user to reedit if invalid */ /* this is a showstopper, so alternative is to abort */ /* Allow user to reedit if desired if any refn links unresolved */ /* this is not a showstopper, so alternative is to continue */ /* If error or user backs out return */ /* Move new data (in fam2 children) into existing fam1 tree */