[18310] | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
---|
| 2 | /* |
---|
| 3 | * oafd: OAF CORBA dameon. |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2000 Eazel, Inc. |
---|
| 6 | * |
---|
| 7 | * This library is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License as |
---|
| 9 | * published by the Free Software Foundation; either version 2 of the |
---|
| 10 | * License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This library is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 15 | * General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License |
---|
| 18 | * along with this library; if not, write to the Free Software |
---|
| 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 20 | * |
---|
| 21 | * Authors: Mathieu Lacage <mathieu@eazel.com> |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include "config.h" |
---|
| 26 | #include <string.h> |
---|
| 27 | #include <libxml/tree.h> |
---|
| 28 | #include <libxml/parser.h> |
---|
| 29 | #include <libxml/xmlmemory.h> |
---|
| 30 | #include <glib.h> |
---|
| 31 | |
---|
| 32 | #include "bonobo-activation/bonobo-activation-i18n.h" |
---|
| 33 | #include "object-directory-config-file.h" |
---|
| 34 | |
---|
| 35 | static xmlDocPtr |
---|
| 36 | object_directory_load_xml_file (void) |
---|
| 37 | { |
---|
| 38 | xmlDocPtr doc; |
---|
| 39 | char *bonobo_activation_config_file; |
---|
| 40 | |
---|
| 41 | bonobo_activation_config_file = g_strconcat ( |
---|
| 42 | SERVER_CONFDIR, SERVER_CONFIG_FILE, NULL); |
---|
| 43 | doc = xmlParseFile (bonobo_activation_config_file); |
---|
| 44 | |
---|
| 45 | /* check if the document was read successfully. */ |
---|
| 46 | if (doc == NULL) { |
---|
| 47 | g_warning (_("The Bonobo Activation configuration file was not read " |
---|
| 48 | "successfully. Please, check it is valid in: %s"), |
---|
| 49 | bonobo_activation_config_file); |
---|
| 50 | g_free (bonobo_activation_config_file); |
---|
| 51 | return NULL; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | g_free (bonobo_activation_config_file); |
---|
| 55 | |
---|
| 56 | return doc; |
---|
| 57 | } |
---|
| 58 | |
---|
| 59 | char * |
---|
| 60 | object_directory_load_config_file (void) |
---|
| 61 | { |
---|
| 62 | char *result; |
---|
| 63 | xmlDocPtr doc; |
---|
| 64 | xmlNodePtr search_node; |
---|
| 65 | |
---|
| 66 | doc = object_directory_load_xml_file (); |
---|
| 67 | |
---|
| 68 | if (doc == NULL || doc->xmlRootNode == NULL) |
---|
| 69 | search_node = NULL; |
---|
| 70 | else |
---|
| 71 | search_node = doc->xmlRootNode->xmlChildrenNode; |
---|
| 72 | result = g_strdup (""); |
---|
| 73 | while (search_node != NULL) { |
---|
| 74 | if (strcmp (search_node->name, "searchpath") == 0) { |
---|
| 75 | xmlNodePtr item_node; |
---|
| 76 | item_node = search_node->xmlChildrenNode; |
---|
| 77 | while (item_node != NULL) { |
---|
| 78 | if (strcmp (item_node->name, "item") == 0) { |
---|
| 79 | char *directory; |
---|
| 80 | char *old_result = result; |
---|
| 81 | |
---|
| 82 | directory = xmlNodeGetContent (item_node); |
---|
| 83 | if (directory) { |
---|
| 84 | result = g_strconcat (old_result, ":", directory, NULL); |
---|
| 85 | xmlFree (directory); |
---|
| 86 | g_free (old_result); |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | item_node = item_node->next; |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | search_node = search_node->next; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | xmlFreeDoc (doc); |
---|
| 96 | |
---|
| 97 | return result; |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | |
---|