]> git.mxchange.org Git - flightgear.git/commitdiff
Added support for reading ~/.fgfsrc.hostname files.
authorcurt <curt>
Thu, 22 Mar 2001 04:02:11 +0000 (04:02 +0000)
committercurt <curt>
Thu, 22 Mar 2001 04:02:11 +0000 (04:02 +0000)
src/Main/fg_init.cxx
tests/Makefile.am

index d2e5bb305701593c6e9a2cf4a49e9e3378e393e0..a052cafc14ac8245d16cd57b85b18eda423be099 100644 (file)
 #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
@@ -116,6 +121,22 @@ bool fgInitFGRoot ( int argc, char **argv ) {
     // 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" );
@@ -170,13 +191,24 @@ bool fgInitConfig ( int argc, char **argv ) {
       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 );
@@ -184,6 +216,14 @@ bool fgInitConfig ( int argc, char **argv ) {
        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);
index cbb62fa1c3cb23c998fcb8c53aed29927828f049..8c7ab12810c2d1545c9fcb04567c14a805407eb7 100644 (file)
@@ -1,4 +1,4 @@
-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)
@@ -6,6 +6,9 @@ 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)