Changeset View
Changeset View
Standalone View
Standalone View
lib/libgeom/geom_xml2tree.c
| Show All 30 Lines | |||||
| #include <sys/types.h> | #include <sys/types.h> | ||||
| #include <sys/mman.h> | #include <sys/mman.h> | ||||
| #include <sys/queue.h> | #include <sys/queue.h> | ||||
| #include <sys/sbuf.h> | #include <sys/sbuf.h> | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
| #include <assert.h> | |||||
| #include <ctype.h> | #include <ctype.h> | ||||
| #include <err.h> | #include <err.h> | ||||
| #include <errno.h> | #include <errno.h> | ||||
| #include <fcntl.h> | #include <fcntl.h> | ||||
| #include <inttypes.h> | #include <inttypes.h> | ||||
| #include <paths.h> | #include <paths.h> | ||||
| #include <stdio.h> | #include <stdio.h> | ||||
| #include <stdlib.h> | #include <stdlib.h> | ||||
| ▲ Show 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | geom_lookupid(const struct gmesh *gmp, const void *id) | ||||
| for (gip = gmp->lg_ident; gip->lg_id != NULL; gip++) | for (gip = gmp->lg_ident; gip->lg_id != NULL; gip++) | ||||
| if (gip->lg_id == id) | if (gip->lg_id == id) | ||||
| return (gip); | return (gip); | ||||
| return (NULL); | return (NULL); | ||||
| } | } | ||||
| static void * | static void * | ||||
| geom_lookupidptr(struct gmesh *gmp, const void *id) | geom_lookup_class(const struct gmesh *gmp, const void *id) | ||||
| { | { | ||||
| struct gident *gip; | struct gident *gip; | ||||
| gip = geom_lookupid(gmp, id); | if ((gip = geom_lookupid(gmp, id)) == NULL) | ||||
| if (gip) | return (NULL); | ||||
| assert(gip->lg_what == ISCLASS); | |||||
| return (gip->lg_ptr); | return (gip->lg_ptr); | ||||
| } | |||||
| static void * | |||||
| geom_lookup_geom(const struct gmesh *gmp, const void *id) | |||||
| { | |||||
| struct gident *gip; | |||||
| if ((gip = geom_lookupid(gmp, id)) == NULL) | |||||
| return (NULL); | return (NULL); | ||||
| assert(gip->lg_what == ISGEOM); | |||||
| return (gip->lg_ptr); | |||||
| } | } | ||||
| static void * | |||||
| geom_lookup_provider(const struct gmesh *gmp, const void *id) | |||||
| { | |||||
| struct gident *gip; | |||||
| if ((gip = geom_lookupid(gmp, id)) == NULL) | |||||
| return (NULL); | |||||
| assert(gip->lg_what == ISPROVIDER); | |||||
| return (gip->lg_ptr); | |||||
| } | |||||
| static void * __unused | |||||
| geom_lookup_consumer(const struct gmesh *gmp, const void *id) | |||||
| { | |||||
| struct gident *gip; | |||||
| if ((gip = geom_lookupid(gmp, id)) == NULL) | |||||
| return (NULL); | |||||
| assert(gip->lg_what == ISCONSUMER); | |||||
| return (gip->lg_ptr); | |||||
| } | |||||
| int | int | ||||
| geom_xml2tree(struct gmesh *gmp, char *p) | geom_xml2tree(struct gmesh *gmp, char *p) | ||||
| { | { | ||||
| XML_Parser parser; | XML_Parser parser; | ||||
| struct mystate *mt; | struct mystate *mt; | ||||
| struct gclass *cl; | struct gclass *cl; | ||||
| struct ggeom *ge; | struct ggeom *ge; | ||||
| struct gprovider *pr; | struct gprovider *pr; | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | LIST_FOREACH(ge, &cl->lg_geom, lg_geom) { | ||||
| gmp->lg_ident[i].lg_what = ISCONSUMER; | gmp->lg_ident[i].lg_what = ISCONSUMER; | ||||
| i++; | i++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* Substitute all identifiers */ | /* Substitute all identifiers */ | ||||
| LIST_FOREACH(cl, &gmp->lg_class, lg_class) { | LIST_FOREACH(cl, &gmp->lg_class, lg_class) { | ||||
| LIST_FOREACH(ge, &cl->lg_geom, lg_geom) { | LIST_FOREACH(ge, &cl->lg_geom, lg_geom) { | ||||
| ge->lg_class = geom_lookupidptr(gmp, ge->lg_class); | ge->lg_class = geom_lookup_class(gmp, ge->lg_class); | ||||
| LIST_FOREACH(pr, &ge->lg_provider, lg_provider) { | LIST_FOREACH(pr, &ge->lg_provider, lg_provider) { | ||||
| pr->lg_geom = geom_lookupidptr(gmp, pr->lg_geom); | pr->lg_geom = geom_lookup_geom(gmp, pr->lg_geom); | ||||
| } | } | ||||
| LIST_FOREACH(co, &ge->lg_consumer, lg_consumer) { | LIST_FOREACH(co, &ge->lg_consumer, lg_consumer) { | ||||
| co->lg_geom = geom_lookupidptr(gmp, co->lg_geom); | co->lg_geom = geom_lookup_geom(gmp, co->lg_geom); | ||||
| if (co->lg_provider != NULL) { | if (co->lg_provider != NULL) { | ||||
| co->lg_provider = geom_lookupidptr(gmp, | co->lg_provider = geom_lookup_provider(gmp, | ||||
| co->lg_provider); | co->lg_provider); | ||||
| if (co->lg_provider != NULL) { | if (co->lg_provider != NULL) { | ||||
| LIST_INSERT_HEAD( | LIST_INSERT_HEAD( | ||||
| &co->lg_provider->lg_consumers, | &co->lg_provider->lg_consumers, | ||||
| co, lg_consumers); | co, lg_consumers); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines | |||||