Commit 79d50145 79d50145c61bb725de932955c86cf96f275f60b3 by Sergey Poznyakoff

Remove guimb.

It was inoperational since 2009-03-27 and nobody complained, so it seems
to not be reclaimed at all. FWIW, it will be easy to recreate it entirely
in Scheme, should the need be.

* guimb/.gitignore: Remove.
* guimb/Makefile.am: Remove.
* guimb/collect.c: Remove.
* guimb/guimb.h: Remove.
* guimb/main.c: Remove.
* guimb/util.c: Remove.

* Makefile.am (GUIMB_DIR): Remove.
[MU_COND_LIBMU_SCM] (SCHEME_DIR): New variable.
(SUBDIRS): Add SCHEME_DIR instead of GUIMB_DIR.
* configure.ac (MU_GUILE_SIEVE_MOD_DATA): Remove substitution.
(AC_CONFIG_FILES): Remove guimb and guimb/scm, add scheme

* guimb/scm/.gitignore: move to scheme/.gitignore
* guimb/scm/Makefile.am: move to scheme/Makefile.am
* guimb/scm/README: move to scheme/README
* guimb/scm/mimeheader.scm: move to scheme/mimeheader.scm
* guimb/scm/numaddr.scm: move to scheme/numaddr.scm
* guimb/scm/redirect.scm: move to scheme/redirect.scm
* guimb/scm/reject.scm: move to scheme/reject.scm
* guimb/scm/sieve-core.scm: move to scheme/sieve-core.scm
* guimb/scm/sieve.scm.in: move to scheme/sieve2scm.scmi
* guimb/scm/vacation.scm: move to scheme/vacation.scm
1 parent b6671a03
......@@ -49,10 +49,6 @@ if MU_COND_SIEVE
SIEVE_DIR = sieve
endif
if MU_COND_GUIMB
GUIMB_DIR = guimb
endif
if MU_COND_MESSAGES
MESSAGES_DIR = messages
endif
......@@ -80,6 +76,7 @@ endif
if MU_COND_LIBMU_SCM
GINT_DIR = gint
LIBMU_SCM_DIR = libmu_scm
SCHEME_DIR = scheme
endif
if MU_COND_SUPPORT_CXX
......@@ -107,13 +104,13 @@ SUBDIRS = . \
doc\
examples\
mu\
$(SCHEME_DIR)\
$(FRM_DIR)\
$(POP3D_DIR)\
$(IMAP4D_DIR)\
$(MAIDAG_DIR)\
$(MAIL_DIR)\
$(SIEVE_DIR)\
$(GUIMB_DIR)\
$(MESSAGES_DIR)\
$(COMSAT_DIR)\
$(READMSG_DIR)\
......
......@@ -1067,7 +1067,6 @@ AC_SUBST([GUILE_BINDIR])
AC_SUBST([LIBMU_SCM])
AC_SUBST([LIBMU_SCM_DEPS])
AC_SUBST([MU_GUILE_SIEVE_MOD_DIR])
AC_SUBST([MU_GUILE_SIEVE_MOD_DATA])
GINT_INIT([gint],[1.8 with-guile],
[useguile=yes
AC_DEFINE([WITH_GUILE],1,[Enable Guile support])
......@@ -1075,7 +1074,6 @@ GINT_INIT([gint],[1.8 with-guile],
LIBMU_SCM=../libmu_scm/libmu_scm.la
LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}'
MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/$(PACKAGE)/sieve-modules'
MU_GUILE_SIEVE_MOD_DATA='$(MU_GUILE_SIEVE_MOD_DATA_X)'
GINT_INCLUDES='${MU_APP_COMMON_INCLUDES}'
GINT_LDADD=../lib/libmuaux.a
],[useguile=no])
......@@ -1185,7 +1183,6 @@ MU_ENABLE_BUILD(comsat)
MU_ENABLE_BUILD(maidag)
MU_ENABLE_BUILD(mail)
MU_ENABLE_BUILD(sieve)
MU_ENABLE_BUILD(guimb,,,["$useguile" = "yes"])
MU_ENABLE_BUILD(messages)
MU_ENABLE_BUILD(readmsg)
MU_ENABLE_BUILD(dotlock)
......@@ -1354,8 +1351,7 @@ AC_CONFIG_FILES([
examples/scheme/Makefile
gint/Makefile
frm/Makefile
guimb/Makefile
guimb/scm/Makefile
scheme/Makefile
imap4d/Makefile
imap4d/testsuite/Makefile
include/Makefile
......
Makefile.in
Makefile
guimb
guile-procedures.txt
.deps
*.doc
*.x
.libs
.gdbinit
## This file is part of GNU Mailutils.
## Copyright (C) 2001, 2002, 2007, 2009, 2010 Free Software
## Foundation, Inc.
##
## GNU Mailutils 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, or (at
## your option) any later version.
##
## GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
INCLUDES = @MU_APP_COMMON_INCLUDES@ @GUILE_INCLUDES@
SUBDIRS=scm
bin_PROGRAMS=guimb
guimb_SOURCES=main.c collect.c util.c guimb.h
guimb_LDADD = \
${MU_APP_LIBRARIES}\
../libmu_scm/libmu_scm.la\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
${MU_LIB_NNTP}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
${MU_LIB_MAILER}\
${MU_LIB_AUTH}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS}\
@GUILE_LIBS@ @MU_COMMON_LIBRARIES@
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
Software Foundation, Inc.
GNU Mailutils 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, or (at your option)
any later version.
GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include "guimb.h"
char *temp_filename;
FILE *temp_file;
mu_mailbox_t mbox;
void
collect_open_default ()
{
size_t nmesg;
if (!default_mailbox)
{
int rc = mu_construct_user_mailbox_url (&default_mailbox, user_name);
if (rc)
{
util_error (_("cannot construct default mailbox URL: %s"),
mu_strerror (rc));
exit (1);
}
}
if (mu_mailbox_create (&mbox, default_mailbox) != 0
|| mu_mailbox_open (mbox, MU_STREAM_RDWR) != 0)
{
util_error (_("cannot open default mailbox %s: %s"),
default_mailbox, mu_strerror (errno));
exit (1);
}
/* Suck in the messages */
mu_mailbox_messages_count (mbox, &nmesg);
}
/* Open temporary file for collecting incoming messages */
void
collect_open_mailbox_file ()
{
int fd;
/* Create input mailbox */
if (mu_tempfile (NULL, 0, &fd, &temp_filename))
exit (1);
temp_file = fdopen (fd, "w");
if (!temp_file)
{
util_error ("fdopen: %s", strerror (errno));
close (fd);
exit (1);
}
}
/* Append contents of file `name' to the temporary file */
int
collect_append_file (char *name)
{
char *buf = NULL;
size_t n = 0;
FILE *fp;
if (strcmp (name, "-") == 0)
fp = stdin;
else
{
fp = fopen (name, "r");
if (!fp)
{
util_error (_("cannot open input file %s: %s"), name, strerror (errno));
return -1;
}
}
/* Copy the contents of the file */
while (getline (&buf, &n, fp) > 0)
fprintf (temp_file, "%s", buf);
free (buf);
fclose (fp);
return 0;
}
/* Close the temporary, and reopen it as a mailbox. */
void
collect_create_mailbox ()
{
size_t nmesg;
if (!temp_file)
return;
fclose (temp_file);
if (mu_mailbox_create (&mbox, temp_filename) != 0
|| mu_mailbox_open (mbox, MU_STREAM_READ) != 0)
{
util_error (_("cannot create temp mailbox %s: %s"),
temp_filename, strerror (errno));
unlink (temp_filename);
exit (1);
}
/* Suck in the messages */
mu_mailbox_messages_count (mbox, &nmesg);
if (nmesg == 0)
{
util_error (_("input format not recognized"));
exit (1);
}
}
int
collect_output ()
{
size_t i, count = 0;
mu_mailbox_t outbox = NULL;
int saved_umask;
if (!temp_filename)
{
mu_mailbox_expunge (mbox);
return 0;
}
if (user_name)
saved_umask = umask (077);
if (mu_mailbox_create_default (&outbox, default_mailbox) != 0
|| mu_mailbox_open (outbox, MU_STREAM_RDWR|MU_STREAM_CREAT) != 0)
{
mu_mailbox_destroy (&outbox);
mu_error (_("cannot open output mailbox %s: %s"),
default_mailbox, strerror (errno));
return 1;
}
mu_mailbox_messages_count (mbox, &count);
for (i = 1; i <= count; i++)
{
mu_message_t msg = NULL;
mu_attribute_t attr = NULL;
mu_mailbox_get_message (mbox, i, &msg);
mu_message_get_attribute (msg, &attr);
if (!mu_attribute_is_deleted (attr))
{
mu_attribute_set_recent (attr);
mu_mailbox_append_message (outbox, msg);
}
}
mu_mailbox_close (outbox);
mu_mailbox_destroy (&outbox);
if (user_name)
umask (saved_umask);
return 0;
}
/* Close the temporary mailbox and unlink the file associated with it */
void
collect_drop_mailbox ()
{
mu_mailbox_close (mbox);
mu_mailbox_destroy (&mbox);
if (temp_filename)
{
unlink (temp_filename);
free (temp_filename);
}
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
Software Foundation, Inc.
GNU Mailutils 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, or (at your option)
any later version.
GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#if defined(HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h> /* strerror(3), strdup(3) */
#include <mailutils/errno.h>
#include <mailutils/mailbox.h>
#include <mailutils/message.h>
#include <mailutils/header.h>
#include <mailutils/body.h>
#include <mailutils/registrar.h>
#include <mailutils/error.h>
#include <mailutils/address.h>
#include <mailutils/registrar.h>
#include <mailutils/stream.h>
#include <mailutils/guile.h>
#include <mailutils/nls.h>
#include <mailutils/list.h>
#include <mailutils/util.h>
#include <mailutils/attribute.h>
#include <mailutils/envelope.h>
#include <mailutils/io.h>
extern char *program_file;
extern char *program_expr;
extern char *user_name;
extern char *default_mailbox;
extern mu_mailbox_t mbox;
extern size_t nmesg;
extern size_t current_mesg_no;
extern mu_message_t current_message;
extern int debug_guile;
extern char *maildir;
void collect_open_default (void);
void collect_open_mailbox_file (void);
int collect_append_file (char *name);
void collect_create_mailbox (void);
void collect_drop_mailbox (void);
int collect_output (void);
void util_error (const char *fmt, ...) MU_PRINTFLIKE(1, 2);
int util_tempfile (char **namep);
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
2009, 2010 Free Software Foundation, Inc.
GNU Mailutils 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, or (at your option)
any later version.
GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include "guimb.h"
#include "mailutils/libargp.h"
char *program_file;
char *program_expr;
int debug_guile;
char *user_name;
char *default_mailbox;
char * who_am_i ();
static int g_size;
static int g_argc;
static char **g_argv;
#define ARG_INC 16
void
append_arg (char *arg)
{
if (g_argc == g_size)
{
g_size += ARG_INC;
g_argv = realloc (g_argv, g_size * sizeof (g_argv[0]));
if (!g_argv)
{
util_error (_("not enough memory"));
exit (1);
}
}
g_argv[g_argc++] = arg;
}
static struct argp_option options[] = {
{NULL, 0, NULL, 0,
/* TRANSLATORS: (command-line) is the name of Guile function. Do not
translate it.
*/
N_("The following switches stop argument processing, and pass all\n"
"remaining arguments as the value of (command-line):"), 1},
{"code", 'c', N_("EXPR"), 0, N_("execute given scheme expression"), 1},
{"source", 's', N_("PROGFILE"), 0,
N_("load Scheme source code from PROGFILE and exit"), 1},
{NULL, 0, NULL, 0,
N_("The following options do not change the order of options parsing:"), 2},
{"expression", 'e', N_("EXPR"), 0, N_("execute given scheme expression"), 2},
{"file", 'f', N_("PROGFILE"), 0,
N_("load Scheme source code from PROGFILE and exit"), 2},
{NULL, 0, NULL, 0, N_("Other options:"), 3},
{"debug", 'd', NULL, 0, N_("start with debugging evaluator and backtraces"), 3},
{"guile-arg", 'g', N_("ARG"), 0,
N_("append ARG to the command line passed to Guile"), 3},
{"mailbox", 'M', N_("NAME"), 0, N_("set default mailbox name"), 3},
{"user", 'u', N_("NAME"), OPTION_ARG_OPTIONAL,
N_("act as local MDA for user NAME"), 3},
{0, 0, 0, 0}
};
static error_t
parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case 'c':
program_expr = arg;
*(int *)state->input = state->next;
state->next = state->argc;
break;
case 's':
program_file = arg;
*(int *)state->input = state->next;
state->next = state->argc;
break;
case 'f':
program_file = arg;
break;
case 'e':
program_expr = arg;
break;
case 'd':
debug_guile = 1;
break;
case 'g':
append_arg (arg);
break;
case 'M':
default_mailbox = arg;
break;
case 'u':
user_name = arg ? arg : who_am_i ();
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static char doc[] =
N_("GNU guimb -- process contents of the specified mailboxes "
"using a Scheme program or expression.");
static char args_doc[] = N_("[mailbox...]");
static struct argp argp = {
options,
parse_opt,
args_doc,
doc,
NULL,
NULL, NULL
};
static const char *guimb_argp_capa[] = {
"common",
"debug",
"mailbox",
"locking",
NULL
};
char *main_sym = "mailutils-main";
int
main (int argc, char *argv[])
{
int rc;
int c = argc;
int index;
/* Native Language Support */
MU_APP_INIT_NLS ();
/* Register the desired formats. */
mu_register_all_formats ();
mu_argp_init (NULL, NULL);
if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
exit (1);
for (; c < argc; c++)
append_arg (argv[c]);
if (!user_name)
user_name = who_am_i ();
if (!program_file && !program_expr)
{
mu_error (_("At least one of -fecs must be used. Try guimb --help for more info."));
exit (1);
}
if (!argv[index])
{
if (default_mailbox)
append_arg (default_mailbox);
collect_open_default ();
}
else
{
collect_open_mailbox_file ();
if (argv[index])
{
for (; argv[index]; index++)
{
append_arg (argv[index]);
collect_append_file (argv[index]);
}
}
else
collect_append_file ("-");
}
/* Finish creating input mailbox */
collect_create_mailbox ();
mu_guile_init (debug_guile);
if (program_file)
mu_guile_load (program_file, g_argc, g_argv);
if (program_expr)
mu_guile_eval (program_expr);
rc = mu_guile_mailbox_apply (mbox, main_sym);
switch (rc)
{
case 0:
collect_output ();
break;
case MU_ERR_NOENT:
mu_error (_("%s not defined"), main_sym);
break;
case EINVAL:
mu_error (_("%s is not a procedure object"), main_sym);
break;
case MU_ERR_FAILURE:
mu_error (_("execution of %s failed"), main_sym);
break;
default:
mu_error (_("unrecognized error"));
break;
}
collect_drop_mailbox ();
return !!rc;
}
char *
who_am_i ()
{
char *name = getenv ("LOGNAME");
if (!name)
{
name = getenv ("USER");
if (!name)
name = strdup (getlogin ());
}
return name;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
Software Foundation, Inc.
GNU Mailutils 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, or (at your option)
any later version.
GNU Mailutils 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 GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
#include "guimb.h"
void
util_error (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
fprintf (stderr, "guimb: ");
vfprintf (stderr, fmt, ap);
fprintf (stderr, "\n");
va_end (ap);
}
char *
util_get_sender (int msgno)
{
mu_header_t header = NULL;
mu_address_t addr = NULL;
mu_message_t msg = NULL;
const char *buffer;
char *email;
mu_mailbox_get_message (mbox, msgno, &msg);
mu_message_get_header (msg, &header);
if (mu_header_sget_value (header, MU_HEADER_FROM, &buffer)
|| mu_address_create (&addr, buffer))
{
mu_envelope_t env = NULL;
mu_message_get_envelope (msg, &env);
if (mu_envelope_sget_sender (env, &buffer)
|| mu_address_create (&addr, buffer))
{
util_error (_("cannot determine sender name (msg %d)"), msgno);
return NULL;
}
}
if (mu_address_aget_email (addr, 1, &email))
{
util_error (_("cannot determine sender name (msg %d)"), msgno);
mu_address_destroy (&addr);
return NULL;
}
mu_address_destroy (&addr);
return email;
}
......@@ -13,10 +13,6 @@ frm/common.c
frm/frm.c
frm/from.c
guimb/collect.c
guimb/main.c
guimb/util.c
imap4d/auth_gsasl.c
imap4d/auth_gss.c
imap4d/bye.c
......
......@@ -15,19 +15,19 @@
## You should have received a copy of the GNU General Public License
## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
MU_GUILE_SIEVE_SCRIPTS_X=sieve.scm
bin_SCRIPTS = sieve.scm
EXTRA_SCRIPTS=sieve.scm
# FIXME: Sieve.scm is temporarly exempted from installchecks because
bin_SCRIPTS = sieve2scm
EXTRA_SCRIPTS=sieve2scm
# FIXME: Sieve2scm is temporarly exempted from installchecks because
# it may fail starting during checks, if libguile-mailutils-v- library
# has not been previously installed. The proper fix would be to alter
# %load-path during tests.
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=sieve.scm
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=sieve2scm
sievemoddir=@MU_GUILE_SIEVE_MOD_DIR@
sieve.scm: sieve.scm.in sieve.sed
$(AM_V_GEN)sed -f sieve.sed $(srcdir)/sieve.scm.in > sieve.scm
sieve2scm: sieve2scm.scmi sieve.sed
$(AM_V_GEN)sed -f sieve.sed $(srcdir)/sieve2scm.scmi > sieve2scm
$(AM_V_at)chmod +w sieve2scm
sieve.sed: Makefile
$(AM_V_GEN)echo 's,%GUILE_BINDIR%,@GUILE_BINDIR@,g' > sieve.sed
......@@ -37,26 +37,20 @@ sieve.sed: Makefile
$(AM_V_at)echo 's,%PACKAGE%,$(PACKAGE),g' >> sieve.sed
$(AM_V_at)echo 's,%VERSION%,$(VERSION),g' >> sieve.sed
CLEANFILES = sieve.scm sieve.sed
CLEANFILES = sieve2scm sieve.sed
sitedir=@GUILE_SITE@/$(PACKAGE)
site_DATA=sieve-core.scm
MU_GUILE_SIEVE_MOD_DATA_X=\
sievemod_DATA=\
mimeheader.scm\
numaddr.scm\
redirect.scm\
reject.scm\
vacation.scm
sievemod_DATA=@MU_GUILE_SIEVE_MOD_DATA@
EXTRA_DIST=\
mimeheader.scm\
numaddr.scm\
redirect.scm\
reject.scm\
$(sievemod_DATA)\
sieve-core.scm\
sieve.scm.in\
vacation.scm
sieve2scm.scmi
......
......@@ -449,13 +449,6 @@
(if (isatty? (current-error-port))
(display (string-append level ": " msg "\n") (current-error-port)))))
(define (guimb?)
(catch #t
(lambda ()
(let ((v current-mailbox))
v))
(lambda args #f)))
;;; Sieve-main
(define-public sieve-mailbox #f)
(define-public sieve-current-message #f)
......@@ -490,20 +483,14 @@
(define-public (sieve-main thunk)
(handle-exception
(cond
((not (guimb?))
(let* ((cl (sieve-command-line))
(name (if (and (not (null? (cdr cl)))
(string? (cadr cl)))
(cadr cl)
(mu-user-mailbox-url
(passwd:name (mu-getpwuid (getuid)))))))
(set! sieve-mailbox (mu-mailbox-open name "rw"))
(sieve-run thunk)
(mu-mailbox-expunge sieve-mailbox)
(mu-mailbox-close sieve-mailbox)))
(else
(set! sieve-mailbox current-mailbox)
(sieve-run thunk)))))
(let* ((cl (sieve-command-line))
(name (if (and (not (null? (cdr cl)))
(string? (cadr cl)))
(cadr cl)
(mu-user-mailbox-url
(passwd:name (mu-getpwuid (getuid)))))))
(set! sieve-mailbox (mu-mailbox-open name "rw"))
(sieve-run thunk)
(mu-mailbox-expunge sieve-mailbox)
(mu-mailbox-close sieve-mailbox))))
......
......@@ -23,14 +23,12 @@
;;;;
;;;; To convert a sieve script into equivalent Scheme program, run:
;;;;
;;;; guile -s sieve.scm --file <sieve-script-name> --output <output-file-name>
;;;; guile -s sieve2scm.scm --file <sieve-script-name> --output <output-file-name>
;;;;
;;;; To compile and execute a sieve script upon a mailbox, run:
;;;;
;;;; guile -s sieve.scm --file <sieve-script-name> [mailbox-name]
;;;; or
;;;; guimb [--mailbox mailbox-name] -s sieve.scm --file <sieve-script-name>
;;;; guile -s sieve2scm.scm --file <sieve-script-name> [mailbox-name]
;;;;
(if (not (member "%GUILE_SITE%" %load-path))
(set! %load-path (cons "%GUILE_SITE%" %load-path)))
(use-modules (ice-9 getopt-long)
......@@ -926,18 +924,14 @@
;;; Save the program
(define (sieve-save-program outfile guimb-header)
(define (sieve-save-program outfile)
(with-output-to-file
outfile
(lambda ()
(display "#! ")
(cond
(guimb-header
(display "/home/gray/alpha/bin/guimb -s\n"))
(else
(display "/bin/sh\n\
(display "/bin/sh\n\
# aside from this initial boilerplate, this is actually -*- scheme -*- code\n\
exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")
(display (string-append
"# This Guile mailbox parser was made from " filename))
(newline)
......@@ -985,16 +979,14 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
(define filename #f)
(define output #f)
(define guimb-header #f)
(define (sieve-usage)
(display "usage: sieve.scm [OPTIONS][mailbox]\n")
(display "GNU sieve.scm -- compile a Sieve program into Scheme code\n")
(display "usage: sieve2scm [OPTIONS][mailbox]\n")
(display "GNU sieve2scm -- compile a Sieve program into Scheme code\n")
(display "Options are:\n")
(display " -f, --file FILENAME Set input file name\n")
(display " -o, --output FILENAME Set output file name\n")
(display " -L, --lib-dir DIRNAME Set sieve library directory name\n")
(display " -g, --guimb Make output file executable for guimb\n")
(display " -d, --debug LEVEL Set debugging level\n")
(display " --version Show program version\n\n")
(display "If -o option is not given, the compiled program is executed\n")
......@@ -1018,7 +1010,6 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
(value #t))
(lib-dir (single-char #\L)
(value #t))
(guimb (single-char #\g))
(version)
(verbose (single-char #\v))
(help (single-char #\h))))
......@@ -1038,8 +1029,6 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
(set! sieve-libdir (cdr x)))
((output)
(set! output (cdr x)))
((guimb)
(set! guimb-header #t))
((version)
(sieve-version))
((verbose)
......@@ -1083,11 +1072,11 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
(newline)
(exit 1))
(output
(sieve-save-program output guimb-header))
(sieve-save-program output))
(else
(let ((temp-file (tmpnam))
(saved-umask (umask #o077)))
(sieve-save-program temp-file guimb-header)
(sieve-save-program temp-file)
(catch #t
(lambda ()
(set-cdr! (command-line) sieve-script-args)
......