Ignore:
Timestamp:
2010-05-20T20:59:01+12:00 (14 years ago)
Author:
davidb
Message:

For the CGI 'e' variable to be inter-changable between mod_gsdl and library.cgi then they need to have exactly the same actions. The code has been refactored so they now use a shared function to do this, the ensure this is the case.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/runtime-src/src/recpt/mod_gsdl.cpp

    r22048 r22142  
    8181
    8282#include "action.h"
    83 #include "pageaction.h"
    84 #include "queryaction.h"
    85 
    86 #if defined(USE_SQLITE)
    87 #include "sqlqueryaction.h"
    88 #endif
    89 
    90 #include "documentaction.h"
    91 #include "extlinkaction.h"
    92 #ifdef ENABLE_MGPP
    93 #include "phindaction.h"
    94 #endif
    95 #if defined(USE_MYSQL) || defined(USE_ACCESS)
    96 #include "orderaction.h"
    97 #endif
    98 #include "configaction.h"
    99 
    10083#include "browserclass.h"
    101 #include "vlistbrowserclass.h"
    102 #include "hlistbrowserclass.h"
    103 #include "datelistbrowserclass.h"
    104 #include "invbrowserclass.h"
    105 #include "pagedbrowserclass.h"
    106 #include "phindbrowserclass.h"
    107 
    108 #include <strstream>
     84
     85#define GSDL_USE_OSTRINGSTREAM 1
     86// ostrstream is deprecated => switch to using ostringstream
     87// Doing this with the above define so it is easy to switch
     88// back to ostrstream this backwards compatability is needed
     89// for some reason.
     90
     91#if defined(GSDL_USE_OSTRINGSTREAM)
     92#  include <sstream>
     93#else
     94#  if defined(GSDL_USE_IOS_H)
     95#    if defined(__WIN32__)
     96#      include <strstrea.h> // vc4
     97#    else
     98#      include <strstream.h>
     99#    endif
     100#  else
     101#    include <strstream>
     102#  endif
     103#endif
    109104
    110105receptionist recpt;
     
    252247  // class as a filler (but most likely won't work) - only useful
    253248  // if creating a binary that doesn't require access to the database
    254   dbclass *db = new gdbmclass();
     249  dbclass *db = new gdbmclass(gsdlhome);
    255250
    256251#endif
     
    260255#endif
    261256
    262   // the list of actions.
    263   pageaction *apageaction = new pageaction();
    264   apageaction->set_receptionist(&recpt);
    265   recpt.add_action(apageaction);
     257  userdbclass *udb = new userdbclass(gsdlhome);
     258  keydbclass *kdb = new keydbclass(gsdlhome);
     259  // do these two database classes ever get deleted in the module version
     260  // of Greenstone?
     261
     262  // librarymain.cpp deletes these when its finished its function
     263  // does comparable code need to be put into "gsdl_deinit()" routine
     264  // whatever that might be called in reality?
     265
     266  add_all_actions(recpt,udb,kdb);
     267  add_all_browsers(recpt);
    266268 
    267   queryaction *aqueryaction = new queryaction();
    268   aqueryaction->set_receptionist(&recpt);
    269   recpt.add_action(aqueryaction);
    270  
    271 #if defined(USE_SQLITE)
    272   sqlqueryaction *asqlqueryaction = new sqlqueryaction();
    273   asqlqueryaction->set_receptionist (&recpt);
    274   recpt.add_action (asqlqueryaction);
    275 #endif
    276 
    277   documentaction *adocumentaction = new documentaction();
    278   adocumentaction->set_receptionist(&recpt);
    279   recpt.add_action(adocumentaction);
    280 
    281   extlinkaction *anextlinkaction = new extlinkaction();
    282   recpt.add_action(anextlinkaction);
    283 
    284   // phindaction is for MGPP and uses MGQuery
    285 #ifdef ENABLE_MGPP
    286   phindaction *aphindaction = new phindaction();
    287   recpt.add_action(aphindaction);
    288 #endif
    289 
    290 #if defined(USE_MYSQL) || defined(USE_ACCESS)
    291   orderaction *aorderaction = new orderaction();
    292   aorderaction->set_receptionist(&recpt);
    293   recpt.add_action(aorderaction);
    294 #endif
    295 
    296   configaction *aconfigaction = new configaction();
    297   aconfigaction->set_receptionist(&recpt);
    298   recpt.add_action(aconfigaction);
    299 
    300   // list of browsers
    301   vlistbrowserclass *avlistbrowserclass = new vlistbrowserclass();
    302   recpt.add_browser(avlistbrowserclass);
    303   recpt.setdefaultbrowser("VList");
    304 
    305   hlistbrowserclass *ahlistbrowserclass = new hlistbrowserclass();
    306   recpt.add_browser(ahlistbrowserclass);
    307 
    308   datelistbrowserclass *adatelistbrowserclass = new datelistbrowserclass();
    309   recpt.add_browser(adatelistbrowserclass);
    310 
    311   invbrowserclass *ainvbrowserclass = new invbrowserclass();
    312   recpt.add_browser(ainvbrowserclass);
    313 
    314   pagedbrowserclass *apagedbrowserclass = new pagedbrowserclass();
    315   recpt.add_browser(apagedbrowserclass);
    316 
    317   phindbrowserclass *aphindbrowserclass = new phindbrowserclass();;
    318   recpt.add_browser(aphindbrowserclass);
    319  
     269
    320270  // configure everything
    321271  recpt.configure("gsdlhome", gsdlhome);
     
    500450  }
    501451
     452#ifdef GSDL_USE_OSTRINGSTREAM
     453  ostringstream pageout;
     454#else
    502455  ostrstream pageout;
     456#endif
    503457
    504458  // get http headers
     
    552506      return 500;
    553507    }
     508#ifdef GSDL_USE_OSTRINGSTREAM
     509    string out = pageout.str();
     510    ap_rwrite(out.c_str(), out.size(), r);
     511#else
    554512    char *out = pageout.str();
    555513    ap_rwrite(out, pageout.pcount(), r);
    556514    pageout.rdbuf()->freeze(0);
     515#endif
    557516  }
    558517
Note: See TracChangeset for help on using the changeset viewer.