vlc_configuration.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * configuration.h : configuration management module
00003  * This file describes the programming interface for the configuration module.
00004  * It includes functions allowing to declare, get or set configuration options.
00005  *****************************************************************************
00006  * Copyright (C) 1999-2006 the VideoLAN team
00007  * $Id: c208509efc117b657e989c819e2ff83f280334df $
00008  *
00009  * Authors: Gildas Bazin <gbazin@videolan.org>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00024  *****************************************************************************/
00025 
00026 #ifndef VLC_CONFIGURATION_H
00027 #define VLC_CONFIGURATION_H 1
00028 
00029 /**
00030  * \file
00031  * This file describes the programming interface for the configuration module.
00032  * It includes functions allowing to declare, get or set configuration options.
00033  */
00034 
00035 # ifdef __cplusplus
00036 extern "C" {
00037 # endif
00038 
00039 /*****************************************************************************
00040  * Macros used to build the configuration structure.
00041  *****************************************************************************/
00042 
00043 /* Configuration hint types */
00044 
00045 
00046 #define CONFIG_HINT_CATEGORY                0x0002  /* Start of new category */
00047 #define CONFIG_HINT_SUBCATEGORY             0x0003  /* Start of sub-category */
00048 #define CONFIG_HINT_SUBCATEGORY_END         0x0004  /* End of sub-category */
00049 #define CONFIG_HINT_USAGE                   0x0005  /* Usage information */
00050 
00051 #define CONFIG_CATEGORY                     0x0006 /* Set category */
00052 #define CONFIG_SUBCATEGORY                  0x0007 /* Set subcategory */
00053 #define CONFIG_SECTION                      0x0008 /* Start of new section */
00054 
00055 #define CONFIG_HINT                         0x000F
00056 
00057 /* Configuration item types */
00058 #define CONFIG_ITEM_STRING                  0x0010  /* String option */
00059 #define CONFIG_ITEM_FILE                    0x0020  /* File option */
00060 #define CONFIG_ITEM_MODULE                  0x0030  /* Module option */
00061 #define CONFIG_ITEM_INTEGER                 0x0040  /* Integer option */
00062 #define CONFIG_ITEM_BOOL                    0x0050  /* Bool option */
00063 #define CONFIG_ITEM_FLOAT                   0x0060  /* Float option */
00064 #define CONFIG_ITEM_DIRECTORY               0x0070  /* Directory option */
00065 #define CONFIG_ITEM_KEY                     0x0080  /* Hot key option */
00066 #define CONFIG_ITEM_MODULE_CAT              0x0090  /* Module option */
00067 #define CONFIG_ITEM_MODULE_LIST             0x00A0  /* Module option */
00068 #define CONFIG_ITEM_MODULE_LIST_CAT         0x00B0  /* Module option */
00069 #define CONFIG_ITEM_FONT                    0x00C0  /* Font option */
00070 #define CONFIG_ITEM_PASSWORD                0x00D0  /* Password option (*) */
00071 
00072 #define CONFIG_ITEM                         0x00F0
00073 
00074 /*******************************************************************
00075  * All predefined categories and subcategories
00076  *******************************************************************/
00077 #define CAT_INTERFACE 1
00078    #define SUBCAT_INTERFACE_GENERAL 101
00079    #define SUBCAT_INTERFACE_MAIN 102
00080    #define SUBCAT_INTERFACE_CONTROL 103
00081    #define SUBCAT_INTERFACE_HOTKEYS 104
00082 
00083 #define CAT_AUDIO 2
00084    #define SUBCAT_AUDIO_GENERAL 201
00085    #define SUBCAT_AUDIO_AOUT 202
00086    #define SUBCAT_AUDIO_AFILTER 203
00087    #define SUBCAT_AUDIO_VISUAL 204
00088    #define SUBCAT_AUDIO_MISC 205
00089 
00090 #define CAT_VIDEO 3
00091    #define SUBCAT_VIDEO_GENERAL 301
00092    #define SUBCAT_VIDEO_VOUT 302
00093    #define SUBCAT_VIDEO_VFILTER 303
00094    #define SUBCAT_VIDEO_TEXT 304
00095    #define SUBCAT_VIDEO_SUBPIC 305
00096    #define SUBCAT_VIDEO_VFILTER2 306
00097 
00098 #define CAT_INPUT 4
00099    #define SUBCAT_INPUT_GENERAL 401
00100    #define SUBCAT_INPUT_ACCESS 402
00101    #define SUBCAT_INPUT_DEMUX 403
00102    #define SUBCAT_INPUT_VCODEC 404
00103    #define SUBCAT_INPUT_ACODEC 405
00104    #define SUBCAT_INPUT_SCODEC 406
00105    #define SUBCAT_INPUT_STREAM_FILTER 407
00106 
00107 #define CAT_SOUT 5
00108    #define SUBCAT_SOUT_GENERAL 501
00109    #define SUBCAT_SOUT_STREAM 502
00110    #define SUBCAT_SOUT_MUX 503
00111    #define SUBCAT_SOUT_ACO 504
00112    #define SUBCAT_SOUT_PACKETIZER 505
00113    #define SUBCAT_SOUT_SAP 506
00114    #define SUBCAT_SOUT_VOD 507
00115 
00116 #define CAT_ADVANCED 6
00117    #define SUBCAT_ADVANCED_CPU 601
00118    #define SUBCAT_ADVANCED_MISC 602
00119    #define SUBCAT_ADVANCED_NETWORK 603
00120    #define SUBCAT_ADVANCED_XML 604
00121 
00122 #define CAT_PLAYLIST 7
00123    #define SUBCAT_PLAYLIST_GENERAL 701
00124    #define SUBCAT_PLAYLIST_SD 702
00125    #define SUBCAT_PLAYLIST_EXPORT 703
00126 
00127 #define CAT_OSD 8
00128    #define SUBCAT_OSD_IMPORT 801
00129 
00130 struct config_category_t
00131 {
00132     int         i_id;
00133     const char *psz_name;
00134     const char *psz_help;
00135 };
00136 
00137 typedef union
00138 {
00139     char       *psz;
00140     int         i;
00141     float       f;
00142 } module_value_t;
00143 
00144 typedef union
00145 {
00146     int         i;
00147     float       f;
00148 } module_nvalue_t;
00149 
00150 struct module_config_t
00151 {
00152     int          i_type;                               /* Configuration type */
00153     char        *psz_type;                          /* Configuration subtype */
00154     char        *psz_name;                                    /* Option name */
00155     char         i_short;                      /* Optional short option name */
00156     char        *psz_text;      /* Short comment on the configuration option */
00157     char        *psz_longtext;   /* Long comment on the configuration option */
00158     module_value_t value;                                    /* Option value */
00159     module_value_t orig;
00160     module_value_t saved;
00161     module_nvalue_t min;
00162     module_nvalue_t max;
00163 
00164     /* Function to call when commiting a change */
00165     vlc_callback_t pf_callback;
00166     void          *p_callback_data;
00167 
00168     /* Values list */
00169     char **      ppsz_list;       /* List of possible values for the option */
00170     int         *pi_list;                              /* Idem for integers */
00171     char       **ppsz_list_text;          /* Friendly names for list values */
00172     int          i_list;                               /* Options list size */
00173     vlc_callback_t pf_update_list; /*callback to initialize dropdownlists */
00174 
00175     /* Actions list */
00176     vlc_callback_t *ppf_action;    /* List of possible actions for a config */
00177     char          **ppsz_action_text;         /* Friendly names for actions */
00178     int            i_action;                           /* actions list size */
00179 
00180     /* Misc */
00181     vlc_mutex_t *p_lock;           /* Lock to use when modifying the config */
00182     bool        b_dirty;          /* Dirty flag to indicate a config change */
00183     bool        b_advanced;          /* Flag to indicate an advanced option */
00184     bool        b_internal;   /* Flag to indicate option is not to be shown */
00185     bool        b_restart;   /* Flag to indicate the option needs a restart */
00186                               /* to take effect */
00187 
00188     /* Deprecated */
00189     char        *psz_oldname;                          /* Old option name */
00190     bool        b_removed;
00191 
00192     /* Option values loaded from config file */
00193     bool        b_autosave;      /* Config will be auto-saved at exit time */
00194     bool        b_unsaveable;                /* Config should not be saved */
00195 
00196     bool        b_safe;
00197 };
00198 
00199 /*****************************************************************************
00200  * Prototypes - these methods are used to get, set or manipulate configuration
00201  * data.
00202  *****************************************************************************/
00203 VLC_EXPORT( int,    __config_GetType,  (vlc_object_t *, const char *) LIBVLC_USED );
00204 VLC_EXPORT( int,    __config_GetInt,   (vlc_object_t *, const char *) LIBVLC_USED );
00205 VLC_EXPORT( void,   __config_PutInt,   (vlc_object_t *, const char *, int) );
00206 VLC_EXPORT( float,  __config_GetFloat, (vlc_object_t *, const char *) LIBVLC_USED );
00207 VLC_EXPORT( void,   __config_PutFloat, (vlc_object_t *, const char *, float) );
00208 VLC_EXPORT( char *, __config_GetPsz,   (vlc_object_t *, const char *) LIBVLC_USED );
00209 VLC_EXPORT( void,   __config_PutPsz,   (vlc_object_t *, const char *, const char *) );
00210 
00211 #define config_SaveConfigFile(a,b) __config_SaveConfigFile(VLC_OBJECT(a),b)
00212 VLC_EXPORT( int,    __config_SaveConfigFile, ( vlc_object_t *, const char * ) );
00213 #define config_ResetAll(a) __config_ResetAll(VLC_OBJECT(a))
00214 VLC_EXPORT( void,   __config_ResetAll, ( vlc_object_t * ) );
00215 
00216 VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) LIBVLC_USED );
00217 VLC_EXPORT(const char *, config_GetDataDir, ( void ) LIBVLC_USED);
00218 VLC_EXPORT(const char *, config_GetConfDir, ( void ) LIBVLC_USED);
00219 
00220 typedef enum vlc_userdir
00221 {
00222     VLC_HOME_DIR, /* User's home */
00223     VLC_CONFIG_DIR, /* VLC-specific configuration directory */
00224     VLC_DATA_DIR, /* VLC-specific data directory */
00225     VLC_CACHE_DIR, /* VLC-specific user cached data directory */
00226     /* Generic directories (same as XDG) */
00227     VLC_DESKTOP_DIR=0x80,
00228     VLC_DOWNLOAD_DIR,
00229     VLC_TEMPLATES_DIR,
00230     VLC_PUBLICSHARE_DIR,
00231     VLC_DOCUMENTS_DIR,
00232     VLC_MUSIC_DIR,
00233     VLC_PICTURES_DIR,
00234     VLC_VIDEOS_DIR,
00235 } vlc_userdir_t;
00236 
00237 VLC_EXPORT(char *, config_GetUserDir, ( vlc_userdir_t ) LIBVLC_USED);
00238 
00239 VLC_EXPORT( void,       __config_AddIntf,    ( vlc_object_t *, const char * ) );
00240 VLC_EXPORT( void,       __config_RemoveIntf, ( vlc_object_t *, const char * ) );
00241 VLC_EXPORT( bool, __config_ExistIntf,  ( vlc_object_t *, const char * ) LIBVLC_USED);
00242 
00243 #define config_GetType(a,b) __config_GetType(VLC_OBJECT(a),b)
00244 #define config_GetInt(a,b) __config_GetInt(VLC_OBJECT(a),b)
00245 #define config_PutInt(a,b,c) __config_PutInt(VLC_OBJECT(a),b,c)
00246 #define config_GetFloat(a,b) __config_GetFloat(VLC_OBJECT(a),b)
00247 #define config_PutFloat(a,b,c) __config_PutFloat(VLC_OBJECT(a),b,c)
00248 #define config_GetPsz(a,b) __config_GetPsz(VLC_OBJECT(a),b)
00249 #define config_PutPsz(a,b,c) __config_PutPsz(VLC_OBJECT(a),b,c)
00250 
00251 #define config_AddIntf(a,b) __config_AddIntf(VLC_OBJECT(a),b)
00252 #define config_RemoveIntf(a,b) __config_RemoveIntf(VLC_OBJECT(a),b)
00253 #define config_ExistIntf(a,b) __config_ExistIntf(VLC_OBJECT(a),b)
00254 
00255 /****************************************************************************
00256  * config_chain_t:
00257  ****************************************************************************/
00258 struct config_chain_t
00259 {
00260     config_chain_t *p_next;     /**< Pointer on the next config_chain_t element */
00261 
00262     char        *psz_name;      /**< Option name */
00263     char        *psz_value;     /**< Option value */
00264 };
00265 
00266 /**
00267  * This function will
00268  * - create all options in the array ppsz_options (var_Create).
00269  * - parse the given linked list of config_chain_t and set the value (var_Set).
00270  *
00271  * The option names will be created by adding the psz_prefix prefix.
00272  */
00273 #define config_ChainParse( a, b, c, d ) __config_ChainParse( VLC_OBJECT(a), b, c, d )
00274 VLC_EXPORT( void,   __config_ChainParse, ( vlc_object_t *, const char *psz_prefix, const char *const *ppsz_options, config_chain_t * ) );
00275 
00276 /**
00277  * This function will parse a configuration string (psz_string) and
00278  * - set the module name (*ppsz_name)
00279  * - set all options for this module in a chained list (*pp_cfg)
00280  * - returns a pointer on the next module if any.
00281  *
00282  * The string format is
00283  *   module{option=*,option=*}[:modulenext{option=*,...}]
00284  *
00285  * The options values are unescaped using config_StringUnescape.
00286  */
00287 VLC_EXPORT( char *, config_ChainCreate, ( char **ppsz_name, config_chain_t **pp_cfg, const char *psz_string ) );
00288 
00289 /**
00290  * This function will release a linked list of config_chain_t
00291  * (Including the head)
00292  */
00293 VLC_EXPORT( void, config_ChainDestroy, ( config_chain_t * ) );
00294 
00295 /**
00296  * This function will duplicate a linked list of config_chain_t
00297  */
00298 VLC_EXPORT( config_chain_t *, config_ChainDuplicate, ( const config_chain_t * ) );
00299 
00300 /**
00301  * This function will unescape a string in place and will return a pointer on
00302  * the given string.
00303  * No memory is allocated by it (unlike config_StringEscape).
00304  * If NULL is given as parameter nothing will be done (NULL will be returned).
00305  *
00306  * The following sequences will be unescaped (only one time):
00307  * \\ \' and \"
00308  */
00309 VLC_EXPORT( char *, config_StringUnescape, ( char *psz_string ) );
00310 
00311 /**
00312  * This function will escape a string that can be unescaped by
00313  * config_StringUnescape.
00314  * The returned value is allocated by it. You have to free it once you
00315  * do not need it anymore (unlike config_StringUnescape).
00316  * If NULL is given as parameter nothing will be done (NULL will be returned).
00317  *
00318  * The escaped characters are ' " and \
00319  */
00320 VLC_EXPORT( char *, config_StringEscape, ( const char *psz_string ) LIBVLC_USED);
00321 
00322 # ifdef __cplusplus
00323 }
00324 # endif
00325 
00326 #endif /* _VLC_CONFIGURATION_H */

Generated on Sat Nov 21 08:05:14 2009 for VLC by  doxygen 1.5.6