Emeric Vigier | 2f62582 | 2012-08-06 11:09:52 -0400 | [diff] [blame] | 1 | /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ |
| 2 | /* config-parser-trivial.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_TRIVIAL_H |
| 25 | #define BUS_CONFIG_PARSER_TRIVIAL_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 | |
| 32 | /* Whatever XML library we're using just pushes data into this API */ |
| 33 | |
| 34 | typedef struct BusConfigParser BusConfigParser; |
| 35 | |
| 36 | BusConfigParser* bus_config_parser_new (const DBusString *basedir, |
| 37 | dbus_bool_t is_toplevel, |
| 38 | const BusConfigParser *parent); |
| 39 | |
| 40 | BusConfigParser* bus_config_parser_ref (BusConfigParser *parser); |
| 41 | void bus_config_parser_unref (BusConfigParser *parser); |
| 42 | dbus_bool_t bus_config_parser_check_doctype (BusConfigParser *parser, |
| 43 | const char *doctype, |
| 44 | DBusError *error); |
| 45 | dbus_bool_t bus_config_parser_start_element (BusConfigParser *parser, |
| 46 | const char *element_name, |
| 47 | const char **attribute_names, |
| 48 | const char **attribute_values, |
| 49 | DBusError *error); |
| 50 | dbus_bool_t bus_config_parser_end_element (BusConfigParser *parser, |
| 51 | const char *element_name, |
| 52 | DBusError *error); |
| 53 | dbus_bool_t bus_config_parser_content (BusConfigParser *parser, |
| 54 | const DBusString *content, |
| 55 | DBusError *error); |
| 56 | dbus_bool_t bus_config_parser_finished (BusConfigParser *parser, |
| 57 | DBusError *error); |
| 58 | |
| 59 | /* Functions for extracting the parse results */ |
| 60 | const char* bus_config_parser_get_user (BusConfigParser *parser); |
| 61 | const char* bus_config_parser_get_type (BusConfigParser *parser); |
| 62 | DBusList** bus_config_parser_get_service_dirs (BusConfigParser *parser); |
| 63 | |
| 64 | /* Loader functions (backended off one of the XML parsers). Returns a |
| 65 | * finished ConfigParser. |
| 66 | */ |
| 67 | BusConfigParser* bus_config_load (const DBusString *file, |
| 68 | dbus_bool_t is_toplevel, |
| 69 | const BusConfigParser *parent, |
| 70 | DBusError *error); |
| 71 | |
| 72 | #endif /* BUS_CONFIG_PARSER_TRIVIAL_H */ |