[tuxdroid-svn] r423 - daemon/trunk
Status: Beta
Brought to you by:
ks156
From: neimad <c2m...@c2...> - 2007-06-23 19:33:53
|
Author: neimad Date: 2007-06-23 21:33:21 +0200 (Sat, 23 Jun 2007) New Revision: 423 Modified: daemon/trunk/main.c Log: * usage() is now given a status code and makes the daemon exit with this status code. Usage help is printed on stdout if the status is 0 (no error), and on stderr otherwise (error). Modified: daemon/trunk/main.c =================================================================== --- daemon/trunk/main.c 2007-06-23 19:22:50 UTC (rev 422) +++ daemon/trunk/main.c 2007-06-23 19:33:21 UTC (rev 423) @@ -294,10 +294,13 @@ /** * Display usage help. + * + * \param[in] status Exit status */ -static void usage(void) +static void usage(int status) { - printf("usage : tuxd [options]\n" + fprintf(status ? stderr : stdout, + "usage : tuxd [options]\n" "options:\n" " -d start in daemon mode\n" " -lsys log to syslog\n" @@ -309,6 +312,7 @@ " -sr show all raw status\n" " -si show only invalid raw status\n" " -h show this usage list\n"); + exit(status); } int main(int argc, char *argv[]) @@ -341,15 +345,9 @@ else if (!strcmp("-si", argv[i])) show_invalid_raw = 1; else if (!strcmp("-h", argv[i])) - { - usage(); - exit(1); - } + usage(0); else - { - usage(); - exit(1); - } + usage(1); } /* Only one instance of the daemon is allowed */ |