xine-lib: xine-lib-1.2.13/include/xine/configfile.h Source File

xine-lib 1.2.13-20230125hg15249

configfile.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2000-2022 the xine project
3 *
4 * This file is part of xine, a free video player.
5 *
6 * xine is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * xine is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 *
20 * config file management
21 */
22
23#ifndef HAVE_CONFIGFILE_H
24#define HAVE_CONFIGFILE_H
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include <pthread.h>
31
32#include <xine.h>
33
34#define CONFIG_FILE_VERSION 2
35
40#define XINE_CONFIG_SECURITY 30
41
42
43 typedef struct cfg_entry_s cfg_entry_t;
44 typedef struct config_values_s config_values_t;
45
46 struct cfg_entry_s {
47 cfg_entry_t *next;
48 config_values_t *config;
49
50 char *key;
51 int type;
52
54 int exp_level;
55
57 char *unknown_value;
58
60 char *str_value;
61 char *str_default;
62
64 int num_value;
65 int num_default;
66
68 int range_min;
69 int range_max; /* also used for enum */
70
72 char **enum_values;
73
75 char *description;
76 char *help;
77
79 xine_config_cb_t callback;
80 void *callback_data;
81};
82
83 struct config_values_s {
84
85 /*
86 * register config values
87 *
88 * these functions return the current value of the
89 * registered item, i.e. the default value if it was
90 * not found in the config file or the current value
91 * from the config file otherwise
92 * NOTE: config entries registered during class init of
93 * input, demux, decoder, or post plugins will _always_
94 * show up in the application - even if that plugin is
95 * not currently loaded.
96 *
97 * NOTE on callbacks:
98 * - callback shall be safe to run from _any_ thread.
99 * There will be no 2 calls at the same time, though.
100 * - callback shall be safe to call at any time between
101 * entering register_foo (), and leaving unregister_foo ().
102 * - There can be multiple callbacks for the same key.
103 * They will run in no fixed order.
104 * - if cb_data is a real pointer, make sure it points to
105 * valid thread shared memory (malloc'ed or static).
106 * Plain stack variables will not work, and may cause
107 * strange malfunction.
108 */
109
110 char* (*register_string) (config_values_t *self,
111 const char *key,
112 const char *def_value,
113 const char *description,
114 const char *help,
115 int exp_level,
116 xine_config_cb_t changed_cb,
117 void *cb_data);
118
119 char* (*register_filename) (config_values_t *self,
120 const char *key,
121 const char *def_value,
122 int req_type,
123 const char *description,
124 const char *help,
125 int exp_level,
126 xine_config_cb_t changed_cb,
127 void *cb_data);
128
129 int (*register_range) (config_values_t *self,
130 const char *key,
131 int def_value,
132 int min, int max,
133 const char *description,
134 const char *help,
135 int exp_level,
136 xine_config_cb_t changed_cb,
137 void *cb_data);
138
139 int (*register_enum) (config_values_t *self,
140 const char *key,
141 int def_value,
142 char **values,
143 const char *description,
144 const char *help,
145 int exp_level,
146 xine_config_cb_t changed_cb,
147 void *cb_data);
148
149 int (*register_num) (config_values_t *self,
150 const char *key,
151 int def_value,
152 const char *description,
153 const char *help,
154 int exp_level,
155 xine_config_cb_t changed_cb,
156 void *cb_data);
157
158 int (*register_bool) (config_values_t *self,
159 const char *key,
160 int def_value,
161 const char *description,
162 const char *help,
163 int exp_level,
164 xine_config_cb_t changed_cb,
165 void *cb_data);
166
168 void (*register_entry) (config_values_t *self, cfg_entry_t* entry);
169
171 void (*update_num) (config_values_t *self, const char *key, int value);
172
174 void (*update_string) (config_values_t *self, const char *key, const char *value);
175
177 int (*parse_enum) (const char *str, const char **values);
178
186 cfg_entry_t* (*lookup_entry) (config_values_t *self, const char *key);
187
195 void (*unregister_callback) (config_values_t *self, const char *key);
196
200 void (*dispose) (config_values_t *self);
201
205 void (*set_new_entry_callback) (config_values_t *self, xine_config_cb_t new_entry_cb, void *cb_data);
206
210 void (*unset_new_entry_callback) (config_values_t *self);
211
216 char* (*get_serialized_entry) (config_values_t *self, const char *key);
217
223 char* (*register_serialized_entry) (config_values_t *self, const char *value);
224
228 cfg_entry_t *first, *last, *cur;
229
233 xine_config_cb_t new_entry_cb;
234 void *new_entry_cbdata;
235
239 pthread_mutex_t config_lock;
240
244 int current_version;
245
253 int (*unregister_callbacks) (config_values_t *self,
254 const char *key, xine_config_cb_t changed_cb, void *cb_data, size_t cb_data_size);
255
259 xine_t *xine;
260
266 char * (*lookup_string)(config_values_t *, const char *key);
267 void (*free_string)(config_values_t *, char **);
268
270 int (*lookup_num)(config_values_t *, const char *key, int def_value);
271};
272
277 config_values_t *_x_config_init (void);
278
284int _x_config_change_opt(config_values_t *config, const char *opt);
285
287void _x_config_unregister_cb_class_d (config_values_t *config, void *callback_data) XINE_PROTECTED;
288void _x_config_unregister_cb_class_p (config_values_t *config, xine_config_cb_t callback) XINE_PROTECTED;
289
290#ifdef __cplusplus
291}
292#endif
293
294#endif
_x_config_unregister_cb_class_d
void _x_config_unregister_cb_class_d(config_values_t *config, void *callback_data)
Definition configfile.c:2007
_x_config_change_opt
int _x_config_change_opt(config_values_t *config, const char *opt)
interpret stream_setup part of mrls for config value changes
Definition configfile.c:2536
_x_config_unregister_cb_class_p
void _x_config_unregister_cb_class_p(config_values_t *config, xine_config_cb_t callback)
Definition configfile.c:2017
_x_config_init
config_values_t * _x_config_init(void)
allocate and init a new xine config object
Definition configfile.c:2478
XINE_PROTECTED
#define XINE_PROTECTED
Definition attributes.h:75
cfg_entry_s
Definition configfile.h:46
cfg_entry_s::num_default
int num_default
Definition configfile.h:65
cfg_entry_s::help
char * help
Definition configfile.h:76
cfg_entry_s::next
cfg_entry_t * next
Definition configfile.h:47
cfg_entry_s::range_min
int range_min
Definition configfile.h:68
cfg_entry_s::description
char * description
Definition configfile.h:75
cfg_entry_s::enum_values
char ** enum_values
Definition configfile.h:72
cfg_entry_s::str_default
char * str_default
Definition configfile.h:61
cfg_entry_s::config
config_values_t * config
Definition configfile.h:48
cfg_entry_s::callback
xine_config_cb_t callback
Definition configfile.h:79
cfg_entry_s::range_max
int range_max
Definition configfile.h:69
cfg_entry_s::type
int type
Definition configfile.h:51
cfg_entry_s::key
char * key
Definition configfile.h:50
cfg_entry_s::callback_data
void * callback_data
Definition configfile.h:80
cfg_entry_s::num_value
int num_value
Definition configfile.h:64
cfg_entry_s::exp_level
int exp_level
Definition configfile.h:54
cfg_entry_s::unknown_value
char * unknown_value
Definition configfile.h:57
cfg_entry_s::str_value
char * str_value
Definition configfile.h:60
config_values_s
Definition configfile.h:83
config_values_s::new_entry_cbdata
void * new_entry_cbdata
Definition configfile.h:234
config_values_s::register_enum
int(* register_enum)(config_values_t *self, const char *key, int def_value, char **values, const char *description, const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data)
Definition configfile.h:139
config_values_s::update_num
void(* update_num)(config_values_t *self, const char *key, int value)
Definition configfile.h:171
config_values_s::register_bool
int(* register_bool)(config_values_t *self, const char *key, int def_value, const char *description, const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data)
Definition configfile.h:158
config_values_s::cur
cfg_entry_t * cur
Definition configfile.h:228
config_values_s::register_range
int(* register_range)(config_values_t *self, const char *key, int def_value, int min, int max, const char *description, const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data)
Definition configfile.h:129
config_values_s::unset_new_entry_callback
void(* unset_new_entry_callback)(config_values_t *self)
Definition configfile.h:210
config_values_s::lookup_num
int(* lookup_num)(config_values_t *, const char *key, int def_value)
Definition configfile.h:270
config_values_s::register_entry
void(* register_entry)(config_values_t *self, cfg_entry_t *entry)
Definition configfile.h:168
config_values_s::dispose
void(* dispose)(config_values_t *self)
Definition configfile.h:200
config_values_s::unregister_callback
void(* unregister_callback)(config_values_t *self, const char *key)
Definition configfile.h:195
config_values_s::update_string
void(* update_string)(config_values_t *self, const char *key, const char *value)
Definition configfile.h:174
config_values_s::set_new_entry_callback
void(* set_new_entry_callback)(config_values_t *self, xine_config_cb_t new_entry_cb, void *cb_data)
Definition configfile.h:205
config_values_s::first
cfg_entry_t * first
Definition configfile.h:228
config_values_s::free_string
void(* free_string)(config_values_t *, char **)
Definition configfile.h:267
config_values_s::xine
xine_t * xine
Definition configfile.h:259
config_values_s::parse_enum
int(* parse_enum)(const char *str, const char **values)
Definition configfile.h:177
config_values_s::register_num
int(* register_num)(config_values_t *self, const char *key, int def_value, const char *description, const char *help, int exp_level, xine_config_cb_t changed_cb, void *cb_data)
Definition configfile.h:149
config_values_s::current_version
int current_version
Definition configfile.h:244
config_values_s::new_entry_cb
xine_config_cb_t new_entry_cb
Definition configfile.h:233
config_values_s::config_lock
pthread_mutex_t config_lock
Definition configfile.h:239
config_values_s::unregister_callbacks
int(* unregister_callbacks)(config_values_t *self, const char *key, xine_config_cb_t changed_cb, void *cb_data, size_t cb_data_size)
Definition configfile.h:253
config_values_s::last
cfg_entry_t * last
Definition configfile.h:228
xine_s
Definition xine_internal.h:80
xine.h
xine_config_cb_t
void(* xine_config_cb_t)(void *user_data, xine_cfg_entry_t *entry)
Definition xine.h:1647
key
char key[16]
Definition xine_speex_decoder.c:94