1 /*****************************************************************************
2 * variables.h: variables handling
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: variables.h,v 1.12 2003/03/11 23:56:53 gbazin Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 typedef struct callback_entry_t callback_entry_t;
26 /*****************************************************************************
27 * vlc_value_t is the common union for variable values; variable_t is the
28 * structure describing a variable.
29 *****************************************************************************/
32 /* The variable's exported value */
35 /* The variable unique name, (almost) unique hashed value, and type */
40 /* A pointer to a comparison function, a duplication function, and
41 * a deallocation function */
42 int ( * pf_cmp ) ( vlc_value_t, vlc_value_t );
43 void ( * pf_dup ) ( vlc_value_t * );
44 void ( * pf_free ) ( vlc_value_t * );
46 /* Creation count: we only destroy the variable if it reaches 0 */
49 /* If the variable has min/max/step values */
50 vlc_value_t min, max, step;
52 /* If the variable is to be chosen in a list */
56 /* Set to TRUE if the variable is in a callback */
57 vlc_bool_t b_incallback;
59 /* Registered callbacks */
61 callback_entry_t * p_entries;
64 /*****************************************************************************
65 * Variable types - probably very incomplete
66 *****************************************************************************/
67 #define VLC_VAR_TYPE 0x00ff
68 #define VLC_VAR_FLAGS 0xff00
71 #define VLC_VAR_VOID 0x0010
72 #define VLC_VAR_BOOL 0x0020
73 #define VLC_VAR_INTEGER 0x0030
74 #define VLC_VAR_STRING 0x0040
75 #define VLC_VAR_MODULE 0x0041
76 #define VLC_VAR_FILE 0x0042
77 #define VLC_VAR_DIRECTORY 0x0043
78 #define VLC_VAR_VARIABLE 0x0044
79 #define VLC_VAR_FLOAT 0x0050
80 #define VLC_VAR_TIME 0x0060
81 #define VLC_VAR_ADDRESS 0x0070
82 #define VLC_VAR_MUTEX 0x0080
85 #define VLC_VAR_HASCHOICE 0x0100
86 #define VLC_VAR_HASMIN 0x0200
87 #define VLC_VAR_HASMAX 0x0400
88 #define VLC_VAR_HASSTEP 0x0800
90 #define VLC_VAR_ISLIST 0x1000
91 #define VLC_VAR_ISCOMMAND 0x2000
92 #define VLC_VAR_ISCONFIG 0x2000
94 /*****************************************************************************
96 *****************************************************************************/
97 #define VLC_VAR_SETMIN 0x0010
98 #define VLC_VAR_SETMAX 0x0011
99 #define VLC_VAR_SETSTEP 0x0012
101 #define VLC_VAR_SETVALUE 0x0013
103 #define VLC_VAR_ADDCHOICE 0x0020
104 #define VLC_VAR_DELCHOICE 0x0021
105 #define VLC_VAR_CLEARCHOICES 0x0022
106 #define VLC_VAR_SETDEFAULT 0x0023
107 #define VLC_VAR_GETLIST 0x0024
108 #define VLC_VAR_FREELIST 0x0025
110 /*****************************************************************************
112 *****************************************************************************/
113 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
114 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
116 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
118 VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
119 VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
120 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
122 #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
123 #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
125 #define var_Change(a,b,c,d) __var_Change( VLC_OBJECT(a), b, c, d )
127 #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
128 #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
129 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
131 /*****************************************************************************
133 *****************************************************************************
134 * int MyCallback( vlc_object_t *p_this,
135 * char const *psz_variable,
136 * vlc_value_t oldvalue,
137 * vlc_value_t newvalue,
139 *****************************************************************************/
140 VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
141 VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
143 #define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
144 #define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )