From: Kay Sievers Date: Thu, 2 Oct 2008 14:49:05 +0000 (+0200) Subject: use no_argument, required_argument, optional_argument in longopts X-Git-Tag: 174~1493 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=033e9f8cde5a7feec1334888aec69def99c945b5;p=systemd use no_argument, required_argument, optional_argument in longopts --- diff --git a/extras/ata_id/ata_id.c b/extras/ata_id/ata_id.c index 927dbfab..a4f73b8d 100644 --- a/extras/ata_id/ata_id.c +++ b/extras/ata_id/ata_id.c @@ -88,8 +88,8 @@ int main(int argc, char *argv[]) int fd; int rc = 0; static const struct option options[] = { - { "export", 0, NULL, 'x' }, - { "help", 0, NULL, 'h' }, + { "export", no_argument, NULL, 'x' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/extras/cdrom_id/cdrom_id.c b/extras/cdrom_id/cdrom_id.c index 627ae0de..381aa70b 100644 --- a/extras/cdrom_id/cdrom_id.c +++ b/extras/cdrom_id/cdrom_id.c @@ -503,9 +503,9 @@ int main(int argc, char *argv[]) { struct udev *udev; static const struct option options[] = { - { "export", 0, NULL, 'x' }, - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, + { "export", no_argument, NULL, 'x' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, {} }; const char *node = NULL; diff --git a/extras/collect/collect.c b/extras/collect/collect.c index 14184a5e..7ebe865b 100644 --- a/extras/collect/collect.c +++ b/extras/collect/collect.c @@ -321,10 +321,10 @@ static void everybody(void) int main(int argc, char **argv) { static const struct option options[] = { - { "add", 0, NULL, 'a' }, - { "remove", 0, NULL, 'r' }, - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, + { "add", no_argument, NULL, 'a' }, + { "remove", no_argument, NULL, 'r' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, {} }; int argi; diff --git a/extras/fstab_import/fstab_import.c b/extras/fstab_import/fstab_import.c index 71ab5d34..e793604f 100644 --- a/extras/fstab_import/fstab_import.c +++ b/extras/fstab_import/fstab_import.c @@ -66,9 +66,9 @@ int main(int argc, char *argv[]) { struct udev *udev; static const struct option options[] = { - { "export", 0, NULL, 'x' }, - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, + { "export", no_argument, NULL, 'x' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, {} }; char **devices; diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c index 10ec98c8..6334af38 100644 --- a/extras/scsi_id/scsi_id.c +++ b/extras/scsi_id/scsi_id.c @@ -31,17 +31,17 @@ #include "scsi_id.h" static const struct option options[] = { - { "device", 1, NULL, 'd' }, - { "config", 1, NULL, 'f' }, - { "page", 1, NULL, 'p' }, - { "blacklisted", 0, NULL, 'b' }, - { "whitelisted", 0, NULL, 'g' }, - { "replace-whitespace", 0, NULL, 'u' }, - { "sg-version", 1, NULL, 's' }, - { "verbose", 0, NULL, 'v' }, - { "version", 0, NULL, 'V' }, - { "export", 0, NULL, 'x' }, - { "help", 0, NULL, 'h' }, + { "device", required_argument, NULL, 'd' }, + { "config", required_argument, NULL, 'f' }, + { "page", required_argument, NULL, 'p' }, + { "blacklisted", no_argument, NULL, 'b' }, + { "whitelisted", no_argument, NULL, 'g' }, + { "replace-whitespace", no_argument, NULL, 'u' }, + { "sg-version", required_argument, NULL, 's' }, + { "verbose", no_argument, NULL, 'v' }, + { "version", no_argument, NULL, 'V' }, + { "export", no_argument, NULL, 'x' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c index 21545521..f39496b0 100644 --- a/extras/usb_id/usb_id.c +++ b/extras/usb_id/usb_id.c @@ -359,10 +359,10 @@ int main(int argc, char **argv) char devpath[MAX_PATH_LEN]; static int export; static const struct option options[] = { - { "usb-info", 0, NULL, 'u' }, - { "num-info", 0, NULL, 'n' }, - { "export", 0, NULL, 'x' }, - { "help", 0, NULL, 'h' }, + { "usb-info", no_argument, NULL, 'u' }, + { "num-info", no_argument, NULL, 'n' }, + { "export", no_argument, NULL, 'x' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/extras/volume_id/vol_id.c b/extras/volume_id/vol_id.c index b47d6a4e..0137b84f 100644 --- a/extras/volume_id/vol_id.c +++ b/extras/volume_id/vol_id.c @@ -111,16 +111,16 @@ static int all_probers(volume_id_probe_fn_t probe_fn, int main(int argc, char *argv[]) { static const struct option options[] = { - { "label", 0, NULL, 'l' }, - { "label-raw", 0, NULL, 'L' }, - { "uuid", 0, NULL, 'u' }, - { "type", 0, NULL, 't' }, - { "export", 0, NULL, 'x' }, - { "skip-raid", 0, NULL, 's' }, - { "probe-all", 0, NULL, 'a' }, - { "offset", 2, NULL, 'o' }, - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, + { "label", no_argument, NULL, 'l' }, + { "label-raw", no_argument, NULL, 'L' }, + { "uuid", no_argument, NULL, 'u' }, + { "type", no_argument, NULL, 't' }, + { "export", no_argument, NULL, 'x' }, + { "skip-raid", no_argument, NULL, 's' }, + { "probe-all", no_argument, NULL, 'a' }, + { "offset", optional_argument, NULL, 'o' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/udev/lib/test-libudev.c b/udev/lib/test-libudev.c index 5d19d5dd..47fbf3b4 100644 --- a/udev/lib/test-libudev.c +++ b/udev/lib/test-libudev.c @@ -273,12 +273,12 @@ int main(int argc, char *argv[], char *envp[]) { struct udev *udev = NULL; static const struct option options[] = { - { "syspath", 1, NULL, 'p' }, - { "subsystem", 1, NULL, 's' }, - { "socket", 1, NULL, 'S' }, - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, + { "syspath", required_argument, NULL, 'p' }, + { "subsystem", required_argument, NULL, 's' }, + { "socket", required_argument, NULL, 'S' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, {} }; struct udev_enumerate *udev_enumerate; diff --git a/udev/udevadm-control.c b/udev/udevadm-control.c index baffd0d2..50020b57 100644 --- a/udev/udevadm-control.c +++ b/udev/udevadm-control.c @@ -46,18 +46,18 @@ int udevadm_control(struct udev *udev, int argc, char *argv[]) /* compat values with '_' will be removed in a future release */ static const struct option options[] = { - { "log-priority", 1, NULL, 'l' }, - { "log_priority", 1, NULL, 'l' + 256 }, - { "stop-exec-queue", 0, NULL, 's' }, - { "stop_exec_queue", 0, NULL, 's' + 256 }, - { "start-exec-queue", 0, NULL, 'S' }, - { "start_exec_queue", 0, NULL, 'S' + 256}, - { "reload-rules", 0, NULL, 'R' }, - { "reload_rules", 0, NULL, 'R' + 256}, - { "env", 1, NULL, 'e' }, - { "max-childs", 1, NULL, 'm' }, - { "max_childs", 1, NULL, 'm' + 256}, - { "help", 0, NULL, 'h' }, + { "log-priority", required_argument, NULL, 'l' }, + { "log_priority", required_argument, NULL, 'l' + 256 }, + { "stop-exec-queue", no_argument, NULL, 's' }, + { "stop_exec_queue", no_argument, NULL, 's' + 256 }, + { "start-exec-queue", no_argument, NULL, 'S' }, + { "start_exec_queue", no_argument, NULL, 'S' + 256}, + { "reload-rules", no_argument, NULL, 'R' }, + { "reload_rules", no_argument, NULL, 'R' + 256}, + { "env", required_argument, NULL, 'e' }, + { "max-childs", required_argument, NULL, 'm' }, + { "max_childs", required_argument, NULL, 'm' + 256}, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/udev/udevadm-info.c b/udev/udevadm-info.c index 4da9881d..ec098abd 100644 --- a/udev/udevadm-info.c +++ b/udev/udevadm-info.c @@ -217,17 +217,17 @@ int udevadm_info(struct udev *udev, int argc, char *argv[]) int rc = 0; static const struct option options[] = { - { "name", 1, NULL, 'n' }, - { "path", 1, NULL, 'p' }, - { "query", 1, NULL, 'q' }, - { "attribute-walk", 0, NULL, 'a' }, - { "export-db", 0, NULL, 'e' }, - { "root", 0, NULL, 'r' }, - { "device-id-of-file", 1, NULL, 'd' }, - { "export", 0, NULL, 'x' }, - { "export-prefix", 1, NULL, 'P' }, - { "version", 0, NULL, 1 }, /* -V outputs braindead format */ - { "help", 0, NULL, 'h' }, + { "name", required_argument, NULL, 'n' }, + { "path", required_argument, NULL, 'p' }, + { "query", required_argument, NULL, 'q' }, + { "attribute-walk", no_argument, NULL, 'a' }, + { "export-db", no_argument, NULL, 'e' }, + { "root", no_argument, NULL, 'r' }, + { "device-id-of-file", required_argument, NULL, 'd' }, + { "export", no_argument, NULL, 'x' }, + { "export-prefix", required_argument, NULL, 'P' }, + { "version", no_argument, NULL, 1 }, /* -V outputs braindead format */ + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/udev/udevadm-monitor.c b/udev/udevadm-monitor.c index d5992ceb..14a6edc8 100644 --- a/udev/udevadm-monitor.c +++ b/udev/udevadm-monitor.c @@ -77,10 +77,10 @@ int udevadm_monitor(struct udev *udev, int argc, char *argv[]) int rc = 0; static const struct option options[] = { - { "environment", 0, NULL, 'e' }, - { "kernel", 0, NULL, 'k' }, - { "udev", 0, NULL, 'u' }, - { "help", 0, NULL, 'h' }, + { "environment", no_argument, NULL, 'e' }, + { "kernel", no_argument, NULL, 'k' }, + { "udev", no_argument, NULL, 'u' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/udev/udevadm-settle.c b/udev/udevadm-settle.c index d066ef90..5e5a080b 100644 --- a/udev/udevadm-settle.c +++ b/udev/udevadm-settle.c @@ -36,8 +36,8 @@ int udevadm_settle(struct udev *udev, int argc, char *argv[]) { static const struct option options[] = { - { "timeout", 1, NULL, 't' }, - { "help", 0, NULL, 'h' }, + { "timeout", required_argument, NULL, 't' }, + { "help", no_argument, NULL, 'h' }, {} }; int timeout = DEFAULT_TIMEOUT; diff --git a/udev/udevadm-test.c b/udev/udevadm-test.c index ba085287..f4b0125d 100644 --- a/udev/udevadm-test.c +++ b/udev/udevadm-test.c @@ -83,10 +83,10 @@ int udevadm_test(struct udev *udev, int argc, char *argv[]) int rc = 0; static const struct option options[] = { - { "action", 1, NULL, 'a' }, - { "subsystem", 1, NULL, 's' }, - { "force", 0, NULL, 'f' }, - { "help", 0, NULL, 'h' }, + { "action", required_argument, NULL, 'a' }, + { "subsystem", required_argument, NULL, 's' }, + { "force", no_argument, NULL, 'f' }, + { "help", no_argument, NULL, 'h' }, {} }; diff --git a/udev/udevadm-trigger.c b/udev/udevadm-trigger.c index 8d25f923..eb46a298 100644 --- a/udev/udevadm-trigger.c +++ b/udev/udevadm-trigger.c @@ -79,16 +79,16 @@ static int scan_failed(struct udev_enumerate *udev_enumerate) int udevadm_trigger(struct udev *udev, int argc, char *argv[]) { static const struct option options[] = { - { "verbose", 0, NULL, 'v' }, - { "dry-run", 0, NULL, 'n' }, - { "type", 1, NULL, 't' }, - { "retry-failed", 0, NULL, 'F' }, - { "action", 1, NULL, 'c' }, - { "subsystem-match", 1, NULL, 's' }, - { "subsystem-nomatch", 1, NULL, 'S' }, - { "attr-match", 1, NULL, 'a' }, - { "attr-nomatch", 1, NULL, 'A' }, - { "help", 0, NULL, 'h' }, + { "verbose", no_argument, NULL, 'v' }, + { "dry-run", no_argument, NULL, 'n' }, + { "type", required_argument, NULL, 't' }, + { "retry-failed", no_argument, NULL, 'F' }, + { "action", required_argument, NULL, 'c' }, + { "subsystem-match", required_argument, NULL, 's' }, + { "subsystem-nomatch", required_argument, NULL, 'S' }, + { "attr-match", required_argument, NULL, 'a' }, + { "attr-nomatch", required_argument, NULL, 'A' }, + { "help", no_argument, NULL, 'h' }, {} }; enum { diff --git a/udev/udevadm.c b/udev/udevadm.c index b1811427..3f2c7821 100644 --- a/udev/udevadm.c +++ b/udev/udevadm.c @@ -124,9 +124,9 @@ int main(int argc, char *argv[]) { struct udev *udev; static const struct option options[] = { - { "debug", 0, NULL, 'd' }, - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, + { "debug", no_argument, NULL, 'd' }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, {} }; const char *command; diff --git a/udev/udevd.c b/udev/udevd.c index 9783fe4e..a821ee7d 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -784,11 +784,11 @@ int main(int argc, char *argv[]) const char *value; int daemonize = 0; static const struct option options[] = { - { "daemon", 0, NULL, 'd' }, - { "debug-trace", 0, NULL, 't' }, - { "debug", 0, NULL, 'D' }, - { "help", 0, NULL, 'h' }, - { "version", 0, NULL, 'V' }, + { "daemon", no_argument, NULL, 'd' }, + { "debug-trace", no_argument, NULL, 't' }, + { "debug", no_argument, NULL, 'D' }, + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, {} }; int rc = 1;