]> git.sesse.net Git - vlc/blob - include/configuration.h
* moved GetConfigurationFromCmdLine() into configuration.c and renamed it
[vlc] / include / configuration.h
1 /*****************************************************************************
2  * 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, 2000 VideoLAN
7  * $Id: configuration.h,v 1.4 2002/03/21 07:11:57 gbazin Exp $
8  *
9  * Authors: Gildas Bazin <gbazin@netcourrier.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Macros used to build the configuration structure.
28  *****************************************************************************/
29
30 /* Configuration hint types */
31 #define MODULE_CONFIG_HINT_END              0x0001  /* End of config */
32 #define MODULE_CONFIG_HINT_CATEGORY         0x0002  /* Start of new category */
33 #define MODULE_CONFIG_HINT_SUBCATEGORY      0x0003  /* Start of sub-category */
34 #define MODULE_CONFIG_HINT_SUBCATEGORY_END  0x0004  /* End of sub-category */
35
36 #define MODULE_CONFIG_HINT                  0x000F
37
38 /* Configuration item types */
39 #define MODULE_CONFIG_ITEM_STRING           0x0010  /* String option */
40 #define MODULE_CONFIG_ITEM_FILE             0x0020  /* File option */
41 #define MODULE_CONFIG_ITEM_PLUGIN           0x0030  /* Plugin option */
42 #define MODULE_CONFIG_ITEM_INTEGER          0x0040  /* Integer option */
43 #define MODULE_CONFIG_ITEM_BOOL             0x0050  /* Bool option */
44 #define MODULE_CONFIG_ITEM_ALIAS            0x0060  /* Alias option */
45
46 #define MODULE_CONFIG_ITEM                  0x00F0
47
48 typedef struct module_config_s
49 {
50     int         i_type;                                /* Configuration type */
51     char        *psz_name;                                    /* Option name */
52     char        *psz_text;      /* Short comment on the configuration option */
53     char        *psz_longtext;   /* Long comment on the configuration option */
54     char        *psz_value;                                  /* Option value */
55     int         i_value;                                     /* Option value */
56     void        *p_callback;     /* Function to call when commiting a change */
57     vlc_mutex_t *p_lock;            /* lock to use when modifying the config */
58     boolean_t   b_dirty;           /* Dirty flag to indicate a config change */
59
60 } module_config_t;
61
62 /*****************************************************************************
63  * Prototypes - these methods are used to get, set or manipulate configuration
64  * data.
65  *****************************************************************************/
66 #ifndef PLUGIN
67 int    config_GetIntVariable( const char *psz_name );
68 char * config_GetPszVariable( const char *psz_name );
69 void   config_PutIntVariable( const char *psz_name, int i_value );
70 void   config_PutPszVariable( const char *psz_name, char *psz_value );
71
72 int config_LoadConfigFile( const char *psz_module_name );
73 int config_SaveConfigFile( const char *psz_module_name );
74 module_config_t *config_FindConfig( const char *psz_name );
75 module_config_t *config_Duplicate ( module_t *p_module );
76 char *config_GetHomeDir( void );
77 int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
78                         boolean_t b_ignore_errors );
79
80 #else
81 #   define config_GetIntVariable p_symbols->config_GetIntVariable
82 #   define config_PutIntVariable p_symbols->config_PutIntVariable
83 #   define config_GetPszVariable p_symbols->config_GetPszVariable
84 #   define config_PutPszVariable p_symbols->config_PutPszVariable
85 #   define config_Duplicate      p_symbols->config_Duplicate
86 #   define config_FindConfig     p_symbols->config_FindConfig
87 #   define config_LoadConfigFile p_symbols->config_LoadConfigFile
88 #   define config_SaveConfigFile p_symbols->config_SaveConfigFile
89 #endif
90
91 /*****************************************************************************
92  * Macros used to build the configuration structure.
93  *
94  * Note that internally we support only 2 types of config data: int and string.
95  *   The other types declared here just map to one of these 2 basic types but
96  *   have the advantage of also providing very good hints to a configuration
97  *   interface so as to make it more user friendly.
98  * The configuration structure also includes category hints. These hints can
99  *   provide a configuration inteface with some very useful data and also allow
100  *   for a more user friendly interface.
101  *****************************************************************************/
102
103 #define MODULE_CONFIG_START \
104     static module_config_t p_config[] = {
105
106 #define MODULE_CONFIG_STOP \
107     { MODULE_CONFIG_HINT_END, NULL, NULL, NULL, NULL, 0, NULL, 0 } };
108
109 #define ADD_CATEGORY_HINT( text, longtext ) \
110     { MODULE_CONFIG_HINT_CATEGORY, NULL, text, longtext, NULL, 0, NULL, \
111       NULL, 0 },
112 #define ADD_SUBCATEGORY_HINT( text, longtext ) \
113     { MODULE_CONFIG_HINT_SUBCATEGORY, NULL, text, longtext, NULL, 0, NULL, \
114       NULL, 0 },
115 #define END_SUBCATEGORY_HINT \
116     { MODULE_CONFIG_HINT_SUBCATEGORY_END, NULL, NULL, NULL, NULL, 0, NULL, \
117       NULL, 0 },
118 #define ADD_STRING( name, value, p_callback, text, longtext ) \
119     { MODULE_CONFIG_ITEM_STRING, name, text, longtext, value, 0, \
120       p_callback, NULL, 0 },
121 #define ADD_FILE( name, psz_value, p_callback, text, longtext ) \
122     { MODULE_CONFIG_ITEM_FILE, name, text, longtext, psz_value, 0, \
123       p_callback, NULL, 0 },
124 #define ADD_PLUGIN( name, i_capability, psz_value, p_callback, text, longtext)\
125     { MODULE_CONFIG_ITEM_PLUGIN, name, text, longtext, psz_value, \
126       i_capability, p_callback, NULL, 0 },
127 #define ADD_INTEGER( name, i_value, p_callback, text, longtext ) \
128     { MODULE_CONFIG_ITEM_INTEGER, name, text, longtext, NULL, i_value, \
129       p_callback, NULL, 0 },
130 #define ADD_BOOL( name, p_callback, text, longtext ) \
131     { MODULE_CONFIG_ITEM_BOOL, name, text, longtext, NULL, 0, p_callback, \
132       NULL, 0 },