From: John Ellson Date: Wed, 16 Oct 2013 18:01:45 +0000 (-0400) Subject: run through 'indent -l132 -nut' X-Git-Tag: 2.38.0~235^2~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=79b80f4ecbf8e5a45ec32edfd3e4e4a5aca2ac51;p=graphviz run through 'indent -l132 -nut' --- diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index 8d22012ed..2f92b07b5 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -45,7 +45,7 @@ extern int strcasecmp(const char *s1, const char *s2); * inititialized here by redefining ELEM and reinvoking APIS. */ #define ELEM(x) #x, -static char *api_names[] = { APIS }; /* "render", "layout", ... */ +static char *api_names[] = { APIS }; /* "render", "layout", ... */ #undef ELEM @@ -55,17 +55,17 @@ api_t gvplugin_api(char *str) int api; for (api = 0; api < ARRAY_SIZE(api_names); api++) { - if (strcmp(str, api_names[api]) == 0) - return (api_t) api; + if (strcmp(str, api_names[api]) == 0) + return (api_t) api; } - return -1; /* invalid api */ + return -1; /* invalid api */ } /* translate api_t into string name, or NULL */ char *gvplugin_api_name(api_t api) { if (api < 0 || api >= ARRAY_SIZE(api_names)) - return NULL; + return NULL; return api_names[api]; } @@ -75,42 +75,42 @@ char *gvplugin_api_name(api_t api) * last install wins. */ boolean gvplugin_install(GVC_t * gvc, api_t api, const char *typestr, - int quality, gvplugin_package_t * package, gvplugin_installed_t * typeptr) + int quality, gvplugin_package_t * package, gvplugin_installed_t * typeptr) { gvplugin_available_t *plugin, **pnext; #define TYPSIZ 63 char *p, pins[TYPSIZ + 1], pnxt[TYPSIZ + 1]; if (api < 0) - return FALSE; + return FALSE; strncpy(pins, typestr, TYPSIZ); if ((p = strchr(pins, ':'))) - *p = '\0'; + *p = '\0'; /* point to the beginning of the linked list of plugins for this api */ pnext = &(gvc->apis[api]); /* keep alpha-sorted and insert new duplicates ahead of old */ while (*pnext) { - strncpy(pnxt, (*pnext)->typestr, TYPSIZ); - if ((p = strchr(pnxt, ':'))) - *p = '\0'; - if (strcmp(pins, pnxt) <= 0) - break; - pnext = &((*pnext)->next); + strncpy(pnxt, (*pnext)->typestr, TYPSIZ); + if ((p = strchr(pnxt, ':'))) + *p = '\0'; + if (strcmp(pins, pnxt) <= 0) + break; + pnext = &((*pnext)->next); } /* keep quality sorted within type and insert new duplicates ahead of old */ while (*pnext) { - strncpy(pnxt, (*pnext)->typestr, TYPSIZ); - if ((p = strchr(pnxt, ':'))) - *p = '\0'; - if (strcmp(pins, pnxt) != 0) - break; - if (quality >= (*pnext)->quality) - break; - pnext = &((*pnext)->next); + strncpy(pnxt, (*pnext)->typestr, TYPSIZ); + if ((p = strchr(pnxt, ':'))) + *p = '\0'; + if (strcmp(pins, pnxt) != 0) + break; + if (quality >= (*pnext)->quality) + break; + pnext = &((*pnext)->next); } plugin = GNEW(gvplugin_available_t); @@ -119,7 +119,7 @@ boolean gvplugin_install(GVC_t * gvc, api_t api, const char *typestr, plugin->typestr = typestr; plugin->quality = quality; plugin->package = package; - plugin->typeptr = typeptr; /* null if not loaded */ + plugin->typeptr = typeptr; /* null if not loaded */ return TRUE; } @@ -132,26 +132,26 @@ boolean gvplugin_install(GVC_t * gvc, api_t api, const char *typestr, * manually changed in the config file. */ static boolean gvplugin_activate(GVC_t * gvc, api_t api, - const char *typestr, char *name, char *path, gvplugin_installed_t * typeptr) + const char *typestr, char *name, char *path, gvplugin_installed_t * typeptr) { gvplugin_available_t **pnext; if (api < 0) - return FALSE; + return FALSE; /* point to the beginning of the linked list of plugins for this api */ pnext = &(gvc->apis[api]); while (*pnext) { - if ((strcasecmp(typestr, (*pnext)->typestr) == 0) - && (strcasecmp(name, (*pnext)->package->name) == 0) - && ((*pnext)->package->path != 0) - && (strcasecmp(path, (*pnext)->package->path) == 0)) { - (*pnext)->typeptr = typeptr; - return TRUE; - } - pnext = &((*pnext)->next); + if ((strcasecmp(typestr, (*pnext)->typestr) == 0) + && (strcasecmp(name, (*pnext)->package->name) == 0) + && ((*pnext)->package->path != 0) + && (strcasecmp(path, (*pnext)->package->path) == 0)) { + (*pnext)->typeptr = typeptr; + return TRUE; + } + pnext = &((*pnext)->next); } return FALSE; } @@ -169,40 +169,40 @@ gvplugin_library_t *gvplugin_library_load(GVC_t * gvc, char *path) char *suffix = "_LTX_library"; if (!gvc->common.demand_loading) - return NULL; + return NULL; libdir = gvconfig_libdir(gvc); len = strlen(libdir) + 1 + strlen(path) + 1; if (len > lenp) { - lenp = len + 20; - if (p) - p = grealloc(p, lenp); - else - p = gmalloc(lenp); + lenp = len + 20; + if (p) + p = grealloc(p, lenp); + else + p = gmalloc(lenp); } #ifdef WIN32 if (path[1] == ':') { #else if (path[0] == '/') { #endif - strcpy(p, path); + strcpy(p, path); } else { - strcpy(p, libdir); - strcat(p, DIRSEP); - strcat(p, path); + strcpy(p, libdir); + strcat(p, DIRSEP); + strcat(p, path); } if (lt_dlinit()) { - agerr(AGERR, "failed to init libltdl\n"); - return NULL; + agerr(AGERR, "failed to init libltdl\n"); + return NULL; } hndl = lt_dlopen(p); if (!hndl) { - agerr(AGWARN, "Could not load \"%s\" - %s\n", p, (char *) lt_dlerror()); - return NULL; + agerr(AGWARN, "Could not load \"%s\" - %s\n", p, (char *) lt_dlerror()); + return NULL; } if (gvc->common.verbose >= 2) - fprintf(stderr, "Loading %s\n", p); + fprintf(stderr, "Loading %s\n", p); s = strrchr(p, DIRSEP[0]); len = strlen(s); @@ -211,27 +211,27 @@ gvplugin_library_t *gvplugin_library_load(GVC_t * gvc, char *path) #else if (len < strlen("/libgvplugin_x")) { #endif - agerr(AGERR, "invalid plugin path \"%s\"\n", p); - return NULL; + agerr(AGERR, "invalid plugin path \"%s\"\n", p); + return NULL; } sym = gmalloc(len + strlen(suffix) + 1); #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) - strcpy(sym, s + 1); /* strip leading "/" */ + strcpy(sym, s + 1); /* strip leading "/" */ #else - strcpy(sym, s + 4); /* strip leading "/lib" or "/cyg" */ + strcpy(sym, s + 4); /* strip leading "/lib" or "/cyg" */ #endif #if defined(__CYGWIN__) || defined(__MINGW32__) - s = strchr(sym, '-'); /* strip trailing "-1.dll" */ + s = strchr(sym, '-'); /* strip trailing "-1.dll" */ #else - s = strchr(sym, '.'); /* strip trailing ".so.0" or ".dll" or ".sl" */ + s = strchr(sym, '.'); /* strip trailing ".so.0" or ".dll" or ".sl" */ #endif - strcpy(s, suffix); /* append "_LTX_library" */ + strcpy(s, suffix); /* append "_LTX_library" */ ptr = lt_dlsym(hndl, sym); if (!ptr) { - agerr(AGERR, "failed to resolve %s in %s\n", sym, p); - free(sym); - return NULL; + agerr(AGERR, "failed to resolve %s in %s\n", sym, p); + free(sym); + return NULL; } free(sym); return (gvplugin_library_t *) (ptr); @@ -268,68 +268,68 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) /* check for valid apis[] index */ if (api < 0) - return NULL; + return NULL; if (api == API_device || api == API_loadimage) - /* api dependencies - FIXME - find better way to code these *s */ - apidep = API_render; + /* api dependencies - FIXME - find better way to code these *s */ + apidep = API_render; else - apidep = api; + apidep = api; strncpy(reqtyp, str, TYPBUFSIZ - 1); reqdep = strchr(reqtyp, ':'); if (reqdep) { - *reqdep++ = '\0'; - reqpkg = strchr(reqdep, ':'); - if (reqpkg) - *reqpkg++ = '\0'; + *reqdep++ = '\0'; + reqpkg = strchr(reqdep, ':'); + if (reqpkg) + *reqpkg++ = '\0'; } else - reqpkg = NULL; + reqpkg = NULL; /* iterate the linked list of plugins for this api */ for (pnext = &(gvc->apis[api]); *pnext; pnext = &((*pnext)->next)) { - strncpy(typ, (*pnext)->typestr, TYPBUFSIZ - 1); - dep = strchr(typ, ':'); - if (dep) - *dep++ = '\0'; - if (strcmp(typ, reqtyp)) - continue; /* types empty or mismatched */ - if (dep && reqdep && strcmp(dep, reqdep)) - continue; /* dependencies not empty, but mismatched */ - if (!reqpkg || strcmp(reqpkg, (*pnext)->package->name) == 0) { - /* found with no packagename constraints, or with required matching packagname */ - - if (dep && (apidep != api)) /* load dependency if needed, continue if can't find */ - if (!(gvplugin_load(gvc, apidep, dep))) - continue; - break; - } + strncpy(typ, (*pnext)->typestr, TYPBUFSIZ - 1); + dep = strchr(typ, ':'); + if (dep) + *dep++ = '\0'; + if (strcmp(typ, reqtyp)) + continue; /* types empty or mismatched */ + if (dep && reqdep && strcmp(dep, reqdep)) + continue; /* dependencies not empty, but mismatched */ + if (!reqpkg || strcmp(reqpkg, (*pnext)->package->name) == 0) { + /* found with no packagename constraints, or with required matching packagname */ + + if (dep && (apidep != api)) /* load dependency if needed, continue if can't find */ + if (!(gvplugin_load(gvc, apidep, dep))) + continue; + break; + } } rv = *pnext; if (rv && rv->typeptr == NULL) { - library = gvplugin_library_load(gvc, rv->package->path); - if (library) { - - /* Now activate the library with real type ptrs */ - for (apis = library->apis; (types = apis->types); apis++) { - for (i = 0; types[i].type; i++) { - /* NB. quality is not checked or replaced - * in case user has manually edited quality in config */ - gvplugin_activate(gvc, apis->api, types[i].type, library->packagename, rv->package->path, &types[i]); - } - } - if (gvc->common.verbose >= 1) - fprintf(stderr, "Activated plugin library: %s\n", rv->package->path ? rv->package->path : ""); - } + library = gvplugin_library_load(gvc, rv->package->path); + if (library) { + + /* Now activate the library with real type ptrs */ + for (apis = library->apis; (types = apis->types); apis++) { + for (i = 0; types[i].type; i++) { + /* NB. quality is not checked or replaced + * in case user has manually edited quality in config */ + gvplugin_activate(gvc, apis->api, types[i].type, library->packagename, rv->package->path, &types[i]); + } + } + if (gvc->common.verbose >= 1) + fprintf(stderr, "Activated plugin library: %s\n", rv->package->path ? rv->package->path : ""); + } } /* one last check for successfull load */ if (rv && rv->typeptr == NULL) - rv = NULL; + rv = NULL; if (rv && gvc->common.verbose >= 1) - fprintf(stderr, "Using %s: %s:%s\n", api_names[api], rv->typestr, rv->package->name); + fprintf(stderr, "Using %s: %s:%s\n", api_names[api], rv->typestr, rv->package->name); gvc->api[api] = rv; return rv; @@ -349,70 +349,70 @@ char *gvplugin_list(GVC_t * gvc, api_t api, const char *str) /* check for valid apis[] index */ if (api < 0) - return NULL; + return NULL; /* check for valid str */ if (!str) - return NULL; + return NULL; if (first) { - agxbinit(&xb, 0, 0); - first = 0; + agxbinit(&xb, 0, 0); + first = 0; } /* does str have a :path modifier? */ s = strdup(str); p = strchr(s, ':'); if (p) - *p++ = '\0'; + *p++ = '\0'; /* point to the beginning of the linked list of plugins for this api */ plugin = &(gvc->apis[api]); - if (p) { /* if str contains a ':', and if we find a match for the type, - then just list the alternative paths for the plugin */ - for (pnext = plugin; *pnext; pnext = &((*pnext)->next)) { - q = strdup((*pnext)->typestr); - if ((p = strchr(q, ':'))) - *p++ = '\0'; - /* list only the matching type, or all types if s is an empty string */ - if (!s[0] || strcasecmp(s, q) == 0) { - /* list each member of the matching type as "type:path" */ - agxbputc(&xb, ' '); - agxbput(&xb, (*pnext)->typestr); - agxbputc(&xb, ':'); - agxbput(&xb, (*pnext)->package->name); - new = FALSE; - } - free(q); - } + if (p) { /* if str contains a ':', and if we find a match for the type, + then just list the alternative paths for the plugin */ + for (pnext = plugin; *pnext; pnext = &((*pnext)->next)) { + q = strdup((*pnext)->typestr); + if ((p = strchr(q, ':'))) + *p++ = '\0'; + /* list only the matching type, or all types if s is an empty string */ + if (!s[0] || strcasecmp(s, q) == 0) { + /* list each member of the matching type as "type:path" */ + agxbputc(&xb, ' '); + agxbput(&xb, (*pnext)->typestr); + agxbputc(&xb, ':'); + agxbput(&xb, (*pnext)->package->name); + new = FALSE; + } + free(q); + } } free(s); - if (new) { /* if the type was not found, or if str without ':', - then just list available types */ - typestr_last = NULL; - for (pnext = plugin; *pnext; pnext = &((*pnext)->next)) { - /* list only one instance of type */ - q = strdup((*pnext)->typestr); - if ((p = strchr(q, ':'))) - *p++ = '\0'; - if (!typestr_last || strcasecmp(typestr_last, q) != 0) { - /* list it as "type" i.e. w/o ":path" */ - agxbputc(&xb, ' '); - agxbput(&xb, q); - new = FALSE; - } - if (!typestr_last) - free(typestr_last); - typestr_last = q; - } - if (!typestr_last) - free(typestr_last); + if (new) { /* if the type was not found, or if str without ':', + then just list available types */ + typestr_last = NULL; + for (pnext = plugin; *pnext; pnext = &((*pnext)->next)) { + /* list only one instance of type */ + q = strdup((*pnext)->typestr); + if ((p = strchr(q, ':'))) + *p++ = '\0'; + if (!typestr_last || strcasecmp(typestr_last, q) != 0) { + /* list it as "type" i.e. w/o ":path" */ + agxbputc(&xb, ' '); + agxbput(&xb, q); + new = FALSE; + } + if (!typestr_last) + free(typestr_last); + typestr_last = q; + } + if (!typestr_last) + free(typestr_last); } if (new) - bp = ""; + bp = ""; else - bp = agxbuse(&xb); + bp = agxbuse(&xb); return bp; } @@ -436,29 +436,29 @@ char **gvPluginList(GVC_t * gvc, char *kind, int *sz, const char *str) char *p, *q, *typestr_last; if (!kind) - return NULL; + return NULL; for (api = 0; api < ARRAY_SIZE(api_names); api++) { - if (!strcasecmp(kind, api_names[api])) - break; + if (!strcasecmp(kind, api_names[api])) + break; } if (api == ARRAY_SIZE(api_names)) { - agerr(AGERR, "unrecognized api name \"%s\"\n", kind); - return NULL; + agerr(AGERR, "unrecognized api name \"%s\"\n", kind); + return NULL; } /* point to the beginning of the linked list of plugins for this api */ plugin = &(gvc->apis[api]); typestr_last = NULL; for (pnext = plugin; *pnext; pnext = &((*pnext)->next)) { - /* list only one instance of type */ - q = strdup((*pnext)->typestr); - if ((p = strchr(q, ':'))) - *p++ = '\0'; - if (!typestr_last || strcasecmp(typestr_last, q) != 0) { - list = RALLOC(cnt + 1, list, char *); - list[cnt++] = q; - } - typestr_last = q; + /* list only one instance of type */ + q = strdup((*pnext)->typestr); + if ((p = strchr(q, ':'))) + *p++ = '\0'; + if (!typestr_last || strcasecmp(typestr_last, q) != 0) { + list = RALLOC(cnt + 1, list, char *); + list[cnt++] = q; + } + typestr_last = q; } *sz = cnt; @@ -471,21 +471,21 @@ void gvplugin_write_status(GVC_t * gvc) #ifdef ENABLE_LTDL if (gvc->common.demand_loading) { - fprintf(stderr, "The plugin configuration file:\n\t%s\n", gvc->config_path); - if (gvc->config_found) - fprintf(stderr, "\t\twas successfully loaded.\n"); - else - fprintf(stderr, "\t\twas not found or not usable. No on-demand plugins.\n"); + fprintf(stderr, "The plugin configuration file:\n\t%s\n", gvc->config_path); + if (gvc->config_found) + fprintf(stderr, "\t\twas successfully loaded.\n"); + else + fprintf(stderr, "\t\twas not found or not usable. No on-demand plugins.\n"); } else { - fprintf(stderr, "Demand loading of plugins is disabled.\n"); + fprintf(stderr, "Demand loading of plugins is disabled.\n"); } #endif for (api = 0; api < ARRAY_SIZE(api_names); api++) { - if (gvc->common.verbose >= 2) - fprintf(stderr, " %s\t: %s\n", api_names[api], gvplugin_list(gvc, api, ":")); - else - fprintf(stderr, " %s\t: %s\n", api_names[api], gvplugin_list(gvc, api, "?")); + if (gvc->common.verbose >= 2) + fprintf(stderr, " %s\t: %s\n", api_names[api], gvplugin_list(gvc, api, ":")); + else + fprintf(stderr, " %s\t: %s\n", api_names[api], gvplugin_list(gvc, api, "?")); } } @@ -518,165 +518,165 @@ Agraph_t *gvplugin_graph(GVC_t * gvc) agxset(g, a, "Plugins"); for (package = gvc->packages; package; package = package->next) { - strcpy(bufa, "cluster_"); - strcat(bufa, package->name); - sg = agsubg(g, bufa, 1); - a = agfindgraphattr(sg, "label"); - agxset(sg, a, package->name); - strcpy(bufa, package->name); - strcat(bufa, "_"); - buf1 = bufa + strlen(bufa); - for (api = 0; api < ARRAY_SIZE(api_names); api++) { - found = 0; - strcpy(buf1, api_names[api]); - ssg = agsubg(sg, bufa, 1); - a = agfindgraphattr(ssg, "rank"); - agxset(ssg, a, "same"); - strcat(buf1, "_"); - buf2 = bufa + strlen(bufa); - for (pnext = &(gvc->apis[api]); *pnext; pnext = &((*pnext)->next)) { - if ((*pnext)->package == package) { - found++; - t = q = strdup((*pnext)->typestr); - if ((p = strchr(q, ':'))) - *p++ = '\0'; - /* Now p = renderer, e.g. "gd" - * and q = device, e.g. "png" - * or q = imageloader, e.g. "png" */ - switch (api) { - case API_device: - case API_loadimage: - - /* hack for aliases */ - if (!strncmp(q, "jp", 2)) - q = "jpeg/jpe/jpg"; - else if (!strncmp(q, "tif", 3)) - q = "tiff/tif"; - else if (!strcmp(q, "x11") || !strcmp(q, "xlib")) - q = "x11/xlib"; - else if (!strcmp(q, "dot") || !strcmp(q, "gv")) - q = "gv/dot"; - - strcpy(buf2, q); - n = agnode(ssg, bufa, 1); - a = agfindnodeattr(g, "label"); - agxset(n, a, q); - if (!(p && *p)) { - strcpy(bufb, "render_cg"); - m = agfindnode(sg, bufb); - if (!m) { - m = agnode(sg, bufb, 1); - a = agfindgraphattr(g, "label"); - agxset(m, a, "cg"); - } - agedge(sg, m, n, NULL, 1); - } - break; - case API_render: - strcpy(bufb, api_names[api]); - strcat(bufb, "_"); - strcat(bufb, q); - n = agnode(ssg, bufb, 1); - a = agfindnodeattr(g, "label"); - agxset(n, a, q); - break; - default: - break; - } - free(t); - } - } - if (!found) - agdelete(sg, ssg); - } + strcpy(bufa, "cluster_"); + strcat(bufa, package->name); + sg = agsubg(g, bufa, 1); + a = agfindgraphattr(sg, "label"); + agxset(sg, a, package->name); + strcpy(bufa, package->name); + strcat(bufa, "_"); + buf1 = bufa + strlen(bufa); + for (api = 0; api < ARRAY_SIZE(api_names); api++) { + found = 0; + strcpy(buf1, api_names[api]); + ssg = agsubg(sg, bufa, 1); + a = agfindgraphattr(ssg, "rank"); + agxset(ssg, a, "same"); + strcat(buf1, "_"); + buf2 = bufa + strlen(bufa); + for (pnext = &(gvc->apis[api]); *pnext; pnext = &((*pnext)->next)) { + if ((*pnext)->package == package) { + found++; + t = q = strdup((*pnext)->typestr); + if ((p = strchr(q, ':'))) + *p++ = '\0'; + /* Now p = renderer, e.g. "gd" + * and q = device, e.g. "png" + * or q = imageloader, e.g. "png" */ + switch (api) { + case API_device: + case API_loadimage: + + /* hack for aliases */ + if (!strncmp(q, "jp", 2)) + q = "jpeg/jpe/jpg"; + else if (!strncmp(q, "tif", 3)) + q = "tiff/tif"; + else if (!strcmp(q, "x11") || !strcmp(q, "xlib")) + q = "x11/xlib"; + else if (!strcmp(q, "dot") || !strcmp(q, "gv")) + q = "gv/dot"; + + strcpy(buf2, q); + n = agnode(ssg, bufa, 1); + a = agfindnodeattr(g, "label"); + agxset(n, a, q); + if (!(p && *p)) { + strcpy(bufb, "render_cg"); + m = agfindnode(sg, bufb); + if (!m) { + m = agnode(sg, bufb, 1); + a = agfindgraphattr(g, "label"); + agxset(m, a, "cg"); + } + agedge(sg, m, n, NULL, 1); + } + break; + case API_render: + strcpy(bufb, api_names[api]); + strcat(bufb, "_"); + strcat(bufb, q); + n = agnode(ssg, bufb, 1); + a = agfindnodeattr(g, "label"); + agxset(n, a, q); + break; + default: + break; + } + free(t); + } + } + if (!found) + agdelete(sg, ssg); + } } ssg = agsubg(g, "output_formats", 1); a = agfindgraphattr(ssg, "rank"); agxset(ssg, a, "same"); for (package = gvc->packages; package; package = package->next) { - strcpy(bufa, package->name); - strcat(bufa, "_"); - buf1 = bufa + strlen(bufa); - for (api = 0; api < ARRAY_SIZE(api_names); api++) { - strcpy(buf1, api_names[api]); - strcat(buf1, "_"); - buf2 = bufa + strlen(bufa); - for (pnext = &(gvc->apis[api]); *pnext; pnext = &((*pnext)->next)) { - if ((*pnext)->package == package) { - t = q = strdup((*pnext)->typestr); - if ((p = strchr(q, ':'))) - *p++ = '\0'; - /* Now p = renderer, e.g. "gd" - * and q = device, e.g. "png" - * or q = imageloader, e.g. "png" */ - - /* hack for aliases */ - if (!strncmp(q, "jp", 2)) - q = "jpeg/jpe/jpg"; - else if (!strncmp(q, "tif", 3)) - q = "tiff/tif"; - else if (!strcmp(q, "x11") || !strcmp(q, "xlib")) - q = "x11/xlib"; - else if (!strcmp(q, "dot") || !strcmp(q, "gv")) - q = "gv/dot"; - - switch (api) { - case API_device: - strcpy(buf2, q); - n = agnode(g, bufa, 1); - strcpy(bufb, "output_"); - strcat(bufb, q); - m = agfindnode(ssg, bufb); - if (!m) { - m = agnode(ssg, bufb, 1); - a = agfindnodeattr(g, "label"); - agxset(m, a, q); - } - e = agfindedge(g, n, m); - if (!e) - e = agedge(g, n, m, NULL, 1); - if (p && *p) { - strcpy(bufb, "render_"); - strcat(bufb, p); - m = agfindnode(ssg, bufb); - if (!m) - m = agnode(g, bufb, 1); - e = agfindedge(g, m, n); - if (!e) - e = agedge(g, m, n, NULL, 1); - } - break; - case API_loadimage: - strcpy(buf2, q); - n = agnode(g, bufa, 1); - strcpy(bufb, "input_"); - strcat(bufb, q); - m = agfindnode(g, bufb); - if (!m) { - m = agnode(g, bufb, 1); - a = agfindnodeattr(g, "label"); - agxset(m, a, q); - } - e = agfindedge(g, m, n); - if (!e) - e = agedge(g, m, n, NULL, 1); - strcpy(bufb, "render_"); - strcat(bufb, p); - m = agfindnode(g, bufb); - if (!m) - m = agnode(g, bufb, 1); - e = agfindedge(g, n, m); - if (!e) - e = agedge(g, n, m, NULL, 1); - break; - default: - break; - } - free(t); - } - } - } + strcpy(bufa, package->name); + strcat(bufa, "_"); + buf1 = bufa + strlen(bufa); + for (api = 0; api < ARRAY_SIZE(api_names); api++) { + strcpy(buf1, api_names[api]); + strcat(buf1, "_"); + buf2 = bufa + strlen(bufa); + for (pnext = &(gvc->apis[api]); *pnext; pnext = &((*pnext)->next)) { + if ((*pnext)->package == package) { + t = q = strdup((*pnext)->typestr); + if ((p = strchr(q, ':'))) + *p++ = '\0'; + /* Now p = renderer, e.g. "gd" + * and q = device, e.g. "png" + * or q = imageloader, e.g. "png" */ + + /* hack for aliases */ + if (!strncmp(q, "jp", 2)) + q = "jpeg/jpe/jpg"; + else if (!strncmp(q, "tif", 3)) + q = "tiff/tif"; + else if (!strcmp(q, "x11") || !strcmp(q, "xlib")) + q = "x11/xlib"; + else if (!strcmp(q, "dot") || !strcmp(q, "gv")) + q = "gv/dot"; + + switch (api) { + case API_device: + strcpy(buf2, q); + n = agnode(g, bufa, 1); + strcpy(bufb, "output_"); + strcat(bufb, q); + m = agfindnode(ssg, bufb); + if (!m) { + m = agnode(ssg, bufb, 1); + a = agfindnodeattr(g, "label"); + agxset(m, a, q); + } + e = agfindedge(g, n, m); + if (!e) + e = agedge(g, n, m, NULL, 1); + if (p && *p) { + strcpy(bufb, "render_"); + strcat(bufb, p); + m = agfindnode(ssg, bufb); + if (!m) + m = agnode(g, bufb, 1); + e = agfindedge(g, m, n); + if (!e) + e = agedge(g, m, n, NULL, 1); + } + break; + case API_loadimage: + strcpy(buf2, q); + n = agnode(g, bufa, 1); + strcpy(bufb, "input_"); + strcat(bufb, q); + m = agfindnode(g, bufb); + if (!m) { + m = agnode(g, bufb, 1); + a = agfindnodeattr(g, "label"); + agxset(m, a, q); + } + e = agfindedge(g, m, n); + if (!e) + e = agedge(g, m, n, NULL, 1); + strcpy(bufb, "render_"); + strcat(bufb, p); + m = agfindnode(g, bufb); + if (!m) + m = agnode(g, bufb, 1); + e = agfindedge(g, n, m); + if (!e) + e = agedge(g, n, m, NULL, 1); + break; + default: + break; + } + free(t); + } + } + } } return g;