Changeset 1342 for branches/z3950-branch/gsdl/src/recpt/receptionist.cpp
- Timestamp:
- 2000-08-03T14:49:41+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/z3950-branch/gsdl/src/recpt/receptionist.cpp
r1148 r1342 22 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 23 * 24 * $Id$25 *26 24 *********************************************************************/ 27 28 /*29 $Log$30 Revision 1.49 2000/05/04 05:18:46 sjboddie31 attempting to get end-user collection building to work under windows32 33 Revision 1.48 2000/04/14 02:52:06 sjboddie34 tidied up error messaging and set up some debugging info to be output35 when running library from command line36 37 Revision 1.47 2000/02/17 22:26:17 sjboddie38 set macros for displaying macrons in utf839 40 Revision 1.46 2000/02/17 02:34:09 sjboddie41 made compressedoptions macro dm_safe - added SCRIPT_NAME to log string42 43 Revision 1.45 2000/02/03 01:48:52 sjboddie44 fixed potential bug in ccscols stuff45 46 Revision 1.44 2000/01/24 22:53:09 sjboddie47 a few small changes to get fastcgi working properly here at Waikato -48 hopefully changes will work everywhere ...49 50 Revision 1.43 1999/12/06 01:14:16 sjboddie51 added arabic encoding52 53 Revision 1.42 1999/12/05 21:21:04 sjboddie54 added support for multiple gsdlhomes and gdbmhomes55 56 Revision 1.41 1999/11/25 21:44:16 sjboddie57 fixed bug in logout58 59 Revision 1.40 1999/11/08 20:26:37 sjboddie60 added multiplevalue option to cgiarginfo61 62 Revision 1.39 1999/11/03 22:49:10 sjboddie63 A location url may now contain macros64 65 Revision 1.38 1999/11/01 21:49:34 sjboddie66 changes to arguments of many functions67 68 Revision 1.37 1999/10/20 03:55:03 sjboddie69 yet another problem with calling browserclass70 processOID functions correctly71 72 Revision 1.36 1999/10/19 03:23:44 davidb73 Collection building support through web pages74 and internal and external link handling for collection documents75 76 Revision 1.35 1999/10/18 20:07:05 sjboddie77 tidied up a few things - moved processing of "hp" argument78 to htmlbrowserclass79 80 Revision 1.34 1999/10/14 23:00:52 sjboddie81 finished changes to browsing support82 83 Revision 1.33 1999/10/10 08:14:10 sjboddie84 - metadata now returns mp rather than array85 - redesigned browsing support (although it's not finished so86 won't currently work ;-)87 88 Revision 1.32 1999/09/21 11:28:45 sjboddie89 tidied up file locking90 91 Revision 1.31 1999/09/16 21:38:17 sjboddie92 added some file locking stuff for logging. Windows still needs to93 be done.94 95 Revision 1.30 1999/09/07 04:56:58 sjboddie96 added GPL notice97 98 Revision 1.29 1999/09/03 10:02:30 rjmcnab99 Made the page parameters configurable. Now the page parameters must100 correspond to cgi arguments in name and value (ie language=zh should now101 be l=zh) which makes things more consistent anyway. Removed a couple of102 specialised NZDL page parameters.103 104 Moved the combining of the cgi arguments so that the receptionist does105 all the configuration now.106 107 Made the macro precedence configurable.108 109 Made cgi arguments totally configurable. Now any piece of information about110 a cgi argument can be configured meaning that cgi arguments can be declared111 from the configuration file.112 113 Removed the argdefault configuration argument. This should now be done114 using cgiarg.115 116 Revision 1.28 1999/09/03 04:39:46 rjmcnab117 Made cookies and logs optional (they are turned off by default). To118 turn them on put119 120 usecookies true121 logcgiargs true122 123 in your configuration file.124 125 Revision 1.27 1999/09/02 00:27:21 rjmcnab126 A few small things.127 128 Revision 1.26 1999/08/25 04:43:06 sjboddie129 made FilterRequest_t::docSet an array rather than a set130 131 Revision 1.25 1999/08/20 00:59:01 sjboddie132 -fixed up location redirection133 -added some usage logging, also now set a GSDL_UID cookie. Logging134 does NOT presently lock the log file while it's in use. That has yet135 to be done.136 137 Revision 1.24 1999/08/13 04:16:42 sjboddie138 added some collection-level metadata stuff139 140 Revision 1.23 1999/08/11 23:28:59 sjboddie141 added support for html classifier (i.e. the hp argumant now must be142 translated too).143 144 Revision 1.22 1999/08/10 22:45:21 sjboddie145 format option ShowTopPages is now called DocumentTopPages146 147 Revision 1.21 1999/08/09 04:25:17 sjboddie148 moved OID translation stuff from documentaction::define_external_macros149 to receptionist150 151 Revision 1.20 1999/07/30 02:13:09 sjboddie152 -added collectinfo argument to some functions153 -made some function prototypes virtual154 155 Revision 1.19 1999/07/15 06:02:05 rjmcnab156 Moved the setting of argsinfo into the constructor. Added the configuration157 command argdefault (as used by the actions). Added code to output the158 correct charset based on the page encoding so that the user does not need159 to specify the encoding used for a particular page.160 161 Revision 1.18 1999/07/11 01:05:20 rjmcnab162 Stored origin of cgiarg with argument.163 164 Revision 1.17 1999/07/10 22:18:26 rjmcnab165 Added calls to define_external_cgiargs.166 167 Revision 1.16 1999/06/27 21:49:03 sjboddie168 fixed a couple of version conflicts - tidied up some small things169 170 Revision 1.15 1999/06/26 01:14:32 rjmcnab171 Made a couple of changes to handle different encodings.172 173 Revision 1.14 1999/06/09 00:08:36 sjboddie174 query string macro (_cgiargq_) is now made html safe before being set175 176 Revision 1.13 1999/06/08 04:29:31 sjboddie177 added argsinfo to the call to check_cgiargs to make it easy to set178 args to their default if they're found to be screwed up179 180 Revision 1.12 1999/04/30 01:59:42 sjboddie181 lots of stuff - getting documentaction working (documentaction replaces182 old browseaction)183 184 Revision 1.11 1999/03/25 03:06:43 sjboddie185 186 altered receptionist slightly so it now passes *collectproto to187 define_internal_macros and define_external_macros - need it188 for browseaction189 190 Revision 1.10 1999/03/05 03:53:54 sjboddie191 192 fixed some bugs193 194 Revision 1.9 1999/02/28 20:00:16 rjmcnab195 196 197 Fixed a few things.198 199 Revision 1.8 1999/02/25 21:58:59 rjmcnab200 201 Merged sources.202 203 Revision 1.7 1999/02/21 22:33:55 rjmcnab204 205 Lots of stuff :-)206 207 Revision 1.6 1999/02/11 01:24:05 rjmcnab208 209 Fixed a few compiler warnings.210 211 Revision 1.5 1999/02/08 01:28:02 rjmcnab212 213 Got the receptionist producing something using the statusaction.214 215 Revision 1.4 1999/02/05 10:42:46 rjmcnab216 217 Continued working on receptionist218 219 Revision 1.3 1999/02/04 10:00:56 rjmcnab220 221 Developed the idea of an "action" and having them define the cgi arguments222 which they need and how those cgi arguments function.223 224 Revision 1.2 1999/02/04 01:17:27 rjmcnab225 226 Got it outputing something.227 228 229 */230 231 25 232 26 #include "receptionist.h" … … 239 33 #include <time.h> 240 34 #include <stdio.h> 35 #if defined (GSDL_USE_IOS_H) 241 36 #include <fstream.h> 37 #else 38 #include <fstream> 39 #endif 242 40 243 41 #if defined (__WIN32_) … … 252 50 collectdir.clear(); 253 51 httpprefix.clear(); 254 httpimg .clear();52 httpimg = "/images"; 255 53 gwcgi.clear(); 256 54 macrofiles.erase(macrofiles.begin(), macrofiles.end()); … … 272 70 } 273 71 274 72 void collectioninfo_t::clear () { 73 gsdl_gsdlhome.clear(); 74 gsdl_gdbmhome.clear(); 75 76 info_loaded = false; 77 info.clear(); 78 } 275 79 276 80 receptionist::receptionist () { … … 789 593 utf8outconvertclass text_t2utf8; 790 594 char *lfile = filename.getcstr(); 595 791 596 ofstream log (lfile, ios::app); 792 597 … … 912 717 bool receptionist::produce_content (cgiargsclass &args, ostream &contentout, 913 718 ostream &logout) { 914 719 915 720 // decide on the output conversion class 916 721 text_t &arg_w = args["w"]; … … 1019 824 colinfo_tmap::iterator colend = configinfo.collectinfo.end(); 1020 825 while (colhere != colend) { 1021 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 1022 maindirs.insert (gsdlmacrodir); 826 if (!((*colhere).second.gsdl_gsdlhome).empty()) { 827 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 828 maindirs.insert (gsdlmacrodir); 829 } 1023 830 colhere ++; 1024 831 } … … 1103 910 1104 911 text_t &arg_c = args["c"]; 1105 ColInfoResponse_t cinfo;1106 comerror_t err;1107 912 recptproto *collectproto = protocols.getrecptproto (arg_c, logout); 1108 collectproto->get_collectinfo (arg_c, cinfo, err, logout); 1109 1110 if (!cinfo.ccsCols.empty()) { 1111 args["ccs"] = 1; 1112 if (args["cc"].empty()) { 1113 text_tarray::const_iterator col_here = cinfo.ccsCols.begin(); 1114 text_tarray::const_iterator col_end = cinfo.ccsCols.end(); 1115 bool first = true; 1116 while (col_here != col_end) { 1117 // make sure it's a valid collection 1118 if (protocols.getrecptproto (*col_here, logout) != NULL) { 1119 if (!first) args["cc"].push_back (','); 1120 args["cc"] += *col_here; 1121 first = false; 913 if (collectproto == NULL) { 914 // oops, this collection isn't valid 915 outconvertclass text_t2ascii; 916 logout << text_t2ascii << "ERROR: Invalid collection: " << arg_c << "\n"; 917 args["c"].clear(); 918 919 } else { 920 921 ColInfoResponse_t *cinfo = get_collectinfo_ptr (collectproto, arg_c, logout); 922 923 if (cinfo != NULL) { 924 if (!cinfo->ccsCols.empty()) { 925 args["ccs"] = 1; 926 if (args["cc"].empty()) { 927 text_tarray::const_iterator col_here = cinfo->ccsCols.begin(); 928 text_tarray::const_iterator col_end = cinfo->ccsCols.end(); 929 bool first = true; 930 while (col_here != col_end) { 931 // make sure it's a valid collection 932 if (protocols.getrecptproto (*col_here, logout) != NULL) { 933 if (!first) args["cc"].push_back (','); 934 args["cc"] += *col_here; 935 first = false; 936 } 937 col_here ++; 938 } 1122 939 } 1123 col_here ++;1124 940 } 941 } else { 942 logout << "ERROR (receptionist::check_mainargs): get_collectinfo_ptr returned NULL\n"; 1125 943 } 1126 944 } … … 1245 1063 decode_cgi_arg (compressedoptions); 1246 1064 disp.setmacro ("decodedcompressedoptions", "Global", dm_safe(compressedoptions)); 1065 1066 #if defined (__WIN32__) 1067 disp.setmacro ("win32", "Global", "1"); 1068 #endif 1247 1069 1248 1070 // set macron macros if encoding is utf8 … … 1307 1129 } 1308 1130 } 1131 1132 // gets collection info from cache if found or 1133 // calls collection server (and updates cache) 1134 // returns NULL if there's an error 1135 ColInfoResponse_t *receptionist::get_collectinfo_ptr (recptproto *collectproto, 1136 const text_t &collection, 1137 ostream &logout) { 1138 1139 // check the cache 1140 colinfo_tmap::iterator it = configinfo.collectinfo.find (collection); 1141 if ((it != configinfo.collectinfo.end()) && ((*it).second.info_loaded)) { 1142 // found it 1143 return &((*it).second.info); 1144 } 1145 1146 // not cached, get info from collection server 1147 if (collectproto == NULL) { 1148 logout << "ERROR: receptionist::get_collectinfo_ptr passed null collectproto\n"; 1149 return NULL; 1150 } 1151 1152 comerror_t err; 1153 if (it == configinfo.collectinfo.end()) { 1154 collectioninfo_t cinfo; 1155 collectproto->get_collectinfo (collection, cinfo.info, err, logout); 1156 if (err != noError) { 1157 outconvertclass text_t2ascii; 1158 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1159 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1160 return NULL; 1161 } 1162 cinfo.info_loaded = true; 1163 configinfo.collectinfo[collection] = cinfo; 1164 return &(configinfo.collectinfo[collection].info); 1165 } else { 1166 collectproto->get_collectinfo (collection, (*it).second.info, err, logout); 1167 if (err != noError) { 1168 outconvertclass text_t2ascii; 1169 logout << text_t2ascii << "ERROR (receptionist::getcollectinfo_ptr): \"" 1170 << get_comerror_string (err) << "\"while getting collectinfo\n"; 1171 return NULL; 1172 } 1173 (*it).second.info_loaded = true; 1174 return &((*it).second.info); 1175 } 1176 }
Note:
See TracChangeset
for help on using the changeset viewer.