* ./Makefile: we check for Makefile.config before including it.
[vlc.git] / include / configuration.h
blob650fa1ab337d9f6099c6d0598003acd45a05c890
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.10 2002/05/03 20:49:30 sam Exp $
9 * Authors: Gildas Bazin <gbazin@netcourrier.com>
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.
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.
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 *****************************************************************************/
26 /*****************************************************************************
27 * Macros used to build the configuration structure.
28 *****************************************************************************/
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 */
36 #define MODULE_CONFIG_HINT 0x000F
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_MODULE 0x0030 /* Module option */
42 #define MODULE_CONFIG_ITEM_INTEGER 0x0040 /* Integer option */
43 #define MODULE_CONFIG_ITEM_BOOL 0x0050 /* Bool option */
44 #define MODULE_CONFIG_ITEM_FLOAT 0x0060 /* Float option */
46 #define MODULE_CONFIG_ITEM 0x00F0
48 typedef struct module_config_s
50 int i_type; /* Configuration type */
51 char *psz_name; /* Option name */
52 char i_short; /* Optional short option name */
53 char *psz_text; /* Short comment on the configuration option */
54 char *psz_longtext; /* Long comment on the configuration option */
55 char *psz_value; /* Option value */
56 int i_value; /* Option value */
57 float f_value; /* Option value */
58 void *p_callback; /* Function to call when commiting a change */
59 vlc_mutex_t *p_lock; /* lock to use when modifying the config */
60 boolean_t b_dirty; /* Dirty flag to indicate a config change */
62 } module_config_t;
64 /*****************************************************************************
65 * Prototypes - these methods are used to get, set or manipulate configuration
66 * data.
67 *****************************************************************************/
68 #ifndef __PLUGIN__
69 int config_GetIntVariable( const char *psz_name );
70 float config_GetFloatVariable( const char *psz_name );
71 char * config_GetPszVariable( const char *psz_name );
72 void config_PutIntVariable( const char *psz_name, int i_value );
73 void config_PutFloatVariable( const char *psz_name, float f_value );
74 void config_PutPszVariable( const char *psz_name, char *psz_value );
76 int config_LoadConfigFile( const char *psz_module_name );
77 int config_SaveConfigFile( const char *psz_module_name );
78 char * config_GetHomeDir( void );
79 int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
80 boolean_t b_ignore_errors );
82 module_config_t *config_Duplicate ( module_config_t * );
83 module_config_t *config_FindConfig ( const char * );
84 void config_SetCallbacks ( module_config_t *, module_config_t * );
85 void config_UnsetCallbacks( module_config_t * );
87 #else
88 # define config_GetIntVariable p_symbols->config_GetIntVariable
89 # define config_PutIntVariable p_symbols->config_PutIntVariable
90 # define config_GetFloatVariable p_symbols->config_GetFloatVariable
91 # define config_PutFloatVariable p_symbols->config_PutFloatVariable
92 # define config_GetPszVariable p_symbols->config_GetPszVariable
93 # define config_PutPszVariable p_symbols->config_PutPszVariable
94 # define config_LoadConfigFile p_symbols->config_LoadConfigFile
95 # define config_SaveConfigFile p_symbols->config_SaveConfigFile
96 # define config_Duplicate p_symbols->config_Duplicate
97 # define config_FindConfig p_symbols->config_FindConfig
98 # define config_SetCallbacks p_symbols->config_SetCallbacks
99 # define config_UnsetCallbacks p_symbols->config_UnsetCallbacks
100 #endif
102 /*****************************************************************************
103 * Macros used to build the configuration structure.
105 * Note that internally we support only 2 types of config data: int and string.
106 * The other types declared here just map to one of these 2 basic types but
107 * have the advantage of also providing very good hints to a configuration
108 * interface so as to make it more user friendly.
109 * The configuration structure also includes category hints. These hints can
110 * provide a configuration inteface with some very useful data and also allow
111 * for a more user friendly interface.
112 *****************************************************************************/
114 #define MODULE_CONFIG_START \
115 static module_config_t p_config[] = {
117 #define MODULE_CONFIG_STOP \
118 { MODULE_CONFIG_HINT_END, NULL, '\0', NULL, NULL, NULL, 0, 0, NULL, 0 } };
120 #define ADD_CATEGORY_HINT( text, longtext ) \
121 { MODULE_CONFIG_HINT_CATEGORY, NULL, '\0', text, longtext, NULL, 0, 0, \
122 NULL, NULL, 0 },
123 #define ADD_SUBCATEGORY_HINT( text, longtext ) \
124 { MODULE_CONFIG_HINT_SUBCATEGORY, NULL, '\0', text, longtext, NULL, 0, 0, \
125 NULL, NULL, 0 },
126 #define END_SUBCATEGORY_HINT \
127 { MODULE_CONFIG_HINT_SUBCATEGORY_END, NULL, '\0', NULL, NULL, NULL, 0, 0, \
128 NULL, NULL, 0 },
129 #define ADD_STRING( name, value, p_callback, text, longtext ) \
130 { MODULE_CONFIG_ITEM_STRING, name, '\0', text, longtext, value, 0, 0, \
131 p_callback, NULL, 0 },
132 #define ADD_FILE( name, psz_value, p_callback, text, longtext ) \
133 { MODULE_CONFIG_ITEM_FILE, name, '\0', text, longtext, psz_value, 0, 0, \
134 p_callback, NULL, 0 },
135 #define ADD_MODULE( name, i_capability, psz_value, p_callback, text, longtext)\
136 { MODULE_CONFIG_ITEM_MODULE, name, '\0', text, longtext, psz_value, \
137 i_capability, 0, p_callback, NULL, 0 },
138 #define ADD_INTEGER( name, i_value, p_callback, text, longtext ) \
139 { MODULE_CONFIG_ITEM_INTEGER, name, '\0', text, longtext, NULL, i_value, \
140 0, p_callback, NULL, 0 },
141 #define ADD_FLOAT( name, f_value, p_callback, text, longtext ) \
142 { MODULE_CONFIG_ITEM_FLOAT, name, '\0', text, longtext, NULL, 0, f_value, \
143 p_callback, NULL, 0 },
144 #define ADD_BOOL( name, p_callback, text, longtext ) \
145 { MODULE_CONFIG_ITEM_BOOL, name, '\0', text, longtext, NULL, 0, 0, \
146 p_callback, NULL, 0 },
147 #define ADD_STRING_WITH_SHORT( name, ch, value, p_callback, text, longtext ) \
148 { MODULE_CONFIG_ITEM_STRING, name, ch, text, longtext, value, 0, 0, \
149 p_callback, NULL, 0 },
150 #define ADD_FILE_WITH_SHORT( name, ch, psz_value, p_callback, text, longtext ) \
151 { MODULE_CONFIG_ITEM_FILE, name, ch, text, longtext, psz_value, 0, 0, \
152 p_callback, NULL, 0 },
153 #define ADD_MODULE_WITH_SHORT( name, ch, i_capability, psz_value, p_callback, \
154 text, longtext) \
155 { MODULE_CONFIG_ITEM_MODULE, name, ch, text, longtext, psz_value, \
156 i_capability, 0, p_callback, NULL, 0 },
157 #define ADD_INTEGER_WITH_SHORT( name, ch, i_value, p_callback, text, \
158 longtext ) \
159 { MODULE_CONFIG_ITEM_INTEGER, name, ch, text, longtext, NULL, i_value, 0, \
160 p_callback, NULL, 0 },
161 #define ADD_FLOAT_WITH_SHORT( name, f_value, p_callback, text, longtext ) \
162 { MODULE_CONFIG_ITEM_FLOAT, name, ch, text, longtext, NULL, 0, f_value, \
163 p_callback, NULL, 0 },
164 #define ADD_BOOL_WITH_SHORT( name, ch, p_callback, text, longtext ) \
165 { MODULE_CONFIG_ITEM_BOOL, name, ch, text, longtext, NULL, 0, 0, \
166 p_callback, NULL, 0 },