Bug 21161 - Update the FSF address
[platform/upstream/dbus.git] / bus / config-parser-common.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* config-parser-common.c  Common defines and routines for config file parsing
3  *
4  * Copyright (C) 2007 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 #include <dbus/dbus-internals.h>
25 #include <string.h>
26
27 #include "config-parser-common.h"
28 #include "utils.h"
29
30 ElementType
31 bus_config_parser_element_name_to_type (const char *name)
32 {
33   if (strcmp (name, "none") == 0)
34     {
35       return ELEMENT_NONE;
36     }
37   else if (strcmp (name, "busconfig") == 0)
38     {
39       return ELEMENT_BUSCONFIG;
40     }
41   else if (strcmp (name, "user") == 0)
42     {
43       return ELEMENT_USER;
44     }
45   else if (strcmp (name, "auth") == 0)
46     {
47       return ELEMENT_AUTH;
48     }
49   else if (strcmp (name, "type") == 0)
50     {
51       return ELEMENT_TYPE;
52     }
53   else if (strcmp (name, "fork") == 0)
54     {
55       return ELEMENT_FORK;
56     }
57   else if (strcmp (name, "pidfile") == 0)
58     {
59       return ELEMENT_PIDFILE;
60     }
61   else if (strcmp (name, "listen") == 0)
62     {
63       return ELEMENT_LISTEN;
64     }
65   else if (strcmp (name, "auth") == 0)
66     {
67       return ELEMENT_AUTH;
68     }
69   else if (strcmp (name, "allow") == 0)
70     {
71       return ELEMENT_ALLOW;
72     }
73   else if (strcmp (name, "deny") == 0)
74     {
75       return ELEMENT_DENY;
76     }
77   else if (strcmp (name, "servicehelper") == 0)
78     {
79       return ELEMENT_SERVICEHELPER;
80     }
81   else if (strcmp (name, "includedir") == 0)
82     {
83       return ELEMENT_INCLUDEDIR;
84     }
85   else if (strcmp (name, "standard_session_servicedirs") == 0)
86     {
87       return ELEMENT_STANDARD_SESSION_SERVICEDIRS;
88     }
89   else if (strcmp (name, "standard_system_servicedirs") == 0)
90     {
91       return ELEMENT_STANDARD_SYSTEM_SERVICEDIRS;
92     }
93   else if (strcmp (name, "servicedir") == 0)
94     {
95       return ELEMENT_SERVICEDIR;
96     }
97   else if (strcmp (name, "include") == 0)
98     {
99       return ELEMENT_INCLUDE;
100     }
101   else if (strcmp (name, "policy") == 0)
102     {
103       return ELEMENT_POLICY;
104     }
105   else if (strcmp (name, "limit") == 0)
106     {
107       return ELEMENT_LIMIT;
108     }
109   else if (strcmp (name, "selinux") == 0)
110     {
111       return ELEMENT_SELINUX;
112     }
113   else if (strcmp (name, "associate") == 0)
114     {
115       return ELEMENT_ASSOCIATE;
116     }
117   else if (strcmp (name, "syslog") == 0)
118     {
119       return ELEMENT_SYSLOG;
120     }
121   else if (strcmp (name, "keep_umask") == 0)
122     {
123       return ELEMENT_KEEP_UMASK;
124     }
125   return ELEMENT_NONE;
126 }
127
128 const char*
129 bus_config_parser_element_type_to_name (ElementType type)
130 {
131   switch (type)
132     {
133     case ELEMENT_NONE:
134       return NULL;
135     case ELEMENT_BUSCONFIG:
136       return "busconfig";
137     case ELEMENT_INCLUDE:
138       return "include";
139     case ELEMENT_USER:
140       return "user";
141     case ELEMENT_LISTEN:
142       return "listen";
143     case ELEMENT_AUTH:
144       return "auth";
145     case ELEMENT_POLICY:
146       return "policy";
147     case ELEMENT_LIMIT:
148       return "limit";
149     case ELEMENT_ALLOW:
150       return "allow";
151     case ELEMENT_DENY:
152       return "deny";
153     case ELEMENT_FORK:
154       return "fork";
155     case ELEMENT_PIDFILE:
156       return "pidfile";
157     case ELEMENT_STANDARD_SESSION_SERVICEDIRS:
158       return "standard_session_servicedirs";
159     case ELEMENT_STANDARD_SYSTEM_SERVICEDIRS:
160       return "standard_system_servicedirs";
161     case ELEMENT_SERVICEDIR:
162       return "servicedir";
163     case ELEMENT_SERVICEHELPER:
164       return "servicehelper";
165     case ELEMENT_INCLUDEDIR:
166       return "includedir";
167     case ELEMENT_TYPE:
168       return "type";
169     case ELEMENT_SELINUX:
170       return "selinux";
171     case ELEMENT_ASSOCIATE:
172       return "associate";
173     case ELEMENT_SYSLOG:
174       return "syslog";
175     case ELEMENT_KEEP_UMASK:
176       return "keep_umask";
177     }
178
179   _dbus_assert_not_reached ("bad element type");
180
181   return NULL;
182 }
183