1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* -*-c-*- -------------- gmixvm.c :
* Main function of the mix gtk front-end
* ------------------------------------------------------------------
* Copyright (C) 2001, 2002, 2006, 2007, 2009 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 3 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 <stdio.h>
#include <stdlib.h>
#include "mixgtk.h"
static gboolean initfile_ = TRUE;
#ifdef MAKE_GUILE
# include <mixguile/mixguile.h>
# include "mixgtk_cmd_dispatcher.h"
static void
inner_main_ (void *closure, 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 <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
if (!mixgtk_init (argc, argv)) return EXIT_FAILURE;
mixgtk_main ();
mixgtk_release ();
#endif
return EXIT_SUCCESS;
}
|