Ignore:
Timestamp:
2008-07-09T13:12:15+12:00 (16 years ago)
Author:
davidb
Message:

Introduction of 'collecthome' which parallels 'gsdlhome' to allow the toplevel collect folder to be outside of the gsdlhome area

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/src/lib/gsdlsitecfg.cpp

    r15402 r16310  
    2424 *********************************************************************/
    2525
    26 
     26#include "fileutil.h"
    2727#include "gsdlsitecfg.h"
    2828
     
    4242private:
    4343  text_t *gsdlhome;
     44  text_t *collecthome;
    4445  text_t *httpdomain;
    4546  text_t *httpprefix;
     
    4950  int    *maxrequests;
    5051public:
    51   __site_configuration (text_t *_gsdlhome, int *_maxrequests) {
     52  __site_configuration (text_t *_gsdlhome, text_t* _collecthome, int *_maxrequests) {
    5253    gsdlhome = _gsdlhome;
     54    collecthome = _collecthome;
    5355    httpdomain = NULL;
    5456    httpprefix = NULL;
     
    5961  }
    6062
    61   __site_configuration (text_t *_gsdlhome, text_t *_httpdomain,
    62                         text_t *_httpprefix) {
     63  __site_configuration (text_t *_gsdlhome, text_t* _collecthome,
     64            text_t *_httpdomain, text_t *_httpprefix) {
    6365    gsdlhome    = _gsdlhome;
     66    collecthome  = _collecthome;
    6467    httpdomain = _httpdomain;
    6568    httpprefix = _httpprefix;
     
    7073  }
    7174
    72   __site_configuration (text_t *_gsdlhome, text_t *_httpdomain,
     75  __site_configuration (text_t *_gsdlhome, text_t* _collecthome,
     76            text_t *_httpdomain,
    7377            text_t *_httpprefix, text_t *_collection) {
    7478    gsdlhome    = _gsdlhome;
     79    collecthome  = _collecthome;
    7580    httpdomain = _httpdomain;
    7681    httpprefix = _httpprefix;
     
    8388  __site_configuration (text_t *_httpprefix, text_tset *_actions, text_tset *_browsers) {
    8489    gsdlhome    = NULL;
     90    collecthome  = NULL;
    8591    httpdomain = NULL;
    8692    httpprefix = _httpprefix;
     
    94100    if (gsdlhome != NULL && key == "gsdlhome") {
    95101      *gsdlhome = cfgline[0];
     102
     103      if ((collecthome != NULL) && (collecthome->empty())) {
     104    // defaults to <gsdlhome>/collect
     105    *collecthome = filename_cat(*gsdlhome,"collect");
     106      }
     107    }
     108
     109    if (collecthome != NULL && key == "collecthome") {
     110      if (!collecthome->empty()) {
     111    // if it has been previously set to default, free and then reassign
     112    collecthome->clear();
     113      }
     114      *collecthome = cfgline[0];
    96115    }
    97116
     
    141160// also sets gsdlhome and maxrequests
    142161// gsdlsite.cfg should be in same directory as library executable
    143 bool site_cfg_read (configurator gsdlconfigurator, text_t &gsdlhome, int &maxrequests)
     162bool site_cfg_read (configurator gsdlconfigurator, text_t &gsdlhome,
     163            text_t& collecthome, int &maxrequests)
    144164{
    145   __site_configuration sitecfg(&gsdlhome, &maxrequests);
     165  __site_configuration sitecfg(&gsdlhome, &collecthome, &maxrequests);
    146166  gsdlconfigurator.add_configurable(&sitecfg);
    147167
    148   // blank the gsdl home text
     168  // blank the gsdlhome and collecthome text
    149169  gsdlhome.clear();
     170  collecthome.clear();
    150171
    151172  if (gsdlconfigurator.configure("gsdlsite.cfg"))
     
    158179
    159180
    160 // this version grabs gsdlhome, httpdomain and httpprefix,
     181// this version grabs gsdlhome, collecthome, httpdomain and httpprefix,
    161182// returns false if it can't find all of them
    162 bool site_cfg_read (text_t &gsdlhome, text_t &httpdomain,
     183bool site_cfg_read (text_t &gsdlhome, text_t& collecthome, text_t &httpdomain,
    163184            text_t &httpprefix)
    164185{
    165186  // get gsdlhome etc
    166   __site_configuration sitecfg(&gsdlhome, &httpdomain, &httpprefix);
     187  __site_configuration sitecfg(&gsdlhome, &collecthome, &httpdomain, &httpprefix);
    167188  configurator gsdlconfigurator(&sitecfg);
    168189
    169190  gsdlhome.clear();
     191  collecthome.clear();
    170192  httpdomain.clear();
    171193  httpprefix.clear();
     
    180202
    181203
    182 // this version grabs gsdlhome, httpdomain, httpprefix, collection,
     204// this version grabs gsdlhome, collecthome, httpdomain, httpprefix, collection,
    183205// returns false if it can't find gsdlhome, httpdomain and httpprefix
    184 bool site_cfg_read (text_t &gsdlhome, text_t &httpdomain,
     206bool site_cfg_read (text_t &gsdlhome, text_t& collecthome, text_t &httpdomain,
    185207            text_t &httpprefix, text_t &collection)
    186208{
    187209  // get gsdlhome etc
    188   __site_configuration sitecfg(&gsdlhome, &httpdomain, &httpprefix, &collection);
     210  __site_configuration sitecfg(&gsdlhome, &collecthome, &httpdomain, &httpprefix, &collection);
    189211  configurator gsdlconfigurator(&sitecfg);
    190212   
    191213  gsdlhome.clear();
     214  collecthome.clear();
    192215  httpdomain.clear();
    193216  httpprefix.clear();
     
    195218   
    196219  if (gsdlconfigurator.configure("gsdlsite.cfg") &&
    197       !gsdlhome.empty() && !httpdomain.empty() && !httpprefix.empty())
     220      !gsdlhome.empty() && !collecthome.empty()
     221      && !httpdomain.empty() && !httpprefix.empty())
    198222  {
    199223    return true;
Note: See TracChangeset for help on using the changeset viewer.