Changeset 150 for trunk/gsdl/src/recpt
- Timestamp:
- 1999-02-05T23:42:50+13:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 added
- 2 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/action.cpp
r146 r150 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/02/05 10:42:41 rjmcnab 15 16 Continued working on receptionist 17 14 18 Revision 1.2 1999/02/04 10:00:53 rjmcnab 15 19 … … 84 88 aptr.a = theaction; 85 89 actionptrs[theaction->get_action_name()] = aptr; 90 aptr.a = NULL; // control has passed on 86 91 } 87 92 -
trunk/gsdl/src/recpt/cgiargs.cpp
r146 r150 12 12 /* 13 13 $Log$ 14 Revision 1.4 1999/02/05 10:42:41 rjmcnab 15 16 Continued working on receptionist 17 14 18 Revision 1.3 1999/02/04 10:00:54 rjmcnab 15 19 … … 157 161 << "\" was defined as being a single character option\n" 158 162 << "but a multiple character default was given.\n\n"; 159 } 163 return false; // found a problem 164 } 165 166 // make sure there is no clashes in the savedarginfo 167 if ((orginfo->savedarginfo==cgiarginfo::mustnot && 168 info.savedarginfo==cgiarginfo::must) || 169 (orginfo->savedarginfo==cgiarginfo::must && 170 info.savedarginfo==cgiarginfo::mustnot)) { 171 logout << text_t2ascii << "Error: it was specified that cgi argument \"" 172 << info.shortname << "\" should be saved in the state\n" 173 << "information and that it should not be save in the state information.\n\n"; 174 return false; // found a clash 175 } 176 // the only time orginfo->savedarginfo can change is when it is set 177 // to "can" 178 if (orginfo->savedarginfo == cgiarginfo::can) 179 orginfo->savedarginfo = info.savedarginfo; 180 160 181 161 182 if (orginfo->defaultstatus > info.defaultstatus) { 162 183 return true; 163 184 } 164 165 185 orginfo->defaultstatus = info.defaultstatus; 166 186 orginfo->argdefault = info.argdefault; 187 167 188 return true; 168 189 } … … 187 208 } 188 209 210 const cgiarginfo *cgiargsinfoclass::getarginfo (const text_t &key) const { 211 const_iterator here = argsinfo.find (key); 212 if (here == argsinfo.end()) return NULL; 213 214 return &((*here).second); 215 } 216 217 218 219 // utilities related to cgi arguments 220 221 222 static text_t::const_iterator get_next_save_arg (text_t::const_iterator first, 223 text_t::const_iterator last, 224 text_t &argname) { 225 first = getdelimitstr (first, last, '-', argname); 226 return first; 227 } 228 229 230 231 232 233 // check_save_conf_str checks the configuration string for 234 // the saved args and makes sure it does not conflict with 235 // the information about the arguments. If an error is encountered 236 // it will return false and the program should not produce any 237 // output. 238 bool check_save_conf_str (const text_t &saveconf, 239 const cgiargsinfoclass &argsinfo, 240 ostream &logout) { 241 outconvertclass text_t2ascii; 242 243 text_tset argsset; 244 text_t::const_iterator saveconfhere = saveconf.begin (); 245 text_t::const_iterator saveconfend = saveconf.end (); 246 text_t argname; 247 const cgiarginfo *info; 248 249 // first check to make sure all saved arguments can be saved 250 251 while (saveconfhere != saveconfend) { 252 saveconfhere = get_next_save_arg (saveconfhere, saveconfend, argname); 253 254 if (!argname.empty()) { 255 // save the argument name for later 256 argsset.insert (argname); 257 258 // check the argument 259 info = argsinfo.getarginfo (argname); 260 if (info == NULL) { 261 logout << text_t2ascii << "Error: the cgi argument \"" << argname 262 << "\" is used in the configuration string for the\n" 263 << "saved arguments but does not exist as a valid argument.\n\n"; 264 return false; 265 } 266 if (info->savedarginfo == cgiarginfo::mustnot) { 267 logout << text_t2ascii << "Error: the cgi argument \"" << argname 268 << "\" is used in the configuration string for the\n" 269 << "saved arguments but has been specified as an argument whose\n" 270 << "state must not be saved.\n\n"; 271 return false; 272 } 273 } 274 } 275 276 277 // next check that all saved arguments that should be saved 278 // are saved 279 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin (); 280 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end (); 281 282 while (argsinfohere != argsinfoend) { 283 if (((*argsinfohere).second.savedarginfo == cgiarginfo::must) && 284 (argsset.find((*argsinfohere).second.shortname) == argsset.end())) { 285 logout << text_t2ascii << "Error: the cgi argument \"" 286 << (*argsinfohere).second.shortname << "\" was specified as needing to\n" 287 << "be save but was not listed in the saved arguments.\n\n"; 288 return false; 289 } 290 291 argsinfohere++; 292 } 293 294 return true; // made it, no clashes 295 } 296 297 298 299 // create_save_conf_str will create a configuration string 300 // based on the information in argsinfo. This method of configuration 301 // is not recomended as small changes can produce large changes in 302 // the resulting configuration string (for instance a totally different 303 // ordering) 304 text_t create_save_conf_str (const cgiargsinfoclass &argsinfo, 305 ostream &logout); 306 307 // expand_save_args will expand the saved arguments based 308 // on saveconf placing the results in args if they are not 309 // already defined. If it encounters an error it will return false 310 // and output more information to logout. 311 bool expand_save_args (const text_t &saveconf, 312 cgiargsclass &args, 313 ostream &logout); 314 315 // adds the default values for those arguments which have not 316 // been specified 317 void add_default_args (const cgiargsinfoclass &argsinfo, 318 cgiargsclass &args, 319 ostream &logout); 320 -
trunk/gsdl/src/recpt/cgiargs.h
r146 r150 124 124 defaultstatus_t defaultstatus; 125 125 text_t argdefault; // a default value 126 127 // savedarginfo_t indicates whether the argument should be saved 128 // between pages (e.g. using the compressed argument) or not. The 129 // value of an argument can change from "can" to "mustnot" and 130 // "can" to "must" but not "mustnot" to "must" or "must" to "mustnot". 131 enum savedarginfo_t {mustnot, can, must}; 132 133 savedarginfo_t savedarginfo; 126 134 }; 127 135 … … 174 182 175 183 cgiarginfo *getarginfo (const text_t &key); 184 const cgiarginfo *getarginfo (const text_t &key) const; 176 185 cgiarginfo &operator[] (const text_t &key) {return argsinfo[key];} 177 186 }; … … 179 188 180 189 190 // utilities related to cgi arguments 191 192 // check_compress_conf_str checks the configuration string for 193 // the compressed args and makes sure it does not conflict with 194 // the information about the arguments. If an error is encountered 195 // it will return false and the program should not produce any 196 // output. 197 bool check_compress_conf_str (const text_t &compressconf, 198 const cgiargsinfoclass &argsinfo, 199 ostream &logout); 200 201 // create_compress_conf_str will create a configuration string 202 // based on the information in argsinfo. This method of configuration 203 // is not recomended as small changes can produce large changes in 204 // the resulting configuration string (for instance a totally different 205 // ordering) 206 text_t create_compress_conf_str (const cgiargsinfoclass &argsinfo, 207 ostream &logout); 208 209 // expand_compress_args will expand the compressed arguments based 210 // on compressconf placing the results in args if they are not 211 // already defined. If it encounters an error it will return false 212 // and output more information to logout. 213 bool expand_compress_args (const text_t &compressconf, 214 cgiargsclass &args, 215 ostream &logout); 216 217 // adds the default values for those arguments which have not 218 // been specified 219 void add_default_args (const cgiargsinfoclass &argsinfo, 220 cgiargsclass &args, 221 ostream &logout); 222 223 181 224 #endif -
trunk/gsdl/src/recpt/cgiutils.cpp
r108 r150 12 12 /* 13 13 $Log$ 14 Revision 1.2 1999/02/05 10:42:43 rjmcnab 15 16 Continued working on receptionist 17 14 18 Revision 1.1 1999/01/08 08:40:56 rjmcnab 15 19 … … 21 25 22 26 */ 23 24 static char *RCSID = "$Id$";25 27 26 28 … … 128 130 } else if (c == ' ') { 129 131 // space 130 outtext.push_back( "+");132 outtext.push_back('+'); 131 133 } else { 132 134 // everything else -
trunk/gsdl/src/recpt/cgiwrapper.cpp
r146 r150 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/02/05 10:42:44 rjmcnab 15 16 Continued working on receptionist 17 14 18 Revision 1.2 1999/02/04 10:00:56 rjmcnab 15 19 … … 34 38 #include "gsdlconf.h" 35 39 #include "cgiwrapper.h" 40 #include "recptconfig.h" 36 41 #include <stdlib.h> 42 37 43 38 44 #if defined(GSDL_USE_OBJECTSPACE) … … 47 53 #endif 48 54 49 #include "cfgread.h"50 #include "fileutil.h"51 52 55 #ifdef USE_FASTCGI 53 56 #include "fcgiapp.h" … … 108 111 109 112 110 // returns true on success 111 static bool site_cfg_read (receptionist &recpt, const text_t &collection, 112 const text_t &filename, int &maxrequests) { 113 text_tarray cfgline; 114 char *cstr = filename.getcstr(); 115 ifstream confin (cstr); 116 delete cstr; 117 118 maxrequests = 10000; 119 120 if (confin) { 121 while (read_cfg_line(confin, cfgline) >= 0) { 122 if (cfgline.size () >= 2) { 123 if (cfgline[0] == "gsdlhome") { 124 if (collection.empty()) recpt.set_gsdlhome(cfgline[1]); 125 else recpt.set_gsdlhome(cfgline[1], collection); 126 } 127 else if (cfgline[0] == "httpimg") recpt.set_httpimg(cfgline[1]); 128 else if (cfgline[0] == "gwcgi") recpt.set_gwcgi(cfgline[1]); 129 else if (cfgline[0] == "maxrequests") { 130 maxrequests = cfgline[1].getint(); 131 if (maxrequests < 1) maxrequests = 1; 132 } 133 } 134 } 135 confin.close (); 136 return true; 137 } 138 return false; 139 } 140 141 142 static void page_errorconfigfile (const text_t &collection) { 113 static void page_errorsitecfg (const text_t &gsdlhome, const text_t &collection) { 114 outconvertclass text_t2ascii; 115 143 116 cout << "Content-type: text/html\n\n"; 144 117 … … 154 127 if (collection.empty()) { 155 128 cout << "As this cgi script is not being run in collection specific mode,\n"; 156 cout << "the file should reside at " GSDL_GSDLHOME "/etc/site.cfg.\n"; 129 cout << "the file should reside at "; 130 cout << text_t2ascii << gsdlhome; 131 cout << "/etc/site.cfg.\n"; 157 132 } else { 158 char *cstr = collection.getcstr();159 133 cout << "As this cgi script is being run in collection specific mode,\n"; 160 cout << "the file can reside in " GSDL_GSDLHOME "/collect/" << cstr 161 << "/etc/site.cfg or " GSDL_GSDLHOME "/etc/site.cfg.\n"; 162 delete cstr; 134 cout << text_t2ascii << "the file can reside in " << gsdlhome << "/collect/" 135 << collection << "/etc/site.cfg or " << gsdlhome << "/etc/site.cfg.\n"; 163 136 } 164 137 cout << "</body>\n"; … … 167 140 168 141 169 static void page_errorinit () { 142 static void page_errormaincfg (const text_t &gsdlhome, const text_t &collection) { 143 outconvertclass text_t2ascii; 144 145 cout << "Content-type: text/html\n\n"; 146 147 cout << "<html>\n"; 148 cout << "<head>\n"; 149 cout << "<title>Error</title>\n"; 150 cout << "</head>\n"; 151 cout << "<body>\n"; 152 cout << "<h2>Oops!</h2>\n"; 153 if (collection.empty()) { 154 cout << "The main.cfg configuration file could not be found. This file\n"; 155 cout << "should contain configuration information relating to the\n"; 156 cout << "setup of the interface. As this cgi script is not being run\n"; 157 cout << "in collection specific mode the file should reside at\n"; 158 cout << text_t2ascii << gsdlhome << "/etc/main.cfg.\n"; 159 } else { 160 cout << "Neither the collect.cfg or main.cfg configuration files could\n"; 161 cout << "not be found. This file should contain configuration information\n"; 162 cout << "relating to the setup of the interface. As this cgi script is\n"; 163 cout << "being run in collection specific mode the file should reside\n"; 164 cout << "at either "; 165 cout << text_t2ascii << gsdlhome << "/collect/" << collection 166 << "/etc/collect.cfg, " << gsdlhome << "/etc/collect.cfg or " 167 << gsdlhome << "/etc/main.cfg.\n"; 168 } 169 cout << "</body>\n"; 170 cout << "</html>\n"; 171 } 172 173 174 static void page_errorinit (const text_t &gsdlhome) { 175 outconvertclass text_t2ascii; 176 170 177 cout << "Content-type: text/html\n\n"; 171 178 … … 178 185 cout << "An error occurred during the initialisation of the Greenstone Digital\n"; 179 186 cout << "Library software. It is likely that the software has not been setup\n"; 180 cout << "correctly, consult " GSDL_GSDLHOME "/etc/initout.txt for more information.\n"; 187 cout << "correctly, consult "; 188 cout << text_t2ascii << gsdlhome << "/etc/initout.txt for more information.\n"; 181 189 cout << "</body>\n"; 182 190 cout << "</html>\n"; … … 204 212 else recpt.set_gwcgi("/cgi-bin/gw"); 205 213 206 // read in the site configuration file. Try to find it in the 207 // GSDLHOME/collect/collection-name/etc directory 208 // (if this is for a particular collection), and then GSDLHOME/etc. 209 bool configfileread = false; 210 text_t filename; 211 if (!collection.empty()) { 212 filename = filename_cat (GSDL_GSDLHOME, "collect"); 213 filename = filename_cat (filename, collection); 214 filename = filename_cat (filename, "etc"); 215 filename = filename_cat (filename, "site.cfg"); 216 configfileread = site_cfg_read (recpt, collection, filename, maxrequests); 217 } 218 if (!configfileread) { 219 filename = filename_cat (GSDL_GSDLHOME, "etc"); 220 filename = filename_cat (filename, "site.cfg"); 221 if (!site_cfg_read (recpt, collection, filename, maxrequests)) { 222 // couldn't find the site configuration file 223 page_errorconfigfile (collection); 224 return; 225 } 214 // read in the configuration files. 215 if (!site_cfg_read (recpt, GSDL_GSDLHOME, collection, maxrequests)) { 216 // couldn't find the site configuration file 217 page_errorsitecfg (GSDL_GSDLHOME, collection); 218 return; 219 } 220 if (!main_cfg_read (recpt, GSDL_GSDLHOME, collection)) { 221 // couldn't find the main configuration file 222 page_errormaincfg (GSDL_GSDLHOME, collection); 223 return; 226 224 } 227 225 228 226 // initialise the library software 229 227 ofstream initout (GSDL_GSDLHOME "/etc/initout.txt"); 230 if (!recpt. digest(initout)) {228 if (!recpt.init(initout)) { 231 229 // an error occurred during the initialisation 232 230 initout.close(); 233 page_errorinit( );231 page_errorinit(GSDL_GSDLHOME); 234 232 return; 235 233 } -
trunk/gsdl/src/recpt/receptionist.cpp
r146 r150 12 12 /* 13 13 $Log$ 14 Revision 1.4 1999/02/05 10:42:46 rjmcnab 15 16 Continued working on receptionist 17 14 18 Revision 1.3 1999/02/04 10:00:56 rjmcnab 15 19 … … 28 32 #include "fileutil.h" 29 33 #include <assert.h> 34 #include <time.h> 30 35 31 36 … … 78 83 // meaningless output), instead an error page should be 79 84 // produced by the calling code. 80 bool receptionist:: digest (ostream &logout) {85 bool receptionist::init (ostream &logout) { 81 86 // redirect the error output to logout 82 87 // disp.setlogout (&logout); … … 86 91 // cfg_info.defaultpage = "about"; 87 92 // cfg_info.defaultencoding = "w"; 88 89 // read in the configuration files etc/collect.cfg and index/build.cfg90 // entries in build.cfg should override those in collect.cfg91 // filename = filename_cat (collectdir, "etc");92 // filename = filename_cat (filename, "collect.cfg");93 // cfg_read(filename);94 93 95 94 // load up the default macro files, the collection directory … … 108 107 // } 109 108 110 //srand(time(NULL));109 srand(time(NULL)); 111 110 112 111 // utf8outconvert.set_rzws(1); 113 112 // gboutconvert.set_rzws(1); 114 113 115 // return collect_init(collection);116 114 return true; 117 115 } -
trunk/gsdl/src/recpt/receptionist.h
r146 r150 47 47 void set_gwcgi (const text_t &thegwcgi); 48 48 49 // digest should be called after setgsdhome has been called.49 // init should be called after setgsdhome has been called. 50 50 // It returns true on success and false on failure. If false is 51 51 // returned getpage should not be called (without producing 52 52 // meaningless output), instead an error page should be 53 53 // produced by the calling code. 54 bool digest (ostream &logout);54 bool init (ostream &logout); 55 55 56 56 // There are two ways to produce a page. You can either call parse_cgi_args,
Note:
See TracChangeset
for help on using the changeset viewer.