source: trunk/gsdl/src/colservr/colservrconfig.cpp@ 1661

Last change on this file since 1661 was 1285, checked in by sjboddie, 24 years ago

Removed CVS logging information from source files

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1/**********************************************************************
2 *
3 * colservrconfig.cpp --
4 * Copyright (C) 1999 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 "colservrconfig.h"
27#include "fileutil.h"
28#include "cfgread.h"
29
30
31#if defined(GSDL_USE_OBJECTSPACE)
32# include <ospace/std/iostream>
33# include <ospace/std/fstream>
34#elif defined(GSDL_USE_IOS_H)
35# include <iostream.h>
36# include <fstream.h>
37#else
38# include <iostream>
39# include <fstream>
40#endif
41
42// collect_cfg_read reads collect.cfg returning true on success.
43bool collect_cfg_read (collectserver &cserver, const text_t &gsdlhome,
44 const text_t &collection) {
45 text_t filename = filename_cat (gsdlhome, "collect");
46 filename = filename_cat (filename, collection);
47 filename = filename_cat (filename, "etc");
48 filename = filename_cat (filename, "collect.cfg");
49 if (!file_exists (filename)) {
50 filename = filename_cat (gsdlhome, "etc");
51 filename = filename_cat (filename, "collect.cfg");
52 if (!file_exists (filename)) return false;
53 }
54
55 // read in the collection configuration file
56 text_t key;
57 text_tarray cfgline;
58 char *cstr = filename.getcstr();
59 ifstream confin (cstr);
60 delete cstr;
61
62 if (confin) {
63 while (read_cfg_line(confin, cfgline) >= 0) {
64 if (cfgline.size () >= 2) {
65 key = cfgline[0];
66 cfgline.erase(cfgline.begin());
67
68 // configure the collection server
69 cserver.configure (key, cfgline);
70 }
71 }
72 confin.close ();
73 return true;
74 }
75 return false;
76}
77
78
79// build_cfg_read reads build.cfg and returns true on success.
80bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
81 const text_t &collection) {
82 text_t filename = filename_cat (gsdlhome, "collect");
83 filename = filename_cat (filename, collection);
84 filename = filename_cat (filename, "index");
85
86 filename = filename_cat (filename, "build.cfg");
87 if (!file_exists (filename)) {
88 filename = filename_cat (gsdlhome, "index");
89 filename = filename_cat (filename, "build.cfg");
90 if (!file_exists (filename)) return false;
91 }
92
93 // read in the build configuration file
94 text_t key;
95 text_tarray cfgline;
96 char *cstr = filename.getcstr();
97 ifstream confin (cstr);
98 delete cstr;
99
100 if (confin) {
101 while (read_cfg_line(confin, cfgline) >= 0) {
102 if (cfgline.size () >= 2) {
103 key = cfgline[0];
104 cfgline.erase(cfgline.begin());
105
106 // configure the collection server
107 cserver.configure (key, cfgline);
108 }
109 }
110 confin.close ();
111 return true;
112 }
113 return false;
114}
Note: See TracBrowser for help on using the repository browser.