Changeset 902

Show
Ignore:
Timestamp:
03.02.2000 14:45:48 (20 years ago)
Author:
sjboddie
Message:

lots of stuff

Location:
trunk/gsdl/src/w32server
Files:
8 modified

Legend:

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

    r611 r902  
    99#include "wincgiutils.h" 
    1010#include "settings.h" 
     11#include "fileutil.h" 
    1112 
    1213#include "gsdlconf.h" 
     
    3132#include "mggdbmsource.h" 
    3233 
    33  
    3434// actions 
     35#include "action.h" 
     36#include "statusaction.h" 
    3537#include "pageaction.h" 
    3638#include "pingaction.h" 
    3739#include "queryaction.h" 
    3840#include "documentaction.h" 
    39 #include "statusaction.h" 
     41#include "authenaction.h" 
    4042#include "usersaction.h" 
    41 #include "authenaction.h" 
    42 #include "tipaction.h" 
     43#include "extlinkaction.h" 
     44//#include "buildaction.h" 
     45 
     46// browsers 
     47#include "browserclass.h" 
     48#include "vlistbrowserclass.h" 
     49#include "hlistbrowserclass.h" 
     50#include "datelistbrowserclass.h" 
     51#include "invbrowserclass.h" 
     52#include "pagedbrowserclass.h" 
     53#include "htmlbrowserclass.h" 
    4354 
    4455// filters 
     
    115126 
    116127int logstreambuf::sync () { 
    117   if (gs_keep_log || gs_show_console) { 
     128  if (gsdl_keep_log || gsdl_show_console) { 
    118129    log_message ("LOCAL LIB MESSAGE: "); 
    119130        log_message_N (pbase(), out_waiting()); 
     
    143154DWORD lastlibaccesstime; 
    144155DWORD baseavailvirtual; 
    145  
    146156 
    147157static void page_errorsitecfg (const text_t &gsdlhome, const text_t &collection) { 
     
    318328  cerr = &logstream; 
    319329  cout = &textstream; 
    320    
     330 
    321331  // collection should be set to "" unless in  
    322332  // collection specific mode 
    323333  text_t collection = ""; 
     334  text_tset gsdlhomes; 
     335  text_tarray collections; 
     336  colinfo_tmap::const_iterator this_info = gsdl_collectinfo.begin(); 
     337  colinfo_tmap::const_iterator end_info = gsdl_collectinfo.end(); 
    324338 
    325339  // note the current time 
    326340  lastlibaccesstime = GetTickCount(); 
    327    
     341 
    328342  // before we do the init we should make sure 
    329343  // that we can find the relevant directories 
    330   if (!checkdir (GSDL_GSDLHOME "\\")) return 0; 
    331   if (!checkdir (GSDL_GSDLHOME "\\macros\\")) return 0; 
    332    
    333   // add a collection server for each collection 
    334   text_tarray collections; 
    335   ifstream collist (GSDL_GSDLHOME "/etc/collections.txt"); 
    336   if (!collist) { 
    337     exit(1); 
    338   } 
    339   char col[100]; 
    340   while (!collist.eof()) { 
    341     collist.getline (col, 100); 
    342     if (col[0] != '\0') 
    343       collections.push_back (col); 
    344   } 
    345   collist.close(); 
    346  
     344  if (!checkdir (gsdl_gsdlhome + "\\")) return 0; 
     345  if (!checkdir (gsdl_gsdlhome + "\\macros\\")) return 0; 
     346 
     347  if (collection.empty()) { 
     348 
     349    // get all collections from each gsdlhome (this relies  
     350    // on there not being more than one collection with the same  
     351    // name) 
     352    read_dir (filename_cat (gsdl_gsdlhome, "collect"), collections); 
     353    gsdlhomes.insert (gsdl_gsdlhome); 
     354    while (this_info != end_info) { 
     355      if (gsdlhomes.find ((*this_info).second.gsdl_gsdlhome) == gsdlhomes.end()) { 
     356    read_dir (filename_cat ((*this_info).second.gsdl_gsdlhome, "collect"), collections); 
     357    gsdlhomes.insert ((*this_info).second.gsdl_gsdlhome); 
     358      } 
     359      this_info ++; 
     360    } 
     361  } else { 
     362    collections.push_back (collection); 
     363  } 
     364   
    347365  text_tarray::const_iterator thiscol = collections.begin(); 
    348366  text_tarray::const_iterator endcol = collections.end(); 
    349    
     367 
    350368  while (thiscol != endcol) { 
    351      
     369 
    352370    // this memory is created but never destroyed 
    353371    // we're also not doing any error checking to make sure we didn't 
     
    396414   
    397415  mapinconvertclass *gbinconvert = new mapinconvertclass(); 
    398   gbinconvert->setmapfile (GSDL_GSDLHOME, "gbku", 0x25a1); 
     416  gbinconvert->setmapfile (gsdl_gsdlhome, "gbku", 0x25a1); 
    399417  mapoutconvertclass *gboutconvert = new mapoutconvertclass(); 
    400   gboutconvert->setmapfile (GSDL_GSDLHOME, "ugbk", 0xa1f5); 
     418  gboutconvert->setmapfile (gsdl_gsdlhome, "ugbk", 0xa1f5); 
    401419  recpt.add_converter ("g", gbinconvert, gboutconvert); 
    402420   
     
    407425   
    408426  pageaction *apageaction = new pageaction(); 
    409   apageaction->set_receptionist (&recpt); 
    410427  recpt.add_action (apageaction); 
    411428   
     
    421438  usersaction *ausersaction = new usersaction(); 
    422439  recpt.add_action (ausersaction); 
     440 
     441  extlinkaction *anextlinkaction = new extlinkaction(); 
     442  recpt.add_action (anextlinkaction); 
     443 
     444  //  buildaction *abuildaction = new buildaction(); 
     445  //  abuildaction->set_receptionist (&recpt); 
     446  //  recpt.add_action (abuildaction); 
    423447   
    424448  authenaction *aauthenaction = new authenaction(); 
    425449  aauthenaction->set_receptionist(&recpt); 
    426450  recpt.add_action (aauthenaction); 
    427    
    428   tipaction *atipaction = new tipaction(); 
    429   recpt.add_action (atipaction); 
     451 
     452 
     453  // list of browsers 
     454  vlistbrowserclass *avlistbrowserclass = new vlistbrowserclass(); 
     455  recpt.add_browser (avlistbrowserclass); 
     456  recpt.setdefaultbrowser ("VList"); 
     457 
     458  hlistbrowserclass *ahlistbrowserclass = new hlistbrowserclass(); 
     459  recpt.add_browser (ahlistbrowserclass); 
     460 
     461  datelistbrowserclass *adatelistbrowserclass = new datelistbrowserclass(); 
     462  recpt.add_browser (adatelistbrowserclass); 
     463 
     464  invbrowserclass *ainvbrowserclass = new invbrowserclass(); 
     465  recpt.add_browser (ainvbrowserclass); 
     466 
     467  pagedbrowserclass *apagedbrowserclass = new pagedbrowserclass(); 
     468  recpt.add_browser (apagedbrowserclass); 
     469 
     470  htmlbrowserclass *ahtmlbrowserclass = new htmlbrowserclass(); 
     471  recpt.add_browser (ahtmlbrowserclass); 
    430472   
    431473  // set defaults 
    432   recpt.configure ("gsdlhome", GSDL_GSDLHOME); 
     474  recpt.configure ("gsdlhome", gsdl_gsdlhome); 
    433475  recpt.configure ("collection", collection); 
    434476 
    435477  int maxrequests = 1; 
    436   if (!site_cfg_read (recpt, GSDL_GSDLHOME, collection, maxrequests)) { 
    437     // couldn't find the site configuration file 
    438     page_errorsitecfg (GSDL_GSDLHOME, collection); 
    439     return 0; 
    440   } else if (!main_cfg_read (recpt, GSDL_GSDLHOME, collection)) { 
    441     // couldn't find the main configuration file 
    442     page_errormaincfg (GSDL_GSDLHOME, collection); 
    443     return 0; 
     478  text_tset seenhomes; 
     479  this_info = gsdl_collectinfo.begin(); 
     480 
     481  // configure any collections with gsdlhome (or gdbmhome)  
     482  // different from the default 
     483  while (this_info != end_info) { 
     484    if (((*this_info).second.gsdl_gsdlhome != gsdl_gsdlhome) || 
     485    ((*this_info).second.gsdl_gdbmhome != gsdl_gdbmhome) && 
     486    (seenhomes.find ((*this_info).second.gsdl_gsdlhome +  
     487             (*this_info).second.gsdl_gdbmhome) == seenhomes.end())) { 
     488      text_tarray tmpconf; 
     489      tmpconf.push_back ((*this_info).first); 
     490      tmpconf.push_back ((*this_info).second.gsdl_gsdlhome); 
     491      tmpconf.push_back ((*this_info).second.gsdl_gdbmhome); 
     492      recpt.configure ("collectinfo", tmpconf); 
     493      seenhomes.insert ((*this_info).second.gsdl_gsdlhome +  
     494            (*this_info).second.gsdl_gdbmhome); 
     495    } 
     496    this_info ++; 
     497  } 
     498 
     499  // read in config files of each gsdlhome (in no particular order) 
     500  // those read in last will override those read earlier 
     501  // collections being used together in this way should be  
     502  // careful not to have site.cfg or main.cfg files that might  
     503  // screw with each other. 
     504  text_tset::const_iterator thome = gsdlhomes.begin(); 
     505  text_tset::const_iterator ehome = gsdlhomes.end(); 
     506  while (thome != ehome) { 
     507    if (!site_cfg_read (recpt, *thome, collection, maxrequests)) { 
     508      // couldn't find the site configuration file 
     509      page_errorsitecfg (*thome, collection); 
     510      return 0; 
     511    } else if (!main_cfg_read (recpt, *thome, collection)) { 
     512      // couldn't find the main configuration file 
     513      page_errormaincfg (*thome, collection); 
     514      return 0; 
     515    } 
     516    thome ++; 
    444517  } 
    445518 
     
    450523  if (!recpt.init(cerr)) { 
    451524    // an error occurred during the initialisation 
    452     page_errorinit(GSDL_GSDLHOME); 
     525    page_errorinit(gsdl_gsdlhome); 
    453526    return 0; 
    454527  } 
     
    465538 
    466539static void rememberpref (char *tailstr) { 
    467   strcpy(gs_enterlib, tailstr); 
    468  
    469   // add "a=p&p=home" 
    470   strcat(gs_enterlib, "&a=p&p=home"); 
     540 
     541  //  gsdl_enterlib = tailstr; 
    471542} 
    472543 
     
    493564 
    494565  // set up file name 
    495   text_t filenamet = text_t(GSDL_GSDLHOME) + filename; 
     566  text_t filenamet = text_t(gsdl_gsdlhome) + filename; 
    496567  text_t::iterator here = filenamet.begin(); 
    497568  text_t::iterator end = filenamet.end(); 
     
    538609  // has been no errors so far 
    539610  cgiargsclass args; 
    540   if (!recpt.parse_cgi_args (TailStr, args, cerr)) { 
    541     page_errorparseargs(GSDL_GSDLHOME); 
     611  text_tmap empty; // don't use this (it's for fastcgi on unix) 
     612  if (!recpt.parse_cgi_args (TailStr, args, cerr, empty)) { 
     613    page_errorparseargs(gsdl_gsdlhome); 
    542614    return; 
    543615  }  
     
    547619  text_t response_data; 
    548620 
    549   recpt.get_cgihead_info (args, response, response_data, cerr); 
    550   char *response_data_c = response_data.getcstr(); 
     621  recpt.get_cgihead_info (args, response, response_data, cerr, empty); 
    551622 
    552623  if (response == location) { 
    553624    // location response 
    554     if (send_header(strcat("@", response_data_c), RInfo) < 0) return; 
    555     // textstream << text_t2ascii << "Location: " << response_data << "\n\n"; 
     625    response_data = "@" + recpt.expandmacros (response_data, args, cerr); 
     626    char *response_data_c = response_data.getcstr(); 
     627    send_header(response_data_c, RInfo); 
     628    delete response_data_c; 
     629    return; 
    556630  } else if (response == content) { 
    557631    // content response 
    558     if (send_header(response_data_c, RInfo) < 0) return; 
     632    char *response_data_c = response_data.getcstr(); 
     633    if (send_header(response_data_c, RInfo) < 0) { 
     634      delete response_data_c; 
     635      return; 
     636    } 
     637    delete response_data_c; 
    559638  } else { 
    560639    // unknown response 
     
    565644  textstream.tsbreset(); 
    566645  textstream.setrequestinfo (RInfo); 
    567   delete response_data_c; 
    568646   
    569647  if (!recpt.produce_content (args, cout, cerr)) { 
    570     page_errorcgipage(GSDL_GSDLHOME); 
     648    page_errorcgipage(gsdl_gsdlhome); 
    571649    return; 
    572650  }  
    573   recpt.log_cgi_args (args, cerr); 
     651  recpt.log_cgi_args (args, cerr, empty); 
    574652 
    575653  cout << flush; 
     
    598676    // log the difference in access times 
    599677    DWORD thislibaccesstime = GetTickCount(); 
    600     if (gs_keep_log||gs_show_console) { 
     678    if (gsdl_keep_log||gsdl_show_console) { 
    601679      sprintf(tmpstr, "DELTA LIB ACCESS TIME: %i\n", (int)(thislibaccesstime - lastlibaccesstime)); 
    602680      log_message (tmpstr); 
     
    605683     
    606684    // log this request 
    607     if (gs_keep_log||gs_show_console) { 
     685    if (gsdl_keep_log||gsdl_show_console) { 
    608686      sprintf (tmpstr, "LOCAL LIB: %s\n", tailstr); 
    609687      log_message (tmpstr); 
     
    616694     
    617695    // log memory information 
    618     if (gs_keep_log||gs_show_console) { 
     696    if (gsdl_keep_log||gsdl_show_console) { 
    619697      MEMORYSTATUS memstatus; 
    620698      memstatus.dwLength = sizeof(MEMORYSTATUS); 
     
    627705  } else { 
    628706    // local file 
    629     if (gs_keep_log||gs_show_console) { 
     707    if (gsdl_keep_log||gsdl_show_console) { 
    630708      sprintf (tmpstr, "LOCAL FILE: %s\n", tailstr); 
    631709      log_message (tmpstr); 
  • trunk/gsdl/src/w32server/cgiwrapper.h

    r611 r902  
    44#include "httpreq.h" 
    55#include "locate.h" 
     6#include "receptionist.h" 
    67 
    78// the number of times the library has been accessed 
    89extern int libaccessnum; 
     10 
     11//void configure_httpprefix (); 
    912 
    1013int ExamineURIStr(char *URIStr,RequestInfoT *RequestInfo, 
  • trunk/gsdl/src/w32server/fnord.cpp

    r611 r902  
    7777#define ENTERBUTTONY ((MAINWINDOWHEIGHT-RESTHEIGHT)+5) 
    7878 
    79 #define VERSIONSTRING "version 1.1" 
     79#define VERSIONSTRING "version 1.0" 
    8080const char versionstring[] = VERSIONSTRING; 
    8181 
     
    196196   
    197197  // decide what we want to draw 
    198   if (gs_show_console) { 
     198  if (gsdl_show_console) { 
    199199    // we want to draw a "console" window 
    200200    if (window_state != console_window || 
     
    278278// returns 1 on success, 0 otherwise 
    279279int enter_library (HWND Window) { 
    280   char url[256], numbuf[20]; 
    281280  int res; 
    282281   
    283282  // get the url and attempt to start a browser 
     283  char *localname = GetLocalName(NULL); 
    284284  if (have_networking) { 
    285     strcpy(url, "http://"); 
    286     strcat(url, GetLocalName(NULL)); 
    287     if (gs_port_num != 80) { 
    288       itoa(gs_port_num,numbuf,10); 
    289       strcat(url,":"); 
    290       strcat(url,numbuf); 
    291     } 
    292     strcat(url, gs_enterlib); 
    293      
     285    text_t url = "http://" + text_t(localname); 
     286    if (gsdl_port_num != 80) 
     287      url += ":" + text_t(gsdl_port_num); 
     288     
     289    url += gsdl_enterlib; 
     290 
    294291    // add a unique ending so it will always result in a request 
    295     if (strstr (gs_enterlib, "?") == NULL) strcat (url, "?"); 
    296     else strcat (url, "&"); 
    297      
    298     strcat (url, "uq="); 
    299     itoa ((int)GetTickCount(), numbuf, 10); 
    300     strcat (url, numbuf); 
     292    text_t::const_iterator it =  
     293      findchar (gsdl_enterlib.begin(), gsdl_enterlib.end(), '?'); 
     294    if (it == gsdl_enterlib.end()) url.push_back ('?'); 
     295    else url.push_back ('&'); 
     296    int tcount = GetTickCount(); 
     297    url += "uq=" + text_t(tcount); 
    301298     
    302299    // remember the library access number for later proxy checking 
     
    305302    // do a quick check to make sure we're using netscape when 
    306303    // we should be (it might have been just installed) 
    307     if (netscapeneeded) gs_check_browser_settings (netscapeneeded); 
    308      
     304    if (netscapeneeded) gsdl_check_browser_settings (netscapeneeded); 
     305     
     306    char *cstr_url = url.getcstr(); 
    309307    if (strlen (startbrowserdir) <= 0) { 
    310       res = startbrowser (url, gs_browser_exe, NULL); 
     308      res = startbrowser (cstr_url, gsdl_browser_exe, NULL); 
    311309       
    312     } else res = startbrowser (url, gs_browser_exe, startbrowserdir); 
    313      
     310    } else res = startbrowser (cstr_url, gsdl_browser_exe, startbrowserdir); 
     311     
     312    delete cstr_url; 
     313 
    314314  } else { 
     315    /* 
    315316    char staticpath[256]; 
    316317     
    317318    // try to find the static pages 
    318     strcpy (url, gs_staticpages); 
     319    strcpy (url, gsdl_staticpages); 
    319320     
    320321    // remove any slashes from the static pathname 
     
    341342    strcat (url, "niupepa.htm"); 
    342343     
    343     res = startbrowser (url, gs_browser_exe, NULL); 
     344    res = startbrowser (url, gsdl_browser_exe, NULL); 
    344345    startbrowserdir[0] = '\0'; // doesn't make sense for non-networked case 
     346    */ 
    345347  } 
    346348   
     
    393395   
    394396  // try to find the browser directory 
    395   strcpy (installpath, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive... 
     397  char *gsdlhome = gsdl_gsdlhome.getcstr(); 
     398  strcpy (installpath, gsdlhome); // use gsdlhome to find the CD-ROM drive... 
     399  delete gsdlhome; 
    396400   
    397401  // remove any slashes from the pathname 
     
    457461   
    458462  // try to find the browser directory 
    459   strcpy (topdir, gs_gsdlhome); // use gsdlhome to find the CD-ROM drive... 
     463  char *gsdlhome = gsdl_gsdlhome.getcstr(); 
     464  strcpy (topdir, gsdlhome); // use gsdlhome to find the CD-ROM drive... 
     465  delete gsdlhome; 
    460466  strcpy (cmd, "notepad "); 
    461467   
     
    486492    // repeat key press then attempt to start a browser 
    487493    if ((WParam == '\r') && !(LParam & 0xe0000000)) { 
    488       if (enter_library (Window) && !gs_show_console)  
     494      if (enter_library (Window) && !gsdl_show_console)  
    489495    ShowWindow(Window,SW_MINIMIZE); 
    490496    } 
     
    493499    if ((HWND)LParam == GoButton) { 
    494500      // attempt to start a browser 
    495       if (enter_library (Window) && !gs_show_console)  
     501      if (enter_library (Window) && !gsdl_show_console)  
    496502    ShowWindow(Window,SW_MINIMIZE); 
    497503 
     
    591597  startbrowserdir[0] = '\0'; 
    592598  netscapeneeded = 0; 
    593   //    int err = tryinitnetwork (Instance, MsgWindow, NULL); 
    594   int err = 1; 
     599  int err = tryinitnetwork (Instance, MsgWindow, NULL); 
     600  //int err = 1; 
    595601   
    596602  // if an error occurred, try again with billsock 
     
    624630    netscapeneeded = 1; 
    625631    // make sure the browser state is in step with the network condition 
    626     gs_check_browser_settings (netscapeneeded); 
     632    gsdl_check_browser_settings (netscapeneeded); 
    627633      } 
    628634       
    629635      // check to see if a browser is running 
    630       if (browserrunning(gs_browser_exe) == NO_ERROR) { 
     636      if (browserrunning(gsdl_browser_exe) == NO_ERROR) { 
    631637    MessageBox (NULL,  
    632638            "The Greenstone Digital Library software has detected a\n" 
     
    748754   
    749755  // get various information about this computer 
    750   if (gs_keep_log || gs_show_console) { 
     756  if (gsdl_keep_log || gsdl_show_console) { 
    751757    // get operating system information 
    752758    OSVERSIONINFO osver; 
     
    856862  // init various modules 
    857863  read_settings (0); // don't know if netscape is needed at this point 
    858   if (!gsdl_init()) // quit if can't initialise the library correctly 
    859     exit (0); 
    860   initstartbrowser(); 
    861   log_computer_info (); 
    862    
     864 
    863865  // attempt to initialise the network 
     866  // we do this first now as gsdl_init  
     867  // needs networking initialized to  
     868  // set httpprefix - Stefan. 
     869  // -- gsdl_init doesn't currently set httpprefix, 
     870  // it did for a brief time when I was using some 
     871  // scary html that didn't like relative links 
    864872  have_networking = initnetwork (Instance, MainWindow); 
    865873  if (!have_networking) { 
     
    869877    exit (0); // there is no static library for this collection 
    870878  } 
     879 
     880  if (!gsdl_init()) // quit if can't initialise the library correctly 
     881    exit (0); 
     882  initstartbrowser(); 
     883  log_computer_info (); 
     884 
    871885  // show the initialising message for at least 1 second 
    872886  while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) { 
     
    875889   
    876890  // if autoenter is enabled attempt to start a browser 
    877   if (have_networking && gs_auto_enter) { 
     891  if (have_networking && gsdl_auto_enter) { 
    878892    infostring = strsb; 
    879893    paint_window (pdc, windowRect); 
    880894    lastcheck = GetTickCount(); 
    881     if (enter_library (MainWindow) && !gs_show_console) { 
     895    if (enter_library (MainWindow) && !gsdl_show_console) { 
    882896      // stay maximised for at least 1 second 
    883897      while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) Sleep (1); 
     
    916930  // we will ask if they want to close the 
    917931  // the library down 
    918   char last_gs_browser_exe[MAX_FILENAME_SIZE]; // need to notice when the 
     932  char last_gsdl_browser_exe[MAX_FILENAME_SIZE]; // need to notice when the 
    919933  // browser setting changes 
    920   strcpy (last_gs_browser_exe, gs_browser_exe); 
     934  strcpy (last_gsdl_browser_exe, gsdl_browser_exe); 
    921935   
    922936  for (;;) { 
     
    929943      if (DiffTickCounts (lastcheck, GetTickCount()) > 500) { 
    930944    // make sure the browser hasn't changed 
    931     if (strcmp (last_gs_browser_exe, gs_browser_exe) != 0) { 
     945    if (strcmp (last_gsdl_browser_exe, gsdl_browser_exe) != 0) { 
    932946      seenbrowser = 0; 
    933       strcpy (last_gs_browser_exe, gs_browser_exe); 
     947      strcpy (last_gsdl_browser_exe, gsdl_browser_exe); 
    934948    } 
    935949     
    936950    // do check 
    937951    lastcheck = GetTickCount(); 
    938     if (browserrunning(gs_browser_exe) == NO_ERROR) { 
     952    if (browserrunning(gsdl_browser_exe) == NO_ERROR) { 
    939953      // we were able to connect to a browser 
    940954      seenbrowser = 1; 
  • trunk/gsdl/src/w32server/httpsrv.cpp

    r611 r902  
    5050  MsgWindow = PassedMsgWindow; 
    5151  //Create the server socket 
    52   return CreateListeningSocket(gs_port_num, MsgWindow, HTTP_SERVER_MSG, ServerSocket); 
     52  return CreateListeningSocket(gsdl_port_num, MsgWindow, HTTP_SERVER_MSG, ServerSocket); 
    5353} 
    5454 
     
    6464    log_message("accept message arrived\n"); 
    6565    if (Socket != ServerSocket) { 
    66         if (gs_keep_log || gs_show_console) log_message("Incorrect socket sent in message"); 
     66        if (gsdl_keep_log || gsdl_show_console) log_message("Incorrect socket sent in message"); 
    6767        } 
    6868    switch (WSAGETSELECTEVENT(MsgInfo)) { 
  • trunk/gsdl/src/w32server/locate.cpp

    r611 r902  
    5252{ 
    5353  if (log_file != NULL) fclose(log_file); 
    54   log_file = fopen(gs_log_name, "a"); 
     54  log_file = fopen(gsdl_log_name, "a"); 
    5555  if (log_file != NULL) { 
    5656      fprintf (log_file, "\n\n-----------\n"); 
     
    7575void activate_console(void) 
    7676{ 
    77   gs_show_console = 1; 
     77  gsdl_show_console = 1; 
    7878  next_console = console_buffer; 
    7979  *next_console = 0; 
     
    8686void deactivate_console(void) 
    8787{ 
    88   gs_show_console = 0; 
     88  gsdl_show_console = 0; 
    8989  InvalidateRect(GSDL_Window,NULL,TRUE); 
    9090} 
     
    189189    fflush(log_file); 
    190190    } 
    191   if (gs_show_console) { 
     191  if (gsdl_show_console) { 
    192192    char buffer[1024];  HDC dc; 
    193193    sprintf(buffer,"%s",msg); 
     
    210210 
    211211  // these messages are not send to the console 
    212   if (gs_show_console) { 
     212  if (gsdl_show_console) { 
    213213    HDC dc; 
    214214    dc = GetDC(GSDL_Window); 
  • trunk/gsdl/src/w32server/resource.h

    r611 r902  
    1010#define GSDL_LOGO                       108 
    1111#define GSDL_COL_TITLE                  109 
     12#define IDD_DIALOG1                     118 
    1213#define APPLY_BUTTON                    1000 
    1314#define REMOTE_CHECK                    1001 
     
    4142#ifdef APSTUDIO_INVOKED 
    4243#ifndef APSTUDIO_READONLY_SYMBOLS 
    43 #define _APS_NEXT_RESOURCE_VALUE        118 
     44#define _APS_NEXT_RESOURCE_VALUE        119 
    4445#define _APS_NEXT_COMMAND_VALUE         40008 
    4546#define _APS_NEXT_CONTROL_VALUE         1024 
  • trunk/gsdl/src/w32server/settings.cpp

    r611 r902  
    88 
    99#include <windows.h> 
    10 //#include <stdlib.h> 
    11 //#include <stdio.h> 
    12 //#include <string.h> 
    13 //#include <memory.h> 
    14 //#pragma hdrstop 
    1510#include "httpsrv.h" 
    1611#include "settings.h" 
    1712#include "locate.h" 
    1813#include "resource.h" 
    19  
    20 #include "text_t.h" 
    21 #include "conftools.h" 
    22  
     14#include "cgiwrapper.h" 
    2315 
    2416// library settings 
    25 char gs_enterlib[MAX_FILENAME_SIZE] = ""; 
    26 char gs_gsdlhome[MAX_FILENAME_SIZE] = ""; 
    27 char gs_macroshome[MAX_FILENAME_SIZE] = ""; 
    28 char gs_gdbmhome[MAX_FILENAME_SIZE] = ""; 
    29 char gs_indexhome[MAX_FILENAME_SIZE] = ""; 
    30  
    31 char gs_staticpages[MAX_FILENAME_SIZE] = "d:\\static"; 
    32  
     17text_t gsdl_enterlib; 
     18text_t gsdl_gsdlhome; 
     19text_t gsdl_gdbmhome; 
     20text_t gsdl_collections; 
     21colinfo_tmap gsdl_collectinfo; 
     22 
     23char gsdl_staticpages[MAX_FILENAME_SIZE]; 
    3324 
    3425// debug settings 
    35 char gs_log_name[MAX_FILENAME_SIZE] = "c:\\gsdl.log"; 
    36 int gs_keep_log = 0; 
    37 int gs_show_console = 0; 
     26char gsdl_log_name[MAX_FILENAME_SIZE] = "c:\\gsdl.log"; 
     27int gsdl_keep_log = 0; 
     28int gsdl_show_console = 0; 
    3829 
    3930// general settings 
    40 int gs_port_num = 80; 
    41 int gs_auto_enter = 0; 
    42 int gs_browser = GS_NETSCAPE; 
    43 char gs_browser_exe[MAX_FILENAME_SIZE]=""; 
    44  
     31int gsdl_port_num = 80; 
     32int gsdl_auto_enter = 0; 
     33int gsdl_browser = GS_NETSCAPE; 
     34char gsdl_browser_exe[MAX_FILENAME_SIZE] = ""; 
    4535 
    4636 
     
    5646 
    5747// whether netscape is needed (used in the settings dialog box) 
    58 static int gs_netscapeneeded = 0; 
    59  
     48static int gsdl_netscapeneeded = 0; 
    6049 
    6150static void remove_end_slashes(char *str) { 
    62     int len = strlen (str); 
    63     while ((len > 0) && ((str[len-1] == '\\') || (str[len-1] == '/'))) { 
    64         len --; 
    65     } 
    66     str[len] = '\0'; 
    67 } 
    68  
     51  int len = strlen (str); 
     52  while ((len > 0) && ((str[len-1] == '\\') || (str[len-1] == '/'))) { 
     53    len --; 
     54  } 
     55  str[len] = '\0'; 
     56} 
     57 
     58static void remove_end_slashes (text_t &str) { 
     59  char *cstr = str.getcstr(); 
     60  remove_end_slashes (cstr); 
     61  str = cstr; 
     62  delete cstr; 
     63} 
    6964 
    7065// returns 1 if successful, 0 otherwise 
    7166// checks for a file's existence 
    7267static int check_program_exe (char *path) { 
    73     UINT curerrormode; 
    74     OFSTRUCT reOpenBuff; 
    75     int retvalue = 0; 
    76  
    77     reOpenBuff.cBytes = sizeof (OFSTRUCT); 
    78  
    79     curerrormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); 
    80     if (OpenFile(path, &reOpenBuff, OF_EXIST) != HFILE_ERROR) retvalue = 1; 
    81     SetErrorMode(curerrormode); 
    82  
    83     return retvalue; 
     68  UINT curerrormode; 
     69  OFSTRUCT reOpenBuff; 
     70  int retvalue = 0; 
     71   
     72  reOpenBuff.cBytes = sizeof (OFSTRUCT); 
     73   
     74  curerrormode = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); 
     75  if (OpenFile(path, &reOpenBuff, OF_EXIST) != HFILE_ERROR) retvalue = 1; 
     76  SetErrorMode(curerrormode); 
     77   
     78  return retvalue; 
    8479} 
    8580 
     
    8782// returns 1 if successful, 0 otherwise 
    8883static int get_default_browser_path (char *providedhtmltype, char *path, int maxsize) { 
    89     HKEY hk1, hk2; 
    90     char htmltype[256]; 
    91     long size; 
    92     int retval = 0; 
    93  
    94     htmltype[0] = '\0'; 
    95     path[0] = '\0'; 
    96  
    97  
    98     // try and get information about the default browser from the  
    99     // registry 
    100  
    101     if (providedhtmltype != NULL) strcpy (htmltype, providedhtmltype); 
    102  
    103     else if (RegOpenKey(HKEY_CLASSES_ROOT, ".htm", &hk1) == ERROR_SUCCESS) { 
    104         size = 256; 
    105         RegQueryValue(hk1, NULL, htmltype, &size); 
    106         RegCloseKey(hk1); 
     84  HKEY hk1, hk2; 
     85  char htmltype[256]; 
     86  long size; 
     87  int retval = 0; 
     88   
     89  htmltype[0] = '\0'; 
     90  path[0] = '\0'; 
     91   
     92  // try and get information about the default browser from the  
     93  // registry 
     94   
     95  if (providedhtmltype != NULL) strcpy (htmltype, providedhtmltype); 
     96   
     97  else if (RegOpenKey(HKEY_CLASSES_ROOT, ".htm", &hk1) == ERROR_SUCCESS) { 
     98    size = 256; 
     99    RegQueryValue(hk1, NULL, htmltype, &size); 
     100    RegCloseKey(hk1); 
     101  } 
     102   
     103  if (RegOpenKey(HKEY_CLASSES_ROOT, htmltype, &hk1) == ERROR_SUCCESS) { 
     104    if (RegOpenKey(hk1, "shell\\open", &hk2) == ERROR_SUCCESS) { 
     105      // look for the command to start the browser 
     106      size = maxsize; 
     107      if (RegQueryValue(hk2,"command",path,&size) == ERROR_SUCCESS) { 
     108                // strip all excess stuff off the command 
     109    char endchar = ' '; 
     110    int i = 0, len = 0; 
     111    int state = 0; // 0=strip initial white-space and quotes, 1=grab path 
     112    while (path[i] != '\0') { 
     113      if (state == 0) { 
     114        if (path[i] == ' ') { 
     115          // do nothing 
     116        } else if (path[i] == '"') { 
     117          endchar = '"'; 
     118          state = 1; 
     119        } else { 
     120          state = 1; 
     121          path[len] = path[i]; 
     122          len++; 
     123        } 
     124      } else { 
     125        if (path[i] == endchar) break; 
     126        path[len] = path[i]; 
     127        len++; 
     128      } 
     129      i++; 
    107130    } 
    108  
    109     if (RegOpenKey(HKEY_CLASSES_ROOT, htmltype, &hk1) == ERROR_SUCCESS) { 
    110         if (RegOpenKey(hk1, "shell\\open", &hk2) == ERROR_SUCCESS) { 
    111             // look for the command to start the browser 
    112             size = maxsize; 
    113             if (RegQueryValue(hk2,"command",path,&size) == ERROR_SUCCESS) { 
    114                 // strip all excess stuff off the command 
    115                 char endchar = ' '; 
    116                 int i = 0, len = 0; 
    117                 int state = 0; // 0=strip initial white-space and quotes, 1=grab path 
    118                 while (path[i] != '\0') { 
    119                     if (state == 0) { 
    120                         if (path[i] == ' ') { 
    121                             // do nothing 
    122                         } else if (path[i] == '"') { 
    123                             endchar = '"'; 
    124                             state = 1; 
    125                         } else { 
    126                             state = 1; 
    127                             path[len] = path[i]; 
    128                             len++; 
    129                         } 
    130                     } else { 
    131                         if (path[i] == endchar) break; 
    132                         path[len] = path[i]; 
    133                         len++; 
    134                     } 
    135                     i++; 
    136                 } 
    137                 path[len] = '\0'; 
    138  
    139                 // check the resulting pathname 
    140                 if (check_program_exe (path)) { 
    141                     retval = 1; // succeeded 
    142                 } else { 
    143                     path[0] = '\0'; // failed (must have been deleted or something...) 
    144                 } 
    145             } 
    146             RegCloseKey(hk2); 
    147         } 
    148         RegCloseKey(hk1); 
     131    path[len] = '\0'; 
     132     
     133    // check the resulting pathname 
     134    if (check_program_exe (path)) { 
     135      retval = 1; // succeeded 
     136    } else { 
     137      path[0] = '\0'; // failed (must have been deleted or something...) 
    149138    } 
    150  
    151     return retval; 
     139      } 
     140      RegCloseKey(hk2); 
     141    } 
     142    RegCloseKey(hk1); 
     143  } 
     144   
     145  return retval; 
    152146} 
    153147 
     
    156150// note that appname should include .exe (e.g. netscape.exe) 
    157151static int registry_get_app_paths (char *appname, char *path, int maxsize) { 
    158     HKEY hk1; 
    159     long size; 
    160     int retval = 0; 
    161  
    162     path[0] = '\0'; 
    163  
    164     if (RegOpenKey(HKEY_LOCAL_MACHINE,  
    165             "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths",  
    166             &hk1) == ERROR_SUCCESS) { 
    167         size = maxsize; 
    168         if (RegQueryValue (hk1, appname, path, &size) == ERROR_SUCCESS && 
    169                 check_program_exe (path)); 
    170             retval = 1; 
    171  
    172         RegCloseKey(hk1); 
     152  HKEY hk1; 
     153  long size; 
     154  int retval = 0; 
     155   
     156  path[0] = '\0'; 
     157   
     158  if (RegOpenKey(HKEY_LOCAL_MACHINE,  
     159         "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths",  
     160         &hk1) == ERROR_SUCCESS) { 
     161    size = maxsize; 
     162    if (RegQueryValue (hk1, appname, path, &size) == ERROR_SUCCESS && 
     163    check_program_exe (path)); 
     164    retval = 1; 
     165     
     166    RegCloseKey(hk1); 
     167  } 
     168   
     169  return retval; 
     170} 
     171 
     172static void check_installed_browsers (int netscapeneeded) { 
     173  netscape_exe[0] = '\0'; 
     174  iexplore_exe[0] = '\0'; 
     175  default_browser_exe[0] = '\0'; 
     176   
     177  // update the default browser information (if netscape isn't needed) 
     178  if (!netscapeneeded) { 
     179    get_default_browser_path (NULL, default_browser_exe, MAX_FILENAME_SIZE); 
     180    _strlwr (default_browser_exe); 
     181  } 
     182   
     183  // look for netscape 
     184   
     185  // first look for netscape in the registry 
     186  if (!registry_get_app_paths("netscape.exe", netscape_exe, MAX_FILENAME_SIZE)) { 
     187    // next look for "NetscapeMarkup" 
     188    if (get_default_browser_path ("NetscapeMarkup", netscape_exe, MAX_FILENAME_SIZE)) { 
     189      _strlwr (netscape_exe); 
     190      if (!strstr (netscape_exe, "netscape.exe")) { 
     191    netscape_exe[0] = '\0'; 
     192     
     193    // next look for \netscape\netscape.exe 
     194     
     195    // get drive letter of the windows directory 
     196    GetWindowsDirectory(netscape_exe, MAX_FILENAME_SIZE); 
     197    netscape_exe[1] = '\0'; 
     198    strcat (netscape_exe, ":\\netscape\\netscape.exe"); 
     199     
     200    if (!check_program_exe (netscape_exe)) { 
     201      // lastly look for \netscape\program\netscape.exe 
     202      netscape_exe[1] = '\0'; 
     203      strcat (netscape_exe, ":\\netscape\\program\\netscape.exe"); 
     204       
    173205    } 
    174  
    175     return retval; 
    176 } 
    177  
    178 static void check_installed_browsers (int netscapeneeded) { 
    179     netscape_exe[0] = '\0'; 
     206      } 
     207    } 
     208  } 
     209  _strlwr (netscape_exe); 
     210  if ((strlen (netscape_exe) > 0) && !check_program_exe (netscape_exe)) { 
     211    netscape_exe[0] = '\0';  // couldn't find netscape 
     212  } 
     213   
     214  // look for internet explorer (if netscape isn't needed) 
     215   
     216  // first look for iexplore in the registry 
     217  if (!netscapeneeded && !registry_get_app_paths("iexplore.exe",  
     218                         iexplore_exe, MAX_FILENAME_SIZE)) { 
     219    // next look for "htmlfile" 
     220    if (get_default_browser_path ("htmlfile", iexplore_exe, MAX_FILENAME_SIZE)) { 
     221      _strlwr (iexplore_exe); 
     222      if (!strstr (iexplore_exe, "iexplore.exe")) { 
    180223    iexplore_exe[0] = '\0'; 
    181     default_browser_exe[0] = '\0'; 
    182  
    183     // update the default browser information (if netscape isn't needed) 
    184     if (!netscapeneeded) { 
    185         get_default_browser_path (NULL, default_browser_exe, MAX_FILENAME_SIZE); 
    186         _strlwr (default_browser_exe); 
    187     } 
    188  
    189  
    190     // look for netscape 
    191  
    192     // first look for netscape in the registry 
    193     if (!registry_get_app_paths("netscape.exe", netscape_exe, MAX_FILENAME_SIZE)) { 
    194         // next look for "NetscapeMarkup" 
    195         if (get_default_browser_path ("NetscapeMarkup", netscape_exe, MAX_FILENAME_SIZE)) { 
    196             _strlwr (netscape_exe); 
    197             if (!strstr (netscape_exe, "netscape.exe")) { 
    198                 netscape_exe[0] = '\0'; 
    199  
    200                 // next look for \netscape\netscape.exe 
    201  
    202                 // get drive letter of the windows directory 
    203                 GetWindowsDirectory(netscape_exe, MAX_FILENAME_SIZE); 
    204                 netscape_exe[1] = '\0'; 
    205                 strcat (netscape_exe, ":\\netscape\\netscape.exe"); 
    206  
    207                 if (!check_program_exe (netscape_exe)) { 
    208                     // lastly look for \netscape\program\netscape.exe 
    209                     netscape_exe[1] = '\0'; 
    210                     strcat (netscape_exe, ":\\netscape\\program\\netscape.exe"); 
    211                      
    212                 } 
    213             } 
    214         } 
    215     } 
    216     _strlwr (netscape_exe); 
    217     if ((strlen (netscape_exe) > 0) && !check_program_exe (netscape_exe)) { 
    218         netscape_exe[0] = '\0';  // couldn't find netscape 
    219     } 
    220  
    221  
    222     // look for internet explorer (if netscape isn't needed) 
    223  
    224     // first look for iexplore in the registry 
    225     if (!netscapeneeded && !registry_get_app_paths("iexplore.exe",  
    226             iexplore_exe, MAX_FILENAME_SIZE)) { 
    227         // next look for "htmlfile" 
    228         if (get_default_browser_path ("htmlfile", iexplore_exe, MAX_FILENAME_SIZE)) { 
    229             _strlwr (iexplore_exe); 
    230             if (!strstr (iexplore_exe, "iexplore.exe")) { 
    231                 iexplore_exe[0] = '\0'; 
    232  
    233                 // next look for \iexplore\iexplore.exe 
    234  
    235                 // get drive letter of the windows directory 
    236                 GetWindowsDirectory(iexplore_exe, MAX_FILENAME_SIZE); 
    237                 iexplore_exe[1] = '\0'; 
    238                 strcat (iexplore_exe, ":\\iexplore\\iexplore.exe"); 
    239             } 
    240         } 
    241     } 
    242     _strlwr (iexplore_exe); 
    243     if ((strlen (iexplore_exe) > 0) && !check_program_exe (iexplore_exe)) { 
    244         iexplore_exe[0] = '\0';  // couldn't find internet explorer 
    245     } 
    246  
    247 } 
    248  
     224     
     225    // next look for \iexplore\iexplore.exe 
     226     
     227    // get drive letter of the windows directory 
     228    GetWindowsDirectory(iexplore_exe, MAX_FILENAME_SIZE); 
     229    iexplore_exe[1] = '\0'; 
     230    strcat (iexplore_exe, ":\\iexplore\\iexplore.exe"); 
     231      } 
     232    } 
     233  } 
     234  _strlwr (iexplore_exe); 
     235  if ((strlen (iexplore_exe) > 0) && !check_program_exe (iexplore_exe)) { 
     236    iexplore_exe[0] = '\0';  // couldn't find internet explorer 
     237  } 
     238} 
    249239 
    250240void write_settings () { 
    251     char conffile[MAX_FILENAME_SIZE]; 
    252  
    253     strcpy (conffile, data_location); 
    254     remove_end_slashes (conffile); 
    255     strcat (conffile, "\\gsdl.ini"); 
    256  
    257     ofstream fout (conffile); 
    258     if (fout) { 
    259         write_confline(fout, "enterlib", gs_enterlib); 
    260         write_confline(fout, "gsdlhome", gs_gsdlhome); 
    261         write_confline(fout, "macroshome", gs_macroshome); 
    262         write_confline(fout, "gdbmhome", gs_gdbmhome); 
    263         write_confline(fout, "indexhome", gs_indexhome); 
    264  
    265         write_confline(fout, "staticpages", gs_staticpages); 
    266  
    267         write_confline(fout, "logfilename", gs_log_name); 
    268         write_confline(fout, "keeplog", text_t(gs_keep_log)); 
    269         write_confline(fout, "consolelog", text_t(gs_show_console)); 
    270  
    271         write_confline(fout, "portnumber", text_t(gs_port_num)); 
    272         write_confline(fout, "autoenter", text_t(gs_auto_enter)); 
    273         write_confline(fout, "browser", text_t(gs_browser)); 
    274         write_confline(fout, "browserexe", gs_browser_exe); 
    275          
    276         fout.close(); 
    277     } 
     241  char conffile[MAX_FILENAME_SIZE]; 
     242   
     243  strcpy (conffile, data_location); 
     244  remove_end_slashes (conffile); 
     245  strcat (conffile, "\\gsdl.ini"); 
     246   
     247  ofstream fout (conffile); 
     248  if (fout) { 
     249     
     250    outconvertclass text_t2ascii; 
     251 
     252    // top (gsdl) level stuff 
     253    fout << "[gsdl]\n"; 
     254    write_ini_line(fout, "enterlib", gsdl_enterlib); 
     255    write_ini_line(fout, "gsdlhome", gsdl_gsdlhome); 
     256    write_ini_line(fout, "gdbmhome", gsdl_gdbmhome); 
     257     
     258    write_ini_line(fout, "logfilename", gsdl_log_name); 
     259    write_ini_line(fout, "keeplog", text_t(gsdl_keep_log)); 
     260    write_ini_line(fout, "consolelog", text_t(gsdl_show_console)); 
     261     
     262    write_ini_line(fout, "portnumber", text_t(gsdl_port_num)); 
     263    write_ini_line(fout, "autoenter", text_t(gsdl_auto_enter)); 
     264    write_ini_line(fout, "browser", text_t(gsdl_browser)); 
     265    write_ini_line(fout, "browserexe", gsdl_browser_exe); 
     266    write_ini_line(fout, "collections", gsdl_collections); 
     267     
     268    // collection levels 
     269    colinfo_tmap::iterator here = gsdl_collectinfo.begin(); 
     270    colinfo_tmap::iterator end = gsdl_collectinfo.end(); 
     271    while (here != end) { 
     272      fout << text_t2ascii << "[" << (*here).first << "]\n"; 
     273      if (!(*here).second.gsdl_gsdlhome.empty())  
     274    write_ini_line(fout, "gsdlhome", (*here).second.gsdl_gsdlhome); 
     275      if (!(*here).second.gsdl_gdbmhome.empty())  
     276    write_ini_line(fout, "gdbmhome", (*here).second.gsdl_gdbmhome); 
     277       
     278      here ++; 
     279    } 
     280    fout.close(); 
     281  } 
    278282} 
    279283 
     
    281285// browser_compare assumes that check_exe is in lowercase 
    282286static int browser_compare (char *browser_exe_path, char *check_exe) { 
    283     char tmp_exe[MAX_FILENAME_SIZE]; 
    284     strcpy (tmp_exe, browser_exe_path); 
    285     _strlwr (tmp_exe); 
    286     return (strstr (tmp_exe, check_exe) != NULL); 
     287  char tmp_exe[MAX_FILENAME_SIZE]; 
     288  strcpy (tmp_exe, browser_exe_path); 
     289  _strlwr (tmp_exe); 
     290  return (strstr (tmp_exe, check_exe) != NULL); 
    287291} 
    288292 
     
    292296// enough to receive any path names to any browser 
    293297static void check_browser_settings (int &browser, char *browser_exe,  
    294                              int netscapeneeded) { 
    295  
    296     // sort out which browser to use 
    297     if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0')) 
    298         browser = GS_IEXPLORE; 
    299     if ((browser == GS_IEXPLORE) && (netscapeneeded || (iexplore_exe[0] == '\0'))) { 
    300         if (netscape_exe[0] != '\0') browser = GS_NETSCAPE; 
    301         else browser = GS_OTHER; 
     298                    int netscapeneeded) { 
     299   
     300  // sort out which browser to use 
     301  if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0')) 
     302    browser = GS_IEXPLORE; 
     303  if ((browser == GS_IEXPLORE) && (netscapeneeded || (iexplore_exe[0] == '\0'))) { 
     304    if (netscape_exe[0] != '\0') browser = GS_NETSCAPE; 
     305    else browser = GS_OTHER; 
     306  } 
     307  if ((browser == GS_OTHER) && netscapeneeded &&  
     308      !browser_compare (browser_exe, "netscape.exe") && (netscape_exe[0] != '\0')) { 
     309    // this other browser isn't netscape and netscape is available 
     310    browser = GS_NETSCAPE; 
     311  } 
     312   
     313   
     314  // get the browser's executable 
     315  if (browser == GS_NETSCAPE) { 
     316    strcpy (browser_exe, netscape_exe); 
     317  } else if (browser == GS_IEXPLORE) { 
     318    strcpy (browser_exe, iexplore_exe); 
     319  } else { 
     320    browser = GS_OTHER; 
     321     
     322    // if the browser should be netscape then check to 
     323    // make sure it is 
     324    if (netscapeneeded && !browser_compare (browser_exe, "netscape.exe")) { 
     325      // not netscape, set to no browser 
     326      browser_exe[0] = '\0'; 
     327    } 
     328  } 
     329} 
     330 
     331 
     332static void revert_defaults (int netscapeneeded) { 
     333  find_location(); 
     334   
     335  // library settings 
     336  gsdl_enterlib = "/cgi-bin/gw"; 
     337  gsdl_gsdlhome = data_location; 
     338  gsdl_gdbmhome = data_location; 
     339   
     340  // debug settings 
     341  gsdl_keep_log = 0; 
     342  strcpy (gsdl_log_name, "c:\\gsdl.log"); 
     343  gsdl_show_console = 0; 
     344   
     345  // general settings 
     346  gsdl_port_num = 80; 
     347  gsdl_auto_enter = 0; 
     348   
     349  check_installed_browsers (netscapeneeded); 
     350  gsdl_browser = GS_NETSCAPE; 
     351  strcpy (gsdl_browser_exe, default_browser_exe); 
     352  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded); 
     353} 
     354 
     355void read_settings (int netscapeneeded) { 
     356  char conffile[MAX_FILENAME_SIZE]; 
     357   
     358  find_location(); 
     359   
     360  strcpy (conffile, data_location); 
     361  remove_end_slashes (conffile); 
     362  strcat (conffile, "\\gsdl.ini"); 
     363   
     364  // set up defaults 
     365  revert_defaults (netscapeneeded); 
     366   
     367  text_t key, value, section; 
     368  char *cstr_value; 
     369  ifstream conf (conffile, ios::nocreate); 
     370  if (conf) { 
     371    while (read_ini_line(conf, key, value) >= 0) { 
     372      if (value.empty()) { 
     373    // should be a section title 
     374    section = key; 
     375    // remove square brackets 
     376    section.erase (section.begin()); 
     377    section.erase (section.end()-1); 
     378 
     379      } else { 
     380 
     381    cstr_value = value.getcstr (); 
     382       
     383    if (section == "gsdl") { 
     384 
     385      if (key == "enterlib") { 
     386        gsdl_enterlib = value; 
     387       
     388        // 'logfilename' should occur in the configuration file 
     389        // before 'keeplog' 
     390      } else if (key == "logfilename") { 
     391        strcpy (gsdl_log_name, cstr_value); 
     392       
     393      } else if (key == "keeplog") { 
     394        gsdl_keep_log = value.getint(); 
     395        if (gsdl_keep_log) open_log_file(); 
     396     
     397      } else if (key == "consolelog") { 
     398        if (value.getint()) activate_console(); 
     399        else deactivate_console(); 
     400     
     401      } else if (key == "portnumber") { 
     402        gsdl_port_num = value.getint(); 
     403         
     404      } else if (key == "autoenter") { 
     405        gsdl_auto_enter = value.getint(); 
     406     
     407      } else if (key == "browser") { 
     408        gsdl_browser = value.getint(); 
     409     
     410      } else if (key == "browserexe") { 
     411        strcpy (gsdl_browser_exe, cstr_value); 
     412 
     413      } else if (key == "collections") { 
     414        gsdl_collections = value; 
     415 
     416      // gsdlhome must occur in file before gdbmhome         
     417      } else if (key == "gsdlhome") { 
     418        gsdl_gsdlhome = value; 
     419        gsdl_gdbmhome = value; 
     420       
     421      } else if (key == "gdbmhome") { 
     422        gsdl_gdbmhome = value; 
     423      } 
     424    } else { 
     425       
     426      // gsdlhome must occur in file before gdbmhome 
     427      if (key == "gsdlhome") { 
     428        gsdl_collectinfo[section].gsdl_gsdlhome = value; 
     429        gsdl_collectinfo[section].gsdl_gdbmhome = value; 
     430      } else if (key == "gdbmhome") { 
     431        gsdl_collectinfo[section].gsdl_gdbmhome = value; 
     432      } 
    302433    } 
    303     if ((browser == GS_OTHER) && netscapeneeded &&  
    304         !browser_compare (browser_exe, "netscape.exe") && (netscape_exe[0] != '\0')) { 
    305         // this other browser isn't netscape and netscape is available 
    306         browser = GS_NETSCAPE; 
     434    delete cstr_value; 
     435      } 
     436    } 
     437    conf.close(); 
     438  } 
     439   
     440  // check the homes to make sure they don't contain 
     441  // extra slashes at the end 
     442  remove_end_slashes (gsdl_gsdlhome); 
     443  remove_end_slashes (gsdl_gdbmhome); 
     444  colinfo_tmap::iterator here = gsdl_collectinfo.begin(); 
     445  colinfo_tmap::iterator end = gsdl_collectinfo.end(); 
     446  while (here != end) { 
     447    remove_end_slashes ((*here).second.gsdl_gsdlhome); 
     448    remove_end_slashes ((*here).second.gsdl_gdbmhome); 
     449    here ++; 
     450  } 
     451 
     452  // check the browser settings 
     453  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded); 
     454} 
     455 
     456void gsdl_check_browser_settings (int netscapeneeded) { 
     457  check_installed_browsers (netscapeneeded); 
     458  check_browser_settings (gsdl_browser, gsdl_browser_exe, netscapeneeded); 
     459} 
     460 
     461 
     462static void dialog_update_enables (HWND hwndDlg) { 
     463  int res; 
     464   
     465  // if they want to use another browser, they should be able 
     466  // edit its filename 
     467  res = SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_GETCHECK,0,0); 
     468  SendDlgItemMessage(hwndDlg, ID_OTHER_NAME, WM_ENABLE, (res == 1), 0); 
     469} 
     470 
     471 
     472static int read_dialog_browser_field (HWND hwndDlg) { 
     473  if (SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, 
     474             BM_GETCHECK, 0, 0) == 1) return GS_NETSCAPE; 
     475  if (SendDlgItemMessage(hwndDlg, ID_RADIO_IE, 
     476             BM_GETCHECK, 0, 0) == 1) return GS_IEXPLORE; 
     477  if (SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, 
     478             BM_GETCHECK, 0, 0) == 1) return GS_OTHER; 
     479  return GS_NETSCAPE; 
     480} 
     481 
     482 
     483 
     484static void set_dialog_browser_field (HWND hwndDlg, int browser, char *othername) { 
     485  // if we are trying to set the browser to netscape or 
     486  // internet explorer and we can't find them, set the browser 
     487  // to 'other' 
     488  if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0')) 
     489    browser = GS_IEXPLORE; 
     490  if ((browser == GS_IEXPLORE) && (iexplore_exe[0] == '\0')) { 
     491    if (netscape_exe[0] != '\0') browser = GS_NETSCAPE; 
     492    else browser = GS_OTHER; 
     493  } 
     494   
     495  // update the radio buttons 
     496  SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, BM_SETCHECK, 
     497             (browser == GS_NETSCAPE) ? BST_CHECKED : BST_UNCHECKED, 0); 
     498  SendDlgItemMessage(hwndDlg, ID_RADIO_IE, BM_SETCHECK, 
     499             (browser == GS_IEXPLORE) ? BST_CHECKED : BST_UNCHECKED, 0); 
     500  SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_SETCHECK, 
     501             (browser == GS_OTHER) ? BST_CHECKED : BST_UNCHECKED, 0); 
     502   
     503  // update the other name field 
     504  if (browser == GS_NETSCAPE) { 
     505    SetDlgItemText(hwndDlg, ID_OTHER_NAME, netscape_exe); 
     506  } else if (browser == GS_IEXPLORE) { 
     507    SetDlgItemText(hwndDlg, ID_OTHER_NAME, iexplore_exe); 
     508  } else if (othername != NULL) { 
     509    SetDlgItemText(hwndDlg, ID_OTHER_NAME, othername); 
     510  } 
     511} 
     512 
     513 
     514static void read_browser_exe_field (HWND hwndDlg, char *filename, int maxsize) { 
     515  filename[0] = '\0'; 
     516  GetDlgItemText(hwndDlg, ID_OTHER_NAME, filename, maxsize); 
     517} 
     518 
     519 
     520static void read_dialog_fields (HWND hwndDlg) { 
     521  int res;  BOOL bres; 
     522   
     523  // port number 
     524  gsdl_port_num = GetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, &bres, 0); 
     525  if (!bres) gsdl_port_num = 80; 
     526   
     527  // whether to enter the library automatically on startup 
     528  res = SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_GETCHECK, 0, 0); 
     529  gsdl_auto_enter = (res == 1); 
     530   
     531  // which browser to use 
     532  gsdl_browser = read_dialog_browser_field (hwndDlg); 
     533   
     534  // find out where the browser exe lives 
     535  read_browser_exe_field (hwndDlg, gsdl_browser_exe, MAX_FILENAME_SIZE); 
     536} 
     537 
     538 
     539 
     540 
     541static BOOL CALLBACK dialog_proc(HWND hwndDlg, UINT uMsg,  
     542                 WPARAM wParam,LPARAM  lParam) { 
     543  int wNotifyCode = HIWORD(wParam); 
     544  int wID = LOWORD(wParam); 
     545  char *filefilter = "Program Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0"; 
     546  OPENFILENAME fname; 
     547  char filename[MAX_FILENAME_SIZE]; 
     548   
     549  switch (uMsg) { 
     550  case WM_INITDIALOG: 
     551    // set current values 
     552    SetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, gsdl_port_num, FALSE); 
     553    SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_SETCHECK, 
     554               gsdl_auto_enter ? 1 : 0, 0); 
     555    set_dialog_browser_field (hwndDlg, gsdl_browser, gsdl_browser_exe); 
     556    dialog_update_enables(hwndDlg); 
     557     
     558    // make sure that the netscape and internet explorer 
     559    // radio buttons are only enabled if they could be found 
     560    if (netscape_exe[0] == '\0') 
     561      EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_NETSCAPE), FALSE); 
     562    if (iexplore_exe[0] == '\0') 
     563      EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_IE), FALSE); 
     564     
     565    return 1; 
     566     
     567  case WM_COMMAND: 
     568    if (wNotifyCode == BN_CLICKED) { 
     569      switch (wID) { 
     570      case ID_CANCEL_BUTTON: 
     571    EndDialog(hwndDlg, 0); 
     572    return 1; 
     573     
     574      case ID_OK_BUTTON: 
     575    // check to make sure we can find the browser 
     576    filename[0] = '\0'; 
     577    read_browser_exe_field (hwndDlg, filename, MAX_FILENAME_SIZE); 
     578    if (check_program_exe (filename)) {  
     579      // the file exists 
     580      // if netscape is needed, make sure the browser is netscape 
     581      _strlwr(filename); 
     582      if (!gsdl_netscapeneeded || strstr (filename, "netscape.exe") != NULL) { 
     583        // everything is ok 
     584        read_dialog_fields(hwndDlg); 
     585        EndDialog(hwndDlg, 1); 
     586         
     587      } else { 
     588        // message: must use netscape with this version 
     589        MessageBox(hwndDlg, 
     590               "You are using this software on a machine which\n" 
     591               "currently does not have a working TCP/IP network layer.\n" 
     592               "To allow the Greenstone Digital Library software to use\n" 
     593               "its own TCP/IP network layer you must use a Netscape\n" 
     594               "browser. If you do not have Netscape installed, please\n" 
     595               "choose 'Install Netscape 4.05' from the 'Files' menu.", 
     596               "Greenstone Digital Library Software", 
     597               MB_OK|MB_APPLMODAL); 
     598      } 
     599    } else { 
     600      // message: the file did not exist 
     601      MessageBox(hwndDlg, 
     602             "Could not find the selected browser. If you do not\n" 
     603             "have a browser installed, please choose\n" 
     604             "'Install Netscape 4.05' from the 'Files' menu.", 
     605             "Greenstone Digital Library Software", 
     606             MB_OK|MB_APPLMODAL); 
    307607    } 
    308  
    309  
    310     // get the browser's executable 
    311     if (browser == GS_NETSCAPE) { 
    312         strcpy (browser_exe, netscape_exe); 
    313     } else if (browser == GS_IEXPLORE) { 
    314         strcpy (browser_exe, iexplore_exe); 
    315     } else { 
    316         browser = GS_OTHER; 
    317          
    318         // if the browser should be netscape then check to 
    319         // make sure it is 
    320         if (netscapeneeded && !browser_compare (browser_exe, "netscape.exe")) { 
    321             // not netscape, set to no browser 
    322             browser_exe[0] = '\0'; 
    323         } 
     608    return 1; 
     609     
     610      case ID_RADIO_NETSCAPE: 
     611    set_dialog_browser_field (hwndDlg, GS_NETSCAPE, NULL); 
     612    dialog_update_enables(hwndDlg); 
     613    return 1; 
     614     
     615      case ID_RADIO_IE: 
     616    set_dialog_browser_field (hwndDlg, GS_IEXPLORE, NULL); 
     617    dialog_update_enables(hwndDlg); 
     618    return 1; 
     619     
     620      case ID_RADIO_OTHER: 
     621    set_dialog_browser_field (hwndDlg, GS_OTHER, NULL); 
     622    dialog_update_enables(hwndDlg); 
     623    return 1; 
     624     
     625      case ID_BROWSE_BUTTON: 
     626    filename[0] = '\0'; 
     627    memset(&fname, 0, sizeof(OPENFILENAME)); 
     628    fname.lStructSize = sizeof(OPENFILENAME); 
     629    fname.hwndOwner = hwndDlg; 
     630    fname.hInstance = NULL; 
     631    fname.lpstrFilter = filefilter; 
     632    fname.lpstrCustomFilter = NULL; 
     633    fname.nMaxCustFilter = 0; 
     634    fname.nFilterIndex = 1; 
     635    fname.lpstrFile = filename; 
     636    fname.nMaxFile = MAX_FILENAME_SIZE-1; 
     637    fname.lpstrFileTitle = NULL; 
     638    fname.nMaxFileTitle = 0; 
     639    fname.lpstrInitialDir = NULL; 
     640    fname.lpstrTitle = "Choose Web Browser"; 
     641    fname.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; 
     642     
     643    if(GetOpenFileName(&fname)) { 
     644      set_dialog_browser_field (hwndDlg, GS_OTHER, filename); 
     645      dialog_update_enables(hwndDlg); 
    324646    } 
    325 } 
    326  
    327  
    328 static void revert_defaults (int netscapeneeded) { 
    329     find_location(); 
    330      
    331     // library settings 
    332     strcpy (gs_enterlib,"/cgi-bin/gw"); 
    333     strcpy (gs_gsdlhome, data_location); 
    334     strcpy (gs_macroshome, data_location); 
    335     strcpy (gs_gdbmhome, data_location); 
    336     strcpy (gs_indexhome, data_location); 
    337  
    338     strcpy (gs_staticpages, "d:\\static"); 
    339  
    340     // debug settings 
    341     gs_keep_log = 0; 
    342     strcpy (gs_log_name, "c:\\gsdl.log"); 
    343     gs_show_console = 0; 
    344  
    345     // general settings 
    346     gs_port_num = 80; 
    347     gs_auto_enter = 0; 
    348  
    349     check_installed_browsers (netscapeneeded); 
    350     gs_browser = GS_NETSCAPE; 
    351     strcpy (gs_browser_exe, default_browser_exe); 
    352     check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded); 
    353 } 
    354  
    355  
    356 // debug settings 
    357  
    358 // general settings 
    359 extern int gs_port_num;                        // portnumber 
    360 extern int gs_auto_enter;                      // autoenter 
    361 extern int gs_browser;                         // browser 
    362 extern char gs_browser_exe[MAX_FILENAME_SIZE]; // browserexe 
    363  
    364  
    365  
    366 void read_settings (int netscapeneeded) { 
    367     char conffile[MAX_FILENAME_SIZE]; 
    368  
    369     find_location(); 
    370  
    371     strcpy (conffile, data_location); 
    372     remove_end_slashes (conffile); 
    373     strcat (conffile, "\\gsdl.ini"); 
    374  
    375     // set up defaults 
    376     revert_defaults (netscapeneeded); 
    377  
    378     text_t key, value; 
    379     char *cstr_value; 
    380     ifstream conf (conffile, ios::nocreate); 
    381     if (conf) { 
    382         while (get_confline(conf, key, value) >= 0) { 
    383             cstr_value = value.getcstr (); 
    384  
    385             if (key == "enterlib") { 
    386                 strcpy (gs_enterlib, cstr_value); 
    387  
    388             } else if (key == "gsdlhome") { 
    389                 strcpy (gs_gsdlhome, cstr_value); 
    390                 strcpy (gs_macroshome, cstr_value); 
    391                 strcpy (gs_gdbmhome, cstr_value); 
    392                 strcpy (gs_indexhome, cstr_value); 
    393  
    394             } else if (key == "macroshome") { 
    395                 strcpy (gs_macroshome, cstr_value); 
    396  
    397             } else if (key == "gdbmhome") { 
    398                 strcpy (gs_gdbmhome, cstr_value); 
    399  
    400             } else if (key == "indexhome") { 
    401                 strcpy (gs_indexhome, cstr_value); 
    402  
    403  
    404             } else if (key == "staticpages") { 
    405                 strcpy (gs_staticpages, cstr_value); 
    406  
    407  
    408             // 'logfilename' should occur in the configuration file 
    409             // before 'keeplog' 
    410             } else if (key == "logfilename") { 
    411                 strcpy (gs_log_name, cstr_value); 
    412  
    413             } else if (key == "keeplog") { 
    414                 gs_keep_log = value.getint(); 
    415                 if (gs_keep_log) open_log_file(); 
    416  
    417             } else if (key == "consolelog") { 
    418                 if (value.getint()) activate_console(); 
    419                 else deactivate_console(); 
    420  
    421              
    422             } else if (key == "portnumber") { 
    423                 gs_port_num = value.getint(); 
    424  
    425             } else if (key == "autoenter") { 
    426                 gs_auto_enter = value.getint(); 
    427  
    428             } else if (key == "browser") { 
    429                 gs_browser = value.getint(); 
    430  
    431             } else if (key == "browserexe") { 
    432                 strcpy (gs_browser_exe, cstr_value); 
    433             } 
    434  
    435             delete cstr_value; 
    436         } 
    437         conf.close(); 
    438     } 
    439  
    440     // check the homes to make sure they don't contain 
    441     // extra slashes at the end 
    442     remove_end_slashes (gs_gsdlhome); 
    443     remove_end_slashes (gs_macroshome); 
    444     remove_end_slashes (gs_gdbmhome); 
    445     remove_end_slashes (gs_indexhome); 
    446     remove_end_slashes (gs_staticpages); 
    447  
    448     // check the browser settings 
    449     check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded); 
    450 } 
    451  
    452  
    453  
    454  
    455 void gs_check_browser_settings (int netscapeneeded) { 
    456     check_installed_browsers (netscapeneeded); 
    457     check_browser_settings (gs_browser, gs_browser_exe, netscapeneeded); 
    458 } 
    459  
    460  
    461 static void dialog_update_enables (HWND hwndDlg) { 
    462     int res; 
    463  
    464     // if they want to use another browser, they should be able 
    465     // edit its filename 
    466     res = SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_GETCHECK,0,0); 
    467     SendDlgItemMessage(hwndDlg, ID_OTHER_NAME, WM_ENABLE, (res == 1), 0); 
    468 } 
    469  
    470  
    471 static int read_dialog_browser_field (HWND hwndDlg) { 
    472     if (SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, 
    473             BM_GETCHECK, 0, 0) == 1) return GS_NETSCAPE; 
    474     if (SendDlgItemMessage(hwndDlg, ID_RADIO_IE, 
    475             BM_GETCHECK, 0, 0) == 1) return GS_IEXPLORE; 
    476     if (SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, 
    477             BM_GETCHECK, 0, 0) == 1) return GS_OTHER; 
    478     return GS_NETSCAPE; 
    479 } 
    480  
    481  
    482  
    483 static void set_dialog_browser_field (HWND hwndDlg, int browser, char *othername) { 
    484     // if we are trying to set the browser to netscape or 
    485     // internet explorer and we can't find them, set the browser 
    486     // to 'other' 
    487     if ((browser == GS_NETSCAPE) && (netscape_exe[0] == '\0')) 
    488         browser = GS_IEXPLORE; 
    489     if ((browser == GS_IEXPLORE) && (iexplore_exe[0] == '\0')) { 
    490         if (netscape_exe[0] != '\0') browser = GS_NETSCAPE; 
    491         else browser = GS_OTHER; 
    492     } 
    493  
    494     // update the radio buttons 
    495     SendDlgItemMessage(hwndDlg, ID_RADIO_NETSCAPE, BM_SETCHECK, 
    496         (browser == GS_NETSCAPE) ? BST_CHECKED : BST_UNCHECKED, 0); 
    497     SendDlgItemMessage(hwndDlg, ID_RADIO_IE, BM_SETCHECK, 
    498         (browser == GS_IEXPLORE) ? BST_CHECKED : BST_UNCHECKED, 0); 
    499     SendDlgItemMessage(hwndDlg, ID_RADIO_OTHER, BM_SETCHECK, 
    500         (browser == GS_OTHER) ? BST_CHECKED : BST_UNCHECKED, 0); 
    501  
    502     // update the other name field 
    503     if (browser == GS_NETSCAPE) { 
    504         SetDlgItemText(hwndDlg, ID_OTHER_NAME, netscape_exe); 
    505     } else if (browser == GS_IEXPLORE) { 
    506         SetDlgItemText(hwndDlg, ID_OTHER_NAME, iexplore_exe); 
    507     } else if (othername != NULL) { 
    508         SetDlgItemText(hwndDlg, ID_OTHER_NAME, othername); 
    509     } 
    510 } 
    511  
    512  
    513 static void read_browser_exe_field (HWND hwndDlg, char *filename, int maxsize) { 
    514     filename[0] = '\0'; 
    515     GetDlgItemText(hwndDlg, ID_OTHER_NAME, filename, maxsize); 
    516 } 
    517  
    518  
    519 static void read_dialog_fields (HWND hwndDlg) { 
    520     int res;  BOOL bres; 
    521  
    522     // port number 
    523     gs_port_num = GetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, &bres, 0); 
    524     if (!bres) gs_port_num = 80; 
    525      
    526     // whether to enter the library automatically on startup 
    527     res = SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_GETCHECK, 0, 0); 
    528     gs_auto_enter = (res == 1); 
    529  
    530     // which browser to use 
    531     gs_browser = read_dialog_browser_field (hwndDlg); 
    532  
    533     // find out where the browser exe lives 
    534     read_browser_exe_field (hwndDlg, gs_browser_exe, MAX_FILENAME_SIZE); 
    535 } 
    536  
    537  
    538  
    539  
    540 static BOOL CALLBACK dialog_proc(HWND hwndDlg, UINT uMsg,  
    541                                 WPARAM wParam,LPARAM  lParam) { 
    542     int wNotifyCode = HIWORD(wParam); 
    543     int wID = LOWORD(wParam); 
    544     char *filefilter = "Program Files (*.exe)\0*.exe\0All Files (*.*)\0*.*\0\0"; 
    545     OPENFILENAME fname; 
    546     char filename[MAX_FILENAME_SIZE]; 
    547  
    548     switch (uMsg) { 
    549     case WM_INITDIALOG: 
    550         // set current values 
    551         SetDlgItemInt(hwndDlg, SERVER_PORT_EDIT_BOX, gs_port_num, FALSE); 
    552         SendDlgItemMessage(hwndDlg, ID_AUTO_ENTER_LIBRARY, BM_SETCHECK, 
    553             gs_auto_enter ? 1 : 0, 0); 
    554         set_dialog_browser_field (hwndDlg, gs_browser, gs_browser_exe); 
    555         dialog_update_enables(hwndDlg); 
    556  
    557         // make sure that the netscape and internet explorer 
    558         // radio buttons are only enabled if they could be found 
    559         if (netscape_exe[0] == '\0') 
    560             EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_NETSCAPE), FALSE); 
    561         if (iexplore_exe[0] == '\0') 
    562             EnableWindow (GetDlgItem (hwndDlg, ID_RADIO_IE), FALSE); 
    563  
    564         return 1; 
    565  
    566     case WM_COMMAND: 
    567         if (wNotifyCode == BN_CLICKED) { 
    568             switch (wID) { 
    569             case ID_CANCEL_BUTTON: 
    570                 EndDialog(hwndDlg, 0); 
    571                 return 1; 
    572  
    573             case ID_OK_BUTTON: 
    574                 // check to make sure we can find the browser 
    575                 filename[0] = '\0'; 
    576                 read_browser_exe_field (hwndDlg, filename, MAX_FILENAME_SIZE); 
    577                 if (check_program_exe (filename)) {  
    578                     // the file exists 
    579                     // if netscape is needed, make sure the browser is netscape 
    580                     _strlwr(filename); 
    581                     if (!gs_netscapeneeded || strstr (filename, "netscape.exe") != NULL) { 
    582                         // everything is ok 
    583                         read_dialog_fields(hwndDlg); 
    584                         EndDialog(hwndDlg, 1); 
    585  
    586                     } else { 
    587                         // message: must use netscape with this version 
    588                         MessageBox(hwndDlg, 
    589                                 "You are using this software on a machine which\n" 
    590                                 "currently does not have a working TCP/IP network layer.\n" 
    591                                 "To allow the Greenstone Digital Library software to use\n" 
    592                                 "its own TCP/IP network layer you must use a Netscape\n" 
    593                                 "browser. If you do not have Netscape installed, please\n" 
    594                                 "choose 'Install Netscape 4.05' from the 'Files' menu.", 
    595                                 "Greenstone Digital Library Software", 
    596                                 MB_OK|MB_APPLMODAL); 
    597                     } 
    598                 } else { 
    599                     // message: the file did not exist 
    600                     MessageBox(hwndDlg, 
    601                             "Could not find the selected browser. If you do not\n" 
    602                             "have a browser installed, please choose\n" 
    603                             "'Install Netscape 4.05' from the 'Files' menu.", 
    604                             "Greenstone Digital Library Software", 
    605                             MB_OK|MB_APPLMODAL); 
    606                 } 
    607                 return 1; 
    608  
    609             case ID_RADIO_NETSCAPE: 
    610                 set_dialog_browser_field (hwndDlg, GS_NETSCAPE, NULL); 
    611                 dialog_update_enables(hwndDlg); 
    612                 return 1; 
    613  
    614             case ID_RADIO_IE: 
    615                 set_dialog_browser_field (hwndDlg, GS_IEXPLORE, NULL); 
    616                 dialog_update_enables(hwndDlg); 
    617                 return 1; 
    618  
    619             case ID_RADIO_OTHER: 
    620                 set_dialog_browser_field (hwndDlg, GS_OTHER, NULL); 
    621                 dialog_update_enables(hwndDlg); 
    622                 return 1; 
    623  
    624             case ID_BROWSE_BUTTON: 
    625                 filename[0] = '\0'; 
    626                 memset(&fname, 0, sizeof(OPENFILENAME)); 
    627                 fname.lStructSize = sizeof(OPENFILENAME); 
    628                 fname.hwndOwner = hwndDlg; 
    629                 fname.hInstance = NULL; 
    630                 fname.lpstrFilter = filefilter; 
    631                 fname.lpstrCustomFilter = NULL; 
    632                 fname.nMaxCustFilter = 0; 
    633                 fname.nFilterIndex = 1; 
    634                 fname.lpstrFile = filename; 
    635                 fname.nMaxFile = MAX_FILENAME_SIZE-1; 
    636                 fname.lpstrFileTitle = NULL; 
    637                 fname.nMaxFileTitle = 0; 
    638                 fname.lpstrInitialDir = NULL; 
    639                 fname.lpstrTitle = "Choose Web Browser"; 
    640                 fname.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; 
    641  
    642                 if(GetOpenFileName(&fname)) { 
    643                     set_dialog_browser_field (hwndDlg, GS_OTHER, filename); 
    644                     dialog_update_enables(hwndDlg); 
    645                 } 
    646                 return 1; 
    647             } 
    648         } 
    649         return 0; 
    650  
    651     case WM_CLOSE: 
    652     case WM_DESTROY: 
    653         EndDialog(hwndDlg, 0); 
    654         return 1; 
    655     } 
    656  
    657     return 0; 
    658 } 
    659  
    660  
     647    return 1; 
     648      } 
     649    } 
     650    return 0; 
     651     
     652  case WM_CLOSE: 
     653  case WM_DESTROY: 
     654    EndDialog(hwndDlg, 0); 
     655    return 1; 
     656  } 
     657   
     658  return 0; 
     659} 
    661660 
    662661static void dialog_debug_update_enables (HWND hwndDlg) { 
    663     int res; 
    664  
    665     // if they want a log of program use allow them to 
    666     // edit its filename 
    667     res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0); 
    668     SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, WM_ENABLE, (res == 1), 0); 
     662  int res; 
     663   
     664  // if they want a log of program use allow them to 
     665  // edit its filename 
     666  res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0); 
     667  SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, WM_ENABLE, (res == 1), 0); 
    669668} 
    670669 
    671670 
    672671static void read_dialog_debug_fields (HWND hwndDlg) { 
    673     int res; 
    674  
    675     // whether to log program use 
    676     res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0); 
    677     gs_keep_log = (res == 1); 
    678  
    679     // log filename 
    680     res = SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, EM_GETMODIFY,0,0); 
    681     if (res != 0) { 
    682         res = GetDlgItemText(hwndDlg, LOG_NAME_BOX, gs_log_name, MAX_FILENAME_SIZE); 
    683     } 
    684  
    685     // whether to display log information on console 
    686     res = SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_GETCHECK,0,0); 
    687     gs_show_console = (res == 1); 
     672  int res; 
     673   
     674  // whether to log program use 
     675  res = SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_GETCHECK,0,0); 
     676  gsdl_keep_log = (res == 1); 
     677   
     678  // log filename 
     679  res = SendDlgItemMessage(hwndDlg, LOG_NAME_BOX, EM_GETMODIFY,0,0); 
     680  if (res != 0) { 
     681    res = GetDlgItemText(hwndDlg, LOG_NAME_BOX, gsdl_log_name, MAX_FILENAME_SIZE); 
     682  } 
     683   
     684  // whether to display log information on console 
     685  res = SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_GETCHECK,0,0); 
     686  gsdl_show_console = (res == 1); 
    688687} 
    689688 
    690689 
    691690static BOOL CALLBACK dialog_debug_proc(HWND hwndDlg, UINT uMsg,  
    692                                         WPARAM wParam,LPARAM  lParam) { 
    693     int wNotifyCode = HIWORD(wParam); 
    694     int wID = LOWORD(wParam); 
    695  
    696     switch (uMsg) { 
    697     case WM_INITDIALOG: 
    698         // set current values 
    699         SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_SETCHECK, 
    700             gs_keep_log ? 1 : 0, 0); 
    701         SetDlgItemText(hwndDlg, LOG_NAME_BOX, gs_log_name); 
    702         SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_SETCHECK, 
    703             gs_show_console ? 1 : 0, 0); 
    704         dialog_debug_update_enables(hwndDlg); 
    705         return 1; 
    706  
    707     case WM_COMMAND: 
    708         if (wNotifyCode == BN_CLICKED) { 
    709             switch (wID) { 
    710             case ID_CANCEL_BUTTON: 
    711                 EndDialog(hwndDlg, 0); 
    712                 return 1; 
    713  
    714             case ID_OK_BUTTON: 
    715                 read_dialog_debug_fields(hwndDlg); 
    716                 EndDialog(hwndDlg, 1); 
    717                 return 1; 
    718  
    719             case LOG_CHECK: 
    720                 dialog_debug_update_enables(hwndDlg); 
    721                 return 1; 
    722             } 
    723         } 
    724         return 0; 
    725  
    726     case WM_CLOSE: 
    727     case WM_DESTROY: 
    728         EndDialog(hwndDlg, 0); 
    729         return 1; 
    730     } 
    731  
    732     return 0; 
     691                       WPARAM wParam,LPARAM  lParam) { 
     692  int wNotifyCode = HIWORD(wParam); 
     693  int wID = LOWORD(wParam); 
     694   
     695  switch (uMsg) { 
     696  case WM_INITDIALOG: 
     697    // set current values 
     698    SendDlgItemMessage(hwndDlg, LOG_CHECK, BM_SETCHECK, 
     699               gsdl_keep_log ? 1 : 0, 0); 
     700    SetDlgItemText(hwndDlg, LOG_NAME_BOX, gsdl_log_name); 
     701    SendDlgItemMessage(hwndDlg, CONSOLE_CHECK, BM_SETCHECK, 
     702               gsdl_show_console ? 1 : 0, 0); 
     703    dialog_debug_update_enables(hwndDlg); 
     704    return 1; 
     705     
     706  case WM_COMMAND: 
     707    if (wNotifyCode == BN_CLICKED) { 
     708      switch (wID) { 
     709      case ID_CANCEL_BUTTON: 
     710    EndDialog(hwndDlg, 0); 
     711    return 1; 
     712     
     713      case ID_OK_BUTTON: 
     714    read_dialog_debug_fields(hwndDlg); 
     715    EndDialog(hwndDlg, 1); 
     716    return 1; 
     717     
     718      case LOG_CHECK: 
     719    dialog_debug_update_enables(hwndDlg); 
     720    return 1; 
     721      } 
     722    } 
     723    return 0; 
     724     
     725  case WM_CLOSE: 
     726  case WM_DESTROY: 
     727    EndDialog(hwndDlg, 0); 
     728    return 1; 
     729  } 
     730   
     731  return 0; 
    733732} 
    734733 
     
    736735void Settings_Dialog(HWND window, int netscapeneeded) 
    737736{ 
    738     int old_gs_show_console = gs_show_console; 
    739     int old_gs_port_num = gs_port_num; 
    740  
    741     int res = 0; 
    742      
    743  
    744     gs_netscapeneeded = netscapeneeded; 
    745  
    746     if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) &&  
    747         (GetAsyncKeyState(VkKeyScan('d')) & 0x8000)) { 
    748         // control-D was pressed, display debug settings 
    749         // dialog box 
    750         res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG_DEBUG), 
    751             window, (DLGPROC)dialog_debug_proc); 
    752  
    753         if (res == 1) { 
    754             // only update if exited via the OK button 
    755             if (gs_keep_log) open_log_file();  
    756             else close_log_file(); 
    757  
    758             // turn the console on/off if we need to 
    759             if (gs_show_console != old_gs_show_console) { 
    760                 if (gs_show_console) activate_console (); 
    761                 else deactivate_console (); 
    762             } 
    763         } 
    764  
    765     } else { 
    766         // display normal settings dialog box 
    767  
    768         // make sure everything is up-to-date 
    769         gs_check_browser_settings (netscapeneeded); 
    770  
    771         res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG2), 
    772             window, (DLGPROC)dialog_proc); 
    773  
    774         if (res == 1) { 
    775             // only update if exited via the OK button 
    776             if (gs_port_num != old_gs_port_num) { 
    777                 EndHTTPServer(); 
    778                 StartHTTPServer(window); 
    779             } 
    780         } 
    781     } 
    782  
    783     // save the settings if we exited via the ok button 
    784     if (res == 1) { 
    785         write_settings(); 
    786     } 
    787 } 
     737  int old_gsdl_show_console = gsdl_show_console; 
     738  int old_gsdl_port_num = gsdl_port_num; 
     739   
     740  int res = 0; 
     741   
     742  gsdl_netscapeneeded = netscapeneeded; 
     743   
     744  if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) &&  
     745      (GetAsyncKeyState(VkKeyScan('d')) & 0x8000)) { 
     746    // control-D was pressed, display debug settings 
     747    // dialog box 
     748    res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG_DEBUG), 
     749             window, (DLGPROC)dialog_debug_proc); 
     750     
     751    if (res == 1) { 
     752      // only update if exited via the OK button 
     753      if (gsdl_keep_log) open_log_file();  
     754      else close_log_file(); 
     755       
     756      // turn the console on/off if we need to 
     757      if (gsdl_show_console != old_gsdl_show_console) { 
     758    if (gsdl_show_console) activate_console (); 
     759    else deactivate_console (); 
     760      } 
     761    } 
     762     
     763  } else { 
     764    // display normal settings dialog box 
     765     
     766    // make sure everything is up-to-date 
     767    gsdl_check_browser_settings (netscapeneeded); 
     768     
     769    res = DialogBox (NULL, MAKEINTRESOURCE(COMMS_DIALOG2), 
     770             window, (DLGPROC)dialog_proc); 
     771 
     772    if (res == 1) { 
     773      // only update if exited via the OK button 
     774      if (gsdl_port_num != old_gsdl_port_num) { 
     775    EndHTTPServer(); 
     776    StartHTTPServer(window); 
     777      } 
     778    } 
     779  } 
     780   
     781  // save the settings if we exited via the ok button 
     782  if (res == 1) { 
     783    write_settings(); 
     784    // reset httpprefix in case port number was changed 
     785    //    configure_httpprefix (); 
     786  } 
     787} 
  • trunk/gsdl/src/w32server/settings.h

    r611 r902  
    1010#define GS_OTHER    2 
    1111 
     12#include "text_t.h" 
     13#include "cfgread.h" 
    1214 
    1315// library settings 
    14 extern char gs_enterlib[MAX_FILENAME_SIZE];    // enterlib 
    15 extern char gs_gsdlhome[MAX_FILENAME_SIZE];    // gsdlhome 
    16 extern char gs_macroshome[MAX_FILENAME_SIZE];  // macroshome 
    17 extern char gs_gdbmhome[MAX_FILENAME_SIZE];    // gdbmhome 
    18 extern char gs_indexhome[MAX_FILENAME_SIZE];   // indexhome 
     16extern text_t gsdl_enterlib; 
     17extern text_t gsdl_gsdlhome; 
     18extern text_t gsdl_gdbmhome; 
     19extern text_t gsdl_collections; 
     20extern colinfo_tmap gsdl_collectinfo; 
    1921 
    20 extern char gs_staticpages[MAX_FILENAME_SIZE]; // staticpages 
     22extern char gsdl_staticpages[MAX_FILENAME_SIZE]; 
    2123 
    2224// debug settings 
    23 extern char gs_log_name[MAX_FILENAME_SIZE];    // logfilename 
    24 extern int gs_keep_log;                        // keeplog 
    25 extern int gs_show_console;                    // consolelog 
     25extern char gsdl_log_name[MAX_FILENAME_SIZE]; 
     26extern int gsdl_keep_log; 
     27extern int gsdl_show_console; 
    2628 
    2729// general settings 
    28 extern int gs_port_num;                        // portnumber 
    29 extern int gs_auto_enter;                      // autoenter 
    30 extern int gs_browser;                         // browser 
    31 extern char gs_browser_exe[MAX_FILENAME_SIZE]; // browserexe 
    32  
     30extern int gsdl_port_num; 
     31extern int gsdl_auto_enter; 
     32extern int gsdl_browser; 
     33extern char gsdl_browser_exe[MAX_FILENAME_SIZE]; 
    3334 
    3435void Settings_Dialog(HWND window, int netscapeneeded); 
     
    3738void write_settings (); 
    3839 
    39 void gs_check_browser_settings (int netscapeneeded); 
     40void gsdl_check_browser_settings (int netscapeneeded); 
    4041 
    4142#endif