src/liflines/loadsave.c
/*================================
 * load_gedcom -- have user select gedcom file & import it
 *==============================*/
- have user select gedcom file & import it
- have user select gedcom file & import it
void
load_gedcom (BOOLEAN picklist)
{
	FILE *fp=NULL;
	struct tag_import_feedback ifeed;
	STRING srcdir=NULL;
	STRING fullpath=0;
	time_t begin = time(NULL);
	time_t beginui = get_uitime();
	srcdir = getlloptstr("InputPath", ".");
	if (!ask_for_gedcom(LLREADTEXT, _(qSwhatgedc), 0, &fullpath, srcdir, ".ged", picklist)
		|| !(fp = fopen(fullpath, LLREADBINARY))) {
		strfree(&fullpath);
		return;
	}
	memset(&ifeed, 0, sizeof(ifeed));
	ifeed.validating_fnc = import_validating;
	ifeed.validated_rec_fnc = import_validated_rec;
	ifeed.beginning_import_fnc = import_beginning_import;
	ifeed.error_invalid_fnc = import_error_invalid;
	ifeed.error_readonly_fnc = import_readonly;
	ifeed.adding_unused_keys_fnc = import_adding_unused_keys;
	ifeed.added_rec_fnc = import_added_rec;
	ifeed.validation_error_fnc = import_validation_error;
	ifeed.validation_warning_fnc =  import_validation_warning;
	import_from_gedcom_file(&ifeed, fp);
	fclose(fp);
	strfree(&fullpath);
	if (1) {
		INT duration = time(NULL) - begin;
		INT uitime = get_uitime() - beginui;
		ZSTR zt1=approx_time(duration-uitime), zt2=approx_time(uitime);
		ZSTR zout = zs_newf(_("Import time %s (ui %s)\n")
			, zs_str(zt1), zs_str(zt2));
		wfield(8,0, zs_str(zout));
		zs_free(&zt1);
		zs_free(&zt2);
		zs_free(&zout);
	}
	wpos(15,0);
}
void load_gedcom ( BOOLEAN picklist ) { FILE * fp = NULL ; struct tag_import_feedback ifeed ; STRING srcdir = NULL ; STRING fullpath = 0 ; time_t begin = time ( NULL ) ; time_t beginui = get_uitime ( ) ; srcdir = getlloptstr ( " " , " " ) ; if ( ! ask_for_gedcom ( LLREADTEXT , _ ( qSwhatgedc ) , 0 , & fullpath , srcdir , " " , picklist ) || ! ( fp = fopen ( fullpath , LLREADBINARY ) ) ) { strfree ( & fullpath ) ; return ; } memset ( & ifeed , 0 , sizeof ( ifeed ) ) ; ifeed . validating_fnc = import_validating ; ifeed . validated_rec_fnc = import_validated_rec ; ifeed . beginning_import_fnc = import_beginning_import ; ifeed . error_invalid_fnc = import_error_invalid ; ifeed . error_readonly_fnc = import_readonly ; ifeed . adding_unused_keys_fnc = import_adding_unused_keys ; ifeed . added_rec_fnc = import_added_rec ; ifeed . validation_error_fnc = import_validation_error ; ifeed . validation_warning_fnc = import_validation_warning ; import_from_gedcom_file ( & ifeed , fp ) ; fclose ( fp ) ; strfree ( & fullpath ) ; if ( 1 ) { INT duration = time ( NULL ) - begin ; INT uitime = get_uitime ( ) - beginui ; ZSTR zt1 = approx_time ( duration - uitime ) , zt2 = approx_time ( uitime ) ; ZSTR zout = zs_newf ( _ ( " \n " ) , zs_str ( zt1 ) , zs_str ( zt2 ) ) ; wfield ( 8 , 0 , zs_str ( zout ) ) ; zs_free ( & zt1 ) ; zs_free ( & zt2 ) ; zs_free ( & zout ) ; } wpos ( 15 , 0 ) ; }
load_gedcom -- have user select gedcom file & import it
load_gedcom -- have user select gedcom file & import it
/*
	Note: we read the file in binary mode, so ftell & fseek will work correctly.
	Microsoft's ftell/fseek do not work correctly if the file has simple unix (\n)
	line terminations! -- Perry, 2003-02-11
	*/ /* TRANSLATORS: how long Import ran, and how much of that was UI delay */ /* position cursor further down stdout so check_stdout 
	doesn't overwrite our messages from above */