Ignore:
Timestamp:
2003-06-13T12:24:12+12:00 (21 years ago)
Author:
sjboddie
Message:

Added command line arguments to server.exe so the GLI can tell it to use
an alternative config file.

File:
1 edited

Legend:

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

    r4339 r4642  
    631631   
    632632    find_location();
    633     strcpy (winsockpath, data_location);
     633    char *data_location_c = data_location.getcstr();
     634    strcpy (winsockpath, data_location_c);
     635    delete data_location_c;
    634636   
    635637    // remove all the slashes at the end of billpath
     
    824826}
    825827
     828// possible command line options are
     829// --location=directory (the path to GSDLHOME which defaults to the
     830// directory where server.exe lives)
     831// --config=file (the path to the configuration file to use which defaults
     832// to GSDLHOME\gsdlsite.cfg)
     833static void parse_args(const text_t cmdline, text_t &location, text_t &config_file) {
     834
     835  location.clear();
     836  config_file.clear();
     837
     838  if (cmdline.size() < 3) return;
     839
     840  text_t name, val;
     841  bool foundname = false;
     842  text_t::const_iterator here = cmdline.begin();
     843  text_t::const_iterator end = cmdline.end();
     844  while (here != end) {
     845    if (*here == '-' && ((here+1) != end) && (*(here+1) == '-')) {
     846      here++;
     847      if (name == "location") {
     848    location = val;
     849      } else if (name == "config") {
     850    config_file = val;
     851      }
     852      foundname = false;
     853      name.clear();
     854      val.clear();
     855    } else if (*here == '=') {
     856      foundname = true;
     857    } else {
     858      if (foundname) {
     859    val.push_back(*here);
     860      } else {
     861    name.push_back(*here);
     862      }
     863    }
     864    here++;
     865  }
     866  if (name == "location") {
     867    location = val;
     868  } else if (name == "config") {
     869    config_file = val;
     870  }
     871}
     872
    826873
    827874int __stdcall WinMain(HINSTANCE Instance, HINSTANCE /*PrevInstance*/, LPSTR CmdLineStr, int /*CmdShow*/) {
    828875  HWND MainWindow;  MSG Message;  WNDCLASS MainClass; 
    829  
     876
     877  // parse arguments
     878  text_t location, config_file;
     879  parse_args(CmdLineStr, location, config_file);
     880  gsdl_conffile = config_file;
     881
    830882  //Create a window class
    831883  MainClass.style = CS_HREDRAW | CS_VREDRAW;
     
    865917 
    866918  ShowWindow(MainWindow, SW_SHOW);
    867   set_location(CmdLineStr);
     919  set_location(location);
    868920 
    869921  // get ready to draw the main window
Note: See TracChangeset for help on using the changeset viewer.