#include "fg_os.hxx"
-char *homedir = NULL;
-char *hostname = NULL;
-bool free_hostname = false;
+string homedir;
+string hostname;
-// foreward declaration.
+// forward declaration.
void fgExitCleanup();
static bool fpeAbort = false;
SetErrorMode(SEM_NOOPENFILEERRORBOX);
// Windows has no $HOME aka %HOME%, so we have to construct the full path.
- // make sure it fits into the buffer. Max. path length is 255, but who knows
- // what's in these environment variables?
- char homepath[256] = "";
- homepath[sizeof(homepath)-1] = 0;
- strncpy( homepath, ::getenv("APPDATA"), sizeof(homepath)-1 );
- strncat( homepath, "\\flightgear.org", sizeof(homepath)-strlen(homepath)-1 );
-
- homedir = strdup(homepath);
+ homedir = ::getenv("APPDATA");
+ homedir.append("\\flightgear.org");
+
hostname = ::getenv( "COMPUTERNAME" );
#else
// Unix(alike) systems
char _hostname[256];
gethostname(_hostname, 256);
- hostname = strdup(_hostname);
- free_hostname = true;
+ hostname = _hostname;
homedir = ::getenv( "HOME" );
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
delete globals;
-
- if (free_hostname && hostname != NULL)
- free(hostname);
}
#include "options.hxx"
#include "util.hxx"
#include "viewmgr.hxx"
+#include "main.hxx"
#include <Main/viewer.hxx>
#include <Environment/presets.hxx>
#define NEW_DEFAULT_MODEL_HZ 120
-// defined in bootstrap.cxx
-extern char *homedir;
-extern char *hostname;
-
enum
{
FG_OPTIONS_OK = 0,
// then config files
SGPath config;
- if( homedir && hostname && strlen(hostname) > 0 ) {
+ if( homedir.size() && hostname.size() ) {
// Check for ~/.fgfsrc.hostname
config.set(homedir);
config.append(".fgfsrc");
}
// Check for ~/.fgfsrc
- if( homedir ) {
+ if( homedir.size() ) {
config.set(homedir);
config.append(".fgfsrc");
readConfig(config);
setupRoot();
// system.fgfsrc handling
- if( hostname && strlen(hostname) > 0 ) {
+ if( hostname.size() > 0 ) {
config.set(globals->get_fg_root());
config.append( "system.fgfsrc" );
config.concat( "." );
return result;
}
-
+
void Options::processOptions()
{
// establish locale before showing help