source: gsdl/trunk/src/recpt/maincfg.cpp@ 15597

Last change on this file since 15597 was 15402, checked in by mdewsnip, 16 years ago

(Untangling colservr/recpt) Split recpt/recptconfig into two: lib/gsdlsitecfg (reads gsdlsite.cfg file; used by both colservr and recpt) and recpt/maincfg (reads main.cfg file; used by recpt only).

  • Property svn:executable set to *
File size: 2.7 KB
Line 
1/**********************************************************************
2 *
3 * maincfg.cpp --
4 * Copyright (C) 2008 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "maincfg.h"
27#include "fileutil.h"
28
29
30#if defined(GSDL_USE_OBJECTSPACE)
31# include <ospace/std/iostream>
32# include <ospace/std/fstream>
33#elif defined(GSDL_USE_IOS_H)
34# include <iostream.h>
35# include <fstream.h>
36#else
37# include <iostream>
38# include <fstream>
39#endif
40
41
42// main_cfg_read reads both main.cfg and collect.cfg. It attempts
43// to read main.cfg first so values in collect.cfg override those
44// set earlier by main.cfg
45bool main_cfg_read (receptionist &recpt, const text_t &gsdlhome,
46 const text_t &collection) {
47
48 // read in the main configuration file
49 bool rv = false;
50
51 text_t key, filename;
52 text_tarray cfgline;
53 filename = filename_cat (gsdlhome, "etc");
54 filename = filename_cat (filename, "main.cfg");
55 if (!collection.empty() && file_exists(filename)) {
56 rv = recpt.read_configfile(filename);
57 } else {
58 filename_cat (filename, gsdlhome, "etc", "main.cfg");
59 if (file_exists (filename)) {
60 rv = recpt.read_configfile(filename);
61 }
62 }
63
64 // Look for collect.cfg in GSDLHOME/collect/collection-name/etc directory
65 // (if this is for a particular collection), and then GSDLHOME/etc.
66 if (!collection.empty()) {
67 filename = filename_cat (gsdlhome, "collect");
68 filename = filename_cat (filename, collection);
69 filename = filename_cat (filename, "etc");
70 filename = filename_cat (filename, "collect.cfg");
71 if (!file_exists (filename)) {
72 filename = filename_cat (gsdlhome, "etc");
73 filename = filename_cat (filename, "collect.cfg");
74 if (!file_exists (filename)) filename.clear();
75 }
76
77 if (!filename.empty()) {
78 rv |= recpt.read_configfile(filename);
79 }
80 }
81 return rv;
82}
Note: See TracBrowser for help on using the repository browser.