Changeset 5889


Ignore:
Timestamp:
2003-11-19T12:14:36+13:00 (20 years ago)
Author:
jmt12
Message:

Added a new argument to the server, --cmd=init, which is used to generate the GSDLSite.cfg file without starting the server itself. Thus it can be run once during the Greenstone installation to create the file needed for GLI to run properly

File:
1 edited

Legend:

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

    r4642 r5889  
    140140int init_done = 0;
    141141
    142 void finish_up() {
     142
     143// Added an argument so you can specify not to do any of the windows orientated clean up - jmt12 18/11/2003
     144void finish_up(bool init_only) {
    143145  // remember the current preferences
    144146  write_settings("");
    145147
    146   // Shutdown the HTTP server
     148  if(init_only) {
     149    return;
     150  }
     151   
     152 // Shutdown the HTTP server
    147153  EndHTTPServer();
    148154 
     
    539545    break;
    540546      case ID_PROJECT_EXIT:
    541         finish_up();
     547        finish_up(false);
    542548        break;
    543549      default:
     
    556562   
    557563  case WM_DESTROY:
    558     finish_up();
     564    finish_up(false);
    559565    break;
    560566   
     
    669675            "Greenstone Digital Library Software", MB_OK|MB_APPLMODAL);
    670676    PostMessage(MsgWindow,WM_CLOSE,0,0);
    671     finish_up(); // will unload winsock
     677    finish_up(false); // will unload winsock
    672678    exit(0);      // nothing more to do
    673679      }
     
    831837// --config=file (the path to the configuration file to use which defaults
    832838// to GSDLHOME\gsdlsite.cfg)
    833 static void parse_args(const text_t cmdline, text_t &location, text_t &config_file) {
     839// --cmd=init  Used to initialize the gsdlsite.cfg file onlt - jmt12 18/11/2003
     840static void parse_args(const text_t cmdline, text_t &location, text_t &config_file, text_t &command) {
    834841
    835842  location.clear();
    836843  config_file.clear();
     844  command.clear(); // jmt12 18/11/2003
    837845
    838846  if (cmdline.size() < 3) return;
     
    849857      } else if (name == "config") {
    850858    config_file = val;
     859      }
     860      // jmt12 18/11/2003
     861      else if(name == "cmd") {
     862    command = val;
    851863      }
    852864      foundname = false;
     
    869881    config_file = val;
    870882  }
    871 }
    872 
    873 
     883  // jmt12 18/11/2003
     884  else if(name == "cmd") {
     885    command = val;
     886  }
     887}
     888
     889// Added code to allow for an 'init' run of the server which just creates the gsdlsite.cfg file
    874890int __stdcall WinMain(HINSTANCE Instance, HINSTANCE /*PrevInstance*/, LPSTR CmdLineStr, int /*CmdShow*/) {
    875891  HWND MainWindow;  MSG Message;  WNDCLASS MainClass; 
    876892
    877893  // parse arguments
    878   text_t location, config_file;
    879   parse_args(CmdLineStr, location, config_file);
     894  text_t location, config_file, command;
     895  parse_args(CmdLineStr, location, config_file, command);
    880896  gsdl_conffile = config_file;
     897
     898  // jmt12 18/11/2003
     899  if(command == "init") {
     900    // init various modules
     901    read_settings(0); // don't know if netscape is needed at this point
     902    finish_up(true);
     903    exit(0);
     904  }
    881905
    882906  //Create a window class
     
    894918    return 0;
    895919 
    896 
     920 
    897921  // Load various bitmaps
    898922  coltitlebitmap = LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_COL_TITLE));
    899923  logobitmap= LoadBitmap (Instance, MAKEINTRESOURCE(GSDL_LOGO));
    900 
     924 
    901925  // Create the main window
    902926  MainWindow = CreateWindow("Greenstone Digital Library Software",
     
    928952  GetTextMetrics(pdc, &tm);
    929953  line_spacing = tm.tmHeight + tm.tmExternalLeading;
    930   GSDL_Window = MainWindow;
    931  
     954  GSDL_Window = MainWindow; 
     955
    932956  // init various modules
    933957  read_settings (0); // don't know if netscape is needed at this point
    934 
     958 
    935959  if (!gsdl_auto_enter) {
    936 
     960   
    937961    // add the select version checkbox
    938962    Enter = CreateWindow("BUTTON",             // predefined class
     
    971995                  Instance,
    972996                  NULL);                   // pointer not needed
    973 
     997   
    974998    HANDLE i_icon = LoadImage (Instance, MAKEINTRESOURCE(GSDL_ICBMP), IMAGE_BITMAP,
    975999                   INFOBUTTONWIDTH-4, ALTERNATIVEBUTTONHEIGHT-4, LR_DEFAULTCOLOR);
    9761000    SendMessage (InfoRestricted, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)i_icon);
    977 
     1001   
    9781002    SetFocus (Enter);
    9791003   
    9801004    enterstring = strenterlib;
    9811005    paint_window (pdc, windowRect);
    982 
     1006   
    9831007    // message loop for init buttons
    9841008    while (!init_done) {
     
    9931017      }
    9941018    }
    995 
     1019   
    9961020    // don't want these buttons anymore
    9971021    DestroyWindow (Enter);
    9981022    DestroyWindow (EnterRestricted);
    9991023    DestroyWindow (InfoRestricted);
    1000 
     1024   
    10011025    enterstring = strnothing;
    10021026    paint_window (pdc, windowRect);
    1003 
     1027   
    10041028  } else {
    10051029    // auto enter is enabled - start up standard version
     
    10071031    init_done = 1;
    10081032  }
    1009 
     1033 
    10101034  // draw the main window containing an init message
    10111035  infostring = strinit;
    10121036  paint_window (pdc, windowRect);
    10131037  DWORD lastcheck = GetTickCount();
    1014 
     1038 
    10151039  have_networking = initnetwork (Instance, MainWindow);
    10161040  if (!have_networking) {
     
    10201044    exit (0);
    10211045  }
    1022 
     1046 
    10231047  if (!gsdl_init()) // quit if can't initialise the library correctly
    10241048    exit (0);
    10251049  initstartbrowser();
    10261050  log_computer_info ();
    1027 
     1051 
    10281052  // show the initialising message for at least 1 second
    10291053  while (DiffTickCounts (lastcheck, GetTickCount()) < 1000) {
     
    10571081  infostring = strrestartlib;
    10581082  paint_window (pdc, windowRect);
    1059 
     1083 
    10601084  // release the DC used to display the init messages
    10611085  ReleaseDC (MainWindow, pdc);
     
    11101134    } else {
    11111135      // no browser was found
    1112 
     1136     
    11131137      if (seenbrowser) {
    11141138        // we have seen a browser in the past
     
    11301154  return Message.wParam;
    11311155}
     1156
Note: See TracChangeset for help on using the changeset viewer.