VLC 4.0.0-dev
|
Go to the source code of this file.
Data Structures | |
struct | vlc_param |
Macros | |
#define | CONFIG_FILE "vlcrc" |
Functions | |
struct vlc_param * | vlc_param_Find (const char *name) |
Looks up a configuration parameter by name. | |
int | vlc_param_SetString (struct vlc_param *param, const char *value) |
int | config_AutoSaveConfigFile (libvlc_int_t *) |
void | config_Free (struct vlc_param *, size_t) |
Destroys an array of configuration items. | |
void | config_CmdLineEarlyScan (libvlc_int_t *, int, const char *[]) |
Perform early scan of arguments for a small subset of simple options. | |
int | config_LoadCmdLine (libvlc_int_t *, int, const char *[], int *) |
Parse command line for configuration options. | |
int | config_LoadConfigFile (libvlc_int_t *) |
bool | config_PrintHelp (libvlc_int_t *) |
Checks for help command line options such as –help or –version. | |
void | config_Lock (void) |
void | config_Unlock (void) |
int | config_SortConfig (void) |
Index the configuration items by name for faster lookups. | |
void | config_UnsortConfig (void) |
bool | config_IsSafe (const char *) |
char * | config_GetLibDir (void) |
Gets the arch-specific installation directory. | |
char * | platform_GetUserDir (vlc_userdir_t) |
#define CONFIG_FILE "vlcrc" |
int config_AutoSaveConfigFile | ( | libvlc_int_t * | p_this | ) |
References config_dirty, config_SaveConfigFile, and unlikely.
Referenced by libvlc_InternalCleanup().
void config_CmdLineEarlyScan | ( | libvlc_int_t * | p_this, |
int | argc, | ||
const char * | argv[] | ||
) |
Perform early scan of arguments for a small subset of simple options.
Before proper full processing can be done, which requires full knowledge of all available options, we have a need to perform a preliminary check for a few options that affect plugin loading. This is because the full option set consists of a core subset plus various plugin subsets and we thus need to load plugin data to know the plugin subsets, but there are a few core options that actually affect loading of plugin data.
Note that we want to be cautious about doing too much here. Firstly simply to avoid duplicating effort done later in the proper full processing step. Additionally though because fundamentally the very notion of a preliminary scan is problematic in terms of taking "correct" (or at least consistent) action in the face of certain use or misuse of options. Consider the fact that it is standard practice with option arguments that take a value, should a value not be provided within the same argument, to just consume the next argument as the option's value, no matter whether or not the next argument might "look" like an option itself (or an "early terminator"). Such is the behaviour of getopt. (It may perhaps seem wrong to do things that way, but that's how it works; it would alternatively be wrong for getopt in general to prevent options from taking values that just happen to resemble these things; and besides, bad consumption will only occur through bad option use which is fair to expect to cause incorrect results and in many cases ideally would be caught early by validation checks on option values anyway). So, a preliminary scan, by not knowing the full option set and not following the standard parsing rules (since it can't), naturally introduces risks of "incorrect" or "inconsistent" interpretation of the set of arguments, at least wrt. the later full/proper processing, and the more that we do, the more such incorrect/inconsistent processing scenarios we introduce. Furthermore consider the additional complication of short option "sets" (which is a short option argument involving multiple characters like -abc
). In a short option set only the last option in the set (which is not necessarily its last character) can be one that takes a value, with any characters coming after it (if any) taken as its option value (if none then the next argument is consumed instead). In a preliminary scan where we do not know the full set of available short options, we can risk misinterpreting characters in short option sets as options when they are meant to be consumed as an option value. Thus it is very problematic to properly try to deal with an option like --help
, which comes with the short option -h
as well as --no-help
, here in a preliminary scan, which is unfortunate because it might make a nice optimisation if we could.
Considering this discussion, it is simply best that we keep option checks here to an absolute bare minimum of just the three plugin data related ones that we have no choice but to scan for early, and we must put up with a minimal amount of possible incorrect/inconsistent interpretation as unavoidable. (Though we could add some code after the full scan to determine whether or not the wrong action took place and issue a warning if so).
p_this | object to write command line options as variables to |
argc | number of command line arguments |
argv | command line arguments |
References arg, and VLC_UNUSED.
Referenced by libvlc_InternalInit().
void config_Free | ( | struct vlc_param * | tab, |
size_t | confsize | ||
) |
Destroys an array of configuration items.
tab | start of array of items |
confsize | number of items in the array |
References module_config_t::i_type, IsConfigStringType, vlc_param::item, module_config_t::list, module_config_t::list_count, module_config_t::list_text, module_config_t::psz, vlc_param::str, and vlc_param::value.
Referenced by vlc_plugin_destroy().
char * config_GetLibDir | ( | void | ) |
Gets the arch-specific installation directory.
This function determines the directory containing the architecture-specific installed asset files (such as executable plugins and compiled byte code).
Gets the arch-specific installation directory.
References cached_path, config_GetLibDir(), config_GetLibDirOnce(), config_getLibraryDirReal(), config_GetRealDir(), FromLocaleDup, getenv(), and strdup().
Referenced by config_GetDataDir(), config_GetHomeDir(), config_GetLibDir(), config_GetLibDirRaw(), and config_GetSysPath().
bool config_IsSafe | ( | const char * | name | ) |
References name, vlc_param::safe, and vlc_param_Find().
Referenced by var_OptionParse().
int config_LoadCmdLine | ( | libvlc_int_t * | p_this, |
int | i_argc, | ||
const char * | ppsz_argv[], | ||
int * | pindex | ||
) |
Parse command line for configuration options.
Now that the module_bank has been initialized, we can dynamically generate the longopts structure used by getops. We have to do it this way because we don't know (and don't want to know) in advance the configuration options used (ie. exported) by each module.
p_this | object to write command line options as variables to |
i_argc | number of command line arguments |
ppsz_argv | command line arguments [IN/OUT] |
pindex | index of the first non-option argument [OUT] |
References _, asprintf(), CONFIG_CLASS, config_FindConfig(), CONFIG_ITEM, CONFIG_ITEM_BOOL, CONFIG_ITEM_FLOAT, CONFIG_ITEM_INTEGER, CONFIG_ITEM_STRING, container_of, module_value_t::f, vlc_option::flag, vlc_option::has_arg, module_value_t::i, vlc_param::i, module_config_t::i_type, i_type, vlc_getopt_s::ind, vlc_option::is_obsolete, vlc_param::item, module_config_t::max, module_config_t::min, vlc_option::name, name, vlc_plugin_t::next, vlc_param::obsolete, p, module_config_t::psz_name, psz_name, vlc_param::shortname, state, strdup(), strtoll(), TS_GREEN, TS_RED_BOLD, TS_RESET, TS_YELLOW, TS_YELLOW_BOLD, vlc_option::val, var_Change(), var_Create(), var_SetBool(), var_SetFloat(), var_SetInteger(), var_SetString(), vlc_alloc(), vlc_assert_unreachable, vlc_atof_c(), vlc_getopt_long(), vlc_jaro_winkler(), vlc_plugins, VLC_VAR_BOOL, VLC_VAR_FLOAT, VLC_VAR_INTEGER, VLC_VAR_SETMINMAX, and VLC_VAR_STRING.
Referenced by libvlc_InternalInit().
int config_LoadConfigFile | ( | libvlc_int_t * | p_this | ) |
References atof(), CONFIG_CLASS, CONFIG_ITEM_BOOL, CONFIG_ITEM_FLOAT, CONFIG_ITEM_INTEGER, config_Lock(), config_OpenConfigFile(), config_Unlock(), module_value_t::f, vlc_param::f, freelocale(), getline(), module_value_t::i, vlc_param::i, module_config_t::i_type, vlc_param::item, LC_NUMERIC_MASK, module_config_t::max, msg_Err, msg_Warn, newlocale(), vlc_param::obsolete, rewind(), vlc_param::unsaved, uselocale(), module_config_t::value, vlc_param::value, VLC_EGENERIC, vlc_param_Find(), vlc_param_SetString(), vlc_strerror_c(), and vlc_strtoi().
Referenced by libvlc_InternalInit().
void config_Lock | ( | void | ) |
References config_lock, and vlc_mutex_lock().
Referenced by config_LoadConfigFile().
bool config_PrintHelp | ( | libvlc_int_t * | obj | ) |
Checks for help command line options such as –help or –version.
If one is found, print the corresponding text.
References Help(), ListModules(), var_Create(), var_InheritBool(), var_InheritString(), var_SetBool(), Version(), and VLC_VAR_BOOL.
Referenced by libvlc_InternalInit().
int config_SortConfig | ( | void | ) |
Index the configuration items by name for faster lookups.
References vlc_plugin_t::conf, confcmp(), config, CONFIG_ITEM, vlc_plugin_t::count, vlc_param::i, module_config_t::i_type, vlc_param::item, vlc_plugin_t::next, p, unlikely, vlc_alloc(), VLC_ENOMEM, vlc_plugins, and VLC_SUCCESS.
Referenced by module_InitBank(), and module_LoadPlugins().
void config_Unlock | ( | void | ) |
References config_lock, and vlc_mutex_unlock().
Referenced by config_LoadConfigFile().
void config_UnsortConfig | ( | void | ) |
References config.
Referenced by module_EndBank(), and module_LoadPlugins().
char * platform_GetUserDir | ( | vlc_userdir_t | type | ) |
References asprintf(), config_GetAppDir(), config_GetCacheDir(), config_GetGenericDir(), config_GetHomeDir(), config_GetHomeDir(), config_GetKnownFolder(), config_GetShellDir(), config_GetTypeDir(), config_GetUserDir(), getAppDependentDir(), ppsz_generic_names, psz_name, vlc_assert_unreachable, VLC_CACHE_DIR, VLC_CONFIG_DIR, VLC_DESKTOP_DIR, VLC_DOCUMENTS_DIR, VLC_DOWNLOAD_DIR, VLC_HOME_DIR, VLC_MUSIC_DIR, VLC_PICTURES_DIR, VLC_PUBLICSHARE_DIR, VLC_SNAPSHOTS_DIR, VLC_TEMPLATES_DIR, VLC_USERDATA_DIR, and VLC_VIDEOS_DIR.
Referenced by config_GetUserDir().
struct vlc_param * vlc_param_Find | ( | const char * | name | ) |
Looks up a configuration parameter by name.
References config, confnamecmp(), name, and p.
Referenced by config_ChainParse(), config_FindConfig(), config_GetFloat(), config_GetInt(), config_GetIntChoices(), config_GetPsz(), config_GetPszChoices(), config_GetType(), config_IsSafe(), config_LoadConfigFile(), config_PutFloat(), config_PutInt(), and config_PutPsz().
int vlc_param_SetString | ( | struct vlc_param * | param, |
const char * | value | ||
) |
References module_config_t::i_type, IsConfigStringType, vlc_param::item, module_value_t::psz, vlc_param::str, strdup(), unlikely, module_config_t::value, vlc_param::value, and vlc_rcu_synchronize().
Referenced by config_LoadConfigFile(), config_PutPsz(), config_ResetAll(), and vlc_plugin_desc_cb().