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