root/gsdl/trunk/src/colservr/colservrconfig.cpp @ 14376

Revision 14376, 4.2 KB (checked in by mdewsnip, 12 years ago)

Changed to read custom collect.cfg file from "custom" collection sub-directory, to match changes to building code.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
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 * $Id$
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.
66bool 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, "custom");
71  filename = filename_cat (filename, collection);
72  filename = filename_cat (filename, "etc");
73  filename = filename_cat (filename, "custom.cfg");
74
75  if (!file_exists (filename)) {
76    filename = filename_cat (gsdlhome, "collect");
77    filename = filename_cat (filename, collection);
78    filename = filename_cat (filename, "etc");
79    filename = filename_cat (filename, "collect.cfg");
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    }
86  }
87
88  return cserver.read_configfile(filename);
89  /*
90  // read in the collection configuration file
91  text_t key;
92  text_tarray cfgline;
93  char *cstr = filename.getcstr();
94  ifstream confin (cstr);
95  delete []cstr;
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;
111  */
112}
113
114
115// build_cfg_read reads build.cfg and returns true on success.
116bool 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");
121
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
129  return cserver.read_configfile(filename);
130
131  /*
132  // read in the build configuration file
133  text_t key;
134  text_tarray cfgline;
135  char *cstr = filename.getcstr();
136  ifstream confin (cstr);
137  delete []cstr;
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;
153  */
154}
Note: See TracBrowser for help on using the browser.