[166] | 1 | /**********************************************************************
|
---|
| 2 | *
|
---|
| 3 | * colservrconfig.cpp --
|
---|
| 4 | * Copyright (C) 1999 The New Zealand Digital Library Project
|
---|
| 5 | *
|
---|
[534] | 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.
|
---|
[166] | 9 | *
|
---|
[534] | 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 | *
|
---|
[1860] | 24 | * $Id: colservrconfig.cpp 15458 2008-05-14 23:08:25Z mdewsnip $
|
---|
| 25 | *
|
---|
[166] | 26 | *********************************************************************/
|
---|
| 27 |
|
---|
| 28 | #include "colservrconfig.h"
|
---|
| 29 | #include "fileutil.h"
|
---|
| 30 | #include "cfgread.h"
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 34 | # include <ospace/std/iostream>
|
---|
| 35 | # include <ospace/std/fstream>
|
---|
| 36 | #elif defined(GSDL_USE_IOS_H)
|
---|
| 37 | # include <iostream.h>
|
---|
| 38 | # include <fstream.h>
|
---|
| 39 | #else
|
---|
| 40 | # include <iostream>
|
---|
| 41 | # include <fstream>
|
---|
| 42 | #endif
|
---|
| 43 |
|
---|
| 44 | // collect_cfg_read reads collect.cfg returning true on success.
|
---|
| 45 | bool collect_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
| 46 | const text_t &collection) {
|
---|
| 47 | text_t filename = filename_cat (gsdlhome, "collect");
|
---|
| 48 | filename = filename_cat (filename, collection);
|
---|
[14376] | 49 | filename = filename_cat (filename, "custom");
|
---|
| 50 | filename = filename_cat (filename, collection);
|
---|
[166] | 51 | filename = filename_cat (filename, "etc");
|
---|
[14376] | 52 | filename = filename_cat (filename, "custom.cfg");
|
---|
| 53 |
|
---|
[166] | 54 | if (!file_exists (filename)) {
|
---|
[14376] | 55 | filename = filename_cat (gsdlhome, "collect");
|
---|
| 56 | filename = filename_cat (filename, collection);
|
---|
| 57 | filename = filename_cat (filename, "etc");
|
---|
[166] | 58 | filename = filename_cat (filename, "collect.cfg");
|
---|
[14376] | 59 |
|
---|
| 60 | if (!file_exists (filename)) {
|
---|
| 61 | filename = filename_cat (gsdlhome, "etc");
|
---|
| 62 | filename = filename_cat (filename, "collect.cfg");
|
---|
| 63 | if (!file_exists (filename)) return false;
|
---|
| 64 | }
|
---|
[166] | 65 | }
|
---|
| 66 |
|
---|
[1860] | 67 | return cserver.read_configfile(filename);
|
---|
| 68 | /*
|
---|
[166] | 69 | // read in the collection configuration file
|
---|
| 70 | text_t key;
|
---|
| 71 | text_tarray cfgline;
|
---|
| 72 | char *cstr = filename.getcstr();
|
---|
| 73 | ifstream confin (cstr);
|
---|
[9631] | 74 | delete []cstr;
|
---|
[166] | 75 |
|
---|
| 76 | if (confin) {
|
---|
| 77 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
| 78 | if (cfgline.size () >= 2) {
|
---|
| 79 | key = cfgline[0];
|
---|
| 80 | cfgline.erase(cfgline.begin());
|
---|
| 81 |
|
---|
| 82 | // configure the collection server
|
---|
| 83 | cserver.configure (key, cfgline);
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 | confin.close ();
|
---|
| 87 | return true;
|
---|
| 88 | }
|
---|
| 89 | return false;
|
---|
[1860] | 90 | */
|
---|
[166] | 91 | }
|
---|
| 92 |
|
---|
| 93 |
|
---|
| 94 | // build_cfg_read reads build.cfg and returns true on success.
|
---|
| 95 | bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
| 96 | const text_t &collection) {
|
---|
| 97 | text_t filename = filename_cat (gsdlhome, "collect");
|
---|
| 98 | filename = filename_cat (filename, collection);
|
---|
| 99 | filename = filename_cat (filename, "index");
|
---|
[534] | 100 |
|
---|
[166] | 101 | filename = filename_cat (filename, "build.cfg");
|
---|
| 102 | if (!file_exists (filename)) {
|
---|
| 103 | filename = filename_cat (gsdlhome, "index");
|
---|
| 104 | filename = filename_cat (filename, "build.cfg");
|
---|
| 105 | if (!file_exists (filename)) return false;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
[1860] | 108 | return cserver.read_configfile(filename);
|
---|
| 109 |
|
---|
| 110 | /*
|
---|
[166] | 111 | // read in the build configuration file
|
---|
| 112 | text_t key;
|
---|
| 113 | text_tarray cfgline;
|
---|
| 114 | char *cstr = filename.getcstr();
|
---|
| 115 | ifstream confin (cstr);
|
---|
[9631] | 116 | delete []cstr;
|
---|
[166] | 117 |
|
---|
| 118 | if (confin) {
|
---|
| 119 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
| 120 | if (cfgline.size () >= 2) {
|
---|
| 121 | key = cfgline[0];
|
---|
| 122 | cfgline.erase(cfgline.begin());
|
---|
| 123 |
|
---|
| 124 | // configure the collection server
|
---|
| 125 | cserver.configure (key, cfgline);
|
---|
| 126 | }
|
---|
| 127 | }
|
---|
| 128 | confin.close ();
|
---|
| 129 | return true;
|
---|
| 130 | }
|
---|
| 131 | return false;
|
---|
[1860] | 132 | */
|
---|
[166] | 133 | }
|
---|