Exemple #1
0
/*****************************************************************************
*
*   void AsnKillValue(atp, dvp)
*   	eliminates stored values such as strings
*
*****************************************************************************/
NLM_EXTERN void LIBCALL  AsnKillValue (AsnTypePtr atp, DataValPtr dvp)
{
	Int2 isa;

	isa = AsnFindBaseIsa(atp);
	if (ISA_STRINGTYPE(isa))
		MemFree(dvp->ptrvalue);
	else if ((isa == OCTETS_TYPE) || (isa == STRSTORE_TYPE))
		BSFree((ByteStorePtr) dvp->ptrvalue);
	return;
}
Exemple #2
0
/*****************************************************************************
*
*   Boolean AsnBinBufWrite(aip, atp, buf, buflen)
*
*****************************************************************************/
NLM_EXTERN Boolean LIBCALL AsnBinBufWrite (AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen)
{
    int	isa;
    AsnTypePtr atp2;
    int next_type;

    if (! AsnTypeValidateOut(aip, atp, NULL))
        return FALSE;

    atp2 = AsnFindBaseType(atp);
    isa = atp2->type->isa;
    if (ISA_STRINGTYPE(isa))
        isa = GENERALSTRING_TYPE;

    AsnEnBinTags(atp, aip);	/* put in the tags */

    switch (isa) {
    case GENERALSTRING_TYPE:
    case OCTETS_TYPE:
    case STRSTORE_TYPE:
        AsnEnBinBuf(buf, buflen, aip, atp);
        break;
    default:
        AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name));
        return FALSE;
    }

    if (atp->tagclass != TAG_NONE)
        AsnEnBinEndIndef(aip);    /* put indefinite encoding */
    next_type = aip->type_indent - 1;   /* end any choices */
    while ((next_type >= 0) &&
            (AsnFindBaseIsa(aip->typestack[next_type].type) == CHOICE_TYPE)) {
        if (aip->typestack[next_type].type->tagclass != TAG_NONE)
            AsnEnBinEndIndef(aip);
        next_type--;
    }
    if (AsnFindBaseIsa(aip->typestack[aip->type_indent - 1].type) == CHOICE_TYPE)
        AsnTypeSetIndent(FALSE, aip, atp);
    return TRUE;
}
Exemple #3
0
/*****************************************************************************
*
*   void AsnEnBinTags(atp, aip)
*   	encode tags for atp
*
*****************************************************************************/
NLM_EXTERN void AsnEnBinTags (AsnTypePtr atp, AsnIoPtr aip)
{
	int isa, len;
	Int4 tagnumber;
	Byte octets[6], bit87, bit6, bit5_1;

	if (atp->tagclass == TAG_NONE)     /* encode tag, if any */
		return;

	isa = AsnFindBaseIsa(atp);
	if ((isa == SEQ_TYPE) || (isa == SEQOF_TYPE) ||
		(isa == SET_TYPE) || (isa == SETOF_TYPE) ||
		(atp->tagclass == TAG_CONTEXT))
		bit6 = 32;       /* constructed bit set */
	else
		bit6 = 0;

	bit87 = atp->tagclass;    /* map directly */

	tagnumber = atp->tagnumber;

	if (tagnumber <= 30)        /* only need one octet */
	{
		bit5_1 = (Byte)(tagnumber) & (Byte)0x0ff;
		octets[0] = bit87 + bit6 + bit5_1;
		AsnEnBinBytes(octets, (Uint4)1, aip);
	}
	else
	{
		bit5_1 = 31;            /* extended tag */

		octets[0] = bit87 + bit6 + bit5_1;

		if (tagnumber <= 0x07f)
		{
			octets[1] = (Byte)tagnumber;
			len = 2;
		}
		else if (tagnumber <= 0x03fff)
		{
			octets[1] = (Byte)(128 + ((tagnumber >> 7) & 0x07f));
			octets[2] = (Byte)(tagnumber & 0x07f);
			len = 3;
		}
		else if (tagnumber <= 0x01fffff)
Exemple #4
0
static Pointer AsnLexReadStringEx (AsnIoPtr aip, AsnTypePtr atp, Uint1 fix_non_print)
{
	Int2 token;
	ByteStorePtr ssp;
	CharPtr result=NULL;
	Int4 bytes;

	token = AsnLexWordEx (aip, fix_non_print);      /* read the start */
	if (token != START_STRING)
	{
		AsnIoErrorMsg(aip, 43, AsnErrGetTypeName(atp->name), aip->linenumber);
		return NULL;
	}

	ssp = BSNew(0);
	if (ssp == NULL) return result;
	token = AsnLexWordEx (aip, fix_non_print);   /* read the string(s) */
	while (token == IN_STRING)
	{
		bytes = BSWrite(ssp, aip->word, (Int4)aip->wordlen);
		if (bytes != (Int4)(aip->wordlen))
		{
			BSFree(ssp);
			return result;
		}
		token = AsnLexWord(aip);
	}

	if (token == ERROR_TOKEN) return NULL;

	if (token != END_STRING)
	{
		AsnIoErrorMsg(aip, 44, AsnErrGetTypeName(atp->name), aip->linenumber);
		return NULL;
	}
	if (AsnFindBaseIsa(atp) == STRSTORE_TYPE)    /* string store */
		return ssp;

	result = (CharPtr) BSMerge(ssp, NULL);
	BSFree(ssp);

	return result;
}
Exemple #5
0
/*****************************************************************************
*
*   CharPtr AsnTypeDumpStack(str, aip)
*   	dump a typestack into str
*       returns a pointer to the '\0' at the end of the str
*
*****************************************************************************/
NLM_EXTERN CharPtr LIBCALL  AsnTypeDumpStack (CharPtr str, AsnIoPtr aip)
{
    Int2 level, isa, lastnochoice;

    lastnochoice = -1;
    *str = '\0';

	for(level = 0; level <= aip->type_indent; level++)
	{
		if (level == aip->type_indent)
		{
			if ((aip->type & ASNIO_OUT) ||
				((aip->type & ASNIO_IN) && (aip->read_id == FALSE)))
				str = StringMove(str, "<");
		}
		if (aip->typestack[level].type == NULL)
			str = StringMove(str, " ");
		else
		{
			isa = AsnFindBaseIsa(aip->typestack[level].type);
            if (aip->typestack[level].type->name != NULL)
                str = StringMove(str, aip->typestack[level].type->name);
            else if ((lastnochoice == SEQOF_TYPE) ||
                        (lastnochoice == SETOF_TYPE))
                str = StringMove(str, "E");
            else
                str = StringMove(str, "?");
            if (isa != CHOICE_TYPE)
                lastnochoice = isa;
		}
        if (level != aip->type_indent)
            str = StringMove(str, ".");
		else
		{
			if ((aip->type & ASNIO_OUT) ||
				((aip->type & ASNIO_IN) && (aip->read_id == FALSE)))
				str = StringMove(str, ">");
		}
	}
	return str;
}
Exemple #6
0
/*****************************************************************************
*
*   void AsnTypeSetIndent(increase, aip, atp)
*   	set the typestack type_indent
*
*****************************************************************************/
NLM_EXTERN void AsnTypeSetIndent (Boolean increase, AsnIoPtr aip, AsnTypePtr atp)
{
	Int1 curr_indent;
	PstackPtr tmptype;
	

	if (increase)
	{
		aip->typestack[aip->type_indent].type = atp;     /* save type */
		aip->type_indent++;
		curr_indent = aip->type_indent;
		if (curr_indent == aip->max_type)   /* expand indent levels */
		{
			tmptype = aip->typestack;
			aip->typestack = (PstackPtr) MemNew((sizeof(Pstack) * (aip->max_type + 10)));
			MemCopy(aip->typestack, tmptype, (size_t)(sizeof(Pstack) * aip->max_type));
			MemFree(tmptype);
			aip->max_type += 10;
		}
		aip->typestack[curr_indent].type = NULL;     /* set to first time */
	}
	else
	{
		do
		{
			aip->typestack[aip->type_indent].type = NULL;
			if (aip->type_indent)
				aip->type_indent--;
		} while ((aip->type_indent) &&
			(AsnFindBaseIsa(aip->typestack[aip->type_indent-1].type) == CHOICE_TYPE)
			 && (aip->token != ISMODULE_TOKEN) && (!(aip->type & ASNIO_XML)));
		/* this is to pop out of choice nests */
		/* XML popping is formatted at ends */
	}
	return;
}
Exemple #7
0
/*****************************************************************************
*
*   void AsnTxtBufWrite(aip, atp, buf, buflen)
*
*****************************************************************************/
NLM_EXTERN Boolean LIBCALL AsnTxtBufWrite (AsnIoPtr aip, AsnTypePtr atp, CharPtr buf, size_t buflen)
{
    Int2 isa;
    AsnTypePtr atp2;
    Boolean firstvalue;

    if ((! aip->indent_level) && (aip->typestack[0].type == NULL))
        firstvalue = TRUE;    /* first call to this routine */
    else
        firstvalue = FALSE;

    atp2 = AsnFindBaseType(atp);
    isa = atp2->type->isa;
    if (ISA_STRINGTYPE(isa))
        isa = GENERALSTRING_TYPE;

    switch (isa) {
    case GENERALSTRING_TYPE:
    case OCTETS_TYPE:
    case STRSTORE_TYPE:
        break;
    default:
        AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name));
        return FALSE;
    }

    if (! AsnTypeValidateOut(aip, atp, NULL))
        return FALSE;

    if (! aip->first[aip->indent_level])
        AsnPrintNewLine(aip);
    else
        aip->first[aip->indent_level] = FALSE;

    atp2 = atp;
    if (firstvalue) {	/* first item, need ::= */
        while ((atp2->name == NULL) || (IS_LOWER(*atp2->name)))
            atp2 = atp2->type;    /* find a Type Reference */
    }

    if (atp2->name != NULL) {
        AsnPrintString(atp2->name, aip);	/* put the element name */
        if (IS_LOWER(*atp2->name))
            AsnPrintChar(' ', aip);
        else
            AsnPrintString(" ::= ", aip);
    }

    switch (isa) {
    case GENERALSTRING_TYPE:
    case STRSTORE_TYPE:
        AsnPrintChar('\"', aip);
        AsnPrintBuf(buf, buflen, aip);
        AsnPrintChar('\"', aip);
        break;
    case OCTETS_TYPE:
        AsnPrintBufOctets(buf, buflen, aip);
        break;
    default:
        AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name));
        return FALSE;
    }

    if (aip->type_indent) { /* pop out of choice nests */
        if (AsnFindBaseIsa(aip->typestack[aip->type_indent - 1].type) == CHOICE_TYPE) {
            if (aip->type_indent >= 2)
                isa = AsnFindBaseIsa(aip->typestack[aip->type_indent - 2].type);
            else
                isa = NULL_TYPE;    /* just fake it */
            AsnPrintIndent(FALSE, aip);
            AsnTypeSetIndent(FALSE, aip, atp);
        }
    }
    return TRUE;
}
Exemple #8
0
/*****************************************************************************
*
*   Boolean AsnBinWrite(aip, atp, valueptr)
*
*****************************************************************************/
NLM_EXTERN Boolean LIBCALL  AsnBinWrite (AsnIoPtr aip, AsnTypePtr atp, DataValPtr dvp)
{
	Int2 isa;
	AsnTypePtr atp2;
	Boolean terminalvalue;
	int next_type;

	terminalvalue = TRUE;   /* most are terminal values */

	if (! AsnTypeValidateOut(aip, atp, dvp))
		return FALSE;

	atp2 = AsnFindBaseType(atp);
	isa = atp2->type->isa;
	if (ISA_STRINGTYPE(isa))
		isa = GENERALSTRING_TYPE;
	
	if (((isa == SEQ_TYPE) || (isa == SET_TYPE) ||
		 (isa == SEQOF_TYPE) || (isa == SETOF_TYPE))
		 && (dvp->intvalue == END_STRUCT))
	{
		AsnEnBinCloseStruct(aip, atp);
		return TRUE;
	}

	AsnEnBinTags(atp, aip);     /* put in the tags */

	if (isa == CHOICE_TYPE)     /* show nothing */
	{
		AsnTypeSetIndent(TRUE, aip, atp);
		return TRUE;
	}

	switch (isa)
	{
		case SEQ_TYPE:
		case SET_TYPE:
		case SEQOF_TYPE:
		case SETOF_TYPE:
			if (dvp->intvalue == START_STRUCT)   /* open brace */
				AsnEnBinOpenStruct(aip, atp);
			else
			{
				AsnIoErrorMsg(aip, 18 );
				return FALSE;
			}
			terminalvalue = FALSE;
			break;
		case BOOLEAN_TYPE:
			AsnEnBinBoolean(dvp->boolvalue, aip, atp);
			break;
		case INTEGER_TYPE:
		case ENUM_TYPE:
			AsnEnBinInteger(dvp->intvalue, aip, atp);
			break;
		case BIGINT_TYPE:
			AsnEnBinBigInt(dvp->bigintvalue, aip, atp);
			break;
		case REAL_TYPE:
			AsnEnBinReal(dvp->realvalue, aip, atp);
			break;
		case GENERALSTRING_TYPE:
			if (! AsnEnBinString((CharPtr) dvp->ptrvalue, aip, atp))
				return FALSE;
			break;
		case NULL_TYPE:
			AsnEnBinNull(aip, atp);
			break;
		case OCTETS_TYPE:
		case STRSTORE_TYPE:
			AsnEnBinOctets((ByteStorePtr) dvp->ptrvalue, aip, atp);
			break;
		default:
			AsnIoErrorMsg(aip, 19, AsnErrGetTypeName(atp->name));
			return FALSE;
	}

	if (terminalvalue)          /* pop out of choice nests */
	{
		if (atp->tagclass != TAG_NONE)
			AsnEnBinEndIndef(aip);    /* put indefinate encoding */
		next_type = aip->type_indent - 1;   /* end any choices */
		while ((next_type >= 0) &&
			(AsnFindBaseIsa(aip->typestack[next_type].type) == CHOICE_TYPE))
		{
			if (aip->typestack[next_type].type->tagclass != TAG_NONE)
				AsnEnBinEndIndef(aip);
			next_type--;
		}
		if (AsnFindBaseIsa(aip->typestack[aip->type_indent - 1].type) == CHOICE_TYPE)
			AsnTypeSetIndent(FALSE, aip, atp);
	}
	return TRUE;
}
Exemple #9
0
static void AddXMLname(AsnTypePtr atp, AsnTypePtr PNTR typestack, Int2 stackptr)
{
	Char buf[80];
	AsnTypePtr atp2;
	Boolean found=FALSE, getparent=TRUE, doitem = FALSE, done = FALSE;
	CharPtr tmp;
	Int2 i, isa;

	if (atp->XMLname == NULL)   /* only do it once */
	{
		tmp = buf; *tmp = '\0';
		if (atp->name == NULL)
		{
			doitem = TRUE;
		}
		else if (IS_UPPER(*(atp->name)))
		{
			getparent = FALSE;
			tmp = StringMove(tmp, atp->name);
		}

		if ((getparent) && (stackptr))
		{
			atp2 = typestack[stackptr - 1];
			isa = AsnFindBaseIsa(atp2);
			if ((doitem) && ((isa == SEQOF_TYPE) || (isa == SETOF_TYPE)))
			{
				atp2 = AsnFindBaseTypeDTD(atp);
				if (atp2 != NULL)
				{
				if (atp2->name == NULL)
				{
					atp2 = typestack[stackptr - 1];
					if (atp->type != NULL)
					{
						if (ISA_BASETYPE(atp->type->isa))
						{
							if (atp2->XMLname != NULL)
							{
								tmp = StringMove(tmp, atp2->XMLname);
								getparent = FALSE;
								found = TRUE;
							}
						}
					}
				}
				else
				{
					if (atp2->XMLname != NULL)
						tmp = StringMove(tmp, atp2->XMLname);
					else if (atp2->name != NULL)
						tmp = StringMove(tmp, atp2->name);
					if (*buf != '\0')
					{
						doitem = FALSE;
						getparent = FALSE;
						done = TRUE;
						found = TRUE;
					}
				}
				}
			}

			atp2 = typestack[stackptr - 1];
			if ((getparent) && (atp2->XMLname != NULL))  /* already nested */
			{
				tmp = StringMove(tmp, atp2->XMLname);
				tmp = StringMove(tmp, "_");
				getparent = FALSE;
				found = TRUE;
			}

			if ((stackptr) && (getparent))
			{
				found = FALSE;

				for (i = (stackptr - 1); (i >= 0) && (! found); i--)
				{
					atp2 = AsnFindBaseTypeDTD(typestack[i]);
					if ((atp2 != NULL) && (atp2->name != NULL) && (IS_UPPER(*(atp2->name))))
					{
						while (i < stackptr)
						{
							atp2 = AsnFindBaseTypeDTD(typestack[i]);
							if (atp2->name == NULL)
								tmp = StringMove(tmp, "E");
							else
								tmp = StringMove(tmp, atp2->name);
							tmp = StringMove(tmp, "_");
							i++;
						}
						found = TRUE;
					}
				}
			}

			if ((! done) && found)
			{
				if (doitem)
					tmp = StringMove(tmp, "_E");
				else
					tmp = StringMove(tmp, atp->name);
			}
		}


		if (*buf != '\0')
		{
			atp->XMLname = StringSave(buf);
		}
	}

	atp2 = AsnFindBaseTypeDTD(atp);
	if ((! atp->imported) && (atp2 != NULL) && (atp2->type != NULL))
	{
		isa = atp2->type->isa;
		if ((isa == SEQ_TYPE) || (isa == SET_TYPE))
		{
			typestack[stackptr] = atp;
			for (atp2 = atp->branch; atp2 != NULL; atp2 = atp2->next)
				AddXMLname(atp2, typestack, (Int2)(stackptr + 1));
		}
		else if ((isa == SEQOF_TYPE) || (isa == SETOF_TYPE))
		{
			typestack[stackptr] = atp;
			for (atp2 = atp->branch; atp2 != NULL; atp2 = atp2->next)
				AddXMLname(atp2, typestack, (Int2)(stackptr + 1));
		}			
		else if (isa == CHOICE_TYPE)
		{
			typestack[stackptr] = atp;
			for (atp2 = atp->branch; atp2 != NULL; atp2 = atp2->next)
				AddXMLname(atp2, typestack, (Int2)(stackptr + 1));
		}
	}

	return;

}
Exemple #10
0
NLM_EXTERN Int2 LIBCALL  AsnTxtReadVal (AsnIoPtr aip, AsnTypePtr atp, DataValPtr valueptr)
{
	Int2 isa, token, retval;
	Boolean terminalvalue;      /* set if read a terminal value */
	AsnTypePtr atp2;
	Boolean read_value;
	DataVal fake_value;
	AsnTypePtr base_type, curr_type;
    PstackPtr currpsp;

	retval = 1;  /* assume success */
    currpsp = & aip->typestack[aip->type_indent];
	curr_type = currpsp->type;

	if (atp == NULL)
		return 0;

	base_type = AsnFindBaseType(atp);     
    if (base_type == NULL)     /* not found */
    {
        base_type = atp;   
        while (base_type->type != NULL)
            base_type = base_type->type;
        if (base_type->imported)
		{
            AsnIoErrorMsg(aip,35, AsnErrGetTypeName(atp->name), base_type->name, aip->linenumber);
			return 0;
		}
       else
		{
            AsnIoErrorMsg(aip,36, AsnErrGetTypeName(atp->name), base_type->name, aip->linenumber);
			return 0;
		}
    }
	isa = base_type->type->isa;

	if (valueptr == NULL)       /* just check the value */
	{
		read_value = FALSE;
		valueptr = &fake_value;
	}
	else
		read_value = TRUE;

	terminalvalue = TRUE;    /* most values are terminal values */

	if (ISA_STRINGTYPE(isa) && isa != UTF8STRING_TYPE)
		isa = GENERALSTRING_TYPE;

	switch (isa)
	{
		case SEQ_TYPE:
		case SET_TYPE:
		case SETOF_TYPE:
		case SEQOF_TYPE:
			terminalvalue = FALSE;  /* handled by AsnTypeSetIndent() */
			if (aip->token != END_STRUCT)   /* should be open brace */
			{
				token = AsnLexWord(aip);    /* read open brace */
				if (token != START_STRUCT)
				{
					AsnIoErrorMsg(aip, 37, aip->linenumber);
					return 0;
				}
				AsnTypeSetIndent(TRUE, aip, atp);  
				retval = START_STRUCT;
				valueptr->intvalue = START_STRUCT;
				terminalvalue = FALSE;
			}
			else
			{			   /* close brace already read in AsnTxtReadId */
				switch (isa)
				{
					case SEQOF_TYPE:
					case SETOF_TYPE:
						break;
					case SEQ_TYPE:       /* check that no more waiting */
        				if (curr_type != NULL)   /* check next one */
		        			atp2 = curr_type->next;
				        else                     /* empty sequence written */
        					atp2 = (AsnTypePtr)base_type->branch;
						while (atp2 != NULL)
						{
							if (! (atp2->optional || atp2->hasdefault))
							{

                                                                AsnIoErrorMsg(aip, 34, AsnErrGetTypeName(atp2->name), base_type->name, aip->linenumber);
								return 0;
							}
							atp2 = atp2->next;
						}
						break;
					default:
						break;
				}
				AsnTypeSetIndent(FALSE, aip, atp);  
				retval = END_STRUCT;
				valueptr->intvalue = END_STRUCT;
			}
			break;
		case CHOICE_TYPE:
			AsnTypeSetIndent(TRUE, aip, atp);  /* nest down to type */
			terminalvalue = FALSE;
			break;
		case BOOLEAN_TYPE:
			valueptr->boolvalue = AsnLexReadBoolean(aip, atp);
			break;
		case INTEGER_TYPE:
		case ENUM_TYPE:
			valueptr->intvalue = AsnLexReadInteger(aip, atp);
			break;
		case BIGINT_TYPE:
			valueptr->bigintvalue = AsnLexReadBigInt(aip, atp);
			break;
		case REAL_TYPE:
			valueptr->realvalue = AsnLexReadReal(aip, atp);
			break;
		case GENERALSTRING_TYPE:
			if (read_value)
			{
				valueptr->ptrvalue = AsnLexReadString(aip, atp);
				if (valueptr->ptrvalue == NULL)
					return 0;
			}
			else
			{
				if (! AsnLexSkipString(aip, atp))
					return 0;
			}
			break;
		case UTF8STRING_TYPE:
			if (read_value)
			{
				valueptr->ptrvalue = AsnLexReadStringUTF8(aip, atp);
				if (valueptr->ptrvalue == NULL)
					return 0;
			}
			else
			{
				if (! AsnLexSkipStringUTF8(aip, atp))
					return 0;
			}
			break;
		case NULL_TYPE:
			AsnLexReadNull(aip, atp);
			break;
		case OCTETS_TYPE:
			if (read_value)
			{
				valueptr->ptrvalue = AsnLexReadOctets(aip, atp);
				if (valueptr->ptrvalue == NULL) return 0;
			}
			else
				AsnLexSkipOctets(aip, atp);
			break;
		case STRSTORE_TYPE:
			if (read_value)
			{
				valueptr->ptrvalue = (ByteStorePtr) AsnLexReadString(aip, atp);
				if (valueptr->ptrvalue == NULL)
					return 0;
			}
			else
			{
				if (! AsnLexSkipString(aip, atp))
					return 0;
			}
			break;
		default:
			AsnIoErrorMsg(aip, 38,  AsnErrGetTypeName(atp->name),aip->linenumber);
			return 0;
	}

	if (terminalvalue)       /* pop out of any CHOICE nests */
	{
		while ((aip->type_indent) &&
			(AsnFindBaseIsa(aip->typestack[aip->type_indent - 1].type) == CHOICE_TYPE))
			AsnTypeSetIndent(FALSE, aip, atp);
	}

	return retval;
}
Exemple #11
0
/*****************************************************************************
*
*   PrintFormatTraverse(pfp, pflp, index, indent)
*
*****************************************************************************/
NLM_EXTERN Int2 PrintFormatTraverse(PrintFormatPtr pfp, PrintFormatListPtr pflp, Int2 index, Int2 indent)
{
	PrintFormatItemPtr pfip;
	CharPtr template_format;
	PrintTemplatePtr usetemplate;
	Int2 count = 0, retcount;
	PrintFormBlockPtr pfbp;
	AsnTypePtr atp;
	AsnTypePtr PNTR typeptr = NULL;
	Int2 typecount = 0;

	while (pfp != NULL)
	{
		usetemplate = NULL;
		if (pfp->form->choice == PrintForm_use_template)
		{
			template_format = (CharPtr)(pfp->form->data.ptrvalue);
			usetemplate = PrintTemplateFind(template_format);
			if (usetemplate == NULL)
			{
				ErrPost(CTX_OBJPRT, 1, "..couldn't find template [%s]\n", template_format);
				return 0;
			}
			
		}
		if (pflp != NULL)
		{
			pfip = &(pflp->list[index]);
			pfip->sort_key = index;
			pfip->indent_level = indent;
			pfip->format = pfp;
			atp = AsnFind(pfp->asn1);   /* get the node */
			if (atp == NULL)
			{
				ErrPost(CTX_OBJPRT, 1, "PrintFormatTraverse: can't find [%s]", pfp->asn1);
				return 0;
			}
			pfip->atp = atp;
			pfip->isa = AsnFindBaseIsa(atp);
			
			pfip->_template = usetemplate;
			typeptr = AsnTypePathFind(NULL, pfp->asn1, &typecount);
			if (typeptr == NULL)
				return 0;
			pfip->types = typeptr;
			pfip->numtypes = typecount;

		}
		index++;
		count++;
		if (pfp->form->choice == PrintForm_block)
		{
			pfbp = (PrintFormBlockPtr)(pfp->form->data.ptrvalue);
			retcount = PrintFormatTraverse(pfbp->components, pflp, index, (Int2)(indent+1));

			if (retcount == 0)  /* failure */
				return 0;
			count += retcount;
			index += retcount;
		}
		pfp = pfp->next;
	}
	return count;
}