예제 #1
0
int PluginAClientLAD::process_realtime(int64_t size, 
	Samples **input_ptr, Samples **output_ptr)
{
	int in_channels = get_inchannels();
	int out_channels = get_outchannels();
	init_plugin(in_channels, out_channels, size);

	for(int i = 0; i < in_channels; i++) {
		float *in_buffer = in_buffers[i];
		int k = i < PluginClient::total_in_buffers ? i : 0;
		double *in_ptr = input_ptr[k]->get_data();
		for(int j = 0; j < size; j++) in_buffer[j] = in_ptr[j];
	}
	for(int i = 0; i < out_channels; i++)
		bzero(out_buffers[i], sizeof(float) * size);

	server->lad_descriptor->run(lad_instance, size);

	int nbfrs = PluginClient::total_out_buffers;
	if( out_channels < nbfrs ) nbfrs = out_channels;
	for(int i = 0; i < nbfrs; i++) {
		LADSPA_Data *out_buffer = out_buffers[i];
		double *out_ptr = output_ptr[i]->get_data();
		for(int j = 0; j < size; j++) out_ptr[j] = out_buffer[j];
	}
	return size;
}
예제 #2
0
int main(int argc,char ** argv)
{
	//set log level first
	setenv("LOG_LEVEL","2",1);
	char ** ppHead=argv;
	while(ppHead!=NULL && *ppHead!=NULL)
	{
		if(strcmp(*ppHead,"-h")==0)
		{
			printHelp();
			exit(0);
		}
		ppHead++;
	}
	int ret=init_context(argc,argv);
	logI("MAIN","================init context complete===============\n");
	if(ret==-1)
	{
		release();
		printHelp();
		exit(1);
			
	}
	
	init_plugin(argc,argv);
	logI("MAIN","================init plugins complete===============\n");

	startup();
	
	return 0;
}
예제 #3
0
/**
 * Initializes plugins. Browses the plugins directory and calls
 * init_plugin() for each plugin file found with the extension being
 * @ref PLUGIN_SUFFIX. */
void init_plugins()
{
	struct dirent *currentfile;
	DIR *plugdir;
	char pluginfile[MAX_BUF];

	LOG(llevInfo, "Initializing plugins from '%s':\n", PLUGINDIR);

	if (!(plugdir = opendir(PLUGINDIR)))
	{
		return;
	}

	while ((currentfile = readdir(plugdir)))
	{
		size_t l = strlen(currentfile->d_name);

		if (l > strlen(PLUGIN_SUFFIX) && !strcmp(currentfile->d_name + l - strlen(PLUGIN_SUFFIX), PLUGIN_SUFFIX))
		{
			snprintf(pluginfile, sizeof(pluginfile), "%s/%s", PLUGINDIR, currentfile->d_name);
			LOG(llevInfo, "Loading plugin %s\n", currentfile->d_name);
			init_plugin(pluginfile);
		}
	}

	closedir(plugdir);
}
예제 #4
0
파일: downloader.cpp 프로젝트: myly10/mwget
int
Downloader::init_task(void)
{
	int i;
	int ret;

_reinit_plugin:
	if(init_plugin() < 0){
		cerr<<_("Unknown protocol")<<endl;
		return -1;
	}

	for(i = 0; task.tryCount <= 0 || i < task.tryCount; i ++){
		ret = plugin->get_info(&task);
		if(ret == -1){
			return -1;
		}else if(ret == S_REDIRECT){
			cerr<<_("Redirect to: ")<<task.url.get_url()<<endl;
			goto _reinit_plugin;
		}else if(ret == 0){
			return 0;
		}else{
			continue;
		}
	}

	return E_MAX_COUNT;
};
예제 #5
0
void ne_init(void)
{
	memset(&ne, 0, sizeof(ne));

	yylex_init_extra(&ne, &ne.scanner);

	init_built_in(&ne);
	init_plugin(&ne);
}
예제 #6
0
//--------------------------------------------------------------------------
// Initialize debugger plugin
static int idaapi init(void)
{
  if ( init_plugin() )
  {
    dbg = &debugger;
    plugin_inited = true;
    return PLUGIN_KEEP;
  }
  return PLUGIN_SKIP;
}
예제 #7
0
파일: init.cpp 프로젝트: salilab/rmf
VMDPLUGIN_API int VMDPLUGIN_init() {
  init_plugin(plugin);
  plugin.name = "rmf";
  plugin.prettyname = "RMF";
  plugin.filename_extension = "rmf";

  init_plugin(plugin3);
  plugin3.name = "rmf3";
  plugin3.prettyname = "RMF3";
  plugin3.filename_extension = "rmf3";

  init_plugin(pluginz);
  pluginz.name = "rmfz";
  pluginz.prettyname = "RMFz";
  pluginz.filename_extension = "rmfz";

  RMF::set_log_level("off");

  return VMDPLUGIN_SUCCESS;
}
예제 #8
0
파일: plugins.c 프로젝트: ikrabbe/nyx
plugin_repository_t *
discover_plugins(const char *directory, hash_t *config)
{
    plugin_repository_t *repo = NULL;

    if (directory == NULL || *directory == '\0')
        return NULL;

    log_debug("Searching plugin directory '%s'", directory);

    DIR *dir = opendir(directory);
    if (dir)
    {
        repo = plugin_repository_new(config);

        struct dirent *entry = NULL;
        while ((entry = readdir(dir)) != NULL)
        {
            const char *plugin_name = get_plugin(entry->d_name);
            if (!plugin_name)
                continue;

            log_debug("Found plugin '%s'", plugin_name);

            plugin_t *plugin = init_plugin(directory, plugin_name, repo->manager);

            /* plugin initialization failed */
            if (plugin == NULL)
            {
                log_warn("Failed to load plugin '%s'", plugin_name);
                free((void *)plugin_name);
            }
            else
            {
                list_add(repo->plugins, plugin);
                log_info("Successfully loaded plugin '%s'", plugin_name);
            }
        }

        closedir(dir);

        /* we can immediately release the whole plugin repository
         * in case we could not initialize at least one plugin */
        if (list_size(repo->plugins) < 1)
        {
            plugin_repository_destroy(repo);
            repo = NULL;
        }
    }

    return repo;
}
예제 #9
0
static int load_plugins(void)
{
	const char *fsdir = getenv("FSIMAGE_FSDIR");
	struct dirent *dp = NULL;
	struct dirent *dpp;
	DIR *dir = NULL;
	char *tmp = NULL;
	size_t name_max;
	int err;
	int ret = -1;

	if (fsdir == NULL)
		fsdir = FSIMAGE_FSDIR;

	if ((name_max = pathconf(fsdir, _PC_NAME_MAX)) == -1)
		goto fail;

	if ((tmp = malloc(name_max + 1)) == NULL)
		goto fail;

	if ((dp = malloc(sizeof (struct dirent) + name_max + 1)) == NULL)
		goto fail;

	if ((dir = opendir(fsdir)) == NULL)
		goto fail;

	bzero(dp, sizeof (struct dirent) + name_max + 1);

	while (readdir_r(dir, dp, &dpp) == 0 && dpp != NULL) {
		if (strcmp(dpp->d_name, ".") == 0)
			continue;
		if (strcmp(dpp->d_name, "..") == 0)
			continue;

		(void) snprintf(tmp, name_max, "%s/%s/fsimage.so", fsdir,
			dpp->d_name);

		if (init_plugin(tmp) != 0)
			goto fail;
	}

	ret = 0;

fail:
	err = errno;
	if (dir != NULL)
		(void) closedir(dir);
	free(tmp);
	free(dp);
	errno = err;
	return (ret);
}
예제 #10
0
//--------------------------------------------------------------------------
// Initialize debugger plugin
static int idaapi init(void)
{
	if (init_plugin())
	{
		dbg = &debugger;
		plugin_inited = true;
		dbg_started = false;
		hook_to_notification_point(HT_UI, hook_ui, NULL);
		hook_to_notification_point(HT_DBG, hook_dbg, NULL);

		print_version();
		return PLUGIN_KEEP;
	}
	return PLUGIN_SKIP;
}
예제 #11
0
static void init_data(args_t *args)
{
    args->hdr = args->files->readers[0].header;
    args->hdr_out = bcf_hdr_dup(args->hdr);

    init_plugin(args);

    if ( args->filter_str )
        args->filter = filter_init(args->hdr, args->filter_str);

    bcf_hdr_append_version(args->hdr_out, args->argc, args->argv, "bcftools_plugin");
    if ( !args->drop_header )
    {
        args->out_fh = hts_open(args->output_fname,hts_bcf_wmode(args->output_type));
        if ( args->out_fh == NULL ) error("Can't write to \"%s\": %s\n", args->output_fname, strerror(errno));
        bcf_hdr_write(args->out_fh, args->hdr_out);
    }
}
예제 #12
0
int PluginAClientLAD::process_realtime(int64_t size, 
	Samples *input_ptr, 
	Samples *output_ptr)
{
	int in_channels = get_inchannels();
	int out_channels = get_outchannels();
	init_plugin(in_channels, out_channels, size);

	double *input_samples = input_ptr->get_data();
	for(int i = 0; i < in_channels; i++) {
		LADSPA_Data *in_buffer = in_buffers[i];
		for(int j = 0; j < size; j++) in_buffer[j] = input_samples[j];
	}
	for(int i = 0; i < out_channels; i++)
		bzero(out_buffers[i], sizeof(float) * size);

	server->lad_descriptor->run(lad_instance, size);

	double *output_samples = output_ptr->get_data();
	LADSPA_Data *out_buffer = out_buffers[0];
	for(int i = 0; i < size; i++) output_samples[i] = out_buffer[i];
	return size;
}
예제 #13
0
파일: plugins.c 프로젝트: tycho/openbios
int load_plugin(const char *plugin_name)
{
	void *handle;
	char *error;
	char path[PATHSIZE];

	int (*init_plugin) (void);
	char **deps;
	char **plugin_info;
	plugin_t *p;

	if (is_loaded(plugin_name)) {
		printf("Plugin %s already loaded.\n", plugin_name);
		return 0;
	}

	strncpy(path, PLUGINDIR, PATHSIZE);
	strncat(path, "/plugin_", PATHSIZE);
	strncat(path, plugin_name, PATHSIZE);
	strncat(path, ".so", PATHSIZE);

#if DEBUG
	printf("Opening plugin %s\n", path);
#endif

	handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
	if (!handle) {
		error = dlerror();
		printf("Error: Could not open plugin \"%s\": %s\n",
		       plugin_name, error);
		exit(1);
	}
#ifdef CONFIG_DEBUG_PLUGINS
	plugin_info = dlsym(handle, "plugin_author");
	if ((error = dlerror()) == NULL)
		printf("Plugin %s author:  %s\n", plugin_name, *plugin_info);
	plugin_info = dlsym(handle, "plugin_license");
	if ((error = dlerror()) == NULL)
		printf("Plugin %s license: %s\n", plugin_name, *plugin_info);
	plugin_info = dlsym(handle, "plugin_description");
	if ((error = dlerror()) == NULL)
		printf("Plugin %s descr.: %s\n", plugin_name, *plugin_info);
#endif
	p = malloc(sizeof(plugin_t));
	p->next = plugins;
	p->name = plugin_name;
	plugins = p;

	deps = dlsym(handle, "plugin_deps");
	if ((error = dlerror()) != NULL)
		deps = NULL;


	strncpy(path, "plugin_", PATHSIZE);
	strncat(path, plugin_name, PATHSIZE);
	strncat(path, "_init", PATHSIZE);

	init_plugin = dlsym(handle, path);
	if ((error = dlerror()) != NULL) {
		printf("error: %s\n", error);
		exit(1);
	}

	if (deps) {
		int i = 0;
		char *walk = deps[0];
#ifdef CONFIG_DEBUG_PLUGINS
		printf("\nPlugin %s dependencies:", plugin_name);
#endif
		while (walk) {
			printf(" %s", walk);
			if (!is_loaded(walk)) {
#ifdef CONFIG_DEBUG_PLUGINS
				printf("(loading)\n");
#endif
				load_plugin(walk);
			}
#ifdef CONFIG_DEBUG_PLUGINS
			else {
				printf("(loaded)");
			}
#endif
			walk = deps[++i];
		}
	}

	printf("\n");
#if DEBUG
	printf("Initializing module:\n");
#endif

	return init_plugin();

	// We don't dlclose the handle here since
	// we want to keep our symbols for later use.
}
예제 #14
0
파일: dds_plugins.c 프로젝트: crew/c-dds
//Returns an array of all the threads that are running....
thread_container* init_dds_python(Dict* config){
	Py_Initialize();
	if(dict_has_key(config, "plugins")){
		Dict* val = dict_get_val(config, "plugins");

		
		char* cur_plugin;
		char* plugins_list_str = val->value;
		obj_list plugin_list = new_object_list();

		cur_plugin = strtok(plugins_list_str, ",");
		while(cur_plugin){
			//import_plugin(cur_plugin);
			init_plugin(cur_plugin, plugin_list);
			cur_plugin = strtok(NULL, ",");
		}
		int index = 0;
		int len = obj_list_len(plugin_list);
		PyObject* cb_dict = make_callback_dict(plugin_list);
		for(;index < len;index++){
			give_callback_registration_oppertunity(obj_list_get(plugin_list, index), cb_dict);
		}
		thread_container* result = make_thread_container();
		PyObject* mt_tuple = PyTuple_New(0);
		for(index = 0; index < len;index++){
			PyObject* cur = obj_list_get(plugin_list, index);
			PyObject* needsThread = PyObject_GetAttrString(cur, "needsThread");
			if(!needsThread){
				printf("Couldn't get the needsThread method...\n");
				PyErr_Print();
			}
			PyObject* doesNeed = PyObject_Call(needsThread, mt_tuple, NULL);
			if(!doesNeed){
				printf("Couldn't call the needsThread method...\n");
				PyErr_Print();
			}
			if(PyObject_IsTrue(doesNeed)){
				PyObject* getName = PyObject_GetAttrString(cur, "getName");
				if(!getName){
					printf("Couldn't get the getName function...\n");
					PyErr_Print();
				}
				PyObject* nameStr = PyObject_Call(getName, mt_tuple, NULL);
				if(!nameStr){
					printf("Couldn't call the get name function...\n");
					PyErr_Print();
				}
				Py_DECREF(getName);
				plugin_thread* tmp_thread = make_plugin_thread(PyString_AS_STRING(nameStr));
				Py_DECREF(nameStr);
				PyObject* runMethod = PyObject_GetAttrString(cur, "run");
				if(!runMethod){
					printf("Couldn't get the run method...\n");
					PyErr_Print();
				}else{
					pthread_create(&tmp_thread->thread, NULL, run_plugin, (void*)runMethod);
				
				}
				thread_container_add(result, tmp_thread);
			}else{
				//TODO figure out what we want to happen here xD
			}
			Py_DECREF(doesNeed);
			Py_DECREF(needsThread);
		}
		Py_DECREF(mt_tuple);
		Py_DECREF(cb_dict);
		del_object_list(plugin_list);
		return result;
	}
}
예제 #15
0
int main(const int argc, char *const argv[])
{
	int c;
	long rc;
	key_serial_t key = 0;
	char *buf;
	unsigned int timeout = 600; /* default idmap cache timeout */

	openlog(prog, 0, LOG_DAEMON);

	while ((c = getopt_long(argc, argv, "ht:v",
					long_options, NULL)) != -1) {
		switch (c) {
		case 'h':
			rc = 0;
			usage();
			goto out;
		case 't':
			rc = str_to_uint(optarg, &timeout);
			if (rc) {
				syslog(LOG_ERR, "bad timeout value %s: %s",
					optarg, strerror(rc));
				goto out;
			}
			break;
		case 'v':
			rc = 0;
			printf("version: %s\n", VERSION);
			goto out;
		default:
			rc = EINVAL;
			syslog(LOG_ERR, "unknown option: %c", c);
			goto out;
		}
	}

	rc = 1;
	/* is there a key? */
	if (argc <= optind) {
		usage();
		goto out;
	}

	/* get key and keyring values */
	errno = 0;
	key = strtol(argv[optind], NULL, 10);
	if (errno != 0) {
		key = 0;
		syslog(LOG_ERR, "Invalid key format: %s", strerror(errno));
		goto out;
	}

	if (init_plugin(&plugin_handle)) {
		plugin_handle = NULL;
		syslog(LOG_ERR, "Unable to initialize ID mapping plugin: %s",
			plugin_errmsg);
		goto out;
	}

	/* set timeout on key */
	rc = keyctl_set_timeout(key, timeout);
	if (rc == -1) {
		syslog(LOG_ERR, "unable to set key timeout: %s",
			strerror(errno));
		goto out_exit_plugin;
	}

	rc = keyctl_describe_alloc(key, &buf);
	if (rc == -1) {
		syslog(LOG_ERR, "keyctl_describe_alloc failed: %s",
		       strerror(errno));
		goto out_exit_plugin;
	}

	syslog(LOG_DEBUG, "key description: %s", buf);

	rc = cifs_idmap(key, buf);
out_exit_plugin:
	exit_plugin(plugin_handle);
out:
	return rc;
}
예제 #16
0
static int load_plugins(void)
{
	const char *fsdir = getenv("FSIMAGE_FSDIR");
	const char *isadir = "";
	struct dirent *dp = NULL;
	struct dirent *dpp;
	DIR *dir = NULL;
	char *tmp = NULL;
	size_t name_max;
	int err;
	int ret = -1;

#ifdef __sun__
	if (fsdir == NULL)
		fsdir = "/usr/lib/fs";

	if (sizeof(void *) == 8)
		isadir = "64/";
#elif defined(__ia64__)
	if (fsdir == NULL)
		fsdir = "/usr/lib/fs";
#else
	if (fsdir == NULL) {
		if (sizeof(void *) == 8)
			fsdir = "/usr/lib64/fs";
		else
			fsdir = "/usr/lib/fs";
	}
#endif

	if ((name_max = pathconf(fsdir, _PC_NAME_MAX)) == -1)
		goto fail;

	if ((tmp = malloc(name_max + 1)) == NULL)
		goto fail;

	if ((dp = malloc(sizeof (struct dirent) + name_max + 1)) == NULL)
		goto fail;

	if ((dir = opendir(fsdir)) == NULL)
		goto fail;

	bzero(dp, sizeof (struct dirent) + name_max + 1);

	while (readdir_r(dir, dp, &dpp) == 0 && dpp != NULL) {
		if (strcmp(dpp->d_name, ".") == 0)
			continue;
		if (strcmp(dpp->d_name, "..") == 0)
			continue;

		(void) snprintf(tmp, name_max, "%s/%s/%sfsimage.so", fsdir,
		    dpp->d_name, isadir);

		if (init_plugin(tmp) != 0)
			goto fail;
	}

	ret = 0;

fail:
	err = errno;
	if (dir != NULL)
		(void) closedir(dir);
	free(tmp);
	free(dp);
	errno = err;
	return (ret);
}
예제 #17
0
파일: core.c 프로젝트: AndreT/sampgdk
SAMPGDK_API(bool, sampgdk_Load(void **ppData)) {
  void *plugin = sampgdk_plugin_get_handle(RETURN_ADDRESS());
  return init_plugin(plugin, ppData) >= 0;
}