2 Copyright (C) 2005 Georgia Public Library Service
3 Bill Erickson <highfalutin@gmail.com>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
21 @brief Routines for loading, storing, and searching configurations.
23 A configuration file, encoded as XML, is loaded and translated into a jsonObject. This
24 object is stored in an osrfConfig, along with an optional context string which, if
25 present, restricts subsequent searches to a subset of the jsonObject.
27 In theory the context string could identify multiple subtrees of the total configuration.
28 In practice it is used to partition a configuration file into different pieces, each piece
29 to be used by a different application.
31 Normally an application loads a default configuration, accessible from every linked
32 module. It is also possible, although seldom useful, to create and search a configuration
33 distinct from the default configuration.
36 #include <opensrf/xml_utils.h>
37 #include <opensrf/utils.h>
38 #include <opensrf/string_array.h>
39 #include <opensrf/osrf_json.h>
46 @brief Represents a configuration; normally loaded from an XML configuration file.
49 jsonObject* config; /**< Represents the contents of the XML configuration file. */
50 char* configContext; /**< Context string (optional). */
51 char* configFileName; /**< config file path/name */
54 osrfConfig* osrfConfigInit(const char* configFile, const char* configContext);
56 int osrfConfigHasDefaultConfig( void );
58 void osrfConfigReplaceConfig(osrfConfig* cfg, const jsonObject* obj);
60 void osrfConfigFree(osrfConfig* cfg);
62 void osrfConfigSetDefaultConfig(osrfConfig* cfg);
63 osrfConfig* osrfConfigGetDefaultConfig();
65 void osrfConfigCleanup( void );
67 char* osrfConfigGetValue(const osrfConfig* cfg, const char* path, ...);
69 jsonObject* osrfConfigGetValueObject(osrfConfig* cfg, const char* path, ...);
71 int osrfConfigGetValueList(const osrfConfig* cfg, osrfStringArray* arr,
72 const char* path, ...);