summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2016-03-12 07:55:49 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2016-03-12 07:55:49 (GMT)
commitb49a731cce26dc5fa7f61bc80097f85867d77aad (patch) (side-by-side diff)
tree9d687adf6973a6b95b673e4a63c6277050bbb03c
parent3edbd2eb9288f1d2d675c422d5865b8be1f29c32 (diff)
downloadswu-b49a731cce26dc5fa7f61bc80097f85867d77aad.tar.gz
swu-b49a731cce26dc5fa7f61bc80097f85867d77aad.tar.bz2
Implement long options
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--swu.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/swu.c b/swu.c
index 785b00c..0f3291a 100644
--- a/swu.c
+++ b/swu.c
@@ -1,4 +1,5 @@
#include <unistd.h>
+#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -286,6 +287,19 @@ help(void)
//FIXME
}
+struct option opt[] = {
+ { "all", 0, NULL, 'a' },
+ { "human-readable", 0, NULL, 'H' },
+ { "help", 0, NULL, 'h' },
+ { "name", 0, NULL, 'n' },
+ { "pid", 0, NULL, 'p' },
+ { "reverse", 0, NULL, 'r' },
+ { "size", 0, NULL, 's' },
+ { "total", 0, NULL, 't' },
+ { "verbose", 0, NULL, 'v' },
+ { NULL }
+};
+
int
main(int argc, char **argv)
{
@@ -296,7 +310,7 @@ main(int argc, char **argv)
++progname;
else
progname = argv[0];
- while ((c = getopt(argc, argv, "aHhnprstv")) != EOF) {
+ while ((c = getopt_long(argc, argv, "acHhnprstv", opt, NULL)) != EOF) {
switch (c) {
case 'a':
show_all = 1;
@@ -319,6 +333,7 @@ main(int argc, char **argv)
case 's':
cmp = cmp_size;
break;
+ case 'c':
case 't':
show_total = 1;
break;

Return to:

Send suggestions and report system problems to the System administrator.