Example #1
0
/*======================================================
 * choose_from_indiseq -- Format sequence and have user
 *  choose from it (any type)
 * This handles bad pointers, which can get into the data
 *  several ways.
 *  seq:   [IN]  sequence from which to choose
 *  ask1:  [IN]  whether to prompt if only one element in sequence
 *  titl1: [IN]  title if sequence has one element
 *  titln: [IN]  title if sequence has multiple elements
 *=====================================================*/
RECORD
choose_from_indiseq (INDISEQ seq, ASK1Q ask1, STRING titl1, STRING titln)
{
	INT i = 0;
	RECORD rec=0;

	i = choose_one_from_indiseq_if_needed(seq, ask1, titl1, titln);
	if (i == -1) return NULL;
	listbadkeys=1;
	/* which typed value indiseq is this ? */
	if (!indiseq_is_valtype_ival(seq) && !indiseq_is_valtype_null(seq))
	{
		/* int debug=1; */ /* Can this happen ? */
	}
	if (-1 == get_indiseq_ival(seq, i)) /* invalid pointer */
		badkeylist[0] = 0;
	else {
		CNSTRING skey = element_key_indiseq(seq, i);
		rec = key_to_record(skey);
	}
	listbadkeys = 0;
	if(!rec) {
		char buf[132];
		if (badkeylist[0])
			llstrncpyf(buf, sizeof(buf), uu8, "%s: %.40s", _(qSmisskeys), badkeylist);
		else
			llstrncpyf(buf, sizeof(buf), uu8, _(qSbadkeyptr));
		message(buf);
	}
	return rec;
}
Example #2
0
/*======================================
 * make_fname_prompt -- Create prompt line
 *  for filename, depending on extension
 * Created: 2001/12/24, Perry Rapp
 *====================================*/
static void
make_fname_prompt (STRING fnamebuf, INT len, STRING ext)
{
	if (ISNULL(ext)) {
		ext = NULL;	/* a null extension is the same as no extension */
		llstrncpyf(fnamebuf, len, uu8, "%s: ", _(qSwhtfname));
	}
	else {
		llstrncpyf(fnamebuf, len, uu8, _(qSwhtfnameext), ext);
	}
}
Example #3
0
/*=================================
 * print_usage -- Explain arguments
 * Created: 2001/01/01, Perry Rapp
 *===============================*/
static void
print_usage (void)
{
    char verstr[80];
    STRING title = _(qSmtitle);
#ifdef WIN32
    char * fname = _("\\My Documents\\LifeLines\\Databases\\MyFamily");
#else
    char * fname = _("/home/users/myname/lifelines/databases/myfamily");
#endif
    llstrncpyf(verstr, sizeof(verstr), uu8, title
               , get_lifelines_version(sizeof(verstr)-1-strlen(title)));
    printf(_("usage: dbverify -(flags) <btree>\n"));
    printf(_("flags:\n"));
    printf(_("\t-a = Perform all checks (does not include fixes)\n"));
    printf(_("\t-g = Check for ghosts (names/refns)\n"));
    printf(_("\t-G = Check for & fix ghosts (names/refns)\n"));
    printf(_("\t-i = Check individuals\n"));
    printf(_("\t-f = Check families\n"));
    printf(_("\t-F = Alter any bad family lineage pointers (to _badptr)\n"));
    printf(_("\t-h = Display help text (this text)\n"));
    printf(_("\t-s = Check sours\n"));
    printf(_("\t-e = Check events\n"));
    printf(_("\t-x = Check others\n"));
    printf(_("\t-l = Check database structure\n"));
    printf(_("\t-m = Check for records missing data entries\n"));
    printf(_("\t-M = Fix records missing data entries\n"));
    printf(_("\t-D = Fix bad delete entries\n"));
    printf(_("\t-n = Noisy (echo every record processed)\n"));
    printf(_("example: dbverify -ifsex \"%s\"\n"), fname);
    printf("%s\n", verstr);
}
Example #4
0
/*===============================================
 * get_lifelines_version -- Return version string
 *  returns static buffer
 *=============================================*/
STRING
get_lifelines_version (INT maxlen)
{
    static char version[48];
    INT len=sizeof(version);
    if (len>maxlen)
        len=maxlen;
    llstrncpyf(version, len, 0, LIFELINES_VERSION);
    return version;
}
Example #5
0
/*================================================================
 * convert_first_fp_to_node -- Convert first GEDCOM record in file to tree
 *
 * fp:   [IN]  file that holds GEDCOM record/s
 * list: [IN]  can be list at level 0?
 * ttm:  [IN]  character translation table
 * pmsg: [OUT] possible error message
 * peof: [OUT] set true if file is at end of file
 * TODO: revise import (restore_record) so can delete this
 *==============================================================*/
NODE
convert_first_fp_to_node (FILE *fp, BOOLEAN list, XLAT ttm,
	STRING *pmsg,  BOOLEAN *peof)
{
	STRING unitype = check_file_for_unicode(fp);
	NODE node=0;
	if (unitype && !eqstr(unitype, "UTF-8")) {
		char msg[120];
		llstrncpyf(msg, sizeof(msg), uu8, _(qSunsupuniv), unitype);
		*pmsg = _(qSunsupunix);
		return NULL;
	}
	node = do_first_fp_to_node(fp, list, ttm, pmsg, peof);
	nodechk(node, "convert_first_fp_to_node");
	return node;
}
Example #6
0
/*==========================================================
 * add_indi_by_edit -- Add new person to database by editing
 * (with user interaction)
 * returns addref'd record
 *========================================================*/
RECORD
add_indi_by_edit (RFMT rfmt)
{
	FILE *fp;
	RECORD indi0=0;
	NODE indi=0;
	STRING str, msg;
	BOOLEAN emp;
	XLAT ttmi = transl_get_predefined_xlat(MEDIN);

	if (readonly) {
		message(_(qSronlya));
		return NULL;
	}

/* Create person template for user to edit */

	if (!(fp = fopen(editfile, LLWRITETEXT)))
		return NULL;
	prefix_file_for_edit(fp);

	/* prefer useroption in this db */
	if ((str = getlloptstr("INDIREC", NULL)))
		fprintf(fp, "%s\n", str);
	else { /* default */
		fprintf(fp, "0 INDI\n1 NAME Fname/Surname\n1 SEX MF\n");
		fprintf(fp, "1 BIRT\n  2 DATE\n  2 PLAC\n");
		fprintf(fp, "1 DEAT\n  2 DATE\n  2 PLAC\n1 SOUR\n");
	}

/* Have user edit new person record */

	fclose(fp);
	do_edit();
	while (TRUE) {
		INT cnt;
		if (indi0) {
			release_record(indi0);
			indi0=0;
		}
		indi0 = file_to_record(editfile, ttmi, &msg, &emp);
		if (!indi0) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			} 
			break;
		}
		indi = nztop(indi0);
		cnt = resolve_refn_links(indi);
		/* check validation & allow user to reedit if invalid */
		/* this is a showstopper, so alternative is to abort */
		if (!valid_indi_tree(indi, &msg, NULL)) {
			if (ask_yes_or_no_msg(msg, _(qSiredit))) {
				do_edit();
				continue;
			}
			release_record(indi0);
			indi0 = NULL;
			break;
		}
		/* Allow user to reedit if desired if any refn links unresolved */
		/* this is not a showstopper, so alternative is to continue */
		if (cnt > 0) {
			char msgb[120];
			llstrncpyf(msgb, sizeof(msgb), uu8
				, get_unresolved_ref_error_string(cnt), cnt);
			if (ask_yes_or_no_msg(msgb, _(qSireditopt))) {
				write_indi_to_file_for_edit(indi, editfile, rfmt);
				do_edit();
				continue;
			}
		}
		break;
	}
	if (!indi0 || !ask_yes_or_no(_(qScfpadd))) {
		if (indi0) release_record(indi0);
		return NULL;
	}
	
	/* add the new record to the database */
	add_new_indi_to_db(indi0);

	msg_status(_(qSgdpadd), indi_to_name(nztop(indi0), 35));
	return indi0;
}