aboutsummaryrefslogtreecommitdiffstats
path: root/sisinstall
diff options
context:
space:
mode:
authorDaniel Brahneborg <basic@chello.se>2002-03-19 13:33:40 +0000
committerDaniel Brahneborg <basic@chello.se>2002-03-19 13:33:40 +0000
commita7f48478e5126a8cd4b729109ab7aacabc615c66 (patch)
tree1195f1f2598474c6ab48f1432969899535707106 /sisinstall
parentb2c72c769b39e9b20c3934bc5bb37aa438e7e7d5 (diff)
downloadplptools-a7f48478e5126a8cd4b729109ab7aacabc615c66.tar.gz
plptools-a7f48478e5126a8cd4b729109ab7aacabc615c66.tar.bz2
plptools-a7f48478e5126a8cd4b729109ab7aacabc615c66.zip
Support long options.
Diffstat (limited to 'sisinstall')
-rw-r--r--sisinstall/sismain.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/sisinstall/sismain.cpp b/sisinstall/sismain.cpp
index 8420733..21d6f55 100644
--- a/sisinstall/sismain.cpp
+++ b/sisinstall/sismain.cpp
@@ -13,27 +13,65 @@
#include <sys/types.h>
#include <sys/stat.h>
+#define _GNU_SOURCE
+#include <getopt.h>
+
static void error(int line)
{
fprintf(stderr, "Got errno = %d on line %d\n", errno, line);
exit(1);
}
+static struct option opts[] = {
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'V' },
+ { "loglevel", required_argument, 0, 'l' },
+ { "dry-run", no_argument, 0, 'n' },
+ { "force", no_argument, 0, 'f' },
+ { NULL, 0, 0, 0 },
+};
+
+void printHelp()
+{
+ printf(
+ _("Usage: sisinstall [OPTIONS]... SISFILE\n"
+ "\n"
+ "Supported options:\n"
+ "\n"
+ " -h, --help Display this text.\n"
+ " -V, --version Print version and exit.\n"
+ " -l, --loglevel=LEVEL Set the log level, by default 0.\n"
+ " -n, --dry-run Just parse file file.\n"
+ " -f, --force Ignore any earlier installations.\n"
+ ));
+}
+
void main(int argc, char* argv[])
{
char* filename = 0;
char option;
bool dryrun = false;
+ bool forced = false;
#ifdef LC_ALL
setlocale(LC_ALL, "");
#endif
textdomain(PACKAGE);
- while ((option = getopt(argc, argv, "nl:")) != -1)
+ while (1)
{
+ option = getopt_long(argc, argv, "fhnl:", opts, NULL);
+ if (option == -1)
+ break;
switch (option)
{
+ case 'h':
+ case '?':
+ printHelp();
+ exit(0);
+ case 'f':
+ forced = true;
+ break;
case 'l':
logLevel = atoi(optarg);
break;
@@ -80,6 +118,7 @@ void main(int argc, char* argv[])
{
SISInstaller installer;
installer.setPsion(psion);
+ installer.setForced(forced);
installer.run(&sisFile, buf, len);
}
}