]> git.sesse.net Git - vlc/blob - include/configuration.h
*Adaptation to new configuration scheme for dvd, dvdread and spdif
[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.1 2002/02/24 20:51:09 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 /* Mandatory last part of the structure */
31 #define MODULE_CONFIG_ITEM_END              0x000   /* End of config */
32
33 /* Configuration widgets */
34 #define MODULE_CONFIG_ITEM_CATEGORY         0x0001  /* Start of new category */
35 #define MODULE_CONFIG_ITEM_SUBCATEGORY      0x0002  /* Start of sub-category */
36 #define MODULE_CONFIG_ITEM_SUBCATEGORY_END  0x0003  /* End of sub-category */
37 #define MODULE_CONFIG_ITEM_STRING           0x0004  /* String option */
38 #define MODULE_CONFIG_ITEM_FILE             0x0005  /* File option */
39 #define MODULE_CONFIG_ITEM_PLUGIN           0x0006  /* Plugin option */
40 #define MODULE_CONFIG_ITEM_INTEGER          0x0007  /* Integer option */
41 #define MODULE_CONFIG_ITEM_BOOL             0x0008  /* Bool option */
42 #define MODULE_CONFIG_ITEM_ALIAS            0x0009  /* Alias option */
43
44 typedef struct module_config_s
45 {
46     int         i_type;                                /* Configuration type */
47     char *      psz_name;                                     /* Option name */
48     char *      psz_text;       /* Short comment on the configuration option */
49     char *      psz_longtext;    /* Long comment on the configuration option */
50     char *      psz_value;                                   /* Option value */
51     int         i_value;                                     /* Option value */
52     void *      p_callback;      /* Function to call when commiting a change */
53     boolean_t   b_dirty;           /* Dirty flag to indicate a config change */
54
55 } module_config_t;
56
57 /*****************************************************************************
58  * Prototypes - these methods are used to get, set or manipulate configuration
59  * data.
60  *****************************************************************************/
61 #ifndef PLUGIN
62 int    config_GetIntVariable( const char *psz_name );
63 char * config_GetPszVariable( const char *psz_name );
64 void   config_PutIntVariable( const char *psz_name, int i_value );
65 void   config_PutPszVariable( const char *psz_name, char *psz_value );
66
67 module_config_t *config_FindConfig( const char *psz_name );
68 module_config_t *config_Duplicate ( module_config_t *p_config_orig,
69                                     int i_config_options );
70 #else
71 #   define config_GetIntVariable p_symbols->config_GetIntVariable
72 #   define config_PutIntVariable p_symbols->config_PutIntVariable
73 #   define config_GetPszVariable p_symbols->config_GetPszVariable
74 #   define config_PutPszVariable p_symbols->config_PutPszVariable
75 #   define config_Duplicate    p_symbols->config_Duplicate
76 #   define config_FindConfig   p_symbols->config_FindConfig
77 #endif
78
79 /*****************************************************************************
80  * Macros used to build the configuration structure.
81  *
82  * Note that internally we support only 2 types of config data: int and string.
83  *   The other types declared here just map to one of these 2 basic types but
84  *   have the advantage of also providing very good hints to a configuration
85  *   interface so as to make it more user friendly.
86  * The configuration structure also includes category hints. These hints can
87  *   provide a configuration inteface with some very useful data and also allow
88  *   for a more user friendly interface.
89  *****************************************************************************/
90
91 #define MODULE_CONFIG_START \
92     static module_config_t p_config[] = {
93
94 #define MODULE_CONFIG_STOP \
95     { MODULE_CONFIG_ITEM_END, NULL, NULL, NULL, NULL, 0, NULL, 0 } };
96
97 #define ADD_CATEGORY_HINT( text, longtext ) \
98     { MODULE_CONFIG_ITEM_CATEGORY, NULL, text, longtext, NULL, 0, NULL, 0 },
99 #define ADD_SUBCATEGORY_HINT( text, longtext ) \
100     { MODULE_CONFIG_ITEM_SUBCATEGORY, NULL, text, longtext, NULL, 0, NULL, 0 },
101 #define END_SUBCATEGORY_HINT \
102     { MODULE_CONFIG_ITEM_SUBCATEGORY_END, NULL, NULL, NULL, NULL, 0, NULL, 0 },
103 #define ADD_STRING( name, value, p_callback, text, longtext ) \
104     { MODULE_CONFIG_ITEM_STRING, name, text, longtext, value, 0, \
105       p_callback, 0 },
106 #define ADD_FILE( name, psz_value, p_callback, text, longtext ) \
107     { MODULE_CONFIG_ITEM_FILE, name, text, longtext, psz_value, 0, \
108       p_callback, 0 },
109 #define ADD_PLUGIN( name, i_capability, psz_value, p_callback, text, longtext)\
110     { MODULE_CONFIG_ITEM_PLUGIN, name, text, longtext, psz_value, \
111       i_capability, p_callback, 0 },
112 #define ADD_INTEGER( name, i_value, p_callback, text, longtext ) \
113     { MODULE_CONFIG_ITEM_INTEGER, name, text, longtext, NULL, i_value, \
114       p_callback, 0 },
115 #define ADD_BOOL( name, p_callback, text, longtext ) \
116     { MODULE_CONFIG_ITEM_BOOL, name, text, longtext, NULL, 0, p_callback, 0 },