aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_config/Ecore_Config.h
blob: 6733d7bdd9daec8ad1799359c100e6fccf807ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#ifndef _ECORE_CONFIG_H
# define _ECORE_CONFIG_H

#ifdef EAPI
#undef EAPI
#endif
#ifdef _MSC_VER
# ifdef BUILDING_DLL
#  define EAPI __declspec(dllexport)
# else
#  define EAPI __declspec(dllimport)
# endif
#else
# ifdef __GNUC__
#  if __GNUC__ >= 4
#   define EAPI __attribute__ ((visibility("default")))
#  else
#   define EAPI
#  endif
# else
#  define EAPI
# endif
#endif

/**
 * @file 
 * @brief Provides the Enlightened Property Library.
 *
 * This file provies all headers and structs for use with Ecore_Config.
 * Using individual header files should not be necessary.
 */

# define DIR_DELIMITER      '/'
# define ECORE_CONFIG_FLOAT_PRECISION 1000

/* FIXME: this should only be included if evas is present */
# include <Evas.h>

# define ECORE_CONFIG_GLOBAL_ID "_system"

/* structures */

/**
 * Valid configuration property types.
 */
typedef enum Ecore_Config_Type
{
   ECORE_CONFIG_NIL = 0,			/**< Property with no value. */
   ECORE_CONFIG_INT = 1,			/**< Integer property type. */
   ECORE_CONFIG_FLT = 2,			/**< Float property type. */
   ECORE_CONFIG_STR = 3,			/**< String property type. */
   ECORE_CONFIG_RGB = 4,			/**< Colour property type. */
   ECORE_CONFIG_THM = 5,			/**< Theme property type. */
   ECORE_CONFIG_BLN = 6,			/**< Boolean property type. */
   ECORE_CONFIG_SCT = 7,      /**< Structure property type */
} Ecore_Config_Type;

typedef enum Ecore_Config_Flag
{
   ECORE_CONFIG_FLAG_NONE = 0,
   ECORE_CONFIG_FLAG_BOUNDS = 1,
   ECORE_CONFIG_FLAG_MODIFIED = 2,
   ECORE_CONFIG_FLAG_SYSTEM = 4,
   ECORE_CONFIG_FLAG_CMDLN = 8
} Ecore_Config_Flag;

/**
 * Property change callback function prototype.
 */
typedef int         (*Ecore_Config_Listener) (const char *key,
					      const Ecore_Config_Type type,
					      const int tag, void *data);

typedef struct Ecore_Config_Listener_List
{
   Ecore_Config_Listener listener;
   const char         *name;
   void               *data;
   int                 tag;
   struct Ecore_Config_Listener_List *next;
} Ecore_Config_Listener_List;

/**
 * The actual property for storing a key-value pair.
 */
typedef struct Ecore_Config_Prop
{
   char               *key;	/* Property key. */
   char               *description;	/* Description set by ecore_config_descibe. */
   char                short_opt;	/* short identifier on command line (-f) */
   char               *long_opt;	/* long identifier on command line (--foo) */
   char               *ptr;	/* Used as the value when the property is a string or theme. */
   Ecore_Config_Type   type;	/* Property type. */
   long                val;	/* Used as the value when the property is an integer, float or colour. */
   long                lo;	/* Lower bound for the value when the property is an integer or float. */
   long                hi;	/* Higher bound for the value when the property is an integer or float. */
   long                step;	/* Increment for the value when the property is an integer or float. */
   Ecore_Config_Flag   flags;	/// < Configuration flags.
   Ecore_Config_Listener_List *listeners;	/* List of change listeners. */
   void               *data;	/// < Stores extra data for the property.
   struct Ecore_Config_Prop *parent; /* if we are in a struct we have a parent to notify of changes etc */
   struct Ecore_Config_Prop *next;	/* Pointer to the next property in the list. */
} Ecore_Config_Prop;

/*
 * A container for a list of properties.  Provided so that an
 * application can use different set of properties at any time. This
 * is useful for multiple window support.
 */
typedef struct Ecore_Config_Bundle
{
   char               *identifier;	/* Identifier for this set of properties (window ID for example) */
   char               *owner;	/* This is used to store the application name related to the bundle */
   long                serial;	/* Unique identifier to identify bundle */
   Ecore_Config_Prop  *data;	/* Pointer to root of property list */
   void               *user_data;	/* App specific pointer to "other data" */
   struct Ecore_Config_Bundle *next;	/* Pointer to next bundle in this application */
} Ecore_Config_Bundle;

typedef struct Ecore_Config_Server
{
   void               *server;
   char               *name;
   Ecore_Config_Bundle *bundles;	/* data anchor */
   struct Ecore_Config_Server *next;
} Ecore_Config_Server;

# ifdef __cplusplus
extern              "C"
{
# endif

/* global ptrs to save passing them through the API */
   EAPI extern Ecore_Config_Server *__ecore_config_server_global;
   EAPI extern Ecore_Config_Server *__ecore_config_server_local;
   EAPI extern Ecore_Config_Bundle *__ecore_config_bundle_local;
   EAPI extern char        *__ecore_config_app_name;

   EAPI Ecore_Config_Prop  *ecore_config_get(const char *key);
   EAPI const char         *ecore_config_type_get(const Ecore_Config_Prop *e);
   EAPI int                 ecore_config_boolean_get(const char *key);
   EAPI char               *ecore_config_string_get(const char *key);
   EAPI long                ecore_config_int_get(const char *key);
   EAPI int                 ecore_config_argb_get(const char *key, int *a, int *r,
						  int *g, int *b);
   EAPI long                ecore_config_argbint_get(const char *key);
   EAPI char               *ecore_config_argbstr_get(const char *key);
   EAPI float               ecore_config_float_get(const char *key);
   EAPI char               *ecore_config_theme_get(const char *key);
   EAPI char               *ecore_config_as_string_get(const char *key);
   EAPI int                 ecore_config_bound(Ecore_Config_Prop *e);
   EAPI int                 ecore_config_describe(const char *key, const char *desc);
   EAPI int                 ecore_config_short_opt_set(const char *key,
						       char short_opt);
   EAPI int                 ecore_config_long_opt_set(const char *key,
						      const char *long_opt);
   EAPI int                 ecore_config_set(const char *key, const char *val);
   EAPI int                 ecore_config_typed_set(const char *key, const void *val,
						   int type);
   EAPI int                 ecore_config_boolean_set(const char *key, int val);
   EAPI int                 ecore_config_string_set(const char *key, const char *val);
   EAPI int                 ecore_config_int_set(const char *key, int val);
   EAPI int                 ecore_config_argb_set(const char *key, int a, int r, int g, int b);
   EAPI int                 ecore_config_argbint_set(const char *key, long argb);
   EAPI int                 ecore_config_argbstr_set(const char *key, const char *val);
   EAPI int                 ecore_config_float_set(const char *key, float val);
   EAPI int                 ecore_config_theme_set(const char *key, const char *val);
   EAPI int                 ecore_config_theme_preview_group_set(const char *key,
								 const char *group);
   EAPI int                 ecore_config_as_string_set(const char *key, const char *val);

   EAPI int                 ecore_config_default(const char *key, const char *val,
						 float lo, float hi, float step);
   EAPI int                 ecore_config_typed_default(const char *key, const void *val,
						       int type);
   EAPI int                 ecore_config_boolean_default(const char *key, int val);
   EAPI int                 ecore_config_int_default(const char *key, int val);
   EAPI int                 ecore_config_int_default_bound(const char *key, int val,
							   int lo, int hi, int step);
   EAPI int                 ecore_config_string_default(const char *key, const char *val);
   EAPI int                 ecore_config_float_default(const char *key, float val);
   EAPI int                 ecore_config_float_default_bound(const char *key,
							     float val, float lo,
							     float hi, float step);
   EAPI int                 ecore_config_argb_default(const char *key, int a, int r, int g, int b);
   EAPI int                 ecore_config_argbint_default(const char *key, long argb);
   EAPI int                 ecore_config_argbstr_default(const char *key, const char *val);
   EAPI int                 ecore_config_theme_default(const char *key, const char *val);
   EAPI int                 ecore_config_struct_default(const char *key);
   EAPI int                 ecore_config_struct_int_add(const char *key, const char *name, int val);
   EAPI int                 ecore_config_struct_float_add(const char *key, const char *name, float val);
   EAPI int                 ecore_config_struct_create(const char *key);
   EAPI int                 ecore_config_struct_string_add(const char *key, const char *name, const char* val);
   EAPI int                 ecore_config_struct_theme_add(const char *key, const char *name, const char* val);
   EAPI int                 ecore_config_struct_argb_add(const char *key, const char *name, int a, int r, int g, int b);
   EAPI int                 ecore_config_struct_boolean_add(const char *key, const char *name, int val);
   EAPI int                 ecore_config_struct_get(const char *key, void *data);

   EAPI int                 ecore_config_listen(const char *name, const char *key,
						Ecore_Config_Listener listener,
						int tag, void *data);
   EAPI int                 ecore_config_deaf(const char *name, const char *key,
					      Ecore_Config_Listener listener);
   EAPI Ecore_Config_Prop  *ecore_config_dst(Ecore_Config_Prop *e);
   EAPI int                 ecore_config_type_guess(const char *key, const char *val);

   EAPI Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv,
						     const char *id);
   EAPI Ecore_Config_Bundle *ecore_config_bundle_1st_get(Ecore_Config_Server *srv);
   EAPI Ecore_Config_Bundle *ecore_config_bundle_next_get(Ecore_Config_Bundle *ns);
   EAPI Ecore_Config_Bundle *ecore_config_bundle_by_serial_get(Ecore_Config_Server *srv,
							       long serial);
   EAPI Ecore_Config_Bundle *ecore_config_bundle_by_label_get(Ecore_Config_Server *srv,
							      const char *label);
   EAPI long                ecore_config_bundle_serial_get(Ecore_Config_Bundle *ns);
   EAPI char               *ecore_config_bundle_label_get(Ecore_Config_Bundle *ns);

   EAPI int                 ecore_config_init(const char *name);
   EAPI int                 ecore_config_shutdown(void);

   EAPI int                 ecore_config_system_init(void);
   EAPI int                 ecore_config_system_shutdown(void);

   EAPI int                 ecore_config_load(void);
   EAPI int                 ecore_config_file_load(const char *file);
   EAPI int                 ecore_config_save(void);
   EAPI int                 ecore_config_file_save(const char *file);

/* error codes */
# define ECORE_CONFIG_ERR_NOTSUPP     (-16)
# define ECORE_CONFIG_ERR_NOFILE      (-15)
# define ECORE_CONFIG_ERR_META_DLFAIL (-14)
# define ECORE_CONFIG_ERR_META_FILE   (-13)
# define ECORE_CONFIG_ERR_META_FORMAT (-12)
# define ECORE_CONFIG_ERR_MONMIS      (-11)
# define ECORE_CONFIG_ERR_NOEXEC      (-10)
# define ECORE_CONFIG_ERR_PARTIAL      (-9)
# define ECORE_CONFIG_ERR_PATHEX       (-8)
# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
# define ECORE_CONFIG_ERR_MUTEX        (-6)
# define ECORE_CONFIG_ERR_NOTFOUND     (-5)	/* Error indicating that the item searched for could not be found. */
# define ECORE_CONFIG_ERR_OOM          (-4)	/* Error given when the program runs out of memory. */
# define ECORE_CONFIG_ERR_IGNORED      (-3)	/* Error occurred, but was ignored. */
# define ECORE_CONFIG_ERR_NODATA       (-2)	/* Error given when necessary data is not provided. */
# define ECORE_CONFIG_ERR_FAIL         (-1)	/* Failure result. */
# define ECORE_CONFIG_ERR_SUCC          (0)	/* Success result. */

# define ECORE_CONFIG_PARSE_HELP       (-2)	/* Help was displayed */
# define ECORE_CONFIG_PARSE_EXIT       (-1)	/* An error occurred */
# define ECORE_CONFIG_PARSE_CONTINUE    (0)	/* Arguments parsed successfully */

/* convenience mathods in convenience.c */
   /* FIXME: this should only be included if evas is present */
   EAPI int                 ecore_config_evas_font_path_apply(Evas *evas);
   EAPI char               *ecore_config_theme_search_path_get(void);
   EAPI int                 ecore_config_theme_search_path_append(const char *append);
     
   EAPI char               *ecore_config_theme_default_path_get(void);
   EAPI char               *ecore_config_theme_with_path_from_name_get(char *name);
   EAPI char               *ecore_config_theme_with_path_get(const char *key);
   EAPI void                ecore_config_args_display(void);
   EAPI int                 ecore_config_args_parse(void);
   EAPI void                ecore_config_args_callback_str_add(char short_opt,
							       char *long_opt, char *desc,
							       void (*func)(char *val, void *data),
							       void *data);
   EAPI void                ecore_config_args_callback_noarg_add(char short_opt,
								 char *long_opt, char *desc,
								 void (*func)(char *val, void *data),
								 void *data);
   EAPI void                ecore_config_app_describe(char *description);

   EAPI int                 ecore_config_create(const char *key, void *val,
						char short_opt, char *long_opt,
						char *desc);
   EAPI int                 ecore_config_typed_create(const char *key, void *val,
						      int type, char short_opt,
						      char *long_opt, char *desc);
   EAPI int                 ecore_config_boolean_create(const char *key, int val,
							char short_opt, char *long_opt,
							char *desc);
   EAPI int                 ecore_config_int_create(const char *key, int val,
						    char short_opt, char *long_opt,
						    char *desc);
   EAPI int                 ecore_config_int_create_bound(const char *key, int val,
							  int low, int high,
							  int step, char short_opt,
							  char *long_opt,
							  char *desc);
   EAPI int                 ecore_config_string_create(const char *key, char *val,
						       char short_opt,
						       char *long_opt, char *desc);
   EAPI int                 ecore_config_float_create(const char *key, float val,
						      char short_opt, char *long_opt,
						      char *desc);
   EAPI int                 ecore_config_float_create_bound(const char *key,
							    float val, float low,
							    float high, float step,
							    char short_opt,
							    char *long_opt,
							    char *desc);
   EAPI int                 ecore_config_argb_create(const char *key, char *val,
						     char short_opt, char *long_opt,
						     char *desc);
   EAPI int                 ecore_config_theme_create(const char *key, char *val,
						      char short_opt, char *long_opt,
						      char *desc);

# ifdef __cplusplus
}
# endif
#endif