示例#1
0
flux_modlist_t module_get_modlist (modhash_t *mh)
{
    flux_modlist_t mods;
    zlist_t *uuids;
    char *uuid;
    module_t *p;

    if (!(mods = flux_modlist_create ()))
        goto done;
    if (!(uuids = zhash_keys (mh->zh_byuuid)))
        oom ();
    uuid = zlist_first (uuids);
    while (uuid) {
        p = zhash_lookup (mh->zh_byuuid, uuid);
        assert (p != NULL);
        if (flux_modlist_append (mods, module_get_name (p), p->size,
                                 p->digest, module_get_idle (p)) < 0) {
            flux_modlist_destroy (mods);
            mods = NULL;
            goto done;
        }
        uuid = zlist_next (uuids);
    }
done:
    zlist_destroy (&uuids);
    return mods;
}
示例#2
0
/* Load a sub module. */
int module_load_sub(const char *path, const char *submodule, char **prefixes)
{
        GString *full_path;
	char *exppath, *name, *rootmodule;
        int start, end, ret;

	g_return_val_if_fail(path != NULL, FALSE);
	g_return_val_if_fail(submodule != NULL, FALSE);

        exppath = convert_home(path);

	name = module_get_name(exppath, &start, &end);
	rootmodule = module_get_root(name, prefixes);
	g_free(name);

        full_path = g_string_new(exppath);
	if (strcmp(submodule, "core") == 0)
		g_string_insert(full_path, end, "_core");
	else {
		g_string_insert_c(full_path, start, '_');
		g_string_insert(full_path, start, submodule);
	}

	ret = module_load_full(full_path->str, rootmodule, submodule,
			       start, end, NULL);

	g_string_free(full_path, TRUE);
	g_free(rootmodule);
	g_free(exppath);
        return ret;
}
示例#3
0
文件: core.c 项目: Ackhuman/vlc
static libvlc_module_description_t *module_description_list_get(
                libvlc_instance_t *p_instance, const char *capability )
{
    libvlc_module_description_t *p_list = NULL,
                          *p_actual = NULL,
                          *p_previous = NULL;
    size_t count;
    module_t **module_list = module_list_get( &count );

    for (size_t i = 0; i < count; i++)
    {
        module_t *p_module = module_list[i];

        if ( !module_provides( p_module, capability ) )
            continue;

        p_actual = ( libvlc_module_description_t * ) malloc( sizeof( libvlc_module_description_t ) );
        if ( p_actual == NULL )
        {
            libvlc_printerr( "Not enough memory" );
            libvlc_module_description_list_release( p_list );
            module_list_free( module_list );
            return NULL;
        }

        if ( p_list == NULL )
            p_list = p_actual;

        const char* name = module_get_object( p_module );
        const char* shortname = module_get_name( p_module, false );
        const char* longname = module_get_name( p_module, true );
        const char* help = module_get_help( p_module );
        p_actual->psz_name = name ? strdup( name ) : NULL;
        p_actual->psz_shortname = shortname ? strdup( shortname ) : NULL;
        p_actual->psz_longname = longname ? strdup( longname ) : NULL;
        p_actual->psz_help = help ? strdup( help ) : NULL;

        p_actual->p_next = NULL;
        if ( p_previous )
            p_previous->p_next = p_actual;
        p_previous = p_actual;
    }

    module_list_free( module_list );
    VLC_UNUSED( p_instance );
    return p_list;
}
示例#4
0
static void register_request (ctx_t *ctx, const char *name,
                              flux_msg_handler_f cb)
{
    struct flux_match match = FLUX_MATCH_REQUEST;
    flux_msg_handler_t *w;

    match.topic_glob = xasprintf ("%s.%s", module_get_name (ctx->p), name);
    if (!(w = flux_msg_handler_create (ctx->h, match, cb, ctx->p)))
        log_err_exit ("flux_msg_handler_create");
    flux_msg_handler_start (w);
    if (zlist_append (ctx->handlers, w) < 0)
        oom ();
    free (match.topic_glob);
}
示例#5
0
文件: gui-amn.c 项目: hgn/perf-studio
static void generate_cl_elements(GtkTreeStore *treestore,
				 GtkTreeIter *root, struct module *module)
{
	GtkTreeIter child;
	char *module_name;

	assert(treestore);
	assert(root);
	assert(module);

	module_name = module_get_name(module);

	gtk_tree_store_append(treestore, &child, root);
	gtk_tree_store_set(treestore, &child, NAME, module_name, -1);
}
示例#6
0
文件: audio.c 项目: FLYKingdom/vlc
/*****************************************
 * Get the list of available audio outputs
 *****************************************/
libvlc_audio_output_t *
        libvlc_audio_output_list_get( libvlc_instance_t *p_instance,
                                      libvlc_exception_t *p_e )
{
    VLC_UNUSED( p_instance );
    libvlc_audio_output_t *p_list = NULL,
                          *p_actual = NULL,
                          *p_previous = NULL;
    module_t **module_list = module_list_get( NULL );

    for (size_t i = 0; module_list[i]; i++)
    {
        module_t *p_module = module_list[i];

        if( module_provides( p_module, "audio output" ) )
        {
            if( p_actual == NULL)
            {
                p_actual = ( libvlc_audio_output_t * )
                    malloc( sizeof( libvlc_audio_output_t ) );
                if( p_actual == NULL )
                {
                    libvlc_exception_raise( p_e );
                    libvlc_printerr( "Not enough memory" );
                    libvlc_audio_output_list_release( p_list );
                    module_list_free( module_list );
                    return NULL;
                }
                if( p_list == NULL )
                {
                    p_list = p_actual;
                    p_previous = p_actual;
                }
            }
            p_actual->psz_name = strdup( module_get_object( p_module ) );
            p_actual->psz_description = strdup( module_get_name( p_module, true )  );
            p_actual->p_next = NULL;
            if( p_previous != p_actual ) /* not first item */
                p_previous->p_next = p_actual;
            p_previous = p_actual;
            p_actual = p_actual->p_next;
        }
    }

    module_list_free( module_list );

    return p_list;
}
示例#7
0
static void register_event (ctx_t *ctx, const char *name,
                            flux_msg_handler_f cb)
{
    struct flux_match match = FLUX_MATCH_EVENT;
    flux_msg_handler_t *w;

    match.topic_glob = xasprintf ("%s.%s", module_get_name (ctx->p), name);
    if (!(w = flux_msg_handler_create (ctx->h, match, cb, ctx->p)))
        log_err_exit ("flux_msg_handler_create");
    flux_msg_handler_start (w);
    if (zlist_append (ctx->handlers, w) < 0)
        oom ();
    if (flux_event_subscribe (ctx->h, match.topic_glob) < 0)
        log_err_exit ("%s: flux_event_subscribe %s",
                  __FUNCTION__, match.topic_glob);
    free (match.topic_glob);
}
示例#8
0
文件: plugins.cpp 项目: Kafay/vlc
inline void PluginDialog::FillTree()
{
    module_t **p_list = module_list_get( NULL );
    module_t *p_module;

    for( unsigned int i = 0; (p_module = p_list[i] ) != NULL; i++ )
    {
        QStringList qs_item;
        qs_item << qfu( module_get_name( p_module, true ) )
                << qfu( module_get_capability( p_module ) )
                << QString::number( module_get_score( p_module ) );
#ifndef DEBUG
        if( qs_item.at(1).isEmpty() ) continue;
#endif

        QTreeWidgetItem *item = new QTreeWidgetItem( qs_item );
        treePlugins->addTopLevelItem( item );
    }
}
示例#9
0
文件: audio.c 项目: 0xheart0/vlc
/*****************************************
 * Get the list of available audio outputs
 *****************************************/
libvlc_audio_output_t *
        libvlc_audio_output_list_get( libvlc_instance_t *p_instance )
{
    size_t count;
    module_t **module_list = module_list_get( &count );
    libvlc_audio_output_t *list = NULL;

    for (size_t i = 0; i < count; i++)
    {
        module_t *module = module_list[i];

        if( !module_provides( module, "audio output" ) )
            continue;

        libvlc_audio_output_t *item = malloc( sizeof( *item ) );
        if( unlikely(item == NULL) )
        {
    error:
            libvlc_printerr( "Not enough memory" );
            libvlc_audio_output_list_release( list );
            list = NULL;
            break;
        }

        item->psz_name = strdup( module_get_object( module ) );
        item->psz_description = strdup( module_get_name( module, true ) );
        if( unlikely(item->psz_name == NULL || item->psz_description == NULL) )
        {
            free( item->psz_name );
            free( item->psz_description );
            free( item );
            goto error;
        }
        item->p_next = list;
        list = item;
    }
    module_list_free( module_list );

    VLC_UNUSED( p_instance );
    return list;
}
示例#10
0
/* Load module - automatically tries to load also the related non-core
   modules given in `prefixes' (like irc, fe, fe_text, ..) */
int module_load(const char *path, char **prefixes)
{
	char *exppath, *name, *submodule, *rootmodule;
        int start, end, ret;

	g_return_val_if_fail(path != NULL, FALSE);

	exppath = convert_home(path);

	name = module_get_name(exppath, &start, &end);
	rootmodule = module_get_root(name, prefixes);
	submodule = module_get_sub(name, rootmodule);
	g_free(name);

	ret = module_load_full(exppath, rootmodule, submodule,
			       start, end, prefixes);

	g_free(rootmodule);
	g_free(submodule);
        g_free(exppath);
        return ret;
}
示例#11
0
module_t *module_lookup_byname (modhash_t *mh, const char *name)
{
    zlist_t *uuids;
    char *uuid;
    module_t *result = NULL;

    if (!(uuids = zhash_keys (mh->zh_byuuid)))
        oom ();
    uuid = zlist_first (uuids);
    while (uuid) {
        module_t *p = zhash_lookup (mh->zh_byuuid, uuid);
        assert (p != NULL);
        if (!strcmp (module_get_name (p), name)) {
            result = p;
            break;
        }
        uuid = zlist_next (uuids);
        p = NULL;
    }
    zlist_destroy (&uuids);
    return result;
}
示例#12
0
/**
 * dlopen() library and initialize module descriptor accordingly
 *
 * \param[in]   libfile Path to dlopen
 * \param[out]  mod     Robinhood module descriptor to initialize
 *
 * \return 0 on success, negative error code on failure
 */
static int module_load_from_file(const char *libfile, rbh_module_t *mod)
{
    int rc;
    int i;
    struct symbol_descr {
      const char  *sym_name; /**< Exposed symbol name */
      void        *sym_addr; /**< Destination address */
      bool         sym_reqd; /**< Whether the symbol is required */
    } mod_symbols[] = {
      {"mod_get_name",           &mod->mod_ops.mod_get_name,           true},
      {"mod_get_version",        &mod->mod_ops.mod_get_version,        true},
      {"mod_get_status_manager", &mod->mod_ops.mod_get_status_manager, false},
      {"mod_get_action",         &mod->mod_ops.mod_get_action,         false},
      {"mod_get_scheduler",      &mod->mod_ops.mod_get_scheduler,      false},
    };

    if (libfile == NULL)
        return -EINVAL;

    memset(mod, 0, sizeof(*mod));

    mod->sym_hdl = dlopen(libfile, RTLD_NOW | RTLD_LOCAL | RTLD_DEEPBIND);
    if (mod->sym_hdl == NULL) {
        DisplayLog(LVL_CRIT, MODULE_TAG, "Cannot dlopen() '%s': %s",
                   libfile, dlerror());
        return -EINVAL;
    }

    /* Use the filename as module name until loading is done and successful */
    mod->name = libfile;

    for (i = 0; i < ARRAY_SIZE(mod_symbols); i++) {
        struct symbol_descr *sym = &mod_symbols[i];

        rc = module_sym_load(mod, sym->sym_name, sym->sym_addr, sym->sym_reqd);
        if (rc)
            goto err_out;

    }

    /* Get direct reference to the module name for faster accesses */
    mod->name = module_get_name(mod);
    mod->version = module_get_version(mod);
    if (mod->version != RBH_MODULE_VERSION) {
        DisplayLog(LVL_CRIT, MODULE_TAG, "Module '%s': incompatible version. "
                   "version %d != expected version %d", mod->name, mod->version,
                   RBH_MODULE_VERSION);
        rc = -EPROTO;
        goto err_out;
    }

    DisplayLog(LVL_DEBUG, MODULE_TAG, "Successfully loaded module '%s'",
               mod->name);

    return 0;

err_out:
    dlclose(mod->sym_hdl);
    mod->sym_hdl = NULL;
    return rc;
}
示例#13
0
/*********************************************************************
 * The Tree
 *********************************************************************/
PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
                            QTreeWidget( _parent ), p_intf( _p_intf )
{
    /* General Qt options */
    setAlternatingRowColors( true );
    setHeaderHidden( true );

    setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
    setTextElideMode( Qt::ElideNone );

    setUniformRowHeights( true );
    CONNECT( this, itemExpanded(QTreeWidgetItem*), this, resizeColumns() );

    /* Nice icons */
#define BI( a,b) QIcon a##_icon = QIcon( b )
    BI( audio, ":/prefsmenu/advanced/audio" );
    BI( video, ":/prefsmenu/advanced/video" );
    BI( input, ":/prefsmenu/advanced/codec" );
    BI( sout, ":/prefsmenu/advanced/sout" );
    BI( advanced, ":/prefsmenu/advanced/extended" );
    BI( playlist, ":/prefsmenu/advanced/playlist" );
    BI( interface, ":/prefsmenu/advanced/intf" );
#undef BI

    /* Build the tree for the main module */
    module_t *p_module = module_get_main();

    /* Initialisation and get the confsize */
    PrefsItemData *data = NULL;
    PrefsItemData *data_sub = NULL;
    QTreeWidgetItem *current_item = NULL;
    unsigned confsize;
    module_config_t *const p_config = module_config_get (p_module, &confsize);

    /* Go through the list of conf */
    for( size_t i = 0; i < confsize; i++ )
    {
        const char *psz_help;
        QIcon icon;

        /* Work on a new item */
        module_config_t *p_item = p_config + i;

        switch( p_item->i_type )
        {
        /* This is a category */
        case CONFIG_CATEGORY:
            if( p_item->value.i == -1 ) break;

            /* PrefsItemData Init */
            data = new PrefsItemData();
            data->name = qtr( config_CategoryNameGet( p_item->value.i ) );
            psz_help = config_CategoryHelpGet( p_item->value.i );
            if( psz_help )
                data->help = qtr( psz_help );
            else
                data->help.clear();
            data->i_type = TYPE_CATEGORY;
            data->i_object_id = p_item->value.i;

            /* This is a category, put a nice icon */
            switch( p_item->value.i )
            {
#define CI(a,b) case a: icon = b##_icon;break
            CI( CAT_AUDIO, audio );
            CI( CAT_VIDEO, video );
            CI( CAT_INPUT, input );
            CI( CAT_SOUT, sout );
            CI( CAT_ADVANCED, advanced );
            CI( CAT_PLAYLIST, playlist );
            CI( CAT_INTERFACE, interface );
            }
#undef CI

            /* Create a new QTreeItem to display it in the tree at top level */
            current_item = new QTreeWidgetItem();
            current_item->setText( 0, data->name );
            current_item->setIcon( 0 , icon );
            //current_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
            current_item->setData( 0, Qt::UserRole,
                                   qVariantFromValue( data ) );
            addTopLevelItem( current_item );
            break;

        /* This is a subcategory */
        case CONFIG_SUBCATEGORY:
            if( p_item->value.i == -1 ) break;

            /* Special cases: move the main subcategories to the parent cat*/
            if( data &&
                ( p_item->value.i == SUBCAT_VIDEO_GENERAL ||
                  p_item->value.i == SUBCAT_ADVANCED_MISC ||
                  p_item->value.i == SUBCAT_INPUT_GENERAL ||
                  p_item->value.i == SUBCAT_INTERFACE_GENERAL ||
                  p_item->value.i == SUBCAT_SOUT_GENERAL||
                  p_item->value.i == SUBCAT_PLAYLIST_GENERAL||
                  p_item->value.i == SUBCAT_AUDIO_GENERAL ) )
            {
                /* Data still contains the correct thing */
                data->i_type = TYPE_CATSUBCAT;
                data->i_subcat_id = p_item->value.i;
                data->name = qtr( config_CategoryNameGet( p_item->value.i ) );
                psz_help = config_CategoryHelpGet( p_item->value.i );
                if( psz_help )
                    data->help = qtr( psz_help );
                else
                    data->help.clear();
                current_item->setData( 0, Qt::UserRole,
                                       QVariant::fromValue( data ) );
                continue;
            }

            /* Normal Subcategories */

            /* Process the Data */
            data_sub = new PrefsItemData();
            data_sub->name = qtr( config_CategoryNameGet( p_item->value.i) );
            psz_help = config_CategoryHelpGet( p_item->value.i );
            if( psz_help )
                data_sub->help = qtr( psz_help );
            else
                data_sub->help.clear();
            data_sub->i_type = TYPE_SUBCATEGORY;
            data_sub->i_object_id = p_item->value.i;

            /* Create a new TreeWidget */
            QTreeWidgetItem *subcat_item = new QTreeWidgetItem();
            subcat_item->setText( 0, data_sub->name );
            subcat_item->setData( 0, Qt::UserRole,
                                  qVariantFromValue( data_sub ) );
            //subcat_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );

            /* Add it to the parent */
            assert( current_item );
            current_item->addChild( subcat_item );
            break;

        /* Other items don't need yet a place on the tree */
        }
    }
    module_config_free( p_config );


    module_t **p_list = module_list_get( NULL );
    /* Build the tree of plugins */
    for( size_t i = 0; (p_module = p_list[i]) != NULL; i++ )
    {
        // Main module excluded
        if( module_is_main( p_module) ) continue;

        unsigned  confsize;
        int i_subcategory = 0, i_category = 0;

        bool b_options = false;
        module_config_t *const p_config = module_config_get (p_module, &confsize);

        /* Loop through the configurations items */
        for (size_t i = 0; i < confsize; i++)
        {
            const module_config_t *p_item = p_config + i;

            if( p_item->i_type == CONFIG_CATEGORY )
                i_category = p_item->value.i;
            else if( p_item->i_type == CONFIG_SUBCATEGORY )
                i_subcategory = p_item->value.i;

            if( CONFIG_ITEM(p_item->i_type) )
                b_options = true;

            if( b_options && i_category && i_subcategory )
                break;
        }
        module_config_free (p_config);

        /* Dummy item, please proceed */
        if( !b_options || i_category == 0 || i_subcategory == 0 ) continue;


        // Locate the category item;
        QTreeWidgetItem *subcat_item = NULL;
        bool b_found = false;

        for( int i_cat_index = 0 ; i_cat_index < topLevelItemCount();
                                   i_cat_index++ )
        {
            /* Get the treeWidgetItem that correspond to the category */
            QTreeWidgetItem *cat_item = topLevelItem( i_cat_index );
            PrefsItemData *data = cat_item->data( 0, Qt::UserRole ).
                                             value<PrefsItemData *>();

            /* If we match the good category */
            if( data->i_object_id == i_category )
            {
                for( int i_sc_index = 0; i_sc_index < cat_item->childCount();
                         i_sc_index++ )
                {
                    subcat_item = cat_item->child( i_sc_index );
                    PrefsItemData *sc_data = subcat_item->data(0, Qt::UserRole).
                                                value<PrefsItemData *>();
                    if( sc_data && sc_data->i_object_id == i_subcategory )
                    {
                        b_found = true;
                        break;
                    }
                }
                if( !b_found )
                {
                    subcat_item = cat_item;
                    b_found = true;
                }
                break;
            }
        }
        if( !b_found ) continue;

        PrefsItemData *module_data = new PrefsItemData();
        module_data->i_type = TYPE_MODULE;
        module_data->psz_name = strdup( module_get_object( p_module ) );
        module_data->name = qtr( module_get_name( p_module, false ) );
        module_data->help.clear();
        const char *psz_help = module_get_help( p_module );
        if ( psz_help )
            module_data->help = qtr( psz_help );

        QTreeWidgetItem *module_item = new QTreeWidgetItem();
        module_item->setText( 0, module_data->name );
        module_item->setData( 0, Qt::UserRole,
                              QVariant::fromValue( module_data) );
        //module_item->setSizeHint( 0, QSize( -1, ITEM_HEIGHT ) );
        subcat_item->addChild( module_item );
    }

    /* We got everything, just sort a bit */
    sortItems( 0, Qt::AscendingOrder );

    module_list_free( p_list );
    resizeColumnToContents( 0 );
}
/* Helpers */
static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
                                                    const char *psz_name,
                                                    config_chain_t *p_cfg,
                                                    const es_format_t *p_fmt_in,
                                                    const es_format_t *p_fmt_out )
{
    chained_filter_t *p_chained =
        vlc_custom_create( p_chain->p_this, sizeof(*p_chained), "filter" );
    filter_t *p_filter = &p_chained->filter;
    if( !p_filter )
        return NULL;

    if( !p_fmt_in )
    {
        if( p_chain->last != NULL )
            p_fmt_in = &p_chain->last->filter.fmt_out;
        else
            p_fmt_in = &p_chain->fmt_in;
    }

    if( !p_fmt_out )
    {
        p_fmt_out = &p_chain->fmt_out;
    }

    es_format_Copy( &p_filter->fmt_in, p_fmt_in );
    es_format_Copy( &p_filter->fmt_out, p_fmt_out );
    p_filter->p_cfg = p_cfg;
    p_filter->b_allow_fmt_out_change = p_chain->b_allow_fmt_out_change;

    p_filter->p_module = module_need( p_filter, p_chain->psz_capability,
                                      psz_name, psz_name != NULL );

    if( !p_filter->p_module )
        goto error;

    if( p_filter->b_allow_fmt_out_change )
    {
        es_format_Clean( &p_chain->fmt_out );
        es_format_Copy( &p_chain->fmt_out, &p_filter->fmt_out );
    }

    if( AllocatorInit( &p_chain->allocator, p_chained ) )
        goto error;

    if( p_chain->last == NULL )
    {
        assert( p_chain->first == NULL );
        p_chain->first = p_chained;
    }
    else
        p_chain->last->next = p_chained;
    p_chained->prev = p_chain->last;
    p_chain->last = p_chained;
    p_chained->next = NULL;
    p_chain->length++;

    vlc_mouse_t *p_mouse = malloc( sizeof(*p_mouse) );
    if( p_mouse )
        vlc_mouse_Init( p_mouse );
    p_chained->mouse = p_mouse;
    p_chained->pending = NULL;

    msg_Dbg( p_chain->p_this, "Filter '%s' (%p) appended to chain",
             psz_name ? psz_name : module_get_name(p_filter->p_module, false),
             p_filter );

    return p_filter;

error:
    if( psz_name )
        msg_Err( p_chain->p_this, "Failed to create %s '%s'",
                 p_chain->psz_capability, psz_name );
    else
        msg_Err( p_chain->p_this, "Failed to create %s",
                 p_chain->psz_capability );
    if( p_filter->p_module )
        module_unneed( p_filter, p_filter->p_module );
    es_format_Clean( &p_filter->fmt_in );
    es_format_Clean( &p_filter->fmt_out );
    vlc_object_release( p_filter );
    return NULL;
}