From f116b1bc0a6ce114b21bf2e97f6add5fa74f56c3 Mon Sep 17 00:00:00 2001 From: miker Date: Sun, 10 Jun 2007 23:41:14 +0000 Subject: [PATCH] Patch from Scott McKellar; cleaning up several error conditions http://list.georgialibraries.org/pipermail/open-ils-dev/2007-June/001241.html git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@932 9efc2488-bf62-4759-914b-345cdb29e865 --- src/jserver/osrf_chat_main.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/jserver/osrf_chat_main.c b/src/jserver/osrf_chat_main.c index 401d3b4..8ac5298 100644 --- a/src/jserver/osrf_chat_main.c +++ b/src/jserver/osrf_chat_main.c @@ -13,6 +13,10 @@ int main( int argc, char* argv[] ) { } osrfConfig* cfg = osrfConfigInit( argv[1], argv[2] ); + if( !cfg ) { + fprintf( stderr, "Unable to load configuration file %s\n", argv[1] ); + return -1; + } init_proc_title( argc, argv ); set_proc_title( "ChopChop" ); @@ -26,6 +30,27 @@ int main( int argc, char* argv[] ) { char* lfile = osrfConfigGetValue(cfg, "/logfile"); char* facility = osrfConfigGetValue(cfg, "/syslog"); + if(!domain) + fputs( "No domain specified in configuration file\n", stderr ); + + if(!secret) + fputs( "No secret specified in configuration file\n", stderr ); + + if(!sport) + fputs( "No port specified in configuration file\n", stderr ); + + if(!listenaddr) + fputs( "No listen_address specified in configuration file\n", stderr ); + + if(!llevel) + fputs( "No loglevel specified in configuration file\n", stderr ); + + if(!lfile) + fputs( "No logfile specified in configuration file\n", stderr ); + + if(!s2sport) + fputs( "No s2sport specified in configuration file\n", stderr ); + if(!(domain && secret && sport && listenaddr && llevel && lfile && s2sport)) { fprintf(stderr, "Configuration error for ChopChop - missing key ingredient\n"); return -1; @@ -35,10 +60,8 @@ int main( int argc, char* argv[] ) { int s2port = atoi(s2sport); int level = atoi(llevel); - if(!lfile) { fprintf(stderr, "Log file needed\n"); return -1; } - if(!strcmp(lfile, "syslog")) { - osrfLogInit( OSRF_LOG_TYPE_SYSLOG, "chochop", level ); + osrfLogInit( OSRF_LOG_TYPE_SYSLOG, "chopchop", level ); osrfLogSetSyslogFacility(osrfLogFacilityToInt(facility)); } else { -- 2.11.0