Ignore:
Timestamp:
2000-02-22T11:01:02+13:00 (24 years ago)
Author:
sjboddie
Message:

gsdlhome now comes from gsdlsite.cfg

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/recpt/recptconfig.cpp

    r533 r963  
    2828/*
    2929   $Log$
     30   Revision 1.6  2000/02/21 21:55:33  sjboddie
     31   gsdlhome now comes from gsdlsite.cfg
     32
    3033   Revision 1.5  1999/09/07 04:56:59  sjboddie
    3134   added GPL notice
     
    6770
    6871// reads site configuration file returning true on success
    69 bool site_cfg_read (receptionist &recpt, const text_t &gsdlhome,
    70              const text_t &collection, int &maxrequests) {
     72// also sets gsdlhome and maxrequests
     73// gsdlsite.cfg should be in same directory as library executable
     74bool site_cfg_read (receptionist &recpt, text_t &gsdlhome, int &maxrequests) {
    7175
    72   maxrequests = 10000; // a reasonable default
     76  gsdlhome.clear();
    7377
    74   // Look for site.cfg in GSDLHOME/collect/collection-name/etc directory
    75   // (if this is for a particular collection), and then GSDLHOME/etc.
    76   text_t filename;
    77   if (!collection.empty()) {
    78     filename = filename_cat (gsdlhome, "collect");
    79     filename = filename_cat (filename, collection);
    80     filename = filename_cat (filename, "etc");
    81     filename = filename_cat (filename, "site.cfg");
    82     if (!file_exists (filename)) filename.clear();
    83   }
    84   if (filename.empty()) {
    85     filename = filename_cat (gsdlhome, "etc");
    86     filename = filename_cat (filename, "site.cfg");
    87     if (!file_exists (filename)) return false;
    88   }
    89 
    90   // read in the site configuration file
     78  // Look for gsdlsite.cfg in same directory that executable is in.
    9179  text_tarray cfgline;
    9280  text_t key;
    93   char *cstr = filename.getcstr();
    94   ifstream confin (cstr);
    95   delete cstr;
     81  ifstream confin ("gsdlsite.cfg");
    9682
    9783  if (confin) {
     
    10086    key = cfgline[0];
    10187    cfgline.erase(cfgline.begin());
    102 
     88   
    10389    if (key == "maxrequests") {
    10490      maxrequests = cfgline[0].getint();
    10591      if (maxrequests < 1) maxrequests = 1;
    10692    }
     93
     94    if (key == "gsdlhome")
     95      gsdlhome = cfgline[0];
    10796
    10897    // configure the receptionist
     
    116105}
    117106
     107// this version just grabs gsdlhome, returns false if it can't find it
     108bool site_cfg_read (text_t &gsdlhome) {
     109
     110  gsdlhome.clear();
     111
     112  // Look for gsdlsite.cfg in same directory that executable is in.
     113  text_tarray cfgline;
     114  text_t key;
     115  ifstream confin ("gsdlsite.cfg");
     116
     117  if (confin) {
     118    while (read_cfg_line(confin, cfgline) >= 0) {
     119      if (cfgline.size () >= 2) {
     120    if (cfgline[0] == "gsdlhome") {
     121      gsdlhome = cfgline[1];
     122      return true;
     123    }
     124      }
     125    }
     126    confin.close ();
     127  }
     128  return false;
     129}
    118130
    119131// main_cfg_read reads both main.cfg and collect.cfg. It attempts
Note: See TracChangeset for help on using the changeset viewer.