From 4519e2e864c35f2068976b30a60ae33d599fea5b Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 2 Mar 2005 19:53:17 +0000 Subject: [PATCH] if no config file is specified on the command line, we check $HOME/.srfsh.xml for a config file git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@155 9efc2488-bf62-4759-914b-345cdb29e865 --- src/srfsh/srfsh.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/srfsh/srfsh.c b/src/srfsh/srfsh.c index 211ad4e..d65bb2c 100644 --- a/src/srfsh/srfsh.c +++ b/src/srfsh/srfsh.c @@ -31,10 +31,22 @@ char* tabs(int count); int main( int argc, char* argv[] ) { - if( argc < 2 ) - fatal_handler( "usage: %s ", argv[0] ); - - config_reader_init( "opensrf", argv[1] ); + if( argc < 2 ) { + + /* see if they have a .srfsh.xml in their home directory */ + char* home = getenv("HOME"); + int l = strlen(home) + 36; + char fbuf[l]; + memset(fbuf, 0, l); + sprintf(fbuf,"%s/.srfsh.xml",home); + if(!access(fbuf, F_OK)) + config_reader_init( "opensrf", fbuf ); + else + fatal_handler( "No Config file found at %s and none specified. " + "\nusage: %s ", fbuf, argv[0] ); + } else { + config_reader_init( "opensrf", argv[1] ); + } if( ! osrf_system_bootstrap_client("srfsh.xml") ) fprintf( stderr, "Unable to bootstrap client for requests\n"); @@ -312,8 +324,10 @@ int print_help() { "---------------------------------------------------------------------------------\n" "router query servers \n" " - Returns stats on connected services\n" + "\n" "reqeust [ ]\n" - " - Anything passed in will be wrapped in a json array\n" + " - Anything passed in will be wrapped in a json array,\n" + " so add commas if there is more than one param\n" "---------------------------------------------------------------------------------\n" ); -- 2.11.0