Changeset 7418
- Timestamp:
- 2004-05-25T11:57:23+12:00 (20 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/recptconfig.cpp
r7302 r7418 46 46 text_t *httpdomain; 47 47 text_t *httpprefix; 48 text_t *collection; 49 text_tset *actions; 50 text_tset *browsers; 48 51 int *maxrequests; 49 52 public: … … 52 55 httpdomain = NULL; 53 56 httpprefix = NULL; 57 collection = NULL; 58 actions = NULL; 59 browsers = NULL; 54 60 maxrequests = _maxrequests; 55 61 } … … 60 66 httpdomain = _httpdomain; 61 67 httpprefix = _httpprefix; 68 collection = NULL; 69 actions = NULL; 70 browsers = NULL; 62 71 maxrequests = NULL; 63 72 } 64 73 74 __site_configuration (text_t *_gsdlhome, text_t *_httpdomain, 75 text_t *_httpprefix, text_t *_collection) { 76 gsdlhome = _gsdlhome; 77 httpdomain = _httpdomain; 78 httpprefix = _httpprefix; 79 collection = _collection; 80 actions = NULL; 81 browsers = NULL; 82 maxrequests = NULL; 83 } 84 85 __site_configuration (text_t *_httpprefix, text_tset *_actions, text_tset *_browsers) { 86 gsdlhome = NULL; 87 httpdomain = NULL; 88 httpprefix = _httpprefix; 89 collection = NULL; 90 actions = _actions; 91 browsers = _browsers; 92 maxrequests = NULL; 93 } 94 65 95 inline void configure (const text_t &key, const text_tarray &cfgline) { 66 if ( key == "gsdlhome") {96 if (gsdlhome != NULL && key == "gsdlhome") { 67 97 *gsdlhome = cfgline[0]; 68 98 } 69 99 70 if (key == "httpprefix" && 71 httpprefix != NULL) { 100 if (httpprefix != NULL && key == "httpprefix") { 72 101 *httpprefix = cfgline[0]; 73 102 } 74 103 75 if (key == "httpdomain" && 76 httpdomain != NULL) { 104 if (httpdomain != NULL && key == "httpdomain") { 77 105 *httpdomain = cfgline[0]; 78 106 } 79 107 80 if (key == "maxrequests" && 81 maxrequests != NULL) { 108 if (collection != NULL && key == "collection") { 109 *collection = cfgline[0]; 110 } 111 112 if (actions != NULL && key == "actions") { 113 actions->clear(); 114 text_tarray::const_iterator thisAction = cfgline.begin(); 115 text_tarray::const_iterator endAction = cfgline.end(); 116 while (thisAction != endAction) { 117 actions->insert(*thisAction); 118 ++thisAction; 119 } 120 } 121 122 if (browsers != NULL && key == "browsers") { 123 browsers->clear(); 124 text_tarray::const_iterator thisBrowser = cfgline.begin(); 125 text_tarray::const_iterator endBrowser = cfgline.end(); 126 while (thisBrowser != endBrowser) { 127 browsers->insert(*thisBrowser); 128 ++thisBrowser; 129 } 130 } 131 132 if (maxrequests != NULL && key == "maxrequests") { 82 133 *maxrequests = cfgline[0].getint(); 83 134 if ((*maxrequests) < 1) { … … 120 171 httpprefix.clear(); 121 172 122 if (gsdlconfigurator.configure("gsdlsite.cfg")) { 173 if (gsdlconfigurator.configure("gsdlsite.cfg") && 174 !gsdlhome.empty() && !httpdomain.empty() && !httpprefix.empty()) { 123 175 return true; 124 176 } 125 177 126 178 return false; 179 } 180 181 // this version grabs gsdlhome, httpdomain, httpprefix, collection, 182 // returns false if it can't find gsdlhome, httpdomain and httpprefix 183 bool site_cfg_read (text_t &gsdlhome, text_t &httpdomain, 184 text_t &httpprefix, text_t &collection) { 185 // get gsdlhome etc 186 __site_configuration sitecfg(&gsdlhome, &httpdomain, &httpprefix, &collection); 187 configurator gsdlconfigurator(&sitecfg); 188 189 gsdlhome.clear(); 190 httpdomain.clear(); 191 httpprefix.clear(); 192 collection.clear(); 193 194 if (gsdlconfigurator.configure("gsdlsite.cfg") && 195 !gsdlhome.empty() && !httpdomain.empty() && !httpprefix.empty()) { 196 return true; 197 } 198 return false; 199 } 200 201 void main_cfg_read (const text_t& collection, const text_t &gsdlhome, text_t &httpprefix, text_tset& actions, text_tset& browsers) 202 { 203 __site_configuration sitecfg(&httpprefix, &actions, &browsers); 204 configurator gsdlconfigurator(&sitecfg); 205 206 httpprefix.clear(); 207 actions.clear(); 208 browsers.clear(); 209 210 text_t filename; 211 212 filename_cat (filename, gsdlhome, "collect", collection, "etc", "main.cfg"); 213 if (!file_exists(filename)) { 214 filename_cat (filename, gsdlhome, "etc", "main.cfg"); 215 if (!file_exists (filename)) { 216 filename.clear(); 217 } 218 } 219 220 if (!filename.empty()) gsdlconfigurator.configure(filename); 221 222 223 if (!collection.empty()) { 224 filename_cat (filename, gsdlhome, "collect", collection, "etc", "collect.cfg"); 225 if (!file_exists (filename)) { 226 filename_cat (filename, gsdlhome, "etc", "collect.cfg"); 227 if (!file_exists (filename)) filename.clear(); 228 } 229 230 if (!filename.empty()) gsdlconfigurator.configure(filename); 231 } 127 232 } 128 233 … … 140 245 filename = filename_cat (gsdlhome, "etc"); 141 246 filename = filename_cat (filename, "main.cfg"); 142 if ( file_exists(filename)) {247 if (!collection.empty() && file_exists(filename)) { 143 248 rv = recpt.read_configfile(filename); 144 } 145 249 } else { 250 filename_cat (filename, gsdlhome, "etc", "main.cfg"); 251 if (file_exists (filename)) { 252 rv = recpt.read_configfile(filename); 253 } 254 } 255 146 256 // Look for collect.cfg in GSDLHOME/collect/collection-name/etc directory 147 257 // (if this is for a particular collection), and then GSDLHOME/etc. -
trunk/gsdl/src/recpt/recptconfig.h
r1860 r7418 38 38 bool site_cfg_read (receptionist &recpt, text_t &gsdlhome, int &maxrequests); 39 39 bool site_cfg_read (text_t &gsdlhome, text_t &httpdomain, text_t &httpprefix); 40 bool site_cfg_read (text_t &gsdlhome, text_t &httpdomain, text_t &httpprefix, text_t &collection); 41 42 // read main.cfg for the actions and httpprefix 43 void main_cfg_read (const text_t& collection, const text_t &gsdlhome, text_t &httpprefix, text_tset& actions, text_tset& browsers); 40 44 41 45 // main_cfg_read reads either collect.cfg or main.cfg and returning
Note:
See TracChangeset
for help on using the changeset viewer.