summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-12-03 04:02:58 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-12-03 04:02:58 +0000
commitd39d7438c581bab7b0dad7a9a19b2612a633d74a (patch)
tree81adbbf0a5f115bd72039450549e69689620483f /legacy/ecore/src/lib
parentd2db7f68fd042cb4ef38a2e9a561721f9396fa2f (diff)
ecore: is now IN-EFL.
SVN revision: 80004
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/Makefile.am75
-rw-r--r--legacy/ecore/src/lib/ecore/Makefile.am73
-rw-r--r--legacy/ecore/src/lib/ecore_cocoa/Makefile.am29
-rw-r--r--legacy/ecore/src/lib/ecore_con/Makefile.am55
-rw-r--r--legacy/ecore/src/lib/ecore_config/Ecore_Config.h312
-rw-r--r--legacy/ecore/src/lib/ecore_config/Makefile.am62
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config.c1870
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_db.c296
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_extra.c803
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_ipc.h50
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_ipc_ecore.c384
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_ipc_main.c275
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_private.h70
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_storage.c176
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_util.c129
-rw-r--r--legacy/ecore/src/lib/ecore_config/ecore_config_util.h14
-rw-r--r--legacy/ecore/src/lib/ecore_directfb/Makefile.am31
-rw-r--r--legacy/ecore/src/lib/ecore_evas/Makefile.am161
-rw-r--r--legacy/ecore/src/lib/ecore_fb/Makefile.am34
-rw-r--r--legacy/ecore/src/lib/ecore_file/Makefile.am36
-rw-r--r--legacy/ecore/src/lib/ecore_imf/Makefile.am25
-rw-r--r--legacy/ecore/src/lib/ecore_imf_evas/Makefile.am22
-rw-r--r--legacy/ecore/src/lib/ecore_input/Makefile.am25
-rw-r--r--legacy/ecore/src/lib/ecore_input_evas/Makefile.am28
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/Makefile.am31
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/Ecore_Psl1ght.h121
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/Ecore_Psl1ght_Keys.h78
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/Makefile.am30
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/ecore_psl1ght.c859
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/ecore_psl1ght_private.h36
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/gemutil.c281
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/gemutil.h19
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/moveutil.c245
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/moveutil.h43
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/spursutil.c62
-rw-r--r--legacy/ecore/src/lib/ecore_psl1ght/spursutil.h24
-rw-r--r--legacy/ecore/src/lib/ecore_sdl/Makefile.am29
-rw-r--r--legacy/ecore/src/lib/ecore_wayland/Makefile.am33
-rw-r--r--legacy/ecore/src/lib/ecore_win32/Makefile.am41
-rw-r--r--legacy/ecore/src/lib/ecore_wince/Makefile.am31
-rw-r--r--legacy/ecore/src/lib/ecore_x/Makefile.am30
-rw-r--r--legacy/ecore/src/lib/ecore_x/xcb/Makefile.am99
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/Makefile.am94
43 files changed, 0 insertions, 7221 deletions
diff --git a/legacy/ecore/src/lib/Makefile.am b/legacy/ecore/src/lib/Makefile.am
deleted file mode 100644
index d43ad7580b..0000000000
--- a/legacy/ecore/src/lib/Makefile.am
+++ /dev/null
@@ -1,75 +0,0 @@
1## Process this file with automake to produce Makefile.in
2MAINTAINERCLEANFILES = Makefile.in
3SUBDIRS = ecore
4
5if BUILD_ECORE_INPUT
6SUBDIRS += ecore_input
7endif
8
9if BUILD_ECORE_INPUT_EVAS
10SUBDIRS += ecore_input_evas
11endif
12
13if BUILD_ECORE_FB
14SUBDIRS += ecore_fb
15endif
16
17if BUILD_ECORE_DIRECTFB
18SUBDIRS += ecore_directfb
19endif
20
21if BUILD_ECORE_CON
22SUBDIRS += ecore_con
23endif
24
25if BUILD_ECORE_X
26SUBDIRS += ecore_x
27endif
28
29if BUILD_ECORE_WIN32
30SUBDIRS += ecore_win32
31endif
32
33if BUILD_ECORE_WINCE
34SUBDIRS += ecore_wince
35endif
36
37if BUILD_ECORE_SDL
38SUBDIRS += ecore_sdl
39endif
40
41if BUILD_ECORE_PSL1GHT
42SUBDIRS += ecore_psl1ght
43endif
44
45if BUILD_ECORE_COCOA
46SUBDIRS += ecore_cocoa
47endif
48
49if BUILD_ECORE_WAYLAND
50SUBDIRS += ecore_wayland
51endif
52
53if BUILD_ECORE_IPC
54SUBDIRS += ecore_ipc
55endif
56
57if BUILD_ECORE_EVAS
58SUBDIRS += ecore_evas
59endif
60
61if BUILD_ECORE_CONFIG
62SUBDIRS += ecore_config
63endif
64
65if BUILD_ECORE_FILE
66SUBDIRS += ecore_file
67endif
68
69if BUILD_ECORE_IMF
70SUBDIRS += ecore_imf
71endif
72
73if BUILD_ECORE_IMF_EVAS
74SUBDIRS += ecore_imf_evas
75endif
diff --git a/legacy/ecore/src/lib/ecore/Makefile.am b/legacy/ecore/src/lib/ecore/Makefile.am
deleted file mode 100644
index 9e86c87c4f..0000000000
--- a/legacy/ecore/src/lib/ecore/Makefile.am
+++ /dev/null
@@ -1,73 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4@GLIB_CFLAGS@ \
5@EVIL_CFLAGS@ \
6@EINA_CFLAGS@ \
7-DEFL_ECORE_BUILD
8
9AM_CFLAGS = @EFL_PTHREAD_CFLAGS@
10
11lib_LTLIBRARIES = libecore.la
12includes_HEADERS = \
13Ecore.h \
14Ecore_Getopt.h
15includesdir = $(includedir)/ecore-@VMAJ@
16
17libecore_la_SOURCES = \
18ecore.c \
19ecore_alloc.c \
20ecore_anim.c \
21ecore_app.c \
22ecore_events.c \
23ecore_getopt.c \
24ecore_glib.c \
25ecore_idle_enterer.c \
26ecore_idle_exiter.c \
27ecore_idler.c \
28ecore_job.c \
29ecore_main.c \
30ecore_pipe.c \
31ecore_poll.c \
32ecore_time.c \
33ecore_timer.c \
34ecore_thread.c \
35ecore_throttle.c \
36ecore_private.h
37
38if ECORE_HAVE_WIN32
39
40libecore_la_SOURCES += ecore_exe_win32.c
41
42else
43
44if ECORE_HAVE_WINCE
45
46libecore_la_SOURCES += ecore_exe_wince.c
47
48else
49
50if ECORE_HAVE_PS3
51
52libecore_la_SOURCES += ecore_exe_ps3.c
53
54else
55
56if ECORE_HAVE_EXOTIC
57
58libecore_la_SOURCES +=
59
60else
61
62libecore_la_SOURCES += ecore_signal.c ecore_exe.c
63
64endif
65
66endif
67
68endif
69
70endif
71
72libecore_la_LIBADD = @EINA_LIBS@ @EVIL_LIBS@ @GLIB_LIBS@ @WIN32_LIBS@ @LTLIBINTL@ @EFL_PTHREAD_LIBS@ @rt_libs@ -lm
73libecore_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@ @EFL_PTHREAD_LIBS@
diff --git a/legacy/ecore/src/lib/ecore_cocoa/Makefile.am b/legacy/ecore/src/lib/ecore_cocoa/Makefile.am
deleted file mode 100644
index 4ac7b118d6..0000000000
--- a/legacy/ecore/src/lib/ecore_cocoa/Makefile.am
+++ /dev/null
@@ -1,29 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/ecore \
5-I$(top_srcdir)/src/lib/ecore_input \
6-I$(top_builddir)/src/lib/ecore \
7-I$(top_builddir)/src/lib/ecore_input \
8@EVAS_CFLAGS@ \
9@EINA_CFLAGS@
10
11lib_LTLIBRARIES = libecore_cocoa.la
12includes_HEADERS = \
13Ecore_Cocoa.h \
14Ecore_Cocoa_Keys.h
15includesdir = $(includedir)/ecore-@VMAJ@
16
17libecore_cocoa_la_SOURCES = \
18ecore_cocoa.m \
19ecore_cocoa_window.m
20
21libecore_cocoa_la_LIBADD = \
22$(top_builddir)/src/lib/ecore/libecore.la \
23$(top_builddir)/src/lib/ecore_input/libecore_input.la \
24@EVAS_LIBS@ \
25@EINA_LIBS@
26
27libecore_cocoa_la_LDFLAGS = @cocoa_ldflags@ -version-info @version_info@ @release_info@
28
29EXTRA_DIST = ecore_cocoa_private.h
diff --git a/legacy/ecore/src/lib/ecore_con/Makefile.am b/legacy/ecore/src/lib/ecore_con/Makefile.am
deleted file mode 100644
index d17410b626..0000000000
--- a/legacy/ecore/src/lib/ecore_con/Makefile.am
+++ /dev/null
@@ -1,55 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_builddir)/src/lib/ecore \
5-I$(top_builddir)/src/lib/ecore_con \
6-I$(top_srcdir)/src/lib/ecore \
7-I$(top_srcdir)/src/lib/ecore_con \
8-DEFL_ECORE_CON_BUILD \
9@SSL_CFLAGS@ \
10@CURL_CFLAGS@ \
11@EVIL_CFLAGS@ \
12@EINA_CFLAGS@ \
13@TLS_CFLAGS@ \
14@CARES_CFLAGS@ \
15@EET_CFLAGS@
16
17lib_LTLIBRARIES = libecore_con.la
18includes_HEADERS = Ecore_Con.h
19includesdir = $(includedir)/ecore-@VMAJ@
20
21libecore_con_la_SOURCES = \
22ecore_con.c \
23ecore_con_socks.c \
24ecore_con_ssl.c \
25ecore_con_url.c \
26ecore_con_alloc.c \
27ecore_con_private.h
28
29if ECORE_HAVE_WIN32
30libecore_con_la_SOURCES += ecore_con_local_win32.c
31else
32libecore_con_la_SOURCES += ecore_con_local.c
33endif
34
35if HAVE_CARES
36libecore_con_la_SOURCES += ecore_con_ares.c
37else
38if HAVE_IPV6
39libecore_con_la_CFLAGS = @ECORE_CON_CFLAGS@
40libecore_con_la_SOURCES += ecore_con_dns.c dns.c dns.h
41else
42libecore_con_la_SOURCES += ecore_con_info.c
43endif
44endif
45
46if ECORE_HAVE_EET
47libecore_con_la_SOURCES += ecore_con_eet.c
48includes_HEADERS += Ecore_Con_Eet.h
49endif
50
51libecore_con_la_LIBADD = \
52$(top_builddir)/src/lib/ecore/libecore.la \
53@SSL_LIBS@ @CURL_LIBS@ @EINA_LIBS@ @EVIL_LIBS@ @TLS_LIBS@ @CARES_LIBS@ @WIN32_LIBS@ @EET_LIBS@
54
55libecore_con_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@
diff --git a/legacy/ecore/src/lib/ecore_config/Ecore_Config.h b/legacy/ecore/src/lib/ecore_config/Ecore_Config.h
deleted file mode 100644
index 6733d7bdd9..0000000000
--- a/legacy/ecore/src/lib/ecore_config/Ecore_Config.h
+++ /dev/null
@@ -1,312 +0,0 @@
1#ifndef _ECORE_CONFIG_H
2# define _ECORE_CONFIG_H
3
4#ifdef EAPI
5#undef EAPI
6#endif
7#ifdef _MSC_VER
8# ifdef BUILDING_DLL
9# define EAPI __declspec(dllexport)
10# else
11# define EAPI __declspec(dllimport)
12# endif
13#else
14# ifdef __GNUC__
15# if __GNUC__ >= 4
16# define EAPI __attribute__ ((visibility("default")))
17# else
18# define EAPI
19# endif
20# else
21# define EAPI
22# endif
23#endif
24
25/**
26 * @file
27 * @brief Provides the Enlightened Property Library.
28 *
29 * This file provies all headers and structs for use with Ecore_Config.
30 * Using individual header files should not be necessary.
31 */
32
33# define DIR_DELIMITER '/'
34# define ECORE_CONFIG_FLOAT_PRECISION 1000
35
36/* FIXME: this should only be included if evas is present */
37# include <Evas.h>
38
39# define ECORE_CONFIG_GLOBAL_ID "_system"
40
41/* structures */
42
43/**
44 * Valid configuration property types.
45 */
46typedef enum Ecore_Config_Type
47{
48 ECORE_CONFIG_NIL = 0, /**< Property with no value. */
49 ECORE_CONFIG_INT = 1, /**< Integer property type. */
50 ECORE_CONFIG_FLT = 2, /**< Float property type. */
51 ECORE_CONFIG_STR = 3, /**< String property type. */
52 ECORE_CONFIG_RGB = 4, /**< Colour property type. */
53 ECORE_CONFIG_THM = 5, /**< Theme property type. */
54 ECORE_CONFIG_BLN = 6, /**< Boolean property type. */
55 ECORE_CONFIG_SCT = 7, /**< Structure property type */
56} Ecore_Config_Type;
57
58typedef enum Ecore_Config_Flag
59{
60 ECORE_CONFIG_FLAG_NONE = 0,
61 ECORE_CONFIG_FLAG_BOUNDS = 1,
62 ECORE_CONFIG_FLAG_MODIFIED = 2,
63 ECORE_CONFIG_FLAG_SYSTEM = 4,
64 ECORE_CONFIG_FLAG_CMDLN = 8
65} Ecore_Config_Flag;
66
67/**
68 * Property change callback function prototype.
69 */
70typedef int (*Ecore_Config_Listener) (const char *key,
71 const Ecore_Config_Type type,
72 const int tag, void *data);
73
74typedef struct Ecore_Config_Listener_List
75{
76 Ecore_Config_Listener listener;
77 const char *name;
78 void *data;
79 int tag;
80 struct Ecore_Config_Listener_List *next;
81} Ecore_Config_Listener_List;
82
83/**
84 * The actual property for storing a key-value pair.
85 */
86typedef struct Ecore_Config_Prop
87{
88 char *key; /* Property key. */
89 char *description; /* Description set by ecore_config_descibe. */
90 char short_opt; /* short identifier on command line (-f) */
91 char *long_opt; /* long identifier on command line (--foo) */
92 char *ptr; /* Used as the value when the property is a string or theme. */
93 Ecore_Config_Type type; /* Property type. */
94 long val; /* Used as the value when the property is an integer, float or colour. */
95 long lo; /* Lower bound for the value when the property is an integer or float. */
96 long hi; /* Higher bound for the value when the property is an integer or float. */
97 long step; /* Increment for the value when the property is an integer or float. */
98 Ecore_Config_Flag flags; /// < Configuration flags.
99 Ecore_Config_Listener_List *listeners; /* List of change listeners. */
100 void *data; /// < Stores extra data for the property.
101 struct Ecore_Config_Prop *parent; /* if we are in a struct we have a parent to notify of changes etc */
102 struct Ecore_Config_Prop *next; /* Pointer to the next property in the list. */
103} Ecore_Config_Prop;
104
105/*
106 * A container for a list of properties. Provided so that an
107 * application can use different set of properties at any time. This
108 * is useful for multiple window support.
109 */
110typedef struct Ecore_Config_Bundle
111{
112 char *identifier; /* Identifier for this set of properties (window ID for example) */
113 char *owner; /* This is used to store the application name related to the bundle */
114 long serial; /* Unique identifier to identify bundle */
115 Ecore_Config_Prop *data; /* Pointer to root of property list */
116 void *user_data; /* App specific pointer to "other data" */
117 struct Ecore_Config_Bundle *next; /* Pointer to next bundle in this application */
118} Ecore_Config_Bundle;
119
120typedef struct Ecore_Config_Server
121{
122 void *server;
123 char *name;
124 Ecore_Config_Bundle *bundles; /* data anchor */
125 struct Ecore_Config_Server *next;
126} Ecore_Config_Server;
127
128# ifdef __cplusplus
129extern "C"
130{
131# endif
132
133/* global ptrs to save passing them through the API */
134 EAPI extern Ecore_Config_Server *__ecore_config_server_global;
135 EAPI extern Ecore_Config_Server *__ecore_config_server_local;
136 EAPI extern Ecore_Config_Bundle *__ecore_config_bundle_local;
137 EAPI extern char *__ecore_config_app_name;
138
139 EAPI Ecore_Config_Prop *ecore_config_get(const char *key);
140 EAPI const char *ecore_config_type_get(const Ecore_Config_Prop *e);
141 EAPI int ecore_config_boolean_get(const char *key);
142 EAPI char *ecore_config_string_get(const char *key);
143 EAPI long ecore_config_int_get(const char *key);
144 EAPI int ecore_config_argb_get(const char *key, int *a, int *r,
145 int *g, int *b);
146 EAPI long ecore_config_argbint_get(const char *key);
147 EAPI char *ecore_config_argbstr_get(const char *key);
148 EAPI float ecore_config_float_get(const char *key);
149 EAPI char *ecore_config_theme_get(const char *key);
150 EAPI char *ecore_config_as_string_get(const char *key);
151 EAPI int ecore_config_bound(Ecore_Config_Prop *e);
152 EAPI int ecore_config_describe(const char *key, const char *desc);
153 EAPI int ecore_config_short_opt_set(const char *key,
154 char short_opt);
155 EAPI int ecore_config_long_opt_set(const char *key,
156 const char *long_opt);
157 EAPI int ecore_config_set(const char *key, const char *val);
158 EAPI int ecore_config_typed_set(const char *key, const void *val,
159 int type);
160 EAPI int ecore_config_boolean_set(const char *key, int val);
161 EAPI int ecore_config_string_set(const char *key, const char *val);
162 EAPI int ecore_config_int_set(const char *key, int val);
163 EAPI int ecore_config_argb_set(const char *key, int a, int r, int g, int b);
164 EAPI int ecore_config_argbint_set(const char *key, long argb);
165 EAPI int ecore_config_argbstr_set(const char *key, const char *val);
166 EAPI int ecore_config_float_set(const char *key, float val);
167 EAPI int ecore_config_theme_set(const char *key, const char *val);
168 EAPI int ecore_config_theme_preview_group_set(const char *key,
169 const char *group);
170 EAPI int ecore_config_as_string_set(const char *key, const char *val);
171
172 EAPI int ecore_config_default(const char *key, const char *val,
173 float lo, float hi, float step);
174 EAPI int ecore_config_typed_default(const char *key, const void *val,
175 int type);
176 EAPI int ecore_config_boolean_default(const char *key, int val);
177 EAPI int ecore_config_int_default(const char *key, int val);
178 EAPI int ecore_config_int_default_bound(const char *key, int val,
179 int lo, int hi, int step);
180 EAPI int ecore_config_string_default(const char *key, const char *val);
181 EAPI int ecore_config_float_default(const char *key, float val);
182 EAPI int ecore_config_float_default_bound(const char *key,
183 float val, float lo,
184 float hi, float step);
185 EAPI int ecore_config_argb_default(const char *key, int a, int r, int g, int b);
186 EAPI int ecore_config_argbint_default(const char *key, long argb);
187 EAPI int ecore_config_argbstr_default(const char *key, const char *val);
188 EAPI int ecore_config_theme_default(const char *key, const char *val);
189 EAPI int ecore_config_struct_default(const char *key);
190 EAPI int ecore_config_struct_int_add(const char *key, const char *name, int val);
191 EAPI int ecore_config_struct_float_add(const char *key, const char *name, float val);
192 EAPI int ecore_config_struct_create(const char *key);
193 EAPI int ecore_config_struct_string_add(const char *key, const char *name, const char* val);
194 EAPI int ecore_config_struct_theme_add(const char *key, const char *name, const char* val);
195 EAPI int ecore_config_struct_argb_add(const char *key, const char *name, int a, int r, int g, int b);
196 EAPI int ecore_config_struct_boolean_add(const char *key, const char *name, int val);
197 EAPI int ecore_config_struct_get(const char *key, void *data);
198
199 EAPI int ecore_config_listen(const char *name, const char *key,
200 Ecore_Config_Listener listener,
201 int tag, void *data);
202 EAPI int ecore_config_deaf(const char *name, const char *key,
203 Ecore_Config_Listener listener);
204 EAPI Ecore_Config_Prop *ecore_config_dst(Ecore_Config_Prop *e);
205 EAPI int ecore_config_type_guess(const char *key, const char *val);
206
207 EAPI Ecore_Config_Bundle *ecore_config_bundle_new(Ecore_Config_Server *srv,
208 const char *id);
209 EAPI Ecore_Config_Bundle *ecore_config_bundle_1st_get(Ecore_Config_Server *srv);
210 EAPI Ecore_Config_Bundle *ecore_config_bundle_next_get(Ecore_Config_Bundle *ns);
211 EAPI Ecore_Config_Bundle *ecore_config_bundle_by_serial_get(Ecore_Config_Server *srv,
212 long serial);
213 EAPI Ecore_Config_Bundle *ecore_config_bundle_by_label_get(Ecore_Config_Server *srv,
214 const char *label);
215 EAPI long ecore_config_bundle_serial_get(Ecore_Config_Bundle *ns);
216 EAPI char *ecore_config_bundle_label_get(Ecore_Config_Bundle *ns);
217
218 EAPI int ecore_config_init(const char *name);
219 EAPI int ecore_config_shutdown(void);
220
221 EAPI int ecore_config_system_init(void);
222 EAPI int ecore_config_system_shutdown(void);
223
224 EAPI int ecore_config_load(void);
225 EAPI int ecore_config_file_load(const char *file);
226 EAPI int ecore_config_save(void);
227 EAPI int ecore_config_file_save(const char *file);
228
229/* error codes */
230# define ECORE_CONFIG_ERR_NOTSUPP (-16)
231# define ECORE_CONFIG_ERR_NOFILE (-15)
232# define ECORE_CONFIG_ERR_META_DLFAIL (-14)
233# define ECORE_CONFIG_ERR_META_FILE (-13)
234# define ECORE_CONFIG_ERR_META_FORMAT (-12)
235# define ECORE_CONFIG_ERR_MONMIS (-11)
236# define ECORE_CONFIG_ERR_NOEXEC (-10)
237# define ECORE_CONFIG_ERR_PARTIAL (-9)
238# define ECORE_CONFIG_ERR_PATHEX (-8)
239# define ECORE_CONFIG_ERR_TYPEMISMATCH (-7)
240# define ECORE_CONFIG_ERR_MUTEX (-6)
241# define ECORE_CONFIG_ERR_NOTFOUND (-5) /* Error indicating that the item searched for could not be found. */
242# define ECORE_CONFIG_ERR_OOM (-4) /* Error given when the program runs out of memory. */
243# define ECORE_CONFIG_ERR_IGNORED (-3) /* Error occurred, but was ignored. */
244# define ECORE_CONFIG_ERR_NODATA (-2) /* Error given when necessary data is not provided. */
245# define ECORE_CONFIG_ERR_FAIL (-1) /* Failure result. */
246# define ECORE_CONFIG_ERR_SUCC (0) /* Success result. */
247
248# define ECORE_CONFIG_PARSE_HELP (-2) /* Help was displayed */
249# define ECORE_CONFIG_PARSE_EXIT (-1) /* An error occurred */
250# define ECORE_CONFIG_PARSE_CONTINUE (0) /* Arguments parsed successfully */
251
252/* convenience mathods in convenience.c */
253 /* FIXME: this should only be included if evas is present */
254 EAPI int ecore_config_evas_font_path_apply(Evas *evas);
255 EAPI char *ecore_config_theme_search_path_get(void);
256 EAPI int ecore_config_theme_search_path_append(const char *append);
257
258 EAPI char *ecore_config_theme_default_path_get(void);
259 EAPI char *ecore_config_theme_with_path_from_name_get(char *name);
260 EAPI char *ecore_config_theme_with_path_get(const char *key);
261 EAPI void ecore_config_args_display(void);
262 EAPI int ecore_config_args_parse(void);
263 EAPI void ecore_config_args_callback_str_add(char short_opt,
264 char *long_opt, char *desc,
265 void (*func)(char *val, void *data),
266 void *data);
267 EAPI void ecore_config_args_callback_noarg_add(char short_opt,
268 char *long_opt, char *desc,
269 void (*func)(char *val, void *data),
270 void *data);
271 EAPI void ecore_config_app_describe(char *description);
272
273 EAPI int ecore_config_create(const char *key, void *val,
274 char short_opt, char *long_opt,
275 char *desc);
276 EAPI int ecore_config_typed_create(const char *key, void *val,
277 int type, char short_opt,
278 char *long_opt, char *desc);
279 EAPI int ecore_config_boolean_create(const char *key, int val,
280 char short_opt, char *long_opt,
281 char *desc);
282 EAPI int ecore_config_int_create(const char *key, int val,
283 char short_opt, char *long_opt,
284 char *desc);
285 EAPI int ecore_config_int_create_bound(const char *key, int val,
286 int low, int high,
287 int step, char short_opt,
288 char *long_opt,
289 char *desc);
290 EAPI int ecore_config_string_create(const char *key, char *val,
291 char short_opt,
292 char *long_opt, char *desc);
293 EAPI int ecore_config_float_create(const char *key, float val,
294 char short_opt, char *long_opt,
295 char *desc);
296 EAPI int ecore_config_float_create_bound(const char *key,
297 float val, float low,
298 float high, float step,
299 char short_opt,
300 char *long_opt,
301 char *desc);
302 EAPI int ecore_config_argb_create(const char *key, char *val,
303 char short_opt, char *long_opt,
304 char *desc);
305 EAPI int ecore_config_theme_create(const char *key, char *val,
306 char short_opt, char *long_opt,
307 char *desc);
308
309# ifdef __cplusplus
310}
311# endif
312#endif
diff --git a/legacy/ecore/src/lib/ecore_config/Makefile.am b/legacy/ecore/src/lib/ecore_config/Makefile.am
deleted file mode 100644
index c4593515eb..0000000000
--- a/legacy/ecore/src/lib/ecore_config/Makefile.am
+++ /dev/null
@@ -1,62 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3AM_CPPFLAGS = \
4-I$(top_srcdir)/src/lib/ecore \
5-I$(top_srcdir)/src/lib/ecore_ipc \
6-I$(top_srcdir)/ \
7-I$(top_builddir)/src/lib/ecore \
8-I$(top_builddir)/src/lib/ecore_ipc \
9-I$(top_builddir)/ \
10-DPACKAGE_BIN_DIR=\"$(bindir)\" \
11-DPACKAGE_LIB_DIR=\"$(libdir)\" \
12-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
13@EVAS_CFLAGS@ \
14@EET_CFLAGS@ \
15@EINA_CFLAGS@
16
17CLEANFILES = $(DB)
18
19#DB = system.db
20#$(DB): Makefile
21# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/theme/name str "winter"
22# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /e/font/path str "$(pkgdatadir)/data/fonts"
23# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/browser str `which firefox 2>/dev/null || which phoenix 2>/dev/null || which mozilla 2>/dev/null || which opera 2>/dev/null || which konqueror 2>/dev/null || which epiphany 2>/dev/null`
24# edb_ed $(top_builddir)/src/lib/ecore_config/$(DB) add /apps/web/email str `which thunderbird 2>/dev/null || which mozilla 2>/dev/null || which kmail 2>/dev/null || which sylpheed 2>/dev/null || which evolution 2>/dev/null`
25
26lib_LTLIBRARIES = libecore_config.la
27
28includes_HEADERS = Ecore_Config.h
29includesdir = $(includedir)/ecore-@VMAJ@
30
31libecore_config_la_LDFLAGS = -no-undefined -version-info @version_info@ @release_info@
32
33#config_DATA = $(DB)
34#configdir = $(pkgdatadir)
35
36libecore_config_la_SOURCES = \
37ecore_config.c \
38ecore_config_util.c \
39ecore_config_storage.c \
40ecore_config_extra.c \
41ecore_config_db.c
42
43libecore_config_la_LIBADD = \
44$(top_builddir)/src/lib/ecore/libecore.la \
45@EET_LIBS@ \
46@EINA_LIBS@ \
47@EVAS_LIBS@
48
49if BUILD_ECORE_IPC
50
51libecore_config_la_SOURCES += \
52ecore_config_ipc_main.c \
53ecore_config_ipc_ecore.c
54
55libecore_config_la_LIBADD += $(top_builddir)/src/lib/ecore_ipc/libecore_ipc.la
56
57endif
58
59EXTRA_DIST = \
60ecore_config_ipc.h \
61ecore_config_private.h \
62ecore_config_util.h
diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config.c b/legacy/ecore/src/lib/ecore_config/ecore_config.c
deleted file mode 100644
index e81538eb62..0000000000
--- a/legacy/ecore/src/lib/ecore_config/ecore_config.c
+++ /dev/null
@@ -1,1870 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <string.h>
6#include <ctype.h>
7#include <stdio.h>
8#include <stdlib.h>
9
10#include <sys/param.h>
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <fcntl.h>
14#include <limits.h>
15#include <unistd.h>
16
17#include "Ecore_Config.h"
18#include "ecore_config_private.h"
19#include "ecore_config_ipc.h"
20
21#include "ecore_config_util.h"
22int _ecore_config_log_dom = -1;
23int DEBUG = 0;
24EAPI Ecore_Config_Server *__ecore_config_server_global = NULL;
25EAPI Ecore_Config_Server *__ecore_config_server_local = NULL;
26EAPI Ecore_Config_Bundle *__ecore_config_bundle_local = NULL;
27EAPI char *__ecore_config_app_name = NULL;
28int __ecore_config_system_init = 0;
29
30static int _ecore_config_system_init_no_load(void);
31static int _ecore_config_system_load(void);
32
33static inline void *__ecore_argb_to_long(int a, int r, int g, int b, long *v);
34static inline void *__ecore_argbstr_to_long(const char *argb, long *v);
35
36static const char *_ecore_config_type[] =
37 { "undefined", "integer", "float", "string", "colour", "theme", "boolean", "structure" };
38
39/**
40 * @defgroup Ecore_Config_Property_Group Ecore Config Property Functions
41 *
42 * Functions that retrieve or set the attributes relating to a property.
43 */
44
45/**
46 * Removes the given property from the local configuration and destroys it.
47 * @param e Property to destroy.
48 * @return @c NULL
49 * @ingroup Ecore_Config_Property_Group
50 */
51EAPI Ecore_Config_Prop *
52ecore_config_dst(Ecore_Config_Prop * e)
53{
54 Ecore_Config_Bundle *t;
55 Ecore_Config_Prop *p, *c;
56 Ecore_Config_Listener_List *l;
57
58 p = NULL;
59 t = __ecore_config_bundle_local;
60 c = t->data;
61
62 if (!e || !e->key)
63 return NULL;
64 if (t)
65 {
66 if (t->data == e)
67 t->data = e->next;
68 else
69 {
70 do
71 {
72 p = c;
73 c = c->next;
74 }
75 while (c && (c != e));
76 if (c) /* remove from list if even in there */
77 p->next = c->next;
78 }
79 }
80
81 while (e->listeners)
82 {
83 l = e->listeners;
84 e->listeners = e->listeners->next;
85 free(l);
86 }
87
88 if (e->key)
89 free(e->key);
90 if (e->ptr && ((e->type == ECORE_CONFIG_STR) || (e->type == ECORE_CONFIG_THM)))
91 free(e->ptr);
92
93 memset(e, 0, sizeof(Ecore_Config_Prop));
94 free(e);
95
96 return NULL;
97}
98
99/**
100 * @defgroup Ecore_Config_Get_Group Configuration Retrieve Functions
101 *
102 * Functions that retrieve configuration values, based on type.
103 */
104
105/**
106 * Returns the property with the given key.
107 * @param key The unique name of the wanted property.
108 * @return The property that corresponds to the given key. @c NULL if the
109 * key could not be found.
110 * @ingroup Ecore_Config_Get_Group
111 */
112EAPI Ecore_Config_Prop *
113ecore_config_get(const char *key)
114{
115 Ecore_Config_Bundle *t;
116 Ecore_Config_Prop *e;
117
118 t = __ecore_config_bundle_local;
119 if (!t || !key)
120 return NULL;
121 e = t->data;
122 while (e)
123 {
124 if (!strcmp(key, e->key))
125 return e;
126 e = e->next;
127 }
128 return NULL;
129}
130
131/**
132 * Returns the type of the property.
133 * @param e Property to get the type of.
134 * @returns The type of the property. If the property is invalid, then the
135 * string "not found" is returned.
136 * @ingroup Ecore_Config_Property_Group
137 */
138EAPI const char *
139ecore_config_type_get(const Ecore_Config_Prop * e)
140{
141 if (e)
142 {
143 return _ecore_config_type[e->type];
144 }
145 return "not found";
146}
147
148/**
149 * Returns the specified property as a string.
150 * @param key The property key.
151 * @return The string value of the property. The function returns @c NULL if
152 * the property is not a string or is not set.
153 * @ingroup Ecore_Config_Get_Group
154 */
155EAPI char *
156ecore_config_string_get(const char *key)
157{
158 return _ecore_config_string_get( ecore_config_get(key) );
159}
160
161char *
162_ecore_config_string_get(Ecore_Config_Prop *e)
163{
164 return (e && (e->type == ECORE_CONFIG_STR) && e->ptr) ? strdup(e->ptr) : NULL;
165}
166
167/**
168 * Returns the specified property as an integer.
169 * @param key The property key.
170 * @return The value of the property. The function returns -1 if the
171 * property is not an integer or is not set.
172 * @ingroup Ecore_Config_Get_Group
173 */
174EAPI int
175ecore_config_boolean_get(const char *key)
176{
177 return _ecore_config_boolean_get( ecore_config_get(key) );
178}
179
180int
181_ecore_config_boolean_get(Ecore_Config_Prop *e)
182{
183 return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_BLN))) ? (e->val != 0) : -1;
184}
185
186/**
187 * Returns the specified property as a long integer.
188 * @param key The property key.
189 * @return The integer value of the property. The function returns 0 if the
190 * property is not an integer or is not set.
191 * @ingroup Ecore_Config_Get_Group
192 */
193EAPI long
194ecore_config_int_get(const char *key)
195{
196 return _ecore_config_int_get( ecore_config_get(key) );
197}
198
199long
200_ecore_config_int_get(Ecore_Config_Prop *e)
201{
202 return (e && ((e->type == ECORE_CONFIG_INT) || (e->type == ECORE_CONFIG_RGB))) ? e->val : 0L;
203}
204
205/**
206 * Returns the specified property as a float.
207 * @param key The property key.
208 * @return The float value of the property. The function returns 0.0 if the
209 * property is not a float or is not set.
210 * @ingroup Ecore_Config_Get_Group
211 */
212EAPI float
213ecore_config_float_get(const char *key)
214{
215 return _ecore_config_float_get( ecore_config_get(key) );
216}
217
218float
219_ecore_config_float_get(Ecore_Config_Prop *e)
220{
221 return (e && (e->type == ECORE_CONFIG_FLT)) ? ((float)e->val / ECORE_CONFIG_FLOAT_PRECISION) : 0.0;
222}
223
224/**
225 * Finds the alpha, red, green and blue values of a color property.
226 * @param key The property key.
227 * @param a A pointer to an integer to store the alpha value into.
228 * @param r A pointer to an integer to store the red value into.
229 * @param g A pointer to an integer to store the green value into.
230 * @param b A pointer to an integer to store the blue value into.
231 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL
232 * otherwise.
233 * @ingroup Ecore_Config_Get_Group
234 */
235EAPI int
236ecore_config_argb_get(const char *key, int *a, int *r, int *g, int *b)
237{
238 return _ecore_config_argb_get( ecore_config_get(key), a, r, g, b);
239}
240
241int
242_ecore_config_argb_get(Ecore_Config_Prop *e, int *a, int *r, int *g, int *b)
243{
244 if (e && ((e->type == ECORE_CONFIG_RGB)))
245 {
246 if(a) *a = (e->val >> 24) & 0xff;
247 if(r) *r = (e->val >> 16) & 0xff;
248 if(g) *g = (e->val >> 8) & 0xff;
249 if(b) *b = e->val & 0xff;
250 return ECORE_CONFIG_ERR_SUCC;
251 }
252 return ECORE_CONFIG_ERR_FAIL;
253}
254
255/**
256 * Returns a color property as a long
257 * @param key The property key.
258 * @return ARGB data as long
259 * @ingroup Ecore_Config_Get_Group
260 */
261EAPI long
262ecore_config_argbint_get(const char *key)
263{
264 return _ecore_config_argbint_get( ecore_config_get(key) );
265}
266
267long
268_ecore_config_argbint_get(Ecore_Config_Prop *e)
269{
270 if (e && ((e->type == ECORE_CONFIG_RGB)))
271 {
272 return e->val;
273 }
274 return 0L;
275}
276
277/**
278 * Returns a color property as a string of hexadecimal characters.
279 * @param key The property key.
280 * @return A string of hexadecimal characters in the format #aarrggbb.
281 * @ingroup Ecore_Config_Get_Group
282 */
283EAPI char *
284ecore_config_argbstr_get(const char *key)
285{
286 return _ecore_config_argbstr_get( ecore_config_get(key) );
287}
288
289char *
290_ecore_config_argbstr_get(Ecore_Config_Prop *e)
291{
292 char *r;
293
294 r = NULL;
295 esprintf(&r, "#%08x", _ecore_config_int_get(e));
296 return r;
297}
298
299/**
300 * Returns a theme property.
301 * @param key The property key.
302 * @return The name of the theme the property refers to. The function returns
303 * @c NULL if the property is not a theme or is not set.
304 * @ingroup Ecore_Config_Get_Group
305 */
306EAPI char *
307ecore_config_theme_get(const char *key)
308{
309 return _ecore_config_theme_get( ecore_config_get(key) );
310}
311
312char *
313_ecore_config_theme_get(Ecore_Config_Prop *e)
314{
315 return (e && (e->type == ECORE_CONFIG_THM)) ? strdup(e->ptr) : NULL;
316}
317
318/**
319 * Retrieves the key as a string.
320 * @param key The property key.
321 * @return Returns a character array in the form of 'key:type=value'. @c NULL
322 * is returned if the property does not exist.
323 * @ingroup Ecore_Config_Get_Group
324 */
325EAPI char *
326ecore_config_as_string_get(const char *key)
327{
328 Ecore_Config_Prop *e;
329 char *val;
330 char *r;
331
332 val = NULL;
333 r = NULL;
334 if (!(e = ecore_config_get(key)))
335 ERR("no such property, \"%s\"...", key);
336 else
337 {
338 switch (e->type)
339 {
340 case ECORE_CONFIG_NIL:
341 val = strdup("<nil>");
342 break;
343 case ECORE_CONFIG_INT:
344 esprintf(&val, "%ld", _ecore_config_int_get(e));
345 break;
346 case ECORE_CONFIG_BLN:
347 esprintf(&val, "%ld", _ecore_config_boolean_get(e));
348 break;
349 case ECORE_CONFIG_FLT:
350 esprintf(&val, "%lf", _ecore_config_float_get(e));
351 break;
352 case ECORE_CONFIG_STR:
353 esprintf(&val, "\"%s\"", _ecore_config_string_get(e));
354 break;
355 case ECORE_CONFIG_RGB:
356 esprintf(&val, "#%08x", _ecore_config_int_get(e));
357 break;
358 case ECORE_CONFIG_THM:
359 esprintf(&val, "\"%s\"", _ecore_config_theme_get(e));
360 break;
361 case ECORE_CONFIG_SCT:
362 break;
363 default:
364 esprintf(&r, "%s:unknown_type", key);
365 break;
366 }
367 if (val)
368 {
369 esprintf(&r, "%s:%s=%s", key, _ecore_config_type[e->type], val);
370 free(val);
371 }
372 }
373 return r;
374}
375
376EAPI int
377ecore_config_bound(Ecore_Config_Prop * e)
378{
379 int ret;
380 long v;
381
382 ret = ECORE_CONFIG_ERR_SUCC;
383
384 if (!e)
385 return ECORE_CONFIG_ERR_FAIL;
386 if (e->flags & ECORE_CONFIG_FLAG_BOUNDS)
387 {
388 if ((e->val < e->lo))
389 {
390 WRN("ecore_config_bounds(\"%s\",%ld): value out of range; adjusted to %ld...",
391 e->key, e->val, e->lo);
392 e->val = e->lo;
393 }
394 else if ((e->val > e->hi))
395 {
396 WRN("ecore_config_bounds(\"%s\",%ld): value out of range; adjusted to %ld...",
397 e->key, e->val, e->hi);
398 e->val = e->hi;
399 }
400 else
401 ret = ECORE_CONFIG_ERR_IGNORED;
402 }
403 else
404 ret = ECORE_CONFIG_ERR_IGNORED;
405
406 if (e->step)
407 {
408 v = ((int)(e->val / e->step)) * e->step;
409 if (v != e->val)
410 {
411 if (e->type == ECORE_CONFIG_FLT)
412 WRN("ecore_config_bound(\"%s\"): float value %f not a multiple of %f, adjusted to %f...",
413 e->key, ((double)e->val) / ECORE_CONFIG_FLOAT_PRECISION,
414 ((double)e->step) / ECORE_CONFIG_FLOAT_PRECISION,
415 ((double)v) / ECORE_CONFIG_FLOAT_PRECISION);
416 else
417 WRN("ecore_config_bound(\"%s\"): integer value %ld not a multiple of %ld, adjusted to %ld...",
418 e->key, e->val, e->step, v);
419 ret = ECORE_CONFIG_ERR_SUCC;
420 e->val = v;
421 }
422 }
423
424 return ret;
425}
426
427/**
428 * Tries to guess the type of a property.
429 *
430 * This function first checks to see if the property exists. If it does, then
431 * the type of the stored property is returned. Otherwise, the function tries
432 * to guess the type of the property based on @p val.
433 *
434 * @param key The property key.
435 * @param val The value in string form.
436 * @return The type of the property determined by the function. Note that if
437 * val is @c NULL, @c ECORE_CONFIG_NIL will be returned.
438 */
439EAPI int
440ecore_config_type_guess(const char *key, const char *val)
441{
442 Ecore_Config_Prop *p;
443 char *l;
444
445 l = NULL;
446
447 if (key && (p = ecore_config_get(key)) && p->type != ECORE_CONFIG_NIL)
448 return p->type;
449
450 if (!val)
451 return ECORE_CONFIG_NIL;
452 if (val[0] == '#')
453 return ECORE_CONFIG_RGB;
454 strtol(val, &l, 10);
455 if (*l)
456 {
457 float f;
458
459 if (sscanf(val, "%f%*s", &f) != 1)
460 return ECORE_CONFIG_STR;
461 return ECORE_CONFIG_FLT;
462 }
463 return ECORE_CONFIG_INT;
464}
465
466static int
467ecore_config_typed_val(Ecore_Config_Prop * e, const void *val, int type)
468{
469
470 if (!e)
471 return ECORE_CONFIG_ERR_NODATA;
472
473 if (!(val) && (type != ECORE_CONFIG_NIL && type != ECORE_CONFIG_SCT))
474 e->ptr = NULL;
475 else
476 {
477 if (type == ECORE_CONFIG_INT || type == ECORE_CONFIG_BLN)
478 {
479 e->val = (long) *((int *)val);
480 e->type = type;
481 }
482 else if (type == ECORE_CONFIG_STR || type == ECORE_CONFIG_THM)
483 {
484 if (!(e->ptr = strdup(val)))
485 return ECORE_CONFIG_ERR_OOM;
486 if (e->type == ECORE_CONFIG_NIL)
487 e->type = type;
488 }
489 else if (type == ECORE_CONFIG_RGB)
490 {
491 __ecore_argbstr_to_long((char *)val, &e->val);
492 e->type = ECORE_CONFIG_RGB;
493 }
494 else if (type == ECORE_CONFIG_FLT)
495 {
496 e->val = (long) ((*((float *)val)) * ECORE_CONFIG_FLOAT_PRECISION);
497 e->type = ECORE_CONFIG_FLT;
498 }
499 else if (type == ECORE_CONFIG_SCT)
500 {
501 e->type = ECORE_CONFIG_SCT;
502 }
503 else
504 {
505 e->type = ECORE_CONFIG_NIL;
506 }
507
508 ecore_config_bound(e);
509 e->flags |= ECORE_CONFIG_FLAG_MODIFIED;
510 e->flags &= ~ECORE_CONFIG_FLAG_CMDLN;
511 return ECORE_CONFIG_ERR_SUCC;
512 }
513 return ECORE_CONFIG_ERR_IGNORED;
514}
515
516static int
517ecore_config_typed_add(const char *key, const void *val, int type)
518{
519 int error = ECORE_CONFIG_ERR_SUCC;
520 Ecore_Config_Prop *e = NULL;
521 Ecore_Config_Bundle *t;
522
523 t = __ecore_config_bundle_local;
524 if (!key)
525 return ECORE_CONFIG_ERR_NODATA;
526
527 if (!(e = calloc(1, sizeof(Ecore_Config_Prop))))
528 {
529 return ECORE_CONFIG_ERR_OOM;
530 }
531 else if (!(e->key = strdup(key)))
532 {
533 error = ECORE_CONFIG_ERR_OOM;
534 }
535 else if ((error = ecore_config_typed_val(e, val, type)) == ECORE_CONFIG_ERR_SUCC)
536 {
537 if (t)
538 {
539 e->next = t->data;
540 t->data = e;
541 }
542 return ECORE_CONFIG_ERR_SUCC;
543 }
544
545 if(e->key)
546 free(e->key);
547 if(e)
548 free(e);
549
550 if (error == ECORE_CONFIG_ERR_SUCC)
551 error = ECORE_CONFIG_ERR_FAIL;
552
553 return error;
554}
555
556static int
557ecore_config_add(const char *key, const char *val)
558{
559 int type;
560
561 type = ecore_config_type_guess(key, val);
562 return ecore_config_typed_add(key, val, type);
563}
564
565/**
566 * Sets the description field of the indicated property.
567 * @param key The property key.
568 * @param desc Description string.
569 * @note The description string is copied for the property's use. You can
570 * free @p desc once this function is called.
571 * @ingroup Ecore_Config_Property_Group
572 */
573EAPI int
574ecore_config_describe(const char *key, const char *desc)
575{
576 Ecore_Config_Prop *e;
577
578 if (!(e = ecore_config_get(key)))
579 return ECORE_CONFIG_ERR_NODATA;
580 e->description = strdup(desc);
581 return ECORE_CONFIG_ERR_SUCC;
582}
583
584/**
585 * Set the short option character of a property.
586 * @param key The property key.
587 * @param short_opt Character used to indicate the value of a property
588 * given on the command line.
589 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_NODATA
590 * is returned if the property does not exist.
591 * @ingroup Ecore_Config_Property_Group
592 */
593EAPI int
594ecore_config_short_opt_set(const char *key, char short_opt)
595{
596 Ecore_Config_Prop *e;
597
598 if (!(e = ecore_config_get(key)))
599 return ECORE_CONFIG_ERR_NODATA;
600 e->short_opt = short_opt;
601 return ECORE_CONFIG_ERR_SUCC;
602}
603
604/**
605 * Set the long option string of the property.
606 * @param key The property key.
607 * @param long_opt String used to indicate the value of a property given
608 * on the command line.
609 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_NODATA
610 * is returned if the property does not exist.
611 * @ingroup Ecore_Config_Property_Group
612 */
613EAPI int
614ecore_config_long_opt_set(const char *key, const char *long_opt)
615{
616 Ecore_Config_Prop *e;
617
618 if (!(e = ecore_config_get(key)))
619 return ECORE_CONFIG_ERR_NODATA;
620 if (e->long_opt)
621 free(e->long_opt);
622 if (long_opt)
623 e->long_opt = strdup(long_opt);
624 return ECORE_CONFIG_ERR_SUCC;
625}
626
627static void
628_ecore_config_listener_fire(Ecore_Config_Prop *prop)
629{
630 Ecore_Config_Listener_List *l;
631 for (l = prop->listeners; l; l = l->next)
632 l->listener(prop->key, prop->type, l->tag, l->data);
633
634 /* fire change listeners for the generic struct container etc */
635 if (prop->parent)
636 _ecore_config_listener_fire(prop->parent);
637}
638
639/**
640 * Sets the indicated property to the given value and type.
641 * @param key The property key.
642 * @param val A pointer to the value to set the property to.
643 * @param type The type of the property.
644 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
645 * @ingroup Ecore_Config_Property_Group
646 */
647EAPI int
648ecore_config_typed_set(const char *key, const void *val, int type)
649{
650 Ecore_Config_Prop *e;
651 int ret;
652
653 if (!key)
654 return ECORE_CONFIG_ERR_NODATA;
655/* if (!t) { * global prop *
656 e=ecore_config_get(key);
657 if (e)
658 for(l=e->listeners;l;l=l->next)
659 l->listener(e->key,e->type,l->tag,l->data,t);
660 return ECORE_CONFIG_ERR_SUCC;
661 }
662*/
663 if (!(e = ecore_config_get(key)))
664 return ecore_config_typed_add(key, val, type);
665
666 if ((ret = ecore_config_typed_val(e, val, type)) == ECORE_CONFIG_ERR_SUCC)
667 {
668 _ecore_config_listener_fire(e);
669 }
670 else
671 {
672 ERR("ecore_config_typed_set(\"%s\"): ecore_config_typed_val() failed: %d",
673 key, ret);
674 }
675
676 return ret;
677}
678
679/**
680 * @defgroup Ecore_Config_Set_Group Ecore Config Setters
681 *
682 * Functions that set the value of a property.
683 */
684
685/**
686 * Sets the indicated property to the value indicated by @a val.
687 * @param key The property key.
688 * @param val String representation of value to set.
689 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
690 * @ingroup Ecore_Config_Set_Group
691 */
692EAPI int
693ecore_config_set(const char *key, const char *val)
694{
695 int type;
696 int tmpi;
697 float tmpf;
698 long tmpl;
699
700 type = ecore_config_type_guess(key, val);
701 if (type == ECORE_CONFIG_INT || type == ECORE_CONFIG_BLN)
702 {
703 tmpi = atoi(val);
704 return ecore_config_typed_set(key, &tmpi, type);
705 }
706 else if (type == ECORE_CONFIG_FLT)
707 {
708 tmpf = atof(val);
709 return ecore_config_typed_set(key, &tmpf, type);
710 }
711 else if (type == ECORE_CONFIG_RGB)
712 {
713 __ecore_argbstr_to_long(val, &tmpl);
714 return ecore_config_typed_set(key, &tmpl, type);
715 }
716 else
717 return ecore_config_typed_set(key, val, type);
718}
719
720/**
721 * Sets the indicated property to the value given in the string.
722 * @param key The property key.
723 * @param val String representation of the value.
724 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
725 * @ingroup Ecore_Config_Set_Group
726 */
727EAPI int
728ecore_config_as_string_set(const char *key, const char *val)
729{
730 return ecore_config_set(key, val);
731}
732
733/**
734 * Sets the indicated property to the given boolean.
735 * @param key The property key.
736 * @param val Boolean integer to set the property to.
737 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
738 * @ingroup Ecore_Config_Set_Group
739 */
740EAPI int
741ecore_config_boolean_set(const char *key, int val)
742{
743 val = val ? 1 : 0;
744 return ecore_config_typed_set(key, &val, ECORE_CONFIG_BLN);
745}
746
747/**
748 * Sets the indicated property to the given integer.
749 * @param key The property key.
750 * @param val Integer to set the property to.
751 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
752 * @ingroup Ecore_Config_Set_Group
753 */
754EAPI int
755ecore_config_int_set(const char *key, int val)
756{
757 return ecore_config_typed_set(key, &val, ECORE_CONFIG_INT);
758}
759
760/**
761 * Sets the indicated property to the given string.
762 * @param key The property key.
763 * @param val String to set the property to.
764 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
765 * @ingroup Ecore_Config_Set_Group
766 */
767EAPI int
768ecore_config_string_set(const char *key, const char *val)
769{
770 return ecore_config_typed_set(key, val, ECORE_CONFIG_STR);
771}
772
773/**
774 * Sets the indicated property to the given float value.
775 * @param key The property key.
776 * @param val Float to set the property to.
777 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
778 * @ingroup Ecore_Config_Set_Group
779 */
780EAPI int
781ecore_config_float_set(const char *key, float val)
782{
783 return ecore_config_typed_set(key, &val, ECORE_CONFIG_FLT);
784}
785
786/**
787 * Sets the indicated property to a color value.
788 * @param key The property key
789 * @param a integer 0..255
790 * @param r integer 0..255
791 * @param g integer 0..255
792 * @param b integer 0..255
793 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
794 * @ingroup Ecore_Config_Set_Group
795 */
796EAPI int
797ecore_config_argb_set(const char *key, int a, int r, int g, int b)
798{
799 long v = 0;
800 return ecore_config_typed_set(key, __ecore_argb_to_long(a,r,g,b, &v), ECORE_CONFIG_RGB);
801}
802
803/**
804 * Sets the indicated property to a color value.
805 * @param key The property key
806 * @param argb ARGB data as long
807 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
808 * @ingroup Ecore_Config_Set_Group
809 */
810EAPI int
811ecore_config_argbint_set(const char *key, long argb)
812{
813 return ecore_config_typed_set(key, &argb, ECORE_CONFIG_RGB);
814}
815
816/**
817 * Sets the indicated property to a color value.
818 * @param key The property key
819 * @param val Color value in ARGB format.
820 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
821 * @ingroup Ecore_Config_Set_Group
822 */
823EAPI int
824ecore_config_argbstr_set(const char *key, const char *val)
825{
826 long v = 0;
827 return ecore_config_typed_set(key, __ecore_argbstr_to_long(val, &v), ECORE_CONFIG_RGB);
828}
829
830/**
831 * Sets the indicated property to a theme name.
832 * @param key The property key.
833 * @param val String giving the name of the theme.
834 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
835 * @ingroup Ecore_Config_Set_Group
836 */
837EAPI int
838ecore_config_theme_set(const char *key, const char *val)
839{
840 return ecore_config_typed_set(key, val, ECORE_CONFIG_THM);
841}
842
843/**
844 * Sets the theme preview group of an indicated property.
845 * @param key The property key.
846 * @param group The group name.
847 * @return @c ECORE_CONFIG_ERR_SUCC on success.
848 * @ingroup Ecore_Config_Set_Group
849 */
850EAPI int
851ecore_config_theme_preview_group_set(const char *key, const char *group)
852{
853 int ret;
854 Ecore_Config_Prop *e;
855
856 ret = ECORE_CONFIG_ERR_SUCC;
857 if (!(e = ecore_config_get(key)))
858 { /* prop doesn't exist yet */
859 if ((ret = ecore_config_typed_add(key, "", ECORE_CONFIG_THM)) != ECORE_CONFIG_ERR_SUCC) /* try to add it */
860 return ret; /* ...failed */
861 if (!(e = ecore_config_get(key))) /* get handle */
862 return ECORE_CONFIG_ERR_FAIL;
863 }
864 if (e->data)
865 free(e->data);
866 e->data = strdup(group);
867
868 return ret;
869}
870
871EAPI int
872ecore_config_typed_default(const char *key, const void *val, int type)
873{
874 int ret;
875 Ecore_Config_Prop *e;
876
877 ret = ECORE_CONFIG_ERR_SUCC;
878
879 if (!(e = ecore_config_get(key)))
880 { /* prop doesn't exist yet */
881 if ((ret = ecore_config_typed_add(key, val, type)) != ECORE_CONFIG_ERR_SUCC) /* try to add it */
882 return ret; /* ...failed */
883 if (!(e = ecore_config_get(key))) /* get handle */
884 return ECORE_CONFIG_ERR_FAIL;
885 e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED;
886 }
887 else if (!(e->flags & ECORE_CONFIG_FLAG_MODIFIED) && !(e->flags & ECORE_CONFIG_FLAG_SYSTEM))
888 {
889 ecore_config_typed_set(key, val, type);
890 if (!(e = ecore_config_get(key))) /* get handle */
891 return ECORE_CONFIG_ERR_FAIL;
892 e->flags = e->flags & ~ECORE_CONFIG_FLAG_MODIFIED;
893 }
894 return ret;
895}
896
897/**
898 * @defgroup Ecore_Config_Default_Group Ecore Config Defaults
899 *
900 * Functions that are used to set the default values of properties.
901 */
902
903/**
904 * Sets the indicated property if it has not already been set or loaded.
905 * @param key The property key.
906 * @param val Default value of the key.
907 * @param lo Lowest valid value for the key.
908 * @param hi Highest valid value for the key.
909 * @param step Used by integer and float values.
910 * @return @c ECORE_CONFIG_ERR_SUCC if there are no errors.
911 * @note The @p lo, @p hi and @p step parameters are only used when storing
912 * integer and float properties.
913 * @ingroup Ecore_Config_Default_Group
914 */
915EAPI int
916ecore_config_default(const char *key, const char *val, float lo, float hi, float step)
917{
918 int ret, type;
919 Ecore_Config_Prop *e;
920
921 type = ecore_config_type_guess(key, val);
922 ret = ecore_config_typed_default(key, val, type);
923 e = ecore_config_get(key);
924 if (e)
925 {
926 if (type == ECORE_CONFIG_INT)
927 {
928 e->step = step;
929 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
930 e->lo = lo;
931 e->hi = hi;
932 ecore_config_bound(e);
933 }
934 else if (type == ECORE_CONFIG_FLT)
935 {
936 e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
937 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
938 e->lo = (int)(lo * ECORE_CONFIG_FLOAT_PRECISION);
939 e->hi = (int)(hi * ECORE_CONFIG_FLOAT_PRECISION);
940 ecore_config_bound(e);
941 }
942 }
943
944 return ret;
945}
946
947/**
948 * Sets the indicated property to the given boolean if the property has not yet
949 * been set.
950 * @param key The property key.
951 * @param val Boolean Integer to set the value to.
952 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
953 * @ingroup Ecore_Config_Default_Group
954 */
955EAPI int
956ecore_config_boolean_default(const char *key, int val)
957{
958 val = val ? 1 : 0;
959 return ecore_config_typed_default(key, &val, ECORE_CONFIG_BLN);
960}
961
962/**
963 * Sets the indicated property to the given integer if the property has not yet
964 * been set.
965 * @param key The property key.
966 * @param val Integer to set the value to.
967 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
968 * @ingroup Ecore_Config_Default_Group
969 */
970EAPI int
971ecore_config_int_default(const char *key, int val)
972{
973 return ecore_config_typed_default(key, &val, ECORE_CONFIG_INT);
974}
975
976/**
977 * Sets the indicated property to the given integer if the property has not yet
978 * been set.
979 *
980 * The bounds and step values are set regardless.
981 *
982 * @param key The property key.
983 * @param val Integer to set the property to.
984 * @param low Lowest valid integer value for the property.
985 * @param high Highest valid integer value for the property.
986 * @param step Increment value for the property.
987 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
988 * @ingroup Ecore_Config_Default_Group
989 */
990EAPI int
991ecore_config_int_default_bound(const char *key, int val, int low, int high,
992 int step)
993{
994 Ecore_Config_Prop *e;
995 int ret;
996
997 ret = ecore_config_typed_default(key, &val, ECORE_CONFIG_INT);
998 e = ecore_config_get(key);
999 if (e)
1000 {
1001 e->step = step;
1002 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
1003 e->lo = low;
1004 e->hi = high;
1005 ecore_config_bound(e);
1006 }
1007
1008 return ret;
1009}
1010
1011/**
1012 * Sets the indicated property to the given string if the property has not yet
1013 * been set.
1014 * @param key The property key.
1015 * @param val String to set the property to.
1016 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1017 * @ingroup Ecore_Config_Default_Group
1018 */
1019EAPI int
1020ecore_config_string_default(const char *key, const char *val)
1021{
1022 return ecore_config_typed_default(key, val, ECORE_CONFIG_STR);
1023}
1024
1025/**
1026 * Sets the indicated property to the given float if the property has not yet
1027 * been set.
1028 * @param key The property key.
1029 * @param val Float to set the property to.
1030 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1031 * @ingroup Ecore_Config_Default_Group
1032 */
1033EAPI int
1034ecore_config_float_default(const char *key, float val)
1035{
1036 return ecore_config_typed_default(key, &val, ECORE_CONFIG_FLT);
1037}
1038
1039/**
1040 * Sets the indicated property to the given float if the property has not yet
1041 * been set.
1042 *
1043 * The bounds and step values are set regardless.
1044 *
1045 * @param key The property key.
1046 * @param val Float to set the property to.
1047 * @param low Lowest valid integer value for the property.
1048 * @param high Highest valid float value for the property.
1049 * @param step Increment value for the property.
1050 * @return @c ECORE_CONFIG_ERR_SUCC if there were no problems.
1051 * @ingroup Ecore_Config_Default_Group
1052 */
1053EAPI int
1054ecore_config_float_default_bound(const char *key, float val, float low,
1055 float high, float step)
1056{
1057 Ecore_Config_Prop *e;
1058 int ret;
1059
1060 ret = ecore_config_typed_default(key, &val, ECORE_CONFIG_FLT);
1061 e = ecore_config_get(key);
1062 if (e)
1063 {
1064 e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
1065 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
1066 e->lo = (int)(low * ECORE_CONFIG_FLOAT_PRECISION);
1067 e->hi = (int)(high * ECORE_CONFIG_FLOAT_PRECISION);
1068 ecore_config_bound(e);
1069 }
1070
1071 return ret;
1072}
1073
1074/**
1075 * Sets the indicated property to a color value if the property has not yet
1076 * been set.
1077 * @param key The property key.
1078 * @param a integer 0..255
1079 * @param r integer 0..255
1080 * @param g integer 0..255
1081 * @param b integer 0..255
1082 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1083 * @ingroup Ecore_Config_Default_Group
1084 */
1085EAPI int
1086ecore_config_argb_default(const char *key, int a, int r, int g, int b)
1087{
1088 long v = 0;
1089 return ecore_config_typed_default(key, __ecore_argb_to_long(a,r,g,b, &v), ECORE_CONFIG_RGB);
1090}
1091
1092/**
1093 * Sets the indicated property to a color value if the property has not yet
1094 * been set.
1095 * @param key The property key.
1096 * @param argb ARGB data as long
1097 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1098 * @ingroup Ecore_Config_Default_Group
1099 */
1100EAPI int
1101ecore_config_argbint_default(const char *key, long argb)
1102{
1103 return ecore_config_typed_default(key, &argb, ECORE_CONFIG_RGB);
1104}
1105
1106/**
1107 * Sets the indicated property to a color value if the property has not yet
1108 * been set.
1109 * @param key The property key.
1110 * @param val Color value in ARGB format.
1111 * @return @c ECORE_CONFIG_ERR_SUCC if there are no problems.
1112 * @ingroup Ecore_Config_Default_Group
1113 */
1114EAPI int
1115ecore_config_argbstr_default(const char *key, const char *val)
1116{
1117 long v = 0;
1118 return ecore_config_typed_default(key, __ecore_argbstr_to_long(val, &v), ECORE_CONFIG_RGB);
1119}
1120
1121/**
1122 * Sets the indicated property to a theme name if the property has not yet
1123 * been set.
1124 * @param key The property key.
1125 * @param val String giving the name of the theme.
1126 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1127 * @ingroup Ecore_Config_Default_Group
1128 */
1129EAPI int
1130ecore_config_theme_default(const char *key, const char *val)
1131{
1132 return ecore_config_typed_default(key, val, ECORE_CONFIG_THM);
1133}
1134
1135/**
1136 * @defgroup Ecore_Config_Struct_Group Ecore Config Structures
1137 *
1138 * Functions that are used to create structures of properties.
1139 */
1140
1141/**
1142 * Sets the indicated property to a structure if the property has not yet
1143 * been set.
1144 * @param key The property key.
1145 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1146 * @ingroup Ecore_Config_Struct_Group
1147 */
1148EAPI int
1149ecore_config_struct_create(const char *key)
1150{
1151 WRN("you are using ecore_config structures. These are very young");
1152 WRN(" and not complete - you have been warned");
1153
1154 return ecore_config_typed_default(key, NULL, ECORE_CONFIG_SCT);
1155}
1156
1157static int
1158_ecore_config_struct_append(Ecore_Config_Prop *sct, Ecore_Config_Prop *add)
1159{
1160 Eina_List *l;
1161
1162 if (!sct || !add || sct->type != ECORE_CONFIG_SCT)
1163 return ECORE_CONFIG_ERR_IGNORED;
1164
1165 l = sct->data;
1166 sct->data = eina_list_append(l, add);
1167 add->parent = sct;
1168
1169 return ECORE_CONFIG_ERR_SUCC;
1170}
1171
1172static int
1173_ecore_config_struct_typed_add(const char *key, const char *name, const void *val,
1174 int type)
1175{
1176 char *subkey;
1177 int ret;
1178
1179 subkey = malloc((strlen(key) + strlen(name) + 2) * sizeof(char));
1180 strcpy(subkey, key);
1181 strcat(subkey, ".");
1182 strcat(subkey, name);
1183
1184 ecore_config_typed_default(subkey, val, type);
1185 ret = _ecore_config_struct_append(ecore_config_get(key),
1186 ecore_config_get(subkey));
1187 free(subkey);
1188 return ret;
1189}
1190
1191/**
1192 * Add an int property to the named structure. The property is set if it has not
1193 * yet been set.
1194 * @param key The key of the structure to add to.
1195 * @param name The name of the item to add - this will be appended to the key
1196 * @param val the int to default to
1197 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1198 * @ingroup Ecore_Config_Struct_Group
1199 */
1200EAPI int
1201ecore_config_struct_int_add(const char *key, const char *name, int val)
1202{
1203 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_INT);
1204}
1205
1206/**
1207 * Add a float property to the named structure. The property is set if it has
1208 * not yet been set.
1209 * @param key The key of the structure to add to.
1210 * @param name The name of the item to add - this will be appended to the key
1211 * @param val The float to default to
1212 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1213 * @ingroup Ecore_Config_Struct_Group
1214 */
1215EAPI int
1216ecore_config_struct_float_add(const char *key, const char *name, float val)
1217{
1218 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_FLT);
1219}
1220
1221/**
1222 * Add a string property to the named structure. The property is set if it has
1223 * not yet been set.
1224 * @param key The key of the structure to add to.
1225 * @param name The name of the item to add - this will be appended to the key
1226 * @param val The string to default to
1227 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1228 * @ingroup Ecore_Config_Struct_Group
1229 */
1230EAPI int
1231ecore_config_struct_string_add(const char *key, const char *name, const char* val)
1232{
1233 return _ecore_config_struct_typed_add(key, name, val, ECORE_CONFIG_STR);
1234}
1235
1236/**
1237 * Add an argb property to the named structure. The property is set if it has
1238 * not yet been set.
1239 * @param key The key of the structure to add to.
1240 * @param name The name of the item to add - this will be appended to the key
1241 * @param a The alpha to default to
1242 * @param r The red to default to
1243 * @param g The green to default to
1244 * @param b The blue to default to
1245 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1246 * @ingroup Ecore_Config_Struct_Group
1247 */
1248EAPI int
1249ecore_config_struct_argb_add(const char *key, const char *name, int a, int r,
1250 int g, int b)
1251{
1252 long argb;
1253
1254 __ecore_argb_to_long(a, r, g, b, &argb);
1255 return _ecore_config_struct_typed_add(key, name, &argb, ECORE_CONFIG_RGB);
1256}
1257
1258/**
1259 * Add a theme property to the named structure. The property is set if it has
1260 * not yet been set.
1261 * @param key The key of the structure to add to.
1262 * @param name The name of the item to add - this will be appended to the key
1263 * @param val The theme name to default to
1264 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1265 * @ingroup Ecore_Config_Struct_Group
1266 */
1267EAPI int
1268ecore_config_struct_theme_add(const char *key, const char *name, const char* val)
1269{
1270 return _ecore_config_struct_typed_add(key, name, val, ECORE_CONFIG_THM);
1271}
1272
1273/**
1274 * Add a boolean property to the named structure. The property is set if it has
1275 * not yet been set.
1276 * @param key The key of the structure to add to.
1277 * @param name The name of the item to add - this will be appended to the key
1278 * @param val The boolean to default to
1279 * @return @c ECORE_CONFIG_ERR_SUCC if the property is set successfully.
1280 * @ingroup Ecore_Config_Struct_Group
1281 */
1282EAPI int
1283ecore_config_struct_boolean_add(const char *key, const char *name, int val)
1284{
1285 val = val ? 1 : 0;
1286 return _ecore_config_struct_typed_add(key, name, &val, ECORE_CONFIG_BLN);
1287}
1288
1289/**
1290 * Get the contents of a defined structure property and load it into the passed
1291 * C struct
1292 * @param key The name of the structure property to look up.
1293 * @param data The struct to write into.
1294 * @return @c ECORE_CONFIG_ERR_SUCC if the structure is written successfully.
1295 * @ingroup Ecore_Config_Struct_Group
1296 */
1297EAPI int
1298ecore_config_struct_get(const char *key, void *data)
1299{
1300 Ecore_Config_Prop *e, *f;
1301 Eina_List *l;
1302 unsigned char *ptr;
1303 long argb;
1304
1305 e = ecore_config_get(key);
1306 if (!e)
1307 return ECORE_CONFIG_ERR_NODATA;
1308
1309 l = e->data;
1310 ptr = data;
1311 while (l)
1312 {
1313 f = (Ecore_Config_Prop *) l->data;
1314 switch (f->type)
1315 {
1316 case ECORE_CONFIG_INT:
1317 *((int *) ptr) = _ecore_config_int_get(f);
1318 ptr += sizeof(int);
1319 break;
1320 case ECORE_CONFIG_BLN:
1321 *((int *) ptr) = _ecore_config_boolean_get(f);
1322 ptr += sizeof(int);
1323 break;
1324 case ECORE_CONFIG_FLT:
1325 *((float *) ptr) = _ecore_config_float_get(f);
1326 ptr += sizeof(float);
1327 break;
1328 case ECORE_CONFIG_STR:
1329 case ECORE_CONFIG_THM:
1330 *((char **) ptr) = _ecore_config_string_get(f);
1331 ptr += sizeof(char *);
1332 break;
1333 case ECORE_CONFIG_RGB:
1334 argb = _ecore_config_argbint_get(f);
1335 *((int *) ptr) = (argb >> 24) & 0xff;
1336 ptr += sizeof(int);
1337 *((int *) ptr) = (argb >> 16) & 0xff;
1338 ptr += sizeof(int);
1339 *((int *) ptr) = (argb >> 8) & 0xff;
1340 ptr += sizeof(int);
1341 *((int *) ptr) = argb & 0xff;
1342 ptr += sizeof(int);
1343 break;
1344 default:
1345 WRN("ARGH - STRUCT coding not implemented yet");
1346 }
1347 l = eina_list_next(l);
1348 }
1349 return ECORE_CONFIG_ERR_SUCC;
1350}
1351
1352/**
1353 * @defgroup Ecore_Config_Listeners_Group Ecore Config Listeners
1354 *
1355 * Functions that set and unset property listener callbacks.
1356 */
1357
1358/**
1359 * Adds a callback function to the list of functions called when a property
1360 * changes.
1361 * @param name Name of the callback.
1362 * @param key The key of the property to listen to.
1363 * @param listener Listener callback function.
1364 * @param tag Tag to pass to @p listener when it is called.
1365 * @param data Data to pass to @p listener when it is called.
1366 * @return @c ECORE_CONFIG_ERR_SUCC if successful in setting up the callback.
1367 * @ingroup Ecore_Config_Listeners_Group
1368 */
1369EAPI int
1370ecore_config_listen(const char *name, const char *key,
1371 Ecore_Config_Listener listener, int tag, void *data)
1372{
1373 Ecore_Config_Prop *e;
1374 Ecore_Config_Listener_List *l;
1375
1376 if (!key)
1377 return ECORE_CONFIG_ERR_NODATA;
1378
1379 if (!(e = ecore_config_get(key)))
1380 {
1381 int ret = ecore_config_add(key, "");
1382
1383 if (ret != ECORE_CONFIG_ERR_SUCC)
1384 {
1385 ERR("ecore_config_listen: ecore_config_add(\"%s\") failed: %d",
1386 key, ret);
1387 return ret;
1388 }
1389 if (!(e = ecore_config_get(key)))
1390 {
1391 ERR("ecore_config_listen: list of properties corrupted!?");
1392 return ECORE_CONFIG_ERR_FAIL;
1393 }
1394 }
1395
1396 for (l = e->listeners; l; l = l->next)
1397 if (!strcmp(l->name, name) || (l->listener == listener))
1398 {
1399 ERR("ecore_config_listen: %s is already listening for changes of %s...",
1400 name, key);
1401 return ECORE_CONFIG_ERR_IGNORED;
1402 }
1403
1404 if (!(l = malloc(sizeof(Ecore_Config_Listener_List))))
1405 return ECORE_CONFIG_ERR_OOM;
1406
1407 ERR("registering listener \"%s\" for \"%s\" (%d)...", name, key, e->type);
1408
1409 memset(l, 0, sizeof(Ecore_Config_Listener_List));
1410
1411 l->listener = listener;
1412 l->name = name;
1413 l->data = data;
1414 l->tag = tag;
1415 l->next = e->listeners;
1416 e->listeners = l;
1417
1418 if (e->type != ECORE_CONFIG_NIL) /* call right on creation if prop exists and has val */
1419 listener(key, e->type, tag, data);
1420
1421 return ECORE_CONFIG_ERR_SUCC;
1422}
1423
1424/**
1425 * Removes a listener callback.
1426 * @param name Name of the callback to remove.
1427 * @param key The property key the callback is listening to.
1428 * @param listener The callback function to remove.
1429 * @return @c ECORE_CONFIG_ERR_SUCC if successful in removing the callback.
1430 * If no callback matches the given parameters, then
1431 * @c ECORE_CONFIG_ERR_NOTFOUND is returned. If @c NULL is passed
1432 * for the key pointer, @c ECORE_CONFIG_ERR_NODATA is returned.
1433 * @ingroup Ecore_Config_Listeners_Group
1434 */
1435EAPI int
1436ecore_config_deaf(const char *name, const char *key,
1437 Ecore_Config_Listener listener)
1438{
1439 Ecore_Config_Prop *e;
1440 Ecore_Config_Listener_List *l, *p;
1441 int ret;
1442
1443 ret = ECORE_CONFIG_ERR_NOTFOUND;
1444
1445 if (!key)
1446 return ECORE_CONFIG_ERR_NODATA;
1447
1448 if (!(e = ecore_config_get(key)))
1449 return ECORE_CONFIG_ERR_NOTFOUND;
1450
1451 for (p = NULL, l = e->listeners; l; p = l)
1452 {
1453 Ecore_Config_Listener_List *nl;
1454
1455 nl = l->next;
1456 if ((name && !strcmp(l->name, name)) || (l->listener == listener))
1457 {
1458 ret = ECORE_CONFIG_ERR_SUCC;
1459 if (!p)
1460 e->listeners = e->listeners->next;
1461 else
1462 p->next = l->next;
1463 memset(l, 0, sizeof(Ecore_Config_Listener));
1464 free(l);
1465 }
1466 l = nl;
1467 }
1468
1469 return ret;
1470}
1471
1472/**
1473 * Locates the first configuration bundle on the given server.
1474 * @param srv The configuration server.
1475 * @return Pointer to the first configuration bundle.
1476 */
1477EAPI Ecore_Config_Bundle *
1478ecore_config_bundle_1st_get(Ecore_Config_Server * srv)
1479{ /* anchor: global, but read-only */
1480 return srv->bundles;
1481}
1482
1483/**
1484 * Locates the configuration bundle after the given one.
1485 * @param ns The configuration bundle.
1486 * @return The next configuration bundle.
1487 */
1488EAPI Ecore_Config_Bundle *
1489ecore_config_bundle_next_get(Ecore_Config_Bundle * ns)
1490{
1491 return ns ? ns->next : NULL;
1492}
1493
1494/**
1495 * Locates a configuration bundle on a configuration server based on its serial
1496 * number.
1497 * @param srv The configuration server.
1498 * @param serial Serial number.
1499 * @return The configuration bundle with the given serial number.
1500 */
1501EAPI Ecore_Config_Bundle *
1502ecore_config_bundle_by_serial_get(Ecore_Config_Server * srv, long serial)
1503{
1504 Ecore_Config_Bundle *eb;
1505
1506 eb = srv->bundles;
1507
1508 if (serial < 0)
1509 return NULL;
1510 else if (serial == 0)
1511 {
1512 Ecore_Config_Bundle *r = eb;
1513
1514 return r;
1515 }
1516
1517 while (eb)
1518 {
1519 if (eb->serial == serial)
1520 return eb;
1521 eb = eb->next;
1522 }
1523 return NULL;
1524}
1525
1526/**
1527 * Gets the Ecore_Config_Bundle with the given identifier from the given
1528 * server.
1529 * @param srv The configuration server.
1530 * @param label The bundle's identifier string.
1531 * @return The bundle with the given identifier string, or @c NULL if it
1532 * could not be found.
1533 */
1534EAPI Ecore_Config_Bundle *
1535ecore_config_bundle_by_label_get(Ecore_Config_Server * srv, const char *label)
1536{
1537 Ecore_Config_Bundle *ns;
1538
1539 ns = srv->bundles;
1540
1541 while (ns)
1542 {
1543 if (ns->identifier && !strcmp(ns->identifier, label))
1544 return ns;
1545 ns = ns->next;
1546 }
1547 return NULL;
1548}
1549
1550/**
1551 * Retrieves the bundle's serial number.
1552 * @param ns The configuration bundle.
1553 * @return The bundle's identifier string, or -1 if ns is @c NULL.
1554 */
1555EAPI long
1556ecore_config_bundle_serial_get(Ecore_Config_Bundle * ns)
1557{
1558 return ns ? ns->serial : -1;
1559}
1560
1561/**
1562 * Retrieves the bundle's identifier.
1563 * @param ns The configuration bundle.
1564 * @return The bundle's identifer string.
1565 */
1566EAPI char *
1567ecore_config_bundle_label_get(Ecore_Config_Bundle * ns)
1568{
1569 return ns ? ns->identifier : NULL;
1570}
1571
1572/**
1573 * Creates a new Ecore_Config_Bundle.
1574 * @param srv Config server.
1575 * @param identifier Identifier string for the new bundle.
1576 * @return A pointer to a new Ecore_Config_Bundle. @c NULL is returned if the
1577 * structure couldn't be allocated.
1578 */
1579EAPI Ecore_Config_Bundle *
1580ecore_config_bundle_new(Ecore_Config_Server * srv, const char *identifier)
1581{
1582 Ecore_Config_Bundle *t;
1583 static long ss;
1584
1585 ss = 0; /* bundle unique serial */
1586
1587 if ((t = malloc(sizeof(Ecore_Config_Bundle))))
1588 {
1589 memset(t, 0, sizeof(Ecore_Config_Bundle));
1590
1591 t->identifier = (char *)identifier;
1592 t->serial = ++ss;
1593 t->owner = srv->name;
1594 t->next = srv->bundles;
1595 srv->bundles = t;
1596 }
1597 return t;
1598}
1599
1600static Ecore_Config_Server *
1601do_init(const char *name)
1602{
1603 return _ecore_config_ipc_init(name);
1604}
1605
1606static Ecore_Config_Server *
1607ecore_config_init_local(const char *name)
1608{
1609 char *p;
1610 char *buf;
1611
1612 if ((p = getenv("HOME")))
1613 { /* debug-only ### FIXME */
1614 if (!(buf = malloc(PATH_MAX * sizeof(char))))
1615 return NULL;
1616 snprintf(buf, PATH_MAX, "%s/.ecore/%s/.global", p, name);
1617 unlink(buf);
1618
1619 free(buf);
1620 }
1621
1622 return do_init(name);
1623}
1624
1625static Ecore_Config_Server *
1626ecore_config_init_global(const char *name)
1627{
1628 char *p;
1629 int global;
1630 char *buf;
1631
1632 if ((p = getenv("HOME")))
1633 { /* debug-only ### FIXME */
1634 if (!(buf = malloc(PATH_MAX * sizeof(char))))
1635 return NULL;
1636 snprintf(buf, PATH_MAX, "%s/.ecore/%s/.global", p, name);
1637 global = creat(buf, S_IRWXU);
1638
1639 if (global >= 0)
1640 close(global);
1641
1642 free(buf);
1643 }
1644
1645 return do_init(name);
1646}
1647
1648/**
1649 * @defgroup Ecore_Config_App_Lib_Group Ecore Config App Library Functions
1650 *
1651 * Functions that are used to start up and shutdown the Enlightened
1652 * Property Library when used directly by an application.
1653 */
1654
1655/**
1656 * Initializes the Enlightened Property Library.
1657 *
1658 * Either this function or @ref ecore_config_system_init must be run
1659 * before any other function in the Enlightened Property Library, even
1660 * if you have run @ref ecore_init . The name given is used to
1661 * determine the default configuration to load.
1662 *
1663 * @param name Application name
1664 * @return @c ECORE_CONFIG_ERR_SUCC if the library is successfully set up.
1665 * @c ECORE_CONFIG_ERR_FAIL otherwise.
1666 * @ingroup Ecore_Config_App_Lib_Group
1667 */
1668EAPI int
1669ecore_config_init(const char *name)
1670{
1671 char *path;
1672 Ecore_Config_Prop *list;
1673 _ecore_config_log_dom = eina_log_domain_register
1674 ("ecore_config", ECORE_CONFIG_DEFAULT_LOG_COLOR);
1675 if(_ecore_config_log_dom < 0)
1676 {
1677 EINA_LOG_ERR("Impossible to create a log domain for the Ecore config module.");
1678 return -1;
1679 }
1680 _ecore_config_system_init_no_load();
1681
1682 __ecore_config_app_name = strdup(name);
1683 __ecore_config_server_local = ecore_config_init_local(name);
1684 if (!__ecore_config_server_local)
1685 return ECORE_CONFIG_ERR_FAIL;
1686
1687 list = __ecore_config_bundle_local->data;
1688 free( __ecore_config_bundle_local );
1689 __ecore_config_bundle_local =
1690 ecore_config_bundle_new(__ecore_config_server_local, "config");
1691 __ecore_config_bundle_local->data = list;
1692
1693 path = ecore_config_theme_default_path_get();
1694 ecore_config_string_default("/e/themes/search_path", path);
1695 if (path)
1696 free(path);
1697
1698 list = ecore_config_get("/e/themes/search_path");
1699 if (list)
1700 {
1701 list->flags |= ECORE_CONFIG_FLAG_SYSTEM;
1702 list->flags &= ~ECORE_CONFIG_FLAG_MODIFIED;
1703 }
1704
1705 return _ecore_config_system_load();
1706}
1707
1708/**
1709 * Frees memory and shuts down the library for an application.
1710 * @return @c ECORE_CONFIG_ERR_IGNORED .
1711 * @ingroup Ecore_Config_App_Lib_Group
1712 */
1713EAPI int
1714ecore_config_shutdown(void)
1715{
1716 return ecore_config_system_shutdown();
1717}
1718
1719/**
1720 * @defgroup Ecore_Config_Lib_Lib_Group Ecore Config Library Functions
1721 *
1722 * Functions that are used to start up and shutdown the Enlightened
1723 * Property Library when used directly by an application.
1724 */
1725
1726/**
1727 * Initializes the Enlightened Property Library.
1728 *
1729 * This function is meant to be run from other programming libraries.
1730 * It should not be called from applications.
1731 *
1732 * This function (or @ref ecore_config_init )
1733 * must be run before any other function in the
1734 * Enlightened Property Library, even if you have run @ref ecore_init .
1735 *
1736 * @return @c ECORE_CONFIG_ERR_SUCC if the library is successfully set up.
1737 * @c ECORE_CONFIG_ERR_FAIL otherwise.
1738 * @ingroup Ecore_Config_Lib_Lib_Group
1739 */
1740EAPI int
1741ecore_config_system_init(void)
1742{
1743 _ecore_config_system_init_no_load();
1744 return _ecore_config_system_load();
1745}
1746
1747static int
1748_ecore_config_system_init_no_load(void)
1749{
1750 char *p;
1751
1752 __ecore_config_system_init++;
1753 if (__ecore_config_system_init > 1)
1754 return ECORE_CONFIG_ERR_IGNORED;
1755
1756 DEBUG = -1;
1757 if ((p = getenv("ECORE_CONFIG_DEBUG")) && p[0] != 0)
1758 {
1759 DEBUG = atoi(p);
1760 }
1761
1762 __ecore_config_server_global =
1763 ecore_config_init_global(ECORE_CONFIG_GLOBAL_ID);
1764 if (!__ecore_config_server_global)
1765 return ECORE_CONFIG_ERR_FAIL;
1766
1767 __ecore_config_bundle_local =
1768 ecore_config_bundle_new(__ecore_config_server_global, "system");
1769
1770 /* set up a simple default path */
1771 ecore_config_string_default("/e/themes/search_path", PACKAGE_DATA_DIR "../ewl/themes");
1772
1773 return ECORE_CONFIG_ERR_SUCC;
1774}
1775
1776
1777static int
1778_ecore_config_system_load(void)
1779{
1780 char *buf, *p;
1781 Ecore_Config_Prop *sys;
1782
1783 if (__ecore_config_system_init != 1)
1784 return ECORE_CONFIG_ERR_FAIL;
1785
1786 if ((p = getenv("HOME")))
1787 { /* debug-only ### FIXME */
1788 if ((buf = malloc(PATH_MAX * sizeof(char))))
1789 {
1790 snprintf(buf, PATH_MAX, "%s/.e/config.eet", p);
1791 if (ecore_config_file_load(buf) != 0) {
1792 /* even if this file (system.eet) doesn't exist we can
1793 * continue without it as it isn't striclty necessary.
1794 */
1795 ecore_config_file_load(PACKAGE_DATA_DIR "/system.eet");
1796 }
1797 sys = __ecore_config_bundle_local->data;
1798 while (sys)
1799 {
1800 /* unmark it modified - modification will mean it has been overridden */
1801 sys->flags &= ~ECORE_CONFIG_FLAG_MODIFIED;
1802 /* mark as system so that examine can hide them */
1803 sys->flags |= ECORE_CONFIG_FLAG_SYSTEM;
1804 sys = sys->next;
1805 }
1806 }
1807 free(buf);
1808 }
1809
1810 return ECORE_CONFIG_ERR_SUCC;
1811}
1812
1813
1814/**
1815 * Frees memory and shuts down the library for other programming libraries.
1816 * @return @c ECORE_CONFIG_ERR_IGNORED
1817 * @ingroup Ecore_Config_Lib_Lib_Group
1818 */
1819EAPI int
1820ecore_config_system_shutdown(void)
1821{
1822 int ret;
1823
1824 __ecore_config_system_init--;
1825 if (__ecore_config_system_init > 0)
1826 return ECORE_CONFIG_ERR_IGNORED;
1827
1828 ret = _ecore_config_ipc_exit();
1829 if (__ecore_config_app_name)
1830 free(__ecore_config_app_name);
1831 while(__ecore_config_bundle_local->data)
1832 ecore_config_dst(__ecore_config_bundle_local->data);
1833 free(__ecore_config_bundle_local);
1834 free(__ecore_config_server_local);
1835 free(__ecore_config_server_global);
1836 eina_log_domain_unregister(_ecore_config_log_dom);
1837 _ecore_config_log_dom = -1;
1838 return ret;
1839}
1840
1841static inline void *
1842__ecore_argb_to_long(int a, int r, int g, int b, long *v)
1843{
1844 *v = ((a << 24) & 0xff000000 )
1845 | ((r << 16) & 0xff0000 )
1846 | ((g << 8) & 0xff00 )
1847 | ( b & 0xff );
1848
1849 return v;
1850}
1851
1852static inline void *
1853__ecore_argbstr_to_long(const char *argb, long *v)
1854{
1855 char *l = NULL;
1856
1857 // convert hexadecimal string #..., #0x..., 0x..., ... to long
1858 if(*argb == '#')
1859 argb++;
1860 *v = (long)strtoul( argb, &l, 16);
1861
1862 if(*l)
1863 {
1864 ERR("ecore_config_val: value \"%s\" not a valid hexadecimal RGB value?", argb);
1865 return NULL;
1866 }
1867
1868 return v;
1869}
1870
diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config_db.c b/legacy/ecore/src/lib/ecore_config/ecore_config_db.c
deleted file mode 100644
index 6238958aa1..0000000000
--- a/legacy/ecore/src/lib/ecore_config/ecore_config_db.c
+++ /dev/null
@@ -1,296 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8#include <limits.h>
9
10#include <sys/param.h>
11#include <sys/types.h>
12#include <sys/stat.h>
13#include <unistd.h>
14#include <locale.h>
15
16#include <Eet.h>
17
18#include "Ecore_Config.h"
19#include "ecore_config_private.h"
20#include "ecore_config_util.h"
21
22struct _Ecore_Config_DB_File
23{
24 Eet_File *ef;
25};
26
27Ecore_Config_DB_File *
28_ecore_config_db_open_read(const char *file)
29{
30 Eet_File *ef;
31 Ecore_Config_DB_File *db;
32
33 eet_init();
34 db = malloc(sizeof(Ecore_Config_DB_File));
35 if (!db) return NULL;
36 ef = eet_open((char*)file, EET_FILE_MODE_READ);
37 if (!ef)
38 {
39 free(db);
40 return NULL;
41 }
42 db->ef = ef;
43 return db;
44}
45
46Ecore_Config_DB_File *
47_ecore_config_db_open_write(const char *file)
48{
49 Eet_File *ef;
50 Ecore_Config_DB_File *db;
51
52 eet_init();
53 db = malloc(sizeof(Ecore_Config_DB_File));
54 if (!db) return NULL;
55 ef = eet_open((char*)file, EET_FILE_MODE_WRITE);
56 if (!ef)
57 {
58 free(db);
59 return NULL;
60 }
61 db->ef = ef;
62 return db;
63}
64
65void
66_ecore_config_db_close(Ecore_Config_DB_File *db)
67{
68 eet_close(db->ef);
69 free(db);
70 eet_shutdown();
71}
72
73char **
74_ecore_config_db_keys_get(Ecore_Config_DB_File *db, int *num_ret)
75{
76 char **keys;
77 int key_count;
78 int i;
79
80 keys = eet_list(db->ef, (char*)"*", &key_count);
81 if (!keys)
82 {
83 *num_ret = 0;
84 return NULL;
85 }
86 /* make keys freeable - this is safe to do */
87 for (i = 0; i < key_count; i++) keys[i] = strdup(keys[i]);
88 *num_ret = key_count;
89 return keys;
90}
91
92Ecore_Config_Type
93_ecore_config_db_key_type_get(Ecore_Config_DB_File *db, const char *key)
94{
95 char *data;
96 int size;
97
98 data = eet_read(db->ef, (char*)key, &size);
99 if (data)
100 {
101 if (size <= 2)
102 {
103 free(data);
104 return ECORE_CONFIG_NIL;
105 }
106 if (data[size - 1] != 0)
107 {
108 free(data);
109 return ECORE_CONFIG_NIL;
110 }
111 return (Ecore_Config_Type) data[0];
112 }
113 return ECORE_CONFIG_NIL;
114}
115
116int
117_ecore_config_db_read(Ecore_Config_DB_File *db, const char *key)
118{
119 char *data, *value;
120 int size;
121 Ecore_Config_Type type;
122
123 data = eet_read(db->ef, (char*)key, &size);
124 if (data)
125 {
126 int l;
127 char *prev_locale;
128
129 if (size <= 2)
130 {
131 free(data);
132 return 0;
133 }
134 if (data[size - 1] != 0)
135 {
136 free(data);
137 return 0;
138 }
139 /* "type" NIL 1242 NIL */
140 l = strlen(data);
141 if (l >= (size - 1))
142 {
143 free(data);
144 return 0;
145 }
146
147 type = data[0];
148 value = data + l + 1;
149
150 switch (type)
151 {
152 case ECORE_CONFIG_INT:
153 case ECORE_CONFIG_BLN:
154 {
155 int tmp;
156 prev_locale = setlocale(LC_NUMERIC, "C");
157 tmp = atoi(value);
158 if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
159
160 ecore_config_typed_set(key, (void *)&tmp, type);
161 break;
162 }
163 case ECORE_CONFIG_FLT:
164 {
165 float tmp;
166 prev_locale = setlocale(LC_NUMERIC, "C");
167 tmp = atof(value);
168 if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
169
170 ecore_config_typed_set(key, (void *)&tmp, type);
171 break;
172 }
173 case ECORE_CONFIG_RGB:
174 ecore_config_argbstr_set(key, value);
175 break;
176 case ECORE_CONFIG_STR:
177 case ECORE_CONFIG_THM:
178 ecore_config_typed_set(key, (void *)value, type);
179 break;
180 case ECORE_CONFIG_SCT:
181 INF("loading struct %s", key);
182 break;
183 default:
184 WRN("Type %d not handled", type);
185 }
186 free(data);
187 return 1;
188 }
189 return 0;
190}
191
192/*
193void *
194_ecore_config_db_key_data_get(Ecore_Config_DB_File *db, const char *key, int *size_ret)
195{
196 char *data;
197 int size;
198
199 data = eet_read(db->ef, (char*)key, &size);
200 if (data)
201 {
202 int l;
203 char *dat;
204
205 if (size <= 2)
206 {
207 free(data);
208 return NULL;
209 }
210 if (data[size - 1] != 0)
211 {
212 free(data);
213 return NULL;
214 }
215 * "type" NIL data_goes_here NIL *
216 l = strlen(data);
217 if (l >= (size - 1))
218 {
219 free(data);
220 return NULL;
221 }
222 dat = malloc(size - (l + 2));
223 memcpy(dat, data + l + 1, size - (l + 2));
224 free(data);
225 *size_ret = size - (l + 2);
226 return dat;
227 }
228 return NULL;
229}*/
230
231void
232_ecore_config_db_write(Ecore_Config_DB_File *db, Ecore_Config_Prop *e)
233{
234 char *prev_locale= NULL;
235 char *val = NULL;
236 char *r = NULL;
237 int num;
238
239 prev_locale = setlocale(LC_NUMERIC, "C");
240
241 switch (e->type)
242 {
243 case ECORE_CONFIG_INT:
244 esprintf(&val, "%i", _ecore_config_int_get(e));
245 break;
246 case ECORE_CONFIG_BLN:
247 esprintf(&val, "%i", _ecore_config_boolean_get(e));
248 break;
249 case ECORE_CONFIG_FLT:
250 esprintf(&val, "%16.16f", _ecore_config_float_get(e));
251 break;
252 case ECORE_CONFIG_STR:
253 val = _ecore_config_string_get(e);
254 break;
255 case ECORE_CONFIG_THM:
256 val = _ecore_config_theme_get(e);
257 break;
258 case ECORE_CONFIG_RGB:
259 val = _ecore_config_argbstr_get(e);
260 break;
261 default:
262 WRN("Type %d not handled", e->type);
263 }
264
265 if (prev_locale)
266 {
267 setlocale(LC_NUMERIC, prev_locale);
268 }
269
270 if(val)
271 {
272 num = esprintf(&r, "%c%c%s%c", (char) e->type, 0, val, 0);
273 if(num)
274 eet_write(db->ef, e->key, r, num, 1);
275 free(r);
276 }
277
278 free(val);
279}
280/*
281void
282_ecore_config_db_key_data_set(Ecore_Config_DB_File *db, const char *key, void *data, int data_size)
283{
284 char *buf;
285 int num;
286
287 num = 1 + 1 + data_size + 1;
288 buf = malloc(num);
289 if (!buf) return;
290 buf[0] = (char) ECORE_CONFIG_BIN;
291 buf[1] = 0;
292 memcpy(buf + 2, data, data_size);
293 buf[num - 1] = 0;
294 eet_write(db->ef, (char*)key, buf, num, 1);
295 free(buf);
296}*/
diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config_extra.c b/legacy/ecore/src/lib/ecore_config/ecore_config_extra.c
deleted file mode 100644
index a134952ee8..0000000000
--- a/legacy/ecore/src/lib/ecore_config/ecore_config_extra.c
+++ /dev/null
@@ -1,803 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <string.h>
6#include <stdio.h>
7#include <stdlib.h>
8
9#include <sys/types.h>
10#include <sys/stat.h>
11
12#include "Ecore_Config.h"
13#include "Ecore.h"
14#include "ecore_config_private.h"
15typedef struct __Ecore_Config_Arg_Callback _Ecore_Config_Arg_Callback;
16struct __Ecore_Config_Arg_Callback
17{
18 char short_opt;
19 char *long_opt;
20 char *description;
21 void *data;
22 void (*func)(char *val, void *data);
23 Ecore_Config_Type type;
24 _Ecore_Config_Arg_Callback *next;
25};
26
27char *__ecore_config_app_description;
28_Ecore_Config_Arg_Callback *_ecore_config_arg_callbacks;
29
30/* shorthand prop setup code to make client apps a little smaller ;) */
31
32/**
33 * Creates a new property, if it does not already exist, and sets its
34 * attributes to those given.
35 *
36 * The type of the property is guessed from the key and the value
37 * given.
38 *
39 * @param key The property key.
40 * @param val Pointer to default value of key.
41 * @param short_opt Short option used to set the property from command
42 * line.
43 * @param long_opt Long option used to set the property from command line.
44 * @param desc String description of property.
45 * @return @c ECORE_CONFIG_ERR_SUCC on success.
46 * @ingroup Ecore_Config_Create_Group
47 */
48int
49ecore_config_create(const char *key, void *val, char short_opt, char *long_opt,
50 char *desc)
51{
52 int type = ecore_config_type_guess(key, val);
53
54 return ecore_config_typed_create(key, val, type, short_opt, long_opt, desc);
55}
56
57/**
58 * Creates a new property, if it does not already exist, and sets its
59 * attributes to those given.
60 * @param key The property key.
61 * @param val Pointer to default value of key.
62 * @param type Type of the property.
63 * @param short_opt Short option used to set the property from
64 * command line.
65 * @param long_opt Long option used to set the property from command line.
66 * @param desc String description of property.
67 * @return @c ECORE_CONFIG_ERR_SUCC on success.
68 * @ingroup Ecore_Config_Create_Group
69 */
70int
71ecore_config_typed_create(const char *key, void *val, int type, char short_opt,
72 char *long_opt, char *desc)
73{
74 int ret;
75
76 if ((ret =
77 ecore_config_typed_default(key, val, type)) != ECORE_CONFIG_ERR_SUCC)
78 return ret;
79 if ((ret =
80 ecore_config_short_opt_set(key, short_opt)) != ECORE_CONFIG_ERR_SUCC)
81 return ret;
82 if ((ret =
83 ecore_config_long_opt_set(key, long_opt)) != ECORE_CONFIG_ERR_SUCC)
84 return ret;
85 ret = ecore_config_describe(key, desc);
86 return ret;
87}
88
89/**
90 * Creates a new boolean property, if it does not already exist, and sets its
91 * attributes to those given.
92 * @param key The property key.
93 * @param val Default boolean value of key.
94 * @param short_opt Short option used to set the property from command
95 * line.
96 * @param long_opt Long option used to set the property from command line.
97 * @param desc String description of property.
98 * @return @c ECORE_CONFIG_ERR_SUCC on success.
99 * @ingroup Ecore_Config_Create_Group
100 */
101int
102ecore_config_boolean_create(const char *key, int val, char short_opt,
103 char *long_opt, char *desc)
104{
105 return
106 ecore_config_typed_create(key, (void *)&val, ECORE_CONFIG_BLN, short_opt, long_opt,
107 desc);
108}
109
110/**
111 * Creates a new integer property, if it does not already exist, and sets its
112 * attributes to those given.
113 * @param key The property key.
114 * @param val Default integer value of key.
115 * @param short_opt Short option used to set the property from command
116 * line.
117 * @param long_opt Long option used to set the property from command line.
118 * @param desc String description of property.
119 * @return @c ECORE_CONFIG_ERR_SUCC on success.
120 * @ingroup Ecore_Config_Create_Group
121 */
122int
123ecore_config_int_create(const char *key, int val, char short_opt,
124 char *long_opt, char *desc)
125{
126 return
127 ecore_config_typed_create(key, (void *)&val, ECORE_CONFIG_INT, short_opt, long_opt,
128 desc);
129}
130
131/**
132 * Creates a new integer property, if it does not already exist, and sets its
133 * attributes to those given.
134 * @param key The property key.
135 * @param val Default integer value of key.
136 * @param low Lowest valid integer value for the property.
137 * @param high Highest valid integer value for the property.
138 * @param step Increment value for the property.
139 * @param short_opt Short option used to set the property from command
140 * line.
141 * @param long_opt Long option used to set the property from command line.
142 * @param desc String description of property.
143 * @return @c ECORE_CONFIG_ERR_SUCC on success.
144 * @ingroup Ecore_Config_Create_Group
145 */
146int
147ecore_config_int_create_bound(const char *key, int val, int low, int high,
148 int step, char short_opt, char *long_opt,
149 char *desc)
150{
151 Ecore_Config_Prop *e;
152 int ret;
153
154 ret =
155 ecore_config_typed_create(key, (void *)&val, ECORE_CONFIG_INT, short_opt, long_opt,
156 desc);
157 if (ret != ECORE_CONFIG_ERR_SUCC)
158 return ret;
159 e = ecore_config_get(key);
160 if (e)
161 {
162 e->step = step;
163 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
164 e->lo = low;
165 e->hi = high;
166 ecore_config_bound(e);
167 }
168 return ret;
169}
170
171/**
172 * Creates a new string property, if it does not already exist, and sets its
173 * attributes to those given.
174 * @param key The property key.
175 * @param val Default value of key.
176 * @param short_opt Short option used to set the property from command
177 * line.
178 * @param long_opt Long option used to set the property from command line.
179 * @param desc String description of property.
180 * @return @c ECORE_CONFIG_ERR_SUCC on success.
181 * @ingroup Ecore_Config_Create_Group
182 */
183int
184ecore_config_string_create(const char *key, char *val, char short_opt,
185 char *long_opt, char *desc)
186{
187 return
188 ecore_config_typed_create(key, (void *)val, ECORE_CONFIG_STR, short_opt, long_opt,
189 desc);
190}
191
192/**
193 * Creates a new float property, if it does not already exist, and sets its
194 * attributes to those given.
195 * @param key The property key.
196 * @param val Default float value of key.
197 * @param short_opt Short option used to set the property from command
198 * line.
199 * @param long_opt Long option used to set the property from command line.
200 * @param desc String description of property.
201 * @return @c ECORE_CONFIG_ERR_SUCC on success.
202 * @ingroup Ecore_Config_Create_Group
203 */
204int
205ecore_config_float_create(const char *key, float val, char short_opt,
206 char *long_opt, char *desc)
207{
208 return
209 ecore_config_typed_create(key, (void *)&val, ECORE_CONFIG_FLT, short_opt, long_opt,
210 desc);
211}
212
213/**
214 * Creates a new float property, if it does not already exist, and sets its
215 * attributes to those given.
216 * @param key The property key.
217 * @param val Default float value of key.
218 * @param low Lowest valid float value for the property.
219 * @param high Highest valid float value for the property.
220 * @param step Increment value for the property.
221 * @param short_opt Short option used to set the property from command
222 * line.
223 * @param long_opt Long option used to set the property from command line.
224 * @param desc String description of property.
225 * @return @c ECORE_CONFIG_ERR_SUCC on success.
226 * @ingroup Ecore_Config_Create_Group
227 */
228int
229ecore_config_float_create_bound(const char *key, float val, float low,
230 float high, float step, char short_opt,
231 char *long_opt, char *desc)
232{
233 Ecore_Config_Prop *e;
234 int ret;
235
236 ret =
237 ecore_config_typed_create(key, (void *)&val, ECORE_CONFIG_FLT, short_opt, long_opt,
238 desc);
239 e = ecore_config_get(key);
240 if (e)
241 {
242 e->step = (int)(step * ECORE_CONFIG_FLOAT_PRECISION);
243 e->flags |= ECORE_CONFIG_FLAG_BOUNDS;
244 e->lo = (int)(low * ECORE_CONFIG_FLOAT_PRECISION);
245 e->hi = (int)(high * ECORE_CONFIG_FLOAT_PRECISION);
246 ecore_config_bound(e);
247 }
248 return ret;
249}
250
251/**
252 * Creates a new color property, if it does not already exist, and sets its
253 * attributes to those given.
254 * @param key The property key.
255 * @param val Default color value of key, as a hexadecimal string.
256 * @param short_opt Short option used to set the property from command
257 * line.
258 * @param long_opt Long option used to set the property from command line.
259 * @param desc String description of property.
260 * @return @c ECORE_CONFIG_ERR_SUCC on success.
261 * @ingroup Ecore_Config_Create_Group
262 */
263int
264ecore_config_argb_create(const char *key, char *val, char short_opt,
265 char *long_opt, char *desc)
266{
267 return
268 ecore_config_typed_create(key, (void *)val, ECORE_CONFIG_RGB, short_opt, long_opt,
269 desc);
270}
271
272/**
273 * Creates a new theme property, if it does not already exist, and sets its
274 * attributes to those given.
275 * @param key The property key.
276 * @param val Default theme name for the property.
277 * @param short_opt Short option used to set the property from command
278 * line.
279 * @param long_opt Long option used to set the property from command line.
280 * @param desc String description of property.
281 * @return @c ECORE_CONFIG_ERR_SUCC on success.
282 * @ingroup Ecore_Config_Create_Group
283 */
284int
285ecore_config_theme_create(const char *key, char *val, char short_opt,
286 char *long_opt, char *desc)
287{
288 return
289 ecore_config_typed_create(key, (void *)val, ECORE_CONFIG_THM, short_opt, long_opt,
290 desc);
291}
292
293/* this should only be built if evas is present */
294
295/**
296 * Calls evas_font_path_append on @p evas for each of the font names stored
297 * in the property "/e/font/path".
298 * @param evas Evas object to append the font names to.
299 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_NODATA
300 * is returned if the property has not been set.
301 */
302int
303ecore_config_evas_font_path_apply(Evas * evas)
304{
305 char *font_path, *font_path_tmp, *ptr, *end;
306
307 font_path = ecore_config_string_get("/e/font/path");
308
309 if (!font_path)
310 return ECORE_CONFIG_ERR_NODATA;
311 ptr = font_path;
312 end = font_path + strlen(font_path);
313 font_path_tmp = font_path;
314 while (ptr && ptr < end)
315 {
316 while (*ptr != '|' && ptr < end)
317 ptr++;
318 if (ptr < end)
319 *ptr = '\0';
320
321 evas_font_path_append(evas, font_path_tmp);
322 ptr++;
323 font_path_tmp = ptr;
324 }
325
326 free(font_path);
327
328 return ECORE_CONFIG_ERR_SUCC;
329}
330
331/**
332 * Retrieves the default theme search path.
333 *
334 * @return The default theme search path.
335 */
336char *
337ecore_config_theme_default_path_get(void)
338{
339 char *path, *home;
340 int len;
341
342 home = getenv("HOME");
343 len = strlen(PACKAGE_DATA_DIR "/../") + strlen(__ecore_config_app_name) +
344 strlen("/themes/") + 1;
345 if (home)
346 len += strlen(home) + strlen("/.e/apps/") +
347 strlen(__ecore_config_app_name) +
348 strlen("/themes/|"); /* no \0, as that is above */
349
350 if (!(path = malloc(len)))
351 return NULL;
352
353 *path = '\0';
354 if (home)
355 {
356 strcat(path, home);
357 strcat(path, "/.e/apps/");
358 strcat(path, __ecore_config_app_name);
359 strcat(path, "/themes/|");
360 }
361 strcat(path, PACKAGE_DATA_DIR "/../");
362 strcat(path, __ecore_config_app_name);
363 strcat(path, "/themes/");
364
365 return path;
366}
367
368/**
369 * Retrieves the search path used to find themes.
370 *
371 * The search path is stored in the property "/e/themes/search_path". If
372 * the property has not been set, the default path used is
373 * "/usr/local/share/<app_name>/themes|~/.e/apps/<app_name>/themes".
374 * See @ref ecore_config_theme_default_path_get for more information about
375 * the default path.
376 *
377 * @return The search path. @c NULL is returned if there is no memory left.
378 */
379char *
380ecore_config_theme_search_path_get(void)
381{
382 char *search_path;
383 search_path = ecore_config_string_get("/e/themes/search_path");
384
385 /* this should no longer be the case, as it is defaulted in init */
386 if (!search_path)
387 {
388 search_path = ecore_config_theme_default_path_get();
389 if (search_path)
390 {
391 ecore_config_string_default("/e/themes/search_path", search_path);
392 free(search_path);
393 }
394 }
395 return search_path;
396}
397
398/**
399 * Adds the given path to the search path used to find themes.
400 *
401 * If the search path is successfully, the new search path will be saved
402 * into the property "/e/themes/search_path". Therefore, this function
403 * should be called @b after @ref ecore_config_load to allow a user to
404 * override the default search path.
405 *
406 * @param path The given
407 * @return @c ECORE_CONFIG_ERR_SUCC on success. @c ECORE_CONFIG_ERR_FAIL
408 * will be returned if @p path already exists in the search path.
409 * @c ECORE_CONFIG_ERR_FAIL is returned if @p path is @c NULL.
410 */
411int
412ecore_config_theme_search_path_append(const char *path)
413{
414 char *search_path, *loc, *new_search_path;
415 int len, search_len;
416 Ecore_Config_Prop *prop;
417
418 if (!path)
419 return ECORE_CONFIG_ERR_NODATA;
420 search_path = ecore_config_theme_search_path_get();
421
422 loc = strstr(search_path, path);
423 len = strlen(path);
424 search_len = strlen(search_path);
425
426 if (!loc || (loc != search_path && *(loc - 1) != '|') ||
427 (loc != (search_path + search_len - len) && *(loc + len - 1) != '|'))
428 {
429 new_search_path = malloc(search_len + len + 2); /* 2 = \0 + | */
430 strcpy(new_search_path, search_path);
431 strncat(new_search_path, "|", 1);
432 strncat(new_search_path, path, len);
433
434 ecore_config_string_set("/e/themes/search_path", new_search_path);
435 prop = ecore_config_get("/e/themes/search_path");
436 if (prop)
437 prop->flags &= ~ECORE_CONFIG_FLAG_MODIFIED;
438
439 free(new_search_path);
440
441 return ECORE_CONFIG_ERR_SUCC;
442 }
443 return ECORE_CONFIG_ERR_FAIL;
444}
445
446/**
447 * Retrieve a theme file's full path.
448 *
449 * The search path for theme files is given by @ref
450 * ecore_config_theme_search_path_get .
451 *
452 * @param name The name of the theme.
453 * @return A full path to the theme on success. @c NULL will be returned
454 * if @p name is @c NULL or no theme matching the given name could
455 * be found.
456 */
457char *
458ecore_config_theme_with_path_from_name_get(char *name)
459{
460 char *search_path, *search_path_tmp, *ptr, *end, *file;
461 struct stat st;
462
463 if (!name)
464 return NULL; /* no theme specified (nor a default) */
465
466 search_path = ecore_config_theme_search_path_get();
467 ptr = search_path;
468 end = search_path + strlen(search_path);
469 search_path_tmp = search_path;
470 while (ptr && ptr < end)
471 {
472 while (*ptr != '|' && ptr < end)
473 ptr++;
474 if (ptr < end)
475 *ptr = '\0';
476
477 file = malloc(strlen(search_path_tmp) + strlen(name) + 6);
478 /* 6 = / + .edj + \0 */
479
480 snprintf(file, strlen(search_path_tmp) + strlen(name) + 6,
481 "%s/%s.edj", search_path_tmp, name);
482
483 if (stat(file, &st) == 0)
484 {
485 free(search_path);
486 return file;
487 }
488 free(file);
489 ptr++;
490 search_path_tmp = ptr;
491 }
492
493 free(search_path);
494
495 return NULL; /* we could not find the theme with that name in search path */
496}
497
498/**
499 * Retrieves the full path to the theme file of the theme stored in the
500 * given property.
501 *
502 * The search path for themes is given by @ref
503 * ecore_config_theme_search_path_get .
504 *
505 * @param key The given property.
506 * @return A full path to the theme on success, or @c NULL on failure.
507 * This function will fail if no key is specified or not theme
508 * matching that given by the property @p key could be found.
509 */
510char *
511ecore_config_theme_with_path_get(const char *key)
512{
513 return
514 ecore_config_theme_with_path_from_name_get(ecore_config_theme_get(key));
515}
516
517static const char *_ecore_config_short_types[] =
518 { " ", "<int> ", "<flt> ", "<str> ", "<rgb> ", "<str> ", "<bool>" };
519
520/**
521 * Prints the property list of the local configuration bundle to output.
522 */
523void
524ecore_config_args_display(void)
525{
526 Ecore_Config_Prop *props;
527 _Ecore_Config_Arg_Callback *callbacks;
528
529 if (__ecore_config_app_description)
530 ERR("%s\n\n", __ecore_config_app_description);
531 ERR("Supported Options:");
532 ERR(" -h, --help\t Print this text");
533 if (!__ecore_config_bundle_local)
534 return;
535 props = __ecore_config_bundle_local->data;
536 while (props)
537 {
538 /* if it is a system prop, or cannot be set on command line hide it */
539 if (props->flags & ECORE_CONFIG_FLAG_SYSTEM || (!props->short_opt && !props->long_opt))
540 {
541 props = props->next;
542 continue;
543 }
544 INF(" %c%c%c --%s\t%s %s", props->short_opt ? '-' : ' ',
545 props->short_opt ? props->short_opt : ' ',
546 props->short_opt ? ',' : ' ',
547 props->long_opt ? props->long_opt : props->key,
548 _ecore_config_short_types[props->type],
549 props->description ? props->description :
550 "(no description available)");
551
552 props = props->next;
553 }
554 callbacks = _ecore_config_arg_callbacks;
555 while (callbacks)
556 {
557 INF(" %c%c%c --%s\t%s %s", callbacks->short_opt ? '-' : ' ',
558 callbacks->short_opt ? callbacks->short_opt : ' ',
559 callbacks->short_opt ? ',' : ' ',
560 callbacks->long_opt ? callbacks->long_opt : "",
561 _ecore_config_short_types[callbacks->type],
562 callbacks->description ? callbacks->description :
563 "(no description available)");
564
565 callbacks = callbacks->next;
566 }
567}
568
569static int
570ecore_config_parse_set(Ecore_Config_Prop * prop, char *arg, char *opt,
571 char opt2)
572{
573 if (!arg)
574 {
575 if (opt)
576 ERR("Missing expected argument for option --%s", opt);
577 else
578 ERR("Missing expected argument for option -%c", opt2);
579 return ECORE_CONFIG_PARSE_EXIT;
580 }
581 else
582 {
583 ecore_config_set(prop->key, arg);
584 prop->flags |= ECORE_CONFIG_FLAG_CMDLN;
585 }
586 return ECORE_CONFIG_PARSE_CONTINUE;
587}
588
589static void
590ecore_config_args_callback_add(char short_opt, char *long_opt, char *desc,
591 void (*func)(char *val, void *data),
592 void *data, Ecore_Config_Type type) {
593 _Ecore_Config_Arg_Callback *new_cb;
594
595 new_cb = malloc(sizeof(_Ecore_Config_Arg_Callback));
596 new_cb->short_opt = short_opt;
597 if (long_opt)
598 new_cb->long_opt = strdup(long_opt);
599 if (desc)
600 new_cb->description = strdup(desc);
601 new_cb->data = data;
602 new_cb->func = func;
603 new_cb->type = type;
604
605 new_cb->next = _ecore_config_arg_callbacks;
606 _ecore_config_arg_callbacks = new_cb;
607}
608
609void
610ecore_config_args_callback_str_add(char short_opt, char *long_opt, char *desc,
611 void (*func)(char *val, void *data),
612 void *data) {
613 ecore_config_args_callback_add(short_opt, long_opt, desc, func, data, ECORE_CONFIG_STR);
614}
615
616void
617ecore_config_args_callback_noarg_add(char short_opt, char *long_opt, char *desc,
618 void (*func)(char *val, void *data),
619 void *data) {
620 ecore_config_args_callback_add(short_opt, long_opt, desc, func, data, ECORE_CONFIG_NIL);
621}
622
623/**
624 * Parse the arguments set by @ref ecore_app_args_set and set properties
625 * accordingly.
626 *
627 * @return @c ECORE_CONFIG_PARSE_CONTINUE if successful.
628 * @c ECORE_CONFIG_PARSE_EXIT is returned if an unrecognised option
629 * is found. @c ECORE_CONFIG_PARSE_HELP is returned if help was
630 * displayed.
631 */
632int
633ecore_config_args_parse(void)
634{
635 int argc;
636 char **argv;
637 int nextarg, next_short_opt, found, ret;
638 char *arg;
639 char *long_opt, short_opt;
640 Ecore_Config_Prop *prop;
641 _Ecore_Config_Arg_Callback *callback;
642
643 ecore_app_args_get(&argc, &argv);
644 nextarg = 1;
645 while (nextarg < argc)
646 {
647 arg = argv[nextarg];
648
649 if (*arg != '-')
650 {
651 ERR("Unexpected attribute \"%s\"", arg);
652 nextarg++;
653 continue;
654 }
655
656 next_short_opt = 1;
657 short_opt = *(arg + next_short_opt);
658
659 if (short_opt == '-')
660 {
661 long_opt = arg + 2;
662
663 if (!strcmp(long_opt, "help"))
664 {
665 ecore_config_args_display();
666 return ECORE_CONFIG_PARSE_HELP;
667 }
668
669 found = 0;
670 prop = __ecore_config_bundle_local->data;
671 while (prop)
672 {
673 if ((prop->long_opt && !strcmp(long_opt, prop->long_opt))
674 || !strcmp(long_opt, prop->key))
675 {
676 found = 1;
677 if ((ret =
678 ecore_config_parse_set(prop, argv[++nextarg],
679 long_opt,
680 '\0')) !=
681 ECORE_CONFIG_PARSE_CONTINUE)
682 return ret;
683 break;
684 }
685 prop = prop->next;
686 }
687 if (!found)
688 {
689 callback = _ecore_config_arg_callbacks;
690 while (callback)
691 {
692 if ((callback->long_opt &&
693 !strcmp(long_opt, callback->long_opt)))
694 {
695 found = 1;
696 if (callback->type == ECORE_CONFIG_NIL)
697 {
698 callback->func(NULL, callback->data);
699 }
700 else
701 {
702 if (!argv[++nextarg])
703 {
704 ERR("Missing expected argument for option --%s", long_opt);
705 return ECORE_CONFIG_PARSE_EXIT;
706 }
707 callback->func(argv[nextarg], callback->data);
708 }
709 break;
710 }
711 callback = callback->next;
712 }
713 }
714 if (!found)
715 {
716 ERR("Unrecognised option \"%s\"", long_opt);
717 ERR("Try using -h or --help for more information.\n");
718 return ECORE_CONFIG_PARSE_EXIT;
719 }
720 }
721 else
722 {
723 while (short_opt)
724 {
725 if (short_opt == 'h')
726 {
727 ecore_config_args_display();
728 return ECORE_CONFIG_PARSE_HELP;
729 }
730 else
731 {
732 found = 0;
733 prop = __ecore_config_bundle_local->data;
734 while (prop)
735 {
736 if (short_opt == prop->short_opt)
737 {
738 found = 1;
739 if ((ret =
740 ecore_config_parse_set(prop,
741 argv[++nextarg],
742 NULL,
743 short_opt)) !=
744 ECORE_CONFIG_PARSE_CONTINUE)
745 return ret;
746 break;
747 }
748 prop = prop->next;
749 }
750
751 if (!found)
752 {
753 callback = _ecore_config_arg_callbacks;
754 while (callback)
755 {
756 if (short_opt == callback->short_opt)
757 {
758 found = 1;
759 if (callback->type == ECORE_CONFIG_NIL)
760 {
761 callback->func(NULL, callback->data);
762 }
763 else
764 {
765 if (!argv[++nextarg])
766 {
767 ERR("Missing expected argument for option -%c", short_opt);
768 return ECORE_CONFIG_PARSE_EXIT;
769 }
770 callback->func(argv[nextarg], callback->data);
771 }
772 break;
773 }
774 callback = callback->next;
775 }
776 }
777 if (!found)
778 {
779 ERR("Unrecognised option '%c'", short_opt);
780 ERR("Try using -h or --help for more information.\n");
781 return ECORE_CONFIG_PARSE_EXIT;
782 }
783 }
784 short_opt = *(arg + ++next_short_opt);
785 }
786 }
787 nextarg++;
788 }
789
790 return ECORE_CONFIG_PARSE_CONTINUE;
791}
792
793/**
794 * Sets the description string used by @ref ecore_config_args_display .
795 * @param description Description of application.
796 */
797void
798ecore_config_app_describe(char *description)
799{
800 if (__ecore_config_app_description)
801 free(__ecore_config_app_description);
802 __ecore_config_app_description = strdup(description);
803}
diff --git a/legacy/ecore/src/lib/ecore_config/ecore_config_ipc.h b/legacy/ecore/src/lib/ecore_config/ecore_config_ipc.h
deleted file mode 100644
index 7b3dea1dcc..0000000000
--- a/legacy/ecore/src/lib/ecore_config/ecore_config_ipc.h
+++ /dev/null
@@ -1,50 +0,0 @@
1#include <Ecore_Ipc.h>
2#include "Ecore_Config.h"
3
4typedef enum
5{
6 IPC_NONE,
7 IPC_PROP_LIST,
8 IPC_PROP_DESC,
9 IPC_PROP_GET,
10 IPC_PROP_SET, /* end of the codes shared by evidence and econf */
11
12 IPC_GLOBAL_PROP_LIST,
13
14 IPC_BUNDLE_LIST,
15 IPC_BUNDLE_NEW,
16 IPC_BUNDLE_LABEL_GET,
17 IPC_BUNDLE_LABEL_SET,
18 IPC_BUNDLE_LABEL_FIND,
19
20 IPC_LAST
21} Ecore_Config_Ipc_Call;
22
23Ecore_Config_Server *_ecore_config_ipc_init(const char *pipe_name);
24int _ecore_config_ipc_exit(void);
25
26Ecore_Config_Server *_ecore_config_server_convert(void *srv);
27
28char *_ecore_config_ipc_prop_list(Ecore_Config_Server * srv,
29 const long serial);
30char *_ecore_config_ipc_prop_desc(Ecore_Config_Server * srv,
31 const long serial,
32 const char *key);
33char *_ecore_config_ipc_prop_get(Ecore_Config_Server * srv,