Changeset 532 for trunk/gsdl/src


Ignore:
Timestamp:
1999-09-07T12:09:31+12:00 (25 years ago)
Author:
sjboddie
Message:

now reads in both main.cfg and collect.cfg always

File:
1 edited

Legend:

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

    r165 r532  
    1212/*
    1313   $Log$
     14   Revision 1.4  1999/09/07 00:09:31  sjboddie
     15   now reads in both main.cfg and collect.cfg always
     16
    1417   Revision 1.3  1999/02/21 22:33:57  rjmcnab
    1518
     
    9598
    9699
    97 // main_cfg_read reads either collect.cfg or main.cfg and returning
    98 // true on success. It attempts to read collect.cfg first if a
    99 // collection is specified and then it tries to read in main.cfg
     100// main_cfg_read reads both main.cfg and collect.cfg. It attempts
     101// to read main.cfg first so values in collect.cfg override those
     102// set earlier by main.cfg
    100103bool main_cfg_read (receptionist &recpt, const text_t &gsdlhome,
    101104             const text_t &collection) {
    102   // Look for site.cfg in GSDLHOME/collect/collection-name/etc directory
     105
     106  // read in the main configuration file
     107  bool rv = false;
     108  text_t key, filename;
     109  text_tarray cfgline;
     110  filename = filename_cat (gsdlhome, "etc");
     111  filename = filename_cat (filename, "main.cfg");
     112  if (file_exists (filename)) {
     113    char *cstr = filename.getcstr();
     114    ifstream confin (cstr);
     115    delete cstr;
     116 
     117    if (confin) {
     118      while (read_cfg_line(confin, cfgline) >= 0) {
     119    if (cfgline.size () >= 2) {
     120      key = cfgline[0];
     121      cfgline.erase(cfgline.begin());
     122   
     123      // configure the receptionist
     124      recpt.configure (key, cfgline);
     125    }
     126      }
     127      confin.close ();
     128      rv = true;
     129    }
     130  }
     131 
     132  // Look for collect.cfg in GSDLHOME/collect/collection-name/etc directory
    103133  // (if this is for a particular collection), and then GSDLHOME/etc.
    104   text_t filename;
    105134  if (!collection.empty()) {
    106135    filename = filename_cat (gsdlhome, "collect");
     
    113142      if (!file_exists (filename)) filename.clear();
    114143    }
    115   }
    116   if (filename.empty()) {
    117     filename = filename_cat (gsdlhome, "etc");
    118     filename = filename_cat (filename, "main.cfg");
    119     if (!file_exists (filename)) return false;
    120   }
    121144
    122   // read in the main configuration file
    123   text_t key;
    124   text_tarray cfgline;
    125   char *cstr = filename.getcstr();
    126   ifstream confin (cstr);
    127   delete cstr;
    128 
    129   if (confin) {
    130     while (read_cfg_line(confin, cfgline) >= 0) {
    131       if (cfgline.size () >= 2) {
    132     key = cfgline[0];
    133     cfgline.erase(cfgline.begin());
    134 
    135     // configure the receptionist
    136     recpt.configure (key, cfgline);
     145    if (!filename.empty()) {
     146      char *cstr = filename.getcstr();
     147      ifstream confin (cstr);
     148      delete cstr;
     149     
     150      if (confin) {
     151    while (read_cfg_line(confin, cfgline) >= 0) {
     152      if (cfgline.size () >= 2) {
     153        key = cfgline[0];
     154        cfgline.erase(cfgline.begin());
     155       
     156        // configure the receptionist
     157        recpt.configure (key, cfgline);
     158      }
     159    }
     160    confin.close ();
     161    rv = true;
    137162      }
    138163    }
    139     confin.close ();
    140     return true;
    141164  }
    142   return false;
     165  return rv;
    143166}
Note: See TracChangeset for help on using the changeset viewer.