- Timestamp:
- 1999-12-06T10:21:04+13:00 (24 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/receptionist.cpp
r789 r799 28 28 /* 29 29 $Log$ 30 Revision 1.42 1999/12/05 21:21:04 sjboddie 31 added support for multiple gsdlhomes and gdbmhomes 32 30 33 Revision 1.41 1999/11/25 21:44:16 sjboddie 31 34 fixed bug in logout … … 220 223 void recptconf::clear () { 221 224 gsdlhome.clear(); 225 gdbmhome.clear(); 226 collectinfo.clear(); 222 227 collection.clear(); 223 228 collectdir.clear(); … … 360 365 else if (key == "httpimg") configinfo.httpimg = cfgline[0]; 361 366 else if (key == "gwcgi") configinfo.gwcgi = cfgline[0]; 362 else if (key == "macrofiles") configinfo.macrofiles = cfgline; 367 else if (key == "macrofiles") { 368 // want to append to macrofiles (i.e. may be several config files 369 // contributing, maybe from several collections). 370 text_tarray::const_iterator here = cfgline.begin(); 371 text_tarray::const_iterator end = cfgline.end(); 372 while (here != end) { 373 configinfo.macrofiles.insert (*here); 374 here ++; 375 } 376 } 363 377 else if (key == "saveconf") configinfo.saveconf = cfgline[0]; 364 378 else if (key == "usecookies") configinfo.usecookies = (cfgline[0] == "true"); … … 369 383 } 370 384 else if (key == "macroprecedence") configinfo.macroprecedence = cfgline[0]; 371 385 else if (key == "collectinfo") { 386 if (cfgline.size() >= 3) { 387 collectioninfo_t cinfo; 388 cinfo.gsdl_gsdlhome = cfgline[1]; 389 cinfo.gsdl_gdbmhome = cfgline[2]; 390 configinfo.collectinfo[cfgline[0]] = cinfo; 391 } 392 } 372 393 373 394 else if (key == "cgiarg") { … … 771 792 } 772 793 794 text_t receptionist::expandmacros (const text_t &astring, cgiargsclass &args, 795 ostream &logout) { 796 text_t outstring; 797 outconvertclass text_t2ascii; 798 799 action *a = actions.getaction (args["a"]); 800 prepare_page (a, args, text_t2ascii, logout); 801 disp.expandstring ("Global", astring, outstring); 802 return outstring; 803 } 804 773 805 // produce_cgi_page will call get_cgihead_info and 774 806 // produce_content in the appropriate way to output a cgi header and … … 786 818 if (response == location) { 787 819 // location response (url may contain macros!!) 788 text_t ex_location; 789 action *a = actions.getaction (args["a"]); 790 prepare_page (a, args, text_t2ascii, logout); 791 disp.expandstring ("Global", response_data, ex_location); 792 contentout << text_t2ascii << "Location: " << ex_location << "\n\n"; 820 response_data = expandmacros (response_data, args, logout); 821 contentout << text_t2ascii << "Location: " << response_data << "\n\n"; 793 822 contentout << flush; 794 823 return true; … … 854 883 bool receptionist::produce_content (cgiargsclass &args, ostream &contentout, 855 884 ostream &logout) { 885 856 886 // decide on the output conversion class 857 887 text_t &arg_w = args["w"]; … … 860 890 if (outconverter == NULL) outconverter = &defaultoutconverter; 861 891 outconverter->reset(); 892 862 893 863 894 recptproto *collectproto = protocols.getrecptproto (args["c"], logout); … … 916 947 << "</html>\n"; 917 948 } 918 919 949 return true; 920 950 } … … 951 981 // load up the default macro files, the collection directory 952 982 // is searched first for the file (if this is being used in 953 // collection specific mode) and then the main directory 983 // collection specific mode) and then the main directory(s) 954 984 text_t colmacrodir = filename_cat (configinfo.collectdir, "macros"); 985 986 text_tarray maindirs; 955 987 text_t gsdlmacrodir = filename_cat (configinfo.gsdlhome, "macros"); 956 text_tarray::iterator arrhere = configinfo.macrofiles.begin(); 957 text_tarray::iterator arrend = configinfo.macrofiles.end(); 988 maindirs.push_back (gsdlmacrodir); 989 colinfo_tmap::iterator colhere = configinfo.collectinfo.begin(); 990 colinfo_tmap::iterator colend = configinfo.collectinfo.end(); 991 while (colhere != colend) { 992 gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros"); 993 maindirs.push_back (gsdlmacrodir); 994 colhere ++; 995 } 996 997 text_tset::iterator arrhere = configinfo.macrofiles.begin(); 998 text_tset::iterator arrend = configinfo.macrofiles.end(); 958 999 text_t filename; 959 1000 while (arrhere != arrend) { 960 // filename is used as a flag to indicate whether 961 // the macro file has been found 962 filename.clear(); 1001 bool foundfile = false; 963 1002 964 1003 // try in the collection directory if this is being … … 966 1005 if (!configinfo.collection.empty()) { 967 1006 filename = filename_cat (colmacrodir, *arrhere); 968 if (!file_exists (filename)) filename.clear (); 1007 if (file_exists (filename)) { 1008 disp.loaddefaultmacros(filename); 1009 foundfile = true; 1010 } 969 1011 } 970 1012 971 1013 // if we haven't found the macro file yet try in 972 // the main macro directory 973 if (filename.empty()) { 974 filename = filename_cat (gsdlmacrodir, *arrhere); 975 if (!file_exists (filename)) filename.clear (); 1014 // the main macro directory(s) 1015 // if file is found in more than one main directory 1016 // we'll load all copies 1017 if (!foundfile) { 1018 text_tarray::const_iterator dirhere = maindirs.begin(); 1019 text_tarray::const_iterator dirend = maindirs.end(); 1020 while (dirhere != dirend) { 1021 filename = filename_cat (*dirhere, *arrhere); 1022 if (file_exists (filename)) { 1023 disp.loaddefaultmacros(filename); 1024 foundfile = true; 1025 } 1026 dirhere ++; 1027 } 976 1028 } 977 1029 978 1030 // see if we found the file or not 979 if ( filename.empty()) {1031 if (!foundfile) { 980 1032 logout << text_t2ascii 981 1033 << "Error: the macro file \"" << *arrhere << "\" could not be found.\n"; 982 1034 if (configinfo.collection.empty()) { 983 logout << text_t2ascii 984 << "It should be in " << gsdlmacrodir << ".\n\n"; 1035 text_t dirs; 1036 joinchar (maindirs, ", ", dirs); 1037 logout << text_t2ascii 1038 << "It should be in either of the following directories (" 1039 << dirs << ").\n\n"; 1040 985 1041 } else { 986 1042 logout << text_t2ascii … … 991 1047 disp.setlogout (savedlogout); 992 1048 return false; 993 994 } else { // found the file 995 disp.loaddefaultmacros(filename); 996 } 997 1049 } 998 1050 arrhere++; 999 1051 } … … 1010 1062 // error is found it will return false and no cgi page should 1011 1063 // be created using the arguments. 1012 bool receptionist::check_mainargs (cgiargsclass &args, ostream & /*logout*/) {1064 bool receptionist::check_mainargs (cgiargsclass &args, ostream &logout) { 1013 1065 // if this receptionist is running in collection dependant mode 1014 1066 // then it should always set the collection argument to the 1015 1067 // collection 1016 1068 if (!configinfo.collection.empty()) args["c"] = configinfo.collection; 1069 1070 // if cross-collection is turned on make "cc" default to 1071 // all available collections and "c" default to any 1072 // valid collection 1073 if (args["ccs"] == "1") { 1074 if (args["cc"].empty()) { 1075 recptprotolistclass::iterator rprotolist_here = protocols.begin(); 1076 recptprotolistclass::iterator rprotolist_end = protocols.end(); 1077 bool first = true; 1078 while (rprotolist_here != rprotolist_end) { 1079 if ((*rprotolist_here).p != NULL) { 1080 text_tarray collist; 1081 comerror_t err; 1082 (*rprotolist_here).p->get_collection_list (collist, err, logout); 1083 if (err == noError) { 1084 text_tarray::iterator collist_here = collist.begin(); 1085 text_tarray::iterator collist_end = collist.end(); 1086 while (collist_here != collist_end) { 1087 if (!first) args["cc"].push_back (','); 1088 else if (args["c"].empty()) args["c"] = *collist_here; 1089 args["cc"] += *collist_here; 1090 first = false; 1091 collist_here ++; 1092 } 1093 } 1094 } 1095 rprotolist_here ++; 1096 } 1097 } else if (args["c"].empty()) { 1098 text_t argcc = args["cc"]; 1099 decode_cgi_arg (argcc); 1100 text_t::const_iterator it = argcc.begin(); 1101 args["c"] = substr (it, findchar (it, argcc.end(), ',')); 1102 } 1103 } 1017 1104 1018 1105 // argument "v" can only be 0 or 1. Use the default value -
trunk/gsdl/src/recpt/receptionist.h
r760 r799 38 38 #include "recptproto.h" 39 39 #include "converter.h" 40 #include "cfgread.h" 40 41 41 42 // the MACROPRECEDENCE macro is used as a default. override … … 52 53 struct recptconf { 53 54 text_t gsdlhome; 55 text_t gdbmhome; // will equal gsdlhome if not set 54 56 text_t collection; // will equal "" in 'general' mode 55 57 text_t collectdir; // will equal gsdlhome in 'general' mode 58 colinfo_tmap collectinfo; 56 59 text_t httpprefix; 57 60 text_t httpimg; 58 61 text_t gwcgi; 59 text_t arraymacrofiles;62 text_tset macrofiles; 60 63 text_t saveconf; 61 64 bool usecookies; // true if we want cookies set … … 166 169 virtual bool log_cgi_args (cgiargsclass &args, ostream &logout); 167 170 171 text_t expandmacros (const text_t &astring, cgiargsclass &args, 172 ostream &logout); 173 168 174 // produce_cgi_page will call get_cgihead_info and 169 175 // produce_content in the appropriate way to output a cgi header and
Note:
See TracChangeset
for help on using the changeset viewer.