]> git.sesse.net Git - vlc/blob - include/variables.h
- added a NULL pointer test
[vlc] / include / variables.h
1 /*****************************************************************************
2  * variables.h: variables handling
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: variables.h,v 1.11 2002/12/14 19:34:07 gbazin Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 typedef struct callback_entry_t callback_entry_t;
25
26 /*****************************************************************************
27  * vlc_value_t is the common union for variable values; variable_t is the
28  * structure describing a variable. 
29  *****************************************************************************/
30 struct variable_t
31 {
32     /* The variable's exported value */
33     vlc_value_t  val;
34
35     /* The variable unique name, (almost) unique hashed value, and type */
36     char *       psz_name;
37     uint32_t     i_hash;
38     int          i_type;
39
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 * );
45
46     /* Creation count: we only destroy the variable if it reaches 0 */
47     int          i_usage;
48
49     /* If the variable has min/max/step values */
50     vlc_value_t  min, max, step;
51
52     /* If the variable is to be chosen in a list */
53     int          i_default;
54     vlc_list_t   choices;
55
56     /* Set to TRUE if the variable is in a callback */
57     vlc_bool_t   b_incallback;
58
59     /* Registered callbacks */
60     int                i_entries;
61     callback_entry_t * p_entries;
62 };
63
64 /*****************************************************************************
65  * Variable types - probably very incomplete
66  *****************************************************************************/
67 #define VLC_VAR_TYPE      0x00ff
68 #define VLC_VAR_FLAGS     0xff00
69
70 /* Different types */
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_FLOAT     0x0050
79 #define VLC_VAR_TIME      0x0060
80 #define VLC_VAR_ADDRESS   0x0070
81 #define VLC_VAR_MUTEX     0x0080
82
83 /* Additive flags */
84 #define VLC_VAR_HASCHOICE 0x0100
85 #define VLC_VAR_HASMIN    0x0200
86 #define VLC_VAR_HASMAX    0x0400
87 #define VLC_VAR_HASSTEP   0x0800
88
89 #define VLC_VAR_ISLIST    0x1000
90 #define VLC_VAR_ISCOMMAND 0x2000
91 #define VLC_VAR_ISCONFIG  0x2000
92
93 /*****************************************************************************
94  * Variable actions
95  *****************************************************************************/
96 #define VLC_VAR_SETMIN        0x0010
97 #define VLC_VAR_SETMAX        0x0011
98 #define VLC_VAR_SETSTEP       0x0012
99
100 #define VLC_VAR_ADDCHOICE     0x0020
101 #define VLC_VAR_DELCHOICE     0x0021
102 #define VLC_VAR_SETDEFAULT    0x0022
103 #define VLC_VAR_GETLIST       0x0023
104 #define VLC_VAR_FREELIST      0x0024
105
106 /*****************************************************************************
107  * Prototypes
108  *****************************************************************************/
109 VLC_EXPORT( int, __var_Create, ( vlc_object_t *, const char *, int ) );
110 VLC_EXPORT( int, __var_Destroy, ( vlc_object_t *, const char * ) );
111
112 VLC_EXPORT( int, __var_Change, ( vlc_object_t *, const char *, int, vlc_value_t * ) );
113
114 VLC_EXPORT( int, __var_Type, ( vlc_object_t *, const char * ) );
115 VLC_EXPORT( int, __var_Set, ( vlc_object_t *, const char *, vlc_value_t ) );
116 VLC_EXPORT( int, __var_Get, ( vlc_object_t *, const char *, vlc_value_t * ) );
117
118 #define var_Create(a,b,c) __var_Create( VLC_OBJECT(a), b, c )
119 #define var_Destroy(a,b) __var_Destroy( VLC_OBJECT(a), b )
120
121 #define var_Change(a,b,c,d) __var_Change( VLC_OBJECT(a), b, c, d )
122
123 #define var_Type(a,b) __var_Type( VLC_OBJECT(a), b )
124 #define var_Set(a,b,c) __var_Set( VLC_OBJECT(a), b, c )
125 #define var_Get(a,b,c) __var_Get( VLC_OBJECT(a), b, c )
126
127 /*****************************************************************************
128  * Variable callbacks
129  *****************************************************************************
130  * int MyCallback( vlc_object_t *p_this,
131  *                 char const *psz_variable,
132  *                 vlc_value_t oldvalue,
133  *                 vlc_value_t newvalue,
134  *                 void *p_data);
135  *****************************************************************************/
136 VLC_EXPORT( int, __var_AddCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
137 VLC_EXPORT( int, __var_DelCallback, ( vlc_object_t *, const char *, vlc_callback_t, void * ) );
138
139 #define var_AddCallback(a,b,c,d) __var_AddCallback( VLC_OBJECT(a), b, c, d )
140 #define var_DelCallback(a,b,c,d) __var_DelCallback( VLC_OBJECT(a), b, c, d )
141