1 /*****************************************************************************
2 * variables.h: variables handling
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
5 * $Id: variables.h,v 1.9 2002/12/07 15:25:26 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 */
55 vlc_value_t *pp_choices;
57 /* Set to TRUE if the variable is in a callback */
58 vlc_bool_t b_incallback;
60 /* Registered callbacks */
62 callback_entry_t * p_entries;
65 /*****************************************************************************
66 * Variable types - probably very incomplete
67 *****************************************************************************/
68 #define VLC_VAR_TYPE 0x00ff
69 #define VLC_VAR_FLAGS 0xff00
72 #define VLC_VAR_VOID 0x0010
73 #define VLC_VAR_BOOL 0x0020
74 #define VLC_VAR_INTEGER 0x0030
75 #define VLC_VAR_STRING 0x0040
76 #define VLC_VAR_MODULE 0x0041
77 #define VLC_VAR_FILE 0x0042
78 #define VLC_VAR_DIRECTORY 0x0043
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_ISCOMMAND 0x1000
92 /*****************************************************************************
94 *****************************************************************************/
95 #define VLC_VAR_SETMIN 0x0010
96 #define VLC_VAR_SETMAX 0x0011
97 #define VLC_VAR_SETSTEP 0x0012
99 #define VLC_VAR_ADDCHOICE 0x0020
100 #define VLC_VAR_DELCHOICE 0x0021
101 #define VLC_VAR_SETDEFAULT 0x0022
102 #define VLC_VAR_GETLIST 0x0023
103 #define VLC_VAR_FREELIST 0x0024
105 /*****************************************************************************
107 *****************************************************************************/
108 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
109 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
111 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
113 VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
114 VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
115 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
117 #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
118 #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
120 #define var_Change(a,b,c,d) __var_Change( VLC_OBJECT(a), b, c, d )
122 #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
123 #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
124 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
126 /*****************************************************************************
128 *****************************************************************************
129 * int MyCallback( vlc_object_t *p_this,
130 * char const *psz_variable,
131 * vlc_value_t oldvalue,
132 * vlc_value_t newvalue,
134 *****************************************************************************/
135 VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
136 VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
138 #define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
139 #define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )