From 58f9d88fb8f444cf2eb95509a58cfec322786b2b Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Mon, 24 Sep 2001 23:27:42 +0000 Subject: optionally load local startup file --- mixguile/mixguile_main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 3 deletions(-) (limited to 'mixguile/mixguile_main.c') diff --git a/mixguile/mixguile_main.c b/mixguile/mixguile_main.c index 183dfaf..fca0664 100644 --- a/mixguile/mixguile_main.c +++ b/mixguile/mixguile_main.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixguile_main.c : * Main function for mixguile, the MIX Guile shell * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/08/22 01:20:01 jao" + * $Id: mixguile_main.c,v 1.4 2001/09/24 23:28:03 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -25,19 +25,73 @@ #include #include "mixguile.h" + +#ifdef HAVE_GETOPT_LONG +# include +#else +# include +#endif /* HAVE_GETOPT_LONG */ + +enum { + VER_OPT = 'v', + NOINIT_OPT = 'q', +}; + +static const char *options_ = "vq"; + +static struct option long_options_[] = +{ + {"version", no_argument, 0, VER_OPT}, + {0, 0, 0, 0} +}; + int main (int argc, char *argv[]) { const gchar *CONFIG_FILE = "mixvm.config"; mix_config_t *config; mix_vm_cmd_dispatcher_t *dis; - + int c; + + const char *prog_name = argv[0]; + gboolean initfile = TRUE; + + setlocale (LC_ALL, ""); + bindtextdomain (PACKAGE, LOCALEDIR); + textdomain (PACKAGE); + + /* prevent getopt printing a message for unknown options (stored in optopt) */ + opterr = 0; + + 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: + fprintf (stderr, _("%s %s, Scheme MIX Virtual Machine.\n"), + prog_name, VERSION); + fprintf (stderr, MIX_GPL_LICENSE); + return EXIT_SUCCESS; + case NOINIT_OPT: + initfile = FALSE; + break; + default: + /* let guile try to understand the option */ + break; + } + } mix_init_lib (); config = mix_config_new (NULL, CONFIG_FILE); dis = mix_vm_cmd_dispatcher_new_with_config (stdout, stderr, config); - mixguile_init (argc, argv, mixguile_enter_repl, dis); + mixguile_init (argc, argv, initfile, mixguile_enter_repl, dis); return EXIT_SUCCESS; /* never reached */ } -- cgit v1.2.3