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 <stdio.h>
#include <stdlib.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 // 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. // seem to hurt to have this here for all versions of Linux.
#ifdef linux #ifdef linux
@ -116,6 +121,22 @@ bool fgInitFGRoot ( int argc, char **argv ) {
// override anything specified in a config file // override anything specified in a config file
root = fgScanForRoot(argc, argv); 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 // Next check home directory for .fgfsrc file
if ( root == "" ) { if ( root == "" ) {
envp = ::getenv( "HOME" ); envp = ::getenv( "HOME" );
@ -170,13 +191,24 @@ bool fgInitConfig ( int argc, char **argv ) {
FG_LOG(FG_INPUT, FG_INFO, "Finished Reading global preferences"); FG_LOG(FG_INPUT, FG_INFO, "Finished Reading global preferences");
} }
// Attempt to locate and parse a config file // Attempt to locate and parse the various config files in order
// First check fg_root // from least precidence to greatest precidence
// Check for $fg_root/system.fgfsrc
FGPath config( globals->get_fg_root() ); FGPath config( globals->get_fg_root() );
config.append( "system.fgfsrc" ); config.append( "system.fgfsrc" );
fgParseOptions(config.str()); 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" ); char* envp = ::getenv( "HOME" );
if ( envp != NULL ) { if ( envp != NULL ) {
config.set( envp ); config.set( envp );
@ -184,6 +216,14 @@ bool fgInitConfig ( int argc, char **argv ) {
fgParseOptions(config.str()); 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 // Parse remaining command line options
// These will override anything specified in a config file // These will override anything specified in a config file
fgParseOptions(argc, argv); 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_SOURCES = est-epsilon.c
est_epsilon_LDADD = $(base_LIBS) est_epsilon_LDADD = $(base_LIBS)
@ -6,6 +6,9 @@ est_epsilon_LDADD = $(base_LIBS)
gl_info_SOURCES = gl-info.c gl_info_SOURCES = gl-info.c
gl_info_LDADD = $(opengl_LIBS) gl_info_LDADD = $(opengl_LIBS)
test_gethostname_SOURCES = test-gethostname.cxx
test_gethostname_LDADD = $(base_LIBS)
test_mktime_SOURCES = test-mktime.cxx test_mktime_SOURCES = test-mktime.cxx
test_mktime_LDADD = $(base_LIBS) test_mktime_LDADD = $(base_LIBS)