Changeset 4642
- Timestamp:
- 2003-06-13T12:24:12+12:00 (21 years ago)
- Location:
- trunk/gsdl/src/w32server
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/src/w32server/fnord.cpp
r4339 r4642 631 631 632 632 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; 634 636 635 637 // remove all the slashes at the end of billpath … … 824 826 } 825 827 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) 833 static 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 826 873 827 874 int __stdcall WinMain(HINSTANCE Instance, HINSTANCE /*PrevInstance*/, LPSTR CmdLineStr, int /*CmdShow*/) { 828 875 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 830 882 //Create a window class 831 883 MainClass.style = CS_HREDRAW | CS_VREDRAW; … … 865 917 866 918 ShowWindow(MainWindow, SW_SHOW); 867 set_location( CmdLineStr);919 set_location(location); 868 920 869 921 // get ready to draw the main window -
trunk/gsdl/src/w32server/locate.cpp
r2286 r4642 41 41 42 42 static int location_found=0; 43 char data_location[MAX_FILENAME_SIZE];44 45 void set_location( char *possible)43 text_t data_location; 44 45 void set_location(text_t possible) 46 46 { 47 47 if (location_found != 0) return; 48 if (possible != NULL && *possible != 0) { 49 strcpy(data_location, possible); 50 if (data_location[strlen(data_location)-1] != '\\') 51 strcat(data_location,"\\"); 48 if (!possible.empty()) { 49 data_location = possible; 50 if (*(data_location.end()-1) != '\\') { 51 data_location.push_back('\\'); 52 } 52 53 location_found = 1; 53 54 } … … 56 57 void find_location(void) 57 58 { 59 if (location_found != 0) return; 60 61 char here[MAX_FILENAME_SIZE]; 58 62 char *send; 59 if (location_found != 0) return; 60 if (GetModuleFileName(NULL,data_location,MAX_FILENAME_SIZE) <= 0) 61 send = data_location; 62 else { 63 send = strrchr(data_location,'\\'); 64 if (send != NULL) 63 64 if (GetModuleFileName(NULL,here,MAX_FILENAME_SIZE) <= 0) { 65 // failed 66 data_location.clear(); 67 } else { 68 send = strrchr(here,'\\'); 69 if (send != NULL) { 65 70 send++; 66 else {67 send = strchr( data_location,':');68 if (send != NULL) 71 } else { 72 send = strchr(here,':'); 73 if (send != NULL) { 69 74 send++; 70 else 71 send == data_location; 72 } 73 } 75 } else { 76 send = here; 77 } 78 } 79 } 74 80 *send = 0; 81 data_location.setcstr(here); 75 82 location_found = 1; 76 83 } -
trunk/gsdl/src/w32server/locate.h
r2286 r4642 30 30 #endif 31 31 32 #include "text_t.h" 33 32 34 extern HWND GSDL_Window; 33 35 extern int line_spacing; … … 36 38 void refresh_console(HDC dc); 37 39 38 extern char data_location[MAX_FILENAME_SIZE];40 extern text_t data_location; 39 41 40 extern void set_location( char *possible);42 extern void set_location(text_t possible); 41 43 extern void find_location(void); 42 44 -
trunk/gsdl/src/w32server/settings.cpp
r4339 r4642 27 27 28 28 #include "text_t.h" 29 #include "fileutil.h" 29 30 30 31 #if defined(GSDL_USE_OBJECTSPACE) … … 63 64 char gsdl_browser_exe[MAX_FILENAME_SIZE] = ""; 64 65 text_t gsdl_url; 66 text_t gsdl_conffile; 65 67 int gsdl_start_browser = 1; 66 68 … … 269 271 270 272 void write_settings (const text_t url) { 271 char conffile[MAX_FILENAME_SIZE]; 272 273 strcpy (conffile, data_location); 274 remove_end_slashes (conffile); 275 strcat (conffile, "\\gsdlsite.cfg"); 276 277 ofstream fout (conffile); 273 274 if (gsdl_conffile.empty()) { 275 find_location(); 276 gsdl_conffile = filename_cat(data_location, "gsdlsite.cfg"); 277 } 278 279 char *conffile_c = gsdl_conffile.getcstr(); 280 ofstream fout (conffile_c); 281 delete conffile_c; 278 282 if (fout) { 279 283 … … 397 401 398 402 void read_settings (int netscapeneeded) { 399 char conffile[MAX_FILENAME_SIZE]; 400 401 find_location(); 402 403 strcpy (conffile, data_location); 404 remove_end_slashes (conffile); 405 strcat (conffile, "\\gsdlsite.cfg"); 403 404 if (gsdl_conffile.empty()) { 405 find_location(); 406 gsdl_conffile = filename_cat(data_location, "gsdlsite.cfg"); 407 } 406 408 407 409 // set up defaults … … 410 412 text_t key, value, section; 411 413 char *cstr_value; 414 char *conffile_c = gsdl_conffile.getcstr(); 412 415 #if defined (GSDL_USE_IOS_H) 413 ifstream conf (conffile , ios::nocreate);416 ifstream conf (conffile_c, ios::nocreate); 414 417 #else 415 ifstream conf (conffile );418 ifstream conf (conffile_c); 416 419 #endif 420 delete conffile_c; 417 421 if (conf) { 418 422 while (read_ini_line(conf, key, value) >= 0) { -
trunk/gsdl/src/w32server/settings.h
r4339 r4642 58 58 extern char gsdl_browser_exe[MAX_FILENAME_SIZE]; 59 59 extern text_t gsdl_url; 60 extern text_t gsdl_conffile; 60 61 extern int gsdl_start_browser; 61 62
Note:
See TracChangeset
for help on using the changeset viewer.