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 | * $Id: colservrconfig.cpp 9631 2005-04-11 21:08:04Z kjdon $
|
---|
25 | *
|
---|
26 | *********************************************************************/
|
---|
27 |
|
---|
28 | /*
|
---|
29 | $Log$
|
---|
30 | Revision 1.5 2005/04/11 21:08:04 kjdon
|
---|
31 | delete -> delete [] change submitted by Emanuel Dejanu
|
---|
32 |
|
---|
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 |
|
---|
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);
|
---|
70 | filename = filename_cat (filename, "etc");
|
---|
71 | filename = filename_cat (filename, "collect.cfg");
|
---|
72 | if (!file_exists (filename)) {
|
---|
73 | filename = filename_cat (gsdlhome, "etc");
|
---|
74 | filename = filename_cat (filename, "collect.cfg");
|
---|
75 | if (!file_exists (filename)) return false;
|
---|
76 | }
|
---|
77 |
|
---|
78 | return cserver.read_configfile(filename);
|
---|
79 | /*
|
---|
80 | // read in the collection configuration file
|
---|
81 | text_t key;
|
---|
82 | text_tarray cfgline;
|
---|
83 | char *cstr = filename.getcstr();
|
---|
84 | ifstream confin (cstr);
|
---|
85 | delete []cstr;
|
---|
86 |
|
---|
87 | if (confin) {
|
---|
88 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
89 | if (cfgline.size () >= 2) {
|
---|
90 | key = cfgline[0];
|
---|
91 | cfgline.erase(cfgline.begin());
|
---|
92 |
|
---|
93 | // configure the collection server
|
---|
94 | cserver.configure (key, cfgline);
|
---|
95 | }
|
---|
96 | }
|
---|
97 | confin.close ();
|
---|
98 | return true;
|
---|
99 | }
|
---|
100 | return false;
|
---|
101 | */
|
---|
102 | }
|
---|
103 |
|
---|
104 |
|
---|
105 | // build_cfg_read reads build.cfg and returns true on success.
|
---|
106 | bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
|
---|
107 | const text_t &collection) {
|
---|
108 | text_t filename = filename_cat (gsdlhome, "collect");
|
---|
109 | filename = filename_cat (filename, collection);
|
---|
110 | filename = filename_cat (filename, "index");
|
---|
111 |
|
---|
112 | filename = filename_cat (filename, "build.cfg");
|
---|
113 | if (!file_exists (filename)) {
|
---|
114 | filename = filename_cat (gsdlhome, "index");
|
---|
115 | filename = filename_cat (filename, "build.cfg");
|
---|
116 | if (!file_exists (filename)) return false;
|
---|
117 | }
|
---|
118 |
|
---|
119 | return cserver.read_configfile(filename);
|
---|
120 |
|
---|
121 | /*
|
---|
122 | // read in the build configuration file
|
---|
123 | text_t key;
|
---|
124 | text_tarray cfgline;
|
---|
125 | char *cstr = filename.getcstr();
|
---|
126 | ifstream confin (cstr);
|
---|
127 | delete []cstr;
|
---|
128 |
|
---|
129 | if (confin) {
|
---|
130 | while (read_cfg_line(confin, cfgline) >= 0) {
|
---|
131 | if (cfgline.size () >= 2) {
|
---|
132 | key = cfgline[0];
|
---|
133 | cfgline.erase(cfgline.begin());
|
---|
134 |
|
---|
135 | // configure the collection server
|
---|
136 | cserver.configure (key, cfgline);
|
---|
137 | }
|
---|
138 | }
|
---|
139 | confin.close ();
|
---|
140 | return true;
|
---|
141 | }
|
---|
142 | return false;
|
---|
143 | */
|
---|
144 | }
|
---|