1 #include "evas_common_private.h"
2 #include "evas_xcb_xdefaults.h"
5 /* local function prototypes */
6 static Eina_Bool _evas_xcb_xdefaults_glob_match(const char *str, const char *glob);
9 static Eina_File *_evas_xcb_xdefaults_file = NULL;
10 static char *_evas_xcb_xdefaults_data = NULL;
13 _evas_xcb_xdefaults_init(void)
17 snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME"));
18 if ((_evas_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE)))
20 eina_mmap_safety_enabled_set(EINA_TRUE);
22 _evas_xcb_xdefaults_data =
23 eina_file_map_all(_evas_xcb_xdefaults_file, EINA_FILE_SEQUENTIAL);
28 _evas_xcb_xdefaults_shutdown(void)
30 if (!_evas_xcb_xdefaults_file) return;
31 if (_evas_xcb_xdefaults_data)
32 eina_file_map_free(_evas_xcb_xdefaults_file, _evas_xcb_xdefaults_data);
33 if (_evas_xcb_xdefaults_file) eina_file_close(_evas_xcb_xdefaults_file);
37 _evas_xcb_xdefaults_string_get(const char *prog, const char *param)
39 char buff[1024], ret[1024];
42 unsigned int count = 0, i = 0;
44 if ((!_evas_xcb_xdefaults_data) || (!_evas_xcb_xdefaults_file))
47 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
49 str = _evas_xcb_xdefaults_data;
50 ea = eina_str_split_full(str, "\n", -1, &count);
51 for (i = 0; i < count; i++)
53 if (_evas_xcb_xdefaults_glob_match(ea[i], buff))
54 sscanf(ea[i], "%*[^:]:%*[ ]%s", ret);
66 _evas_xcb_xdefaults_int_get(const char *prog, const char *param)
71 unsigned int count = 0, i = 0;
74 if ((!_evas_xcb_xdefaults_data) || (!_evas_xcb_xdefaults_file))
77 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
79 str = _evas_xcb_xdefaults_data;
80 ea = eina_str_split_full(str, "\n", -1, &count);
81 for (i = 0; i < count; i++)
83 if (_evas_xcb_xdefaults_glob_match(ea[i], buff))
84 sscanf(ea[i], "%*[^:]:%*[ ]%d", &ret);
97 _evas_xcb_xdefaults_glob_match(const char *str, const char *glob)
99 if ((!str) || (!glob)) return EINA_FALSE;
102 if (str[0] == 0) return EINA_TRUE;
105 if (!strcmp(glob, "*")) return EINA_TRUE;
106 if (!fnmatch(glob, str, 0)) return EINA_TRUE;