Changeset 165 for trunk/gsdl/src/recpt


Ignore:
Timestamp:
1999-02-22T11:33:58+13:00 (25 years ago)
Author:
rjmcnab
Message:

Lots of stuff :-)

Location:
trunk/gsdl/src/recpt
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/Makefile

    r160 r165  
    3434    $(COMPILE) $<
    3535
    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)
     36COMMONHEADERS = 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
     40RECEPTHEADERS =
     41
     42COLSERVRHEADERS = gdbmclass.h mgq.h mgsearch.h querycache.h queryinfo.h \
     43                  collectserver.h colservrconfig.h
     44
     45LIBRARYHEADERS = $(COLSERVRHEADERS) \
     46                 nullproto.h
     47
     48HEADERS = $(COMMONHEADERS) $(RECPTHEADERS) $(LIBRARYHEADERS)
     49
     50
     51COMMONSOURCES = 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
     56RECPTSOURCES = recptmain.cpp
     57
     58COLSERVRSOURCES = gdbmclass.cpp mgq.c mgsearch.cpp querycache.cpp queryinfo.cpp \
     59                  collectserver.cpp colservrconfig.cpp
     60
     61LIBRARYSOURCES = $(COLSERVRSOURCES) \
     62                 nullproto.cpp librarymain.cpp
     63
     64SOURCES = $(COMMONSOURCES) $(RECPTSOURCES) $(LIBRARYSOURCES)
     65
     66
     67COMMONOBJECTS = 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
     71RECPTOBJECTS = recptmain.o
     72
     73COLSERVROBJECTS = gdbmclass.o mgq.o mgsearch.o querycache.o queryinfo.o \
     74                  collectserver.o colservrconfig.o
     75
     76LIBRARYOBJECTS = $(COLSERVROBJECTS) \
     77                 nullproto.o librarymain.o
     78
     79OBJECTS = $(COMMONOBJECTS) $(RECPTOBJECTS) $(LIBRARYOBJECTS)
     80
     81
     82EXEC = recpt library
     83
     84all: $(COLSERVRHEADERS) $(COLSERVRSOURCES) $(EXEC)
     85
     86$(COLSERVRHEADERS) $(COLSERVRSOURCES):
     87    ln -s ../colservr/$@
    4988
    5089clean:
    51     rm -f $(OBJECTS)
     90    rm -f $(COLSERVRHEADERS) $(COLSERVRSOURCES) $(OBJECTS) $(EXEC)
    5291
    5392install:
     
    5897# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
    5998
    60 RECPT_OBJS = $(OBJECTS) \
     99RECPT_OBJS = $(COMMONOBJECTS) $(RECPTOBJECTS) \
    61100    ../../lib/gsdllib.a  \
    62101    ../../packages/mg-1.3d/src/text/libtextin.a \
     
    67106    $(LINK) $(RECPT_OBJS) $(LIBS)
    68107
     108# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
     109
     110LIBRARY_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
     116library: $(LIBRARY_OBJS)
     117    $(LINK) $(LIBRARY_OBJS) $(LIBS)
     118
     119
    69120# DO NOT DELETE
    70121
    71122receptionist.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h
    72123receptionist.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h
     124receptionist.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h
    73125receptionist.o: ../../lib/fileutil.h cgiutils.h
    74126cgiwrapper.o: ../../lib/gsdlconf.h ../../lib/site.h cgiwrapper.h
    75127cgiwrapper.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
     128cgiwrapper.o: action.h recptproto.h comtypes.h converter.h
     129cgiwrapper.o: ../../lib/gsdlunicode.h recptconfig.h statusaction.h
     130cgiwrapper.o: pageaction.h pingaction.h ../../packages/fcgi/include/fcgiapp.h
    78131cgiwrapper.o: ../../packages/fcgi/include/fcgi_config.h
    79132cgiargs.o: cgiargs.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h
    80133cgiargs.o: ../../lib/gsdlunicode.h
    81 recptmain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h
    82 recptmain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h
    83 recptmain.o: cgiwrapper.h
    84134action.o: action.h ../../lib/gsdlconf.h ../../lib/site.h ../../lib/text_t.h
    85 action.o: cgiargs.h ../../lib/display.h
     135action.o: cgiargs.h ../../lib/display.h recptproto.h comtypes.h
    86136converter.o: converter.h ../../lib/gsdlconf.h ../../lib/site.h
    87137converter.o: ../../lib/text_t.h ../../lib/gsdlunicode.h
    88138recptconfig.o: recptconfig.h ../../lib/gsdlconf.h ../../lib/site.h
    89139recptconfig.o: ../../lib/text_t.h receptionist.h cgiargs.h
    90 recptconfig.o: ../../lib/display.h action.h ../../lib/fileutil.h
     140recptconfig.o: ../../lib/display.h action.h recptproto.h comtypes.h
     141recptconfig.o: converter.h ../../lib/gsdlunicode.h ../../lib/fileutil.h
    91142recptconfig.o: ../../lib/cfgread.h
    92143cgiutils.o: cgiutils.h ../../lib/gsdlconf.h ../../lib/site.h
     
    95146htmlgen.o: ../../lib/display.h ../../packages/mg-1.3d/lib/unitool.h
    96147statusaction.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.h
     148statusaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h
     149statusaction.o: comtypes.h receptionist.h converter.h ../../lib/gsdlunicode.h
    99150pageaction.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
     151pageaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h
     152pageaction.o: comtypes.h
     153comtypes.o: comtypes.h ../../lib/gsdlconf.h ../../lib/site.h
     154comtypes.o: ../../lib/text_t.h
     155recptproto.o: recptproto.h ../../lib/gsdlconf.h ../../lib/site.h
     156recptproto.o: ../../lib/text_t.h comtypes.h
     157pingaction.o: pingaction.h ../../lib/gsdlconf.h ../../lib/site.h action.h
     158pingaction.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h recptproto.h
     159pingaction.o: comtypes.h
     160recptmain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h
     161recptmain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h
     162recptmain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h
     163recptmain.o: cgiwrapper.h
     164gdbmclass.o: ../../lib/text_t.h ../../lib/gsdlconf.h ../../lib/site.h
     165gdbmclass.o: gdbmclass.h ../../packages/mg-1.3d/lib/unitool.h
     166gdbmclass.o: ../../lib/gsdlunicode.h ../../lib/fileutil.h
     167mgq.o: mgq.h ../../packages/mg-1.3d/sysfuncs.h
     168mgq.o: ../../packages/mg-1.3d/lib/pathmax.h
     169mgq.o: ../../packages/mg-1.3d/lib/getopt.h
     170mgq.o: ../../packages/mg-1.3d/lib/messages.h
     171mgq.o: ../../packages/mg-1.3d/lib/memlib.h
     172mgq.o: ../../packages/mg-1.3d/src/text/invf.h
     173mgq.o: ../../packages/mg-1.3d/src/text/text.h
     174mgq.o: ../../packages/mg-1.3d/lib/huffman.h
     175mgq.o: ../../packages/mg-1.3d/lib/filestats.h
     176mgq.o: ../../packages/mg-1.3d/src/text/lists.h
     177mgq.o: ../../packages/mg-1.3d/src/text/backend.h
     178mgq.o: ../../packages/mg-1.3d/lib/timing.h
     179mgq.o: ../../packages/mg-1.3d/src/text/term_lists.h
     180mgq.o: ../../packages/mg-1.3d/src/text/query_term_list.h
     181mgq.o: ../../packages/mg-1.3d/src/text/mg.h
     182mgq.o: ../../packages/mg-1.3d/src/text/environment.h
     183mgq.o: ../../packages/mg-1.3d/src/text/globals.h
     184mgq.o: ../../packages/mg-1.3d/src/text/mg_errors.h
     185mgq.o: ../../packages/mg-1.3d/src/text/commands.h
     186mgq.o: ../../packages/mg-1.3d/src/text/text_get.h
     187mgq.o: ../../packages/mg-1.3d/lib/local_strings.h
     188mgsearch.o: ../../lib/gsdlconf.h ../../lib/site.h mgsearch.h
     189mgsearch.o: ../../lib/text_t.h querycache.h queryinfo.h ../../lib/fileutil.h
     190mgsearch.o: mgq.h ../../lib/gsdlunicode.h
     191mgsearch.o: ../../packages/mg-1.3d/lib/unitool.h
     192querycache.o: querycache.h ../../lib/text_t.h ../../lib/gsdlconf.h
     193querycache.o: ../../lib/site.h queryinfo.h
     194queryinfo.o: queryinfo.h ../../lib/gsdlconf.h ../../lib/site.h
     195queryinfo.o: ../../lib/text_t.h
     196collectserver.o: collectserver.h ../../lib/gsdlconf.h ../../lib/site.h
     197collectserver.o: ../../lib/text_t.h comtypes.h
     198nullproto.o: nullproto.h ../../lib/gsdlconf.h ../../lib/site.h
     199nullproto.o: collectserver.h ../../lib/text_t.h comtypes.h recptproto.h
     200librarymain.o: receptionist.h ../../lib/gsdlconf.h ../../lib/site.h
     201librarymain.o: ../../lib/text_t.h cgiargs.h ../../lib/display.h action.h
     202librarymain.o: recptproto.h comtypes.h converter.h ../../lib/gsdlunicode.h
     203librarymain.o: cgiwrapper.h nullproto.h collectserver.h
  • trunk/gsdl/src/recpt/action.cpp

    r158 r165  
    1212/*
    1313   $Log$
     14   Revision 1.6  1999/02/21 22:33:52  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.5  1999/02/11 01:24:04  rjmcnab
    1519
     
    5660}
    5761
     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
     65void 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
     78bool action::init (ostream &/*logout*/) {
     79  return true;
     80}
     81
    5882// returns the "a" argument value that will specify this action
    5983// this name should be short but does not have to be one character
     
    92116// from outputing anything.
    93117bool action::do_action (cgiargsclass &/*args*/, outconvertclass &/*outconvert*/,
    94             ostream &/*textout*/, ostream &/*logout*/) {
     118            recptproto */*collectproto*/, ostream &/*textout*/,
     119            ostream &/*logout*/) {
    95120  return true;
    96 }
    97 
    98 // configure should be called once for each configuration line
    99 // the default version configures the default for any arguments
    100 // which this action uses
    101 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   }
    110121}
    111122
    112123
    113124
    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.
    120127void actionmapclass::addaction (action *theaction) {
    121128  // can't add a null action
     
    130137  aptr.a = theaction;
    131138  actionptrs[theaction->get_action_name()] = aptr;
    132   aptr.a = NULL; // control has passed on
    133139}
    134140
    135141// getaction will return NULL if the action could not be found
    136142action *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
    137147  iterator here = actionptrs.find (key);
    138148  if (here == actionptrs.end()) return NULL;
  • trunk/gsdl/src/recpt/action.h

    r155 r165  
    1818#include "cgiargs.h"
    1919#include "display.h"
     20#include "recptproto.h"
    2021
    2122#if defined(GSDL_USE_OBJECTSPACE)
     
    4041  action ();
    4142  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);
    4250
    4351  // returns the "a" argument value that will specify this action
     
    6977  // from outputing anything.
    7078  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 
    7682  // getargsinfo should be called after all configuration files
    7783  // have been read
     
    8086
    8187
    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.
    8790class actionptr {
    8891public:
     
    9093
    9194  actionptr () {a=NULL;}
    92   ~actionptr () {if (a!=NULL) delete a; a=NULL;}
    9395};
    9496
     
    112114  typedef actionptrmap::reverse_iterator reverse_iterator;
    113115 
    114   // constructors
    115   actionmapclass ();
    116 
    117116  // basic container support
    118117  iterator begin () {return actionptrs.begin();}
     
    132131  void clear () {actionptrs.erase(actionptrs.begin(),actionptrs.end());}
    133132
    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.
    137135  void addaction (action *theaction);
    138136
  • trunk/gsdl/src/recpt/cgiwrapper.cpp

    r160 r165  
    1212/*
    1313   $Log$
     14   Revision 1.7  1999/02/21 22:33:53  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.6  1999/02/12 02:40:17  sjboddie
    1519
     
    5458#include "statusaction.h"
    5559#include "pageaction.h"
     60#include "pingaction.h"
    5661#include <stdlib.h>
    5762
     
    317322  outconvertclass text_t2ascii;
    318323
    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);
    331335
    332336
    333337  // set defaults
    334338  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");
    338342  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");
    341345
    342346  // read in the configuration files.
  • trunk/gsdl/src/recpt/pageaction.cpp

    r160 r165  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/02/21 22:33:54  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.1  1999/02/12 02:40:17  sjboddie
    1519
     
    2327
    2428pageaction::pageaction () {
    25   disabled = true;
    26   recpt = NULL;
    27 
    2829  // this action uses cgi variables "a" and "p"
    2930  cgiarginfo arg_ainfo;
     
    3233  arg_ainfo.multiplechar = true;
    3334  arg_ainfo.defaultstatus = cgiarginfo::weak;
    34   arg_ainfo.argdefault = "status";
     35  arg_ainfo.argdefault = "p";
    3536  arg_ainfo.savedarginfo = cgiarginfo::must;
    3637  argsinfo.addarginfo (NULL, arg_ainfo);
     
    6162
    6263bool pageaction::do_action (cgiargsclass &args, outconvertclass &outconvert,
    63                 ostream &textout, ostream &logout) {
     64                recptproto */*collectproto*/, ostream &textout,
     65                ostream &/*logout*/) {
    6466
    6567  textout << outconvert << "<html>\n";
     
    7274  return true;
    7375}
    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 which
    81     // are not dealt with here
    82     action::configure (key, cfgline);
    83   }
    84 }
  • trunk/gsdl/src/recpt/pageaction.h

    r160 r165  
    1717#include "gsdlconf.h"
    1818#include "action.h"
    19 #include "receptionist.h"
    2019
    2120
    2221class pageaction : public action {
    23 protected:
    24   bool disabled;
    25   receptionist *recpt;
    26 
    2722public:
    2823  pageaction ();
     
    3025
    3126  text_t get_action_name () {return "p";}
    32   void set_receptionist (receptionist *therecpt) {recpt=therecpt;}
    3327  bool check_cgiargs (cgiargsclass &args, ostream &logout);
    3428  void get_cgihead_info (cgiargsclass &args, response_t &response,
    3529             text_t &response_data, ostream &logout);
    3630  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);
    3933};
    4034
  • trunk/gsdl/src/recpt/receptionist.cpp

    r158 r165  
    1212/*
    1313   $Log$
     14   Revision 1.7  1999/02/21 22:33:55  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.6  1999/02/11 01:24:05  rjmcnab
    1519
     
    4448
    4549
    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.
     55void 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
     92void 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.
    89102// It returns true on success and false on failure. If false is
    90103// returned getpage should not be called (without producing
     
    92105// produced by the calling code.
    93106bool 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
    94127  // read in the macro files
    95128  if (!read_macrofiles (logout)) return false;
     
    97130  // defined the main cgi arguments
    98131  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  }
    99138
    100139  // add the cgi arguments from the actions
     
    111150
    112151  // 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);
    115154
    116155  // check the saveconf string
    117   if (!check_save_conf_str (saveconf, argsinfo, logout))
     156  if (!check_save_conf_str (configinfo.saveconf, argsinfo, logout))
    118157    return false;
    119158
     
    121160  srand (time(NULL));
    122161
    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  }
    125202
    126203  return true;
     
    140217
    141218  // 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;
    143220
    144221  // add the defaults
     
    158235    return false;
    159236  }
     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);
    160249
    161250  return true;
     
    224313bool receptionist::produce_content (cgiargsclass &args, ostream &contentout,
    225314                    ostream &logout) {
    226   outconvertclass text_t2ascii;
    227 
    228315  // 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  }
    229328
    230329  // produce the page using the desired action
    231330  action *a = actions.getaction (args["a"]);
    232331  if (a != NULL) {
    233     if (!a->do_action (args, text_t2ascii, contentout, logout))
     332    if (!a->do_action (args, (*outconverter), collectproto, contentout, logout))
    234333      return false;
    235334
    236335  } else {
    237336    // the action was not found!!
     337    outconvertclass text_t2ascii;
     338
    238339    logout << text_t2ascii << "Error receptionist::produce_content: the action \""
    239340       << args["a"] << "\" could not be found.\n";
    240341   
    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";
    251353  }
    252354
     
    274376  // is searched first for the file (if this is being used in
    275377  // collection specific mode) and then the main directory
    276   text_t colmacrodir = filename_cat (collectdir, "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();
    280382  text_t filename;
    281383  while (arrhere != arrend) {
     
    286388    // try in the collection directory if this is being
    287389    // run in collection specific mode
    288     if (!collection.empty()) {
     390    if (!configinfo.collection.empty()) {
    289391      filename = filename_cat (colmacrodir, *arrhere);
    290392      if (!file_exists (filename)) filename.clear ();
     
    302404      logout << text_t2ascii
    303405         << "Error: the macro file \"" << *arrhere << "\" could not be found.\n";
    304       if (collection.empty()) {
     406      if (configinfo.collection.empty()) {
    305407    logout << text_t2ascii
    306408           << "It should be in " << gsdlmacrodir << ".\n\n";
     
    367469  ainfo.longname = "collection";
    368470  ainfo.multiplechar = true;
    369   if (collection.empty()) {
     471  if (configinfo.collection.empty()) {
    370472    ainfo.defaultstatus = cgiarginfo::none;
    371473    ainfo.argdefault = "";
     
    373475  } else {
    374476    ainfo.defaultstatus = cgiarginfo::good;
    375     ainfo.argdefault = collection;
     477    ainfo.argdefault = configinfo.collection;
    376478    ainfo.savedarginfo = cgiarginfo::can;
    377479  }
     
    417519  // then it should always set the collection argument to the
    418520  // collection
    419   if (!collection.empty()) args["c"] = collection;
     521  if (!configinfo.collection.empty()) args["c"] = configinfo.collection;
    420522
    421523  // argument "v" can only be 0 or 1. Use the default value
  • trunk/gsdl/src/recpt/receptionist.h

    r159 r165  
    1919#include "display.h"
    2020#include "action.h"
     21#include "recptproto.h"
     22#include "converter.h"
    2123
    2224#ifndef MACROPRECEDENCE
     
    2527
    2628
     29struct 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
    2740class receptionist {
     41protected:
     42  recptconf configinfo;
     43
     44  cgiargsinfoclass argsinfo;
     45  actionmapclass actions;
     46  recptprotolistclass protocols;
     47  displayclass disp;
     48  convertinfoclass converters;
     49
    2850public:
    2951  receptionist () {}
    3052  virtual ~receptionist() {}
    3153
    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;}
    3660
    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;}
    4174
    42   // sets the http address of the images directory. This is used to
    43   // speed up the access to the images which are a part of the general
    44   // interface. If this is not set the interface will have to get the
    45   // images via gwcgi which will be a lot slower (especially if the
    46   // browser does not cache the images).
    47   void set_httpimg (const text_t &thehttpimg) {httpimg=thehttpimg;}
    48   text_t get_httpimg () {return httpimg;}
    4975
    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 
    5485
    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.
    7689  // It returns true on success and false on failure. If false is
    7790  // returned getpage should not be called (without producing
     
    114127  text_t get_compressed_arg (const cgiargsclass &args);
    115128
    116   // returns a pointer to the action list
    117   actionmapclass *get_actionmap_ptr () {return &actions;}
    118 
    119129protected:
    120   text_t gsdlhome;
    121   text_t collectdir; // will equal gsdlhome in 'general' mode
    122   text_t collection; // will equal "" in 'general' mode
    123   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 
    133130  // will read in all the macro files. If one is not found an
    134131  // error message will be written to logout and the method will
  • trunk/gsdl/src/recpt/recptconfig.cpp

    r155 r165  
    1212/*
    1313   $Log$
     14   Revision 1.3  1999/02/21 22:33:57  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.2  1999/02/08 01:28:04  rjmcnab
    1519
     
    7579    cfgline.erase(cfgline.begin());
    7680
    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") {
    8482      maxrequests = cfgline[0].getint();
    8583      if (maxrequests < 1) maxrequests = 1;
    8684    }
    8785
    88     // configure all the actions
    89     recpt.configure_actions (key, cfgline);
     86    // configure the receptionist
     87    recpt.configure (key, cfgline);
    9088      }
    9189    }
     
    122120  }
    123121
    124   // read in the site configuration file
     122  // read in the main configuration file
    125123  text_t key;
    126124  text_tarray cfgline;
     
    134132    key = cfgline[0];
    135133    cfgline.erase(cfgline.begin());
    136     if (key == "macrofiles") recpt.set_macrofiles (cfgline);
    137134
    138     // configure all the actions
    139     recpt.configure_actions (key, cfgline);
     135    // configure the receptionist
     136    recpt.configure (key, cfgline);
    140137      }
    141138    }
  • trunk/gsdl/src/recpt/recptmain.cpp

    r144 r165  
    1212/*
    1313   $Log$
     14   Revision 1.2  1999/02/21 22:33:58  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.1  1999/02/04 01:16:18  rjmcnab
    1519
     
    2428
    2529int main () {
    26   receptionist *recpt = new receptionist;
    27   assert (recpt != NULL);
    28   cgiwrapper (*recpt, "");
     30  receptionist recpt;
     31  cgiwrapper (recpt, "");
    2932  return 0;
    3033}
  • trunk/gsdl/src/recpt/statusaction.cpp

    r160 r165  
    1212/*
    1313   $Log$
     14   Revision 1.5  1999/02/21 22:33:58  rjmcnab
     15
     16   Lots of stuff :-)
     17
    1418   Revision 1.4  1999/02/12 02:40:18  sjboddie
    1519
     
    6569
    6670bool statusaction::do_action (cgiargsclass &args, outconvertclass &outconvert,
    67                   ostream &textout, ostream &logout) {
     71                  recptproto */*collectproto*/, ostream &textout,
     72                  ostream &/*logout*/) {
    6873
    6974  textout << outconvert << "<html>\n";
     
    7479  if (disabled) textout << outconvert << "<h2>Status disabled</h2>\n";
    7580  else {
    76     textout << outconvert << "<h2>Status information</h2>\n";
     81    textout << outconvert << "<h2>Receptionist configuration information</h2>\n";
    7782   
    7883    if (recpt == NULL) {
     
    8388
    8489    } else {
     90      const recptconf &rcinfo = recpt->get_configinfo ();
     91
    8592      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
    97106      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 ();
    101109      bool macrofirst = true;
    102110      while (macrohere != macroend) {
     
    106114    macrohere++;
    107115      }
    108 
    109116      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      }
    113160     
     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
    114212      cgiargsclass::const_iterator argshere = args.begin();
    115213      cgiargsclass::const_iterator argsend = args.end();
     214      cgiarginfo *ainfo;
    116215     
    117216      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
    120245    argshere ++;
    121246      }
    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++;
    155277        }
    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";
    163280      }
    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";
    170286    }
    171287  }
    172 
     288 
    173289  ifstream initin (GSDL_GSDLHOME "/etc/initout.txt");
    174290  if (initin) {
  • trunk/gsdl/src/recpt/statusaction.h

    r157 r165  
    2020
    2121
    22 
    2322class statusaction : public action {
    2423protected:
     
    3635             text_t &response_data, ostream &logout);
    3736  bool do_action (cgiargsclass &args, outconvertclass &outconvert,
    38           ostream &textout, ostream &logout);
     37          recptproto *collectproto, ostream &textout,
     38          ostream &logout);
    3939  void configure (const text_t &key, const text_tarray &cfgline);
    4040};
Note: See TracChangeset for help on using the changeset viewer.