Пример #1
0
void gvconfig_plugin_install_from_library(GVC_t * gvc, char *path, gvplugin_library_t *library)
{
    gvplugin_api_t *apis;
    gvplugin_installed_t *types;
    gvplugin_package_t *package;
    int i;

    package = gvplugin_package_record(gvc, path, library->packagename);
    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, package, &types[i]);
        }
    }
}
Пример #2
0
static int gvconfig_plugin_install_from_config(GVC_t * gvc, char *s)
{
    char *path, *name, *api;
    const char *type;
    api_t gv_api;
    int quality, rc;
    int nest = 0;
    gvplugin_package_t *package;

    separator(&nest, &s);
    while (*s) {
	path = token(&nest, &s);
	if (nest == 0)
	    name = token(&nest, &s);
        else
	    name = "x";
        package = gvplugin_package_record(gvc, path, name);
	do {
	    api = token(&nest, &s);
	    gv_api = gvplugin_api(api);
	    do {
		if (nest == 2) {
		    type = token(&nest, &s);
		    if (nest == 2)
		        quality = atoi(token(&nest, &s));
		    else
		        quality = 0;
		    rc = gvplugin_install (gvc, gv_api,
				    type, quality, package, NULL);
		    if (!rc) {
		        agerr(AGERR, "config error: %s %s %s\n", path, api, type);
		        return 0;
		    }
		}
	    } while (nest == 2);
	} while (nest == 1);
    }
    return 1;
}
Пример #3
0
/* load a plugin of type=str
	where str can optionally contain a ":packagename" modifier */
gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, char *str)
{
    gvplugin_available_t **pnext, *rv;
    gvplugin_library_t *library;
    gvplugin_api_t *apis;
    gvplugin_installed_t *types;
    char *s, *p;
    int i;


    /* check for valid apis[] index */
    if (api < 0)
	return NULL;

    /* does str have a :packagename modifier? */
    s = strdup(str);
    p = strchr(s, ':');
    if (p)
	*p++ = '\0';

    /* point to the beginning of the linked list of plugins for this api */
    pnext = &(gvc->apis[api]);

    while (*pnext) {
	if (strcmp(s, (*pnext)->typestr) == 0) {
	    if (p) {
		if (strcmp(p, (*pnext)->packagename) == 0)
		    break;
	    }
	    else
		break;
	}
	pnext = &((*pnext)->next);
    }

    rv = *pnext;
    if ((*pnext) && (*pnext)->typeptr == NULL) {
        rv = NULL;
	library = gvplugin_library_load((*pnext)->path);
	if (library) {

	    /*
	     * FIXME - would be cleaner to here remove the entries from the
	     * config data for the uninstalled library - i.e. the entries
	     * without type ptrs.   It works without because the real library
	     * data is inserted ahead of, and so supercedes, the config data.
	     */

            /* 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->packagename,
				(*pnext)->path,
				&types[i]);
		}
            }
	    
	    /* Now search again for the specific plugin type */
	    pnext = &(gvc->apis[api]);
	    while (*pnext) {
		if (strcmp(s, (*pnext)->typestr) == 0) {
		    if (p) {
			if (strcmp(p, (*pnext)->packagename) == 0)
			    break;
		    }
		    else
			break;
		}
		pnext = &((*pnext)->next);
	    }
	    rv = *pnext;
        }
    }
    /* one last check for succesfull load */
    if ((*pnext) && (*pnext)->typeptr == NULL)
	rv = NULL;
    free(s);
    gvc->api[api] = rv;
    return rv;
}