char *metaTagVal(struct meta *meta, char *name) /* Return value of tag found in this node or if its not there in parents. * Returns NULL if tag not found. */ { struct meta *m; for (m = meta; m != NULL; m = m->parent) { char *val = metaLocalTagVal(m, name); if (val != NULL) return val; } return NULL; }
struct meta *metaFindFirstMatch(struct meta *metaList, char *tag, char *val) /* Find first meta on list (including children) that has tag matching val */ { struct meta *meta; for (meta = metaList; meta != NULL; meta = meta->next) { /* Do depth first search so low level tags override higher. */ if (meta->children) { struct meta *match = metaFindFirstMatch(meta->children, tag, val); if (match != NULL) return match; } char *ourVal = metaLocalTagVal(meta, tag); if (ourVal != NULL && sameString(ourVal, val)) return meta; } return NULL; }
char *allSameVal(char *tag, struct meta *metaList) /* Return value of tag if it exists and is the same in each meta on list */ { char *val = NULL; struct meta *meta; for (meta = metaList; meta != NULL; meta = meta->next) { char *oneVal = metaLocalTagVal(meta, tag); if (oneVal == NULL) return NULL; if (val == NULL) val = oneVal; else { if (!sameString(oneVal, val)) return NULL; } } return val; }