1/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2/* config-parser.h  XML-library-agnostic configuration file parser
3 *
4 * Copyright (C) 2003 Red Hat, Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program 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.
12 *
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.
17 *
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 Street, Fifth Floor, Boston, MA  02110-1301  USA
21 *
22 */
23
24#ifndef BUS_CONFIG_PARSER_H
25#define BUS_CONFIG_PARSER_H
26
27#include <dbus/dbus.h>
28#include <dbus/dbus-string.h>
29#include <dbus/dbus-list.h>
30#include <dbus/dbus-hash.h>
31#include "bus.h"
32
33/* Whatever XML library we're using just pushes data into this API */
34
35typedef struct BusConfigParser BusConfigParser;
36
37BusConfigParser* bus_config_parser_new (const DBusString      *basedir,
38                                        dbus_bool_t            is_toplevel,
39                                        const BusConfigParser *parent);
40
41BusConfigParser* bus_config_parser_ref           (BusConfigParser   *parser);
42void             bus_config_parser_unref         (BusConfigParser   *parser);
43dbus_bool_t      bus_config_parser_check_doctype (BusConfigParser   *parser,
44                                                  const char        *doctype,
45                                                  DBusError         *error);
46dbus_bool_t      bus_config_parser_start_element (BusConfigParser   *parser,
47                                                  const char        *element_name,
48                                                  const char       **attribute_names,
49                                                  const char       **attribute_values,
50                                                  DBusError         *error);
51dbus_bool_t      bus_config_parser_end_element   (BusConfigParser   *parser,
52                                                  const char        *element_name,
53                                                  DBusError         *error);
54dbus_bool_t      bus_config_parser_content       (BusConfigParser   *parser,
55                                                  const DBusString  *content,
56                                                  DBusError         *error);
57dbus_bool_t      bus_config_parser_finished      (BusConfigParser   *parser,
58                                                  DBusError         *error);
59
60/* Functions for extracting the parse results */
61const char* bus_config_parser_get_user         (BusConfigParser *parser);
62const char* bus_config_parser_get_type         (BusConfigParser *parser);
63DBusList**  bus_config_parser_get_addresses    (BusConfigParser *parser);
64DBusList**  bus_config_parser_get_mechanisms   (BusConfigParser *parser);
65dbus_bool_t bus_config_parser_get_fork         (BusConfigParser *parser);
66dbus_bool_t bus_config_parser_get_allow_anonymous (BusConfigParser *parser);
67dbus_bool_t bus_config_parser_get_syslog       (BusConfigParser *parser);
68dbus_bool_t bus_config_parser_get_keep_umask   (BusConfigParser *parser);
69const char* bus_config_parser_get_pidfile      (BusConfigParser *parser);
70const char* bus_config_parser_get_servicehelper (BusConfigParser *parser);
71DBusList**  bus_config_parser_get_service_dirs (BusConfigParser *parser);
72DBusList**  bus_config_parser_get_conf_dirs    (BusConfigParser *parser);
73BusPolicy*  bus_config_parser_steal_policy     (BusConfigParser *parser);
74void        bus_config_parser_get_limits       (BusConfigParser *parser,
75                                                BusLimits       *limits);
76
77DBusHashTable* bus_config_parser_steal_service_context_table (BusConfigParser *parser);
78
79/* Loader functions (backended off one of the XML parsers).  Returns a
80 * finished ConfigParser.
81 */
82BusConfigParser* bus_config_load (const DBusString      *file,
83                                  dbus_bool_t            is_toplevel,
84                                  const BusConfigParser *parent,
85                                  DBusError             *error);
86
87#endif /* BUS_CONFIG_PARSER_H */
88