diff options
author | Sergey Poznyakoff <gray@gnu.org> | 2016-03-12 09:55:49 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org> | 2016-03-12 09:55:49 +0200 |
commit | b49a731cce26dc5fa7f61bc80097f85867d77aad (patch) | |
tree | 9d687adf6973a6b95b673e4a63c6277050bbb03c | |
parent | 3edbd2eb9288f1d2d675c422d5865b8be1f29c32 (diff) | |
download | swu-b49a731cce26dc5fa7f61bc80097f85867d77aad.tar.gz swu-b49a731cce26dc5fa7f61bc80097f85867d77aad.tar.bz2 |
Implement long options
-rw-r--r-- | swu.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -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; |