summaryrefslogtreecommitdiff
path: root/libmu_scm
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-01-21 15:04:11 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-01-21 15:04:11 +0000
commit3dc974822b70bec356ef67234667a85033260e1b (patch)
treec7b416a94c69e8f76baf6804d58beeaad93b41a3 /libmu_scm
parentd81db5aec3ccb49aa16fe5a867c18e382b4c10ba (diff)
downloadmailutils-3dc974822b70bec356ef67234667a85033260e1b.tar.gz
mailutils-3dc974822b70bec356ef67234667a85033260e1b.tar.bz2
Added to repository
Diffstat (limited to 'libmu_scm')
-rw-r--r--libmu_scm/mu_guimb.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/libmu_scm/mu_guimb.c b/libmu_scm/mu_guimb.c
new file mode 100644
index 000000000..5b1e40814
--- /dev/null
+++ b/libmu_scm/mu_guimb.c
@@ -0,0 +1,80 @@
+/* GNU mailutils - a suite of utilities for electronic mail
+ Copyright (C) 1999, 2000, 2001 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, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#include <mu_scm.h>
+
+static void _scheme_main (void *closure, int argc, char **argv);
+
+void
+mu_process_mailbox (int argc, char *argv[], guimb_param_t *param)
+{
+ scm_boot_guile (argc, argv, _scheme_main, param);
+}
+
+SCM _current_mailbox;
+SCM _user_name;
+
+static SCM
+catch_body (void *closure)
+{
+ guimb_param_t *param = closure;
+ return param->catch_body (param->data, param->mbox);
+}
+
+void
+_scheme_main (void *closure, int argc, char **argv)
+{
+ guimb_param_t *param = closure;
+ SCM *scm_loc;
+
+ if (param->debug_guile)
+ {
+ SCM_DEVAL_P = 1;
+ SCM_BACKTRACE_P = 1;
+ SCM_RECORD_POSITIONS_P = 1;
+ SCM_RESET_DEBUG_MODE;
+ }
+
+/* Initialize scheme library */
+ mu_scm_init ();
+
+ /* Provide basic primitives */
+#include <mu_guimb.x>
+
+ _current_mailbox = mu_scm_mailbox_create (param->mbox);
+ scm_loc = SCM_CDRLOC (scm_sysintern ("current-mailbox", SCM_EOL));
+ *scm_loc = _current_mailbox;
+
+ _user_name = param->user_name ?
+ scm_makfrom0str (param->user_name) : SCM_BOOL_F;
+ scm_loc = SCM_CDRLOC (scm_sysintern ("user-name", SCM_EOL));
+ *scm_loc = _user_name;
+
+ if (param->init)
+ param->init (param->data);
+
+ do {
+ scm_internal_lazy_catch (SCM_BOOL_T,
+ catch_body, closure,
+ param->catch_handler, param->data);
+ } while (param->next && param->next (param->data, param->mbox));
+
+ if (param->exit)
+ exit (param->exit (param->data, param->mbox));
+
+ exit (0);
+}

Return to:

Send suggestions and report system problems to the System administrator.