Changeset 64ea683969472b60ebc2b4e15e552f7bf23d017a

Show
Ignore:
Timestamp:
12/16/07 18:36:01 (9 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1197826561 +0000
git-parent:

[f9a54b04067d9433020a8731c3d2090fb36baedb]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1197826561 +0000
Message:

short and list support for vlc_config_set

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_configuration.h

    r0babda7 r64ea683  
    166166 
    167167    /* Values list */ 
    168     const char **ppsz_list;       /* List of possible values for the option */ 
     168    char **      ppsz_list;       /* List of possible values for the option */ 
    169169    int         *pi_list;                              /* Idem for integers */ 
    170     const char **ppsz_list_text;          /* Friendly names for list values */ 
     170    char      **ppsz_list_text;          /* Friendly names for list values */ 
    171171    int          i_list;                               /* Options list size */ 
    172172 
    173173    /* Actions list */ 
    174174    vlc_callback_t *ppf_action;    /* List of possible actions for a config */ 
    175     const char    **ppsz_action_text;         /* Friendly names for actions */ 
     175    char          **ppsz_action_text;         /* Friendly names for actions */ 
    176176    int            i_action;                           /* actions list size */ 
    177177 
     
    269269    VLC_CONFIG_CAPABILITY, 
    270270    /* capability for a module or list thereof (args=const char*) */ 
     271 
     272    VLC_CONFIG_SHORTCUT, 
     273    /* one-character (short) command line option name (args=char) */ 
     274 
     275    VLC_CONFIG_LIST, 
     276    /* possible values list 
     277     * (args=size_t, const <type> *, const char *const *) */ 
    271278}; 
    272279 
     
    431438/* Modifier macros for the config options (used for fine tuning) */ 
    432439#define change_short( ch ) \ 
    433     p_config[i_config].i_short = ch; 
     440    vlc_config_set (p_config + i_config, VLC_CONFIG_SHORTCUT, (int)(ch)) 
    434441 
    435442#define change_string_list( list, list_text, list_update_func ) \ 
    436     p_config[i_config].i_list = sizeof(list)/sizeof(char *); \ 
    437     p_config[i_config].ppsz_list = list; \ 
    438     p_config[i_config].ppsz_list_text = list_text; 
     443    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ 
     444                    (size_t)(sizeof (list) / sizeof (char *)), \ 
     445                    (const char *const *)(list), \ 
     446                    (const char *const *)(list_text)) 
    439447 
    440448#define change_integer_list( list, list_text, list_update_func ) \ 
    441     p_config[i_config].i_list = sizeof(list)/sizeof(int); \ 
    442     p_config[i_config].pi_list = (int *)list; \ 
    443     p_config[i_config].ppsz_list_text = list_text; 
     449    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ 
     450                    (size_t)(sizeof (list) / sizeof (int)), \ 
     451                    (const int *)(list), \ 
     452                    (const char *const *)(list_text)) 
     453 
     454#define change_float_list( list, list_text, list_update_func ) \ 
     455    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ 
     456                    (size_t)(sizeof (list) / sizeof (float)), \ 
     457                    (const float *)(list), \ 
     458                    (const char *const *)(list_text)) 
    444459 
    445460#define change_integer_range( minv, maxv ) \ 
  • src/config/core.c

    reda425f r64ea683  
    523523        p_module->p_config[i].p_lock = &p_module->object_lock; 
    524524 
    525         /* duplicate the string list */ 
    526         if( p_orig[i].i_list ) 
    527         { 
    528             if( p_orig[i].ppsz_list ) 
    529             { 
    530                 p_module->p_config[i].ppsz_list = 
    531                     malloc( (p_orig[i].i_list + 1) * sizeof(char *) ); 
    532                 if( p_module->p_config[i].ppsz_list ) 
    533                 { 
    534                     for( j = 0; j < p_orig[i].i_list; j++ ) 
    535                         p_module->p_config[i].ppsz_list[j] = 
    536                                 strdupnull (p_orig[i].ppsz_list[j]); 
    537                     p_module->p_config[i].ppsz_list[j] = NULL; 
    538                 } 
    539             } 
    540             if( p_orig[i].ppsz_list_text ) 
    541             { 
    542                 p_module->p_config[i].ppsz_list_text = 
    543                     calloc( (p_orig[i].i_list + 1), sizeof(char *) ); 
    544                 if( p_module->p_config[i].ppsz_list_text ) 
    545                 { 
    546                     for( j = 0; j < p_orig[i].i_list; j++ ) 
    547                         p_module->p_config[i].ppsz_list_text[j] = 
    548                                 strdupnull (_(p_orig[i].ppsz_list_text[j])); 
    549                     p_module->p_config[i].ppsz_list_text[j] = NULL; 
    550                 } 
    551             } 
    552             if( p_orig[i].pi_list ) 
    553             { 
    554                 p_module->p_config[i].pi_list = 
    555                     malloc( (p_orig[i].i_list + 1) * sizeof(int) ); 
    556                 if( p_module->p_config[i].pi_list ) 
    557                 { 
    558                     for( j = 0; j < p_orig[i].i_list; j++ ) 
    559                         p_module->p_config[i].pi_list[j] = 
    560                             p_orig[i].pi_list[j]; 
    561                 } 
    562             } 
    563         } 
    564  
    565525        /* duplicate the actions list */ 
    566526        if( p_orig[i].i_action ) 
  • src/modules/entry.c

    r0babda7 r64ea683  
    159159 
    160160    memset (tab + confsize, 0, sizeof (tab[confsize])); 
     161    tab[confsize].i_type = type; 
     162    tab[confsize].p_lock = &module->object_lock; 
     163 
    161164    return tab + confsize; 
    162165} 
     
    277280            break; 
    278281        } 
     282 
     283        case VLC_CONFIG_SHORTCUT: 
     284            item->i_short = va_arg (ap, int); 
     285            ret = 0; 
     286            break; 
     287 
     288        case VLC_CONFIG_LIST: 
     289        { 
     290            size_t len = va_arg (ap, size_t); 
     291            char **dtext = malloc (sizeof (char *) * (len + 1)); 
     292 
     293            if (dtext == NULL) 
     294                break; 
     295 
     296            /* Copy values */ 
     297            if (IsConfigIntegerType (item->i_type)) 
     298            { 
     299                const int *src = va_arg (ap, const int *); 
     300                int *dst = malloc (sizeof (int) * (len + 1)); 
     301 
     302                if (dst != NULL) 
     303                { 
     304                    memcpy (dst, src, sizeof (int) * len); 
     305                    dst[len] = 0; 
     306                } 
     307                item->pi_list = dst; 
     308            } 
     309            else 
     310#if 0 
     311            if (IsConfigFloatType (item->i_type)) 
     312            { 
     313                const float *src = va_arg (ap, const float *); 
     314                float *dst = malloc (sizeof (float) * (len + 1)); 
     315 
     316                if (dst != NULL) 
     317                { 
     318                    memcpy (dst, src, sizeof (float) * len); 
     319                    dst[len] = 0.; 
     320                } 
     321                item->pf_list = dst; 
     322            } 
     323            else 
     324#endif 
     325            if (IsConfigStringType (item->i_type)) 
     326            { 
     327                const char *const *src = va_arg (ap, const char *const *); 
     328                char **dst = malloc (sizeof (char *) * (len + 1)); 
     329 
     330                if (dst != NULL) 
     331                { 
     332                    for (size_t i = 0; i < len; i++) 
     333                        dst[i] = src[i] ? strdup (src[i]) : NULL; 
     334                    dst[len] = NULL; 
     335                } 
     336                item->ppsz_list = dst; 
     337            } 
     338            else 
     339                break; 
     340 
     341            /* Copy textual descriptions */ 
     342            const char *const *text = va_arg (ap, const char *const *); 
     343            if (text != NULL) 
     344            { 
     345                for (size_t i = 0; i < len; i++) 
     346                    dtext[i] = text[i] ? strdup (gettext (text[i])) : NULL; 
     347 
     348                dtext[len] = NULL; 
     349                item->ppsz_list_text = dtext; 
     350            } 
     351            else 
     352                item->ppsz_list_text = NULL; 
     353 
     354            item->i_list = len; 
     355            ret = 0; 
     356            break; 
     357        } 
    279358    } 
    280359