Index: abstract.c =================================================================== --- abstract.c (revision 694) +++ abstract.c (revision 695) @@ -37,6 +37,7 @@ { memset(abs, 0, sizeof(csch_abstract_t)); htsp_init(&abs->nets, strhash, strkeyeq); + htsp_init(&abs->comps, strhash, strkeyeq); } /* Initialize an object by setting the common header fields; the only purpose @@ -63,7 +64,22 @@ return net; } +csch_acomp_t *csch_acomp_get(csch_abstract_t *abs, const char *name, int alloc) +{ + csch_acomp_t *comp; + comp = htsp_get(&abs->comps, name); + if ((comp != NULL) || (!alloc)) + return comp; + + comp = calloc(sizeof(csch_acomp_t), 1); + csch_aobj_init(&comp->hdr, CSCH_ATYPE_COMP); + comp->name = csch_strdup(name); + htsp_set(&abs->comps, comp->name, comp); + return comp; +} + + static void dump_attr(const csch_attribs_t *attr, FILE *f, const char *prefix1, const char *prefix2) { htsp_entry_t *e; @@ -84,4 +100,11 @@ fprintf(f, "%s %s\n", prefix, net->netname); dump_attr(&net->hdr.attr, f, prefix, " "); } + + fprintf(f, "%sComponents:\n", prefix); + for(e = htsp_first(&abs->comps); e != NULL; e = htsp_next(&abs->comps, e)) { + csch_acomp_t *comp = e->value; + fprintf(f, "%s %s\n", prefix, comp->name); + dump_attr(&comp->hdr.attr, f, prefix, " "); + } }