2 * Navit, a modular navigation system.
3 * Copyright (C) 2005-2008 Navit Team
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 2 as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
28 #ifdef HAVE_API_WIN32_CE
34 struct callback_list *cbl;
45 static int configured;
52 config_destroy(struct config *this_)
54 attr_list_free(this_->attrs);
55 callback_list_destroy(this_->cbl);
61 config_terminate(int sig)
63 dbg(0,"terminating\n");
64 config_destroy(config);
70 config=g_new0(struct config, 1);
71 config->cbl=callback_list_new();
72 #ifndef HAVE_API_WIN32_CE
73 signal(SIGTERM, config_terminate);
74 #ifndef HAVE_API_WIN32
76 signal(SIGPIPE, SIG_IGN);
77 #endif /* __MINGW32__ */
83 config_get_attr(struct config *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
85 return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
89 config_set_attr_int(struct config *this_, struct attr *attr)
93 setenv("LANG",attr->u.str,1);
101 config_set_attr(struct config *this_, struct attr *attr)
103 return config_set_attr_int(this_, attr);
107 config_add_attr(struct config *this_, struct attr *attr)
113 switch (attr->type) {
115 callback_list_add(this_->cbl, attr->u.callback);
117 this_->attrs=attr_generic_add_attr(this_->attrs, attr);
119 callback_list_call_attr_2(this_->cbl, attr->type, attr->u.data, 1);
124 config_remove_attr(struct config *this_, struct attr *attr)
126 switch (attr->type) {
128 callback_list_remove(this_->cbl, attr->u.callback);
130 this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
132 callback_list_call_attr_2(this_->cbl, attr->type, attr->u.data, -1);
137 config_attr_iter_new()
139 return g_new0(struct attr_iter, 1);
143 config_attr_iter_destroy(struct attr_iter *iter)
150 config_new(struct attr *parent, struct attr **attrs)
153 dbg(0,"only one config allowed\n");
157 dbg(0,"no parent in config allowed\n");
162 config->attrs=attr_list_dup(attrs);
164 if (!config_set_attr_int(config,*attrs)) {
165 dbg(0,"failed to set attribute '%s'\n",attr_to_name((*attrs)->type));
166 config_destroy(config);