src/gedlib/gengedc.c
/*==============================================
 * output_any_node -- send a node out
 * this is the only path to output for gengedcom
 * this filters for dumping & trimming options
 *============================================*/
- send a node out
this is the only path to output for gengedcom
this filters for dumping & trimming options
- send a node out this is the only path to output for gengedcom this filters for dumping & trimming options
static void
output_any_node (CLOSURE * closure, NODE node, STRING toptag
	, INT lvl, BOOLEAN *eflg)
{
	char newval[MAXGEDNAMELEN]; 
	STRING v,pv;
	BOOLEAN dump, trimmed, insidepointer;
	v=nval(node);
	dump=0;
	trimmed=0;
	insidepointer=0;
	newval[0]=0;
	if (v)
	{
		pv=newval;
		while (*v)
		{
			int ispointer=0;
			if (insidepointer && v[0]=='@')
				insidepointer=0;
			else if (v[0]=='@' && is_valid_key(v))
			{
				if (closure_is_original(closure))
				{ 
					if (eqstr(toptag, "INDI"))
					{
						if (eqstr(ntag(node),"FAMC")||eqstr(ntag(node),"FAMS"))
							ispointer=1;
					}
					else
					{
						if (eqstr(ntag(node),"CHILD")||eqstr(ntag(node),"HUSB")||eqstr(ntag(node),"WIFE"))
							ispointer=1;
					}
				}
				else
					ispointer=1;
			}
			if (ispointer)
			{
				int skeynum;
				char skeybuff[MAXKEYWIDTH+1];
				skeynum = atoi(&v[2]);
				snprintf(skeybuff, sizeof(skeybuff), "%c%d", v[1], skeynum);
				if (!closure_has_key(closure, skeybuff))
				{
					if (closure_is_dump(closure))
					{
						dump=1;
						break;
					}
					trimmed=1;
					for (v++; *v; v++)
					{
						if (*v == '@')
							break;
					}
					v++; 
				}
				else 
				{
					insidepointer=1;
					*pv++ = *v++;
				}
			}
			else 
				*pv++ = *v++;
		}
		if (!dump)
			*pv = 0;
	}
	if (trimmed && !newval[0])
		dump=1; 
	if (!dump)
	{
		char scratch[MAXLINELEN+1];
		INT buflen = sizeof(scratch);
		STRING pq = scratch;
		snprintf(pq, buflen, FMT_INT, lvl);
		buflen -= strlen(pq);
		pq += strlen(pq);
		if (nxref(node)) {
			snprintf(pq, buflen, " %s", nxref(node));
			buflen -= strlen(pq);
			pq += strlen(pq);
		}
		snprintf(pq, buflen, " %s", ntag(node));
		buflen -= strlen(pq);
		pq += strlen(pq);
		if (newval[0])
		{
			ASSERT(buflen > 0);
			strcpy(pq, " ");
			buflen--;
			pq++;
			strncpy(pq, newval, buflen);
			buflen -= strlen(pq);
			pq += strlen(pq);
		}
		snprintf(pq, buflen, "\n");
		poutput(scratch, eflg);
		if (*eflg)
			return;
		if (nchild(node)) {
			output_any_node(closure, nchild(node), toptag, lvl+1, eflg);
			if (*eflg)
				return;
			}
	}
	if (nsibling(node))
		output_any_node(closure, nsibling(node), toptag, lvl, eflg);
}
static void output_any_node ( CLOSURE * closure , NODE node , STRING toptag , INT lvl , BOOLEAN * eflg ) { char newval [ MAXGEDNAMELEN ] ; STRING v , pv ; BOOLEAN dump , trimmed , insidepointer ; v = nval ( node ) ; dump = 0 ; trimmed = 0 ; insidepointer = 0 ; newval [ 0 ] = 0 ; if ( v ) { pv = newval ; while ( * v ) { int ispointer = 0 ; if ( insidepointer && v [ 0 ] == ' ' ) insidepointer = 0 ; else if ( v [ 0 ] == ' ' && is_valid_key ( v ) ) { if ( closure_is_original ( closure ) ) { if ( eqstr ( toptag , " " ) ) { if ( eqstr ( ntag ( node ) , " " ) || eqstr ( ntag ( node ) , " " ) ) ispointer = 1 ; } else { if ( eqstr ( ntag ( node ) , " " ) || eqstr ( ntag ( node ) , " " ) || eqstr ( ntag ( node ) , " " ) ) ispointer = 1 ; } } else ispointer = 1 ; } if ( ispointer ) { int skeynum ; char skeybuff [ MAXKEYWIDTH + 1 ] ; skeynum = atoi ( & v [ 2 ] ) ; snprintf ( skeybuff , sizeof ( skeybuff ) , " " , v [ 1 ] , skeynum ) ; if ( ! closure_has_key ( closure , skeybuff ) ) { if ( closure_is_dump ( closure ) ) { dump = 1 ; break ; } trimmed = 1 ; for ( v ++ ; * v ; v ++ ) { if ( * v == ' ' ) break ; } v ++ ; } else { insidepointer = 1 ; * pv ++ = * v ++ ; } } else * pv ++ = * v ++ ; } if ( ! dump ) * pv = 0 ; } if ( trimmed && ! newval [ 0 ] ) dump = 1 ; if ( ! dump ) { char scratch [ MAXLINELEN + 1 ] ; INT buflen = sizeof ( scratch ) ; STRING pq = scratch ; snprintf ( pq , buflen , FMT_INT , lvl ) ; buflen -= strlen ( pq ) ; pq += strlen ( pq ) ; if ( nxref ( node ) ) { snprintf ( pq , buflen , " " , nxref ( node ) ) ; buflen -= strlen ( pq ) ; pq += strlen ( pq ) ; } snprintf ( pq , buflen , " " , ntag ( node ) ) ; buflen -= strlen ( pq ) ; pq += strlen ( pq ) ; if ( newval [ 0 ] ) { ASSERT ( buflen > 0 ) ; strcpy ( pq , " " ) ; buflen -- ; pq ++ ; strncpy ( pq , newval , buflen ) ; buflen -= strlen ( pq ) ; pq += strlen ( pq ) ; } snprintf ( pq , buflen , " \n " ) ; poutput ( scratch , eflg ) ; if ( * eflg ) return ; if ( nchild ( node ) ) { output_any_node ( closure , nchild ( node ) , toptag , lvl + 1 , eflg ) ; if ( * eflg ) return ; } } if ( nsibling ( node ) ) output_any_node ( closure , nsibling ( node ) , toptag , lvl , eflg ) ; }
output_any_node -- send a node out
 this is the only path to output for gengedcom
 this filters for dumping & trimming options
output_any_node -- send a node out this is the only path to output for gengedcom this filters for dumping & trimming options
/* for modified values */ /* original only suppressed family linking pointers */ /* skip over pointer */ /* skip over last @ */ /* copy included pointers */ /* copy normal data */ /* dump nodes whose values were trimmed to nothing */