⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zsh.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * zsh.cpp: create zsh completion rule for vlc ***************************************************************************** * Copyright © 2005-2008 the VideoLAN team * $Id$ * * Authors: Sigmund Augdal Helberg <dnumgis@videolan.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/#include <stdio.h>#include <map>#include <string>#include <utility>#include <iostream>#include <algorithm>typedef std::multimap<std::string, std::string> mumap;typedef std::multimap<int, std::string> mcmap;typedef std::pair<std::string, std::string> mpair;typedef std::pair<int, std::string> mcpair;#ifdef HAVE_CONFIG_H# include "config.h"#endif#include <vlc/vlc.h>/* evil hack */#undef __PLUGIN__#undef __BUILTIN__#include <../src/modules/modules.h>void ParseModules( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 );void PrintModuleList( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 );void ParseOption( module_config_t *p_item, mumap &mods, mcmap &mods2 );void PrintOption( char *psz_option, char i_short, char *psz_exlusive,                   char *psz_text, char *psz_longtext, char *psz_args );int main( int i_argc, const char **ppsz_argv ){    mumap mods;    mcmap mods2;    /* Create a libvlc structure */    int i_ret = VLC_Create();    libvlc_int_t *p_libvlc;    if( i_ret < 0 )    {        return i_ret;    }    /* Initialize libvlc */    i_ret = VLC_Init( 0, i_argc, ppsz_argv );    if( i_ret < 0 )    {        VLC_Destroy( 0 );        return i_ret;    }    p_libvlc = (libvlc_int_t*)vlc_object_get( i_ret );    printf("#compdef vlc\n\n"           "#This file is autogenerated by zsh.cpp\n"           "typeset -A opt_args\n"           "local context state line ret=1\n"           "local modules\n\n" );    PrintModuleList( p_libvlc, mods, mods2 );    printf( "_arguments -S -s \\\n" );    ParseModules( p_libvlc, mods, mods2 );    printf( "  \"(--module)-p[print help on module]:print help on module:($modules)\"\\\n" );    printf( "  \"(-p)--module[print help on module]:print help on module:($modules)\"\\\n" );    printf( "  \"(--help)-h[print help]\"\\\n" );    printf( "  \"(-h)--help[print help]\"\\\n" );    printf( "  \"(--longhelp)-H[print detailed help]\"\\\n" );    printf( "  \"(-H)--longhelp[print detailed help]\"\\\n" );    printf( "  \"(--list)-l[print a list of available modules]\"\\\n" );    printf( "  \"(-l)--list[print a list of available modules]\"\\\n" );    printf( "  \"--save-config[save the current command line options in the config file]\"\\\n" );    printf( "  \"--reset-config[reset the current config to the default values]\"\\\n" );    printf( "  \"--config[use alternate config file]\"\\\n" );    printf( "  \"--reset-plugins-cache[resets the current plugins cache]\"\\\n" );    printf( "  \"--version[print version information]\"\\\n" );    printf( "  \"*:Playlist item:->mrl\" && ret=0\n\n" );    printf( "case $state in\n" );    printf( "  mrl)\n" );    printf( "    _alternative 'files:file:_files' 'urls:URL:_urls' && ret=0\n" );    printf( "  ;;\n" );    printf( "esac\n\n" );    printf( "return ret\n" );    /* Exit early since we did not release all the objects we used,     * but we don't care, our task is over */    return 0;    /* Finish the threads */    VLC_CleanUp( 0 );    /* Destroy the libvlc structure */    VLC_Destroy( 0 );    return i_ret;}void ParseModules( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 ){    vlc_list_t      *p_list = NULL;;    module_t        *p_module;    module_config_t *p_item;    int              i_index;    int              i_items;    /* List the plugins */    p_list = vlc_list_find( p_libvlc, VLC_OBJECT_MODULE, FIND_ANYWHERE );    if( !p_list ) return;    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_module = (module_t *)p_list->p_values[i_index].p_object;        /* Exclude empty plugins (submodules don't have config options, they         * are stored in the parent module) */        if( p_module->b_submodule )              continue;//            p_item = ((module_t *)p_module->p_parent)->p_config;        else            p_item = p_module->p_config;//        printf( "  #%s\n", p_module->psz_longname );        if( !p_item ) continue;        i_items = 0;        do        {            if( p_item->i_type == CONFIG_CATEGORY )            {//                printf( "  #Category %d\n", p_item->i_value );            }            else if( p_item->i_type == CONFIG_SUBCATEGORY )            {//                printf( "  #Subcategory %d\n", p_item->i_value );            }            if( p_item->i_type & CONFIG_ITEM )                ParseOption( p_item, mods, mods2 );        }        while( i_items++ < p_module->i_config_items && p_item++ );    }}void PrintModuleList( libvlc_int_t *p_libvlc, mumap &mods, mcmap &mods2 ){    vlc_list_t      *p_list = NULL;;    module_t        *p_module;    int              i_index;    int              i_items;    /* List the plugins */    p_list = vlc_list_find( p_libvlc, VLC_OBJECT_MODULE, FIND_ANYWHERE );    if( !p_list ) return;    printf( "modules=\"" );    for( i_index = 0; i_index < p_list->i_count; i_index++ )    {        p_module = (module_t *)p_list->p_values[i_index].p_object;        /* Exclude empty plugins (submodules don't have config options, they         * are stored in the parent module) */        if( strcmp( p_module->psz_object_name, "main" ) )        {            mods.insert( mpair( p_module->psz_capability,                                p_module->psz_object_name ) );            module_config_t *p_config = p_module->p_config;            i_items = 0;            if( p_config ) do            {                /* Hack: required subcategory is stored in i_min */                if( p_config->i_type == CONFIG_SUBCATEGORY )                {                    mods2.insert( mcpair( p_config->value.i,                                          p_module->psz_object_name ) );                }            } while( i_items++ < p_module->i_config_items && p_config++ );            if( p_module->b_submodule )                continue;            printf( "%s ", p_module->psz_object_name );        }    }    printf( "\"\n\n" );    return;}void ParseOption( module_config_t *p_item, mumap &mods, mcmap &mods2 ){    char *psz_arguments = strdup( "" );    char *psz_exclusive;    char *psz_option;    char *psz_name;    char *psz_text;    char *psz_longtext;#define DUP( x ) strdup( x ? x : "" )    //Skip deprecated options    if( p_item->b_removed )        return;    switch( p_item->i_type )    {    case CONFIG_ITEM_MODULE:    {        std::pair<mumap::iterator, mumap::iterator> range = mods.equal_range( p_item->psz_type );        std::string list = (*range.first).second;        ++range.first;        while( range.first != range.second )        {            list = list.append( " " );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -