codegen_info_t *p;
for (p = cg; p->name; ++p)
- gvplugin_install(gvc, API_render, p->name, 0, "cg",
- (gvplugin_type_t *) p);
+ gvplugin_install(gvc,
+ API_render,
+ p->name,
+ 0,
+ "cg",
+ NULL,
+ (gvplugin_type_t *) p);
#endif
}
/* plugins */
extern boolean gvplugin_install(GVC_t * gvc, api_t api,
- char *typestr, int quality, char *path,
- gvplugin_type_t * typeptr);
+ char *typestr, int quality, char *packagename, char *path,
+ gvplugin_type_t * typeptr);
extern gv_plugin_t *gvplugin_load(GVC_t * gvc, api_t api, char *type);
extern gvplugin_library_t *gvplugin_library_load(char *path);
extern const char *gvplugin_list(GVC_t * gvc, api_t api, char *str);
void *window; /* display-specific data for gvrender plugin */
};
-/* gv_plugin_t is a descriptor for available plugins; gvplugin_t is for installed plugins */
+/* gv_plugin_t is a descriptor for available plugins;
+ gvplugin_t is for installed plugins */
typedef struct gv_plugin_s gv_plugin_t;
struct gv_plugin_s {
- gv_plugin_t *next;
- char *typestr;
- int quality;
- char *path;
- gvplugin_type_t *typeptr;
+ gv_plugin_t *next; /* next plugin in linked list, or NULL */
+ char *typestr; /* type string, e.g. "png" or "ps" */
+ int quality; /* programmer assigned quality
+ ranking within type (+ve or -ve int)
+ - codegens have quality = 0 */
+ char *path; /* file path to library containing plugin,
+ or NULL if builtin */
+ char *packagename; /* package name */
+ gvplugin_type_t *typeptr; /* pointer to jumptable for plugin,
+ or NULL if not yet loaded */
};
typedef int (*gvevent_key_callback_t) (GVJ_t * job);
static void gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
{
- char *path, *api, *type;
+ char *path, *packagename, *api, *type;
api_t gv_api;
int quality, rc;
int nest = 0;
separator(&nest, &s);
while (*s) {
path = token(&nest, &s);
+ packagename = token(&nest, &s);
do {
api = token(&nest, &s);
gv_api = gvplugin_api(api);
quality = atoi(token(&nest, &s));
else
quality = 0;
- rc = gvplugin_install (gvc, gv_api, type, quality, path, NULL);
+ rc = gvplugin_install (gvc, gv_api,
+ type, quality, packagename, path, NULL);
if (!rc) {
fprintf(stderr, "config error: %s %s %s\n", path, api, type);
return;
}
}
-static void gvconfig_plugin_install_from_library(GVC_t * gvc, gvplugin_library_t *library)
+static void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplugin_library_t *library)
{
gvplugin_api_t *apis;
gvplugin_type_t *types;
for (apis = library->apis; (types = apis->types); apis++) {
for (i = 0; types[i].type; i++) {
gvplugin_install(gvc, apis->api, types[i].type,
- types[i].quality, library->name, &types[i]);
+ types[i].quality, library->packagename, path, &types[i]);
}
}
}
gvplugin_type_t *types;
int i;
- fputs (path, f);
- fputs (" {\n", f);
+ fprintf(f, "%s %s {\n", path, library->packagename);
for (apis = library->apis; (types = apis->types); apis++) {
- fputs ("\t", f);
- fputs (gvplugin_api_name(apis->api), f);
- fputs (" {\n", f);
+ fprintf(f, "\t%s {\n", gvplugin_api_name(apis->api));
for (i = 0; types[i].type; i++) {
fprintf(f, "\t\t%s %d\n", types[i].type, types[i].quality);
}
#ifdef DISABLE_LTDL
for (libraryp = builtins; *libraryp; libraryp++) {
- gvconfig_plugin_install_from_library(gvc, *libraryp);
+ gvconfig_plugin_install_from_library(gvc, NULL, *libraryp);
}
#else
/* see if there are any new plugins */
for (i = 0; i < globbuf.gl_pathc; i++) {
library = gvplugin_library_load(globbuf.gl_pathv[i]);
if (library) {
- gvconfig_plugin_install_from_library(gvc, library);
+ gvconfig_plugin_install_from_library(gvc, globbuf.gl_pathv[i], library);
if (f) {
gvconfig_write_library_config(globbuf.gl_pathv[i], library, f);
}
/* list is alpha sorted by type, the quality sorted within the type,
then, if qualities are the same, last install wins */
boolean gvplugin_install(GVC_t * gvc, api_t api,
- char *typestr, int quality, char *path,
- gvplugin_type_t * typeptr)
+ char *typestr, int quality, char *packagename, char *path,
+ gvplugin_type_t * typeptr)
{
gv_plugin_t *plugin, **pnext;
*pnext = plugin;
plugin->typestr = typestr;
plugin->quality = quality;
- plugin->path = path; /* filepath for .so, shortname for builtins */
+ plugin->packagename = packagename; /* packagename, all packages */
+ plugin->path = path; /* filepath for .so, or NULL for builtins */
plugin->typeptr = typeptr; /* null if not loaded */
return TRUE;
lt_dlhandle hndl;
lt_ptr ptr;
char *s, *sym;
+ int len;
char *suffix = "_LTX_library";
}
s = strrchr(path, '/');
- sym = malloc(strlen(s) + strlen(suffix) + 1);
+ len = strlen(s);
+ if (len < strlen("libgvplugin_x")) {
+ fprintf(stderr,"invalid plugin path \"%s\"\n", path);
+ return NULL;
+ }
+ sym = malloc(len + strlen(suffix) + 1);
strcpy(sym, s+4); /* strip leading "/lib" */
s = strchr(sym, '.'); /* strip trailing ".so.0" */
- strcpy(s,"_LTX_library"); /* append "_LTX_library" */
+ strcpy(s,suffix); /* append "_LTX_library" */
ptr = lt_dlsym (hndl, sym);
if (!ptr) {
}
-/* load a plugin of type=str where str can optionally contain a ":path" modifier */
+/* load a plugin of type=str
+ where str can optionally contain a ":packagename" modifier */
gv_plugin_t *gvplugin_load(GVC_t * gvc, api_t api, char *str)
{
gv_plugin_t **pnext, *rv;
if (api < 0)
return NULL;
- /* does str have a :path modifier? */
+ /* does str have a :packagename modifier? */
s = strdup(str);
p = strchr(s, ':');
if (p)
while (*pnext) {
if (strcmp(s, (*pnext)->typestr) == 0) {
if (p) {
- if (strcmp(p, (*pnext)->path) == 0)
+ if (strcmp(p, (*pnext)->packagename) == 0)
break;
}
else
/* Now reinsert the library with real type ptrs */
for (apis = library->apis; (types = apis->types); apis++) {
for (i = 0; types[i].type; i++) {
- gvplugin_install(gvc, apis->api, types[i].type,
- types[i].quality, library->name, &types[i]);
+ gvplugin_install(gvc,
+ apis->api,
+ types[i].type,
+ types[i].quality,
+ library->packagename,
+ (*pnext)->path,
+ &types[i]);
}
}
while (*pnext) {
if (strcmp(s, (*pnext)->typestr) == 0) {
if (p) {
- if (strcmp(p, (*pnext)->path) == 0)
+ if (strcmp(p, (*pnext)->packagename) == 0)
break;
}
else
return rv;
}
-/* string buffer management - FIXME - must have 20 solutions for this same thing */
+/* string buffer management
+ - FIXME - must have 20 solutions for this same thing */
static const char *append_buf(char sep, char *str, boolean new)
{
static char *buf;
if (strcmp(s, (*pnext)->typestr) == 0) {
/* list each member of the matching type as "type:path" */
append_buf(' ', (*pnext)->typestr, new);
- buf = append_buf(':', (*pnext)->path, FALSE);
+ buf = append_buf(':', (*pnext)->packagename, FALSE);
new = FALSE;
}
pnext = &((*pnext)->next);
} gvplugin_api_t;
typedef struct {
- char *name; /* used instead of a file pathname
- when this plugin is loaded */
+ char *packagename; /* used when this plugin is builtin and has
+ no pathname */
gvplugin_api_t *apis;
} gvplugin_library_t;
plugin = gvplugin_load(gvc, API_render, str);
if (plugin) {
#ifndef DISABLE_CODEGENS
- if (strcmp(plugin->path, "cg") == 0) {
+ if (strcmp(plugin->packagename, "cg") == 0) {
cg_info = (codegen_info_t *) (plugin->typeptr);
job->codegen = cg_info->cg;
return cg_info->id;
gvconfig(gvc);
/* additional codegens */
for (p = cg; p->name; ++p)
- gvplugin_install(gvc, API_render, p->name, 0, "cg",
+ gvplugin_install(gvc, API_render, p->name, 0, "cg", NULL,
(gvplugin_type_t *) p);
#ifndef TCLOBJ