Changeset 3ca1fe82ca224cd14ec194ad83f6a424dd1a8500
- Timestamp:
- 17/12/07 21:53:25
(10 months ago)
- Author:
- Rémi Denis-Courmont <rem@videolan.org>
- git-committer:
- Rémi Denis-Courmont <rem@videolan.org> 1197924805 +0000
- git-parent:
[927f27d8c6feedb36da0b1e442bb897e2be6f90e]
- git-author:
- Rémi Denis-Courmont <rem@videolan.org> 1197924805 +0000
- Message:
Use vlc_config_create()
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3655c1c |
r3ca1fe8 |
|
| 212 | 212 | VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) ); |
|---|
| 213 | 213 | |
|---|
| 214 | | VLC_EXPORT( int, config_Duplicate,( module_t *, const module_config_t *, size_t )); |
|---|
| 215 | | |
|---|
| 216 | 214 | VLC_EXPORT(const char *, config_GetDataDir, ( void )); |
|---|
| 217 | 215 | |
|---|
| … | … | |
| 301 | 299 | *****************************************************************************/ |
|---|
| 302 | 300 | |
|---|
| 303 | | #define add_config_inner( ) \ |
|---|
| 304 | | i_config++; \ |
|---|
| 305 | | if( (i_config % 10) == 0 ) \ |
|---|
| 306 | | p_config = (module_config_t *) \ |
|---|
| 307 | | realloc(p_config, (i_config+11) * sizeof(module_config_t)); \ |
|---|
| 308 | | memset( p_config + i_config, 0, sizeof( *p_config ) ) |
|---|
| 309 | | |
|---|
| 310 | 301 | #define add_type_inner( type ) \ |
|---|
| 311 | | add_config_inner( ); \ |
|---|
| 312 | | p_config[i_config].i_type = type |
|---|
| | 302 | p_config = vlc_config_create (p_module, type) |
|---|
| 313 | 303 | |
|---|
| 314 | 304 | #define add_typedesc_inner( type, text, longtext ) \ |
|---|
| 315 | 305 | add_type_inner( type ); \ |
|---|
| 316 | | vlc_config_set (p_config + i_config, VLC_CONFIG_DESC, \ |
|---|
| | 306 | vlc_config_set (p_config, VLC_CONFIG_DESC, \ |
|---|
| 317 | 307 | (const char *)(text), (const char *)(longtext)) |
|---|
| 318 | 308 | |
|---|
| 319 | 309 | #define add_typeadv_inner( type, text, longtext, advc ) \ |
|---|
| 320 | 310 | add_typedesc_inner( type, text, longtext ); \ |
|---|
| 321 | | if (advc) vlc_config_set (p_config + i_config, VLC_CONFIG_ADVANCED) |
|---|
| | 311 | if (advc) vlc_config_set (p_config, VLC_CONFIG_ADVANCED) |
|---|
| 322 | 312 | |
|---|
| 323 | 313 | #define add_typename_inner( type, name, text, longtext, advc, cb ) \ |
|---|
| 324 | 314 | add_typeadv_inner( type, text, longtext, advc ); \ |
|---|
| 325 | | vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \ |
|---|
| | 315 | vlc_config_set (p_config, VLC_CONFIG_NAME, \ |
|---|
| 326 | 316 | (const char *)(name), (vlc_callback_t)(cb)) |
|---|
| 327 | 317 | |
|---|
| 328 | 318 | #define add_string_inner( type, name, text, longtext, advc, cb, v ) \ |
|---|
| 329 | 319 | add_typename_inner( type, name, text, longtext, advc, cb ); \ |
|---|
| 330 | | vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (const char *)(v)) |
|---|
| | 320 | vlc_config_set (p_config, VLC_CONFIG_VALUE, (const char *)(v)) |
|---|
| 331 | 321 | |
|---|
| 332 | 322 | #define add_int_inner( type, name, text, longtext, advc, cb, v ) \ |
|---|
| 333 | 323 | add_typename_inner( type, name, text, longtext, advc, cb ); \ |
|---|
| 334 | | vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)(v)) |
|---|
| | 324 | vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)(v)) |
|---|
| 335 | 325 | |
|---|
| 336 | 326 | |
|---|
| 337 | 327 | #define set_category( i_id ) \ |
|---|
| 338 | 328 | add_type_inner( CONFIG_CATEGORY ); \ |
|---|
| 339 | | p_config[i_config].value.i = i_id |
|---|
| | 329 | p_config->value.i = i_id |
|---|
| 340 | 330 | |
|---|
| 341 | 331 | #define set_subcategory( i_id ) \ |
|---|
| 342 | 332 | add_type_inner( CONFIG_SUBCATEGORY ); \ |
|---|
| 343 | | p_config[i_config].value.i = i_id |
|---|
| | 333 | p_config->value.i = i_id |
|---|
| 344 | 334 | |
|---|
| 345 | 335 | #define set_section( text, longtext ) \ |
|---|
| … | … | |
| 372 | 362 | #define add_module( name, psz_caps, value, p_callback, text, longtext, advc ) \ |
|---|
| 373 | 363 | add_string_inner( CONFIG_ITEM_MODULE, name, text, longtext, advc, p_callback, value ); \ |
|---|
| 374 | | vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \ |
|---|
| 375 | | (const char *)(psz_caps)) |
|---|
| | 364 | vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps)) |
|---|
| 376 | 365 | |
|---|
| 377 | 366 | #define add_module_list( name, psz_caps, value, p_callback, text, longtext, advc ) \ |
|---|
| 378 | 367 | add_string_inner( CONFIG_ITEM_MODULE_LIST, name, text, longtext, advc, p_callback, value ); \ |
|---|
| 379 | | vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \ |
|---|
| 380 | | (const char *)(psz_caps)) |
|---|
| | 368 | vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps)) |
|---|
| 381 | 369 | |
|---|
| 382 | 370 | #ifndef __PLUGIN__ |
|---|
| 383 | 371 | #define add_module_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \ |
|---|
| 384 | 372 | add_string_inner( CONFIG_ITEM_MODULE_CAT, name, text, longtext, advc, p_callback, value ); \ |
|---|
| 385 | | p_config[i_config].min.i = i_subcategory /* gruik */ |
|---|
| | 373 | p_config->min.i = i_subcategory /* gruik */ |
|---|
| 386 | 374 | |
|---|
| 387 | 375 | #define add_module_list_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \ |
|---|
| 388 | 376 | add_string_inner( CONFIG_ITEM_MODULE_LIST_CAT, name, text, longtext, advc, p_callback, value ); \ |
|---|
| 389 | | p_config[i_config].min.i = i_subcategory /* gruik */ |
|---|
| | 377 | p_config->min.i = i_subcategory /* gruik */ |
|---|
| 390 | 378 | #endif |
|---|
| 391 | 379 | |
|---|
| … | … | |
| 402 | 390 | #define add_float( name, v, p_callback, text, longtext, advc ) \ |
|---|
| 403 | 391 | add_typename_inner( CONFIG_ITEM_FLOAT, name, text, longtext, advc, p_callback ); \ |
|---|
| 404 | | vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (double)(v)) |
|---|
| | 392 | vlc_config_set (p_config, VLC_CONFIG_VALUE, (double)(v)) |
|---|
| 405 | 393 | |
|---|
| 406 | 394 | #define add_float_with_range( name, value, f_min, f_max, p_callback, text, longtext, advc ) \ |
|---|
| … | … | |
| 410 | 398 | #define add_bool( name, v, p_callback, text, longtext, advc ) \ |
|---|
| 411 | 399 | add_typename_inner( CONFIG_ITEM_BOOL, name, text, longtext, advc, p_callback ); \ |
|---|
| 412 | | if (v) vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)VLC_TRUE) |
|---|
| | 400 | if (v) vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)VLC_TRUE) |
|---|
| 413 | 401 | |
|---|
| 414 | 402 | /* For removed option */ |
|---|
| 415 | 403 | #define add_obsolete_inner( name, type ) \ |
|---|
| 416 | 404 | add_type_inner( type ); \ |
|---|
| 417 | | vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \ |
|---|
| | 405 | vlc_config_set (p_config, VLC_CONFIG_NAME, \ |
|---|
| 418 | 406 | (const char *)(name), (vlc_callback_t)NULL); \ |
|---|
| 419 | | vlc_config_set (p_config + i_config, VLC_CONFIG_REMOVED) |
|---|
| | 407 | vlc_config_set (p_config, VLC_CONFIG_REMOVED) |
|---|
| 420 | 408 | |
|---|
| 421 | 409 | #define add_obsolete_bool( name ) \ |
|---|
| … | … | |
| 434 | 422 | |
|---|
| 435 | 423 | #define add_deprecated_alias( name ) \ |
|---|
| 436 | | vlc_config_set (p_config + i_config, VLC_CONFIG_OLDNAME, \ |
|---|
| 437 | | (const char *)(name)) |
|---|
| | 424 | vlc_config_set (p_config, VLC_CONFIG_OLDNAME, (const char *)(name)) |
|---|
| 438 | 425 | |
|---|
| 439 | 426 | #define change_short( ch ) \ |
|---|
| 440 | | vlc_config_set (p_config + i_config, VLC_CONFIG_SHORTCUT, (int)(ch)) |
|---|
| | 427 | vlc_config_set (p_config, VLC_CONFIG_SHORTCUT, (int)(ch)) |
|---|
| 441 | 428 | |
|---|
| 442 | 429 | #define change_string_list( list, list_text, list_update_func ) \ |
|---|
| 443 | | vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ |
|---|
| | 430 | vlc_config_set (p_config, VLC_CONFIG_LIST, \ |
|---|
| 444 | 431 | (size_t)(sizeof (list) / sizeof (char *)), \ |
|---|
| 445 | 432 | (const char *const *)(list), \ |
|---|
| … | … | |
| 447 | 434 | |
|---|
| 448 | 435 | #define change_integer_list( list, list_text, list_update_func ) \ |
|---|
| 449 | | vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ |
|---|
| | 436 | vlc_config_set (p_config, VLC_CONFIG_LIST, \ |
|---|
| 450 | 437 | (size_t)(sizeof (list) / sizeof (int)), \ |
|---|
| 451 | 438 | (const int *)(list), \ |
|---|
| … | … | |
| 453 | 440 | |
|---|
| 454 | 441 | #define change_float_list( list, list_text, list_update_func ) \ |
|---|
| 455 | | vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \ |
|---|
| | 442 | vlc_config_set (p_config, VLC_CONFIG_LIST, \ |
|---|
| 456 | 443 | (size_t)(sizeof (list) / sizeof (float)), \ |
|---|
| 457 | 444 | (const float *)(list), \ |
|---|
| … | … | |
| 459 | 446 | |
|---|
| 460 | 447 | #define change_integer_range( minv, maxv ) \ |
|---|
| 461 | | vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \ |
|---|
| 462 | | (int)(minv), (int)(maxv)) |
|---|
| | 448 | vlc_config_set (p_config, VLC_CONFIG_RANGE, (int)(minv), (int)(maxv)) |
|---|
| 463 | 449 | |
|---|
| 464 | 450 | #define change_float_range( minv, maxv ) \ |
|---|
| 465 | | vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \ |
|---|
| | 451 | vlc_config_set (p_config, VLC_CONFIG_RANGE, \ |
|---|
| 466 | 452 | (double)(minv), (double)(maxv)) |
|---|
| 467 | 453 | |
|---|
| 468 | 454 | #define change_action_add( pf_action, text ) \ |
|---|
| 469 | | vlc_config_set (p_config + i_config, VLC_CONFIG_ADD_ACTION, \ |
|---|
| | 455 | vlc_config_set (p_config, VLC_CONFIG_ADD_ACTION, \ |
|---|
| 470 | 456 | (vlc_callback_t)(pf_action), (const char *)(text)) |
|---|
| 471 | 457 | |
|---|
| 472 | 458 | #define change_internal() \ |
|---|
| 473 | | vlc_config_set (p_config + i_config, VLC_CONFIG_PRIVATE) |
|---|
| | 459 | vlc_config_set (p_config, VLC_CONFIG_PRIVATE) |
|---|
| 474 | 460 | |
|---|
| 475 | 461 | #define change_need_restart() \ |
|---|
| 476 | | vlc_config_set (p_config + i_config, VLC_CONFIG_RESTART) |
|---|
| | 462 | vlc_config_set (p_config, VLC_CONFIG_RESTART) |
|---|
| 477 | 463 | |
|---|
| 478 | 464 | #define change_autosave() \ |
|---|
| 479 | | vlc_config_set (p_config + i_config, VLC_CONFIG_PERSISTENT) |
|---|
| | 465 | vlc_config_set (p_config, VLC_CONFIG_PERSISTENT) |
|---|
| 480 | 466 | |
|---|
| 481 | 467 | #define change_unsaveable() \ |
|---|
| 482 | | vlc_config_set (p_config + i_config, VLC_CONFIG_VOLATILE) |
|---|
| | 468 | vlc_config_set (p_config, VLC_CONFIG_VOLATILE) |
|---|
| 483 | 469 | |
|---|
| 484 | 470 | /**************************************************************************** |
|---|
| r927f27d |
r3ca1fe8 |
|
| 112 | 112 | { \ |
|---|
| 113 | 113 | int res; \ |
|---|
| 114 | | size_t i_config = (size_t)(-1); \ |
|---|
| 115 | 114 | module_config_t *p_config = NULL; \ |
|---|
| 116 | 115 | if (vlc_module_set (p_module, VLC_MODULE_NAME, \ |
|---|
| … | … | |
| 122 | 121 | #define vlc_module_end( ) \ |
|---|
| 123 | 122 | } \ |
|---|
| 124 | | return config_Duplicate( p_module, p_config, ++i_config ); \ |
|---|
| | 123 | return VLC_SUCCESS; \ |
|---|
| 125 | 124 | \ |
|---|
| 126 | 125 | error: \ |
|---|
| 127 | | /* FIXME: config_Free( p_config ); */ \ |
|---|
| | 126 | /* FIXME: config_Free( p_module ); */ \ |
|---|
| 128 | 127 | /* FIXME: cleanup submodules objects ??? */ \ |
|---|
| 129 | 128 | return VLC_EGENERIC; \ |
|---|
| r850b333 |
r3ca1fe8 |
|
| 34 | 34 | int config_CreateDir( vlc_object_t *, const char * ); |
|---|
| 35 | 35 | int config_AutoSaveConfigFile( vlc_object_t * ); |
|---|
| | 36 | |
|---|
| | 37 | /* TODO: remove this, only used for helper module */ |
|---|
| | 38 | int config_Duplicate( module_t *, module_config_t *, size_t ); |
|---|
| 36 | 39 | |
|---|
| 37 | 40 | void config_Free( module_t * ); |
|---|
| r927f27d |
r3ca1fe8 |
|
| 487 | 487 | * This is why we need to create an exact copy of the config data. |
|---|
| 488 | 488 | *****************************************************************************/ |
|---|
| 489 | | int config_Duplicate( module_t *p_module, const module_config_t *p_orig, |
|---|
| | 489 | int config_Duplicate( module_t *p_module, module_config_t *p_orig, |
|---|
| 490 | 490 | size_t n ) |
|---|
| 491 | 491 | { |
|---|
| ra3576a2 |
r3ca1fe8 |
|
| 47 | 47 | config_ChainDestroy |
|---|
| 48 | 48 | __config_ChainParse |
|---|
| 49 | | config_Duplicate |
|---|
| 50 | 49 | config_FindConfig |
|---|
| 51 | 50 | config_GetDataDir |
|---|
| r927f27d |
r3ca1fe8 |
|
| 158 | 158 | module->p_config = tab; |
|---|
| 159 | 159 | } |
|---|
| 160 | | module->confsize++; |
|---|
| 161 | 160 | |
|---|
| 162 | 161 | memset (tab + confsize, 0, sizeof (tab[confsize])); |
|---|
| … | … | |
| 171 | 170 | } |
|---|
| 172 | 171 | |
|---|
| | 172 | module->confsize++; |
|---|
| 173 | 173 | return tab + confsize; |
|---|
| 174 | 174 | } |
|---|