Changeset 1739


Ignore:
Timestamp:
2000-12-05T13:08:17+13:00 (23 years ago)
Author:
sjboddie
Message:

A few changes to get multi-volume cd-roms working again

Location:
trunk/gsdl
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/cfgread.cpp

    r1432 r1739  
    4949    filein.get(c);
    5050  }
    51   if (key.empty()) return -1;
     51  if (key.empty()) return 0; // blank line maybe?
    5252  return 0;
    5353}
  • trunk/gsdl/lib/fileutil.cpp

    r1648 r1739  
    170170}
    171171
     172bool read_dir (const text_t &dirname, text_tset &filelist) {
     173 
     174  WIN32_FIND_DATA FileData; 
     175  HANDLE hSearch;
     176  char *dirpath = dirname.getcstr();
     177  strcat (dirpath, "\\*");
     178 
     179  hSearch = FindFirstFile(dirpath, &FileData);
     180  // freeing this memory can cause a runtime error on some (particularly
     181  // debug) versions of VC++
     182  delete dirpath;
     183 
     184  if (hSearch == INVALID_HANDLE_VALUE) {
     185    return false;
     186  }
     187 
     188  text_t filename = FileData.cFileName;
     189  if (filename != "." && filename != ".." && filename != "CVS")
     190    filelist.insert (filename);
     191 
     192  while (FindNextFile(hSearch, &FileData)) {
     193    filename = FileData.cFileName;
     194    if (filename == "." || filename == ".." || filename == "CVS")
     195      continue;
     196    filelist.insert (filename);
     197  }
     198 
     199  FindClose(hSearch);
     200 
     201  return true;
     202}
     203
    172204bool read_dir (const text_t &dirname, text_tarray &filelist) {
    173205 
     
    217249}
    218250
     251bool read_dir (const text_t &dirname, text_tset &filelist) {
     252 
     253  char *tmp = dirname.getcstr();
     254  DIR *dirin = opendir (tmp);
     255  delete tmp;
     256 
     257  if (dirin == NULL) return false;
     258 
     259  dirent *dirp;
     260 
     261  text_t filename;
     262  while ((dirp = readdir (dirin)) != NULL) {
     263    filename = dirp->d_name;
     264    if (filename == "." || filename == ".." || filename == "CVS")
     265      continue;
     266    filelist.insert (filename);
     267  }
     268  closedir (dirin);
     269  return true;
     270}
     271
    219272bool read_dir (const text_t &dirname, text_tarray &filelist) {
    220  
    221   filelist.erase (filelist.begin(), filelist.end());
    222273 
    223274  char *tmp = dirname.getcstr();
  • trunk/gsdl/lib/fileutil.h

    r1485 r1739  
    4949bool directory_exists (const text_t &dirname);
    5050
     51// note that read_dir appends to filelist, it doesn't clear
     52// it first
    5153bool read_dir (const text_t &dirname, text_tarray &filelist);
     54bool read_dir (const text_t &dirname, text_tset &filelist);
    5255
    5356bool file_copy (const text_t &fromfile, const text_t &tofile);
  • trunk/gsdl/src/recpt/nullproto.h

    r1679 r1739  
    4141  // add_collection sets up the collectionserver and calls
    4242  // add_collectserver
    43   void add_collection (const text_t &collection, void *recpt,
    44                const text_t &gsdlhome, const text_t &gdbmhome);
     43  virtual void add_collection (const text_t &collection, void *recpt,
     44                   const text_t &gsdlhome, const text_t &gdbmhome);
    4545
    4646  // add_collectserver should be called for each collection server
  • trunk/gsdl/src/w32server/cgiwrapper.cpp

    r1679 r1739  
    187187DWORD lastlibaccesstime;
    188188DWORD baseavailvirtual;
     189text_t current_gsdlhome;
     190colinfo_tmap translated_collectinfo;
    189191
    190192static void page_errormaincfg (const text_t &gsdlhome, const text_t &collection) {
     
    351353  text_t collection = "";
    352354  text_tset gsdlhomes;
    353   text_tarray collections;
    354   colinfo_tmap::const_iterator this_info = gsdl_collectinfo.begin();
    355   colinfo_tmap::const_iterator end_info = gsdl_collectinfo.end();
     355  text_tset collections;
    356356
    357357  // note the current time
     
    363363  if (!checkdir (gsdl_gsdlhome + "\\macros\\")) return 0;
    364364
    365   if (collection.empty()) {
    366 
    367     // get all collections from each gsdlhome (this relies
    368     // on there not being more than one collection with the same
    369     // name)
    370     read_dir (filename_cat (gsdl_gsdlhome, "collect"), collections);
     365  // get all collections from each gsdlhome (this relies
     366  // on there not being more than one collection with the same
     367  // name)
     368
     369  if (!collection.empty()) {
     370    // collection specific receptionist - one collection, one gsdlhome
     371    collections.insert (collection);
    371372    gsdlhomes.insert (gsdl_gsdlhome);
     373    collectioninfo_t tmp;
     374    tmp.gsdl_gsdlhome = gsdl_gsdlhome;
     375    tmp.gsdl_gdbmhome = gsdl_gdbmhome;
     376    translated_collectinfo[collection] = tmp;
     377
     378  } else {
     379
     380    text_tset::const_iterator colhere;
     381    text_tset::const_iterator colend;
     382    text_tset these_collections;
     383
     384    // first volume gsdlhome's
     385    colinfo_tmap::const_iterator this_info = gsdl_collectinfo.begin();
     386    colinfo_tmap::const_iterator end_info = gsdl_collectinfo.end();
    372387    while (this_info != end_info) {
    373388      if (gsdlhomes.find ((*this_info).second.gsdl_gsdlhome) == gsdlhomes.end()) {
    374     read_dir (filename_cat ((*this_info).second.gsdl_gsdlhome, "collect"), collections);
     389    these_collections.erase (these_collections.begin(), these_collections.end());
     390    read_dir (filename_cat ((*this_info).second.gsdl_gsdlhome, "collect"), these_collections);
     391    colhere = these_collections.begin();
     392    colend = these_collections.end();
     393    while (colhere != colend) {
     394      if ((collections.find (*colhere)) == collections.end()) {
     395        // make sure the build.cfg file is at gsdlhome (as it's possible that
     396        // the collection appears at this gsdlhome only because it's gdbm
     397        // file is installed here -- it's real gdbm will therefore be
     398        // somewhere else).
     399        text_t build_cfg = filename_cat ((*this_info).second.gsdl_gsdlhome, "collect",
     400                         *colhere, "index", "build.cfg");
     401        if (file_exists (build_cfg)) {
     402          collections.insert (*colhere);
     403
     404          // since gsdl_collectinfo keys will be stuff like collection#1
     405          // for a multiple volume collection we want to translate it
     406          // so that the keys are the actual collection names
     407          translated_collectinfo[*colhere] = (*this_info).second;
     408        }
     409      }
     410      colhere ++;
     411    }
    375412    gsdlhomes.insert ((*this_info).second.gsdl_gsdlhome);
    376413      }
    377414      this_info ++;
    378415    }
    379   } else {
    380     collections.push_back (collection);
    381     gsdlhomes.insert (gsdl_gsdlhome);
    382   }
    383  
    384   text_tarray::const_iterator thiscol = collections.begin();
    385   text_tarray::const_iterator endcol = collections.end();
     416 
     417    // then if necessary the main gsdlhome (this should only happen if the
     418    // gsdl.ini is a little screwed up and no volume gsdlhomes occurred
     419    if (gsdlhomes.find (gsdl_gsdlhome) == gsdlhomes.end()) {
     420      these_collections.erase (these_collections.begin(), these_collections.end());
     421      read_dir (filename_cat (gsdl_gsdlhome, "collect"), these_collections);
     422      colhere = these_collections.begin();
     423      colend = these_collections.end();
     424      while (colhere != colend) {
     425    collections.insert (*colhere);
     426    collectioninfo_t tmp;
     427    tmp.gsdl_gsdlhome = gsdl_gsdlhome;
     428    tmp.gsdl_gdbmhome = gsdl_gdbmhome;
     429    translated_collectinfo[*colhere] = tmp;
     430    colhere ++;
     431      }
     432      gsdlhomes.insert (gsdl_gsdlhome);
     433    }
     434  }
     435
     436  text_tset::const_iterator thiscol = collections.begin();
     437  text_tset::const_iterator endcol = collections.end();
    386438
    387439  while (thiscol != endcol) {
     
    394446   
    395447    // create collection server and add to null protocol
    396     nproto.add_collection (*thiscol, &recpt, gsdl_gsdlhome, gsdl_gsdlhome);
     448    text_t this_gsdlhome = gsdl_gsdlhome;
     449    text_t this_gdbmhome = gsdl_gdbmhome;
     450    colinfo_tmap::const_iterator it = translated_collectinfo.find (*thiscol);
     451    assert (it != translated_collectinfo.end());
     452    this_gsdlhome = (*it).second.gsdl_gsdlhome;
     453    this_gdbmhome = (*it).second.gsdl_gdbmhome;
     454
     455    nproto.add_collection (*thiscol, &recpt, this_gsdlhome, this_gdbmhome);
    397456   
    398457    thiscol ++;
     
    479538
    480539  int maxrequests = 1;
    481   text_tset seenhomes;
    482   this_info = gsdl_collectinfo.begin();
    483 
    484   // configure any collections with gsdlhome (or gdbmhome)
     540
     541  // configure collections (and receptionist) with collectinfo stuff
    485542  // different from the default
     543  colinfo_tmap::const_iterator this_info = translated_collectinfo.begin();
     544  colinfo_tmap::const_iterator end_info = translated_collectinfo.end();
     545
    486546  while (this_info != end_info) {
    487     if (((*this_info).second.gsdl_gsdlhome != gsdl_gsdlhome) ||
    488     ((*this_info).second.gsdl_gdbmhome != gsdl_gdbmhome) &&
    489     (seenhomes.find ((*this_info).second.gsdl_gsdlhome +
    490              (*this_info).second.gsdl_gdbmhome) == seenhomes.end())) {
    491       text_tarray tmpconf;
    492       tmpconf.push_back ((*this_info).first);
    493       tmpconf.push_back ((*this_info).second.gsdl_gsdlhome);
    494       tmpconf.push_back ((*this_info).second.gsdl_gdbmhome);
    495       recpt.configure ("collectinfo", tmpconf);
    496       seenhomes.insert ((*this_info).second.gsdl_gsdlhome +
    497             (*this_info).second.gsdl_gdbmhome);
    498     }
     547    text_tarray tmpconf;
     548    tmpconf.push_back ((*this_info).first);
     549    tmpconf.push_back ((*this_info).second.gsdl_gsdlhome);
     550    tmpconf.push_back ((*this_info).second.gsdl_gdbmhome);
     551    recpt.configure ("collectinfo", tmpconf);
    499552    this_info ++;
    500553  }
     
    563616
    564617  // set up file name
    565   text_t filenamet = text_t(gsdl_gsdlhome) + filename;
    566   text_t::iterator here = filenamet.begin();
    567   text_t::iterator end = filenamet.end();
    568   while (here != end) {
    569       if (*here == '/') *here = '\\';
    570       here ++;
    571   }
    572 
     618  text_t filenamet = filename_cat (current_gsdlhome, filename);
    573619  filename = filenamet.getcstr();
    574620   
     
    613659    return;
    614660  }
    615  
     661
     662  colinfo_tmap::const_iterator it = translated_collectinfo.find (args["c"]);
     663  if (it != translated_collectinfo.end()) {
     664    current_gsdlhome = (*it).second.gsdl_gsdlhome;
     665  } else {
     666    current_gsdlhome = gsdl_gsdlhome;
     667  }
     668
    616669  // produce cgi header
    617670  response_t response;
  • trunk/gsdl/src/w32server/cgiwrapper.h

    r1284 r1739  
    3434extern int libaccessnum;
    3535
    36 //void configure_httpprefix ();
    37 
    3836int ExamineURIStr(char *URIStr,RequestInfoT *RequestInfo,
    3937          RequestFieldsT *RequestFields);
  • trunk/gsdl/src/w32server/settings.cpp

    r1203 r1739  
    376376  if (conf) {
    377377    while (read_ini_line(conf, key, value) >= 0) {
     378      if (key.empty()) continue;
    378379      if (value.empty()) {
    379380    // should be a section title
Note: See TracChangeset for help on using the changeset viewer.