projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1a9c26b
)
collectd-flush: Simplified ‘usage()’ a bit.
author
Sebastian Harl
<sh@tokkee.org>
Sat, 7 Aug 2010 07:16:50 +0000
(09:16 +0200)
committer
Sebastian Harl
<sh@tokkee.org>
Sat, 7 Aug 2010 07:16:50 +0000
(09:16 +0200)
src/collectd-flush.c
patch
|
blob
|
history
diff --git
a/src/collectd-flush.c
b/src/collectd-flush.c
index
71457e4
..
165c073
100644
(file)
--- a/
src/collectd-flush.c
+++ b/
src/collectd-flush.c
@@
-79,8
+79,8
@@
static int flush (
return 0;
}
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"
"\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=<timeout> Only flush values older than this timeout.\n", name);
" Examples: uptime/uptime\n"
" somehost/cpu-0/cpu-wait\n"
" -t, --timeout=<timeout> Only flush values older than this timeout.\n", name);
+ exit (status);
}
/*
* Count how many occurences there are of a char in a string.
*/
}
/*
* 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) {
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':
timeout = atoi (optarg);
break;
case 'h':
- usage (argv[0]);
- return 0;
+ exit_usage (argv[0], 0);
default:
default:
- usage (argv[0]);
- return 1;
+ exit_usage (argv[0], 1);
}
}
return flush(address, plugin, ident_str, timeout);
}
}
}
return flush(address, plugin, ident_str, timeout);
}
+
+/* vim: set sw=2 ts=2 tw=78 expandtab : */
+