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.
29 struct callback_list *cbl;
37 config_destroy(struct config *this_)
39 attr_list_free(this_->attrs);
40 callback_list_destroy(this_->cbl);
46 config_get_attr(struct config *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
48 return attr_generic_get_attr(this_->attrs, NULL, type, attr, iter);
52 config_set_attr_int(struct config *this_, struct attr *attr)
56 setenv("LANG",attr->u.str,1);
64 config_set_attr(struct config *this_, struct attr *attr)
66 return config_set_attr_int(this_, attr);
70 config_add_attr(struct config *this_, struct attr *attr)
74 callback_list_add(this_->cbl, attr->u.callback);
76 this_->attrs=attr_generic_add_attr(this_->attrs, attr);
78 callback_list_call_attr_2(this_->cbl, attr->type, attr->u.data, 1);
83 config_remove_attr(struct config *this_, struct attr *attr)
87 callback_list_remove(this_->cbl, attr->u.callback);
89 this_->attrs=attr_generic_remove_attr(this_->attrs, attr);
91 callback_list_call_attr_2(this_->cbl, attr->type, attr->u.data, -1);
96 config_attr_iter_new()
98 return g_new0(struct attr_iter, 1);
102 config_attr_iter_destroy(struct attr_iter *iter)
109 config_new(struct attr *parent, struct attr **attrs)
112 dbg(0,"only one config allowed\n");
116 dbg(0,"no parent in config allowed\n");
119 config=g_new0(struct config, 1);
120 config->attrs=attr_list_dup(attrs);
121 config->cbl=callback_list_new();
123 if (!config_set_attr_int(config,*attrs)) {
124 dbg(0,"failed to set attribute '%s'\n",attr_to_name((*attrs)->type));
125 config_destroy(config);