aboutsummaryrefslogtreecommitdiff
path: root/src/ping903q.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2020-02-12 23:08:49 +0200
committerSergey Poznyakoff <gray@gnu.org>2020-02-12 23:08:49 +0200
commit1d1687c574bcbf5a7f54cb45763ad36fa70b3c2a (patch)
treeb61ae0ad99c3654684391c62bb1a1d29d1908273 /src/ping903q.c
parent28c6a911174d2ce2672e44b55e3e09c05adfad3f (diff)
downloadping903-1d1687c574bcbf5a7f54cb45763ad36fa70b3c2a.tar.gz
ping903-1d1687c574bcbf5a7f54cb45763ad36fa70b3c2a.tar.bz2
Add manpages
Diffstat (limited to 'src/ping903q.c')
-rw-r--r--src/ping903q.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/ping903q.c b/src/ping903q.c
index 62bd69c..f9cd5fa 100644
--- a/src/ping903q.c
+++ b/src/ping903q.c
@@ -457,7 +457,7 @@ query_host(char const *name)
ssize_t n = snprintf(url, sizeof(url), "/host/%s", name);
if (n < 0 || n == sizeof(url)) {
fatal("bad host name or IP");
- exit(EX_DATAERR);
+ exit(EX_USAGE);
}
http_query("GET", url, NULL);
http_resp_init(&resp);
@@ -536,7 +536,30 @@ query_all(void)
exit(EX_P903_NOTALIVE);
exit(EX_P903_MIXED);
}
+
+void
+usage(void)
+{
+ printf("Usage: %s [-hVv] [-c FILE]\n", progname);
+ printf("Query ping903 daemon.\n");
+ printf("\n");
+ printf("Options:\n\n");
+ printf(" -c FILE read configuration from FILE\n");
+ printf(" -h print this help test\n");
+ printf(" -V print program version and exit\n");
+ printf(" -v additional verbosity\n");
+ printf("\n");
+ printf("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
+ printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
+}
+void
+version(void)
+{
+ printf("%s (%s) %s\n", progname, PACKAGE_NAME, PACKAGE_VERSION);
+ printf("%s", COPYLEFT);
+}
+
int
main(int argc, char **argv)
{
@@ -544,11 +567,27 @@ main(int argc, char **argv)
char *p, *node, *service;
set_progname(argv[0]);
- while ((c = getopt(argc, argv, "c:v")) != EOF) {
+ if (argc == 2) {
+ if (strcmp(argv[1], "--help") == 0) {
+ usage();
+ exit(0);
+ }
+ if (strcmp(argv[1], "--version") == 0) {
+ version();
+ exit(0);
+ }
+ }
+ while ((c = getopt(argc, argv, "c:hVv")) != EOF) {
switch (c) {
case 'c':
config_file = optarg;
break;
+ case 'h':
+ usage();
+ exit(0);
+ case 'V':
+ version();
+ exit(0);
case 'v':
verbose++;
break;

Return to:

Send suggestions and report system problems to the System administrator.