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

📄 configuration.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
                    }                }            }        }    }    /* We don't need the module list anymore */    vlc_list_release( p_list );    /* Close the longopts and shortopts structures */    memset( &p_longopts[i_index], 0, sizeof(struct option) );    psz_shortopts[i_shortopts] = '\0';    /*     * Parse the command line options     */    opterr = 0;    optind = 0; /* set to 0 to tell GNU getopt to reinitialize */    while( ( i_cmd = getopt_long( *pi_argc, ppsz_argv, psz_shortopts,                                  p_longopts, &i_index ) ) != EOF )    {        /* A long option has been recognized */        if( i_cmd == 0 )        {            module_config_t *p_conf;            char *psz_name = (char *)p_longopts[i_index].name;            /* Check if we deal with a --nofoo or --no-foo long option */            if( flag ) psz_name += psz_name[2] == '-' ? 3 : 2;            /* Store the configuration option */            p_conf = config_FindConfig( p_this, psz_name );            if( p_conf )            {                /* Check if the option is deprecated */                if( p_conf->psz_current )                {                    if( !strcmp(p_conf->psz_current,"SUPPRESSED") )                    {                        if( !b_ignore_errors )                        {                            fprintf(stderr,                                    "Warning: option --%s is no longer used.\n",                                    p_conf->psz_name);                        }                       continue;                    }                    if( !b_ignore_errors )                    {                        if( p_conf->b_strict )                        {                            fprintf( stderr,                                     "Error: option --%s is deprecated. "                                     "Use --%s instead.\n",                                     p_conf->psz_name, p_conf->psz_current);                            /*free */                            for( i_index = 0; p_longopts[i_index].name; i_index++ )                                free( (char *)p_longopts[i_index].name );                            free( p_longopts );                            free( psz_shortopts );                            return -1;                        }                        fprintf(stderr,                                "Warning: option --%s is deprecated. "                                "You should use --%s instead.\n",                                p_conf->psz_name, p_conf->psz_current);                    }                    psz_name=p_conf->psz_current;                    p_conf = config_FindConfig( p_this, psz_name );                }                switch( p_conf->i_type )                {                    case CONFIG_ITEM_STRING:                    case CONFIG_ITEM_FILE:                    case CONFIG_ITEM_DIRECTORY:                    case CONFIG_ITEM_MODULE:                    case CONFIG_ITEM_MODULE_LIST:                    case CONFIG_ITEM_MODULE_LIST_CAT:                    case CONFIG_ITEM_MODULE_CAT:                        config_PutPsz( p_this, psz_name, optarg );                        break;                    case CONFIG_ITEM_INTEGER:                        config_PutInt( p_this, psz_name, strtol(optarg, 0, 0));                        break;                    case CONFIG_ITEM_FLOAT:                        config_PutFloat( p_this, psz_name, (float)atof(optarg) );                        break;                    case CONFIG_ITEM_KEY:                        config_PutInt( p_this, psz_name, ConfigStringToKey( optarg ) );                        break;                    case CONFIG_ITEM_BOOL:                        config_PutInt( p_this, psz_name, !flag );                        break;                }                continue;            }        }        /* A short option has been recognized */        if( pp_shortopts[i_cmd] != NULL )        {            switch( pp_shortopts[i_cmd]->i_type )            {                case CONFIG_ITEM_STRING:                case CONFIG_ITEM_FILE:                case CONFIG_ITEM_DIRECTORY:                case CONFIG_ITEM_MODULE:                case CONFIG_ITEM_MODULE_CAT:                case CONFIG_ITEM_MODULE_LIST:                case CONFIG_ITEM_MODULE_LIST_CAT:                    config_PutPsz( p_this, pp_shortopts[i_cmd]->psz_name, optarg );                    break;                case CONFIG_ITEM_INTEGER:                    if( i_cmd == 'v' )                    {                        if( optarg )                        {                            if( *optarg == 'v' ) /* eg. -vvv */                            {                                i_verbose++;                                while( *optarg == 'v' )                                {                                    i_verbose++;                                    optarg++;                                }                            }                            else                            {                                i_verbose += atoi( optarg ); /* eg. -v2 */                            }                        }                        else                        {                            i_verbose++; /* -v */                        }                        config_PutInt( p_this, pp_shortopts[i_cmd]->psz_name,                                               i_verbose );                    }                    else                    {                        config_PutInt( p_this, pp_shortopts[i_cmd]->psz_name,                                               strtol(optarg, 0, 0) );                    }                    break;                case CONFIG_ITEM_BOOL:                    config_PutInt( p_this, pp_shortopts[i_cmd]->psz_name, 1 );                    break;            }            continue;        }        /* Internal error: unknown option */        if( !b_ignore_errors )        {            fprintf( stderr, "%s: unknown option"                     " or missing mandatory argument ",                     p_this->p_vlc->psz_object_name );            if( optopt )            {                fprintf( stderr, "`-%c'\n", optopt );            }            else            {                fprintf( stderr, "`%s'\n", ppsz_argv[optind-1] );            }            fprintf( stderr, "Try `%s --help' for more information.\n",                             p_this->p_vlc->psz_object_name );            for( i_index = 0; p_longopts[i_index].name; i_index++ )                free( (char *)p_longopts[i_index].name );            free( p_longopts );            free( psz_shortopts );            return -1;        }    }    /* Free allocated resources */    for( i_index = 0; p_longopts[i_index].name; i_index++ )        free( (char *)p_longopts[i_index].name );    free( p_longopts );    free( psz_shortopts );    if( b_ignore_errors ) free( ppsz_argv );    return 0;}/** * config_GetDataDir: find directory where shared data is installed * * @return a string (always succeeds). */const char *config_GetDataDir( const vlc_object_t *p_this ){#if defined (WIN32) || defined (UNDER_CE)    return p_this->p_libvlc->psz_vlcpath;#elif defined(__APPLE__) || defined (SYS_BEOS)    static char path[PATH_MAX] = "";    if( *path == '\0' )    {        snprintf( path, sizeof( path ), "%s/share",                  p_this->p_libvlc->psz_vlcpath );        path[sizeof( path ) - 1] = '\0';    }    return path;#else    return DATA_PATH;#endif}/***************************************************************************** * config_GetHomeDir, config_GetUserDir: find the user's home directory. ***************************************************************************** * This function will try by different ways to find the user's home path. * Note that this function is not reentrant, it should be called only once * at the beginning of main where the result will be stored for later use. *****************************************************************************/static char *GetDir( vlc_bool_t b_appdata ){    char *psz_localhome = NULL;#if defined(HAVE_GETPWUID)    struct passwd *p_pw = NULL;#endif#if defined(WIN32) && !defined(UNDER_CE)    typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD,                                               LPSTR );#ifndef CSIDL_FLAG_CREATE#   define CSIDL_FLAG_CREATE 0x8000#endif#ifndef CSIDL_APPDATA#   define CSIDL_APPDATA 0x1A#endif#ifndef CSIDL_PROFILE#   define CSIDL_PROFILE 0x28#endif#ifndef SHGFP_TYPE_CURRENT#   define SHGFP_TYPE_CURRENT 0#endif    HINSTANCE shfolder_dll;    SHGETFOLDERPATH SHGetFolderPath ;    /* load the shfolder dll to retrieve SHGetFolderPath */    if( ( shfolder_dll = LoadLibrary( _T("SHFolder.dll") ) ) != NULL )    {        SHGetFolderPath = (void *)GetProcAddress( shfolder_dll,                                                  _T("SHGetFolderPathA") );        if ( SHGetFolderPath != NULL )        {            char psz_ACPhome[MAX_PATH];            /* get the "Application Data" folder for the current user */            if( S_OK == SHGetFolderPath( NULL,                                         (b_appdata ? CSIDL_APPDATA :                                           CSIDL_PROFILE) | CSIDL_FLAG_CREATE,                                         NULL, SHGFP_TYPE_CURRENT,                                         psz_ACPhome ) )            {                FreeLibrary( shfolder_dll );                return FromLocaleDup( psz_ACPhome );            }        }        FreeLibrary( shfolder_dll );    }#elif defined(UNDER_CE)#ifndef CSIDL_APPDATA#   define CSIDL_APPDATA 0x1A#endif    wchar_t p_whomedir[MAX_PATH];    /* get the "Application Data" folder for the current user */    if( SHGetSpecialFolderPath( NULL, p_whomedir, CSIDL_APPDATA, 1 ) )    {        char psz_ACPhome[2 * MAX_PATH];        sprintf( psz_ACPhome, "%ls", p_whomedir );        return FromLocaleDup( psz_ACPhome );    }#endif#if defined(HAVE_GETPWUID)    if( ( p_pw = getpwuid( getuid() ) ) == NULL )#endif    {        psz_localhome = getenv( "HOME" );        if( psz_localhome == NULL )        {            psz_localhome = getenv( "TMP" );            if( psz_localhome == NULL )                psz_localhome = "/tmp";        }    }#if defined(HAVE_GETPWUID)    else        psz_localhome = p_pw->pw_dir;#endif    return FromLocaleDup( psz_localhome );}char *config_GetHomeDir( void ){    return GetDir( VLC_TRUE );}char *config_GetUserDir( void ){    return GetDir( VLC_FALSE );}static int ConfigStringToKey( char *psz_key ){    int i_key = 0;    unsigned int i;    char *psz_parser = strchr( psz_key, '-' );    while( psz_parser && psz_parser != psz_key )    {        for( i = 0; i < sizeof(vlc_modifiers) / sizeof(key_descriptor_t); i++ )        {            if( !strncasecmp( vlc_modifiers[i].psz_key_string, psz_key,                              strlen( vlc_modifiers[i].psz_key_string ) ) )            {                i_key |= vlc_modifiers[i].i_key_code;            }        }        psz_key = psz_parser + 1;        psz_parser = strchr( psz_key, '-' );    }    for( i = 0; i < sizeof(vlc_keys) / sizeof( key_descriptor_t ); i++ )    {        if( !strcasecmp( vlc_keys[i].psz_key_string, psz_key ) )        {            i_key |= vlc_keys[i].i_key_code;            break;        }    }    return i_key;}static char *ConfigKeyToString( int i_key ){    char *psz_key = malloc( 100 );    char *p;    size_t index;    if ( !psz_key )    {        return NULL;    }    *psz_key = '\0';    p = psz_key;    for( index = 0; index < (sizeof(vlc_modifiers) / sizeof(key_descriptor_t));         index++ )    {        if( i_key & vlc_modifiers[index].i_key_code )        {            p += sprintf( p, "%s-", vlc_modifiers[index].psz_key_string );        }    }    for( index = 0; index < (sizeof(vlc_keys) / sizeof( key_descriptor_t));         index++)    {        if( (int)( i_key & ~KEY_MODIFIER ) == vlc_keys[index].i_key_code )        {            p += sprintf( p, "%s", vlc_keys[index].psz_key_string );            break;        }    }    return psz_key;}

⌨️ 快捷键说明

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