1 #include "ecore_xcb_private.h"
4 /* local function prototypes */
5 static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str,
9 static Eina_File *_ecore_xcb_xdefaults_file = NULL;
10 static char *_ecore_xcb_xdefaults_data = NULL;
13 _ecore_xcb_xdefaults_init(void)
17 LOGFN(__FILE__, __LINE__, __FUNCTION__);
19 snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME"));
20 if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE)))
22 eina_mmap_safety_enabled_set(EINA_TRUE);
24 _ecore_xcb_xdefaults_data =
25 eina_file_map_all(_ecore_xcb_xdefaults_file, EINA_FILE_SEQUENTIAL);
30 _ecore_xcb_xdefaults_shutdown(void)
32 LOGFN(__FILE__, __LINE__, __FUNCTION__);
34 if (!_ecore_xcb_xdefaults_file) return;
35 if (_ecore_xcb_xdefaults_data)
36 eina_file_map_free(_ecore_xcb_xdefaults_file, _ecore_xcb_xdefaults_data);
37 if (_ecore_xcb_xdefaults_file) eina_file_close(_ecore_xcb_xdefaults_file);
41 _ecore_xcb_xdefaults_string_get(const char *prog,
44 char buff[1024], ret[1024];
47 unsigned int count = 0, i = 0;
49 if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file))
52 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
54 str = _ecore_xcb_xdefaults_data;
55 ea = eina_str_split_full(str, "\n", -1, &count);
56 for (i = 0; i < count; i++)
58 if (_ecore_xcb_xdefaults_glob_match(ea[i], buff))
59 sscanf(ea[i], "%*[^:]:%*[ ]%s", ret);
71 _ecore_xcb_xdefaults_int_get(const char *prog,
77 unsigned int count = 0, i = 0;
80 if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file))
83 snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param);
85 str = _ecore_xcb_xdefaults_data;
86 ea = eina_str_split_full(str, "\n", -1, &count);
87 for (i = 0; i < count; i++)
89 if (_ecore_xcb_xdefaults_glob_match(ea[i], buff))
90 sscanf(ea[i], "%*[^:]:%*[ ]%d", &ret);
101 /* local functions */
103 _ecore_xcb_xdefaults_glob_match(const char *str,
106 if ((!str) || (!glob)) return EINA_FALSE;
109 if (str[0] == 0) return EINA_TRUE;
112 if (!strcmp(glob, "*")) return EINA_TRUE;
113 if (!fnmatch(glob, str, 0)) return EINA_TRUE;