Changeset 165 for trunk/gsdl/src/recpt
- Timestamp:
- 1999-02-22T11:33:58+13:00 (25 years ago)
- Location:
- trunk/gsdl/src/recpt
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/recpt/Makefile
r160 r165 34 34 $(COMPILE) $< 35 35 36 37 HEADERS = receptionist.h cgiwrapper.h cgiargs.h action.h \ 38 converter.h recptconfig.h cgiutils.h htmlgen.h statusaction.h pageaction.h 39 40 SOURCES = receptionist.cpp cgiwrapper.cpp cgiargs.cpp recptmain.cpp action.cpp \ 41 converter.cpp recptconfig.cpp cgiutils.cpp htmlgen.cpp statusaction.cpp pageaction.cpp 42 43 OBJECTS = receptionist.o cgiwrapper.o cgiargs.o recptmain.o action.o \ 44 converter.o recptconfig.o cgiutils.o htmlgen.o statusaction.o pageaction.o 45 46 EXEC = recpt 47 48 all : $(EXEC) 36 COMMONHEADERS = receptionist.h cgiwrapper.h cgiargs.h action.h \ 37 converter.h recptconfig.h cgiutils.h htmlgen.h statusaction.h \ 38 pageaction.h comtypes.h recptproto.h pingaction.h 39 40 RECEPTHEADERS = 41 42 COLSERVRHEADERS = gdbmclass.h mgq.h mgsearch.h querycache.h queryinfo.h \ 43 collectserver.h colservrconfig.h 44 45 LIBRARYHEADERS = $(COLSERVRHEADERS) \ 46 nullproto.h 47 48 HEADERS = $(COMMONHEADERS) $(RECPTHEADERS) $(LIBRARYHEADERS) 49 50 51 COMMONSOURCES = receptionist.cpp cgiwrapper.cpp cgiargs.cpp action.cpp \ 52 converter.cpp recptconfig.cpp cgiutils.cpp htmlgen.cpp \ 53 statusaction.cpp pageaction.cpp comtypes.cpp recptproto.cpp \ 54 pingaction.cpp 55 56 RECPTSOURCES = recptmain.cpp 57 58 COLSERVRSOURCES = gdbmclass.cpp mgq.c mgsearch.cpp querycache.cpp queryinfo.cpp \ 59 collectserver.cpp colservrconfig.cpp 60 61 LIBRARYSOURCES = $(COLSERVRSOURCES) \ 62 nullproto.cpp librarymain.cpp 63 64 SOURCES = $(COMMONSOURCES) $(RECPTSOURCES) $(LIBRARYSOURCES) 65 66 67 COMMONOBJECTS = receptionist.o cgiwrapper.o cgiargs.o action.o \ 68 converter.o recptconfig.o cgiutils.o htmlgen.o statusaction.o \ 69 pageaction.o comtypes.o recptproto.o pingaction.o 70 71 RECPTOBJECTS = recptmain.o 72 73 COLSERVROBJECTS = gdbmclass.o mgq.o mgsearch.o querycache.o queryinfo.o \ 74 collectserver.o colservrconfig.o 75 76 LIBRARYOBJECTS = $(COLSERVROBJECTS) \ 77 nullproto.o librarymain.o 78 79 OBJECTS = $(COMMONOBJECTS) $(RECPTOBJECTS) $(LIBRARYOBJECTS) 80 81 82 EXEC = recpt library 83 84 all: $(COLSERVRHEADERS) $(COLSERVRSOURCES) $(EXEC) 85 86 $(COLSERVRHEADERS) $(COLSERVRSOURCES): 87 ln -s ../colservr/$@ 49 88 50 89 clean: 51 rm -f $( OBJECTS)90 rm -f $(COLSERVRHEADERS) $(COLSERVRSOURCES) $(OBJECTS) $(EXEC) 52 91 53 92 install: … … 58 97 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 59 98 60 RECPT_OBJS = $( OBJECTS) \99 RECPT_OBJS = $(COMMONOBJECTS) $(RECPTOBJECTS) \ 61 100 ../../lib/gsdllib.a \ 62 101 ../../packages/mg-1.3d/src/text/libtextin.a \ … … 67 106 $(LINK) $(RECPT_OBJS) $(LIBS) 68 107 108 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 109 110 LIBRARY_OBJS = $(COMMONOBJECTS) $(LIBRARYOBJECTS) \ 111 ../../lib/gsdllib.a \ 112 ../../packages/mg-1.3d/src/text/libtextin.a \ 113 ../../packages/mg-1.3d/lib/libmg.a \ 114 ../../packages/fcgi/libfcgi/libfcgi.a 115 116 library: $(LIBRARY_OBJS) 117 $(LINK) $(LIBRARY_OBJS) $(LIBS) 118 119 69 120 # DO NOT DELETE 70 121 71 122 receptionist.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h 72 123 receptionist.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h 124 receptionist.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h 73 125 receptionist.o: ../../lib/fileutil.h cgiutils.h 74 126 cgiwrapper.o: ../../lib/gsdlconf.h ../../lib/site.h cgiwrapper.h 75 127 cgiwrapper.o: receptionist.h ../../lib/text_t.h cgiargs.h ../../lib/display.h 76 cgiwrapper.o: action.h recptconfig.h statusaction.h pageaction.h 77 cgiwrapper.o: ../../packages/fcgi/include/fcgiapp.h 128 cgiwrapper.o: action.h recptproto.h comtypes.h converter.h 129 cgiwrapper.o: ../../lib/gsdlunicode.h recptconfig.h statusaction.h 130 cgiwrapper.o: pageaction.h pingaction.h ../../packages/fcgi/include/fcgiapp.h 78 131 cgiwrapper.o: ../../packages/fcgi/include/fcgi_config.h 79 132 cgiargs.o: cgiargs.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h 80 133 cgiargs.o: ../../lib/gsdlunicode.h 81 recptmain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h82 recptmain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h83 recptmain.o: cgiwrapper.h84 134 action.o: action.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h 85 action.o: cgiargs.h ../../lib/display.h 135 action.o: cgiargs.h ../../lib/display.h recptproto.h comtypes.h 86 136 converter.o: converter.h ../../lib/gsdlconf.h ../../lib/site.h 87 137 converter.o: ../../lib/text_t.h ../../lib/gsdlunicode.h 88 138 recptconfig.o: recptconfig.h ../../lib/gsdlconf.h ../../lib/site.h 89 139 recptconfig.o: ../../lib/text_t.h receptionist.h cgiargs.h 90 recptconfig.o: ../../lib/display.h action.h ../../lib/fileutil.h 140 recptconfig.o: ../../lib/display.h action.h recptproto.h comtypes.h 141 recptconfig.o: converter.h ../../lib/gsdlunicode.h ../../lib/fileutil.h 91 142 recptconfig.o: ../../lib/cfgread.h 92 143 cgiutils.o: cgiutils.h ../../lib/gsdlconf.h ../../lib/site.h … … 95 146 htmlgen.o: ../../lib/display.h ../../packages/mg-1.3d/lib/unitool.h 96 147 statusaction.o: statusaction.h ../../lib/gsdlconf.h ../../lib/site.h action.h 97 statusaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h 98 statusaction.o: receptionist.h148 statusaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h 149 statusaction.o: comtypes.h receptionist.h converter.h ../../lib/gsdlunicode.h 99 150 pageaction.o: pageaction.h ../../lib/gsdlconf.h ../../lib/site.h action.h 100 pageaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h 101 pageaction.o: receptionist.h 151 pageaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h 152 pageaction.o: comtypes.h 153 comtypes.o: comtypes.h ../../lib/gsdlconf.h ../../lib/site.h 154 comtypes.o: ../../lib/text_t.h 155 recptproto.o: recptproto.h ../../lib/gsdlconf.h ../../lib/site.h 156 recptproto.o: ../../lib/text_t.h comtypes.h 157 pingaction.o: pingaction.h ../../lib/gsdlconf.h ../../lib/site.h action.h 158 pingaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h 159 pingaction.o: comtypes.h 160 recptmain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h 161 recptmain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h 162 recptmain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h 163 recptmain.o: cgiwrapper.h 164 gdbmclass.o: ../../lib/text_t.h ../../lib/gsdlconf.h ../../lib/site.h 165 gdbmclass.o: gdbmclass.h ../../packages/mg-1.3d/lib/unitool.h 166 gdbmclass.o: ../../lib/gsdlunicode.h ../../lib/fileutil.h 167 mgq.o: mgq.h ../../packages/mg-1.3d/sysfuncs.h 168 mgq.o: ../../packages/mg-1.3d/lib/pathmax.h 169 mgq.o: ../../packages/mg-1.3d/lib/getopt.h 170 mgq.o: ../../packages/mg-1.3d/lib/messages.h 171 mgq.o: ../../packages/mg-1.3d/lib/memlib.h 172 mgq.o: ../../packages/mg-1.3d/src/text/invf.h 173 mgq.o: ../../packages/mg-1.3d/src/text/text.h 174 mgq.o: ../../packages/mg-1.3d/lib/huffman.h 175 mgq.o: ../../packages/mg-1.3d/lib/filestats.h 176 mgq.o: ../../packages/mg-1.3d/src/text/lists.h 177 mgq.o: ../../packages/mg-1.3d/src/text/backend.h 178 mgq.o: ../../packages/mg-1.3d/lib/timing.h 179 mgq.o: ../../packages/mg-1.3d/src/text/term_lists.h 180 mgq.o: ../../packages/mg-1.3d/src/text/query_term_list.h 181 mgq.o: ../../packages/mg-1.3d/src/text/mg.h 182 mgq.o: ../../packages/mg-1.3d/src/text/environment.h 183 mgq.o: ../../packages/mg-1.3d/src/text/globals.h 184 mgq.o: ../../packages/mg-1.3d/src/text/mg_errors.h 185 mgq.o: ../../packages/mg-1.3d/src/text/commands.h 186 mgq.o: ../../packages/mg-1.3d/src/text/text_get.h 187 mgq.o: ../../packages/mg-1.3d/lib/local_strings.h 188 mgsearch.o: ../../lib/gsdlconf.h ../../lib/site.h mgsearch.h 189 mgsearch.o: ../../lib/text_t.h querycache.h queryinfo.h ../../lib/fileutil.h 190 mgsearch.o: mgq.h ../../lib/gsdlunicode.h 191 mgsearch.o: ../../packages/mg-1.3d/lib/unitool.h 192 querycache.o: querycache.h ../../lib/text_t.h ../../lib/gsdlconf.h 193 querycache.o: ../../lib/site.h queryinfo.h 194 queryinfo.o: queryinfo.h ../../lib/gsdlconf.h ../../lib/site.h 195 queryinfo.o: ../../lib/text_t.h 196 collectserver.o: collectserver.h ../../lib/gsdlconf.h ../../lib/site.h 197 collectserver.o: ../../lib/text_t.h comtypes.h 198 nullproto.o: nullproto.h ../../lib/gsdlconf.h ../../lib/site.h 199 nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h recptproto.h 200 librarymain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h 201 librarymain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h 202 librarymain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h 203 librarymain.o: cgiwrapper.h nullproto.h collectserver.h -
trunk/gsdl/src/recpt/action.cpp
r158 r165 12 12 /* 13 13 $Log$ 14 Revision 1.6 1999/02/21 22:33:52 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.5 1999/02/11 01:24:04 rjmcnab 15 19 … … 56 60 } 57 61 62 // configure should be called once for each configuration line 63 // the default version configures the default for any arguments 64 // which this action uses 65 void action::configure (const text_t &key, const text_tarray &cfgline) { 66 cgiarginfo *info = NULL; 67 if ((key == "argdefault") && (cfgline.size() == 2) && 68 ((info = argsinfo.getarginfo(cfgline[0])) != NULL)) { 69 if (info->defaultstatus <= cgiarginfo::config) { 70 info->defaultstatus = cgiarginfo::config; 71 info->argdefault = cfgline[1]; 72 } 73 } 74 } 75 76 // init should be called after all the configuration is done but 77 // before any other methods are called 78 bool action::init (ostream &/*logout*/) { 79 return true; 80 } 81 58 82 // returns the "a" argument value that will specify this action 59 83 // this name should be short but does not have to be one character … … 92 116 // from outputing anything. 93 117 bool action::do_action (cgiargsclass &/*args*/, outconvertclass &/*outconvert*/, 94 ostream &/*textout*/, ostream &/*logout*/) { 118 recptproto */*collectproto*/, ostream &/*textout*/, 119 ostream &/*logout*/) { 95 120 return true; 96 }97 98 // configure should be called once for each configuration line99 // the default version configures the default for any arguments100 // which this action uses101 void action::configure (const text_t &key, const text_tarray &cfgline) {102 cgiarginfo *info = NULL;103 if ((key == "argdefault") && (cfgline.size() == 2) &&104 ((info = argsinfo.getarginfo(cfgline[0])) != NULL)) {105 if (info->defaultstatus <= cgiarginfo::config) {106 info->defaultstatus = cgiarginfo::config;107 info->argdefault = cfgline[1];108 }109 }110 121 } 111 122 112 123 113 124 114 actionmapclass::actionmapclass () { 115 } 116 117 // theaction becomes the property of this class after addaction 118 // therefore theaction should always be created using new but 119 // not deleted after the call to addaction. 125 // theaction remains the property of the calling code but 126 // should not be deleted until it is removed from this list. 120 127 void actionmapclass::addaction (action *theaction) { 121 128 // can't add a null action … … 130 137 aptr.a = theaction; 131 138 actionptrs[theaction->get_action_name()] = aptr; 132 aptr.a = NULL; // control has passed on133 139 } 134 140 135 141 // getaction will return NULL if the action could not be found 136 142 action *actionmapclass::getaction (const text_t &key) { 143 // can't find an action with no name 144 assert (!key.empty()); 145 if (key.empty()) return NULL; 146 137 147 iterator here = actionptrs.find (key); 138 148 if (here == actionptrs.end()) return NULL; -
trunk/gsdl/src/recpt/action.h
r155 r165 18 18 #include "cgiargs.h" 19 19 #include "display.h" 20 #include "recptproto.h" 20 21 21 22 #if defined(GSDL_USE_OBJECTSPACE) … … 40 41 action (); 41 42 virtual ~action (); 43 44 // configure should be called once for each configuration line 45 virtual void configure (const text_t &key, const text_tarray &cfgline); 46 47 // init should be called after all the configuration is done but 48 // before any other methods are called 49 virtual bool init (ostream &logout); 42 50 43 51 // returns the "a" argument value that will specify this action … … 69 77 // from outputing anything. 70 78 virtual bool do_action (cgiargsclass &args, outconvertclass &outconvert, 71 ostream &textout, ostream &logout); 72 73 // configure should be called once for each configuration line 74 virtual void configure (const text_t &key, const text_tarray &cfgline); 75 79 recptproto *collectproto, ostream &textout, 80 ostream &logout); 81 76 82 // getargsinfo should be called after all configuration files 77 83 // have been read … … 80 86 81 87 82 // actionptr is used to keep track of pointers to actions 83 // sub classes of action might not be the same size so 84 // you probably don't want to treat a sub class as a standard 85 // "action" class when it comes to copying etc -- anyone got 86 // a better way to do this ???? 88 // The actionptr function does not 'own' the action. The 89 // action should be deleted by the code which created it. 87 90 class actionptr { 88 91 public: … … 90 93 91 94 actionptr () {a=NULL;} 92 ~actionptr () {if (a!=NULL) delete a; a=NULL;}93 95 }; 94 96 … … 112 114 typedef actionptrmap::reverse_iterator reverse_iterator; 113 115 114 // constructors115 actionmapclass ();116 117 116 // basic container support 118 117 iterator begin () {return actionptrs.begin();} … … 132 131 void clear () {actionptrs.erase(actionptrs.begin(),actionptrs.end());} 133 132 134 // theaction becomes the property of this class after addaction 135 // therefore theaction should always be created using new but 136 // not deleted after the call to addaction. 133 // theaction remains the property of the calling code but 134 // should not be deleted until it is removed from this list. 137 135 void addaction (action *theaction); 138 136 -
trunk/gsdl/src/recpt/cgiwrapper.cpp
r160 r165 12 12 /* 13 13 $Log$ 14 Revision 1.7 1999/02/21 22:33:53 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.6 1999/02/12 02:40:17 sjboddie 15 19 … … 54 58 #include "statusaction.h" 55 59 #include "pageaction.h" 60 #include "pingaction.h" 56 61 #include <stdlib.h> 57 62 … … 317 322 outconvertclass text_t2ascii; 318 323 319 // the list of actions 320 statusaction *astatusaction = new statusaction; 321 if (astatusaction != NULL) { 322 astatusaction->set_receptionist (&recpt); 323 recpt.add_action (astatusaction); 324 } 325 326 pageaction *apageaction = new pageaction; 327 if (apageaction != NULL) { 328 apageaction->set_receptionist (&recpt); 329 recpt.add_action (apageaction); 330 } 324 // the list of actions. Note: these actions will become invalid 325 // at the end of this function. 326 statusaction astatusaction; 327 astatusaction.set_receptionist (&recpt); 328 recpt.add_action (&astatusaction); 329 330 pageaction apageaction; 331 recpt.add_action (&apageaction); 332 333 pingaction apingaction; 334 recpt.add_action (&apingaction); 331 335 332 336 333 337 // set defaults 334 338 int maxrequests = 10000; 335 if (collection.empty()) recpt.set_gsdlhome(GSDL_GSDLHOME);336 else recpt.set_gsdlhome(GSDL_GSDLHOME, collection);337 recpt. set_httpimg("/gsdl/images");339 recpt.configure ("gsdlhome", GSDL_GSDLHOME); 340 recpt.configure ("collection", collection); 341 recpt.configure ("httpimg", "/gsdl/images"); 338 342 char *script_name = getenv("SCRIPT_NAME"); 339 if (script_name != NULL) recpt. set_gwcgi(script_name);340 else recpt. set_gwcgi("/cgi-bin/gw");343 if (script_name != NULL) recpt.configure("gwcgi", script_name); 344 else recpt.configure("gwcgi", "/cgi-bin/gw"); 341 345 342 346 // read in the configuration files. -
trunk/gsdl/src/recpt/pageaction.cpp
r160 r165 12 12 /* 13 13 $Log$ 14 Revision 1.2 1999/02/21 22:33:54 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.1 1999/02/12 02:40:17 sjboddie 15 19 … … 23 27 24 28 pageaction::pageaction () { 25 disabled = true;26 recpt = NULL;27 28 29 // this action uses cgi variables "a" and "p" 29 30 cgiarginfo arg_ainfo; … … 32 33 arg_ainfo.multiplechar = true; 33 34 arg_ainfo.defaultstatus = cgiarginfo::weak; 34 arg_ainfo.argdefault = " status";35 arg_ainfo.argdefault = "p"; 35 36 arg_ainfo.savedarginfo = cgiarginfo::must; 36 37 argsinfo.addarginfo (NULL, arg_ainfo); … … 61 62 62 63 bool pageaction::do_action (cgiargsclass &args, outconvertclass &outconvert, 63 ostream &textout, ostream &logout) { 64 recptproto */*collectproto*/, ostream &textout, 65 ostream &/*logout*/) { 64 66 65 67 textout << outconvert << "<html>\n"; … … 72 74 return true; 73 75 } 74 75 void pageaction::configure (const text_t &key, const text_tarray &cfgline) {76 if ((key == "page") && (cfgline.size() == 1) &&77 (cfgline[0] == "true" || cfgline[0] == "on" || cfgline[0] == "enabled")) {78 disabled = false;79 } else {80 // call the parent class to deal with the things which81 // are not dealt with here82 action::configure (key, cfgline);83 }84 } -
trunk/gsdl/src/recpt/pageaction.h
r160 r165 17 17 #include "gsdlconf.h" 18 18 #include "action.h" 19 #include "receptionist.h"20 19 21 20 22 21 class pageaction : public action { 23 protected:24 bool disabled;25 receptionist *recpt;26 27 22 public: 28 23 pageaction (); … … 30 25 31 26 text_t get_action_name () {return "p";} 32 void set_receptionist (receptionist *therecpt) {recpt=therecpt;}33 27 bool check_cgiargs (cgiargsclass &args, ostream &logout); 34 28 void get_cgihead_info (cgiargsclass &args, response_t &response, 35 29 text_t &response_data, ostream &logout); 36 30 bool do_action (cgiargsclass &args, outconvertclass &outconvert, 37 ostream &textout, ostream &logout);38 void configure (const text_t &key, const text_tarray &cfgline);31 recptproto *collectproto, ostream &textout, 32 ostream &logout); 39 33 }; 40 34 -
trunk/gsdl/src/recpt/receptionist.cpp
r158 r165 12 12 /* 13 13 $Log$ 14 Revision 1.7 1999/02/21 22:33:55 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.6 1999/02/11 01:24:05 rjmcnab 15 19 … … 44 48 45 49 46 // this version of set_gsdlhome should be used if the receptionist 47 // is being run for multiple collections ("general" mode). 48 void receptionist::set_gsdlhome (const text_t &thegsdlhome) { 49 gsdlhome = thegsdlhome; 50 collectdir = thegsdlhome; 51 collection = ""; 52 } 53 54 55 // this version of set_gsdlhome should be used if the receptionist 56 // is being run for a single collection ("collection specific" mode). 57 void receptionist::set_gsdlhome (const text_t &thegsdlhome, const text_t &thecollection) { 58 gsdlhome = thegsdlhome; 59 collection = thecollection; 60 61 // decide where collectdir is by searching for collect.cfg 62 // look in $GSDLHOME/collect/collection-name/etc/collect.cfg and 63 // then $GSDLHOME/etc/collect.cfg 64 collectdir = filename_cat (gsdlhome, "collect"); 65 collectdir = filename_cat (collectdir, collection); 66 text_t filename = filename_cat (collectdir, "etc"); 67 filename = filename_cat (filename, "collect.cfg"); 68 69 if (!file_exists(filename)) collectdir = gsdlhome; 70 } 71 72 // configure_actions should be called for each line in the 73 // configuration files to configure the actions. The configuration 74 // should take place after all the actions have been added. 75 void receptionist::configure_actions (const text_t &key, const text_tarray &cfgline) { 76 actionptrmap::iterator here = actions.begin (); 77 actionptrmap::iterator end = actions.end (); 78 79 while (here != end) { 80 assert ((*here).second.a != NULL); 81 if ((*here).second.a != NULL) 82 (*here).second.a->configure(key, cfgline); 83 84 here++; 85 } 86 } 87 88 // init should be called after setgsdhome has been called. 50 51 // configure should be called for each line in the 52 // configuration files to configure the receptionist and everything 53 // it contains. The configuration should take place after everything 54 // has been added but before the initialisation. 55 void receptionist::configure (const text_t &key, const text_tarray &cfgline) { 56 // configure the receptionist 57 if (cfgline.size() >= 1) { 58 if (key == "gsdlhome") configinfo.gsdlhome = cfgline[0]; 59 else if (key == "collection") configinfo.collection = cfgline[0]; 60 else if (key == "collectdir") configinfo.collectdir = cfgline[0]; 61 else if (key == "httpimg") configinfo.httpimg = cfgline[0]; 62 else if (key == "gwcgi") configinfo.gwcgi = cfgline[0]; 63 else if (key == "macrofiles") configinfo.macrofiles = cfgline; 64 else if (key == "saveconf") configinfo.saveconf = cfgline[0]; 65 } 66 67 // configure the actions 68 actionptrmap::iterator actionhere = actions.begin (); 69 actionptrmap::iterator actionend = actions.end (); 70 71 while (actionhere != actionend) { 72 assert ((*actionhere).second.a != NULL); 73 if ((*actionhere).second.a != NULL) 74 (*actionhere).second.a->configure(key, cfgline); 75 76 actionhere++; 77 } 78 79 // configure the protocols 80 recptprotolistclass::iterator protohere = protocols.begin (); 81 recptprotolistclass::iterator protoend = protocols.end (); 82 83 while (protohere != protoend) { 84 assert ((*protohere).p != NULL); 85 if ((*protohere).p != NULL) 86 (*protohere).p->configure(key, cfgline); 87 88 protohere++; 89 } 90 } 91 92 void receptionist::configure (const text_t &key, const text_t &value) { 93 text_tarray cfgline; 94 cfgline.push_back (value); 95 configure(key, cfgline); 96 } 97 98 99 // init should be called after all the actions, protocols, and 100 // converters have been added to the receptionist and after everything 101 // has been configured but before any pages are created. 89 102 // It returns true on success and false on failure. If false is 90 103 // returned getpage should not be called (without producing … … 92 105 // produced by the calling code. 93 106 bool receptionist::init (ostream &logout) { 107 // first configure collectdir 108 text_t thecollectdir = configinfo.gsdlhome; 109 if (!configinfo.collection.empty()) { 110 // collection specific mode 111 if (!configinfo.collectdir.empty()) { 112 // has already been configured 113 thecollectdir = configinfo.collectdir; 114 } else { 115 // decide where collectdir is by searching for collect.cfg 116 // look in $GSDLHOME/collect/collection-name/etc/collect.cfg and 117 // then $GSDLHOME/etc/collect.cfg 118 text_t thecollectdir = filename_cat (configinfo.gsdlhome, "collect"); 119 thecollectdir = filename_cat (thecollectdir, configinfo.collection); 120 text_t filename = filename_cat (thecollectdir, "etc"); 121 filename = filename_cat (filename, "collect.cfg"); 122 if (!file_exists(filename)) thecollectdir = configinfo.gsdlhome; 123 } 124 } 125 configure("collectdir", thecollectdir); 126 94 127 // read in the macro files 95 128 if (!read_macrofiles (logout)) return false; … … 97 130 // defined the main cgi arguments 98 131 if (!define_mainargs (logout)) return false; 132 133 // there must be at least one action defined 134 if (actions.empty()) { 135 logout << "Error: no actions have been added to the receptionist\n"; 136 return false; 137 } 99 138 100 139 // add the cgi arguments from the actions … … 111 150 112 151 // create a saveconf string if there isn't one already 113 if ( saveconf.empty())114 saveconf = create_save_conf_str (argsinfo, logout);152 if (configinfo.saveconf.empty()) 153 configinfo.saveconf = create_save_conf_str (argsinfo, logout); 115 154 116 155 // check the saveconf string 117 if (!check_save_conf_str ( saveconf, argsinfo, logout))156 if (!check_save_conf_str (configinfo.saveconf, argsinfo, logout)) 118 157 return false; 119 158 … … 121 160 srand (time(NULL)); 122 161 123 // utf8outconvert.set_rzws(1); 124 // gboutconvert.set_rzws(1); 162 // make the output converters remove all the zero-width spaces 163 convertinfoclass::iterator converthere = converters.begin (); 164 convertinfoclass::iterator convertend = converters.end (); 165 text_t defaultconvertname; 166 while (converthere != convertend) { 167 assert ((*converthere).second.outconverter != NULL); 168 if ((*converthere).second.outconverter != NULL) { 169 (*converthere).second.outconverter->set_rzws(1); 170 if (defaultconvertname.empty()) 171 defaultconvertname = (*converthere).second.name; 172 } 173 converthere++; 174 } 175 176 // set default converter if no good one has been defined 177 if (!defaultconvertname.empty()) { 178 cgiarginfo *ainfo = argsinfo.getarginfo ("w"); 179 if ((ainfo != NULL) && (ainfo->defaultstatus < cgiarginfo::good)) { 180 ainfo->defaultstatus = cgiarginfo::good; 181 ainfo->argdefault = defaultconvertname; 182 } 183 } 184 185 // init the actions 186 actionptrmap::iterator actionhere = actions.begin (); 187 actionptrmap::iterator actionend = actions.end (); 188 while (actionhere != actionend) { 189 if (((*actionhere).second.a == NULL) || 190 !(*actionhere).second.a->init(logout)) return false; 191 actionhere++; 192 } 193 194 // init the protocols 195 recptprotolistclass::iterator protohere = protocols.begin (); 196 recptprotolistclass::iterator protoend = protocols.end (); 197 while (protohere != protoend) { 198 if (((*protohere).p == NULL) || 199 !(*protohere).p->init(logout)) return false; 200 protohere++; 201 } 125 202 126 203 return true; … … 140 217 141 218 // expand the compressed argument (if there was one) 142 if (!expand_save_args (argsinfo, saveconf, args, logout)) return false;219 if (!expand_save_args (argsinfo, configinfo.saveconf, args, logout)) return false; 143 220 144 221 // add the defaults … … 158 235 return false; 159 236 } 237 238 // get the input encoding 239 text_t &arg_w = args["w"]; 240 inconvertclass defaultinconvert; 241 inconvertclass *inconvert = converters.get_inconverter (arg_w); 242 if (inconvert == NULL) inconvert = &defaultinconvert; 243 244 // see if the next page will have a different encoding 245 if (args.getarg("nw") != NULL) args["w"] = args["nw"]; 246 247 // convert arguments which aren't in unicode to unicode 248 args_tounicode (args, *inconvert); 160 249 161 250 return true; … … 224 313 bool receptionist::produce_content (cgiargsclass &args, ostream &contentout, 225 314 ostream &logout) { 226 outconvertclass text_t2ascii;227 228 315 // decide on the output conversion class 316 text_t &arg_w = args["w"]; 317 rzwsoutconvertclass defaultoutconverter; 318 rzwsoutconvertclass *outconverter = converters.get_outconverter (arg_w); 319 if (outconverter == NULL) outconverter = &defaultoutconverter; 320 outconverter->reset(); 321 322 // decide on the protocol used for communicating with 323 // the collection server 324 recptproto *collectproto = NULL; 325 if (!args["c"].empty()) { 326 collectproto = protocols.getrecptproto (args["c"], logout); 327 } 229 328 230 329 // produce the page using the desired action 231 330 action *a = actions.getaction (args["a"]); 232 331 if (a != NULL) { 233 if (!a->do_action (args, text_t2ascii, contentout, logout))332 if (!a->do_action (args, (*outconverter), collectproto, contentout, logout)) 234 333 return false; 235 334 236 335 } else { 237 336 // the action was not found!! 337 outconvertclass text_t2ascii; 338 238 339 logout << text_t2ascii << "Error receptionist::produce_content: the action \"" 239 340 << args["a"] << "\" could not be found.\n"; 240 341 241 contentout << text_t2ascii << "<html>\n"; 242 contentout << text_t2ascii << "<head>\n"; 243 contentout << text_t2ascii << "<title>Error</title>\n"; 244 contentout << text_t2ascii << "</head>\n"; 245 contentout << text_t2ascii << "<body>\n"; 246 contentout << text_t2ascii << "<h2>Oops!</h2>\n"; 247 contentout << text_t2ascii << "Undefined Page. The action \"" 248 << args["a"] << "\" could not be found.\n"; 249 contentout << text_t2ascii << "</body>\n"; 250 contentout << text_t2ascii << "</html>\n"; 342 contentout << (*outconverter) 343 << "<html>\n" 344 << "<head>\n" 345 << "<title>Error</title>\n" 346 << "</head>\n" 347 << "<body>\n" 348 << "<h2>Oops!</h2>\n" 349 << "Undefined Page. The action \"" 350 << args["a"] << "\" could not be found.\n" 351 << "</body>\n" 352 << "</html>\n"; 251 353 } 252 354 … … 274 376 // is searched first for the file (if this is being used in 275 377 // collection specific mode) and then the main directory 276 text_t colmacrodir = filename_cat (co llectdir, "macros");277 text_t gsdlmacrodir = filename_cat ( gsdlhome, "macros");278 text_tarray::iterator arrhere = macrofiles.begin();279 text_tarray::iterator arrend = macrofiles.end();378 text_t colmacrodir = filename_cat (configinfo.collectdir, "macros"); 379 text_t gsdlmacrodir = filename_cat (configinfo.gsdlhome, "macros"); 380 text_tarray::iterator arrhere = configinfo.macrofiles.begin(); 381 text_tarray::iterator arrend = configinfo.macrofiles.end(); 280 382 text_t filename; 281 383 while (arrhere != arrend) { … … 286 388 // try in the collection directory if this is being 287 389 // run in collection specific mode 288 if (!co llection.empty()) {390 if (!configinfo.collection.empty()) { 289 391 filename = filename_cat (colmacrodir, *arrhere); 290 392 if (!file_exists (filename)) filename.clear (); … … 302 404 logout << text_t2ascii 303 405 << "Error: the macro file \"" << *arrhere << "\" could not be found.\n"; 304 if (co llection.empty()) {406 if (configinfo.collection.empty()) { 305 407 logout << text_t2ascii 306 408 << "It should be in " << gsdlmacrodir << ".\n\n"; … … 367 469 ainfo.longname = "collection"; 368 470 ainfo.multiplechar = true; 369 if (co llection.empty()) {471 if (configinfo.collection.empty()) { 370 472 ainfo.defaultstatus = cgiarginfo::none; 371 473 ainfo.argdefault = ""; … … 373 475 } else { 374 476 ainfo.defaultstatus = cgiarginfo::good; 375 ainfo.argdefault = co llection;477 ainfo.argdefault = configinfo.collection; 376 478 ainfo.savedarginfo = cgiarginfo::can; 377 479 } … … 417 519 // then it should always set the collection argument to the 418 520 // collection 419 if (!co llection.empty()) args["c"] =collection;521 if (!configinfo.collection.empty()) args["c"] = configinfo.collection; 420 522 421 523 // argument "v" can only be 0 or 1. Use the default value -
trunk/gsdl/src/recpt/receptionist.h
r159 r165 19 19 #include "display.h" 20 20 #include "action.h" 21 #include "recptproto.h" 22 #include "converter.h" 21 23 22 24 #ifndef MACROPRECEDENCE … … 25 27 26 28 29 struct recptconf { 30 text_t gsdlhome; 31 text_t collection; // will equal "" in 'general' mode 32 text_t collectdir; // will equal gsdlhome in 'general' mode 33 text_t httpimg; 34 text_t gwcgi; 35 text_tarray macrofiles; 36 text_t saveconf; 37 }; 38 39 27 40 class receptionist { 41 protected: 42 recptconf configinfo; 43 44 cgiargsinfoclass argsinfo; 45 actionmapclass actions; 46 recptprotolistclass protocols; 47 displayclass disp; 48 convertinfoclass converters; 49 28 50 public: 29 51 receptionist () {} 30 52 virtual ~receptionist() {} 31 53 32 // this version of set_gsdlhome should be used if the receptionist 33 // is being run for multiple collections ("general" mode). 34 void set_gsdlhome (const text_t &thegsdlhome); 35 text_t get_gsdlhome () {return gsdlhome;} 54 // add_action makes another action available to the receptionist 55 // the action remains the property of the calling code and that 56 // code should destroy the action after the recptionist has been 57 // destroyed. 58 void add_action (action *theaction) {actions.addaction(theaction);} 59 actionmapclass *get_actionmap_ptr () {return &actions;} 36 60 37 // this version of set_gsdlhome should be used if the receptionist 38 // is being run for a single collection ("collection specific" mode). 39 void set_gsdlhome (const text_t &thegsdlhome, const text_t &thecollection); 40 text_t get_collection () {return collection;} 61 // add_protocol makes another protocol available to the receptionist 62 // without any protocols, no collections will be available. The 63 // protocols remain the property of the calling code. 64 void add_protocol (recptproto *theprotocol) {protocols.addrecptproto(theprotocol);} 65 recptprotolistclass *get_recptprotolist_ptr () {return &protocols;} 66 67 // add_converter makes another converter available to the receptionist. 68 // Converters are needed to display pages using different encodings. 69 // The converters remain the property of the calling code. 70 void add_converter (const text_t &name, inconvertclass *inconverter, 71 rzwsoutconvertclass *outconverter) 72 {converters.add_converter(name, inconverter, outconverter);} 73 convertinfoclass *get_convertinfo_ptr () {return &converters;} 41 74 42 // sets the http address of the images directory. This is used to43 // speed up the access to the images which are a part of the general44 // interface. If this is not set the interface will have to get the45 // images via gwcgi which will be a lot slower (especially if the46 // browser does not cache the images).47 void set_httpimg (const text_t &thehttpimg) {httpimg=thehttpimg;}48 text_t get_httpimg () {return httpimg;}49 75 50 // sets the http address of the gateway cgi program (ie. the program 51 // that contains this receptionist). 52 void set_gwcgi (const text_t &thegwcgi) {gwcgi=thegwcgi;} 53 text_t get_gwcgi () {return gwcgi;} 76 // configure should be called for each line in the 77 // configuration files to configure the receptionist and everything 78 // it contains. The configuration should take place after everything 79 // has been added but before the initialisation. 80 void configure (const text_t &key, const text_tarray &cfgline); 81 void configure (const text_t &key, const text_t &value); 82 const recptconf &get_configinfo () {return configinfo;} 83 cgiargsinfoclass *get_cgiargsinfo_ptr () {return &argsinfo;} 84 54 85 55 // set_macrofiles defines the macro files which will be read when 56 // the init function is called. 57 void set_macrofiles (const text_tarray &themacrofiles) {macrofiles=themacrofiles;} 58 text_tarray get_macrofiles () {return macrofiles;} 59 60 // set_saveconf defines what should be included in the compressed 61 // arguments. This string should consist of cgi argument names 62 // seperated by "-". 63 void set_saveconf (const text_t &thesaveconf) {saveconf=thesaveconf;} 64 text_t get_saveconf () {return saveconf;} 65 66 // add_action makes another action available to the receptionist 67 // the action becomes the property of the receptionist 68 void add_action (action *theaction) {actions.addaction(theaction);} 69 70 // configure_actions should be called for each line in the 71 // configuration files to configure the actions. The configuration 72 // should take place after all the actions have been added. 73 void configure_actions (const text_t &key, const text_tarray &cfgline); 74 75 // init should be called after setgsdhome has been called. 86 // init should be called after all the actions, protocols, and 87 // converters have been added to the receptionist and after everything 88 // has been configured but before any pages are created. 76 89 // It returns true on success and false on failure. If false is 77 90 // returned getpage should not be called (without producing … … 114 127 text_t get_compressed_arg (const cgiargsclass &args); 115 128 116 // returns a pointer to the action list117 actionmapclass *get_actionmap_ptr () {return &actions;}118 119 129 protected: 120 text_t gsdlhome;121 text_t collectdir; // will equal gsdlhome in 'general' mode122 text_t collection; // will equal "" in 'general' mode123 text_t httpimg;124 text_t gwcgi;125 126 displayclass disp;127 text_tarray macrofiles;128 129 text_t saveconf;130 cgiargsinfoclass argsinfo;131 actionmapclass actions;132 133 130 // will read in all the macro files. If one is not found an 134 131 // error message will be written to logout and the method will -
trunk/gsdl/src/recpt/recptconfig.cpp
r155 r165 12 12 /* 13 13 $Log$ 14 Revision 1.3 1999/02/21 22:33:57 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.2 1999/02/08 01:28:04 rjmcnab 15 19 … … 75 79 cfgline.erase(cfgline.begin()); 76 80 77 if (key == "gsdlhome") { 78 if (collection.empty()) recpt.set_gsdlhome(cfgline[0]); 79 else recpt.set_gsdlhome(cfgline[0], collection); 80 } 81 else if (key == "httpimg") recpt.set_httpimg(cfgline[0]); 82 else if (key == "gwcgi") recpt.set_gwcgi(cfgline[0]); 83 else if (key == "maxrequests") { 81 if (key == "maxrequests") { 84 82 maxrequests = cfgline[0].getint(); 85 83 if (maxrequests < 1) maxrequests = 1; 86 84 } 87 85 88 // configure all the actions89 recpt.configure _actions(key, cfgline);86 // configure the receptionist 87 recpt.configure (key, cfgline); 90 88 } 91 89 } … … 122 120 } 123 121 124 // read in the siteconfiguration file122 // read in the main configuration file 125 123 text_t key; 126 124 text_tarray cfgline; … … 134 132 key = cfgline[0]; 135 133 cfgline.erase(cfgline.begin()); 136 if (key == "macrofiles") recpt.set_macrofiles (cfgline);137 134 138 // configure all the actions139 recpt.configure _actions(key, cfgline);135 // configure the receptionist 136 recpt.configure (key, cfgline); 140 137 } 141 138 } -
trunk/gsdl/src/recpt/recptmain.cpp
r144 r165 12 12 /* 13 13 $Log$ 14 Revision 1.2 1999/02/21 22:33:58 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.1 1999/02/04 01:16:18 rjmcnab 15 19 … … 24 28 25 29 int main () { 26 receptionist *recpt = new receptionist; 27 assert (recpt != NULL); 28 cgiwrapper (*recpt, ""); 30 receptionist recpt; 31 cgiwrapper (recpt, ""); 29 32 return 0; 30 33 } -
trunk/gsdl/src/recpt/statusaction.cpp
r160 r165 12 12 /* 13 13 $Log$ 14 Revision 1.5 1999/02/21 22:33:58 rjmcnab 15 16 Lots of stuff :-) 17 14 18 Revision 1.4 1999/02/12 02:40:18 sjboddie 15 19 … … 65 69 66 70 bool statusaction::do_action (cgiargsclass &args, outconvertclass &outconvert, 67 ostream &textout, ostream &logout) { 71 recptproto */*collectproto*/, ostream &textout, 72 ostream &/*logout*/) { 68 73 69 74 textout << outconvert << "<html>\n"; … … 74 79 if (disabled) textout << outconvert << "<h2>Status disabled</h2>\n"; 75 80 else { 76 textout << outconvert << "<h2> Statusinformation</h2>\n";81 textout << outconvert << "<h2>Receptionist configuration information</h2>\n"; 77 82 78 83 if (recpt == NULL) { … … 83 88 84 89 } else { 90 const recptconf &rcinfo = recpt->get_configinfo (); 91 85 92 textout << outconvert << "<table>\n"; 86 textout << outconvert << "<tr valign=top><th>gsdlhome</th><td>\"" << recpt->get_gsdlhome() 87 << "\"</td></tr>\n"; 88 textout << outconvert << "<tr valign=top><th>collection</th><td>\"" << recpt->get_collection() 89 << "\"</td></tr>\n"; 90 textout << outconvert << "<tr valign=top><th>httpimg</th><td>\"" << recpt->get_httpimg() 91 << "\"</td></tr>\n"; 92 textout << outconvert << "<tr valign=top><th>gwcgi</th><td>\"" << recpt->get_gwcgi() 93 << "\"</td></tr>\n"; 94 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << recpt->get_saveconf() 95 << "\"</td></tr>\n"; 96 93 textout << outconvert << "<tr valign=top><th>gsdlhome</th><td>\"" << rcinfo.gsdlhome 94 << "\"</td></tr>\n"; 95 textout << outconvert << "<tr valign=top><th>collection</th><td>\"" << rcinfo.collection 96 << "\"</td></tr>\n"; 97 textout << outconvert << "<tr valign=top><th>collectdir</th><td>\"" << rcinfo.collectdir 98 << "\"</td></tr>\n"; 99 textout << outconvert << "<tr valign=top><th>httpimg</th><td>\"" << rcinfo.httpimg 100 << "\"</td></tr>\n"; 101 textout << outconvert << "<tr valign=top><th>gwcgi</th><td>\"" << rcinfo.gwcgi 102 << "\"</td></tr>\n"; 103 104 105 // macrofiles 97 106 textout << outconvert << "<tr valign=top><th>macrofiles</th><td>"; 98 text_tarray macrofiles = recpt->get_macrofiles(); 99 text_tarray::iterator macrohere = macrofiles.begin (); 100 text_tarray::iterator macroend = macrofiles.end (); 107 text_tarray::const_iterator macrohere = rcinfo.macrofiles.begin (); 108 text_tarray::const_iterator macroend = rcinfo.macrofiles.end (); 101 109 bool macrofirst = true; 102 110 while (macrohere != macroend) { … … 106 114 macrohere++; 107 115 } 108 109 116 textout << outconvert << "</td></tr>\n"; 110 textout << outconvert << "<tr><th valign=top>current args</th><td>\n"; 111 textout << outconvert << "<table><tr><td><em>arg name</em></td>" 112 << "<td><em>value</em></td></tr>\n"; 117 118 // saveconf 119 textout << outconvert << "<tr valign=top><th>saveconf</th><td>\"" << rcinfo.saveconf 120 << "\"</td></tr>\n"; 121 122 // arguments 123 cgiargsinfoclass *rcargsinfo = recpt->get_cgiargsinfo_ptr (); 124 if (rcargsinfo != NULL) { 125 textout << outconvert << "<tr valign=top><th>arguments</th><td>"; 126 127 cgiargsinfoclass::const_iterator argsinfohere = rcargsinfo->begin (); 128 cgiargsinfoclass::const_iterator argsinfoend = rcargsinfo->end (); 129 bool argsinfofirst = true; 130 while (argsinfohere != argsinfoend) { 131 if (!argsinfofirst) textout << outconvert << ", "; 132 argsinfofirst = false; 133 textout << outconvert << "\"" << (*argsinfohere).second.shortname << "\""; 134 argsinfohere++; 135 } 136 137 textout << outconvert << "</td></tr>\n"; 138 } 139 140 // actions 141 actionmapclass *actions = recpt->get_actionmap_ptr(); 142 if (actions != NULL) { 143 textout << outconvert << "<tr valign=top><th>actions</th><td>"; 144 145 actionptrmap::iterator actionshere = actions->begin (); 146 actionptrmap::iterator actionsend = actions->end (); 147 bool actionsfirst = true; 148 while (actionshere != actionsend) { 149 if (!actionsfirst) textout << outconvert << ", "; 150 actionsfirst = false; 151 assert ((*actionshere).second.a != NULL); 152 if ((*actionshere).second.a != NULL) { 153 textout << outconvert << "\"" << (*actionshere).second.a->get_action_name() << "\""; 154 } 155 actionshere++; 156 } 157 158 textout << outconvert << "</td></tr>\n"; 159 } 113 160 161 // protocols 162 recptprotolistclass *protocols = recpt->get_recptprotolist_ptr (); 163 if (protocols != NULL) { 164 textout << outconvert << "<tr valign=top><th>protocols</th><td>"; 165 166 recptprotolistclass::iterator protohere = protocols->begin (); 167 recptprotolistclass::iterator protoend = protocols->end (); 168 bool protofirst = true; 169 while (protohere != protoend) { 170 if (!protofirst) textout << outconvert << ", "; 171 protofirst = false; 172 if ((*protohere).p != NULL) { 173 textout << outconvert << "\"" << (*protohere).p->get_protocol_name() << "\""; 174 } 175 protohere++; 176 } 177 178 textout << outconvert << "</td></tr>\n"; 179 } 180 181 // converters 182 convertinfoclass *converters = recpt->get_convertinfo_ptr (); 183 if (converters != NULL) { 184 textout << outconvert << "<tr valign=top><th>converters</th><td>"; 185 186 convertinfoclass::iterator converthere = converters->begin (); 187 convertinfoclass::iterator convertend = converters->end (); 188 bool convertfirst = true; 189 while (converthere != convertend) { 190 if (!convertfirst) textout << outconvert << ", "; 191 convertfirst = false; 192 textout << outconvert << "\"" << (*converthere).second.name << "\""; 193 converthere++; 194 } 195 196 textout << outconvert << "</td></tr>\n"; 197 } 198 199 200 textout << outconvert 201 << "</table>\n" 202 << "<hr>\n" 203 << "<h2>Argument information</h2>\n" 204 << "<table>"; 205 206 // argument information 207 textout << outconvert << "<tr valign=top><th>short name</th><th>long name</th>" 208 << "<th>multiple char?</th>" 209 << "<th>default</th><th>default status</th><th>saved args</th>" 210 << "<th>current value</th></tr>\n"; 211 114 212 cgiargsclass::const_iterator argshere = args.begin(); 115 213 cgiargsclass::const_iterator argsend = args.end(); 214 cgiarginfo *ainfo; 116 215 117 216 while (argshere != argsend) { 118 textout << outconvert << "<tr><td>" << (*argshere).first << "</td><td>" 119 << (*argshere).second << "</td></tr>\n"; 217 const text_t &aname = (*argshere).first; 218 textout << outconvert 219 << "<tr valign=top><td>" << aname << "</td>\n"; 220 221 if ((rcargsinfo != NULL) && 222 ((ainfo=rcargsinfo->getarginfo(aname)) != NULL)) { 223 textout << outconvert << "<td>" << ainfo->longname << "</td>\n"; 224 if (ainfo->multiplechar) textout << outconvert << "<td>yes</td>\n"; 225 else textout << outconvert << "<td>no</td>\n"; 226 textout << outconvert << "<td>" << ainfo->argdefault << "</td>\n"; 227 switch (ainfo->defaultstatus) { 228 case cgiarginfo::none: textout << outconvert << "<td>none</td>\n"; break; 229 case cgiarginfo::weak: textout << outconvert << "<td>weak</td>\n"; break; 230 case cgiarginfo::good: textout << outconvert << "<td>good</td>\n"; break; 231 case cgiarginfo::config: textout << outconvert << "<td>config</td>\n"; break; 232 case cgiarginfo::imperative: textout << outconvert << "<td>imperative</td>\n"; break; 233 } 234 switch (ainfo->savedarginfo) { 235 case cgiarginfo::mustnot: textout << outconvert << "<td>mustnot</td>\n"; break; 236 case cgiarginfo::can: textout << outconvert << "<td>can</td>\n"; break; 237 case cgiarginfo::must: textout << outconvert << "<td>must</td>\n"; break; 238 } 239 } else { 240 textout << outconvert << "<td colspan=5></td>\n"; 241 } 242 243 textout << outconvert << "<td>\"" << (*argshere).second << "\"</td></tr>\n"; 244 120 245 argshere ++; 121 246 } 122 123 textout << outconvert << "</table></td></tr>\n"; 124 textout << outconvert << "<tr valign=top><th>actions</th><td>\n<table>"; 125 126 actionmapclass *actions = recpt->get_actionmap_ptr(); 127 actionptrmap::iterator here = actions->begin (); 128 actionptrmap::iterator end = actions->end (); 129 while (here != end) { 130 assert ((*here).second.a != NULL); 131 if ((*here).second.a != NULL) { 132 133 textout << outconvert << "<tr><th colspan=5>" << (*here).second.a->get_action_name() << "</th></tr>\n"; 134 textout << outconvert << "<tr><td colspan=5><b>arguments</b></td></tr>\n"; 135 textout << outconvert << "<tr><td><em>short name</em></td><td><em>long name</em></td>\n"; 136 textout << outconvert << "<td><em>default</em></td><td><em>default status</em></td>"; 137 textout << outconvert << "<td><em>saved arg</em></td></tr>\n"; 138 139 cgiargsinfoclass argsinfo = (*here).second.a->getargsinfo(); 140 141 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin (); 142 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end (); 143 144 while (argsinfohere != argsinfoend) { 145 textout << outconvert << "<tr><td>" << (*argsinfohere).second.shortname << "</td>\n"; 146 textout << outconvert << "<td>" << (*argsinfohere).second.longname << "</td>\n"; 147 textout << outconvert << "<td>" << (*argsinfohere).second.argdefault << "</td>\n"; 148 switch ((*argsinfohere).second.defaultstatus) { 149 case 0: textout << outconvert << "<td>none</td>\n"; break; 150 case 1: textout << outconvert << "<td>weak</td>\n"; break; 151 case 2: textout << outconvert << "<td>good</td>\n"; break; 152 case 3: textout << outconvert << "<td>config</td>\n"; break; 153 case 4: textout << outconvert << "<td>imperitave</td>\n"; break; 154 default: textout << outconvert << "<td></td>\n"; 247 248 textout << outconvert 249 << "</table>\n" 250 << "<hr>\n" 251 << "<h2>Action information</h2>\n" 252 << "<table>"; 253 254 // action information 255 if (actions != NULL) { 256 textout << outconvert 257 << "<tr><th>action name</th><th>cgi arguments</th></tr>\n"; 258 259 actionptrmap::iterator actionshere = actions->begin (); 260 actionptrmap::iterator actionsend = actions->end (); 261 while (actionshere != actionsend) { 262 assert ((*actionshere).second.a != NULL); 263 if ((*actionshere).second.a != NULL) { 264 textout << outconvert 265 << "<tr><td>" << (*actionshere).second.a->get_action_name() 266 << "</td><td>"; 267 268 cgiargsinfoclass argsinfo = (*actionshere).second.a->getargsinfo(); 269 cgiargsinfoclass::const_iterator argsinfohere = argsinfo.begin (); 270 cgiargsinfoclass::const_iterator argsinfoend = argsinfo.end (); 271 bool aifirst = true; 272 while (argsinfohere != argsinfoend) { 273 if (!aifirst) textout << outconvert << ", "; 274 aifirst = false; 275 textout << outconvert << (*argsinfohere).second.shortname; 276 argsinfohere++; 155 277 } 156 switch ((*argsinfohere).second.savedarginfo) { 157 case 0: textout << outconvert << "<td>mustnot</td></tr>\n"; break; 158 case 1: textout << outconvert << "<td>can</td></tr>\n"; break; 159 case 2: textout << outconvert << "<td>must</td></tr>\n"; break; 160 default: textout << outconvert << "<td></td></tr>\n"; 161 } 162 argsinfohere++; 278 279 textout << outconvert << "</td></tr>\n"; 163 280 } 164 } 165 here++; 166 } 167 168 textout << outconvert << "</table></td></tr>\n"; 169 textout << outconvert << "</table>\n"; 281 actionshere++; 282 } 283 } 284 285 textout << outconvert << "</table><hr>\n"; 170 286 } 171 287 } 172 288 173 289 ifstream initin (GSDL_GSDLHOME "/etc/initout.txt"); 174 290 if (initin) { -
trunk/gsdl/src/recpt/statusaction.h
r157 r165 20 20 21 21 22 23 22 class statusaction : public action { 24 23 protected: … … 36 35 text_t &response_data, ostream &logout); 37 36 bool do_action (cgiargsclass &args, outconvertclass &outconvert, 38 ostream &textout, ostream &logout); 37 recptproto *collectproto, ostream &textout, 38 ostream &logout); 39 39 void configure (const text_t &key, const text_tarray &cfgline); 40 40 };
Note:
See TracChangeset
for help on using the changeset viewer.