1
0
Fork 0

Added support for reading ~/.fgfsrc.hostname files.

This commit is contained in:
curt 2001-03-22 04:02:11 +00:00
parent 46a4b960d1
commit def805e9dc
2 changed files with 47 additions and 4 deletions

View file

@ -37,6 +37,11 @@
#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);

View 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)