1 #include "ecore_xcb_private.h"
6 /* local function prototypes */
7 static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str,
11 static Eina_File *_ecore_xcb_xdefaults_file = NULL;
12 static char *_ecore_xcb_xdefaults_data = NULL;
15 _ecore_xcb_xdefaults_init(void)
19 LOGFN(__FILE__, __LINE__, __FUNCTION__);
21 if (eina_environment_home_get())
22 snprintf(buff, sizeof(buff), "%s/.Xdefaults", eina_environment_home_get());
24 if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE)))
26 eina_mmap_safety_enabled_set(EINA_TRUE);
28 _ecore_xcb_xdefaults_data =
29 eina_file_map_all(_ecore_xcb_xdefaults_file, EINA_FILE_SEQUENTIAL);
34 _ecore_xcb_xdefaults_shutdown(void)
36 LOGFN(__FILE__, __LINE__, __FUNCTION__);
38 if (!_ecore_xcb_xdefaults_file) return;
39 if (_ecore_xcb_xdefaults_data)
40 eina_file_map_free(_ecore_xcb_xdefaults_file, _ecore_xcb_xdefaults_data);
41 if (_ecore_xcb_xdefaults_file) eina_file_close(_ecore_xcb_xdefaults_file);
45 _ecore_xcb_xdefaults_string_get(const char *prog,
48 char buff[1024], ret[1024];
51 unsigned int count = 0, i = 0;
53 if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file))
56 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
58 str = _ecore_xcb_xdefaults_data;
59 ea = eina_str_split_full(str, "\n", -1, &count);
60 for (i = 0; i < count; i++)
62 if (_ecore_xcb_xdefaults_glob_match(ea[i], buff))
63 sscanf(ea[i], "%*[^:]:%*[ ]%s", ret);
75 _ecore_xcb_xdefaults_int_get(const char *prog,
81 unsigned int count = 0, i = 0;
84 if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file))
87 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
89 str = _ecore_xcb_xdefaults_data;
90 ea = eina_str_split_full(str, "\n", -1, &count);
91 for (i = 0; i < count; i++)
93 if (_ecore_xcb_xdefaults_glob_match(ea[i], buff))
94 sscanf(ea[i], "%*[^:]:%*[ ]%d", &ret);
105 /* local functions */
107 _ecore_xcb_xdefaults_glob_match(const char *str,
110 if ((!str) || (!glob)) return EINA_FALSE;
113 if (str[0] == 0) return EINA_TRUE;
116 if (!strcmp(glob, "*")) return EINA_TRUE;
117 if (!fnmatch(glob, str, 0)) return EINA_TRUE;