Changeset 3655c1c6edfa65212b263fa330e0bf4809eeb5d1
- Timestamp:
- 17/12/07 20:36:58
(10 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1197920218 +0000
- git-parent:
[2bca4f1c7e98f40ff31e9b0474ec2a2b60d59379]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1197920218 +0000
- Message:
Add support for aliases through vlc_config_set
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2bca4f1 |
r3655c1c |
|
| 185 | 185 | |
|---|
| 186 | 186 | /* Deprecated */ |
|---|
| 187 | | const char *psz_current; /* Good option name */ |
|---|
| 188 | | vlc_bool_t b_strict; /* Transitionnal or strict */ |
|---|
| | 187 | char *psz_oldname; /* Old option name */ |
|---|
| | 188 | vlc_bool_t b_removed; |
|---|
| 189 | 189 | |
|---|
| 190 | 190 | /* Option values loaded from config file */ |
|---|
| … | … | |
| 279 | 279 | VLC_CONFIG_ADD_ACTION, |
|---|
| 280 | 280 | /* add value change callback (args=vlc_callback_t, const char *) */ |
|---|
| | 281 | |
|---|
| | 282 | VLC_CONFIG_OLDNAME, |
|---|
| | 283 | /* former option name (args=const char *) */ |
|---|
| 281 | 284 | }; |
|---|
| 282 | 285 | |
|---|
| … | … | |
| 409 | 412 | if (v) vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)VLC_TRUE) |
|---|
| 410 | 413 | |
|---|
| 411 | | /* For renamed option */ |
|---|
| 412 | | #define add_deprecated_alias( name ) \ |
|---|
| 413 | | add_config_inner( ); \ |
|---|
| 414 | | p_config[ i_config ].i_type = p_config[ i_config -1 ].i_type; \ |
|---|
| 415 | | vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \ |
|---|
| 416 | | (const char *)(name), (vlc_callback_t)NULL); \ |
|---|
| 417 | | p_config[i_config].b_strict = VLC_FALSE; \ |
|---|
| 418 | | p_config[ i_config ].psz_current = p_config[ i_config-1 ].psz_current \ |
|---|
| 419 | | ? p_config[ i_config-1 ].psz_current \ |
|---|
| 420 | | : p_config[ i_config-1 ].psz_name; |
|---|
| 421 | | |
|---|
| 422 | 414 | /* For removed option */ |
|---|
| 423 | 415 | #define add_obsolete_inner( name, type ) \ |
|---|
| … | … | |
| 440 | 432 | |
|---|
| 441 | 433 | /* Modifier macros for the config options (used for fine tuning) */ |
|---|
| | 434 | |
|---|
| | 435 | #define add_deprecated_alias( name ) \ |
|---|
| | 436 | vlc_config_set (p_config + i_config, VLC_CONFIG_OLDNAME, \ |
|---|
| | 437 | (const char *)(name)) |
|---|
| | 438 | |
|---|
| 442 | 439 | #define change_short( ch ) \ |
|---|
| 443 | 440 | vlc_config_set (p_config + i_config, VLC_CONFIG_SHORTCUT, (int)(ch)) |
|---|
| r2d9c9ee |
r3655c1c |
|
| 297 | 297 | /* This is basically cut and paste from src/misc/configuration.c |
|---|
| 298 | 298 | * with slight changes */ |
|---|
| 299 | | if( p_conf && p_conf->psz_current ) |
|---|
| 300 | | { |
|---|
| 301 | | if( p_conf->b_strict ) |
|---|
| | 299 | if( p_conf ) |
|---|
| | 300 | { |
|---|
| | 301 | if( p_conf->b_removed ) |
|---|
| 302 | 302 | { |
|---|
| 303 | 303 | msg_Err( p_this, "Option %s is not supported anymore.", |
|---|
| 304 | | p_conf->psz_name ); |
|---|
| | 304 | name ); |
|---|
| 305 | 305 | /* TODO: this should return an error and end option parsing |
|---|
| 306 | 306 | * ... but doing this would change the VLC API and all the |
|---|
| … | … | |
| 308 | 308 | continue; |
|---|
| 309 | 309 | } |
|---|
| 310 | | msg_Warn( p_this, "Option %s is obsolete. Use %s instead.", |
|---|
| 311 | | p_conf->psz_name, p_conf->psz_current ); |
|---|
| 312 | | psz_name = p_conf->psz_current; |
|---|
| | 310 | if( p_conf->psz_oldname |
|---|
| | 311 | && !strcmp( p_conf->psz_oldname, name ) ) |
|---|
| | 312 | { |
|---|
| | 313 | psz_name = p_conf->psz_name; |
|---|
| | 314 | msg_Warn( p_this, "Option %s is obsolete. Use %s instead.", |
|---|
| | 315 | name, psz_name ); |
|---|
| | 316 | } |
|---|
| 313 | 317 | } |
|---|
| 314 | 318 | /* </Check if the option is deprecated> */ |
|---|
| r2d9c9ee |
r3655c1c |
|
| 279 | 279 | { |
|---|
| 280 | 280 | /* Check if the option is deprecated */ |
|---|
| 281 | | if( p_conf->psz_current ) |
|---|
| | 281 | if( p_conf->b_removed ) |
|---|
| 282 | 282 | { |
|---|
| 283 | | if( p_conf->b_strict ) |
|---|
| 284 | | { |
|---|
| 285 | | fprintf(stderr, |
|---|
| 286 | | "Warning: option --%s no longer exists.\n", |
|---|
| 287 | | p_conf->psz_name); |
|---|
| 288 | | continue; |
|---|
| 289 | | } |
|---|
| 290 | | |
|---|
| | 283 | fprintf(stderr, |
|---|
| | 284 | "Warning: option --%s no longer exists.\n", |
|---|
| | 285 | psz_name); |
|---|
| | 286 | continue; |
|---|
| | 287 | } |
|---|
| | 288 | |
|---|
| | 289 | if( p_conf->psz_oldname |
|---|
| | 290 | && !strcmp( p_conf->psz_oldname, psz_name) ) |
|---|
| | 291 | { |
|---|
| 291 | 292 | fprintf( stderr, |
|---|
| 292 | 293 | "%s: option --%s is deprecated. Use --%s instead.\n", |
|---|
| 293 | 294 | b_ignore_errors ? "Warning" : "Error", |
|---|
| 294 | | p_conf->psz_name, p_conf->psz_current); |
|---|
| | 295 | psz_name, p_conf->psz_name ); |
|---|
| 295 | 296 | if( !b_ignore_errors ) |
|---|
| 296 | 297 | { |
|---|
| … | … | |
| 304 | 305 | } |
|---|
| 305 | 306 | |
|---|
| 306 | | psz_name = (char *)p_conf->psz_current; |
|---|
| 307 | | p_conf = config_FindConfig( p_this, psz_name ); |
|---|
| | 307 | psz_name = p_conf->psz_name; |
|---|
| 308 | 308 | } |
|---|
| 309 | 309 | |
|---|
| r2bca4f1 |
r3655c1c |
|
| 465 | 465 | /* ignore hints */ |
|---|
| 466 | 466 | continue; |
|---|
| 467 | | if( !strcmp( psz_name, p_item->psz_name ) ) |
|---|
| | 467 | if( !strcmp( psz_name, p_item->psz_name ) |
|---|
| | 468 | || ( p_item->psz_oldname |
|---|
| | 469 | && !strcmp( psz_name, p_item->psz_oldname ) ) ) |
|---|
| 468 | 470 | { |
|---|
| 469 | 471 | vlc_list_release( p_list ); |
|---|
| r944a991 |
r3655c1c |
|
| 544 | 544 | |
|---|
| 545 | 545 | if ((p_item->i_type & CONFIG_HINT) /* ignore hint */ |
|---|
| 546 | | || p_item->psz_current /* ignore deprecated option */ |
|---|
| | 546 | || p_item->b_removed /* ignore deprecated option */ |
|---|
| 547 | 547 | || p_item->b_unsaveable) /* ignore volatile option */ |
|---|
| 548 | 548 | continue; |
|---|
| r6837daf |
r3655c1c |
|
| 1456 | 1456 | size_t i_cur_width; |
|---|
| 1457 | 1457 | |
|---|
| 1458 | | /* Skip deprecated options */ |
|---|
| 1459 | | if( p_item->psz_current ) |
|---|
| | 1458 | /* Skip removed options */ |
|---|
| | 1459 | if( p_item->b_removed ) |
|---|
| 1460 | 1460 | { |
|---|
| 1461 | 1461 | continue; |
|---|
| r7eba900 |
r3655c1c |
|
| 353 | 353 | LOAD_STRING( p_module->p_config[i].psz_text ); |
|---|
| 354 | 354 | LOAD_STRING( p_module->p_config[i].psz_longtext ); |
|---|
| 355 | | LOAD_STRING( p_module->p_config[i].psz_current ); |
|---|
| | 355 | LOAD_STRING( p_module->p_config[i].psz_oldname ); |
|---|
| | 356 | LOAD_IMMEDIATE( p_module->p_config[i].b_removed ); |
|---|
| 356 | 357 | |
|---|
| 357 | 358 | if (IsConfigStringType (p_module->p_config[i].i_type)) |
|---|
| … | … | |
| 618 | 619 | SAVE_STRING( p_module->p_config[i].psz_text ); |
|---|
| 619 | 620 | SAVE_STRING( p_module->p_config[i].psz_longtext ); |
|---|
| 620 | | SAVE_STRING( p_module->p_config[i].psz_current ); |
|---|
| | 621 | SAVE_STRING( p_module->p_config[i].psz_oldname ); |
|---|
| | 622 | SAVE_IMMEDIATE( p_module->p_config[i].b_removed ); |
|---|
| | 623 | |
|---|
| 621 | 624 | if (IsConfigStringType (p_module->p_config[i].i_type)) |
|---|
| 622 | 625 | SAVE_STRING( p_module->p_config[i].orig.psz ); |
|---|
| r2bca4f1 |
r3655c1c |
|
| 269 | 269 | |
|---|
| 270 | 270 | case VLC_CONFIG_REMOVED: |
|---|
| 271 | | item->psz_current = "SUPPRESSED"; |
|---|
| | 271 | item->b_removed = VLC_TRUE; |
|---|
| 272 | 272 | ret = 0; |
|---|
| 273 | 273 | break; |
|---|
| … | … | |
| 385 | 385 | item->i_action++; |
|---|
| 386 | 386 | ret = 0; |
|---|
| | 387 | break; |
|---|
| | 388 | } |
|---|
| | 389 | |
|---|
| | 390 | case VLC_CONFIG_OLDNAME: |
|---|
| | 391 | { |
|---|
| | 392 | const char *oldname = va_arg (ap, const char *); |
|---|
| | 393 | item->psz_oldname = oldname ? strdup (oldname) : NULL; |
|---|
| | 394 | ret = 0; |
|---|
| | 395 | break; |
|---|
| 387 | 396 | } |
|---|
| 388 | 397 | } |
|---|
| r773c6cd |
r3655c1c |
|
| 805 | 805 | if (item->b_internal /* internal option */ |
|---|
| 806 | 806 | || item->b_unsaveable /* non-modifiable option */ |
|---|
| 807 | | || item->psz_current /* deprecated option name */) |
|---|
| | 807 | || item->b_removed /* removed option */) |
|---|
| 808 | 808 | continue; |
|---|
| 809 | 809 | |
|---|