[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 14376 2007-08-20 03:14:53Z mdewsnip $
|
---|
| 25 | *
|
---|
[166] | 26 | *********************************************************************/
|
---|
| 27 |
|
---|
[1860] | 28 | /*
|
---|
| 29 | $Log$
|
---|
[9631] | 30 | Revision 1.5 2005/04/11 21:08:04 kjdon
|
---|
| 31 | delete -> delete [] change submitted by Emanuel Dejanu
|
---|
| 32 |
|
---|
[1860] | 33 | Revision 1.4 2001/01/25 18:26:44 cs025
|
---|
| 34 | Included CORBA branch for first time
|
---|
| 35 |
|
---|
| 36 | Revision 1.2.2.1 2000/04/04 15:02:31 cs025
|
---|
| 37 | Corba first commit
|
---|
| 38 |
|
---|
| 39 | Revision 1.2 1999/09/07 04:57:20 sjboddie
|
---|
| 40 | added gpl notice
|
---|
| 41 |
|
---|
| 42 | Revision 1.1 1999/02/21 22:32:55 rjmcnab
|
---|
| 43 |
|
---|
| 44 | Initial revision.
|
---|
| 45 |
|
---|
| 46 | */
|
---|
| 47 |
|
---|
| 48 |
|
---|
[166] | 49 | #include "colservrconfig.h"
|
---|
| 50 | #include "fileutil.h"
|
---|
| 51 | #include "cfgread.h"
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | #if defined(GSDL_USE_OBJECTSPACE)
|
---|
| 55 | # include <ospace/std/iostream>
|
---|
| 56 | # include <ospace/std/fstream>
|
---|
| 57 | #elif defined(GSDL_USE_IOS_H)
|
---|
| 58 | # include <iostream.h>
|
---|
| 59 | # include <fstream.h>
|
---|
| 60 | #else
|
---|
| 61 | # include <iostream>
|
---|
| 62 | # include <fstream>
|
---|
| 63 | #endif
|
---|
| 64 |
|
---|
| 65 | // collect_cfg_read reads collect.cfg returning true on success.
|
---|
| 66 | bool collect_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
| 67 | const text_t &collection) {
|
---|
| 68 | text_t filename = filename_cat (gsdlhome, "collect");
|
---|
| 69 | filename = filename_cat (filename, collection);
|
---|
[14376] | 70 | filename = filename_cat (filename, "custom");
|
---|
| 71 | filename = filename_cat (filename, collection);
|
---|
[166] | 72 | filename = filename_cat (filename, "etc");
|
---|
[14376] | 73 | filename = filename_cat (filename, "custom.cfg");
|
---|
| 74 |
|
---|
[166] | 75 | if (!file_exists (filename)) {
|
---|
[14376] | 76 | filename = filename_cat (gsdlhome, "collect");
|
---|
| 77 | filename = filename_cat (filename, collection);
|
---|
| 78 | filename = filename_cat (filename, "etc");
|
---|
[166] | 79 | filename = filename_cat (filename, "collect.cfg");
|
---|
[14376] | 80 |
|
---|
| 81 | if (!file_exists (filename)) {
|
---|
| 82 | filename = filename_cat (gsdlhome, "etc");
|
---|
| 83 | filename = filename_cat (filename, "collect.cfg");
|
---|
| 84 | if (!file_exists (filename)) return false;
|
---|
| 85 | }
|
---|
[166] | 86 | }
|
---|
| 87 |
|
---|
[1860] | 88 | return cserver.read_configfile(filename);
|
---|
| 89 | /*
|
---|
[166] | 90 | // read in the collection configuration file
|
---|
| 91 | text_t key;
|
---|
| 92 | text_tarray cfgline;
|
---|
| 93 | char *cstr = filename.getcstr();
|
---|
| 94 | ifstream confin (cstr);
|
---|
[9631] | 95 | delete []cstr;
|
---|
[166] | 96 |
|
---|
| 97 | if (confin) {
|
---|
| 98 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
| 99 | if (cfgline.size () >= 2) {
|
---|
| 100 | key = cfgline[0];
|
---|
| 101 | cfgline.erase(cfgline.begin());
|
---|
| 102 |
|
---|
| 103 | // configure the collection server
|
---|
| 104 | cserver.configure (key, cfgline);
|
---|
| 105 | }
|
---|
| 106 | }
|
---|
| 107 | confin.close ();
|
---|
| 108 | return true;
|
---|
| 109 | }
|
---|
| 110 | return false;
|
---|
[1860] | 111 | */
|
---|
[166] | 112 | }
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | // build_cfg_read reads build.cfg and returns true on success.
|
---|
| 116 | bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
| 117 | const text_t &collection) {
|
---|
| 118 | text_t filename = filename_cat (gsdlhome, "collect");
|
---|
| 119 | filename = filename_cat (filename, collection);
|
---|
| 120 | filename = filename_cat (filename, "index");
|
---|
[534] | 121 |
|
---|
[166] | 122 | filename = filename_cat (filename, "build.cfg");
|
---|
| 123 | if (!file_exists (filename)) {
|
---|
| 124 | filename = filename_cat (gsdlhome, "index");
|
---|
| 125 | filename = filename_cat (filename, "build.cfg");
|
---|
| 126 | if (!file_exists (filename)) return false;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[1860] | 129 | return cserver.read_configfile(filename);
|
---|
| 130 |
|
---|
| 131 | /*
|
---|
[166] | 132 | // read in the build configuration file
|
---|
| 133 | text_t key;
|
---|
| 134 | text_tarray cfgline;
|
---|
| 135 | char *cstr = filename.getcstr();
|
---|
| 136 | ifstream confin (cstr);
|
---|
[9631] | 137 | delete []cstr;
|
---|
[166] | 138 |
|
---|
| 139 | if (confin) {
|
---|
| 140 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
| 141 | if (cfgline.size () >= 2) {
|
---|
| 142 | key = cfgline[0];
|
---|
| 143 | cfgline.erase(cfgline.begin());
|
---|
| 144 |
|
---|
| 145 | // configure the collection server
|
---|
| 146 | cserver.configure (key, cfgline);
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 | confin.close ();
|
---|
| 150 | return true;
|
---|
| 151 | }
|
---|
| 152 | return false;
|
---|
[1860] | 153 | */
|
---|
[166] | 154 | }
|
---|