3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 void config_set (char *variable
, char *value
)
37 if (!strcmp (variable
, "wm_mouse"))
38 cfg
->mouse
= atoi (value
);
41 void config_parse (char *cfgfile
)
43 unsigned i
= 0, y
= strlen (cfgfile
), z
= 0;
47 if (cfgfile
[i
] == '\n') {
54 if (cfgfile
[a
+z
] == ' ')
63 memcpy (var
, cfgfile
+z
, a
);
68 memcpy (val
, cfgfile
+z
+a
, i
-z
-a
);
71 config_set (var
, val
);
82 unsigned init_config ()
84 char *cfgfile
= (char *) malloc (sizeof (char) * 2048);
90 int fd
= open ("config", O_RDONLY
);
93 puts ("error -> file 'config' not found\n");
97 if (!read (fd
, cfgfile
, 2048)) {
98 puts ("error -> something was wrong !\n");
102 cfgfile
[2048] = '\0';
104 cfg
= (config_t
*) malloc (sizeof (config_t
));
109 config_parse (cfgfile
);