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

Last change on this file since 166 was 166, checked in by rjmcnab, 25 years ago

Initial revision.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1/**********************************************************************
2 *
3 * colservrconfig.cpp --
4 * Copyright (C) 1999 The New Zealand Digital Library Project
5 *
6 * PUT COPYRIGHT NOTICE HERE
7 *
8 * $Id: colservrconfig.cpp 166 1999-02-21 22:35:26Z rjmcnab $
9 *
10 *********************************************************************/
11
12/*
13 $Log$
14 Revision 1.1 1999/02/21 22:32:55 rjmcnab
15
16 Initial revision.
17
18 */
19
20
21#include "colservrconfig.h"
22#include "fileutil.h"
23#include "cfgread.h"
24
25
26#if defined(GSDL_USE_OBJECTSPACE)
27# include <ospace/std/iostream>
28# include <ospace/std/fstream>
29#elif defined(GSDL_USE_IOS_H)
30# include <iostream.h>
31# include <fstream.h>
32#else
33# include <iostream>
34# include <fstream>
35#endif
36
37// collect_cfg_read reads collect.cfg returning true on success.
38bool collect_cfg_read (collectserver &cserver, const text_t &gsdlhome,
39 const text_t &collection) {
40 text_t filename = filename_cat (gsdlhome, "collect");
41 filename = filename_cat (filename, collection);
42 filename = filename_cat (filename, "etc");
43 filename = filename_cat (filename, "collect.cfg");
44 if (!file_exists (filename)) {
45 filename = filename_cat (gsdlhome, "etc");
46 filename = filename_cat (filename, "collect.cfg");
47 if (!file_exists (filename)) return false;
48 }
49
50 // read in the collection configuration file
51 text_t key;
52 text_tarray cfgline;
53 char *cstr = filename.getcstr();
54 ifstream confin (cstr);
55 delete cstr;
56
57 if (confin) {
58 while (read_cfg_line(confin, cfgline) >= 0) {
59 if (cfgline.size () >= 2) {
60 key = cfgline[0];
61 cfgline.erase(cfgline.begin());
62
63 // configure the collection server
64 cserver.configure (key, cfgline);
65 }
66 }
67 confin.close ();
68 return true;
69 }
70 return false;
71}
72
73
74// build_cfg_read reads build.cfg and returns true on success.
75bool build_cfg_read (collectserver &cserver, const text_t &gsdlhome,
76 const text_t &collection) {
77 text_t filename = filename_cat (gsdlhome, "collect");
78 filename = filename_cat (filename, collection);
79 filename = filename_cat (filename, "index");
80 filename = filename_cat (filename, "build.cfg");
81 if (!file_exists (filename)) {
82 filename = filename_cat (gsdlhome, "index");
83 filename = filename_cat (filename, "build.cfg");
84 if (!file_exists (filename)) return false;
85 }
86
87 // read in the build configuration file
88 text_t key;
89 text_tarray cfgline;
90 char *cstr = filename.getcstr();
91 ifstream confin (cstr);
92 delete cstr;
93
94 if (confin) {
95 while (read_cfg_line(confin, cfgline) >= 0) {
96 if (cfgline.size () >= 2) {
97 key = cfgline[0];
98 cfgline.erase(cfgline.begin());
99
100 // configure the collection server
101 cserver.configure (key, cfgline);
102 }
103 }
104 confin.close ();
105 return true;
106 }
107 return false;
108}
109
Note: See TracBrowser for help on using the repository browser.