spu: rss: fix first character of display being omitted
[vlc.git] / include / vlc_configuration.h
blobd4b8fc24731e7b127f36670f0426a3aa85cce488
1 /*****************************************************************************
2 * vlc_configuration.h : configuration management module
3 * This file describes the programming interface for the configuration module.
4 * It includes functions allowing to declare, get or set configuration options.
5 *****************************************************************************
6 * Copyright (C) 1999-2006 VLC authors and VideoLAN
8 * Authors: Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #ifndef VLC_CONFIGURATION_H
26 #define VLC_CONFIGURATION_H 1
28 /**
29 * \defgroup config User settings
30 * \ingroup interface
31 * VLC provides a simple name-value dictionary for user settings.
33 * Those settings are per-user per-system - they are shared by all LibVLC
34 * instances in a single process, and potentially other processes as well.
36 * Each name-value pair is called a configuration item.
37 * @{
40 /**
41 * \file
42 * This file describes the programming interface for the configuration module.
43 * It includes functions allowing to declare, get or set configuration options.
46 #include <sys/types.h> /* for ssize_t */
48 # ifdef __cplusplus
49 extern "C" {
50 # endif
52 struct config_category_t
54 int i_id;
55 const char *psz_name;
56 const char *psz_help;
59 typedef union
61 char *psz;
62 int64_t i;
63 float f;
64 } module_value_t;
66 typedef int (*vlc_string_list_cb)(const char *, char ***, char ***);
67 typedef int (*vlc_integer_list_cb)(const char *, int64_t **, char ***);
69 /**
70 * Configuration item
72 * This is the internal reprensation of a configuration item.
73 * See also config_FindConfig().
75 struct module_config_t
77 uint8_t i_type; /**< Configuration type */
78 char i_short; /**< Optional short option name */
79 unsigned b_internal:1; /**< Hidden from preferences and help */
80 unsigned b_unsaveable:1; /**< Not stored in configuration */
81 unsigned b_safe:1; /**< Safe for web plugins and playlist files */
82 unsigned b_removed:1; /**< Obsolete */
84 const char *psz_type; /**< Configuration subtype */
85 const char *psz_name; /**< Option name */
86 const char *psz_text; /**< Short comment on the configuration option */
87 const char *psz_longtext; /**< Long comment on the configuration option */
89 module_value_t value; /**< Current value */
90 module_value_t orig; /**< Default value */
91 module_value_t min; /**< Minimum value (for scalars only) */
92 module_value_t max; /**< Maximum value (for scalars only) */
94 /* Values list */
95 uint16_t list_count; /**< Choices count */
96 union
98 const char **psz; /**< Table of possible string choices */
99 const int *i; /**< Table of possible integer choices */
100 } list; /**< Possible choices */
101 const char **list_text; /**< Human-readable names for list values */
102 void *owner; /**< Origin run-time linker module handle */
106 * Gets a configuration item type
108 * This function checks the type of configuration item by name.
109 * \param name Configuration item name
110 * \return The configuration item type or 0 if not found.
112 VLC_API int config_GetType(const char *name) VLC_USED;
115 * Gets an integer configuration item.
117 * This function retrieves the current value of a configuration item of
118 * integral type (\ref CONFIG_ITEM_INTEGER and \ref CONFIG_ITEM_BOOL).
120 * \warning The behaviour is undefined if the configuration item exists but is
121 * not of integer or boolean type.
123 * \param name Configuration item name
124 * \return The configuration item value or -1 if not found.
125 * \bug A legitimate integer value of -1 cannot be distinguished from an error.
127 VLC_API int64_t config_GetInt(const char *name) VLC_USED;
130 * Sets an integer configuration item.
132 * This function changes the current value of a configuration item of
133 * integral type (\ref CONFIG_ITEM_INTEGER and \ref CONFIG_ITEM_BOOL).
135 * \warning The behaviour is undefined if the configuration item exists but is
136 * not of integer or boolean type.
138 * \note If no configuration item by the specified exist, the function has no
139 * effects.
141 * \param name Configuration item name
142 * \param val New value
144 VLC_API void config_PutInt(const char *name, int64_t val);
147 * Gets an floating point configuration item.
149 * This function retrieves the current value of a configuration item of
150 * floating point type (\ref CONFIG_ITEM_FLOAT).
152 * \warning The behaviour is undefined if the configuration item exists but is
153 * not of floating point type.
155 * \param name Configuration item name
156 * \return The configuration item value or -1 if not found.
157 * \bug A legitimate floating point value of -1 cannot be distinguished from an
158 * error.
160 VLC_API float config_GetFloat(const char *name) VLC_USED;
163 * Sets an integer configuration item.
165 * This function changes the current value of a configuration item of
166 * integral type (\ref CONFIG_ITEM_FLOAT).
168 * \warning The behaviour is undefined if the configuration item exists but is
169 * not of floating point type.
171 * \note If no configuration item by the specified exist, the function has no
172 * effects.
174 * \param name Configuration item name
175 * \param val New value
177 VLC_API void config_PutFloat(const char *name, float val);
180 * Gets an string configuration item.
182 * This function retrieves the current value of a configuration item of
183 * string type (\ref CONFIG_ITEM_STRING).
185 * \note The caller must free() the returned pointer (if non-NULL), which is a
186 * duplicate of the current value. It is not safe to return a pointer to the
187 * current value internally as it can be modified at any time by any other
188 * thread.
190 * \warning The behaviour is undefined if the configuration item exists but is
191 * not of string type.
193 * \param name Configuration item name
194 * \return Normally, a heap-allocated copy of the configuration item value.
195 * If the value is the empty string, if the configuration does not exist,
196 * or if an error occurs, NULL is returned.
197 * \bug The empty string value cannot be distinguished from an error.
199 VLC_API char *config_GetPsz(const char *name) VLC_USED VLC_MALLOC;
202 * Sets an string configuration item.
204 * This function changes the current value of a configuration item of
205 * string type (e.g. \ref CONFIG_ITEM_STRING).
207 * \warning The behaviour is undefined if the configuration item exists but is
208 * not of a string type.
210 * \note If no configuration item by the specified exist, the function has no
211 * effects.
213 * \param name Configuration item name
214 * \param val New value (will be copied)
215 * \bug This function allocates memory but errors cannot be detected.
217 VLC_API void config_PutPsz(const char *name, const char *val);
220 * Enumerates integer configuration choices.
222 * Determines a list of suggested values for an integer configuration item.
223 * \param values pointer to a table of integer values [OUT]
224 * \param texts pointer to a table of descriptions strings [OUT]
225 * \return number of choices, or -1 on error
226 * \note the caller is responsible for calling free() on all descriptions and
227 * on both tables. In case of error, both pointers are set to NULL.
229 VLC_API ssize_t config_GetIntChoices(const char *, int64_t **values,
230 char ***texts) VLC_USED;
233 * Determines a list of suggested values for a string configuration item.
234 * \param values pointer to a table of value strings [OUT]
235 * \param texts pointer to a table of descriptions strings [OUT]
236 * \return number of choices, or -1 on error
237 * \note the caller is responsible for calling free() on all values, on all
238 * descriptions and on both tables.
239 * In case of error, both pointers are set to NULL.
241 VLC_API ssize_t config_GetPszChoices(const char *,
242 char ***values, char ***texts) VLC_USED;
244 VLC_API int config_SaveConfigFile( vlc_object_t * );
245 #define config_SaveConfigFile(a) config_SaveConfigFile(VLC_OBJECT(a))
248 * Resets the configuration.
250 * This function resets all configuration items to their respective
251 * compile-time default value.
253 VLC_API void config_ResetAll(void);
256 * Looks up a configuration item.
258 * This function looks for the internal representation of a configuration item.
259 * Where possible, this should be avoided in favor of more specific function
260 * calls.
262 * \param name Configuration item name
263 * \return The internal structure, or NULL if not found.
265 VLC_API module_config_t *config_FindConfig(const char *name) VLC_USED;
268 * System directory identifiers
270 typedef enum vlc_system_dir
272 VLC_PKG_DATA_DIR, /**< Package-specific architecture-independent read-only
273 data directory (e.g. /usr/local/data/vlc). */
274 VLC_PKG_LIB_DIR, /**< Package-specific architecture-dependent read-only
275 data directory (e.g. /usr/local/lib/vlc). */
276 VLC_PKG_LIBEXEC_DIR, /**< Package-specific executable read-only directory
277 (e.g. /usr/local/libexec/vlc). */
278 VLC_PKG_INCLUDE_DIR_RESERVED,
279 VLC_SYSDATA_DIR, /**< Global architecture-independent read-only
280 data directory (e.g. /usr/local/data).
281 Available only on some platforms. */
282 VLC_LIB_DIR, /**< Global architecture-dependent read-only directory
283 (e.g. /usr/local/lib). */
284 VLC_LIBEXEC_DIR, /**< Global executable read-only directory
285 (e.g. /usr/local/libexec). */
286 VLC_INCLUDE_DIR_RESERVED,
287 VLC_LOCALE_DIR, /**< Base directory for package read-only locale data. */
288 } vlc_sysdir_t;
291 * Gets an installation directory.
293 * This function determines one of the installation directory.
295 * @param dir identifier of the directory (see \ref vlc_sysdir_t)
296 * @param filename name of a file or other object within the directory
297 * (or NULL to obtain the plain directory)
299 * @return a heap-allocated string (use free() to release it), or NULL on error
301 VLC_API char *config_GetSysPath(vlc_sysdir_t dir, const char *filename)
302 VLC_USED VLC_MALLOC;
304 typedef enum vlc_user_dir
306 VLC_HOME_DIR, /* User's home */
307 VLC_CONFIG_DIR, /* VLC-specific configuration directory */
308 VLC_USERDATA_DIR, /* VLC-specific data directory */
309 VLC_CACHE_DIR, /* VLC-specific user cached data directory */
310 /* Generic directories (same as XDG) */
311 VLC_DESKTOP_DIR=0x80,
312 VLC_DOWNLOAD_DIR,
313 VLC_TEMPLATES_DIR,
314 VLC_PUBLICSHARE_DIR,
315 VLC_DOCUMENTS_DIR,
316 VLC_MUSIC_DIR,
317 VLC_PICTURES_DIR,
318 VLC_VIDEOS_DIR,
319 } vlc_userdir_t;
321 VLC_API char * config_GetUserDir( vlc_userdir_t ) VLC_USED VLC_MALLOC;
323 VLC_API void config_AddIntf(const char *);
324 VLC_API void config_RemoveIntf(const char *);
325 VLC_API bool config_ExistIntf(const char *) VLC_USED;
327 /****************************************************************************
328 * config_chain_t:
329 ****************************************************************************/
330 struct config_chain_t
332 config_chain_t *p_next; /**< Pointer on the next config_chain_t element */
334 char *psz_name; /**< Option name */
335 char *psz_value; /**< Option value */
339 * This function will
340 * - create all options in the array ppsz_options (var_Create).
341 * - parse the given linked list of config_chain_t and set the value (var_Set).
343 * The option names will be created by adding the psz_prefix prefix.
345 VLC_API void config_ChainParse( vlc_object_t *, const char *psz_prefix, const char *const *ppsz_options, const config_chain_t * );
346 #define config_ChainParse( a, b, c, d ) config_ChainParse( VLC_OBJECT(a), b, c, d )
349 * This function will parse a configuration string (psz_opts) and
350 * - set all options for this module in a chained list (*pp_cfg)
351 * - returns a pointer on the next module if any.
353 * The string format is
354 * module{option=*,option=*}
356 * The options values are unescaped using config_StringUnescape.
358 VLC_API const char *config_ChainParseOptions( config_chain_t **pp_cfg, const char *ppsz_opts );
361 * This function will parse a configuration string (psz_string) and
362 * - set the module name (*ppsz_name)
363 * - set all options for this module in a chained list (*pp_cfg)
364 * - returns a pointer on the next module if any.
366 * The string format is
367 * module{option=*,option=*}[:modulenext{option=*,...}]
369 * The options values are unescaped using config_StringUnescape.
371 VLC_API char *config_ChainCreate( char **ppsz_name, config_chain_t **pp_cfg, const char *psz_string ) VLC_USED VLC_MALLOC;
374 * This function will release a linked list of config_chain_t
375 * (Including the head)
377 VLC_API void config_ChainDestroy( config_chain_t * );
380 * This function will duplicate a linked list of config_chain_t
382 VLC_API config_chain_t * config_ChainDuplicate( const config_chain_t * ) VLC_USED VLC_MALLOC;
385 * This function will unescape a string in place and will return a pointer on
386 * the given string.
387 * No memory is allocated by it (unlike config_StringEscape).
388 * If NULL is given as parameter nothing will be done (NULL will be returned).
390 * The following sequences will be unescaped (only one time):
391 * \\ \' and \"
393 VLC_API char * config_StringUnescape( char *psz_string );
396 * This function will escape a string that can be unescaped by
397 * config_StringUnescape.
398 * The returned value is allocated by it. You have to free it once you
399 * do not need it anymore (unlike config_StringUnescape).
400 * If NULL is given as parameter nothing will be done (NULL will be returned).
402 * The escaped characters are ' " and \
404 VLC_API char * config_StringEscape( const char *psz_string ) VLC_USED VLC_MALLOC;
406 # ifdef __cplusplus
408 # endif
410 /** @} */
412 #endif /* _VLC_CONFIGURATION_H */