From 552e81eebd54e4dc7a5d290a1ec4be769bef4a24 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 7 Aug 2010 09:16:50 +0200 Subject: [PATCH] =?utf8?q?collectd-flush:=20Simplified=20=E2=80=98usage()?= =?utf8?q?=E2=80=99=20a=20bit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/collectd-flush.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/collectd-flush.c b/src/collectd-flush.c index 71457e41..165c073a 100644 --- a/src/collectd-flush.c +++ b/src/collectd-flush.c @@ -79,8 +79,8 @@ static int flush ( return 0; } -void usage (const char *name) { - fprintf (stderr, "Usage: %s [options]\n" +static void exit_usage (const char *name, int status) { + fprintf ((status == 0) ? stdout : stderr, "Usage: %s [options]\n" "\n" "Valid options are:\n" " -h, --help Display this help message.\n" @@ -96,12 +96,13 @@ void usage (const char *name) { " Examples: uptime/uptime\n" " somehost/cpu-0/cpu-wait\n" " -t, --timeout= Only flush values older than this timeout.\n", name); + exit (status); } /* * Count how many occurences there are of a char in a string. */ -int charoccurences (const char *str, char chr) { +static int charoccurences (const char *str, char chr) { int count = 0; while (*str != '\0') { if (*str == chr) { @@ -164,13 +165,14 @@ int main (int argc, char **argv) { timeout = atoi (optarg); break; case 'h': - usage (argv[0]); - return 0; + exit_usage (argv[0], 0); default: - usage (argv[0]); - return 1; + exit_usage (argv[0], 1); } } return flush(address, plugin, ident_str, timeout); } + +/* vim: set sw=2 ts=2 tw=78 expandtab : */ + -- 2.30.2