Пример #1
0
static void plugins_changed_cb (GFileMonitor *monitor, GFile *file, GFile *other_file,
                                GFileMonitorEvent event_type, gpointer user_data)
{
	gchar *path;
	PhidiasLoader *loader;

	path = g_file_get_path (file);
	loader = user_data;

	if (g_str_has_suffix (path, ".la") == TRUE) {
		switch (event_type) {
			case G_FILE_MONITOR_EVENT_DELETED:
				unload_plugin (loader, path);
				break;

			case G_FILE_MONITOR_EVENT_CREATED:
				load_plugin (loader, path);
				break;

			default:
				break;
		}
	}

	g_free (path);
}
Пример #2
0
 static int scan_for_plugins(const gchar *path)
 {
 	GDir			*dir;
 	const gchar	*name;
 	gchar			*filename;

	Trace("Loading plugins in \"%s\"",path);

    dir = g_dir_open(path,0,NULL);
    if(!dir)
		return ENOENT;

	name = g_dir_read_name(dir);
	while(name)
	{
		filename = g_build_filename(path,name,NULL);
		if(g_str_has_suffix(filename,G_MODULE_SUFFIX))
			load_plugin(filename);
		g_free(filename);
		name = g_dir_read_name(dir);
	}

	g_dir_close(dir);

    return 0;
 }
Пример #3
0
static void
run (void *cls, char *const *args, const char *cfgfile,
     const struct GNUNET_CONFIGURATION_Handle *cfg)
{
  struct GNUNET_NAMESTORE_PluginFunctions *nsp;  
  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded zone_key;
  struct GNUNET_CRYPTO_ShortHashCode zone;
  
  ok = 0;
  nsp = load_plugin (cfg);
  if (NULL == nsp)
  {
    FPRINTF (stderr,
             "%s", 
	     "Failed to initialize namestore.  Database likely not setup, skipping test.\n");
    return;
  }
  put_record (nsp, 1);
  get_record (nsp, 1);

  memset (&zone_key, 1, sizeof (zone_key));
  GNUNET_CRYPTO_short_hash (&zone_key, sizeof (zone_key), &zone);
  nsp->delete_zone (nsp->cls, &zone);
  unload_plugin (nsp);
}
Пример #4
0
gboolean init_plugins(const char *plugin_dir)
{
	gboolean ret = TRUE;

	if (!g_module_supported()) {
		log_global(LOG_WARNING, "DSO's not supported on this platform. Not loading any plugins");
	} else {
		const char *name;
		GDir *dir = g_dir_open(plugin_dir, 0, NULL);
		if (!dir) {
			log_global(LOG_WARNING, "Plugin dir does not exist, not loading plugins");
			return FALSE;
		}

		while ((name = g_dir_read_name(dir))) {
			if (strcmp(name + strlen(name) - strlen(G_MODULE_SUFFIX), G_MODULE_SUFFIX) != 0)
				continue;

			if (!load_plugin(plugin_dir, name))
				ret = FALSE;
		}

		g_dir_close(dir);
	}

	return ret;
}
static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
  int claimed = 0;
  int t = load_plugin ();
  struct ld_plugin_input_file file;
  if (!t)
    return NULL;

  file.name = abfd->filename;

  if (abfd->iostream)
    {
      file.fd = fileno ((FILE *) abfd->iostream);
      file.offset = 0;
      file.filesize = 0; /*FIXME*/
    }
  else
    {
      bfd *archive = abfd->my_archive;
      BFD_ASSERT (archive);
      file.fd = fileno ((FILE *) archive->iostream);
      file.offset = abfd->origin;
      file.filesize = arelt_size (abfd);

    }
  file.handle = abfd;
  claim_file (&file, &claimed);
  if (!claimed)
    return NULL;

  return abfd->xvec;
}
Пример #6
0
int main(int argc, char **argv)
{
    int                 i, dev_fd;
    const char         *dev_path, *plugin_path;
    const sim_plugin_t *butt;

    /* Args */
    dev_path = plugin_path = NULL;
    for (i=1; i<argc; ++i)
    {
        if (SAFE_NEXT_ARG("-d", 2, i, argc, argv))
          dev_path = argv[++i];
        else if (SAFE_NEXT_ARG("-p", 2, i, argc, argv))
          plugin_path = argv[++i];
        else
          usage(argv[0]);
    }

    if (!dev_path || !plugin_path)
      usage(argv[0]);

    /* Create the device */
    if ((dev_fd = open(dev_path, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) == -1)
      ERR("Opening device '%s'", dev_path);

    /* Load the plugin */
    butt = load_plugin(plugin_path);

    return 0;
}
Пример #7
0
void init_handlers() {
	b.channels = calloc(1, sizeof(b.channels));
	VEC_INIT(b.channels, 4);
	b.plugins = hashmap_create(4);
	b.handlers = hashmap_create(8);
	b.commands = hashmap_create(8);

	b.tick_functions = calloc(1, sizeof(struct double_link));

	if (!load_plugin(&b, "common")) {
		fprintf(stderr, "[core\tfail] error loading common plugin, exiting..\n");
	}

	if (!load_plugin(&b, "uncommon")) {
		printf("[core\tinfo] the uncommon plugin is not present.\n");
	}
}
Пример #8
0
int PPInstance::LoadPlugin( const std::string& dllFilename ) 
{
    if ( !m_pluginLoaded )
    { 
        ref_plugin();
        m_pluginLoaded = true;
    }

    int error = 0;
    if (!is_plugin_loaded()) {

      std::string pathname = dllFilename;
#ifdef P3D_PLUGIN_P3D_PLUGIN
      // This is a convenience macro for development.  If defined and
      // nonempty, it indicates the name of the plugin DLL that we will
      // actually run, even after downloading a possibly different
      // (presumably older) version.  Its purpose is to simplify iteration
      // on the plugin DLL.
      string override_filename = P3D_PLUGIN_P3D_PLUGIN;
      if (!override_filename.empty()) {
        pathname = override_filename;
      }
#endif  // P3D_PLUGIN_P3D_PLUGIN
      
      nout << "Attempting to load core API from " << pathname << "\n";
      string contents_filename = m_rootDir + "/contents.xml";
      if (!load_plugin(pathname, contents_filename, PANDA_PACKAGE_HOST_URL,
                       P3D_VC_normal, "", "", "", false, false, 
                       m_rootDir, "", nout)) {
        nout << "Unable to launch core API in " << pathname << "\n";
        error = 1;
      } else {

        // Format the coreapi_timestamp as a string, for passing as a
        // parameter.
        ostringstream stream;
        stream << _coreapi_dll.get_timestamp();
        string coreapi_timestamp = stream.str();

#ifdef PANDA_OFFICIAL_VERSION
        static const bool official = true;
#else
        static const bool official = false;
#endif
        P3D_set_plugin_version_ptr(P3D_PLUGIN_MAJOR_VERSION, P3D_PLUGIN_MINOR_VERSION,
                                   P3D_PLUGIN_SEQUENCE_VERSION, official,
                                   PANDA_DISTRIBUTOR,
                                   PANDA_PACKAGE_HOST_URL, coreapi_timestamp.c_str(),
                                   _coreapi_set_ver.c_str());

      }
    }

    if (error) {
      set_failed();
    }
    return error ;
}
Пример #9
0
/***********
 * Methods *
 ***********/
int main(int argc, char **argv)
{
	gtk_init(&argc, &argv);

	prefs   = grits_prefs_new(NULL, NULL);
	plugins = grits_plugins_new(g_getenv("GRITS_PLUGIN_PATH"), prefs);
	viewer  = grits_opengl_new(plugins, prefs);

	GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	GtkWidget *vbox   = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
	GtkWidget *config = gtk_notebook_new();
	g_signal_connect(window, "delete-event",    G_CALLBACK(on_delete),    NULL);
	g_signal_connect(window, "key-press-event", G_CALLBACK(on_key_press), NULL);
	gtk_widget_set_size_request(GTK_WIDGET(viewer), 300, 300);
	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(config), GTK_POS_BOTTOM);
	gtk_container_add(GTK_CONTAINER(window), vbox);
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(viewer), TRUE,  TRUE,  0);
	gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(config), FALSE, FALSE, 0);
	gtk_widget_show_all(window);

	/* Configurable stuff */
	grits_viewer_set_offline(viewer, TRUE);
	(void)load_plugin;
	load_plugin(plugins, "env",   viewer, prefs, GTK_NOTEBOOK(config));
	//load_plugin(plugins, "elev",  viewer, prefs, GTK_NOTEBOOK(config));
	//load_plugin(plugins, "sat",   viewer, prefs, GTK_NOTEBOOK(config));
	load_plugin(plugins, "map",   viewer, prefs, GTK_NOTEBOOK(config));
	//load_plugin(plugins, "alert", viewer, prefs, GTK_NOTEBOOK(config));
	//load_plugin(plugins, "radar", viewer, prefs, GTK_NOTEBOOK(config));
	load_plugin(plugins, "test",  viewer, prefs, GTK_NOTEBOOK(config));

	gtk_widget_show_all(config);
	gtk_main();

	//gdk_display_close(gdk_display_get_default());

	prefs   = NULL;
	plugins = NULL;
	viewer  = NULL;
	window  = vbox = config = NULL;
	return 0;
}
Пример #10
0
static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
  if (ld_plugin_object_p)
    return ld_plugin_object_p (abfd);

  if (abfd->plugin_format == bfd_plugin_unknown && !load_plugin (abfd))
    return NULL;

  return abfd->plugin_format == bfd_plugin_yes ? abfd->xvec : NULL;
}
Пример #11
0
static const bfd_target *
bfd_plugin_object_p (bfd *abfd)
{
  int claimed = 0;
  struct ld_plugin_input_file file;
  bfd *iobfd;
  static int have_loaded = 0;
  static int have_plugin = 0;

  if (!have_loaded)
    {
      have_loaded = 1;
      have_plugin = load_plugin ();
    }
  if (!have_plugin)
    return NULL;

  file.name = abfd->filename;

  if (abfd->my_archive)
    {
      iobfd = abfd->my_archive;
      file.offset = abfd->origin;
      file.filesize = arelt_size (abfd);
    }
  else
    {
      iobfd = abfd;
      file.offset = 0;
      file.filesize = 0;
    }

  if (!iobfd->iostream && !bfd_open_file (iobfd))
    return NULL;

  file.fd = fileno ((FILE *) iobfd->iostream);

  if (!abfd->my_archive)
    {
      struct stat stat_buf;
      if (fstat (file.fd, &stat_buf))
        return NULL;
      file.filesize = stat_buf.st_size;
    }

  file.handle = abfd;
  off_t cur_offset = lseek(file.fd, 0, SEEK_CUR);
  claim_file (&file, &claimed);
  lseek(file.fd, cur_offset, SEEK_SET);
  if (!claimed)
    return NULL;

  return abfd->xvec;
}
Пример #12
0
/*
#<pydoc>
def load_plugin(name):
    """
    Loads a plugin
    @return:
        - None if plugin could not be loaded
        - An opaque object representing the loaded plugin
    """
    pass
#</pydoc>
*/
static PyObject *py_load_plugin(const char *name)
{
  if ( qfileexist(name) )
    prepare_programmatic_plugin_load(name);
  plugin_t *r = load_plugin(name);
  PYW_GIL_CHECK_LOCKED_SCOPE();
  prepare_programmatic_plugin_load(NULL);
  if ( r == NULL )
    Py_RETURN_NONE;
  else
    return PyCObject_FromVoidPtr(r, NULL);
}
Пример #13
0
static int output_ini_handler(void* user, const char* section, const char* name, const char* value) {
    char file_name[1024];
    if (strcmp(section, "plugins"))
        return 1;

    if (strcmp(name, "output"))
        return 1;

    snprintf(file_name, sizeof(file_name), "./lib%s.so", value);
    if (!load_plugin(file_name, false)) 
        return 0;
    return 1;
}
Пример #14
0
int bad_plugin_dir_returns_1()
{
    int     status;
    fork_to_test(
        status = load_plugin("./FUBAR_DIR");
        if(status != 1)
        {
            printf("%s(): load_plugin returned %d\n", __func__, status);
            exit(1);
        }
        exit(0);
    )
}
Пример #15
0
int bad_plugin_returns_1()
{
    int     status;
    fork_to_test(
        status = load_plugin("badplugin" SO_SUFFIX);
        if(status != 1)
        {
            printf("%s(): load_plugin returned %d\n", __func__, status);
            exit(1);
        }
        exit(0);
    )
}
void
pluma_plugins_engine_activate_plugins (PlumaPluginsEngine *engine,
					PlumaWindow        *window)
{
	GSList *active_plugins = NULL;
	GList *pl;

	pluma_debug (DEBUG_PLUGINS);

	g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine));
	g_return_if_fail (PLUMA_IS_WINDOW (window));

	/* the first time, we get the 'active' plugins from mateconf */
	if (engine->priv->activate_from_prefs)
	{
		active_plugins = pluma_prefs_manager_get_active_plugins ();
	}

	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
	{
		PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;

		if (engine->priv->activate_from_prefs &&
		    g_slist_find_custom (active_plugins,
					 pluma_plugin_info_get_module_name (info),
					 (GCompareFunc)strcmp) == NULL)
			continue;

		/* If plugin is not active, don't try to activate/load it */
		if (!engine->priv->activate_from_prefs &&
		    !pluma_plugin_info_is_active (info))
			continue;

		if (load_plugin (engine, info))
			pluma_plugin_activate (info->plugin,
					       window);
	}

	if (engine->priv->activate_from_prefs)
	{
		g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
		g_slist_free (active_plugins);
		engine->priv->activate_from_prefs = FALSE;
	}

	pluma_debug_message (DEBUG_PLUGINS, "End");

	/* also call update_ui after activation */
	pluma_plugins_engine_update_plugins_ui (engine, window);
}
Пример #17
0
void plugin_factory::load_all()
{
	auto file_list = QDir(plugindir_).entryInfoList(
			QDir::Files | QDir::NoDotAndDotDot);
	for (auto const &info : file_list) {
		auto p = info.absoluteFilePath();
		QPluginLoader *ld;
		if ((ld = load_plugin(p)) != 0) {
			qDebug() << "Loaded plugin" << p;
			plugins_.insert(ld->metaData().value("IID").toString(), ld);
		} else
			qDebug() << p << "is not an acv plugin";
	}
}
Пример #18
0
static void load_hfile_plugins()
{
    static const struct hFILE_scheme_handler
        data = { hopen_mem, hfile_always_local, "built-in", 80 },
        file = { hopen_fd_fileuri, hfile_always_local, "built-in", 80 },
        preload = { hopen_preload, is_preload_url_remote, "built-in", 80 };

    schemes = kh_init(scheme_string);
    if (schemes == NULL) abort();

    hfile_add_scheme_handler("data", &data);
    hfile_add_scheme_handler("file", &file);
    hfile_add_scheme_handler("preload", &preload);
    init_add_plugin(NULL, hfile_plugin_init_net, "knetfile");
    init_add_plugin(NULL, hfile_plugin_init_mem, "mem");

#ifdef ENABLE_PLUGINS
    struct hts_path_itr path;
    const char *pluginname;
    hts_path_itr_setup(&path, NULL, NULL, "hfile_", 6, NULL, 0);
    while ((pluginname = hts_path_itr_next(&path)) != NULL) {
        void *obj;
        int (*init)(struct hFILE_plugin *) = (int (*)(struct hFILE_plugin *))
            load_plugin(&obj, pluginname, "hfile_plugin_init");

        if (init) {
            if (init_add_plugin(obj, init, pluginname) != 0)
                close_plugin(obj);
        }
    }
#else

#ifdef HAVE_LIBCURL
    init_add_plugin(NULL, hfile_plugin_init_libcurl, "libcurl");
#endif
#ifdef ENABLE_GCS
    init_add_plugin(NULL, hfile_plugin_init_gcs, "gcs");
#endif
#ifdef ENABLE_S3
    init_add_plugin(NULL, hfile_plugin_init_s3, "s3");
#endif

#endif

    // In the unlikely event atexit() fails, it's better to succeed here and
    // carry on; then eventually when the program exits, we'll merely close
    // down the plugins uncleanly, as if we had aborted.
    (void) atexit(hfile_exit);
}
static void
pluma_plugins_engine_activate_plugin_real (PlumaPluginsEngine *engine,
					   PlumaPluginInfo *info)
{
	const GList *wins;

	if (!load_plugin (engine, info))
		return;

	for (wins = pluma_app_get_windows (pluma_app_get_default ());
	     wins != NULL;
	     wins = wins->next)
	{
		pluma_plugin_activate (info->plugin, PLUMA_WINDOW (wins->data));
	}
}
Пример #20
0
static void preinit_x11_support(void)
{
#ifdef USE_DL_PLUGINS
  void *handle = load_plugin("X");
  assert(handle);
  X_register_speaker = DLSYM_ASSERT(handle, "X_register_speaker");
  X_load_text_font = DLSYM_ASSERT(handle, "X_load_text_font");
  X_pre_init = DLSYM_ASSERT(handle, "X_pre_init");
  X_close_text_display = DLSYM_ASSERT(handle, "X_close_text_display");
  X_handle_text_expose = DLSYM_ASSERT(handle, "X_handle_text_expose");
  X_set_resizable = DLSYM_ASSERT(handle, "X_set_resizable");
  X_process_key = DLSYM_ASSERT(handle, "X_process_key");
  X_pre_init();
  X_handle = handle;
#endif
}
Пример #21
0
static void
xed_plugins_engine_activate_plugin_real (XedPluginsEngine *engine,
					   XedPluginInfo *info)
{
	const GList *wins;

	if (!load_plugin (engine, info))
		return;

	for (wins = xed_app_get_windows (xed_app_get_default ());
	     wins != NULL;
	     wins = wins->next)
	{
		xed_plugin_activate (info->plugin, XED_WINDOW (wins->data));
	}
}
Пример #22
0
static int list_plugins(args_t *args)
{
    plugin_t *plugins = NULL;
    int nplugins = 0, mplugins = 0;

    init_plugin_paths(args);

    kstring_t str = {0,0,0};
    int i;
    for (i=0; i<args->nplugin_paths; i++)
    {
        DIR *dp = opendir(args->plugin_paths[i]);
        if ( dp==NULL ) continue;

        struct dirent *ep;
        while ( (ep=readdir(dp)) )
        {
            int len = strlen(ep->d_name);
            if ( strcasecmp(".so",ep->d_name+len-3) ) continue;
            str.l = 0;
            ksprintf(&str,"%s/%s", args->plugin_paths[i],ep->d_name);
            hts_expand(plugin_t, nplugins+1, mplugins, plugins);
            if ( load_plugin(args, str.s, 0, &plugins[nplugins]) < 0 ) continue;
            nplugins++;
            str.l = 0;
            kputs(ep->d_name, &str);
            int l = str.l - 1;
            while ( l>=0 && str.s[l]!='.' ) l--;
            if ( l>=0 ) str.s[l] = 0;
            free(plugins[nplugins-1].name);
            plugins[nplugins-1].name = strdup(str.s);  // use a short name
        }
        closedir(dp);
    }
    if ( nplugins )
    {
        qsort(plugins, nplugins, sizeof(plugins[0]), cmp_plugin_name);

        for (i=0; i<nplugins; i++)
            printf("\n-- %s --\n%s", plugins[i].name, plugins[i].about());
        printf("\n");
    }
    else
        print_plugin_usage_hint();
    free(str.s);
    return nplugins ? 0 : 1;
}
Пример #23
0
static void load_plugins (PhidiasLoader *item)
{
	gchar *plug_path;
	gchar *plug_name;
	GError *error;
	GFile *plugins_folder;
	GFileEnumerator *enumerator;
	GFileInfo *plugin;

	plugins_folder = g_file_new_for_path (item->priv->path);

	error = NULL;
	enumerator = g_file_enumerate_children (plugins_folder, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &error);
	if (enumerator == NULL) {
		g_warning ("Unable to list plugins in %s: %s.", item->priv->path, error->message);
		g_error_free (error);
	}
	else {
		for (;;) {
			error = NULL;
			plugin = g_file_enumerator_next_file (enumerator, NULL, &error);

			if (plugin == NULL) {
				if (error != NULL) {
					g_warning ("Unable to iterate plugins in %s: %s.", item->priv->path, error->message);
					g_error_free (error);
				}

				break;
			}

			plug_name = g_file_info_get_attribute_as_string (plugin, G_FILE_ATTRIBUTE_STANDARD_NAME);
			if (g_str_has_suffix (plug_name, ".la") == TRUE) {
				plug_path = g_build_filename (item->priv->path, plug_name, NULL);
				load_plugin (item, (const gchar*) plug_path);
				g_free (plug_path);
			}

			g_free (plug_name);
			g_object_unref (plugin);
		}
	}

	g_object_unref (plugins_folder);
}
Пример #24
0
static int query_old_module(const char *filename, const char *modpath)
{
    int ret, status = STATUS_OK;
    char namebuf[NAME_LEN] = { '\0' };
    char options[OPTS_SIZE] = { '\0' };

    vframe_list_t ptr;

    memset(&ptr, 0, sizeof(ptr));

    /* compatibility support only for filters */
    if (verbose >= TC_DEBUG) {
        tc_log_info(EXE, "using old module system");
    }
    /* ok, fallback to old module system */
    strlcpy(namebuf, filename, NAME_LEN);
    filter[0].name = namebuf;
    
    ret = load_plugin(modpath, 0, verbose);
    if (ret != 0) {
        tc_log_error(__FILE__, "unable to load filter `%s' (path=%s)",
                               filter[0].name, modpath);
        status = STATUS_NO_MODULE;
    } else {
        strlcpy(options, "help", OPTS_SIZE);
        ptr.tag = TC_FILTER_INIT;
        if ((ret = filter[0].entry(&ptr, options)) != 0) {
            status = STATUS_MODULE_ERROR;
        } else {
            memset(options, 0, OPTS_SIZE);
            ptr.tag = TC_FILTER_GET_CONFIG;
            ret = filter[0].entry(&ptr, options);

            if (ret == 0) {
                if (verbose >= TC_INFO) {
                    fputs("START\n", stdout);
                    fputs(options, stdout);
                    fputs("END\n", stdout);
                }
                status = STATUS_OK;
            }
        }
    }
    return status;
}
Пример #25
0
static void
load_plugins (KaPluginLoader *self)
{
	int i;
	KaPluginLoaderPrivate *priv = GET_PRIVATE (self);
	GSettings *settings;
	char **plugins = NULL;

	if (!g_module_supported ()) {
		g_warning ("GModules are not supported on your platform!");
		return;
	}
	settings = g_settings_get_child(ka_applet_get_settings (priv->applet),
                                        KA_SETTING_CHILD_PLUGINS);

	/* For now we only load the plugins on program startup */
	plugins = g_settings_get_strv(settings,
                                      KA_SETTING_KEY_PLUGINS_ENABLED);

	if (!plugins) {
		g_message ("No plugins to load");
		return;
	}

	for (i = 0; plugins[i]; i++) {
		char *path;
		char *fname;
		KaPlugin *plugin;

		fname = g_strdup_printf("libka-plugin-%s.%s",
                                        plugins[i],
                                        G_MODULE_SUFFIX);
		path = g_module_build_path (KA_PLUGINS_DIR, fname);

		plugin = load_plugin (path);
		if (plugin) {
			ka_plugin_activate(plugin, priv->applet);
			priv->active_plugins = g_slist_prepend (priv->active_plugins, plugin);
		}
		g_free (fname);
		g_free (path);
	}
	g_strfreev (plugins);
	g_object_unref (settings);
}
Пример #26
0
int main(void)
{
	iorange_t *r;

	// load_plugin("kbd");
	// load_plugin("pci");
	load_plugin("qt");

	printf("\nRegistered IO Ranges:\n");
	r = ioranges;
	while (r) {
		printf("  %s: %x-%x\n", r->name, r->start, r->end);
		r = r->next;
	}

	sleep(10);
	return 0;
}
Пример #27
0
  // Split-complex FFT
  void 
  fft(T const* in_re, T const* in_im, T* out_re, T* out_im, 
    length_type length, T scale, int exponent)
  {
    assert(is_dma_addr_ok(in_re));
    assert(is_dma_addr_ok(in_im));
    assert(is_dma_addr_ok(out_re));
    assert(is_dma_addr_ok(out_im));

    static char* code_ea = 0;
    static int   code_size;
    Overlay_params params;
    Fft_split_params* fftp = &params.zfft;

    if (code_ea == 0) load_plugin(code_ea, code_size, "plugin", "zhalfast_f");

    fftp->code_ea        = (uintptr_t)code_ea;
    fftp->code_size      = code_size;
    fftp->cmd            = overlay_zfft_f;
    fftp->direction      = (exponent == -1 ? fwd_fft : inv_fft);
    fftp->size           = length;
    fftp->scale          = scale;
    fftp->ea_input_re    = ea_from_ptr(in_re);
    fftp->ea_input_im    = ea_from_ptr(in_im);
    fftp->ea_output_re   = ea_from_ptr(out_re);
    fftp->ea_output_im   = ea_from_ptr(out_im);
    fftp->in_blk_stride  = 0;  // not applicable in the single FFT case
    fftp->out_blk_stride = 0;
    fftp->chunks_per_wb  = 1;
    fftp->chunks_per_spe = 1;

    Task_manager *mgr = Task_manager::instance();
    Task task = mgr->reserve_iobuf<Plugin_tag, void>
      (VSIP_IMPL_OVERLAY_STACK_SIZE,
       sizeof(Overlay_params), 
       VSIP_IMPL_OVERLAY_BUFFER_SIZE, VSIP_IMPL_OVERLAY_DTL_SIZE);
    assert(2*sizeof(complex<T>)*length <= VSIP_IMPL_OVERLAY_BUFFER_SIZE);

    Workblock block = task.create_workblock(1);
    block.set_parameters(params);
    block.enqueue();

    task.sync();
  }
Пример #28
0
static void
trace_util_load_plugins_dir(struct pevent *pevent, const char *suffix,
			    const char *path,
			    void (*load_plugin)(struct pevent *pevent,
						const char *path,
						const char *name,
						void *data),
			    void *data)
{
	struct dirent *dent;
	struct stat st;
	DIR *dir;
	int ret;

	ret = stat(path, &st);
	if (ret < 0)
		return;

	if (!S_ISDIR(st.st_mode))
		return;

	dir = opendir(path);
	if (!dir)
		return;

	while ((dent = readdir(dir))) {
		const char *name = dent->d_name;

		if (strcmp(name, ".") == 0 ||
		    strcmp(name, "..") == 0)
			continue;

		/* Only load plugins that end in suffix */
		if (strcmp(name + (strlen(name) - strlen(suffix)), suffix) != 0)
			continue;

		load_plugin(pevent, path, name, data);
	}

	closedir(dir);

	return;
}
Пример #29
0
void plugin_manager_t::load_plugins_in_directory( const boost::filesystem::path& p)
{
    // TODO: error handling, recurse

    if( !boost::filesystem::exists( p))
        return;

    boost::filesystem::directory_iterator end_iter;
    for( boost::filesystem::directory_iterator dir_itr( p); dir_itr != end_iter; ++dir_itr)
    {
        if( boost::filesystem::is_regular_file( dir_itr->status()))
            load_plugin( *dir_itr);
        else
        {
            if( boost::filesystem::is_directory( dir_itr->status()))
				load_plugins_in_directory( *dir_itr);
        }
    }
}
Пример #30
0
static int query_ini_handler(void* user, const char* section, const char* name, const char* value) {
    char file_name[1024];
    static bool loaded = false;
    if (strcmp(section, "plugins"))
        return 1;

    if (strcmp(name, "query"))
        return 1;

    if (loaded) {
        fprintf(stderr, "You can only specify one query plugin.\n");
        return 0;
    }

    snprintf(file_name, sizeof(file_name), "./lib%s.so", value);
    if (!load_plugin(file_name, true))
        return 0;
    return 1;
}