Changeset 963 for trunk/gsdl/src/recpt/recptconfig.cpp
- Timestamp:
- 2000-02-22T11:01:02+13:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/recptconfig.cpp
r533 r963 28 28 /* 29 29 $Log$ 30 Revision 1.6 2000/02/21 21:55:33 sjboddie 31 gsdlhome now comes from gsdlsite.cfg 32 30 33 Revision 1.5 1999/09/07 04:56:59 sjboddie 31 34 added GPL notice … … 67 70 68 71 // reads site configuration file returning true on success 69 bool site_cfg_read (receptionist &recpt, const text_t &gsdlhome, 70 const text_t &collection, int &maxrequests) { 72 // also sets gsdlhome and maxrequests 73 // gsdlsite.cfg should be in same directory as library executable 74 bool site_cfg_read (receptionist &recpt, text_t &gsdlhome, int &maxrequests) { 71 75 72 maxrequests = 10000; // a reasonable default76 gsdlhome.clear(); 73 77 74 // Look for site.cfg in GSDLHOME/collect/collection-name/etc directory 75 // (if this is for a particular collection), and then GSDLHOME/etc. 76 text_t filename; 77 if (!collection.empty()) { 78 filename = filename_cat (gsdlhome, "collect"); 79 filename = filename_cat (filename, collection); 80 filename = filename_cat (filename, "etc"); 81 filename = filename_cat (filename, "site.cfg"); 82 if (!file_exists (filename)) filename.clear(); 83 } 84 if (filename.empty()) { 85 filename = filename_cat (gsdlhome, "etc"); 86 filename = filename_cat (filename, "site.cfg"); 87 if (!file_exists (filename)) return false; 88 } 89 90 // read in the site configuration file 78 // Look for gsdlsite.cfg in same directory that executable is in. 91 79 text_tarray cfgline; 92 80 text_t key; 93 char *cstr = filename.getcstr(); 94 ifstream confin (cstr); 95 delete cstr; 81 ifstream confin ("gsdlsite.cfg"); 96 82 97 83 if (confin) { … … 100 86 key = cfgline[0]; 101 87 cfgline.erase(cfgline.begin()); 102 88 103 89 if (key == "maxrequests") { 104 90 maxrequests = cfgline[0].getint(); 105 91 if (maxrequests < 1) maxrequests = 1; 106 92 } 93 94 if (key == "gsdlhome") 95 gsdlhome = cfgline[0]; 107 96 108 97 // configure the receptionist … … 116 105 } 117 106 107 // this version just grabs gsdlhome, returns false if it can't find it 108 bool site_cfg_read (text_t &gsdlhome) { 109 110 gsdlhome.clear(); 111 112 // Look for gsdlsite.cfg in same directory that executable is in. 113 text_tarray cfgline; 114 text_t key; 115 ifstream confin ("gsdlsite.cfg"); 116 117 if (confin) { 118 while (read_cfg_line(confin, cfgline) >= 0) { 119 if (cfgline.size () >= 2) { 120 if (cfgline[0] == "gsdlhome") { 121 gsdlhome = cfgline[1]; 122 return true; 123 } 124 } 125 } 126 confin.close (); 127 } 128 return false; 129 } 118 130 119 131 // main_cfg_read reads both main.cfg and collect.cfg. It attempts
Note:
See TracChangeset
for help on using the changeset viewer.