Revision: 1766
          http://ipcop.svn.sourceforge.net/ipcop/?rev=1766&view=rev
Author:   owes
Date:     2008-09-01 13:32:14 +0000 (Mon, 01 Sep 2008)

Log Message:
-----------
add long options, not really interesting but keeps consistency.

Modified Paths:
--------------
    ipcop/trunk/src/misc-progs/restartshaping.c

Modified: ipcop/trunk/src/misc-progs/restartshaping.c
===================================================================
--- ipcop/trunk/src/misc-progs/restartshaping.c 2008-08-31 20:03:04 UTC (rev 
1765)
+++ ipcop/trunk/src/misc-progs/restartshaping.c 2008-09-01 13:32:14 UTC (rev 
1766)
@@ -22,29 +22,30 @@
  *
  */
 
-#include "setuid.h"
+#include <fcntl.h>
+#include <getopt.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdlib.h>
 #include "common.h"
+#include "setuid.h"
 
 
-void usage(char *prg)
+void usage(char *prg, int exit_code)
 {
-    printf("Usage: %s [-v]\n\n", prg);
+    printf("Usage: %s [OPTION]\n\n", prg);
     printf("Options:\n");
-    printf(" -v   be verbose\n");
-    exit(1);
+    printf("  -v, --verbose         be verbose\n");
+    printf("      --help            display this help and exit\n");
+    exit(exit_code);
 }
 
 
 int main(int argc, char *argv[])
 {
-    int c;
     FILE *file = NULL;
     NODEKV *shp_kv = NULL;
     int uplink, downlink, count = 0, r2q = 10;
@@ -58,22 +59,30 @@
     char *prio;
     char *enabled;
 
+    static struct option long_options[] =
+    {
+        { "verbose", no_argument, 0, 'v' },
+        { "help", no_argument, 0, 'h' },
+        { 0, 0, 0, 0}
+    };
+    int c;
+    int option_index = 0;
+
     if (!(initsetuid())) {
         fprintf(stderr, "Cannot run setuid\n");
         exit(1);
     }
 
-    while ((c = getopt(argc, argv, "v?")) != -1) {
+    while ((c = getopt_long(argc, argv, "v", long_options, &option_index)) != 
-1) {
         switch (c) {
         case 'v':              /* verbose */
             flag_verbose++;
             break;
-
+        case 'h':
+            usage(argv[0], 0);
         default:
             fprintf(stderr, "unknown option\n");
-        case '?':              /* help */
-            usage(argv[0]);
-            break;
+            usage(argv[0], 1);
         }
     }
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn

Reply via email to