#include <stdio.h>
#include <stdlib.h>
+
+#if defined( unix ) || defined( __CYGWIN__ )
+# include <unistd.h> // for gethostname()
+#endif
+
// work around a stdc++ lib bug in some versions of linux, but doesn't
// seem to hurt to have this here for all versions of Linux.
#ifdef linux
// override anything specified in a config file
root = fgScanForRoot(argc, argv);
+#if defined( unix ) || defined( __CYGWIN__ )
+ // Next check home directory for .fgfsrc.hostname file
+ if ( root == "" ) {
+ envp = ::getenv( "HOME" );
+ if ( envp != NULL ) {
+ FGPath config( envp );
+ config.append( ".fgfsrc" );
+ char name[256];
+ gethostname( name, 256 );
+ config.concat( "." );
+ config.concat( name );
+ root = fgScanForRoot(config.str());
+ }
+ }
+#endif
+
// Next check home directory for .fgfsrc file
if ( root == "" ) {
envp = ::getenv( "HOME" );
FG_LOG(FG_INPUT, FG_INFO, "Finished Reading global preferences");
}
- // Attempt to locate and parse a config file
- // First check fg_root
+ // Attempt to locate and parse the various config files in order
+ // from least precidence to greatest precidence
+
+ // Check for $fg_root/system.fgfsrc
FGPath config( globals->get_fg_root() );
config.append( "system.fgfsrc" );
fgParseOptions(config.str());
- // Next check home directory
+ char name[256];
+#if defined( unix ) || defined( __CYGWIN__ )
+ // Check for $fg_root/system.fgfsrc.hostname
+ gethostname( name, 256 );
+ config.concat( "." );
+ config.concat( name );
+ fgParseOptions(config.str());
+#endif
+
+ // Check for ~/.fgfsrc
char* envp = ::getenv( "HOME" );
if ( envp != NULL ) {
config.set( envp );
fgParseOptions(config.str());
}
+#if defined( unix ) || defined( __CYGWIN__ )
+ // Check for ~/.fgfsrc.hostname
+ gethostname( name, 256 );
+ config.concat( "." );
+ config.concat( name );
+ fgParseOptions(config.str());
+#endif
+
// Parse remaining command line options
// These will override anything specified in a config file
fgParseOptions(argc, argv);
-bin_PROGRAMS = est-epsilon gl-info test-mktime test-up
+bin_PROGRAMS = est-epsilon gl-info test-gethostname test-mktime test-up
est_epsilon_SOURCES = est-epsilon.c
est_epsilon_LDADD = $(base_LIBS)
gl_info_SOURCES = gl-info.c
gl_info_LDADD = $(opengl_LIBS)
+test_gethostname_SOURCES = test-gethostname.cxx
+test_gethostname_LDADD = $(base_LIBS)
+
test_mktime_SOURCES = test-mktime.cxx
test_mktime_LDADD = $(base_LIBS)