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 ...@@ -49,10 +49,6 @@ if MU_COND_SIEVE
49 SIEVE_DIR = sieve 49 SIEVE_DIR = sieve
50 endif 50 endif
51 51
52 if MU_COND_GUIMB
53 GUIMB_DIR = guimb
54 endif
55
56 if MU_COND_MESSAGES 52 if MU_COND_MESSAGES
57 MESSAGES_DIR = messages 53 MESSAGES_DIR = messages
58 endif 54 endif
...@@ -80,6 +76,7 @@ endif ...@@ -80,6 +76,7 @@ endif
80 if MU_COND_LIBMU_SCM 76 if MU_COND_LIBMU_SCM
81 GINT_DIR = gint 77 GINT_DIR = gint
82 LIBMU_SCM_DIR = libmu_scm 78 LIBMU_SCM_DIR = libmu_scm
79 SCHEME_DIR = scheme
83 endif 80 endif
84 81
85 if MU_COND_SUPPORT_CXX 82 if MU_COND_SUPPORT_CXX
...@@ -107,13 +104,13 @@ SUBDIRS = . \ ...@@ -107,13 +104,13 @@ SUBDIRS = . \
107 doc\ 104 doc\
108 examples\ 105 examples\
109 mu\ 106 mu\
107 $(SCHEME_DIR)\
110 $(FRM_DIR)\ 108 $(FRM_DIR)\
111 $(POP3D_DIR)\ 109 $(POP3D_DIR)\
112 $(IMAP4D_DIR)\ 110 $(IMAP4D_DIR)\
113 $(MAIDAG_DIR)\ 111 $(MAIDAG_DIR)\
114 $(MAIL_DIR)\ 112 $(MAIL_DIR)\
115 $(SIEVE_DIR)\ 113 $(SIEVE_DIR)\
116 $(GUIMB_DIR)\
117 $(MESSAGES_DIR)\ 114 $(MESSAGES_DIR)\
118 $(COMSAT_DIR)\ 115 $(COMSAT_DIR)\
119 $(READMSG_DIR)\ 116 $(READMSG_DIR)\
......
...@@ -1067,7 +1067,6 @@ AC_SUBST([GUILE_BINDIR]) ...@@ -1067,7 +1067,6 @@ AC_SUBST([GUILE_BINDIR])
1067 AC_SUBST([LIBMU_SCM]) 1067 AC_SUBST([LIBMU_SCM])
1068 AC_SUBST([LIBMU_SCM_DEPS]) 1068 AC_SUBST([LIBMU_SCM_DEPS])
1069 AC_SUBST([MU_GUILE_SIEVE_MOD_DIR]) 1069 AC_SUBST([MU_GUILE_SIEVE_MOD_DIR])
1070 AC_SUBST([MU_GUILE_SIEVE_MOD_DATA])
1071 GINT_INIT([gint],[1.8 with-guile], 1070 GINT_INIT([gint],[1.8 with-guile],
1072 [useguile=yes 1071 [useguile=yes
1073 AC_DEFINE([WITH_GUILE],1,[Enable Guile support]) 1072 AC_DEFINE([WITH_GUILE],1,[Enable Guile support])
...@@ -1075,7 +1074,6 @@ GINT_INIT([gint],[1.8 with-guile], ...@@ -1075,7 +1074,6 @@ GINT_INIT([gint],[1.8 with-guile],
1075 LIBMU_SCM=../libmu_scm/libmu_scm.la 1074 LIBMU_SCM=../libmu_scm/libmu_scm.la
1076 LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}' 1075 LIBMU_SCM_DEPS='${MU_LIB_MBOX} ${MU_LIB_IMAP} ${MU_LIB_POP} ${MU_LIB_MH} ${MU_LIB_MAILDIR} ${MU_LIB_MAILER}'
1077 MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/$(PACKAGE)/sieve-modules' 1076 MU_GUILE_SIEVE_MOD_DIR='$(GUILE_SITE)/$(PACKAGE)/sieve-modules'
1078 MU_GUILE_SIEVE_MOD_DATA='$(MU_GUILE_SIEVE_MOD_DATA_X)'
1079 GINT_INCLUDES='${MU_APP_COMMON_INCLUDES}' 1077 GINT_INCLUDES='${MU_APP_COMMON_INCLUDES}'
1080 GINT_LDADD=../lib/libmuaux.a 1078 GINT_LDADD=../lib/libmuaux.a
1081 ],[useguile=no]) 1079 ],[useguile=no])
...@@ -1185,7 +1183,6 @@ MU_ENABLE_BUILD(comsat) ...@@ -1185,7 +1183,6 @@ MU_ENABLE_BUILD(comsat)
1185 MU_ENABLE_BUILD(maidag) 1183 MU_ENABLE_BUILD(maidag)
1186 MU_ENABLE_BUILD(mail) 1184 MU_ENABLE_BUILD(mail)
1187 MU_ENABLE_BUILD(sieve) 1185 MU_ENABLE_BUILD(sieve)
1188 MU_ENABLE_BUILD(guimb,,,["$useguile" = "yes"])
1189 MU_ENABLE_BUILD(messages) 1186 MU_ENABLE_BUILD(messages)
1190 MU_ENABLE_BUILD(readmsg) 1187 MU_ENABLE_BUILD(readmsg)
1191 MU_ENABLE_BUILD(dotlock) 1188 MU_ENABLE_BUILD(dotlock)
...@@ -1354,8 +1351,7 @@ AC_CONFIG_FILES([ ...@@ -1354,8 +1351,7 @@ AC_CONFIG_FILES([
1354 examples/scheme/Makefile 1351 examples/scheme/Makefile
1355 gint/Makefile 1352 gint/Makefile
1356 frm/Makefile 1353 frm/Makefile
1357 guimb/Makefile 1354 scheme/Makefile
1358 guimb/scm/Makefile
1359 imap4d/Makefile 1355 imap4d/Makefile
1360 imap4d/testsuite/Makefile 1356 imap4d/testsuite/Makefile
1361 include/Makefile 1357 include/Makefile
......
1 Makefile.in
2 Makefile
3 guimb
4 guile-procedures.txt
5 .deps
6 *.doc
7 *.x
8 .libs
9 .gdbinit
1 ## This file is part of GNU Mailutils.
2 ## Copyright (C) 2001, 2002, 2007, 2009, 2010 Free Software
3 ## Foundation, Inc.
4 ##
5 ## GNU Mailutils is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License as
7 ## published by the Free Software Foundation; either version 3, or (at
8 ## your option) any later version.
9 ##
10 ## GNU Mailutils is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17
18 INCLUDES = @MU_APP_COMMON_INCLUDES@ @GUILE_INCLUDES@
19
20 SUBDIRS=scm
21
22 bin_PROGRAMS=guimb
23 guimb_SOURCES=main.c collect.c util.c guimb.h
24 guimb_LDADD = \
25 ${MU_APP_LIBRARIES}\
26 ../libmu_scm/libmu_scm.la\
27 ${MU_LIB_MBOX}\
28 ${MU_LIB_IMAP}\
29 ${MU_LIB_POP}\
30 ${MU_LIB_NNTP}\
31 ${MU_LIB_MH}\
32 ${MU_LIB_MAILDIR}\
33 ${MU_LIB_MAILER}\
34 ${MU_LIB_AUTH}\
35 @MU_AUTHLIBS@\
36 ${MU_LIB_MAILUTILS}\
37 @GUILE_LIBS@ @MU_COMMON_LIBRARIES@
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
3 Software Foundation, Inc.
4
5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GNU Mailutils is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include "guimb.h"
19
20 char *temp_filename;
21 FILE *temp_file;
22 mu_mailbox_t mbox;
23
24 void
25 collect_open_default ()
26 {
27 size_t nmesg;
28
29 if (!default_mailbox)
30 {
31 int rc = mu_construct_user_mailbox_url (&default_mailbox, user_name);
32 if (rc)
33 {
34 util_error (_("cannot construct default mailbox URL: %s"),
35 mu_strerror (rc));
36 exit (1);
37 }
38 }
39 if (mu_mailbox_create (&mbox, default_mailbox) != 0
40 || mu_mailbox_open (mbox, MU_STREAM_RDWR) != 0)
41 {
42 util_error (_("cannot open default mailbox %s: %s"),
43 default_mailbox, mu_strerror (errno));
44 exit (1);
45 }
46
47 /* Suck in the messages */
48 mu_mailbox_messages_count (mbox, &nmesg);
49 }
50
51 /* Open temporary file for collecting incoming messages */
52 void
53 collect_open_mailbox_file ()
54 {
55 int fd;
56
57 /* Create input mailbox */
58 if (mu_tempfile (NULL, 0, &fd, &temp_filename))
59 exit (1);
60
61 temp_file = fdopen (fd, "w");
62 if (!temp_file)
63 {
64 util_error ("fdopen: %s", strerror (errno));
65 close (fd);
66 exit (1);
67 }
68 }
69
70 /* Append contents of file `name' to the temporary file */
71 int
72 collect_append_file (char *name)
73 {
74 char *buf = NULL;
75 size_t n = 0;
76 FILE *fp;
77
78 if (strcmp (name, "-") == 0)
79 fp = stdin;
80 else
81 {
82 fp = fopen (name, "r");
83 if (!fp)
84 {
85 util_error (_("cannot open input file %s: %s"), name, strerror (errno));
86 return -1;
87 }
88 }
89
90 /* Copy the contents of the file */
91 while (getline (&buf, &n, fp) > 0)
92 fprintf (temp_file, "%s", buf);
93
94 free (buf);
95 fclose (fp);
96 return 0;
97 }
98
99 /* Close the temporary, and reopen it as a mailbox. */
100 void
101 collect_create_mailbox ()
102 {
103 size_t nmesg;
104
105 if (!temp_file)
106 return;
107
108 fclose (temp_file);
109
110 if (mu_mailbox_create (&mbox, temp_filename) != 0
111 || mu_mailbox_open (mbox, MU_STREAM_READ) != 0)
112 {
113 util_error (_("cannot create temp mailbox %s: %s"),
114 temp_filename, strerror (errno));
115 unlink (temp_filename);
116 exit (1);
117 }
118
119 /* Suck in the messages */
120 mu_mailbox_messages_count (mbox, &nmesg);
121
122 if (nmesg == 0)
123 {
124 util_error (_("input format not recognized"));
125 exit (1);
126 }
127 }
128
129 int
130 collect_output ()
131 {
132 size_t i, count = 0;
133 mu_mailbox_t outbox = NULL;
134 int saved_umask;
135
136 if (!temp_filename)
137 {
138 mu_mailbox_expunge (mbox);
139 return 0;
140 }
141
142 if (user_name)
143 saved_umask = umask (077);
144
145 if (mu_mailbox_create_default (&outbox, default_mailbox) != 0
146 || mu_mailbox_open (outbox, MU_STREAM_RDWR|MU_STREAM_CREAT) != 0)
147 {
148 mu_mailbox_destroy (&outbox);
149 mu_error (_("cannot open output mailbox %s: %s"),
150 default_mailbox, strerror (errno));
151 return 1;
152 }
153
154 mu_mailbox_messages_count (mbox, &count);
155 for (i = 1; i <= count; i++)
156 {
157 mu_message_t msg = NULL;
158 mu_attribute_t attr = NULL;
159
160 mu_mailbox_get_message (mbox, i, &msg);
161 mu_message_get_attribute (msg, &attr);
162 if (!mu_attribute_is_deleted (attr))
163 {
164 mu_attribute_set_recent (attr);
165 mu_mailbox_append_message (outbox, msg);
166 }
167 }
168
169 mu_mailbox_close (outbox);
170 mu_mailbox_destroy (&outbox);
171
172 if (user_name)
173 umask (saved_umask);
174 return 0;
175 }
176
177
178 /* Close the temporary mailbox and unlink the file associated with it */
179 void
180 collect_drop_mailbox ()
181 {
182 mu_mailbox_close (mbox);
183 mu_mailbox_destroy (&mbox);
184 if (temp_filename)
185 {
186 unlink (temp_filename);
187 free (temp_filename);
188 }
189 }
190
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
3 Software Foundation, Inc.
4
5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GNU Mailutils is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
17
18 #if defined(HAVE_CONFIG_H)
19 # include <config.h>
20 #endif
21 #include <sys/types.h>
22 #include <sys/stat.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <unistd.h>
26 #include <errno.h>
27 #include <string.h> /* strerror(3), strdup(3) */
28
29 #include <mailutils/errno.h>
30 #include <mailutils/mailbox.h>
31 #include <mailutils/message.h>
32 #include <mailutils/header.h>
33 #include <mailutils/body.h>
34 #include <mailutils/registrar.h>
35 #include <mailutils/error.h>
36 #include <mailutils/address.h>
37 #include <mailutils/registrar.h>
38 #include <mailutils/stream.h>
39 #include <mailutils/guile.h>
40 #include <mailutils/nls.h>
41 #include <mailutils/list.h>
42 #include <mailutils/util.h>
43 #include <mailutils/attribute.h>
44 #include <mailutils/envelope.h>
45 #include <mailutils/io.h>
46
47 extern char *program_file;
48 extern char *program_expr;
49 extern char *user_name;
50 extern char *default_mailbox;
51 extern mu_mailbox_t mbox;
52 extern size_t nmesg;
53 extern size_t current_mesg_no;
54 extern mu_message_t current_message;
55 extern int debug_guile;
56 extern char *maildir;
57
58 void collect_open_default (void);
59 void collect_open_mailbox_file (void);
60 int collect_append_file (char *name);
61 void collect_create_mailbox (void);
62 void collect_drop_mailbox (void);
63 int collect_output (void);
64
65 void util_error (const char *fmt, ...) MU_PRINTFLIKE(1, 2);
66 int util_tempfile (char **namep);
67
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
3 2009, 2010 Free Software Foundation, Inc.
4
5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GNU Mailutils is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include "guimb.h"
19 #include "mailutils/libargp.h"
20
21 char *program_file;
22 char *program_expr;
23 int debug_guile;
24 char *user_name;
25 char *default_mailbox;
26
27 char * who_am_i ();
28
29 static int g_size;
30 static int g_argc;
31 static char **g_argv;
32
33 #define ARG_INC 16
34
35 void
36 append_arg (char *arg)
37 {
38 if (g_argc == g_size)
39 {
40 g_size += ARG_INC;
41 g_argv = realloc (g_argv, g_size * sizeof (g_argv[0]));
42 if (!g_argv)
43 {
44 util_error (_("not enough memory"));
45 exit (1);
46 }
47 }
48 g_argv[g_argc++] = arg;
49 }
50
51 static struct argp_option options[] = {
52 {NULL, 0, NULL, 0,
53 /* TRANSLATORS: (command-line) is the name of Guile function. Do not
54 translate it.
55 */
56 N_("The following switches stop argument processing, and pass all\n"
57 "remaining arguments as the value of (command-line):"), 1},
58 {"code", 'c', N_("EXPR"), 0, N_("execute given scheme expression"), 1},
59 {"source", 's', N_("PROGFILE"), 0,
60 N_("load Scheme source code from PROGFILE and exit"), 1},
61 {NULL, 0, NULL, 0,
62 N_("The following options do not change the order of options parsing:"), 2},
63 {"expression", 'e', N_("EXPR"), 0, N_("execute given scheme expression"), 2},
64 {"file", 'f', N_("PROGFILE"), 0,
65 N_("load Scheme source code from PROGFILE and exit"), 2},
66 {NULL, 0, NULL, 0, N_("Other options:"), 3},
67 {"debug", 'd', NULL, 0, N_("start with debugging evaluator and backtraces"), 3},
68 {"guile-arg", 'g', N_("ARG"), 0,
69 N_("append ARG to the command line passed to Guile"), 3},
70 {"mailbox", 'M', N_("NAME"), 0, N_("set default mailbox name"), 3},
71 {"user", 'u', N_("NAME"), OPTION_ARG_OPTIONAL,
72 N_("act as local MDA for user NAME"), 3},
73 {0, 0, 0, 0}
74 };
75
76 static error_t
77 parse_opt (int key, char *arg, struct argp_state *state)
78 {
79 switch (key)
80 {
81 case 'c':
82 program_expr = arg;
83 *(int *)state->input = state->next;
84 state->next = state->argc;
85 break;
86
87 case 's':
88 program_file = arg;
89 *(int *)state->input = state->next;
90 state->next = state->argc;
91 break;
92
93 case 'f':
94 program_file = arg;
95 break;
96
97 case 'e':
98 program_expr = arg;
99 break;
100
101 case 'd':
102 debug_guile = 1;
103 break;
104
105 case 'g':
106 append_arg (arg);
107 break;
108
109 case 'M':
110 default_mailbox = arg;
111 break;
112
113 case 'u':
114 user_name = arg ? arg : who_am_i ();
115 break;
116
117 default:
118 return ARGP_ERR_UNKNOWN;
119 }
120 return 0;
121 }
122
123 static char doc[] =
124 N_("GNU guimb -- process contents of the specified mailboxes "
125 "using a Scheme program or expression.");
126 static char args_doc[] = N_("[mailbox...]");
127
128 static struct argp argp = {
129 options,
130 parse_opt,
131 args_doc,
132 doc,
133 NULL,
134 NULL, NULL
135 };
136
137 static const char *guimb_argp_capa[] = {
138 "common",
139 "debug",
140 "mailbox",
141 "locking",
142 NULL
143 };
144
145 char *main_sym = "mailutils-main";
146
147 int
148 main (int argc, char *argv[])
149 {
150 int rc;
151 int c = argc;
152 int index;
153
154 /* Native Language Support */
155 MU_APP_INIT_NLS ();
156
157 /* Register the desired formats. */
158 mu_register_all_formats ();
159
160 mu_argp_init (NULL, NULL);
161 if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
162 exit (1);
163
164 for (; c < argc; c++)
165 append_arg (argv[c]);
166
167 if (!user_name)
168 user_name = who_am_i ();
169
170 if (!program_file && !program_expr)
171 {
172 mu_error (_("At least one of -fecs must be used. Try guimb --help for more info."));
173 exit (1);
174 }
175
176 if (!argv[index])
177 {
178 if (default_mailbox)
179 append_arg (default_mailbox);
180 collect_open_default ();
181 }
182 else
183 {
184 collect_open_mailbox_file ();
185
186 if (argv[index])
187 {
188 for (; argv[index]; index++)
189 {
190 append_arg (argv[index]);
191 collect_append_file (argv[index]);
192 }
193 }
194 else
195 collect_append_file ("-");
196 }
197
198 /* Finish creating input mailbox */
199 collect_create_mailbox ();
200
201 mu_guile_init (debug_guile);
202 if (program_file)
203 mu_guile_load (program_file, g_argc, g_argv);
204 if (program_expr)
205 mu_guile_eval (program_expr);
206
207 rc = mu_guile_mailbox_apply (mbox, main_sym);
208 switch (rc)
209 {
210 case 0:
211 collect_output ();
212 break;
213
214 case MU_ERR_NOENT:
215 mu_error (_("%s not defined"), main_sym);
216 break;
217
218 case EINVAL:
219 mu_error (_("%s is not a procedure object"), main_sym);
220 break;
221
222 case MU_ERR_FAILURE:
223 mu_error (_("execution of %s failed"), main_sym);
224 break;
225
226 default:
227 mu_error (_("unrecognized error"));
228 break;
229 }
230
231 collect_drop_mailbox ();
232
233 return !!rc;
234 }
235
236 char *
237 who_am_i ()
238 {
239 char *name = getenv ("LOGNAME");
240 if (!name)
241 {
242 name = getenv ("USER");
243 if (!name)
244 name = strdup (getlogin ());
245 }
246 return name;
247 }
248
1 /* GNU Mailutils -- a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001, 2002, 2005, 2007, 2009, 2010 Free
3 Software Foundation, Inc.
4
5 GNU Mailutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
8 any later version.
9
10 GNU Mailutils is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include "guimb.h"
19
20 void
21 util_error (const char *fmt, ...)
22 {
23 va_list ap;
24
25 va_start (ap, fmt);
26 fprintf (stderr, "guimb: ");
27 vfprintf (stderr, fmt, ap);
28 fprintf (stderr, "\n");
29 va_end (ap);
30 }
31
32 char *
33 util_get_sender (int msgno)
34 {
35 mu_header_t header = NULL;
36 mu_address_t addr = NULL;
37 mu_message_t msg = NULL;
38 const char *buffer;
39 char *email;
40
41 mu_mailbox_get_message (mbox, msgno, &msg);
42 mu_message_get_header (msg, &header);
43 if (mu_header_sget_value (header, MU_HEADER_FROM, &buffer)
44 || mu_address_create (&addr, buffer))
45 {
46 mu_envelope_t env = NULL;
47 mu_message_get_envelope (msg, &env);
48
49 if (mu_envelope_sget_sender (env, &buffer)
50 || mu_address_create (&addr, buffer))
51 {
52 util_error (_("cannot determine sender name (msg %d)"), msgno);
53 return NULL;
54 }
55 }
56
57 if (mu_address_aget_email (addr, 1, &email))
58 {
59 util_error (_("cannot determine sender name (msg %d)"), msgno);
60 mu_address_destroy (&addr);
61 return NULL;
62 }
63
64 mu_address_destroy (&addr);
65 return email;
66 }
67
...@@ -13,10 +13,6 @@ frm/common.c ...@@ -13,10 +13,6 @@ frm/common.c
13 frm/frm.c 13 frm/frm.c
14 frm/from.c 14 frm/from.c
15 15
16 guimb/collect.c
17 guimb/main.c
18 guimb/util.c
19
20 imap4d/auth_gsasl.c 16 imap4d/auth_gsasl.c
21 imap4d/auth_gss.c 17 imap4d/auth_gss.c
22 imap4d/bye.c 18 imap4d/bye.c
......
...@@ -15,19 +15,19 @@ ...@@ -15,19 +15,19 @@
15 ## You should have received a copy of the GNU General Public License 15 ## You should have received a copy of the GNU General Public License
16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. 16 ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>.
17 17
18 MU_GUILE_SIEVE_SCRIPTS_X=sieve.scm 18 bin_SCRIPTS = sieve2scm
19 bin_SCRIPTS = sieve.scm 19 EXTRA_SCRIPTS=sieve2scm
20 EXTRA_SCRIPTS=sieve.scm 20 # FIXME: Sieve2scm is temporarly exempted from installchecks because
21 # FIXME: Sieve.scm is temporarly exempted from installchecks because
22 # it may fail starting during checks, if libguile-mailutils-v- library 21 # it may fail starting during checks, if libguile-mailutils-v- library
23 # has not been previously installed. The proper fix would be to alter 22 # has not been previously installed. The proper fix would be to alter
24 # %load-path during tests. 23 # %load-path during tests.
25 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=sieve.scm 24 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT=sieve2scm
26 25
27 sievemoddir=@MU_GUILE_SIEVE_MOD_DIR@ 26 sievemoddir=@MU_GUILE_SIEVE_MOD_DIR@
28 27
29 sieve.scm: sieve.scm.in sieve.sed 28 sieve2scm: sieve2scm.scmi sieve.sed
30 $(AM_V_GEN)sed -f sieve.sed $(srcdir)/sieve.scm.in > sieve.scm 29 $(AM_V_GEN)sed -f sieve.sed $(srcdir)/sieve2scm.scmi > sieve2scm
30 $(AM_V_at)chmod +w sieve2scm
31 31
32 sieve.sed: Makefile 32 sieve.sed: Makefile
33 $(AM_V_GEN)echo 's,%GUILE_BINDIR%,@GUILE_BINDIR@,g' > sieve.sed 33 $(AM_V_GEN)echo 's,%GUILE_BINDIR%,@GUILE_BINDIR@,g' > sieve.sed
...@@ -37,26 +37,20 @@ sieve.sed: Makefile ...@@ -37,26 +37,20 @@ sieve.sed: Makefile
37 $(AM_V_at)echo 's,%PACKAGE%,$(PACKAGE),g' >> sieve.sed 37 $(AM_V_at)echo 's,%PACKAGE%,$(PACKAGE),g' >> sieve.sed
38 $(AM_V_at)echo 's,%VERSION%,$(VERSION),g' >> sieve.sed 38 $(AM_V_at)echo 's,%VERSION%,$(VERSION),g' >> sieve.sed
39 39
40 CLEANFILES = sieve.scm sieve.sed 40 CLEANFILES = sieve2scm sieve.sed
41 41
42 sitedir=@GUILE_SITE@/$(PACKAGE) 42 sitedir=@GUILE_SITE@/$(PACKAGE)
43 site_DATA=sieve-core.scm 43 site_DATA=sieve-core.scm
44 44
45 MU_GUILE_SIEVE_MOD_DATA_X=\ 45 sievemod_DATA=\
46 mimeheader.scm\ 46 mimeheader.scm\
47 numaddr.scm\ 47 numaddr.scm\
48 redirect.scm\ 48 redirect.scm\
49 reject.scm\ 49 reject.scm\
50 vacation.scm 50 vacation.scm
51 51
52 sievemod_DATA=@MU_GUILE_SIEVE_MOD_DATA@
53
54 EXTRA_DIST=\ 52 EXTRA_DIST=\
55 mimeheader.scm\ 53 $(sievemod_DATA)\
56 numaddr.scm\
57 redirect.scm\
58 reject.scm\
59 sieve-core.scm\ 54 sieve-core.scm\
60 sieve.scm.in\ 55 sieve2scm.scmi
61 vacation.scm
62 56
......
...@@ -449,13 +449,6 @@ ...@@ -449,13 +449,6 @@
449 (if (isatty? (current-error-port)) 449 (if (isatty? (current-error-port))
450 (display (string-append level ": " msg "\n") (current-error-port))))) 450 (display (string-append level ": " msg "\n") (current-error-port)))))
451 451
452 (define (guimb?)
453 (catch #t
454 (lambda ()
455 (let ((v current-mailbox))
456 v))
457 (lambda args #f)))
458
459 ;;; Sieve-main 452 ;;; Sieve-main
460 (define-public sieve-mailbox #f) 453 (define-public sieve-mailbox #f)
461 (define-public sieve-current-message #f) 454 (define-public sieve-current-message #f)
...@@ -490,20 +483,14 @@ ...@@ -490,20 +483,14 @@
490 483
491 (define-public (sieve-main thunk) 484 (define-public (sieve-main thunk)
492 (handle-exception 485 (handle-exception
493 (cond 486 (let* ((cl (sieve-command-line))
494 ((not (guimb?)) 487 (name (if (and (not (null? (cdr cl)))
495 (let* ((cl (sieve-command-line)) 488 (string? (cadr cl)))
496 (name (if (and (not (null? (cdr cl))) 489 (cadr cl)
497 (string? (cadr cl))) 490 (mu-user-mailbox-url
498 (cadr cl) 491 (passwd:name (mu-getpwuid (getuid)))))))
499 (mu-user-mailbox-url 492
500 (passwd:name (mu-getpwuid (getuid))))))) 493 (set! sieve-mailbox (mu-mailbox-open name "rw"))
501 494 (sieve-run thunk)
502 (set! sieve-mailbox (mu-mailbox-open name "rw")) 495 (mu-mailbox-expunge sieve-mailbox)
503 (sieve-run thunk) 496 (mu-mailbox-close sieve-mailbox))))
504 (mu-mailbox-expunge sieve-mailbox)
505 (mu-mailbox-close sieve-mailbox)))
506 (else
507 (set! sieve-mailbox current-mailbox)
508 (sieve-run thunk)))))
509
......
...@@ -23,14 +23,12 @@ ...@@ -23,14 +23,12 @@
23 ;;;; 23 ;;;;
24 ;;;; To convert a sieve script into equivalent Scheme program, run: 24 ;;;; To convert a sieve script into equivalent Scheme program, run:
25 ;;;; 25 ;;;;
26 ;;;; guile -s sieve.scm --file <sieve-script-name> --output <output-file-name> 26 ;;;; guile -s sieve2scm.scm --file <sieve-script-name> --output <output-file-name>
27 ;;;; 27 ;;;;
28 ;;;; To compile and execute a sieve script upon a mailbox, run: 28 ;;;; To compile and execute a sieve script upon a mailbox, run:
29 ;;;; 29 ;;;;
30 ;;;; guile -s sieve.scm --file <sieve-script-name> [mailbox-name] 30 ;;;; guile -s sieve2scm.scm --file <sieve-script-name> [mailbox-name]
31 ;;;; or 31 ;;;;
32 ;;;; guimb [--mailbox mailbox-name] -s sieve.scm --file <sieve-script-name>
33
34 (if (not (member "%GUILE_SITE%" %load-path)) 32 (if (not (member "%GUILE_SITE%" %load-path))
35 (set! %load-path (cons "%GUILE_SITE%" %load-path))) 33 (set! %load-path (cons "%GUILE_SITE%" %load-path)))
36 (use-modules (ice-9 getopt-long) 34 (use-modules (ice-9 getopt-long)
...@@ -926,18 +924,14 @@ ...@@ -926,18 +924,14 @@
926 924
927 ;;; Save the program 925 ;;; Save the program
928 926
929 (define (sieve-save-program outfile guimb-header) 927 (define (sieve-save-program outfile)
930 (with-output-to-file 928 (with-output-to-file
931 outfile 929 outfile
932 (lambda () 930 (lambda ()
933 (display "#! ") 931 (display "#! ")
934 (cond 932 (display "/bin/sh\n\
935 (guimb-header
936 (display "/home/gray/alpha/bin/guimb -s\n"))
937 (else
938 (display "/bin/sh\n\
939 # aside from this initial boilerplate, this is actually -*- scheme -*- code\n\ 933 # aside from this initial boilerplate, this is actually -*- scheme -*- code\n\
940 exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n"))) 934 exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")
941 (display (string-append 935 (display (string-append
942 "# This Guile mailbox parser was made from " filename)) 936 "# This Guile mailbox parser was made from " filename))
943 (newline) 937 (newline)
...@@ -985,16 +979,14 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n"))) ...@@ -985,16 +979,14 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
985 979
986 (define filename #f) 980 (define filename #f)
987 (define output #f) 981 (define output #f)
988 (define guimb-header #f)
989 982
990 (define (sieve-usage) 983 (define (sieve-usage)
991 (display "usage: sieve.scm [OPTIONS][mailbox]\n") 984 (display "usage: sieve2scm [OPTIONS][mailbox]\n")
992 (display "GNU sieve.scm -- compile a Sieve program into Scheme code\n") 985 (display "GNU sieve2scm -- compile a Sieve program into Scheme code\n")
993 (display "Options are:\n") 986 (display "Options are:\n")
994 (display " -f, --file FILENAME Set input file name\n") 987 (display " -f, --file FILENAME Set input file name\n")
995 (display " -o, --output FILENAME Set output file name\n") 988 (display " -o, --output FILENAME Set output file name\n")
996 (display " -L, --lib-dir DIRNAME Set sieve library directory name\n") 989 (display " -L, --lib-dir DIRNAME Set sieve library directory name\n")
997 (display " -g, --guimb Make output file executable for guimb\n")
998 (display " -d, --debug LEVEL Set debugging level\n") 990 (display " -d, --debug LEVEL Set debugging level\n")
999 (display " --version Show program version\n\n") 991 (display " --version Show program version\n\n")
1000 (display "If -o option is not given, the compiled program is executed\n") 992 (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"))) ...@@ -1018,7 +1010,6 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
1018 (value #t)) 1010 (value #t))
1019 (lib-dir (single-char #\L) 1011 (lib-dir (single-char #\L)
1020 (value #t)) 1012 (value #t))
1021 (guimb (single-char #\g))
1022 (version) 1013 (version)
1023 (verbose (single-char #\v)) 1014 (verbose (single-char #\v))
1024 (help (single-char #\h)))) 1015 (help (single-char #\h))))
...@@ -1038,8 +1029,6 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n"))) ...@@ -1038,8 +1029,6 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
1038 (set! sieve-libdir (cdr x))) 1029 (set! sieve-libdir (cdr x)))
1039 ((output) 1030 ((output)
1040 (set! output (cdr x))) 1031 (set! output (cdr x)))
1041 ((guimb)
1042 (set! guimb-header #t))
1043 ((version) 1032 ((version)
1044 (sieve-version)) 1033 (sieve-version))
1045 ((verbose) 1034 ((verbose)
...@@ -1083,11 +1072,11 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n"))) ...@@ -1083,11 +1072,11 @@ exec ${GUILE-guile} -l $0 -c '(mailutils-main)'\n")))
1083 (newline) 1072 (newline)
1084 (exit 1)) 1073 (exit 1))
1085 (output 1074 (output
1086 (sieve-save-program output guimb-header)) 1075 (sieve-save-program output))
1087 (else 1076 (else
1088 (let ((temp-file (tmpnam)) 1077 (let ((temp-file (tmpnam))
1089 (saved-umask (umask #o077))) 1078 (saved-umask (umask #o077)))
1090 (sieve-save-program temp-file guimb-header) 1079 (sieve-save-program temp-file)
1091 (catch #t 1080 (catch #t
1092 (lambda () 1081 (lambda ()
1093 (set-cdr! (command-line) sieve-script-args) 1082 (set-cdr! (command-line) sieve-script-args)
......