add start on config parser files
[platform/upstream/dbus.git] / bus / config-parser.c
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* config-parser.c  XML-library-agnostic configuration file parser
3  *
4  * Copyright (C) 2003 Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 1.2
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #include "config-parser.h"
25 #include <string.h>
26
27 typedef enum
28 {
29   ELEMENT_BUSCONFIG,
30   ELEMENT_INCLUDE,
31   ELEMENT_USER,
32   ELEMENT_LISTEN,
33   ELEMENT_AUTH,
34   ELEMENT_POLICY,
35   ELEMENT_LIMIT
36 } ElementType;
37
38 typedef struct
39 {
40   ElementType type;
41
42   union
43   {
44     struct
45     {
46       BusConfigParser *parser;
47     } include;
48
49     struct
50     {
51       char *username;
52     } user;
53
54     struct
55     {
56       char *address;
57     } listen;
58
59     struct
60     {
61       char *mechanism;
62     } auth;
63
64     struct
65     {
66       char *context;
67       char *user;
68       char *group;
69       DBusList *rules;
70     } policy;
71
72     struct
73     {
74       int foo;
75     } limit;
76     
77   } d;
78   
79 } Element;
80
81 struct BusConfigParser
82 {
83   int refcount;
84
85   DBusList *stack;
86 };
87
88 BusConfigParser*
89 bus_config_parser_new (void)
90 {
91   BusConfigParser *parser;
92
93   parser = dbus_new0 (BusConfigParser, 1);
94   if (parser == NULL)
95     return NULL;
96
97   parser->refcount = 1;
98
99   return parser;
100 }
101
102 void
103 bus_config_parser_ref (BusConfigParser *parser)
104 {
105   _dbus_assert (parser->refcount > 0);
106
107   parser->refcount += 1;
108 }
109
110 void
111 bus_config_parser_unref (BusConfigParser *parser)
112 {
113   _dbus_assert (parser->refcount > 0);
114
115   parser->refcount -= 1;
116
117   if (parser->refcount == 0)
118     {
119
120
121       dbus_free (parser);
122     }
123 }
124
125 dbus_bool_t
126 bus_config_parser_check_doctype (BusConfigParser   *parser,
127                                  const char        *doctype,
128                                  DBusError         *error)
129 {
130   if (strcmp (doctype, "busconfig") != 0)
131     {
132       dbus_set_error (error,
133                       DBUS_ERROR_FAILED,
134                       "Document has the wrong type %s",
135                       doctype);
136       return FALSE;
137     }
138   else
139     return TRUE;
140 }
141
142 dbus_bool_t
143 bus_config_parser_start_element (BusConfigParser   *parser,
144                                  const char        *element_name,
145                                  const char       **attribute_names,
146                                  const char       **attribute_values,
147                                  DBusError         *error)
148 {
149   
150
151 }
152
153 dbus_bool_t
154 bus_config_parser_end_element (BusConfigParser   *parser,
155                                const char        *element_name,
156                                DBusError         *error)
157 {
158   
159
160 }
161
162 dbus_bool_t
163 bus_config_parser_content (BusConfigParser   *parser,
164                            const DBusString  *content,
165                            DBusError         *error)
166 {
167   
168
169 }
170