2
* isdn4linux options file tree support
4
* This file is part of ANT (Ant is Not a Telephone)
6
* Copyright 2003 Roland Stigge
8
* ANT is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* ANT is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with ANT; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31
isdn_tree_node_t* isdn_tree;
34
* helper function for isdn_tree_dump recursively dumping the tree
36
static void isdn_tree_dump_list(isdn_tree_node_t* list, int indent) {
37
while (list != NULL) {
39
case ISDN_NODE_TYPE_ENTRY:
40
printf("%*sEntry \"%s\" => \"%s\"\n",
41
indent, "", list->name, list->content.value);
43
case ISDN_NODE_TYPE_SECTION:
44
printf("%*sSection [%s]:\n",
45
indent, "", list->name);
46
isdn_tree_dump_list(list->content.section, indent + 2);
48
case ISDN_NODE_TYPE_SUBSECTION:
49
printf("%*sSubsection \"%s\":\n",
50
indent, "", list->name);
51
isdn_tree_dump_list(list->content.subsection, indent + 2);
54
fprintf(stderr, "Unknown ISDN_NODE_TYPE\n");
62
* dump whole tree to stdout
64
void isdn_tree_dump() {
65
printf("ISDN config dump:\n");
66
isdn_tree_dump_list(isdn_tree, 2);
70
* helper for isdn_tree_free
71
* -> recursive release of memory from tree
73
static void isdn_tree_free_list(isdn_tree_node_t* list) {
74
while (list != NULL) {
75
isdn_tree_node_t* temp;
80
case ISDN_NODE_TYPE_ENTRY:
81
free(list->content.value);
83
case ISDN_NODE_TYPE_SECTION:
84
isdn_tree_free_list(list->content.section);
86
case ISDN_NODE_TYPE_SUBSECTION:
87
isdn_tree_free_list(list->content.subsection);
90
fprintf(stderr, "Unknown ISDN_NODE_TYPE\n");
100
* cleans up: releases all memory associated with tree
102
void isdn_tree_free() {
103
isdn_tree_free_list(isdn_tree);