[sane-devel] [PATCH v4 3/5] add usage()

Matteo Croce matteo at openwrt.org
Sun Oct 11 17:50:02 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..8eff6c7 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: %s -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.5.0




More information about the sane-devel mailing list