void addToStanza(struct tagStorm *storm, struct tagStanza *stanza, void *context)
/* Check up on one stanza, updating stats and if need be making a uuid */
{
struct missingContext *mc = context;
mc->stanzaCount += 1;
char *id = tagFindLocalVal(stanza, mc->idTag);
if (id != NULL)
    mc->idFound += 1;
char *uuid = tagFindLocalVal(stanza, mc->uuidTag);
if (uuid != NULL)
    mc->uuidFound += 1;
if (id != NULL && uuid == NULL)
    {
    uuid = hashFindVal(mc->idToUuid, id);
    if (uuid == NULL)
        {
	uuid = needMem(UUID_STRING_SIZE);
	makeUuidString(uuid);
	mc->uuidMade += 1;
	hashAdd(mc->idToUuid, id, uuid);
	tagStanzaAppend(storm, stanza, mc->uuidTag, uuid);
	}
    else
	{
	if (!mc->dupeOk)
	   errAbort("The %s %s is duplicated in %s", mc->idTag, id, storm->fileName);
	}
    }
}
示例#2
0
void output(int depth, struct rqlStatement *rql, struct tagStorm *tags, struct tagStanza *stanza)
/* Output stanza according to clOut */
{
char *format = clOut;
if (sameString(format, "ra"))
    {
    if (stanza->children == NULL)
	{
	struct slName *field;
	for (field = rql->fieldList; field != NULL; field = field->next)
	    {
	    char *val = tagFindVal(stanza, field->name);
	    if (val != NULL)
		printf("%s\t%s\n", field->name, val);
	    }
	printf("\n");
	}
    }
else if (sameString(format, "tab"))
    {
    if (stanza->children == NULL)
	{
	struct slName *field;
	char *connector = "";
	for (field = rql->fieldList; field != NULL; field = field->next)
	    {
	    char *val = emptyForNull(tagFindVal(stanza, field->name));
	    printf("%s%s", connector, val);
	    connector = "\t";
	    }
	printf("\n");
	}
    }
else if (sameString(format, "tags"))
    {
    struct slName *field;
    for (field = rql->fieldList; field != NULL; field = field->next)
	{
	char *val = tagFindLocalVal(stanza, field->name);
	if (val != NULL)
	    {
	    repeatCharOut(stdout, '\t', depth);
	    printf("%s\t%s\n", field->name, val);
	    }
	}
    printf("\n");
    }
else
    errAbort("Unrecognized format %s", format);
}
void dupeValToNewTag(struct tagStorm *storm, struct tagStanza *stanzaList, 
    char *oldTag, char *newTag)
/* Everywhere see oldTag also make newTag with same value */
{
struct tagStanza *stanza;
for (stanza = stanzaList; stanza != NULL; stanza = stanza->next)
    {
    char *val = tagFindLocalVal(stanza, oldTag);
    if (val != NULL)
        tagStanzaAppend(storm, stanza, newTag, val);
    if (stanza->children)
        dupeValToNewTag(storm, stanza->children, oldTag, newTag);
    }
}