summaryrefslogtreecommitdiffhomepage
path: root/mixguile/mixguile.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixguile/mixguile.c')
-rw-r--r--mixguile/mixguile.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/mixguile/mixguile.c b/mixguile/mixguile.c
index 52321ca..4072869 100644
--- a/mixguile/mixguile.c
+++ b/mixguile/mixguile.c
@@ -21,31 +21,70 @@
*
*/
+#include <mixlib/mix_config.h>
#include "mixguile_cmd_dispatcher.h"
#include "mixguile.h"
static mixguile_cmd_dispatcher_t *dispatcher_ = NULL;
+static mix_vm_cmd_dispatcher_t *vm_dispatcher_ = NULL;
static main_func_t main_fun_;
/* do local initialisation and enter the user provided main */
+
static void
real_main_ (int argc, char *argv[])
{
+ if (vm_dispatcher_)
+ {
+ mixguile_set_cmd_dispatcher (vm_dispatcher_);
+ mixguile_load_bootstrap ();
+ }
(*main_fun_)(argc, argv);
}
/*
initialise the guile command dispatcher and enter the provided
- main function. the mixlib is also initialised.
+ main function.
*/
void
-mixguile_init (int argc, char *argv[], main_func_t main_fun)
+mixguile_init (int argc, char *argv[], main_func_t main_fun,
+ mix_vm_cmd_dispatcher_t *dis)
{
- mix_init_lib ();
main_fun_ = main_fun;
+ vm_dispatcher_ = dis;
gh_enter (argc, argv, real_main_);
}
+/* load bootstrap file */
+void
+mixguile_load_bootstrap (void)
+{
+ FILE *scm = NULL;
+ const gchar *scmfile = SCM_FILE;
+ gchar *lscmfile =
+ g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S, MIX_CONFIG_DIR,
+ G_DIR_SEPARATOR_S, LOCAL_SCM_FILE, NULL);
+
+ if (!(scm = fopen (scmfile, "r"))
+ && !(scm = fopen ((scmfile = LOCAL_SCM_FILE), "r")))
+ {
+ g_warning ("mixguile bootstrap file %s not found\n", SCM_FILE);
+ scmfile = NULL;
+ }
+ else
+ fclose (scm);
+
+ if (scmfile) mixguile_interpret_file (scmfile);
+
+ if ((scm = fopen (lscmfile, "r")) != NULL)
+ {
+ fclose (scm);
+ mixguile_interpret_file (lscmfile);
+ }
+
+ g_free (lscmfile);
+}
+
/* enter the guile repl */
void
mixguile_enter_repl (int argc, char *argv[])
@@ -60,6 +99,7 @@ mixguile_set_cmd_dispatcher (mix_vm_cmd_dispatcher_t *dis)
{
g_return_if_fail (dis != NULL);
if (dispatcher_) mixguile_cmd_dispatcher_delete (dispatcher_);
+ vm_dispatcher_ = dis;
dispatcher_ = mixguile_cmd_dispatcher_new (dis);
g_assert (dispatcher_);
}