diff options
Diffstat (limited to 'mixguile')
-rw-r--r-- | mixguile/mixguile.c | 9 | ||||
-rw-r--r-- | mixguile/mixguile.h | 4 | ||||
-rw-r--r-- | mixguile/mixguile_main.c | 60 |
3 files changed, 65 insertions, 8 deletions
diff --git a/mixguile/mixguile.c b/mixguile/mixguile.c index 4da3068..482832a 100644 --- a/mixguile/mixguile.c +++ b/mixguile/mixguile.c @@ -1,7 +1,7 @@ /* -*-c-*- -------------- mixguile.c : * Implementation of the functions declared in mixguile.h * ------------------------------------------------------------------ - * Last change: Time-stamp: "01/08/22 01:10:33 jao" + * $Id: mixguile.c,v 1.5 2001/09/24 23:27:42 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -30,6 +30,7 @@ static mixguile_cmd_dispatcher_t *dispatcher_ = NULL; static mix_vm_cmd_dispatcher_t *vm_dispatcher_ = NULL; static main_func_t main_fun_; +static gboolean init_file_; /* do local initialisation and enter the user provided main */ @@ -49,11 +50,13 @@ real_main_ (int argc, char *argv[]) main function. */ void -mixguile_init (int argc, char *argv[], main_func_t main_fun, +mixguile_init (int argc, char *argv[], gboolean initfile, + main_func_t main_fun, mix_vm_cmd_dispatcher_t *dis) { main_fun_ = main_fun; vm_dispatcher_ = dis; + init_file_ = initfile; gh_enter (argc, argv, real_main_); } @@ -74,7 +77,7 @@ mixguile_load_bootstrap (void) else mixguile_interpret_file (scmfile); - if (!access (lscmfile, R_OK)) + if (init_file_ && !access (lscmfile, R_OK)) { mixguile_interpret_file (lscmfile); } diff --git a/mixguile/mixguile.h b/mixguile/mixguile.h index 6cc7918..469f455 100644 --- a/mixguile/mixguile.h +++ b/mixguile/mixguile.h @@ -1,7 +1,7 @@ /* -*-c-*- ---------------- mixguile.h : * Interface to the mixguile interpreter. * ------------------------------------------------------------------ - * Last change: Time-stamp: <01/08/21 23:48:15 jao> + * $Id: mixguile.h,v 1.4 2001/09/24 23:27:42 jao Exp $ * ------------------------------------------------------------------ * Copyright (C) 2001 Free Software Foundation, Inc. * @@ -45,7 +45,7 @@ mixguile_load_bootstrap (); main function. */ extern void -mixguile_init (int argc, char *argv[], main_func_t main_fun, +mixguile_init (int argc, char *argv[], gboolean initfile, main_func_t main_fun, mix_vm_cmd_dispatcher_t *dis); /* set the command dispatcher */ 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 <stdio.h> #include "mixguile.h" + +#ifdef HAVE_GETOPT_LONG +# include <getopt.h> +#else +# include <lib/getopt.h> +#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 */ } |