improve error log to stderr
[monster.git] / conf.c
bloba774bdcfa1dfe6503e7b3fd27ef1ec6ca063d864
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*****************************************************************************
4 * Configuration file access
5 * This file is part of monster
7 * Copyright (C) 2006,2007 Nedko Arnaudov <nedko@arnaudov.name>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2 of the License
13 * This program 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 this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22 *****************************************************************************/
24 #include <libxml/parser.h>
26 #define DISABLE_DEBUG_OUTPUT
28 #include "conf.h"
29 #include "log.h"
30 #include "xml.h"
32 xmlDocPtr g_conf_ptr;
34 int
35 conf_file_parse()
37 DEBUG_OUT("conf_file_parse() called.");
39 g_conf_ptr = xmlParseFile("/etc/monster.xml");
40 if (g_conf_ptr == NULL)
42 ERROR_OUT("Failed to parse conf file");
43 return -1;
46 return 0;
49 void
50 conf_file_cleanup()
52 DEBUG_OUT("conf_file_cleanup() called.");
53 xmlFreeDoc(g_conf_ptr);
56 int
57 conf_file_get_string(
58 const char * xpath,
59 char * buffer_ptr,
60 size_t buffer_size)
62 DEBUG_OUT("conf_file_get_string() called.");
63 return xml_get_string(g_conf_ptr, xpath, buffer_ptr, buffer_size);
66 int
67 conf_file_get_int(
68 const char * xpath,
69 int * value_ptr)
71 DEBUG_OUT("conf_file_get_int() called.");
72 return xml_get_int(g_conf_ptr, xpath, value_ptr);
75 int
76 conf_file_get_uint(
77 const char * xpath,
78 unsigned int * value_ptr)
80 DEBUG_OUT("conf_file_get_uint() called.");
81 return xml_get_uint(g_conf_ptr, xpath, value_ptr);