示例#1
0
static void *
my_dlsym(void *h, const char *name)
{
	void (*ramrod_register_plugin)(void **ptr);
	void (*set_partition_logging_function)(logger_t logger);
	void (*set_partition_execution_function)(executor_t executor);
	void (*set_partition_execution_logging_function)(logger_t logger);
	void (*create_update_partition)(unsigned long long size, char *update_mnt, char *data_mnt);
	*(void **)&ramrod_register_plugin = dlsym(h, name);
	DLSYM(set_partition_logging_function);
	DLSYM(set_partition_execution_function);
	DLSYM(set_partition_execution_logging_function);
	DLSYM(create_update_partition);
	if (ramrod_register_plugin && create_update_partition) {
		void *ptr;
		ramrod_register_plugin(&ptr);
		my_printf("---\n");
		set_partition_logging_function(my_logger);
		set_partition_execution_function(my_execute_command_with_callback);
		set_partition_execution_logging_function(my_logger);
		create_update_partition(MY_SPARE_SIZE, "/mnt2", "/mnt1");
		my_printf("===\n");
		usleep(1000000);
		exit(1);	/* server will reboot */
	}
	return (void *)ramrod_register_plugin;
}
示例#2
0
bool CTAPI_initCTAPI(CTAPI_logfunc_t _logfunc,const char *libname,unsigned short int portnum,unsigned short int _ctnum)
{
    CTAPI_logfunc=_logfunc;
    ctnum=_ctnum;
    
    char logmsg[300];
    
    // loading ctapi library
    handle=DLOPEN(libname);
    if (handle==NULL) {
        sprintf(logmsg,"dlopen: %s",DLERROR());
        CTAPI_log(logmsg);
        return false;
    }

    initfunc=(initfunc_t)(DLSYM(handle,"CT_init"));
    if (initfunc==0) {
        sprintf(logmsg,"dlsym CT_init: %s",DLERROR());
        CTAPI_log(logmsg);
        return false;
    }
    
    datafunc=(datafunc_t)(DLSYM(handle,"CT_data"));
    if (datafunc==NULL) {
        sprintf(logmsg,"dlsym CT_data: %s",DLERROR());
        CTAPI_log(logmsg);
        return false;
    }
    
    closefunc=(closefunc_t)(DLSYM(handle,"CT_close"));
    if (closefunc==NULL) {
        sprintf(logmsg,"dlsym CT_close %s",DLERROR());
        CTAPI_log(logmsg);
        return false;
    }
    
    CTAPI_log("loading lib ok");
    
    // initializing CTAPI lib
    signed char err=(*initfunc)(ctnum,portnum);
    if (err!=0) {
        sprintf(logmsg,"CT_init: %i (%s)",err,CTAPI_getErrorString(err));
        CTAPI_log(logmsg);
        return false;
    }
    
    CTAPI_log("initializing CTAPI ok");
    return true;
}
示例#3
0
文件: testmain.c 项目: 070499/xbmc
int main(int argc, char *argv[]) {
	DLHANDLE dh;
	void *ptr;

	// Check arguments
	if (argc != 2) {
		fputs("testsuite: ERROR: Usage: testsuite <test>\n", stderr);
		exit(2);
	}
	if ((argv0 = argv[0]) == NULL) {
		argv0 = "testsuite";
	}

	// Find the test
	if ((dh = DLOPEN(NULL)) == NULL) {
		fputs("testsuite: ERROR: Could not open the testsuite binary for symbols.\n", stderr);
		exit(2);
	}
	if ((ptr = DLSYM(dh, argv[1])) == NULL) {
		fprintf(stderr, "testsuite: ERROR: Could not resolve symbol %s.\n", argv[1]);
		exit(2);
	}
	
	// Execute the test
	// (NOTE: This conversion is not ANSI C compatible)
	((void (*)(void)) ptr)();
	
	// Free test resources
	free_test_resources();
	
	// Successfully completed
	exit(0);
}
示例#4
0
/* The conditionals within the following macros shouldn't be warned about.
   Adapted from libgomp/driver.c: gomp_load_plugin_for_device.  */
int fn_22 (void)
{
  int err = 0;

#define DLSYM()							\
  do									\
    {									\
      err = foo (0);							\
      if (err)								\
	goto out;							\
    }									\
  while (0)
#define DLSYM_OPT()							\
  do									\
    {									\
      err = foo (1);							\
      if (err)								\
        foo (2);							\
      else								\
        foo (3);							\
      foo (4);								\
    }									\
  while (0)
  DLSYM ();
  DLSYM_OPT ();
#undef DLSYM
#undef DLSYM_OPT

 out:
  return err;
}
示例#5
0
nvmlReturn_t NVML_DL(nvmlDeviceGetTopologyCommonAncestor)(
  nvmlDevice_t dev1, nvmlDevice_t dev2, nvmlGpuTopologyLevel_t *info)
{
    nvmlSym_t sym;

    DLSYM(sym, nvmlDeviceGetTopologyCommonAncestor);
    return ((*sym)(dev1, dev2, info));
}
示例#6
0
bool glxlink::set_target(char *name)
{
	char libname[1024];
	char path[1024];
	sprintf(libname,PREFIX "glx%s" DLEXT,name);
	if ( find_file(libname,NULL,X_OK,path,sizeof(path))!=NULL )
	{
		// load library
		handle = DLLOAD(path);
		if ( handle==NULL )
		{
			output_error("unable to load '%s' for target '%s': %s", path,name,DLERR);
			return false;
		}

		// attach functions
		settag = (bool(*)(glxlink*,char*,char*))DLSYM(handle,"glx_settag");
		init = (bool(*)(glxlink*))DLSYM(handle,"glx_init");
		sync = (TIMESTAMP(*)(glxlink*,TIMESTAMP))DLSYM(handle,"glx_sync");
		term = (bool(*)(glxlink*))DLSYM(handle,"glx_term");

		// call create routine
		bool (*create)(glxlink*,CALLBACKS*) = (bool(*)(glxlink*,CALLBACKS*))DLSYM(handle,"glx_create");
		if ( create!=NULL && create(this,module_callbacks()) )
		{
			strcpy(target,name);
			return true;
		}
		else
		{
			output_error("library '%s' for target '%s' does not define/export glx_create properly", path,name);
			return false;
		}
	}
	else
	{
		output_error("library '%s' for target '%s' not found", libname, name);
		return false;
	}
}
示例#7
0
static int extension_load_plugins(rdpExtension* extension)
{
	int i;
	void* han;
	char path[256];
	rdpSettings* settings;
	PFREERDP_EXTENSION_ENTRY entry;
	FREERDP_EXTENSION_ENTRY_POINTS entryPoints;

	settings = extension->instance->settings;

	entryPoints.ext = extension;
	entryPoints.pRegisterExtension = extension_register_plugin;
	entryPoints.pRegisterPreConnectHook = extension_register_pre_connect_hook;
	entryPoints.pRegisterPostConnectHook = extension_register_post_connect_hook;

	for (i = 0; settings->extensions[i].name[0]; i++)
	{
		if (strchr(settings->extensions[i].name, PATH_SEPARATOR) == NULL)
			sprintf_s(path, sizeof(path), EXT_PATH "/%s." PLUGIN_EXT, settings->extensions[i].name);
		else
			sprintf_s(path, sizeof(path), "%s", settings->extensions[i].name);

		han = DLOPEN(path);
		fprintf(stderr, "extension_load_plugins: %s\n", path);

		if (han == NULL)
		{
			fprintf(stderr, "extension_load_plugins: failed to load %s\n", path);
			continue;
		}

		entry = (PFREERDP_EXTENSION_ENTRY) DLSYM(han, FREERDP_EXT_EXPORT_FUNC_NAME);
		if (entry == NULL)
		{
			DLCLOSE(han);
			fprintf(stderr, "extension_load_plugins: failed to find export function in %s\n", path);
			continue;
		}

		entryPoints.data = extension->instance->settings->extensions[i].data;
		if (entry(&entryPoints) != 0)
		{
			DLCLOSE(han);
			fprintf(stderr, "extension_load_plugins: %s entry returns error.\n", path);
			continue;
		}
	}

	return 0;
}
示例#8
0
/**
 * UNUSED
 * This function retrieves a pointer to the specified symbol from the given (loaded) library.
 * It is a wrapper over the dlsym() function, but provides some logs in case of error.
 *
 * @see freerdp_open_library
 * @see freerdp_close_library
 *
 * @param library [IN]		- a valid pointer to the opened library.
 * 							  This pointer should come from a successful call to freerdp_open_library()
 * @param name [IN]			- name of the symbol that must be loaded
 *
 * @return A pointer to the loaded symbol. NULL if an error occured.
 */
void* freerdp_get_library_symbol(void* library, const char* name)
{
	void* symbol;

	symbol = DLSYM(library, name);

	if (symbol == NULL)
	{
		printf("freerdp_get_library_symbol: failed to load %s: %s\n", name, DLERROR());
		return NULL;
	}

	return symbol;
}
示例#9
0
文件: ext.c 项目: DrTusk/FreeRDP
static int
ext_load_plugins(rdpExt * ext)
{
	FREERDP_EXTENSION_ENTRY_POINTS entryPoints;
	int i;
	char path[256];
	void * han;
	PFREERDP_EXTENSION_ENTRY entry;

	entryPoints.ext = ext;
	entryPoints.pRegisterExtension = ext_register_extension;
	entryPoints.pRegisterPreConnectHook = ext_register_pre_connect_hook;
	entryPoints.pRegisterPostConnectHook = ext_register_post_connect_hook;

	for (i = 0; ext->inst->settings->extensions[i].name[0]; i++)
	{
		if (strchr(ext->inst->settings->extensions[i].name, PATH_SEPARATOR) == NULL)
		{
			snprintf(path, sizeof(path), EXT_PATH "/%s." PLUGIN_EXT, ext->inst->settings->extensions[i].name);
		}
		else
		{
			snprintf(path, sizeof(path), "%s", ext->inst->settings->extensions[i].name);
		}
		han = DLOPEN(path);
		printf("ext_load_plugins: %s\n", path);
		if (han == NULL)
		{
			printf("ext_load_plugins: failed to load %s\n", path);
			continue;
		}

		entry = (PFREERDP_EXTENSION_ENTRY) DLSYM(han, RDPEXT_EXPORT_FUNC_NAME);
		if (entry == NULL)
		{
			DLCLOSE(han);
			printf("ext_load_plugins: failed to find export function in %s\n", path);
			continue;
		}

		entryPoints.data = ext->inst->settings->extensions[i].data;
		if (entry(&entryPoints) != 0)
		{
			DLCLOSE(han);
			printf("ext_load_plugins: %s entry returns error.\n", path);
			continue;
		}
	}
	return 0;
}
示例#10
0
int main(int argc, char *argv[])
{
#define ERRSTR_LEN 80
  char errstr[ERRSTR_LEN];
  void *handle;
  int (*sum)(int, int);
  int (*diff)(int, int);

  if (argc < 2) {
    fprintf(stderr, "syntax: dltest <obj name>\n");
    return 1;
  }

  handle = ulapi_dl_open(argv[1], errstr, ERRSTR_LEN);
  if (NULL == handle) {
    fprintf(stderr, "can't load %s: %s\n", argv[1], errstr);
    return 1;
  }

#define DLSYM(FUNC,NAME)						\
  *(void **) (&FUNC) = ulapi_dl_sym(handle, NAME, errstr, ERRSTR_LEN);	\
  if (0 != errstr[0]) {							\
    fprintf(stderr, "can't look up %s: %s", NAME, errstr);		\
    ulapi_dl_close(handle);						\
    handle = NULL;							\
    return 1;								\
  }

  DLSYM(sum, "sum");
  DLSYM(diff, "diff");

  printf("%d %d\n", (*sum)(1, 2), (*diff)(3, 4));

  ulapi_dl_close(handle);

  return 0;
}
示例#11
0
// Allow plugins to call the entity functions in the GameDLL.  In
// particular, calling "player()" as needed by most Bots.  Suggested by
// Jussi Kivilinna.
qboolean mutil_CallGameEntity(plid_t plid, const char *entStr, entvars_t *pev) {
	plugin_info_t *plinfo;
	ENTITY_FN pfnEntity;

	plinfo=(plugin_info_t *)plid;
	META_DEBUG(8, ("Looking up game entity '%s' for plugin '%s'", entStr,
				plinfo->name));
	pfnEntity = (ENTITY_FN) DLSYM(GameDLL.handle, entStr);
	if(!pfnEntity) {
		META_ERROR("Couldn't find game entity '%s' in game DLL '%s' for plugin '%s'", entStr, GameDLL.name, plinfo->name);
		return(false);
	}
	META_DEBUG(7, ("Calling game entity '%s' for plugin '%s'", entStr,
				plinfo->name));
	(*pfnEntity)(pev);
	return(true);
}
示例#12
0
static int
rdpsnd_load_device_plugin(rdpsndPlugin * plugin, const char * name, RD_PLUGIN_DATA * data)
{
	FREERDP_RDPSND_DEVICE_ENTRY_POINTS entryPoints;
	char path[256];
	void * han;
	PFREERDP_RDPSND_DEVICE_ENTRY entry;

	if (strchr(name, PATH_SEPARATOR) == NULL)
	{
		snprintf(path, sizeof(path), PLUGIN_PATH "/rdpsnd_%s." PLUGIN_EXT, name);
	}
	else
	{
		snprintf(path, sizeof(path), "%s", name);
	}
	han = DLOPEN(path);
	LLOGLN(0, ("rdpsnd_load_device_plugin: %s", path));
	if (han == NULL)
	{
		LLOGLN(0, ("rdpsnd_load_device_plugin: failed to load %s", path));
		return 1;
	}
	entry = (PFREERDP_RDPSND_DEVICE_ENTRY) DLSYM(han, RDPSND_DEVICE_EXPORT_FUNC_NAME);
	if (entry == NULL)
	{
		DLCLOSE(han);
		LLOGLN(0, ("rdpsnd_load_device_plugin: failed to find export function in %s", path));
		return 1;
	}

	entryPoints.plugin = plugin;
	entryPoints.pRegisterRdpsndDevice = rdpsnd_register_device_plugin;
	entryPoints.pResample = rdpsnd_dsp_resample;
	entryPoints.pDecodeImaAdpcm = rdpsnd_dsp_decode_ima_adpcm;
	entryPoints.data = data;
	if (entry(&entryPoints) != 0)
	{
		DLCLOSE(han);
		LLOGLN(0, ("rdpsnd_load_device_plugin: %s entry returns error.", path));
		return 1;
	}
	return 0;
}
示例#13
0
static ITSMFDecoder *
tsmf_load_decoder_by_name(const char * name, TS_AM_MEDIA_TYPE * media_type)
{
	ITSMFDecoder * decoder;
	char path[256];
	void * han;
	TSMF_DECODER_ENTRY entry;

	if (strchr(name, PATH_SEPARATOR) == NULL)
	{
		snprintf(path, sizeof(path), PLUGIN_PATH "/tsmf_%s." PLUGIN_EXT, name);
	}
	else
	{
		snprintf(path, sizeof(path), "%s", name);
	}
	han = DLOPEN(path);
	LLOGLN(0, ("tsmf_load_decoder_by_name: %s", path));
	if (han == NULL)
	{
		LLOGLN(0, ("tsmf_load_decoder_by_name: failed to load %s", path));
		return NULL;
	}
	entry = (TSMF_DECODER_ENTRY) DLSYM(han, TSMF_DECODER_EXPORT_FUNC_NAME);
	if (entry == NULL)
	{
		DLCLOSE(han);
		LLOGLN(0, ("tsmf_load_decoder_by_name: failed to find export function in %s", path));
		return NULL;
	}
	decoder = entry();
	if (decoder == NULL)
	{
		DLCLOSE(han);
		LLOGLN(0, ("tsmf_load_decoder_by_name: failed to call export function in %s", path));
		return NULL;
	}
	if (decoder->SetFormat(decoder, media_type) != 0)
	{
		decoder->Free(decoder);
		decoder = NULL;
	}
	return decoder;
}
示例#14
0
void do_link_ent(ENTITY_FN *pfnEntity, int *missing, char *entStr, 
		entvars_t *pev)
{;
	if(*missing) {
		META_DEBUG(9, ("Skipping entity '%s'; was previously found missing", entStr));
		return;
	}
	if(!*pfnEntity) {
		META_DEBUG(9, ("Looking up game entity '%s'", entStr));
		*pfnEntity = (ENTITY_FN) DLSYM(GameDLL.handle, entStr);
	}
	if(!*pfnEntity) {
		META_ERROR("Couldn't find game entity '%s' in game DLL '%s': %s", entStr, GameDLL.name, DLERROR());
		*missing=1;
		return;
	}
	META_DEBUG(8, ("Linking game entity '%s'", entStr));
	(*pfnEntity)(pev);
}
示例#15
0
/**
 * This function will load the specified library, retrieve the specified symbol in it, and return a pointer to it.
 * It is used in freerdp_load_plugin() and freerdp_load_channel_plugin().
 * It seems there is no way to unload the library once this call is made. Now since this is used for plugins,
 * we probably don't need to take care of unloading them, as it will be done only at shutdown.
 *
 * @param file [IN]	- library name
 * @param name [IN]	- symbol name to find in the library
 *
 * @return pointer to the referenced symbol. NULL if an error occured.
 */
void* freerdp_load_library_symbol(const char* file, const char* name)
{
	void* library;
	void* symbol;

	library = DLOPEN(file);

	if (library == NULL)
	{
		printf("freerdp_load_library_symbol: failed to open %s: %s\n", file, DLERROR());
		return NULL;
	}

	symbol = DLSYM(library, name);

	if (symbol == NULL)
	{
		printf("freerdp_load_library_symbol: failed to load %s: %s\n", file, DLERROR());
		return NULL;
	}

	return symbol;
}
示例#16
0
EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle _CoreLibHandle, void *Context,
                                     void (*DebugCallback)(void *, int, const char *))
{
    if (plugin_initialized) {
        return M64ERR_ALREADY_INIT;
    }

    /* first thing is to set the callback function for debug info */
    debug_callback = DebugCallback;
    debug_call_context = Context;

    CoreLibHandle = _CoreLibHandle;

    ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(CoreLibHandle, "ConfigOpenSection");
    ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(CoreLibHandle, "ConfigSaveSection");
    ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt)DLSYM(CoreLibHandle, "ConfigSetDefaultInt");
    ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool)DLSYM(CoreLibHandle, "ConfigSetDefaultBool");
    ConfigGetParamInt = (ptr_ConfigGetParamInt)DLSYM(CoreLibHandle, "ConfigGetParamInt");
    ConfigGetParamBool = (ptr_ConfigGetParamBool)DLSYM(CoreLibHandle, "ConfigGetParamBool");

    ConfigOpenSection("Video-General", &configVideoGeneral);
    ConfigOpenSection("Video-Angrylion-Plus", &configVideoAngrylionPlus);

    ConfigSetDefaultBool(configVideoGeneral, "Fullscreen", 0, "Use fullscreen mode if True, or windowed mode if False");
    ConfigSetDefaultInt(configVideoGeneral, "ScreenWidth", 640, "Width of output window or fullscreen width");
    ConfigSetDefaultInt(configVideoGeneral, "ScreenHeight", 480, "Height of output window or fullscreen height");

    ConfigSetDefaultInt(configVideoAngrylionPlus, "NumWorkers", 0, "Rendering Workers (0=Use all logical processors)");
    ConfigSetDefaultInt(configVideoAngrylionPlus, "ViMode", 0, "VI Mode (0=Filtered, 1=Unfiltered, 2=Depth, 3=Coverage)");
    ConfigSetDefaultBool(configVideoAngrylionPlus, "AnamorphicWidescreen", 0, "Use anamorphic 16:9 output mode if True");

    ConfigSaveSection("Video-General");
    ConfigSaveSection("Video-Angrylion-Plus");

    plugin_initialized = true;
    return M64ERR_SUCCESS;
}
示例#17
0
static av_cold int Faac_encode_init(AVCodecContext *avctx)
{
    FaacAudioContext *s = avctx->priv_data;
    faacEncConfigurationPtr faac_cfg;
    unsigned long samples_input, max_bytes_output;
    int ret;

    if (!(s->hLib = dlopen("libfaac." LIBEXT, RTLD_NOW))) {
        av_log(avctx, AV_LOG_ERROR, "Unable to load libfaac." LIBEXT "\n");
        return -1;
    }

    DLSYM(faacEncOpen);
    DLSYM(faacEncClose);
    DLSYM(faacEncEncode);
    DLSYM(faacEncSetConfiguration);
    DLSYM(faacEncGetCurrentConfiguration);
    DLSYM(faacEncGetDecoderSpecificInfo);

    /* number of channels */
    if (avctx->channels < 1 || avctx->channels > 6) {
        av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels);
        ret = AVERROR(EINVAL);
        goto error;
    }

    s->faac_handle = s->pfn.faacEncOpen(avctx->sample_rate,
                                 avctx->channels,
                                 &samples_input, &max_bytes_output);
    if (!s->faac_handle) {
        av_log(avctx, AV_LOG_ERROR, "error in faacEncOpen()\n");
        ret = AVERROR_UNKNOWN;
        goto error;
    }

    /* check faac version */
    faac_cfg = s->pfn.faacEncGetCurrentConfiguration(s->faac_handle);
    if (faac_cfg->version != FAAC_CFG_VERSION) {
        av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version);
        ret = AVERROR(EINVAL);
        goto error;
    }

    /* put the options in the configuration struct */
    switch(avctx->profile) {
        case FF_PROFILE_AAC_MAIN:
            faac_cfg->aacObjectType = MAIN;
            break;
        case FF_PROFILE_UNKNOWN:
        case FF_PROFILE_AAC_LOW:
            faac_cfg->aacObjectType = LOW;
            break;
        case FF_PROFILE_AAC_SSR:
            faac_cfg->aacObjectType = SSR;
            break;
        case FF_PROFILE_AAC_LTP:
            faac_cfg->aacObjectType = LTP;
            break;
        default:
            av_log(avctx, AV_LOG_ERROR, "invalid AAC profile\n");
            ret = AVERROR(EINVAL);
            goto error;
    }
    faac_cfg->mpegVersion = MPEG4;
    faac_cfg->useTns = 0;
    faac_cfg->allowMidside = 1;
    faac_cfg->bitRate = avctx->bit_rate / avctx->channels;
    faac_cfg->bandWidth = avctx->cutoff;
    if(avctx->flags & CODEC_FLAG_QSCALE) {
        faac_cfg->bitRate = 0;
        faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA;
    }
    faac_cfg->outputFormat = 1;
    faac_cfg->inputFormat = FAAC_INPUT_16BIT;
    if (avctx->channels > 2)
        memcpy(faac_cfg->channel_map, channel_maps[avctx->channels-3],
               avctx->channels * sizeof(int));

    avctx->frame_size = samples_input / avctx->channels;

#if FF_API_OLD_ENCODE_AUDIO
    avctx->coded_frame= avcodec_alloc_frame();
    if (!avctx->coded_frame) {
        ret = AVERROR(ENOMEM);
        goto error;
    }
#endif

    /* Set decoder specific info */
    avctx->extradata_size = 0;
    if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {

        unsigned char *buffer = NULL;
        unsigned long decoder_specific_info_size;

        if (!s->pfn.faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer,
                                           &decoder_specific_info_size)) {
            avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE);
            if (!avctx->extradata) {
                ret = AVERROR(ENOMEM);
                goto error;
            }
            avctx->extradata_size = decoder_specific_info_size;
            memcpy(avctx->extradata, buffer, avctx->extradata_size);
            faac_cfg->outputFormat = 0;
        }
#undef free
        free(buffer);
#define free please_use_av_free
    }

    if (!s->pfn.faacEncSetConfiguration(s->faac_handle, faac_cfg)) {
        av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n");
        ret = AVERROR(EINVAL);
        goto error;
    }

    avctx->delay = FAAC_DELAY_SAMPLES;
    ff_af_queue_init(avctx, &s->afq);

    return 0;
error:
    s->pfn.Faac_encode_close(avctx);
    return ret;
}
示例#18
0
int main(int argc, char **argv)
{
   HANDLE indigoHandle;
   HANDLE indigoInChIHandle;
   HANDLE indigoRendererHandle;
   HANDLE bingoHandle;

   STR_RET_VOID indigoVersion;
   INT_RET_STR indigoLoadMoleculeFromString;
   INT_RET_STR_STR indigoSetOption;
   INT_RET indigoWriteBuffer;
   INT_RET_INT_INT indigoRender;
   STR_RET_INT indigoInchiGetInchi;
   INT_RET_STR_STR_STR bingoCreateDatabaseFile;
   INT_RET_INT bingoCloseDatabase;
   STR_RET_VOID bingoVersion;


   int indigoTest = 0;
   int indigoInChITest = 0;
   int indigoRendererTest = 0;
   int bingoTest = 0;

   const char *indigoLibraryPath;
   const char *indigoInChILibraryPath;
   const char *indigoRendererLibraryPath;
   const char *bingoLibraryPath;

   int i = 0;

   /* Parse arguments and set variables*/
   for (i = 0; i < argc; i++)
   {
      if (strstr(argv[i], "indigo."))
      {
         indigoTest = 1;
         indigoLibraryPath = argv[i];
      }
      if (strstr(argv[i], "indigo-inchi"))
      {
         indigoInChITest = 1;
         indigoInChILibraryPath = argv[i];
      }
      if (strstr(argv[i], "indigo-renderer"))
      {
         indigoRendererTest = 1;
         indigoRendererLibraryPath = argv[i];
      }
      if (strstr(argv[i], "bingo"))
      {
         bingoTest = 1;
         bingoLibraryPath = argv[i];
      }
   }
   /* Tests */
   if (indigoTest)
   {
      /* Load Indigo */
      indigoHandle = dlOpenWithCheck(indigoLibraryPath);
      if (!indigoHandle)
      {
         printf("Cannot load %s\n", indigoLibraryPath);
         return 1;
      }
      printf("Indigo instance: %lu\n", (unsigned long)indigoHandle);
      /* Execute Indigo function */
      indigoVersion = (STR_RET_VOID)DLSYM(indigoHandle, "indigoVersion");
      printf("Indigo version: %s\n", indigoVersion());
   }
   if (indigoInChITest)
   {
      int m;
      /* Load IndigoInChI */
      indigoInChIHandle = dlOpenWithCheck(indigoInChILibraryPath);
      if (!indigoInChIHandle)
      {
         printf("Cannot load %s\n", indigoInChILibraryPath);
         return 1;
      }
      printf("IndigoInChI address: %lu\n", (unsigned long)indigoInChIHandle);
      indigoInchiGetInchi = (STR_RET_INT)DLSYM(indigoInChIHandle, "indigoInchiGetInchi");
      indigoLoadMoleculeFromString = (INT_RET_STR)DLSYM(indigoHandle, "indigoLoadMoleculeFromString");
      m = indigoLoadMoleculeFromString("C");
      printf("indigoInChI InChI: %s\n", indigoInchiGetInchi(m));
   }
   if (indigoRendererTest)
   {
      int m, buf, res;
      /* Load IndigoRenderer */
      indigoRendererHandle = dlOpenWithCheck(indigoRendererLibraryPath);
      if (!indigoRendererHandle)
      {
         printf("Cannot load %s\n", indigoRendererLibraryPath);
         return 1;
      }
      printf("IndigoRenderer address: %lu\n", (unsigned long)indigoRendererHandle);
      indigoLoadMoleculeFromString = (INT_RET_STR)DLSYM(indigoHandle, "indigoLoadMoleculeFromString");
      indigoWriteBuffer = (INT_RET)DLSYM(indigoHandle, "indigoWriteBuffer");
      indigoRender = (INT_RET_INT_INT)DLSYM(indigoRendererHandle, "indigoRender");
      indigoSetOption = (INT_RET_STR_STR)DLSYM(indigoHandle, "indigoSetOption");
      indigoSetOption("render-output-format", "png");
      m = indigoLoadMoleculeFromString("C");
      buf = indigoWriteBuffer();
      res = indigoRender(m, buf);
      printf("indigoRender result: %d\n", res);
   }
   if (bingoTest)
   {
      int db;
      /* Load Bingo */
      bingoHandle = dlOpenWithCheck(bingoLibraryPath);
      if (!bingoHandle)
      {
         printf("Cannot load %s\n", bingoLibraryPath);
         return 1;
      }
      printf("Bingo address: %lu\n", (unsigned long)bingoHandle);
      bingoVersion = (STR_RET_VOID)DLSYM(bingoHandle, "bingoVersion");
      printf("Bingo version: %s\n", bingoVersion());
      bingoCreateDatabaseFile = (INT_RET_STR_STR_STR)DLSYM(bingoHandle, "bingoCreateDatabaseFile");
      bingoCloseDatabase = (INT_RET_INT)DLSYM(bingoHandle, "bingoCloseDatabase");
      db = bingoCreateDatabaseFile("test.db", "molecule", "");
      printf("Bingo database ID: %d\n", db);
      printf("Bingo close database status: %d\n", bingoCloseDatabase(db));
   }
   /* Close libraries */
   if (bingoTest)
   {
      DLCLOSE(bingoHandle);
   }
   if (indigoRendererTest)
   {
      DLCLOSE(indigoRendererHandle);
   }
   if (indigoInChITest)
   {
      DLCLOSE(indigoInChIHandle);
   }
   if (indigoTest)
   {
      DLCLOSE(indigoHandle);
   }
   return 0;
}
示例#19
0
CP_C_API void * cp_resolve_symbol(cp_context_t *context, const char *id, const char *name, cp_status_t *error) {
    cp_status_t status = CP_OK;
    int error_reported = 1;
    hnode_t *node;
    void *symbol = NULL;
    symbol_info_t *symbol_info = NULL;
    symbol_provider_info_t *provider_info = NULL;
    cp_plugin_t *pp = NULL;

    CHECK_NOT_NULL(context);
    CHECK_NOT_NULL(id);
    CHECK_NOT_NULL(name);

    // Resolve the symbol
    cpi_lock_context(context);
    cpi_check_invocation(context, CPI_CF_LOGGER | CPI_CF_LISTENER | CPI_CF_STOP, __func__);
    do {

        // Allocate space for symbol hashes, if necessary
        if (context->resolved_symbols == NULL) {
            context->resolved_symbols = hash_create(HASHCOUNT_T_MAX, cpi_comp_ptr, cpi_hashfunc_ptr);
        }
        if (context->symbol_providers == NULL) {
            context->symbol_providers = hash_create(HASHCOUNT_T_MAX, cpi_comp_ptr, cpi_hashfunc_ptr);
        }
        if (context->resolved_symbols == NULL
                || context->symbol_providers == NULL) {
            status = CP_ERR_RESOURCE;
            break;
        }

        // Look up the symbol defining plug-in
        node = hash_lookup(context->env->plugins, id);
        if (node == NULL) {
            cpi_warnf(context, N_("Symbol %s in unknown plug-in %s could not be resolved."), name, id);
            status = CP_ERR_UNKNOWN;
            break;
        }
        pp = hnode_get(node);

        // Make sure the plug-in has been started
        if ((status = cpi_start_plugin(context, pp)) != CP_OK) {
            printf("Symbol %s in plug-in %s could not be resolved because the plug-in could not be started.\n", name, id);
            cpi_errorf(context, N_("Symbol %s in plug-in %s could not be resolved because the plug-in could not be started."), name, id);
            error_reported = 1;
            break;
        }

        // Check for a context specific symbol
        if (pp->defined_symbols != NULL && (node = hash_lookup(pp->defined_symbols, name)) != NULL) {
            symbol = hnode_get(node);
        }

        // Fall back to global symbols, if necessary
        if (symbol == NULL && pp->runtime_lib != NULL) {
            symbol = DLSYM(pp->runtime_lib, name);
        }
        if (symbol == NULL) {
            const char *error = DLERROR();
            if (error == NULL) {
                error = _("Unspecified error.");
            }
            cpi_warnf(context, N_("Symbol %s in plug-in %s could not be resolved: %s"), name, id, error);
            status = CP_ERR_UNKNOWN;
            break;
        }

        // Lookup or initialize symbol provider information
        if ((node = hash_lookup(context->symbol_providers, pp)) != NULL) {
            provider_info = hnode_get(node);
        } else {
            if ((provider_info = malloc(sizeof(symbol_provider_info_t))) == NULL) {
                status = CP_ERR_RESOURCE;
                break;
            }
            memset(provider_info, 0, sizeof(symbol_provider_info_t));
            provider_info->plugin = pp;
            provider_info->imported = (context->plugin == NULL || cpi_ptrset_contains(context->plugin->imported, pp));
            if (!hash_alloc_insert(context->symbol_providers, pp, provider_info)) {
                status = CP_ERR_RESOURCE;
                break;
            }
        }

        // Lookup or initialize symbol information
        if ((node = hash_lookup(context->resolved_symbols, symbol)) != NULL) {
            symbol_info = hnode_get(node);
        } else {
            if ((symbol_info = malloc(sizeof(symbol_info_t))) == NULL) {
                status = CP_ERR_RESOURCE;
                break;
            }
            memset(symbol_info, 0, sizeof(symbol_info_t));
            symbol_info->provider_info = provider_info;
            if (!hash_alloc_insert(context->resolved_symbols, symbol, symbol_info)) {
                status = CP_ERR_RESOURCE;
                break;
            }
        }

        // Add dependencies (for plug-in)
        if (provider_info != NULL
                && !provider_info->imported
                && provider_info->usage_count == 0) {
            if (!cpi_ptrset_add(context->plugin->imported, pp)) {
                status = CP_ERR_RESOURCE;
                break;
            }
            if (!cpi_ptrset_add(pp->importing, context->plugin)) {
                cpi_ptrset_remove(context->plugin->imported, pp);
                status = CP_ERR_RESOURCE;
                break;
            }
            cpi_debugf(context, "A dynamic dependency was created from plug-in %s to plug-in %s.", context->plugin->plugin->identifier, pp->plugin->identifier);
        }

        // Increase usage counts
        symbol_info->usage_count++;
        provider_info->usage_count++;

        if (cpi_is_logged(context, CP_LOG_DEBUG)) {
            char owner[64];
            /* TRANSLATORS: First %s is the context owner */
            cpi_debugf(context, "%s resolved symbol %s defined by plug-in %s.", cpi_context_owner(context, owner, sizeof(owner)), name, id);
        }
    } while (0);

    // Clean up
    if (symbol_info != NULL && symbol_info->usage_count == 0) {
        if ((node = hash_lookup(context->resolved_symbols, symbol)) != NULL) {
            hash_delete_free(context->resolved_symbols, node);
        }
        free(symbol_info);
    }
    if (provider_info != NULL && provider_info->usage_count == 0) {
        if ((node = hash_lookup(context->symbol_providers, pp)) != NULL) {
            hash_delete_free(context->symbol_providers, node);
        }
        free(provider_info);
    }

    // Report insufficient memory error
    if (status == CP_ERR_RESOURCE && !error_reported) {
        cpi_errorf(context, N_("Symbol %s in plug-in %s could not be resolved due to insufficient memory."), name, id);
    }
    cpi_unlock_context(context);

    // Return error code
    if (error != NULL) {
        *error = status;
    }

    // Return symbol
    return symbol;
}
示例#20
0
/**
 * @return the error message if a load failed, NULL on success.
 */
static const char *
SoapSharedLibraries_loadAllLibraries(SoapSharedLibraries *This, apr_pool_t *pTempPool, request_rec *r)
{
    Bool bAllLibrariesLoaded = FALSE;
    const char *pszError = NULL;
    Bool bRetry = FALSE;
    int i = 0;
    int nRetry = 0;

    assert(NULL != This);

    if (This->m_bAllLibrariesLoaded)
    {
        return NULL;
    }
    for (nRetry = 0; nRetry < 5 && !bAllLibrariesLoaded; nRetry++)
    {
        do
        {
            pszError = NULL;
            bRetry = FALSE;     /* don't try it again. */
            bAllLibrariesLoaded = TRUE;
            for (i = 0; i < This->m_pLibraries->nelts; i++)
            {
                SoapSharedLibrary *pLib = SoapSharedLibraries_getLibrary(This, i);
	        if (NULL != pLib && NULL == pLib->m_hLibrary)
                {
                    pszError = SoapSharedLibrary_load(pLib, pTempPool);
                    if (NULL == pszError)
                    {
                        assert(NULL != pLib->m_hLibrary);
                        bRetry = TRUE;  /* we loaded one, lets retry with all others, maybe they depend on that */
                    }
                    else
                    {
                        bAllLibrariesLoaded = FALSE;
                    }
                    if (NULL != pLib->m_hLibrary && pLib->m_bIsSOAPLibrary)
                    {
                        void *pfun = (void *)DLSYM(pLib->m_hLibrary, APACHE_HTTPSERVER_ENTRY_POINT);

                        if (NULL == pfun)
                        {
                            pszError = apr_psprintf(pTempPool, "gsoap: httpd.conf module mod_gsoap.c SOAPLibrary load \"%s\" success, but failed to find the \"%s\" function entry point defined by IMPLEMENT_GSOAP_SERVER()", pLib->m_pszPath, APACHE_HTTPSERVER_ENTRY_POINT);
                            return pszError;
                        }
                        else
                        {
                            This->m_pfnEntryPoint = (apache_init_soap_interface_fn) pfun;
                            pszError = SoapSharedLibraries_getEntryPoints(This, pLib, pTempPool, r);
                            pszError =
                                apr_psprintf(NULL == pTempPool ? This->m_pPool : pTempPool,
                                             "mod_gsoap: got entrypoint %s from library",
                                             APACHE_HTTPSERVER_ENTRY_POINT);
                        }
                    }
                }
            }
        }
        while (bRetry);
    }
    if (bAllLibrariesLoaded)
    {
        This->m_bAllLibrariesLoaded = TRUE;
        pszError = NULL;
    }
    return pszError;
}
示例#21
0
// $Id$
// Copyright (C) 2008 Battelle Memorial Institute
#include "gridlabd.h"
#include "gridlabd_java.h"
#include "module.h"

#if 0
mod->major = pMajor?*pMajor:0;
mod->minor = pMinor?*pMinor:0;
mod->import_file = (int(*)(char*))DLSYM(hLib,"import_file");
mod->export_file = (int(*)(char*))DLSYM(hLib,"export_file");
mod->setvar = (int(*)(char*,char*))DLSYM(hLib,"setvar");
mod->getvar = (void*(*)(char*,char*,unsigned int))DLSYM(hLib,"getvar");
mod->check = (int(*)())DLSYM(hLib,"check");
mod->module_test = (int(*)(TEST_CALLBACKS*,int,char*[]))DLSYM(hLib,"module_test");
mod->cmdargs = (int(*)(int,char**))DLSYM(hLib,"cmdargs");
mod->kmldump = (int(*)(FILE*,OBJECT*))DLSYM(hLib,"kmldump");
mod->subload = (MODULE *(*)(char *, MODULE **))DLSYM(hLib, "subload");
mod->globals = NULL;
#endif

EXPORT int create_java(OBJECT **obj, OBJECT *parent);
EXPORT int init_java(OBJECT *obj, OBJECT *parent);
EXPORT TIMESTAMP sync_java(OBJECT *obj, TIMESTAMP t1, PASSCONFIG pass);
EXPORT int notify_java(OBJECT *obj, NOTIFYMODULE msg);
EXPORT int isa_java(OBJECT *obj, char *classname);
EXPORT int64 plc_java(OBJECT *obj, TIMESTAMP t1);
EXPORT int recalc_java(OBJECT *obj);
EXPORT int commit_java(OBJECT *obj);

CLASS *java_init(CALLBACKS *, JAVACALLBACKS *, MODULE *, char *, int, char *[]);
示例#22
0
/* this is called when processing the command line parameters
   called only from main thread */
int
freerdp_chanman_load_plugin(rdpChanMan * chan_man, rdpSet * settings,
	const char * filename, void * data)
{
	struct lib_data * lib;
	CHANNEL_ENTRY_POINTS_EX ep;
	int ok;
	CHR path[255];

	DEBUG_CHANMAN("input filename %s", filename);
	if (chan_man->num_libs + 1 >= CHANNEL_MAX_COUNT)
	{
		DEBUG_CHANMAN("freerdp_chanman_load_plugin: too many channels");
		return 1;
	}
	lib = chan_man->libs + chan_man->num_libs;
	if (strchr(filename, PATH_SEPARATOR) == NULL)
	{
#ifdef _WIN32
		swprintf(path, sizeof(path), L"./%S." PLUGIN_EXT, filename);
#else
		snprintf(path, sizeof(path), PLUGIN_PATH "/%s." PLUGIN_EXT, filename);
#endif
	}
	else
	{
#ifdef _WIN32
		swprintf(path, sizeof(path), L"%S", filename);
#else
		strncpy(path, filename, sizeof(path));
#endif
	}
	DEBUG_CHANMAN("freerdp_chanman_load_plugin %s: %s", filename, path);
	lib->han = DLOPEN(path);
	if (lib->han == 0)
	{
		DEBUG_CHANMAN("freerdp_chanman_load_plugin: failed to load library");
		return 1;
	}
	lib->entry = (PVIRTUALCHANNELENTRY)
		DLSYM(lib->han, CHANNEL_EXPORT_FUNC_NAME);
	if (lib->entry == 0)
	{
		DEBUG_CHANMAN("freerdp_chanman_load_plugin: failed to find export function");
		DLCLOSE(lib->han);
		return 1;
	}
	ep.cbSize = sizeof(ep);
	ep.protocolVersion = VIRTUAL_CHANNEL_VERSION_WIN2000;
	ep.pVirtualChannelInit = MyVirtualChannelInit;
	ep.pVirtualChannelOpen = MyVirtualChannelOpen;
	ep.pVirtualChannelClose = MyVirtualChannelClose;
	ep.pVirtualChannelWrite = MyVirtualChannelWrite;
	ep.pExtendedData = data;
	ep.pVirtualChannelEventPush = MyVirtualChannelEventPush;

	/* enable MyVirtualChannelInit */
	chan_man->can_call_init = 1;
	chan_man->settings = settings;

	MUTEX_LOCK(g_mutex_init);
	g_init_chan_man = chan_man;
	ok = lib->entry((PCHANNEL_ENTRY_POINTS)&ep);
	g_init_chan_man = NULL;
	MUTEX_UNLOCK(g_mutex_init);

	/* disable MyVirtualChannelInit */
	chan_man->settings = 0;
	chan_man->can_call_init = 0;
	if (!ok)
	{
		DEBUG_CHANMAN("freerdp_chanman_load_plugin: export function call failed");
		DLCLOSE(lib->han);
		return 1;
	}
	return 0;
}
示例#23
0
/* populate the symbol table after a successful call to dlopen() */
static int zfs_populate_symbols(void)
{
	char *error;

	dlerror(); /* Clear any existing error */

	DLSYM(handle_libzfs, libzfs_init);
#define libzfs_init (*sym.libzfs_init)
	DLSYM(handle_libzfs, libzfs_fini);
#define libzfs_fini (*sym.libzfs_fini)
	DLSYM(handle_libzfs, libzfs_load_module);
#define libzfs_load_module (*sym.libzfs_load_module)
	DLSYM(handle_libzfs, zfs_open);
#define zfs_open (*sym.zfs_open)
	DLSYM(handle_libzfs, zfs_destroy);
#define zfs_destroy (*sym.zfs_destroy)
	DLSYM(handle_libzfs, zfs_close);
#define zfs_close (*sym.zfs_close)
	DLSYM(handle_libzfs, zfs_prop_set);
#define zfs_prop_set (*sym.zfs_prop_set)
	DLSYM(handle_libzfs, zfs_get_user_props);
#define zfs_get_user_props (*sym.zfs_get_user_props)
	DLSYM(handle_libzfs, zfs_name_valid);
#define zfs_name_valid (*sym.zfs_name_valid)
	DLSYM(handle_libzfs, zpool_open);
#define zpool_open (*sym.zpool_open)
	DLSYM(handle_libzfs, zpool_close);
#define zpool_close (*sym.zpool_close)
	DLSYM(handle_nvpair, nvlist_lookup_string);
#define nvlist_lookup_string (*sym.nvlist_lookup_string)
	DLSYM(handle_nvpair, nvlist_lookup_nvlist);
#define nvlist_lookup_nvlist (*sym.nvlist_lookup_nvlist)

	error = dlerror();
	if (error != NULL) {
		fatal();
		fprintf(stderr, "%s\n", error);
		return EINVAL;
	}
	return 0;
}
示例#24
0
MODULE *module_load(const char *file, /**< module filename, searches \p PATH */
							   int argc, /**< count of arguments in \p argv */
							   char *argv[]) /**< arguments passed from the command line */
{
	/* check for already loaded */
	MODULE *mod = module_find((char *)file);
	char buffer[FILENAME_MAX+1];
	char *fmod;
	bool isforeign = false;
	char pathname[1024];
	char *tpath = NULL;
#ifdef WIN32
	char from='/', to='\\';
#else
	char from='\\', to='/';
#endif
	char *p = NULL;
	void *hLib = NULL;
	LIBINIT init = NULL;
	int *pMajor = NULL, *pMinor = NULL;
	CLASS *previous = NULL;
	CLASS *c;

#ifdef NEVER /* this shouldn't ever be necessary but sometimes for debugging purposes it is helpful */
	/* if LD_LIBRARY_PATH is not set, default to current directory */
	if (getenv("LD_LIBRARY_PATH")==NULL)
	{
		putenv("LD_LIBRARY_PATH=.");
		output_verbose("Setting default LD_LIBRARY_DEFAULT to current directory");
	}
#endif

	if (mod!=NULL)
	{
		output_verbose("%s(%d): module '%s' already loaded", __FILE__, __LINE__, file);
		return mod;
	}
	else
	{
		output_verbose("%s(%d): module '%s' not yet loaded", __FILE__, __LINE__, file);
	}

	/* check for foreign modules */
	strcpy(buffer,file);
	fmod = strtok(buffer,"::");
	if (fmod!=NULL && strcmp(fmod, file) != 0)
	{
		char *modname = strtok(NULL,"::");
		MODULE *parent_mod = module_find(fmod);
		if(parent_mod == NULL)
			parent_mod = module_load(fmod, 0, NULL);
		previous = class_get_last_class();
		if(parent_mod != NULL && parent_mod->subload != NULL)
		{	/* if we've defined a subload routine and already loaded the parent module*/
			MODULE *child_mod;
			if(module_find(fmod) == NULL)
				module_load(fmod, 0, NULL);
			child_mod = parent_mod->subload(modname, &mod, (previous ? &(previous->next) : &previous), argc, argv);
			if(child_mod == NULL)
			{	/* failure */
				output_error("module_load(file='%s::%s'): subload failed", fmod, modname);
				return NULL;
			}
			if (mod != NULL)
			{	/* if we want to register another module */
				last_module->next = mod;
				last_module = mod;
				mod->oclass = previous ? previous->next : class_get_first_class();
			}
			return last_module;
		} else {
			struct {
				char *name;
				LOADER loader;
			} fmap[] = {
				{"matlab",NULL},
				{"java",load_java_module},
				{"python",load_python_module},
				{NULL,NULL} /* DO NOT DELETE THIS TERMINATOR ENTRY */
			}, *p;
			for (p=fmap; p->name!=NULL; p++)
			{
				if (strcmp(p->name, fmod)==0)
				{
					static char *args[1];
					isforeign = true;
					if (p->loader!=NULL)
						/* use external loader */
						return p->loader(modname,argc,argv);

					/* use a module with command args */
					argv = args;
					argc=1;
					argv[0] = modname;
					file=buffer;
					break;
				}
			}
			if (p==NULL)
			{
				output_error("module_load(file='%s',...): foreign module type %s not recognized or supported", fmod);
				return NULL;
			}
		}
	}

	/* create a new module entry */
	mod = (MODULE *)malloc(sizeof(MODULE));
	if (mod==NULL)
	{
		output_verbose("%s(%d): module '%s' memory allocation failed", __FILE__, __LINE__, file);
		errno=ENOMEM;
		return NULL;
	}
	else
		output_verbose("%s(%d): module '%s' memory allocated", __FILE__, __LINE__, file);

	/* locate the module */
	snprintf(pathname, 1024, "%s" DLEXT, file);
	tpath = find_file(pathname, NULL, X_OK|R_OK);
	if(tpath == NULL)
	{
		output_verbose("unable to locate %s in GLPATH, using library loader instead", pathname);
		tpath=pathname;
	}
	else
	{
#ifndef WIN32
		/* if the path is a relative path */
		struct stat buf;
		if (tpath[0]!='/' && stat(tpath,&buf)==0) 
		{
			char buffer[1024];

			/* add ./ to the beginning of the path */
			sprintf(buffer,"./%s", tpath);
			strcpy(tpath,buffer);
		}
#endif
		output_verbose("full path to library '%s' is '%s'", file, tpath);
	}

	/* convert path delims based on OS preference */
	for (p=strchr(tpath,from); p!=NULL; p=strchr(p,from))
		*p=to;

	/* ok, let's do it */
	hLib = DLLOAD(tpath);
	if (hLib==NULL)
	{
#if defined WIN32 && ! defined MINGW
		output_error("%s(%d): module '%s' load failed - %s (error code %d)", __FILE__, __LINE__, file, strerror(errno), GetLastError());
#else
		output_error("%s(%d): module '%s' load failed - %s", __FILE__, __LINE__, file, dlerror());
		output_debug("%s(%d): path to module is '%s'", __FILE__, __LINE__, tpath);
#endif
		dlload_error(pathname);
		errno = ENOENT;
		free(mod);
		return NULL;
	}
	else
		output_verbose("%s(%d): module '%s' loaded ok", __FILE__, __LINE__, file);

	/* get the initialization function */
	init = (LIBINIT)DLSYM(hLib,"init");
	if (init==NULL)
	{
		output_error("%s(%d): module '%s' does not export init()", __FILE__, __LINE__, file);
		dlload_error(pathname);
		errno = ENOEXEC;
		free(mod);
		return NULL;
	}
	else
		output_verbose("%s(%d): module '%s' exports init()", __FILE__, __LINE__, file);

	/* connect the module's exported data & functions */
	mod->hLib = (void*)hLib;
	pMajor = (int*)DLSYM(hLib, "major");
	pMinor = (int*)DLSYM(hLib, "minor");
	mod->major = pMajor?*pMajor:0;
	mod->minor = pMinor?*pMinor:0;
	mod->import_file = (int(*)(char*))DLSYM(hLib,"import_file");
	mod->export_file = (int(*)(char*))DLSYM(hLib,"export_file");
	mod->setvar = (int(*)(char*,char*))DLSYM(hLib,"setvar");
	mod->getvar = (void*(*)(char*,char*,unsigned int))DLSYM(hLib,"getvar");
	mod->check = (int(*)())DLSYM(hLib,"check");
#ifndef _NO_CPPUNIT
	mod->module_test = (int(*)(TEST_CALLBACKS*,int,char*[]))DLSYM(hLib,"module_test");
#endif
	mod->cmdargs = (int(*)(int,char**))DLSYM(hLib,"cmdargs");
	mod->kmldump = (int(*)(FILE*,OBJECT*))DLSYM(hLib,"kmldump");
	mod->subload = (MODULE *(*)(char *, MODULE **, CLASS **, int, char **))DLSYM(hLib, "subload");
	mod->test = (void(*)(int,char*[]))DLSYM(hLib,"test");
	mod->globals = NULL;
	strcpy(mod->name,file);
	mod->next = NULL;

	/* call the initialization function */
	mod->oclass = (*init)(&callbacks,(void*)mod,argc,argv);
	if (mod->oclass==NULL)
		return NULL;

	/* connect intrinsic functions */
	for (c=mod->oclass; c!=NULL; c=c->next) {
		char fname[1024];
		struct {
			FUNCTIONADDR *func;
			char *name;
			int optional;
		} map[] = {
			{&c->create,"create",FALSE},
			{&c->init,"init",TRUE},
			{&c->sync,"sync",TRUE},
			{&c->commit,"commit",TRUE},
			{&c->notify,"notify",TRUE},
			{&c->isa,"isa",TRUE},
			{&c->plc,"plc",TRUE},
			{&c->recalc,"recalc",TRUE},
		};
		int i;
		for (i=0; i<sizeof(map)/sizeof(map[0]); i++)
		{
			snprintf(fname, 1024,"%s_%s",map[i].name,isforeign?fmod:c->name);
			if ((*(map[i].func) = (FUNCTIONADDR)DLSYM(hLib,fname))==NULL && !map[i].optional)
			{
				output_fatal("intrinsic %s is not defined in class %s", fname,file);
				/*	TROUBLESHOOT
					A required intrinsic function was not found.  Please review and modify the class definition.
				 */
				errno=EINVAL;
				return NULL;
			}
			else
				if(!map[i].optional)
					output_verbose("%s(%d): module '%s' intrinsic %s found", __FILE__, __LINE__, file, fname);
		}
	}

	/* attach to list of known modules */
	if (first_module==NULL)
		first_module = mod;
	else
		last_module->next = mod;
	last_module = mod;
	return last_module;
}
示例#25
0
Vamp::Plugin *
FeatureExtractionPluginFactory::instantiatePlugin(QString identifier,
						  float inputSampleRate)
{
    Profiler profiler("FeatureExtractionPluginFactory::instantiatePlugin");

    Vamp::Plugin *rv = 0;
    Vamp::PluginHostAdapter *plugin = 0;

    const VampPluginDescriptor *descriptor = 0;
    int index = 0;

    QString type, soname, label;
    PluginIdentifier::parseIdentifier(identifier, type, soname, label);
    if (type != "vamp") {
	std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Wrong factory for plugin type " << type.toStdString() << std::endl;
	return 0;
    }

    QString found = findPluginFile(soname);

    if (found == "") {
        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find library file " << soname.toStdString() << std::endl;
        return 0;
    } else if (found != soname) {

#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Given library name was " << soname.toStdString() << ", found at " << found.toStdString() << std::endl;
        std::cerr << soname.toStdString() << " -> " << found.toStdString() << std::endl;
#endif

    }        

    soname = found;

    void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
            
    if (!libraryHandle) {
        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl;
        return 0;
    }

    VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
        DLSYM(libraryHandle, "vampGetPluginDescriptor");
    
    if (!fn) {
        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: No descriptor function in " << soname.toStdString() << std::endl;
        goto done;
    }

    while ((descriptor = fn(VAMP_API_VERSION, index))) {
        if (label == descriptor->identifier) break;
        ++index;
    }

    if (!descriptor) {
        std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Failed to find plugin \"" << label.toStdString() << "\" in library " << soname.toStdString() << std::endl;
        goto done;
    }

    plugin = new Vamp::PluginHostAdapter(descriptor, inputSampleRate);

    if (plugin) {
        m_handleMap[plugin] = libraryHandle;
        rv = new PluginDeletionNotifyAdapter(plugin, this);
    }

//    std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Constructed Vamp plugin, rv is " << rv << std::endl;

    //!!! need to dlclose() when plugins from a given library are unloaded

done:
    if (!rv) {
        if (DLCLOSE(libraryHandle) != 0) {
            std::cerr << "WARNING: FeatureExtractionPluginFactory::instantiatePlugin: Failed to unload library " << soname.toStdString() << std::endl;
        }
    }

//    std::cerr << "FeatureExtractionPluginFactory::instantiatePlugin: Instantiated plugin " << label.toStdString() << " from library " << soname.toStdString() << ": descriptor " << descriptor << ", rv "<< rv << ", label " << rv->getName() << ", outputs " << rv->getOutputDescriptors().size() << std::endl;
    
    return rv;
}
示例#26
0
static int
loadlib (gameinfo * gi, CBengine * engine)
{
	char enginepath[512];

#if 0
#ifdef WIN32

	strcpy (enginepath, gi->opponent);
	strcat (enginepath, ".dll");

	engine->handle = LoadLibrary (enginepath);
	if (!engine->handle)
	{
		printf ("\nNo such opponent.\n");
		fprintf (stderr, "DLL not found: %s.\n", enginepath);
		strcpy (gi->opponent, "part");
		return 0;
	}

#else // not WIN32

	const char *error;

	// try system location
	strcpy (enginepath, LIB_DIR);
	strcat (enginepath, gi->opponent);
	strcat (enginepath, ".so");
	engine->handle = dlopen (enginepath, RTLD_LAZY);

	// try cwd
	if (!engine->handle)
	{
		strcpy (enginepath, "./");
		strcat (enginepath, gi->opponent);
		strcat (enginepath, ".so");
		engine->handle = dlopen (enginepath, RTLD_LAZY);
	}

	if (!engine->handle)
	{
		printf ("\nNo such opponent.\n");
		fprintf (stderr, "%s", dlerror ());
		printf ("\nAdditional search path: %s\n", LIB_DIR);
		strcpy (gi->opponent, "part");
		return 0;
	}

#endif // WIN32

	// mandatory library functions
	engine->command = (E_COMMAND) DLSYM (engine->handle, "enginecommand");
	engine->islegal = (E_ISLEGAL) DLSYM (engine->handle, "islegal");
	engine->getmove = (E_GETMOVE) DLSYM (engine->handle, "getmove");
#endif

	engine->command = enginecommand;
	engine->islegal = islegal;
	engine->getmove = getmove;

#if 0
#ifdef WIN32
	if (engine->command == NULL
		|| engine->islegal == NULL || engine->getmove == NULL)
	{
		fprintf (stderr, "Invalid engine.\n");
		strcpy (gi->opponent, "part");
		DLCLOSE (engine->handle);
		return 0;
	}
#else // not WIN32
	if (engine->command == NULL
		|| engine->islegal == NULL || engine->getmove == NULL)
	{
		fprintf (stderr, "Invalid engine: ");
		if ((error = dlerror ()) != NULL)
			fprintf (stderr, "%s\n", error);
		strcpy (gi->opponent, "part");
		DLCLOSE (engine->handle);
		return 0;
	}
#endif
#endif

	return 1;
}
示例#27
0
/**
 * Load plugin for a given mount_type from ${pkglibdir}/mount_osd_FSTYPE.so and
 * return struct of function pointers (will be freed in unloack_backfs_module).
 *
 * \param[in] mount_type	Mount type to load module for.
 * \retval Value of backfs_ops struct
 * \retval NULL if no module exists
 */
struct module_backfs_ops *load_backfs_module(enum ldd_mount_type mount_type)
{
	void *handle;
	char *error, filename[512], fsname[512], *name;
	struct module_backfs_ops *ops;

	/* This deals with duplicate ldd_mount_types resolving to same OSD layer
	 * plugin (e.g. ext3/ldiskfs/ldiskfs2 all being ldiskfs) */
	strncpy(fsname, mt_type(mount_type), sizeof(fsname));
	name = fsname + sizeof("osd-") - 1;

	/* change osd- to osd_ */
	fsname[sizeof("osd-") - 2] = '_';

	snprintf(filename, sizeof(filename), PLUGIN_DIR"/mount_%s.so", fsname);

	handle = dlopen(filename, RTLD_LAZY);

	/* Check for $LUSTRE environment variable from test-framework.
	 * This allows using locally built modules to be used.
	 */
	if (handle == NULL) {
		char *dirname;
		dirname = getenv("LUSTRE");
		if (dirname) {
			snprintf(filename, sizeof(filename),
				 "%s/utils/.libs/mount_%s.so",
				 dirname, fsname);
			handle = dlopen(filename, RTLD_LAZY);
		}
	}

	/* Do not clutter up console with missing types */
	if (handle == NULL)
		return NULL;

	ops = malloc(sizeof(*ops));
	if (ops == NULL) {
		dlclose(handle);
		return NULL;
	}

	ops->dl_handle = handle;
	dlerror(); /* Clear any existing error */

	DLSYM(name, ops, init);
	DLSYM(name, ops, fini);
	DLSYM(name, ops, read_ldd);
	DLSYM(name, ops, write_ldd);
	DLSYM(name, ops, is_lustre);
	DLSYM(name, ops, make_lustre);
	DLSYM(name, ops, prepare_lustre);
	DLSYM(name, ops, tune_lustre);
	DLSYM(name, ops, label_lustre);
	DLSYM(name, ops, enable_quota);

	error = dlerror();
	if (error != NULL) {
		fatal();
		fprintf(stderr, "%s\n", error);
		dlclose(handle);
		free(ops);
		return NULL;
	}
	return ops;
}
示例#28
0
m64p_error PluginAPI::PluginStartup(m64p_dynlib_handle _CoreLibHandle)
{
	ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath)	DLSYM(_CoreLibHandle, "ConfigGetSharedDataFilepath");
	ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath)	DLSYM(_CoreLibHandle, "ConfigGetUserConfigPath");
	ConfigGetUserCachePath = (ptr_ConfigGetUserCachePath)DLSYM(_CoreLibHandle, "ConfigGetUserCachePath");
	ConfigGetUserDataPath = (ptr_ConfigGetUserDataPath)DLSYM(_CoreLibHandle, "ConfigGetUserDataPath");

	ConfigOpenSection = (ptr_ConfigOpenSection)DLSYM(_CoreLibHandle, "ConfigOpenSection");
	ConfigDeleteSection = (ptr_ConfigDeleteSection)DLSYM(_CoreLibHandle, "ConfigDeleteSection");
	ConfigSaveSection = (ptr_ConfigSaveSection)DLSYM(_CoreLibHandle, "ConfigSaveSection");
	ConfigSaveFile = (ptr_ConfigSaveFile)DLSYM(_CoreLibHandle, "ConfigSaveFile");
	ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt)DLSYM(_CoreLibHandle, "ConfigSetDefaultInt");
	ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat)DLSYM(_CoreLibHandle, "ConfigSetDefaultFloat");
	ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool)DLSYM(_CoreLibHandle, "ConfigSetDefaultBool");
	ConfigSetDefaultString = (ptr_ConfigSetDefaultString)DLSYM(_CoreLibHandle, "ConfigSetDefaultString");
	ConfigGetParamInt = (ptr_ConfigGetParamInt)DLSYM(_CoreLibHandle, "ConfigGetParamInt");
	ConfigGetParamFloat = (ptr_ConfigGetParamFloat)DLSYM(_CoreLibHandle, "ConfigGetParamFloat");
	ConfigGetParamBool = (ptr_ConfigGetParamBool)DLSYM(_CoreLibHandle, "ConfigGetParamBool");
	ConfigGetParamString = (ptr_ConfigGetParamString)DLSYM(_CoreLibHandle, "ConfigGetParamString");

	/* Get the core Video Extension function pointers from the library handle */
	CoreVideo_Init = (ptr_VidExt_Init) DLSYM(_CoreLibHandle, "VidExt_Init");
	CoreVideo_Quit = (ptr_VidExt_Quit) DLSYM(_CoreLibHandle, "VidExt_Quit");
	CoreVideo_ListFullscreenModes = (ptr_VidExt_ListFullscreenModes) DLSYM(_CoreLibHandle, "VidExt_ListFullscreenModes");
	CoreVideo_SetVideoMode = (ptr_VidExt_SetVideoMode) DLSYM(_CoreLibHandle, "VidExt_SetVideoMode");
	CoreVideo_SetCaption = (ptr_VidExt_SetCaption) DLSYM(_CoreLibHandle, "VidExt_SetCaption");
	CoreVideo_ToggleFullScreen = (ptr_VidExt_ToggleFullScreen) DLSYM(_CoreLibHandle, "VidExt_ToggleFullScreen");
	CoreVideo_ResizeWindow = (ptr_VidExt_ResizeWindow) DLSYM(_CoreLibHandle, "VidExt_ResizeWindow");
	CoreVideo_GL_GetProcAddress = (ptr_VidExt_GL_GetProcAddress) DLSYM(_CoreLibHandle, "VidExt_GL_GetProcAddress");
	CoreVideo_GL_SetAttribute = (ptr_VidExt_GL_SetAttribute) DLSYM(_CoreLibHandle, "VidExt_GL_SetAttribute");
	CoreVideo_GL_GetAttribute = (ptr_VidExt_GL_GetAttribute) DLSYM(_CoreLibHandle, "VidExt_GL_GetAttribute");
	CoreVideo_GL_SwapBuffers = (ptr_VidExt_GL_SwapBuffers) DLSYM(_CoreLibHandle, "VidExt_GL_SwapBuffers");

	return M64ERR_SUCCESS;
}
示例#29
0
// open & setup audio device
// return: 1=success 0=fail
static int init(int rate,int channels,int format,int flags){

	/* SDL Audio Specifications */
	SDL_AudioSpec aspec, obtained;

#ifdef _WIN32
    if (!(hSDL = LoadLibraryA("SDL.dll")))
    {
        mp_msg(MSGT_AO, MSGL_ERR, "SDL LoadLibrary failed\n");
        return -1;
    }
#define DLSYM(x) if (!(p##x = (imp_##x) GetProcAddress(hSDL, #x))) \
    { \
        mp_msg(MSGT_AO, MSGL_ERR, "Error loading %s\n", #x); \
        return -1; \
    };

    DLSYM(SDL_Init);
    DLSYM(SDL_OpenAudio);
    DLSYM(SDL_CloseAudio);
    DLSYM(SDL_PauseAudio);
    DLSYM(SDL_GetError);
    DLSYM(SDL_QuitSubSystem);
#endif

	/* Allocate ring-buffer memory */
	buffer = av_fifo_alloc(BUFFSIZE);

	mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_INFO, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format));

	if(ao_subdevice) {
		setenv("SDL_AUDIODRIVER", ao_subdevice, 1);
		mp_msg(MSGT_AO,MSGL_INFO,MSGTR_AO_SDL_DriverInfo, ao_subdevice);
	}

	ao_data.channels=channels;
	ao_data.samplerate=rate;
	ao_data.format=format;

	ao_data.bps=channels*rate;
	if(format != AF_FORMAT_U8 && format != AF_FORMAT_S8)
	  ao_data.bps*=2;

	/* The desired audio format (see SDL_AudioSpec) */
	switch(format) {
	    case AF_FORMAT_U8:
		aspec.format = AUDIO_U8;
	    break;
	    case AF_FORMAT_S16_LE:
		aspec.format = AUDIO_S16LSB;
	    break;
	    case AF_FORMAT_S16_BE:
		aspec.format = AUDIO_S16MSB;
	    break;
	    case AF_FORMAT_S8:
		aspec.format = AUDIO_S8;
	    break;
	    case AF_FORMAT_U16_LE:
		aspec.format = AUDIO_U16LSB;
	    break;
	    case AF_FORMAT_U16_BE:
		aspec.format = AUDIO_U16MSB;
	    break;
	    default:
                aspec.format = AUDIO_S16LSB;
                ao_data.format = AF_FORMAT_S16_LE;
                mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, format);
	}

	/* The desired audio frequency in samples-per-second. */
	aspec.freq     = rate;

	/* Number of channels (mono/stereo) */
	aspec.channels = channels;

	/* The desired size of the audio buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq */
	aspec.samples  = SAMPLESIZE;

	/* This should be set to a function that will be called when the audio device is ready for more data. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling SDL_LockAudio and SDL_UnlockAudio in your code. The callback prototype is:
void callback(void *userdata, Uint8 *stream, int len); userdata is the pointer stored in userdata field of the SDL_AudioSpec. stream is a pointer to the audio buffer you want to fill with information and len is the length of the audio buffer in bytes. */
	aspec.callback = outputaudio;

	/* This pointer is passed as the first parameter to the callback function. */
	aspec.userdata = NULL;

	/* initialize the SDL Audio system */
        if (SDL_Init (SDL_INIT_AUDIO/*|SDL_INIT_NOPARACHUTE*/)) {
                mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantInit, SDL_GetError());
                return 0;
        }

	/* Open the audio device and start playing sound! */
	if(SDL_OpenAudio(&aspec, &obtained) < 0) {
        	mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_SDL_CantOpenAudio, SDL_GetError());
        	return 0;
	}

	/* did we got what we wanted ? */
	ao_data.channels=obtained.channels;
	ao_data.samplerate=obtained.freq;

	switch(obtained.format) {
	    case AUDIO_U8 :
		ao_data.format = AF_FORMAT_U8;
	    break;
	    case AUDIO_S16LSB :
		ao_data.format = AF_FORMAT_S16_LE;
	    break;
	    case AUDIO_S16MSB :
		ao_data.format = AF_FORMAT_S16_BE;
	    break;
	    case AUDIO_S8 :
		ao_data.format = AF_FORMAT_S8;
	    break;
	    case AUDIO_U16LSB :
		ao_data.format = AF_FORMAT_U16_LE;
	    break;
	    case AUDIO_U16MSB :
		ao_data.format = AF_FORMAT_U16_BE;
	    break;
	    default:
                mp_msg(MSGT_AO,MSGL_WARN,MSGTR_AO_SDL_UnsupportedAudioFmt, obtained.format);
                return 0;
	}

	mp_msg(MSGT_AO,MSGL_V,"SDL: buf size = %d\n",obtained.size);
	ao_data.buffersize=obtained.size;
	ao_data.outburst = CHUNK_SIZE;

	/* unsilence audio, if callback is ready */
	SDL_PauseAudio(0);

	return 1;
}
示例#30
0
std::vector<QString>
FeatureExtractionPluginFactory::getPluginIdentifiers()
{
    Profiler profiler("FeatureExtractionPluginFactory::getPluginIdentifiers");

    std::vector<QString> rv;
    std::vector<QString> path = getPluginPath();
    
    for (std::vector<QString>::iterator i = path.begin(); i != path.end(); ++i) {

#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
        std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: scanning directory " << i->toStdString() << std::endl;
#endif

	QDir pluginDir(*i, PLUGIN_GLOB,
                       QDir::Name | QDir::IgnoreCase,
                       QDir::Files | QDir::Readable);

	for (unsigned int j = 0; j < pluginDir.count(); ++j) {

            QString soname = pluginDir.filePath(pluginDir[j]);

#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: trying potential library " << soname.toStdString() << std::endl;
#endif

            void *libraryHandle = DLOPEN(soname, RTLD_LAZY | RTLD_LOCAL);
            
            if (!libraryHandle) {
                std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to load library " << soname.toStdString() << ": " << DLERROR() << std::endl;
                continue;
            }

#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: It's a library all right, checking for descriptor" << std::endl;
#endif

            VampGetPluginDescriptorFunction fn = (VampGetPluginDescriptorFunction)
                DLSYM(libraryHandle, "vampGetPluginDescriptor");

            if (!fn) {
                std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: No descriptor function in " << soname.toStdString() << std::endl;
                if (DLCLOSE(libraryHandle) != 0) {
                    std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl;
                }
                continue;
            }

#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
            std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Vamp descriptor found" << std::endl;
#endif

            const VampPluginDescriptor *descriptor = 0;
            int index = 0;

            std::map<std::string, int> known;
            bool ok = true;

            while ((descriptor = fn(VAMP_API_VERSION, index))) {

                if (known.find(descriptor->identifier) != known.end()) {
                    std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Plugin library "
                              << soname.toStdString()
                              << " returns the same plugin identifier \""
                              << descriptor->identifier << "\" at indices "
                              << known[descriptor->identifier] << " and "
                              << index << std::endl;
                    std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Avoiding this library (obsolete API?)" << std::endl;
                    ok = false;
                    break;
                } else {
                    known[descriptor->identifier] = index;
                }

                ++index;
            }

            if (ok) {

                index = 0;

                while ((descriptor = fn(VAMP_API_VERSION, index))) {

                    QString id = PluginIdentifier::createIdentifier
                        ("vamp", soname, descriptor->identifier);
                    rv.push_back(id);
#ifdef DEBUG_PLUGIN_SCAN_AND_INSTANTIATE
                    std::cerr << "FeatureExtractionPluginFactory::getPluginIdentifiers: Found plugin id " << id.toStdString() << " at index " << index << std::endl;
#endif
                    ++index;
                }
            }
            
            if (DLCLOSE(libraryHandle) != 0) {
                std::cerr << "WARNING: FeatureExtractionPluginFactory::getPluginIdentifiers: Failed to unload library " << soname.toStdString() << std::endl;
            }
	}
    }

    generateTaxonomy();

    return rv;
}