summaryrefslogtreecommitdiff
path: root/libmu_scm
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2002-09-12 09:55:03 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2002-09-12 09:55:03 +0000
commit011de7c8220790db66632e091e893cee4fc6aa2f (patch)
tree28641c26821f01cecb56eba6530caee498218691 /libmu_scm
parentc7963338dddac353d1d97c0ae2990fa86dfb6ad7 (diff)
downloadmailutils-011de7c8220790db66632e091e893cee4fc6aa2f.tar.gz
mailutils-011de7c8220790db66632e091e893cee4fc6aa2f.tar.bz2
(mu-register-format): New primitive. Registers desired mailbox/mailer formats.
(mu_scm_init): Unconditionally register path_record format.
Diffstat (limited to 'libmu_scm')
-rw-r--r--libmu_scm/mu_scm.c104
1 files changed, 97 insertions, 7 deletions
diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c
index ab69623bb..a5767a0de 100644
--- a/libmu_scm/mu_scm.c
+++ b/libmu_scm/mu_scm.c
@@ -16,6 +16,7 @@
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17 17
18#include "mu_scm.h" 18#include "mu_scm.h"
19#include <mailutils/registrar.h>
19 20
20#ifndef _PATH_SENDMAIL 21#ifndef _PATH_SENDMAIL
21# define _PATH_SENDMAIL "/usr/lib/sendmail" 22# define _PATH_SENDMAIL "/usr/lib/sendmail"
@@ -43,19 +44,104 @@ scm_makenum (unsigned long val)
43void 44void
44mu_set_variable (const char *name, SCM value) 45mu_set_variable (const char *name, SCM value)
45{ 46{
46#if GUILE_VERSION == 14
47 scm_c_define (name, value); /*FIXME*/
48#else
49 scm_c_define (name, value); 47 scm_c_define (name, value);
50#endif
51} 48}
52 49
53
54SCM _mu_scm_package; /* STRING: PACKAGE */ 50SCM _mu_scm_package; /* STRING: PACKAGE */
55SCM _mu_scm_version; /* STRING: VERSION */ 51SCM _mu_scm_version; /* STRING: VERSION */
56SCM _mu_scm_mailer; /* STRING: Default mailer path. */ 52SCM _mu_scm_mailer; /* STRING: Default mailer path. */
57SCM _mu_scm_debug; /* NUM: Default debug level. */ 53SCM _mu_scm_debug; /* NUM: Default debug level. */
58 54
55struct format_record {
56 char *name;
57 record_t *record;
58};
59
60static struct format_record format_table[] = {
61 { "mbox", &mbox_record },
62 { "mh", &mh_record },
63 { "pop", &pop_record },
64 { "imap", &imap_record },
65 { "sendmail", &sendmail_record },
66 { "smtp", &smtp_record },
67 { NULL, NULL },
68};
69
70static record_t *
71find_format (const struct format_record *table, const char *name)
72{
73 for (; table->name; table++)
74 if (strcmp (table->name, name) == 0)
75 break;
76 return table->record;
77}
78
79static int
80register_format (const char *name)
81{
82 int status = 0;
83 list_t reglist = NULL;
84
85 status = registrar_get_list (&reglist);
86 if (status)
87 return status;
88
89 if (!name)
90 {
91 struct format_record *table;
92 for (table = format_table; table->name; table++)
93 list_append (reglist, *table->record);
94 status = 0;
95 }
96 else
97 {
98 record_t *record = find_format (format_table, name);
99 if (record)
100 status = list_append (reglist, *record);
101 else
102 status = EINVAL;
103 }
104 return status;
105}
106
107
108SCM_DEFINE (mu_register_format, "mu-register-format", 0, 0, 1,
109 (SCM REST),
110"Registers desired mailutils formats. Takes any number of arguments.\n"
111"Allowed arguments are:\n"
112" \"mbox\" Regular UNIX mbox format\n"
113" \"mh\" MH mailbox format\n"
114" \"pop\" POP mailbox format\n"
115" \"imap\" IMAP mailbox format\n"
116" \"sendmail\" sendmail mailer\n"
117" \"smtp\" smtp mailer\n"
118"\n"
119"If called without arguments, registers all available formats\n")
120#define FUNC_NAME s_mu_register_format
121{
122 SCM status;
123
124 if (REST == SCM_EOL)
125 {
126 register_format (NULL);
127 status = SCM_BOOL_T;
128 }
129 else
130 {
131 status = SCM_BOOL_T;
132 for (; REST != SCM_EOL; REST = SCM_CDR (REST))
133 {
134 SCM scm = SCM_CAR (REST);
135 SCM_ASSERT (SCM_NIMP (scm) && SCM_STRINGP (scm),
136 scm, SCM_ARGn, FUNC_NAME);
137 if (register_format (SCM_STRING_CHARS (scm)))
138 status = SCM_BOOL_F;
139 }
140 }
141 return status;
142}
143#undef FUNC_NAME
144
59static struct 145static struct
60{ 146{
61 char *name; 147 char *name;
@@ -71,7 +157,6 @@ static struct
71 { "MU-ATTRIBUTE-RECENT", MU_ATTRIBUTE_RECENT }, 157 { "MU-ATTRIBUTE-RECENT", MU_ATTRIBUTE_RECENT },
72 { NULL, 0 } 158 { NULL, 0 }
73}; 159};
74
75 160
76/* Initialize the library */ 161/* Initialize the library */
77void 162void
@@ -79,7 +164,8 @@ mu_scm_init ()
79{ 164{
80 char *defmailer; 165 char *defmailer;
81 int i; 166 int i;
82 167 list_t lst;
168
83 asprintf (&defmailer, "sendmail:%s", _PATH_SENDMAIL); 169 asprintf (&defmailer, "sendmail:%s", _PATH_SENDMAIL);
84 _mu_scm_mailer = scm_makfrom0str (defmailer); 170 _mu_scm_mailer = scm_makfrom0str (defmailer);
85 mu_set_variable ("mu-mailer", _mu_scm_mailer); 171 mu_set_variable ("mu-mailer", _mu_scm_mailer);
@@ -105,4 +191,8 @@ mu_scm_init ()
105 mu_scm_logger_init (); 191 mu_scm_logger_init ();
106 mu_scm_port_init (); 192 mu_scm_port_init ();
107 mu_scm_mime_init (); 193 mu_scm_mime_init ();
194#include "mu_scm.x"
195
196 registrar_get_list (&lst);
197 list_append (lst, path_record);
108} 198}

Return to:

Send suggestions and report system problems to the System administrator.