[sane-devel] [PATCH 3/3] add usage()
Matteo Croce
matteo at openwrt.org
Sun Sep 20 17:55:37 UTC 2015
move help text in a separate function
---
frontend/saned.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/frontend/saned.c b/frontend/saned.c
index ab36397..93da1ff 100644
--- a/frontend/saned.c
+++ b/frontend/saned.c
@@ -3253,6 +3253,11 @@ run_inetd (char *sock)
handle_connection(fd);
}
+static void usage(char *me, int err)
+{
+ fprintf (stderr, "Usage: saned -a [ username ] | -d [ n ] | -s [ n ]| -h\n", me);
+ exit(err);
+}
int
main (int argc, char *argv[])
@@ -3288,12 +3293,11 @@ main (int argc, char *argv[])
run_mode = SANED_RUN_DEBUG;
else
{
- printf ("Usage: saned [ -a [ username ] | -d [ n ] | -s [ n ] ] | -h\n");
if ((strncmp (argv[1], "-h", 2) == 0) ||
(strncmp (argv[1], "--help", 6) == 0))
- exit (EXIT_SUCCESS);
+ usage (argv[0], EXIT_SUCCESS);
else
- exit (EXIT_FAILURE);
+ usage (argv[0], EXIT_FAILURE);
}
}
--
2.1.4
More information about the sane-devel
mailing list