Changeset 1089


Ignore:
Timestamp:
2000-04-14T14:52:06+12:00 (24 years ago)
Author:
sjboddie
Message:

tidied up error messaging and set up some debugging info to be output
when running library from command line

Location:
trunk/gsdl/src/recpt
Files:
4 edited

Legend:

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

    r963 r1089  
    2828/*
    2929   $Log$
     30   Revision 1.23  2000/04/14 02:52:05  sjboddie
     31   tidied up error messaging and set up some debugging info to be output
     32   when running library from command line
     33
    3034   Revision 1.22  2000/02/21 21:56:46  sjboddie
    3135   gsdlhome now comes from gsdlsite.cfg
     
    191195#endif
    192196
    193 
    194 static void page_errorsitecfg (text_t &errorpage, int mode) {
    195   errorpage += "Content-type: text/html\n\n";
    196 
    197   errorpage += "<html>\n";
    198   errorpage += "<head>\n";
    199   errorpage += "<title>Error</title>\n";
    200   errorpage += "</head>\n";
    201   errorpage += "<body>\n";
    202   errorpage += "<h2>Oops!</h2>\n";
     197static void format_error_string (text_t &errorpage, const text_t &errortext, bool debug) {
     198
     199  errorpage.clear();
     200
     201  if (debug) {
     202    errorpage += "\n";
     203    errorpage += "ERROR: " + errortext;
     204    errorpage += "\n";
     205   
     206  } else {
     207
     208    errorpage += "Content-type: text/html\n\n";
     209   
     210    errorpage += "<html>\n";
     211    errorpage += "<head>\n";
     212    errorpage += "<title>Error</title>\n";
     213    errorpage += "</head>\n";
     214    errorpage += "<body>\n";
     215    errorpage += "<h2>Oops!</h2>\n";
     216    errorpage += errortext;
     217    errorpage += "</body>\n";
     218    errorpage += "</html>\n";
     219  }
     220}
     221
     222static void page_errorcollect (const text_t &gsdlhome, text_t &errorpage, bool debug) {
     223
     224  text_t collectdir = filename_cat (gsdlhome, "collect");
     225
     226  text_t errortext = "No valid collections were found: Check that your collect directory\n";
     227  errortext += "(" + collectdir + ") is readable and contains at least one valid collection.\n";
     228  errortext += "Note that modelcol is NOT a valid collection.\n";
     229  errortext += "If the path to your collect directory is wrong edit the 'gsdlhome' field\n";
     230  errortext += "in your gsdlsite.cfg configuration file.\n";
     231
     232  format_error_string (errorpage, errortext, debug);
     233}
     234
     235static void page_errorsitecfg (text_t &errorpage, bool debug, int mode) {
     236
     237  text_t errortext;
     238
    203239  if (mode == 0) {
    204     errorpage += "The gsdlsite.cfg configuration file could not be found. This file\n";
    205     errorpage += "should contain configuration information relating to this\n";
    206     errorpage += "site's setup.\n";
    207     errorpage += "gsdlsite.cfg should reside in the same directory as this executable\n";
     240    errortext += "The gsdlsite.cfg configuration file could not be found. This file\n";
     241    errortext += "should contain configuration information relating to this site's setup.\n";
     242    errortext += "gsdlsite.cfg should reside in the same directory as this executable file.\n";
    208243  } else if (mode == 1) {
    209     errorpage += "The gsdlsite.cfg configuration file does not contain a valid gsdlhome\n";
    210     errorpage += "entry.\n";
    211     errorpage += "gsdlsite.cfg resides in the same directory as this executable\n";
    212   }
    213   errorpage += "</body>\n";
    214   errorpage += "</html>\n";
     244    errortext += "The gsdlsite.cfg configuration file does not contain a valid gsdlhome entry.\n";
     245    errortext += "gsdlsite.cfg resides in the same directory as this executable.\n";
     246  }
     247
     248  format_error_string (errorpage, errortext, debug);
    215249}
    216250
    217251
    218252static void page_errormaincfg (const text_t &gsdlhome, const text_t &collection,
    219                    text_t &errorpage) {
    220   errorpage += "Content-type: text/html\n\n";
    221 
    222   errorpage += "<html>\n";
    223   errorpage += "<head>\n";
    224   errorpage += "<title>Error</title>\n";
    225   errorpage += "</head>\n";
    226   errorpage += "<body>\n";
    227   errorpage += "<h2>Oops!</h2>\n";
     253                   bool debug, text_t &errorpage) {
     254
     255  text_t errortext;
     256
    228257  if (collection.empty()) {
    229258    text_t main_cfg_file = filename_cat (gsdlhome, "etc", "main.cfg");
    230     errorpage += "The main.cfg configuration file could not be found. This file\n";
    231     errorpage += "should contain configuration information relating to the\n";
    232     errorpage += "setup of the interface. As this cgi script is not being run\n";
    233     errorpage += "in collection specific mode the file should reside at\n";
    234     errorpage += main_cfg_file + ".\n";
     259    errortext += "The main.cfg configuration file could not be found. This file\n";
     260    errortext += "should contain configuration information relating to the\n";
     261    errortext += "setup of the interface. As this receptionist is not being run\n";
     262    errortext += "in collection specific mode the file should reside at\n";
     263    errortext += main_cfg_file + ".\n";
    235264  } else {
    236265    text_t collect_cfg_file = filename_cat (gsdlhome, "collect", collection, "etc", "collect.cfg");
    237266    text_t main_collect_cfg_file = filename_cat (gsdlhome, "etc", "collect.cfg");
    238267    text_t main_cfg_file = filename_cat (gsdlhome, "etc", "main.cfg");
    239     errorpage += "Either the collect.cfg or main.cfg configuration file could\n";
    240     errorpage += "not be found. This file should contain configuration information\n";
    241     errorpage += "relating to the setup of the interface. As this cgi script is\n";
    242     errorpage += "being run in collection specific mode the file should reside\n";
    243     errorpage += "at either ";
    244     errorpage += collect_cfg_file + ",\n";
    245     errorpage += main_collect_cfg_file + " or " + main_cfg_file + ".\n";
    246   }
    247   errorpage += "</body>\n";
    248   errorpage += "</html>\n";
    249 }
    250 
    251 
    252 static void page_errorinit (const text_t &gsdlhome, text_t &errorpage) {
    253   errorpage += "Content-type: text/html\n\n";
    254 
    255   errorpage += "<html>\n";
    256   errorpage += "<head>\n";
    257   errorpage += "<title>Error</title>\n";
    258   errorpage += "</head>\n";
    259   errorpage += "<body>\n";
    260   errorpage += "<h2>Oops!</h2>\n";
    261   errorpage += "An error occurred during the initialisation of the Greenstone Digital\n";
    262   errorpage += "Library software. It is likely that the software has not been setup\n";
    263   errorpage += "correctly.\n";
     268    errortext += "Either the collect.cfg or main.cfg configuration file could\n";
     269    errortext += "not be found. This file should contain configuration information\n";
     270    errortext += "relating to the setup of the interface. As this receptionist is\n";
     271    errortext += "being run in collection specific mode the file should reside\n";
     272    errortext += "at either " + collect_cfg_file + ",\n";
     273    errortext += main_collect_cfg_file + " or " + main_cfg_file + ".\n";
     274  }
     275
     276  format_error_string (errorpage, errortext, debug);
     277}
     278
     279
     280static void page_errorinit (const text_t &gsdlhome, bool debug, text_t &errorpage) {
     281
     282  text_t errortext = "An error occurred during the initialisation of the Greenstone Digital\n";
     283  errortext += "Library software. It is likely that the software has not been setup\n";
     284  errortext += "correctly.\n";
    264285
    265286  text_t init_file = filename_cat (gsdlhome, "etc", "initout.txt");
     
    268289  delete ifile;
    269290  if (initin) {
    270     errorpage += "The initialisation error log, " + init_file + ", contains the\n";
    271     errorpage += "following information:\n\n";
    272     errorpage += "<pre>\n";
     291    errortext += "The initialisation error log, " + init_file + ", contains the\n";
     292    errortext += "following information:\n\n";
     293    if (!debug) errortext += "<pre>\n";
    273294
    274295    char c;
    275296    initin.get(c);
    276297    while (!initin.eof ()) {
    277       errorpage.push_back(c);
     298      errortext.push_back(c);
    278299      initin.get(c);
    279300    }
    280301   
    281     errorpage += "</pre>\n";
     302    if (!debug) errortext += "</pre>\n";
    282303
    283304    initin.close();
    284305
    285306  } else {
    286     errorpage += "Please consult " + init_file + " for more information.\n";
    287   }
    288 
    289   errorpage += "</body>\n";
    290   errorpage += "</html>\n";
    291 }
    292 
    293 static void page_errorparseargs (const text_t &gsdlhome, text_t &errorpage) {
    294   errorpage += "Content-type: text/html\n\n";
    295 
    296   errorpage += "<html>\n";
    297   errorpage += "<head>\n";
    298   errorpage += "<title>Error</title>\n";
    299   errorpage += "</head>\n";
    300   errorpage += "<body>\n";
    301   errorpage += "<h2>Oops!</h2>\n";
    302   errorpage += "An error occurred during the parsing of the cgi arguments.\n";
     307    errortext += "Please consult " + init_file + " for more information.\n";
     308  }
     309
     310  format_error_string (errorpage, errortext, debug);
     311}
     312
     313static void page_errorparseargs (const text_t &gsdlhome, bool debug, text_t &errorpage) {
     314
     315  text_t errortext = "An error occurred during the parsing of the cgi arguments.\n";
    303316
    304317  text_t error_file = filename_cat (gsdlhome, "etc", "errout.txt");
     
    307320  delete efile;
    308321  if (errin) {
    309     errorpage += "The error log, " + error_file + ", contains the\n";
    310     errorpage += "following information:\n\n";
    311     errorpage += "<pre>\n";
     322    errortext += "The error log, " + error_file + ", contains the\n";
     323    errortext += "following information:\n\n";
     324    if (!debug) errortext += "<pre>\n";
    312325
    313326    char c;
    314327    errin.get(c);
    315328    while (!errin.eof ()) {
    316       errorpage.push_back(c);
     329      errortext.push_back(c);
    317330      errin.get(c);
    318331    }
    319     errorpage += "</pre>\n";
     332    if (!debug) errortext += "</pre>\n";
    320333    errin.close();
    321334
    322335  } else {
    323     errorpage += "Please consult " + error_file + " for more information.\n";
    324   }
    325 
    326   errorpage += "</body>\n";
    327   errorpage += "</html>\n";
    328 }
    329 
    330 static void page_errorcgipage (const text_t &gsdlhome, text_t &errorpage) {
    331   errorpage += "Content-type: text/html\n\n";
    332 
    333   errorpage += "<html>\n";
    334   errorpage += "<head>\n";
    335   errorpage += "<title>Error</title>\n";
    336   errorpage += "</head>\n";
    337   errorpage += "<body>\n";
    338   errorpage += "<h2>Oops!</h2>\n";
    339   errorpage += "An error occurred during the construction of the cgi page.\n";
    340 
     336    errortext += "Please consult " + error_file + " for more information.\n";
     337  }
     338
     339  format_error_string (errorpage, errortext, debug);
     340}
     341
     342static void page_errorcgipage (const text_t &gsdlhome, bool debug, text_t &errorpage) {
     343
     344  text_t errortext = "An error occurred during the construction of the cgi page.\n";
    341345
    342346  text_t error_file = filename_cat (gsdlhome, "etc", "errout.txt");
     
    345349  delete efile;
    346350  if (errin) {
    347     errorpage += "The error log, " + error_file + ", contains the\n";
    348     errorpage += "following information:\n\n";
    349     errorpage += "<pre>\n";
     351    errortext += "The error log, " + error_file + ", contains the\n";
     352    errortext += "following information:\n\n";
     353    if (!debug) errortext += "<pre>\n";
    350354
    351355    char c;
    352356    errin.get(c);
    353357    while (!errin.eof ()) {
    354       errorpage.push_back(c);
     358      errortext.push_back(c);
    355359      errin.get(c);
    356360    }
    357     errorpage += "</pre>\n";
     361    if (!debug) errortext += "</pre>\n";
    358362    errin.close();
    359363
    360364  } else {
    361     errorpage += "Please consult " + error_file + " for more information.\n";
    362   }
    363 
    364   errorpage += "</body>\n";
    365   errorpage += "</html>\n";
    366 }
    367 
     365    errortext += "Please consult " + error_file + " for more information.\n";
     366  }
     367
     368  format_error_string (errorpage, errortext, debug);
     369}
     370
     371static void print_debug_info (receptionist &recpt) {
     372
     373  outconvertclass text_t2ascii;
     374  recptconf configinfo = recpt.get_configinfo ();
     375  text_t etc_dir = filename_cat (configinfo.gsdlhome, "etc");
     376
     377  cout << "\n";
     378  cout << text_t2ascii
     379       << "------------------------------------------------------------\n"
     380       << "Configuration and initialization completed successfully.\n"
     381       << "  Note that more debug information may be available in the\n"
     382       << "  initialization and error logs initout.txt and errout.txt\n"
     383       << "  in " << etc_dir << ".\n"
     384       << "------------------------------------------------------------\n\n";
     385
     386  bool colspec = false;
     387  if (configinfo.collection.empty()) {
     388    cout << "Receptionist is running in general mode.\n";
     389  } else {
     390    cout << text_t2ascii
     391     << "Receptionist is running in collection specific mode.\n"
     392     << "  collection=" << configinfo.collection << "\n"
     393     << "  collection directory=" << configinfo.collectdir << "\n";
     394    colspec = true;
     395  }
     396 
     397  cout << text_t2ascii << "gsdlhome=" << configinfo.gsdlhome << "\n";
     398  if (!configinfo.gdbmhome.empty())
     399    cout << text_t2ascii << "gdbmhome=" << configinfo.gdbmhome << "\n";
     400  cout << text_t2ascii << "httpprefix=" << configinfo.httpprefix << "\n";
     401  cout << text_t2ascii << "httpimg=" << configinfo.httpimg << "\n";
     402  cout << text_t2ascii << "gwcgi=" << configinfo.gwcgi << "\n"
     403       << "  Note that unless gwcgi has been set from a configuration\n"
     404       << "  file it is dependant on environment variables set by your\n"
     405       << "  webserver. It may not therefore be the same value when run\n"
     406       << "  from the command line as it would be when run from your\n"
     407       << "  web server.\n";
     408  if (configinfo.usecookies)
     409    cout << "cookies are enabled\n";
     410  else
     411    cout << "cookies are disabled\n";
     412  if (configinfo.logcgiargs)
     413    cout << "logging is enabled\n";
     414  else
     415    cout << "logging is disabled\n";
     416  cout << "------------------------------------------------------------\n\n";
     417
     418  text_tset::const_iterator this_mfile = configinfo.macrofiles.begin();
     419  text_tset::const_iterator end_mfile = configinfo.macrofiles.end();
     420  cout << "Macro Files:\n"
     421       << "------------\n";
     422  text_t mfile;
     423  bool found;
     424  while (this_mfile != end_mfile) {
     425    cout << text_t2ascii << *this_mfile;
     426    int spaces = (22 - (*this_mfile).size());
     427    if (spaces < 2) spaces = 2;
     428    text_t outspaces;
     429    for (int i = 0; i < spaces; i++) outspaces.push_back (' ');
     430    cout << text_t2ascii << outspaces;
     431
     432    found = false;
     433    if (colspec) {
     434      // collection specific - try collectdir/macros first
     435      mfile = filename_cat (configinfo.collectdir, "macros", *this_mfile);
     436      if (file_exists (mfile)) {
     437    cout << text_t2ascii << "found (" << mfile << ")\n";
     438    found = true;
     439      }
     440    }
     441 
     442    if (!found) {
     443      // try main macro directory
     444      mfile = filename_cat (configinfo.gsdlhome, "macros", *this_mfile);
     445      if (file_exists (mfile)) {
     446    cout << text_t2ascii << "found (" << mfile << ")\n";
     447    found = true;
     448      }
     449    }
     450
     451    if (!found)
     452      cout << text_t2ascii << "NOT FOUND\n";
     453
     454    this_mfile ++;
     455  }
     456
     457  cout << "------------------------------------------------------------\n\n"
     458       << "Collections:\n"
     459       << "------------\n"
     460       << "  Note that collections will only appear as being built if\n"
     461       << "  their build.cfg files exist, are readable, contain a valid\n"
     462       << "  builddate field (i.e. > 0), and are in the collection's\n"
     463       << "  index directory (i.e. NOT the building directory)\n\n";
     464
     465  recptprotolistclass *protos = recpt.get_recptprotolist_ptr();
     466  recptprotolistclass::iterator rprotolist_here = protos->begin();
     467  recptprotolistclass::iterator rprotolist_end = protos->end();
     468  while (rprotolist_here != rprotolist_end) {
     469    if ((*rprotolist_here).p != NULL) {
     470
     471      text_tarray collist;
     472      comerror_t err;
     473      (*rprotolist_here).p->get_collection_list (collist, err, cerr);
     474      if (err == noError) {
     475    text_tarray::iterator collist_here = collist.begin();
     476    text_tarray::iterator collist_end = collist.end();
     477
     478    while (collist_here != collist_end) {
     479     
     480      cout << text_t2ascii << *collist_here;
     481
     482      int spaces = (22 - (*collist_here).size());
     483      if (spaces < 2) spaces = 2;
     484      text_t outspaces;
     485      for (int i = 0; i < spaces; i++) outspaces.push_back (' ');
     486      cout << text_t2ascii << outspaces;
     487
     488      ColInfoResponse_t cinfo;
     489      (*rprotolist_here).p->get_collectinfo (*collist_here, cinfo, err, cerr);
     490      if (err == noError) {
     491        if (cinfo.isPublic) cout << "public ";
     492        else cout << "private";
     493
     494        if (cinfo.buildDate > 0) cout << "   built            ";
     495        else cout << "   requires building";
     496      }
     497
     498      cout << "\n";
     499
     500      collist_here ++;
     501    }
     502      }
     503    }
     504    rprotolist_here ++;
     505  }
     506 
     507  cout << "------------------------------------------------------------\n";
     508  cout << "------------------------------------------------------------\n\n";
     509  cout << "receptionist running in command line debug mode\n";
     510  cout << "enter cgi arguments as name=value pairs (e.g. 'a=p&p=home'):\n";
     511
     512}
    368513
    369514// cgiwrapper does everything necessary to output a page
     
    372517// should equal "".
    373518void cgiwrapper (receptionist &recpt, text_t collection) {
     519 
     520  int numrequests = 0;
     521  bool debug = false;
     522  recptconf configinfo = recpt.get_configinfo ();
     523
     524  // find out whether this is being run as a cgi-script
     525  // or a fastcgi script
    374526#ifdef USE_FASTCGI
    375527  fcgistreambuf outbuf;
    376 #endif
    377 
    378   // init stuff - we can't output error pages directly with
    379   // fastcgi so the pages are stored until we can output them
    380   text_t errorpage;
    381   outconvertclass text_t2ascii;
    382 
    383   // set defaults
    384   int maxrequests = 10000;
    385   recpt.configure ("collection", collection);
    386   recpt.configure ("httpimg", "/gsdl/images");
    387   char *script_name = getenv("SCRIPT_NAME");
    388   if (script_name != NULL) recpt.configure("gwcgi", script_name);
    389   else recpt.configure("gwcgi", "/cgi-bin/gw");
    390 
    391   // read in the configuration files.
    392   text_t gsdlhome;
    393   if (!site_cfg_read (recpt, gsdlhome, maxrequests)) {
    394     // couldn't find the site configuration file
    395     page_errorsitecfg (errorpage, 0);
    396   } else if (gsdlhome.empty()) {
    397     // no gsdlhome in gsdlsite.cfg
    398     page_errorsitecfg (errorpage, 1);
    399   } else if (!main_cfg_read (recpt, gsdlhome, collection)) {
    400     // couldn't find the main configuration file
    401     page_errormaincfg (gsdlhome, collection, errorpage);
    402   }
    403 
    404   // initialise the library software
    405   if (errorpage.empty()) {
    406     text_t init_file = filename_cat (gsdlhome, "etc", "initout.txt");
    407     char *iout = init_file.getcstr();
    408     ofstream initout (iout);
    409     delete iout;
    410     if (!recpt.init(initout)) {
    411       // an error occurred during the initialisation
    412       initout.close();
    413       page_errorinit(gsdlhome, errorpage);
    414     }
    415     initout.close();
    416   }
    417  
    418   // find out whether this is being run as a cgi-script
    419   // or a fastcgi script
    420   int numrequests = 0;
    421 #ifdef USE_FASTCGI
    422528  int isfastcgi = !FCGX_IsCGI();
    423529  FCGX_Stream *fcgiin, *fcgiout, *fcgierr;
     
    457563      } else {
    458564    // debugging from command line
    459     char cinURIStr[1024];
    460     cin.get(cinURIStr, 1024);
    461     argstr = cinURIStr;
     565    debug = true;
    462566      }
    463567    }
    464 
    465     // cgi scripts only deal with one request
    466     maxrequests = 1;
    467   }
     568  }
     569
     570  if (debug) cout << "Configuring Greenstone...\n";
     571
     572
     573  // init stuff - we can't output error pages directly with
     574  // fastcgi so the pages are stored until we can output them
     575  text_t errorpage;
     576  outconvertclass text_t2ascii;
     577
     578  // set defaults
     579  int maxrequests = 10000;
     580  recpt.configure ("collection", collection);
     581  recpt.configure ("httpimg", "/gsdl/images");
     582  char *script_name = getenv("SCRIPT_NAME");
     583  if (script_name != NULL) recpt.configure("gwcgi", script_name);
     584  else recpt.configure("gwcgi", "/cgi-bin/gw");
     585
     586  // read in the configuration files.
     587  text_t gsdlhome;
     588  if (!site_cfg_read (recpt, gsdlhome, maxrequests)) {
     589    // couldn't find the site configuration file
     590    page_errorsitecfg (errorpage, debug, 0);
     591  } else if (gsdlhome.empty()) {
     592    // no gsdlhome in gsdlsite.cfg
     593    page_errorsitecfg (errorpage, debug, 1);
     594  } else if (!main_cfg_read (recpt, gsdlhome, collection)) {
     595    // couldn't find the main configuration file
     596    page_errormaincfg (gsdlhome, collection, debug, errorpage);
     597  } else  if (configinfo.collectinfo.empty()) {
     598    // don't have any collections
     599    page_errorcollect (gsdlhome, errorpage, debug);
     600  }
     601
     602  if (errorpage.empty()) {
     603
     604    // initialise the library software
     605    if (debug) cout << "Initializing...\n";
     606
     607    text_t init_file = filename_cat (gsdlhome, "etc", "initout.txt");
     608    char *iout = init_file.getcstr();
     609    ofstream initout (iout);
     610    delete iout;
     611    if (!recpt.init(initout)) {
     612      // an error occurred during the initialisation
     613      initout.close();
     614      page_errorinit(gsdlhome, debug, errorpage);
     615    }
     616    initout.close();
     617  }
     618
     619  if (debug && errorpage.empty()) {
     620    // get query string from command line
     621    print_debug_info (recpt);
     622    char cinURIStr[1024];
     623    cin.get(cinURIStr, 1024);
     624    argstr = cinURIStr;
     625  }
     626
     627  // cgi scripts only deal with one request
     628  if (!isfastcgi) maxrequests = 1;
    468629
    469630  // Page-request loop. If this is not being run as a fastcgi
     
    536697      if (!recpt.parse_cgi_args (argstr, args, errout, fastcgienv)) {
    537698    errout.close ();
    538     page_errorparseargs(gsdlhome, errorpage);
     699    page_errorparseargs(gsdlhome, debug, errorpage);
    539700      } else {
    540701    if (!recpt.produce_cgi_page (args, pageout, errout, fastcgienv)) {
    541702      errout.close ();
    542       page_errorcgipage(gsdlhome, errorpage);
    543     } else {
    544       errout.close ();
     703      page_errorcgipage(gsdlhome, debug, errorpage);
    545704    }
    546705    recpt.log_cgi_args (args, errout, fastcgienv);
     706    errout.close ();
    547707      }
    548708    }
  • trunk/gsdl/src/recpt/librarymain.cpp

    r994 r1089  
    2828/*
    2929   $Log$
     30   Revision 1.25  2000/04/14 02:52:05  sjboddie
     31   tidied up error messaging and set up some debugging info to be output
     32   when running library from command line
     33
    3034   Revision 1.24  2000/02/29 20:59:02  sjboddie
    3135   added error message when unable to read from collect directory - should
     
    132136#include "authenaction.h"
    133137#include "usersaction.h"
    134 #include "authenaction.h"
    135138#include "extlinkaction.h"
    136139#include "buildaction.h"
     
    152155  text_tarray collections;
    153156
    154   // get gsdlhome (if we fail the error will be picked up later -- in
    155   // cgiwrapper)
     157  // get gsdlhome
    156158  text_t gsdlhome;
    157   if (site_cfg_read (gsdlhome)) {
    158     text_t collectdir = filename_cat (gsdlhome, "collect");
    159     if (!read_dir (collectdir, collections)) {
    160       cerr << "couldn't read collect directory - make sure gsdlhome field is correct in gsdlsite.cfg\n";
    161       exit (1);
    162     }
    163   }
     159  site_cfg_read (gsdlhome);
     160  text_t collectdir = filename_cat (gsdlhome, "collect");
     161  read_dir (collectdir, collections);
    164162
    165163  text_tarray::const_iterator thiscol = collections.begin();
     
    202200    // collection name
    203201    cserver->configure ("collection", *thiscol);
    204    
     202 
     203    // configure receptionist's collectinfo structure
     204    text_tarray colinfo;
     205    colinfo.push_back (*thiscol);
     206    colinfo.push_back (gsdlhome);
     207    colinfo.push_back (gsdlhome);
     208    recpt.configure ("collectinfo", colinfo);
     209 
    205210    nproto.add_collectserver (cserver);
    206211    thiscol ++;
  • trunk/gsdl/src/recpt/receptionist.cpp

    r950 r1089  
    2828/*
    2929   $Log$
     30   Revision 1.48  2000/04/14 02:52:06  sjboddie
     31   tidied up error messaging and set up some debugging info to be output
     32   when running library from command line
     33
    3034   Revision 1.47  2000/02/17 22:26:17  sjboddie
    3135   set macros for displaying macrons in utf8
     
    10051009  text_t colmacrodir = filename_cat (configinfo.collectdir, "macros");
    10061010
    1007   text_tarray maindirs;
     1011  text_tset maindirs;
    10081012  text_t gsdlmacrodir = filename_cat (configinfo.gsdlhome, "macros");
    1009   maindirs.push_back (gsdlmacrodir);
     1013  maindirs.insert (gsdlmacrodir);
    10101014  colinfo_tmap::iterator colhere = configinfo.collectinfo.begin();
    10111015  colinfo_tmap::iterator colend = configinfo.collectinfo.end();
    10121016  while (colhere != colend) {
    10131017    gsdlmacrodir = filename_cat ((*colhere).second.gsdl_gsdlhome, "macros");
    1014     maindirs.push_back (gsdlmacrodir);
     1018    maindirs.insert (gsdlmacrodir);
    10151019    colhere ++;
    10161020  }
     
    10371041    // we'll load all copies
    10381042    if (!foundfile) {
    1039       text_tarray::const_iterator dirhere = maindirs.begin();
    1040       text_tarray::const_iterator dirend = maindirs.end();
     1043      text_tset::const_iterator dirhere = maindirs.begin();
     1044      text_tset::const_iterator dirend = maindirs.end();
    10411045      while (dirhere != dirend) {
    10421046    filename = filename_cat (*dirhere, *arrhere);
  • trunk/gsdl/src/recpt/recptconfig.cpp

    r963 r1089  
    2828/*
    2929   $Log$
     30   Revision 1.7  2000/04/14 02:52:06  sjboddie
     31   tidied up error messaging and set up some debugging info to be output
     32   when running library from command line
     33
    3034   Revision 1.6  2000/02/21 21:55:33  sjboddie
    3135   gsdlhome now comes from gsdlsite.cfg
     
    105109}
    106110
    107 // this version just grabs gsdlhome, returns false if it can't find it
     111// this version just grabs gsdlhome, returning true
     112// unless unable to read gsdlsite.cfg
    108113bool site_cfg_read (text_t &gsdlhome) {
    109114
     
    120125    if (cfgline[0] == "gsdlhome") {
    121126      gsdlhome = cfgline[1];
    122       return true;
    123     }
    124       }
    125     }
     127      break;
     128    }
     129      }
     130    }
     131    return true;
    126132    confin.close ();
    127133  }
Note: See TracChangeset for help on using the changeset viewer.