From 300160e73da486946ae513f1d039dcd7b85ff17c Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 20 Mar 2006 22:46:46 +0000 Subject: Version 1.2.1 imported git-archimport-id: mdk@sv.gnu.org/mdk--devel--1--patch-1 --- mixgtk/gmixvm.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 mixgtk/gmixvm.c (limited to 'mixgtk/gmixvm.c') diff --git a/mixgtk/gmixvm.c b/mixgtk/gmixvm.c new file mode 100644 index 0000000..150c891 --- /dev/null +++ b/mixgtk/gmixvm.c @@ -0,0 +1,124 @@ +/* -*-c-*- -------------- gmixvm.c : + * Main function of the mix gtk front-end + * ------------------------------------------------------------------ + * $Id: gmixvm.c,v 1.6 2005/09/20 19:43:14 jao Exp $ + * ------------------------------------------------------------------ + * Copyright (C) 2001, 2002 Free Software Foundation, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include +#include +#include "mixgtk.h" + +static gboolean initfile_ = TRUE; + +#ifdef MAKE_GUILE +# include +# include "mixgtk_cmd_dispatcher.h" +static void +inner_main_ (int argc, char *argv[]) +{ + mixgtk_init (argc, argv); + mixguile_set_cmd_dispatcher (mixgtk_cmd_dispatcher_get_mix_dispatcher ()); + mixguile_load_bootstrap (initfile_); + mixgtk_main (); + mixgtk_release (); +} +#endif + +#ifdef HAVE_GETOPT_LONG +# include +#else +# include +#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 + if (!mixgtk_init (argc, argv)) return EXIT_FAILURE; + mixgtk_main (); + mixgtk_release (); +#endif + + return EXIT_SUCCESS; +} -- cgit v1.2.3