Print exit message only in verbose mode

Update the exit message printing in all the modules:
- print on standard error
- print only in verbose mode
- use "exiting" instead of "end"
This commit is contained in:
Matteo Cypriani 2013-06-12 14:03:40 -04:00
parent 86510d490f
commit 5ddca24738
4 changed files with 21 additions and 4 deletions

View File

@ -166,6 +166,11 @@ int main(int argc, char **argv)
/* Last cleaning tasks */
exit:
/* If called with -h, cfg won't be initialised, so we must check if
* cfg is NULL */
if (cfg && VERBOSE_CHATTERBOX)
fprintf(stderr, "%s: exiting.\n", program_name) ;
if (sockfd >= 0)
close(sockfd) ; // Close socket
free_request_list() ;
@ -175,7 +180,6 @@ int main(int argc, char **argv)
sem_destroy(&lock_requests) ;
sem_destroy(&lock_aps) ;
fprintf(stderr, "%s: end.\n", program_name) ;
return ret ;
}

View File

@ -275,11 +275,19 @@ int main(int argc, char *argv[])
/* Last cleaning tasks */
exit:
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
/* If called with -h, cfg won't be initialised, so we must check if
* cfg is NULL */
if (cfg && VERBOSE_CHATTERBOX)
#else // OWLPS_LISTENER_USES_CONFIG_FILE
if (VERBOSE_CHATTERBOX)
#endif // OWLPS_LISTENER_USES_CONFIG_FILE
fprintf(stderr, "%s: exiting.\n", program_name) ;
#ifdef OWLPS_LISTENER_USES_CONFIG_FILE
cfg_free(cfg) ; // Clean configuration
#endif // OWLPS_LISTENER_USES_CONFIG_FILE
printf("%s: end.\n", program_name) ;
return ret ;
}

View File

@ -18,6 +18,7 @@
#include "userinterface.hh"
#include "configuration.hh"
#include "inputdatareader.hh"
#include "stock.hh"
#include "positioning.hh"
@ -59,6 +60,8 @@ int main(int argc, char **argv)
Stock::clear() ;
}
cerr << argv[0] << ": end." << endl ;
if (Configuration::is_configured("verbose"))
cerr << argv[0] << ": exiting." << endl ;
return 0 ;
}

View File

@ -158,7 +158,9 @@ int main(int argc, char *argv[])
free_results_list() ;
sem_destroy(&lock_results) ;
printf("%s: end.\n", program_name) ;
if (verbose)
fprintf(stderr, "%s: exiting.\n", program_name) ;
return ret ;
}