summaryrefslogtreecommitdiffhomepage
path: root/mixgtk
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-09-28 23:10:45 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-09-28 23:10:45 +0000
commit1d0fcf308929bde5749b889373d5c2f338fa8969 (patch)
tree624b053028a1ff9505b9fd297107278c5273e17d /mixgtk
parent08ae1393b7d415355308856618ca96c3ba2cfbd0 (diff)
downloadmdk-1d0fcf308929bde5749b889373d5c2f338fa8969.tar.gz
mdk-1d0fcf308929bde5749b889373d5c2f338fa8969.tar.bz2
uniform command line options handling
Diffstat (limited to 'mixgtk')
-rw-r--r--mixgtk/gmixvm.c73
1 files changed, 71 insertions, 2 deletions
diff --git a/mixgtk/gmixvm.c b/mixgtk/gmixvm.c
index 59b4b41..91b03f3 100644
--- a/mixgtk/gmixvm.c
+++ b/mixgtk/gmixvm.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- gmixvm.c :
* Main function of the mix gtk front-end
* ------------------------------------------------------------------
- * Last change: Time-stamp: "2001-04-28 22:37:45 jao"
+ * $Id: gmixvm.c,v 1.3 2001/09/28 23:10:45 jao Exp $
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include "mixgtk.h"
+static gboolean initfile_ = TRUE;
#ifdef MAKE_GUILE
# include <mixguile/mixguile.h>
@@ -33,15 +34,83 @@ inner_main_ (int argc, char *argv[])
{
mixgtk_init (argc, argv);
mixguile_set_cmd_dispatcher (mixgtk_cmd_dispatcher_get_mix_dispatcher ());
- mixguile_load_bootstrap ();
+ mixguile_load_bootstrap (initfile_);
mixgtk_main ();
mixgtk_release ();
}
#endif
+#ifdef HAVE_GETOPT_LONG
+# include <getopt.h>
+#else
+# include <lib/getopt.h>
+#endif /* HAVE_GETOPT_LONG */
+
+enum {
+ VER_OPT = 'v',
+ NOINIT_OPT = 'q',
+ HELP_OPT = 'h',
+ USAGE_OPT = 'u'
+};
+
+static const char *options_ = "vqhu";
+
+static struct option long_options_[] =
+{
+ {"version", no_argument, 0, VER_OPT},
+ {"help", no_argument, 0, HELP_OPT},
+ {"usage", no_argument, 0, USAGE_OPT},
+ {"noinit", no_argument, 0, NOINIT_OPT},
+ {0, 0, 0, 0}
+};
+
+static void print_usage_ (const gchar *prog)
+{
+ static const char *usage_ =
+ "Usage: %s [-vhuq] [--version] [--help] [--usage] [--noinit]\n";
+ fprintf (stderr, usage_, prog);
+}
+
int
main(int argc, char *argv[])
{
+ int c;
+
+ const char *prog_name = argv[0];
+
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
+
+ while (1)
+ {
+ c = getopt_long (argc, argv, options_, long_options_, (int*)0);
+
+ /* Detect the end of the options. */
+ if (c == -1)
+ break;
+
+ switch (c)
+ {
+ case VER_OPT:
+ mix_print_license ("gmixvm, GTK MIX virtual machine");
+ return EXIT_SUCCESS;
+ case NOINIT_OPT:
+ initfile_ = FALSE;
+ break;
+ case HELP_OPT:
+ case USAGE_OPT:
+ print_usage_ (prog_name);
+ return EXIT_SUCCESS;
+ case '?':
+ print_usage_ (prog_name);
+ return EXIT_FAILURE;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+
#ifdef MAKE_GUILE
mixguile_enter (argc, argv, inner_main_);
#else