From 56fd9165d0e1979d8b73262ec575637f49b09e85 Mon Sep 17 00:00:00 2001 From: Joshua Kwan Date: Sun, 1 Feb 2004 20:53:08 +0000 Subject: [PATCH] Let's use getopt.. git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@210 db0b04b0-f4d1-0310-9a6d-de3e77497b0e --- dgamelaunch.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/dgamelaunch.c b/dgamelaunch.c index 1a8ded9..3408a32 100644 --- a/dgamelaunch.c +++ b/dgamelaunch.c @@ -1478,28 +1478,35 @@ main (int argc, char** argv) /* for chroot and program execution */ char atrcfilename[81], *spool; unsigned int len; - int i; + int c; - for (i = 1; i < argc; i++) + while ((c = getopt(argc, argv, "qh:p")) != -1) { - if (!strcmp(argv[i], "-q")) silent = 1; - if (*argv[i] == '-') + switch (c) { - i++; - continue; + case 'q': + silent = 1; break; + + default: + break; /*ignore */ } - else + } + + if (optind < argc) + { + while (optind < argc) { if (config) { if (!silent) - fprintf(stderr, "warning: using %s\n", argv[i]); + fprintf(stderr, "warning: using %s\n", argv[optind]); free(config); } - config = strdup(argv[i]); + config = strdup(argv[optind]); + optind++; } } - + create_config(); /* signal handlers */