summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auth/sql.c2
-rw-r--r--comsat/Makefile.am5
-rw-r--r--comsat/cfg.c17
-rw-r--r--comsat/comsat.c140
-rw-r--r--include/mailutils/stream.h4
-rw-r--r--libproto/mbox/folder.c2
-rw-r--r--libproto/mbox/mbox.c143
-rw-r--r--libproto/mbox/mbox0.h3
-rw-r--r--libproto/mbox/mboxscan.c406
-rw-r--r--libsieve/load.c11
-rw-r--r--mail.local/main.c4
-rw-r--r--mailbox/amd.c23
-rw-r--r--mailbox/errors3
-rw-r--r--mailbox/file_stream.c59
-rw-r--r--mailbox/mailbox.c32
15 files changed, 428 insertions, 426 deletions
diff --git a/auth/sql.c b/auth/sql.c
index d91999b5e..81588e608 100644
--- a/auth/sql.c
+++ b/auth/sql.c
@@ -417,7 +417,7 @@ get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory)
{
mu_error (_("SQL field `%s' (`%s') has NULL value"),
id, name ? *name : id);
- rc = MU_READ_ERROR;
+ rc = MU_ERR_READ;
}
return rc;
diff --git a/comsat/Makefile.am b/comsat/Makefile.am
index ac2d4435d..be0eb38b3 100644
--- a/comsat/Makefile.am
+++ b/comsat/Makefile.am
@@ -26,6 +26,11 @@ comsatd_SOURCES = action.c cfg.c comsat.c comsat.h
comsatd_LDADD = \
../lib/libmuaux.la\
${MU_LIB_MBOX}\
+ ${MU_LIB_IMAP}\
+ ${MU_LIB_POP}\
+ ${MU_LIB_NNTP}\
+ ${MU_LIB_MH}\
+ ${MU_LIB_MAILDIR}\
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
diff --git a/comsat/cfg.c b/comsat/cfg.c
index a126c4fcd..2f4f38170 100644
--- a/comsat/cfg.c
+++ b/comsat/cfg.c
@@ -110,7 +110,7 @@ netdef_parse (char *str)
netdef = malloc (sizeof *netdef);
if (!netdef)
{
- syslog (LOG_ERR, _("Out of memory"));
+ mu_error (_("Out of memory"));
exit (1);
}
@@ -135,7 +135,8 @@ read_config (const char *config_file)
fp = fopen (config_file, "r");
if (!fp)
{
- syslog (LOG_ERR, _("Cannot open config file %s: %m"), config_file);
+ mu_error (_("Cannot open config file %s: %s"), config_file,
+ mu_strerror (errno));
return;
}
@@ -162,7 +163,7 @@ read_config (const char *config_file)
mu_argcv_get (ptr, "", NULL, &argc, &argv);
if (argc < 2)
{
- syslog (LOG_ERR, _("%s:%d: too few fields"), config_file, line);
+ mu_error (_("%s:%d: too few fields"), config_file, line);
mu_argcv_free (argc, argv);
continue;
}
@@ -174,7 +175,7 @@ read_config (const char *config_file)
else if (strcmp (argv[1], "no") == 0)
allow_biffrc = 0;
else
- syslog (LOG_ERR, _("%s:%d: yes or no expected"), config_file, line);
+ mu_error (_("%s:%d: yes or no expected"), config_file, line);
}
else if (strcmp (argv[0], "max-requests") == 0)
maxrequests = strtoul (argv[1], NULL, 0);
@@ -194,7 +195,7 @@ read_config (const char *config_file)
action = ACT_DENY;
else
{
- syslog (LOG_ERR, _("%s:%d: unknown keyword"), config_file, line);
+ mu_error (_("%s:%d: unknown keyword"), config_file, line);
mu_argcv_free (argc, argv);
continue;
}
@@ -205,8 +206,8 @@ read_config (const char *config_file)
netdef_t *cur = netdef_parse (argv[i]);
if (!cur)
{
- syslog (LOG_ERR, _("%s:%d: cannot parse netdef: %s"),
- config_file, line, argv[i]);
+ mu_error (_("%s:%d: cannot parse netdef: %s"),
+ config_file, line, argv[i]);
continue;
}
if (!tail)
@@ -221,7 +222,7 @@ read_config (const char *config_file)
acl = malloc (sizeof *acl);
if (!acl)
{
- syslog (LOG_CRIT, _("Out of memory"));
+ mu_error (_("Out of memory"));
exit (1);
}
acl->next = NULL;
diff --git a/comsat/comsat.c b/comsat/comsat.c
index f1a02f4bb..43bb5e91f 100644
--- a/comsat/comsat.c
+++ b/comsat/comsat.c
@@ -57,7 +57,8 @@ static char doc[] = "GNU comsatd";
static struct argp_option options[] =
{
- {"config", 'c', N_("FILE"), 0, N_("Read configuration from FILE"), 0},
+ { "config", 'c', N_("FILE"), 0, N_("Read configuration from FILE"), 0 },
+ { "test", 't', NULL, 0, N_("Run in test mode"), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
@@ -104,7 +105,8 @@ static void comsat_init (void);
static void comsat_daemon_init (void);
static void comsat_daemon (int _port);
static int comsat_main (int fd);
-static void notify_user (const char *user, const char *device, const char *path, off_t offset);
+static void notify_user (const char *user, const char *device,
+ const char *path, mu_message_qid_t qid);
static int find_user (const char *name, char *tty);
static char *mailbox_path (const char *user);
static void change_user (const char *user);
@@ -112,6 +114,7 @@ static void change_user (const char *user);
static int xargc;
static char **xargv;
char *config_file = NULL;
+int test_mode;
static error_t
comsatd_parse_opt (int key, char *arg, struct argp_state *state)
@@ -125,6 +128,10 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state)
case 'c':
config_file = arg;
break;
+
+ case 't':
+ test_mode = 1;
+ break;
default:
return ARGP_ERR_UNKNOWN;
@@ -134,20 +141,59 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state)
int
-main(int argc, char **argv)
+main (int argc, char **argv)
{
int c;
-
+ int ind;
+
/* Native Language Support */
mu_init_nls ();
mu_argp_init (program_version, NULL);
mu_argp_parse (&argp, &argc, &argv, 0, comsat_argp_capa,
- NULL, &daemon_param);
+ &ind, &daemon_param);
+ argc -= ind;
+ argv += ind;
+
+ if (test_mode)
+ {
+ char *user, *url, *qid;
+
+ comsat_init ();
+ if (config_file)
+ read_config (config_file);
+ if (argc == 0)
+ exit (0);
+ if (argc < 2 || argc > 2)
+ {
+ mu_error (_("Mailbox URL and message QID are required in test mode"));
+ exit (EXIT_FAILURE);
+ }
+
+ user = getenv ("LOGNAME");
+ if (!user)
+ {
+ user = getenv ("USER");
+ if (!user)
+ {
+ struct passwd *pw = getpwuid (getuid ());
+ if (!pw)
+ {
+ mu_error (_("Cannot determine user name"));
+ exit (EXIT_FAILURE);
+ }
+ user = pw->pw_name;
+ }
+ }
+
+ notify_user (user, "/dev/tty", argv[0], argv[1]);
+ exit (0);
+ }
+
if (daemon_param.timeout > 0 && daemon_param.mode == MODE_DAEMON)
{
- fprintf (stderr, _("--timeout and --daemon are incompatible\n"));
+ mu_error (_("--timeout and --daemon are incompatible"));
exit (EXIT_FAILURE);
}
@@ -194,7 +240,8 @@ sig_hup (int sig)
void
comsat_init ()
{
- mu_registrar_record (mu_path_record);
+ /* Register mailbox formats */
+ mu_register_all_mbox_formats ();
gethostname (hostname, sizeof hostname);
@@ -324,10 +371,10 @@ comsat_main (int fd)
char buffer[216]; /*FIXME: Arbitrary size */
pid_t pid;
char tty[MAX_TTY_SIZE];
- char *p, *endp;
- size_t offset;
+ char *p;
char *path = NULL;
-
+ mu_message_qid_t qid;
+
len = sizeof sin_from;
rdlen = recvfrom (fd, buffer, sizeof buffer, 0,
(struct sockaddr*)&sin_from, &len);
@@ -362,19 +409,8 @@ comsat_main (int fd)
}
*p++ = 0;
- offset = strtoul (p, &endp, 0);
- switch (*endp)
- {
- case 0:
- break;
- case ':':
- path = endp+1;
- break;
- default:
- if (!isspace (*endp))
- syslog (LOG_ERR, _("Malformed input: %s@%s (near %s)"), buffer, p, endp);
- }
-
+ qid = p;
+
if (find_user (buffer, tty) != SUCCESS)
return 0;
@@ -400,7 +436,7 @@ comsat_main (int fd)
}
/* Child: do actual I/O */
- notify_user (buffer, tty, path, offset);
+ notify_user (buffer, tty, path, qid);
exit (0);
}
@@ -423,17 +459,14 @@ get_newline_str (FILE *fp)
/* NOTE: Do not bother to free allocated memory, as the program exits
immediately after executing this */
static void
-notify_user (const char *user, const char *device, const char *path, off_t offset)
+notify_user (const char *user, const char *device, const char *path,
+ mu_message_qid_t qid)
{
FILE *fp;
const char *cr;
- char *blurb;
- mu_mailbox_t mbox = NULL, tmp = NULL;
+ mu_mailbox_t mbox = NULL;
mu_message_t msg;
- mu_stream_t stream = NULL;
int status;
- off_t size;
- size_t count, n;
change_user (user);
if ((fp = fopen (device, "w")) == NULL)
@@ -452,56 +485,21 @@ notify_user (const char *user, const char *device, const char *path, off_t offse
}
if ((status = mu_mailbox_create (&mbox, path)) != 0
- || (status = mu_mailbox_open (mbox, MU_STREAM_READ)) != 0)
+ || (status = mu_mailbox_open (mbox, MU_STREAM_READ|MU_STREAM_QACCESS)) != 0)
{
syslog (LOG_ERR, _("Cannot open mailbox %s: %s"),
path, mu_strerror (status));
return;
}
- if ((status = mu_mailbox_get_stream (mbox, &stream)))
- {
- syslog (LOG_ERR, _("Cannot get stream for mailbox %s: %s"),
- path, mu_strerror (status));
- return;
- }
-
- if ((status = mu_stream_size (stream, &size)))
- {
- syslog (LOG_ERR, _("Cannot get stream size (mailbox %s): %s"),
- path, mu_strerror (status));
- return;
- }
-
- /* Read headers */
- size -= offset;
- blurb = malloc (size + 1);
- if (!blurb)
- return;
-
- mu_stream_read (stream, blurb, size, offset, &n);
- blurb[size] = 0;
-
- if ((status = mu_mailbox_create (&tmp, "/dev/null")) != 0
- || (status = mu_mailbox_open (tmp, MU_STREAM_READ)) != 0)
- {
- syslog (LOG_ERR, _("Cannot create temporary mailbox: %s"),
- mu_strerror (status));
- return;
- }
-
- if ((status = mu_memory_stream_create (&stream, 0, 0)))
+ status = mu_mailbox_quick_get_message (mbox, qid, &msg);
+ if (status)
{
- syslog (LOG_ERR, _("Cannot create temporary stream: %s"),
- mu_strerror (status));
- return;
+ syslog (LOG_ERR, _("Cannot get message (mailbox %s, qid %s): %s"),
+ path, qid, mu_strerror (status));
+ return; /* FIXME: Notify the user, anyway */
}
- mu_stream_write (stream, blurb, size, 0, &count);
- mu_mailbox_set_stream (tmp, stream);
- mu_mailbox_messages_count (tmp, &count);
- mu_mailbox_get_message (tmp, 1, &msg);
-
run_user_action (fp, cr, msg);
fclose (fp);
}
diff --git a/include/mailutils/stream.h b/include/mailutils/stream.h
index 5bc9c3870..642c922bb 100644
--- a/include/mailutils/stream.h
+++ b/include/mailutils/stream.h
@@ -39,7 +39,9 @@ extern "C" { /*}*/
#define MU_STREAM_NO_CLOSE 0x00000100
#define MU_STREAM_ALLOW_LINKS 0x00000200
#define MU_STREAM_NONLOCK 0x00000400
-
+/* This one affects only mailboxes */
+#define MU_STREAM_QACCESS 0x00000800
+
/* Functions useful to users of the pre-defined stream types. */
extern int mu_file_stream_create (mu_stream_t *stream, const char* filename,
diff --git a/libproto/mbox/folder.c b/libproto/mbox/folder.c
index e40f5029a..e434bcc64 100644
--- a/libproto/mbox/folder.c
+++ b/libproto/mbox/folder.c
@@ -358,7 +358,7 @@ list_helper (struct search_data *data,
break;
case GLOB_ABORTED:
- status = MU_READ_ERROR;
+ status = MU_ERR_READ;
break;
case GLOB_NOMATCH:
diff --git a/libproto/mbox/mbox.c b/libproto/mbox/mbox.c
index 76ee4064d..ac78aab69 100644
--- a/libproto/mbox/mbox.c
+++ b/libproto/mbox/mbox.c
@@ -35,6 +35,9 @@ static void mbox_destroy (mu_mailbox_t);
static int mbox_open (mu_mailbox_t, int);
static int mbox_close (mu_mailbox_t);
static int mbox_get_message (mu_mailbox_t, size_t, mu_message_t *);
+static int mbox_quick_get_message (mu_mailbox_t, mu_message_qid_t,
+ mu_message_t *);
+
/* static int mbox_get_message_by_uid (mu_mailbox_t, size_t, mu_message_t *); */
static int mbox_append_message (mu_mailbox_t, mu_message_t);
static int mbox_messages_count (mu_mailbox_t, size_t *);
@@ -136,6 +139,7 @@ _mailbox_mbox_init (mu_mailbox_t mailbox)
mailbox->_sync = mbox_sync;
mailbox->_uidvalidity = mbox_uidvalidity;
mailbox->_uidnext = mbox_uidnext;
+ mailbox->_quick_get_message = mbox_quick_get_message;
mailbox->_scan = mbox_scan;
mailbox->_is_updated = mbox_is_updated;
@@ -1065,45 +1069,10 @@ mbox_envelope_sender (mu_envelope_t envelope, char *buf, size_t len,
}
static int
-mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
+new_message (mu_mailbox_t mailbox, mbox_message_t mum, mu_message_t *pmsg)
{
int status;
- mbox_data_t mud = mailbox->data;
- mbox_message_t mum;
- mu_message_t msg = NULL;
-
- /* Sanity checks. */
- if (pmsg == NULL)
- return MU_ERR_OUT_PTR_NULL;
- if (mud == NULL)
- return EINVAL;
-
- /* If we did not start a scanning yet do it now. */
- if (mud->messages_count == 0)
- {
- status = mbox_scan0 (mailbox, 1, NULL, 0);
- if (status != 0)
- return status;
- }
-
- /* Second sanity: check the message number. */
- if (!(mud->messages_count > 0
- && msgno > 0
- && msgno <= mud->messages_count))
- return EINVAL;
-
- mum = mud->umessages[msgno - 1];
-
- /* Check if we already have it. */
- if (mum->message)
- {
- if (pmsg)
- *pmsg = mum->message;
- return 0;
- }
-
- MAILBOX_DEBUG2 (mailbox, MU_DEBUG_TRACE, "mbox_get_message (%s, %d)\n",
- mud->name, msgno);
+ mu_message_t msg;
/* Get an empty message struct. */
status = mu_message_create (&msg, mum);
@@ -1185,9 +1154,109 @@ mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
mu_message_set_mailbox (msg, mailbox, mum);
*pmsg = msg;
+
+ return 0;
+}
+
+static int
+mbox_get_message (mu_mailbox_t mailbox, size_t msgno, mu_message_t *pmsg)
+{
+ int status;
+ mbox_data_t mud = mailbox->data;
+ mbox_message_t mum;
+
+ /* Sanity checks. */
+ if (pmsg == NULL)
+ return MU_ERR_OUT_PTR_NULL;
+ if (mud == NULL)
+ return EINVAL;
+
+ /* If we did not start a scanning yet do it now. */
+ if (mud->messages_count == 0)
+ {
+ status = mbox_scan0 (mailbox, 1, NULL, 0);
+ if (status != 0)
+ return status;
+ }
+
+ /* Second sanity: check the message number. */
+ if (!(mud->messages_count > 0
+ && msgno > 0
+ && msgno <= mud->messages_count))
+ return EINVAL;
+
+ mum = mud->umessages[msgno - 1];
+
+ /* Check if we already have it. */
+ if (mum->message)
+ {
+ if (pmsg)
+ *pmsg = mum->message;
+ return 0;
+ }
+
+ MAILBOX_DEBUG2 (mailbox, MU_DEBUG_TRACE, "mbox_get_message (%s, %d)\n",
+ mud->name, msgno);
+
+ return new_message (mailbox, mum, pmsg);
+}
+
+static int
+qid2off (mu_message_qid_t qid, mu_off_t *pret)
+{
+ mu_off_t ret = 0;
+ for (;*qid; qid++)
+ {
+ if (!('0' <= *qid && *qid <= '9'))
+ return 1;
+ ret = ret * 10 + *qid - '0';
+ }
+ *pret = ret;
return 0;
}
+
+static int
+mbox_quick_get_message (mu_mailbox_t mailbox, mu_message_qid_t qid,
+ mu_message_t *pmsg)
+{
+ int status;
+ mbox_data_t mud = mailbox->data;
+ mbox_message_t mum;
+ mu_off_t offset;
+
+ if (mailbox == NULL || qid2off (qid, &offset)
+ || !(mailbox->flags & MU_STREAM_QACCESS))
+ return EINVAL;
+ if (mud->messages_count == 0)
+ {
+ status = mbox_scan1 (mailbox, offset, 0);
+ if (status != 0)
+ return status;
+ }
+
+ /* Quick access mode retrieves only one message */
+ mum = mud->umessages[0];
+
+ /* Check if we already have it and verify if it is the right one. */
+ if (mum->message)
+ {
+ char *vqid;
+ status = mu_message_get_qid (mum->message, &vqid);
+ if (status)
+ return status;
+ status = strcmp (qid, vqid);
+ free (vqid);
+ if (status)
+ return MU_ERR_EXISTS;
+ if (pmsg)
+ *pmsg = mum->message;
+ return 0;
+ }
+
+ return new_message (mailbox, mum, pmsg);
+}
+
static int
mbox_append_message (mu_mailbox_t mailbox, mu_message_t msg)
{
diff --git a/libproto/mbox/mbox0.h b/libproto/mbox/mbox0.h
index 4d03deb48..f5b897520 100644
--- a/libproto/mbox/mbox0.h
+++ b/libproto/mbox/mbox0.h
@@ -124,6 +124,9 @@ struct _mbox_data
int mbox_scan0 (mu_mailbox_t mailbox, size_t msgno, size_t *pcount,
int do_notif);
+int mbox_scan1 (mu_mailbox_t mailbox, mu_off_t offset, int do_notif);
+
#ifdef WITH_PTHREAD
void mbox_cleanup (void *arg);
#endif
+
diff --git a/libproto/mbox/mboxscan.c b/libproto/mbox/mboxscan.c
index daf9b8811..1ec1e946b 100644
--- a/libproto/mbox/mboxscan.c
+++ b/libproto/mbox/mboxscan.c
@@ -52,8 +52,6 @@
locks, flush the stream save the pointers etc ... hurry and wait...
I this point I'm pretty much ranting. */
-
-/* From the C-Client, part of pine */
/* You are not expected to understand this macro, but read the next page if
* you are not faint of heart.
*
@@ -181,6 +179,7 @@ h
} \
while (0)
+
#define ATTRIBUTE_SET(buf,mum,c0,c1,type) \
do \
{ \
@@ -195,215 +194,6 @@ do \
} \
} while (0)
-#define ISBCC(buf) ( \
-(buf[0] == 'B' || buf[0] == 'b') \
- && (buf[1] == 'C' || buf[1] == 'c') \
- && (buf[2] == 'C' || buf[2] == 'c') \
- && (buf[3] == ':' || buf[3] == ' ' || buf[3] == '\t'))
-
-#define ISCC(buf) ( \
-(buf[0] == 'C' || buf[0] == 'c') \
- && (buf[1] == 'C' || buf[1] == 'c') \
- && (buf[2] == ':' || buf[2] == ' ' || buf[2] == '\t'))
-
-#define ISCONTENT_LANGUAGE(buf) ( \
-(buf[0] == 'C' || buf[0] == 'c') \
- && (buf[1] == 'O' || buf[1] == 'o') \
- && (buf[2] == 'N' || buf[2] == 'n') \
- && (buf[3] == 'T' || buf[3] == 't') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'N' || buf[5] == 'n') \
- && (buf[6] == 'T' || buf[6] == 't') \
- && (buf[7] == '-') \
- && (buf[8] == 'L' || buf[8] == 'l') \
- && (buf[9] == 'A' || buf[9] == 'a') \
- && (buf[10] == 'N' || buf[10] == 'n') \
- && (buf[11] == 'G' || buf[11] == 'g') \
- && (buf[12] == 'U' || buf[12] == 'u') \
- && (buf[13] == 'A' || buf[13] == 'a') \
- && (buf[14] == 'G' || buf[14] == 'g') \
- && (buf[15] == 'E' || buf[15] == 'e') \
- && (buf[16] == ':' || buf[16] == ' ' || buf[16] == '\t'))
-
-#define ISCONTENT_TRANSFER_ENCODING(buf) ( \
-(buf[0] == 'C' || buf[0] == 'c') \
- && (buf[1] == 'O' || buf[1] == 'o') \
- && (buf[2] == 'N' || buf[2] == 'n') \
- && (buf[3] == 'T' || buf[3] == 't') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'N' || buf[5] == 'n') \
- && (buf[6] == 'T' || buf[6] == 't') \
- && (buf[7] == '-') \
- && (buf[8] == 'T' || buf[8] == 't') \
- && (buf[9] == 'R' || buf[9] == 'r') \
- && (buf[10] == 'A' || buf[10] == 'a') \
- && (buf[11] == 'N' || buf[11] == 'n') \
- && (buf[12] == 'S' || buf[12] == 's') \
- && (buf[13] == 'F' || buf[13] == 'f') \
- && (buf[14] == 'E' || buf[14] == 'e') \
- && (buf[15] == 'R' || buf[15] == 'r') \
- && (buf[16] == '-') \
- && (buf[17] == 'E' || buf[17] == 'e') \
- && (buf[18] == 'N' || buf[18] == 'n') \
- && (buf[19] == 'C' || buf[19] == 'c') \
- && (buf[20] == 'O' || buf[20] == 'o') \
- && (buf[21] == 'D' || buf[21] == 'd') \
- && (buf[22] == 'I' || buf[22] == 'i') \
- && (buf[23] == 'N' || buf[23] == 'n') \
- && (buf[24] == 'G' || buf[24] == 'g') \
- && (buf[25] == ':' || buf[25] == ' ' || buf[25] == '\t'))
-
-#define ISCONTENT_TYPE(buf) ( \
-(buf[0] == 'C' || buf[0] == 'c') \
- && (buf[1] == 'O' || buf[1] == 'o') \
- && (buf[2] == 'N' || buf[2] == 'n') \
- && (buf[3] == 'T' || buf[3] == 't') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'N' || buf[5] == 'n') \
- && (buf[6] == 'T' || buf[6] == 't') \
- && (buf[7] == '-') \
- && (buf[8] == 'T' || buf[8] == 't') \
- && (buf[9] == 'Y' || buf[9] == 'y') \
- && (buf[10] == 'P' || buf[10] == 'p') \
- && (buf[11] == 'E' || buf[11] == 'e') \
- && (buf[12] == ':' || buf[12] == ' ' || buf[12] == '\t'))
-
-#define ISDATE(buf) ( \
-(buf[0] == 'D' || buf[0] == 'd') \
- && (buf[1] == 'A' || buf[1] == 'a') \
- && (buf[2] == 'T' || buf[2] == 't') \
- && (buf[3] == 'E' || buf[3] == 'e') \
- && (buf[4] == ':' || buf[4] == ' ' || buf[4] == '\t'))
-
-#define ISFROM(buf) ( \
-(buf[0] == 'F' || buf[0] == 'f') \
- && (buf[1] == 'R' || buf[1] == 'r') \
- && (buf[2] == 'O' || buf[2] == 'o') \
- && (buf[3] == 'M' || buf[3] == 'm') \
- && (buf[4] == ':' || buf[4] == ' ' || buf[4] == '\t'))
-
-#define ISIN_REPLY_TO(buf) ( \
-(buf[0] == 'I' || buf[0] == 'i') \
- && (buf[1] == 'N' || buf[1] == 'n') \
- && (buf[2] == '-' || buf[2] == '-') \
- && (buf[3] == 'R' || buf[3] == 'r') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'P' || buf[5] == 'p') \
- && (buf[6] == 'L' || buf[6] == 'l') \
- && (buf[7] == 'Y' || buf[7] == 'y') \
- && (buf[8] == '-') \
- && (buf[9] == 'T' || buf[9] == 't') \
- && (buf[10] == 'O' || buf[10] == 'o') \
- && (buf[11] == ':' || buf[11] == ' ' || buf[11] == '\t'))
-
-#define ISMESSAGE_ID(buf) ( \
-(buf[0] == 'M' || buf[0] == 'm') \
- && (buf[1] == 'E' || buf[1] == 'e') \
- && (buf[2] == 'S' || buf[2] == 's') \
- && (buf[3] == 'S' || buf[3] == 's') \
- && (buf[4] == 'A' || buf[4] == 'a') \
- && (buf[5] == 'G' || buf[5] == 'g') \
- && (buf[6] == 'E' || buf[6] == 'e') \
- && (buf[7] == '-') \
- && (buf[8] == 'I' || buf[8] == 'i') \
- && (buf[9] == 'D' || buf[9] == 'd') \
- && (buf[10] == ':' || buf[10] == ' ' || buf[10] == '\t'))
-
-#define ISREFERENCE(buf) ( \
-(buf[0] == 'R' || buf[0] == 'r') \
- && (buf[1] == 'E' || buf[1] == 'e') \
- && (buf[2] == 'F' || buf[2] == 'f') \
- && (buf[3] == 'E' || buf[3] == 'e') \
- && (buf[4] == 'R' || buf[4] == 'r') \
- && (buf[5] == 'E' || buf[5] == 'e') \
- && (buf[6] == 'n' || buf[6] == 'n') \
- && (buf[7] == 'C' || buf[7] == 'c') \
- && (buf[8] == 'E' || buf[8] == 'e') \
- && (buf[9] == ':' || buf[9] == ' ' || buf[9] == '\t'))
-
-#define ISREPLY_TO(buf) ( \
-(buf[0] == 'R' || buf[0] == 'r') \
- && (buf[1] == 'E' || buf[1] == 'e') \
- && (buf[2] == 'P' || buf[2] == 'p') \
- && (buf[3] == 'L' || buf[3] == 'l') \
- && (buf[4] == 'Y' || buf[4] == 'y') \
- && (buf[5] == '-') \
- && (buf[6] == 'T' || buf[6] == 't') \
- && (buf[7] == 'O' || buf[7] == 'o') \
- && (buf[8] == ':' || buf[8] == ' ' || buf[8] == '\t'))
-
-#define ISSENDER(buf) ( \
-(buf[0] == 'S' || buf[0] == 's') \
- && (buf[1] == 'E' || buf[1] == 'e') \
- && (buf[2] == 'N' || buf[2] == 'n') \
- && (buf[3] == 'D' || buf[3] == 'd') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'R' || buf[5] == 'r') \
- && (buf[6] == ':' || buf[6] == ' ' || buf[6] == '\t'))
-
-#define ISSTATUS(buf) ( \
-(buf[0] == 'S' || buf[0] == 's') \
- && (buf[1] == 'T' || buf[1] == 't') \
- && (buf[2] == 'A' || buf[2] == 'a') \
- && (buf[3] == 'T' || buf[3] == 't') \
- && (buf[4] == 'U' || buf[4] == 'u') \
- && (buf[5] == 'S' || buf[5] == 's') \
- && (buf[6] == ':' || buf[6] == ' ' || buf[6] == '\t'))
-
-#define ISSUBJECT(buf) ( \
-(buf[0] == 'S' || buf[0] == 's') \
- && (buf[1] == 'U' || buf[1] == 'u') \
- && (buf[2] == 'B' || buf[2] == 'b') \
- && (buf[3] == 'J' || buf[3] == 'j') \
- && (buf[4] == 'E' || buf[4] == 'e') \
- && (buf[5] == 'C' || buf[5] == 'c') \
- && (buf[6] == 'T' || buf[6] == 't') \
- && (buf[7] == ':' || buf[7] == ' ' || buf[7] == '\t'))
-
-#define ISTO(buf) ( \
-(buf[0] == 'T' || buf[0] == 't') \
- && (buf[1] == 'O' || buf[1] == 'o') \
- && (buf[2] == ':' || buf[2] == ' ' || buf[2] == '\t'))
-
-#define ISX_IMAPBASE(buf) ( \
-(buf[0] == 'X' || buf[0] == 'x') \
- && (buf[1] == '-') \
- && (buf[2] == 'I' || buf[2] == 'i') \
- && (buf[3] == 'M' || buf[3] == 'm') \
- && (buf[4] == 'A' || buf[4] == 'a') \
- && (buf[5] == 'P' || buf[5] == 'p') \
- && (buf[6] == 'B' || buf[6] == 'b') \
- && (buf[7] == 'A' || buf[7] == 'a') \
- && (buf[8] == 'S' || buf[8] == 's') \
- && (buf[9] == 'E' || buf[9] == 'e') \
- && (buf[10] == ':' || buf[10] == ' ' || buf[10] == '\t'))
-
-#define ISX_UIDL(buf) ( \
-(buf[0] == 'X' || buf[0] == 'x') \
- && (buf[1] == '-') \
- && (buf[2] == 'U' || buf[2] == 'u') \
- && (buf[3] == 'I' || buf[3] == 'i') \
- && (buf[4] == 'D' || buf[4] == 'd') \
- && (buf[5] == 'L' || buf[5] == 'l') \
- && (buf[6] == ':' || buf[6] == ' ' || buf[6] == '\t'))
-
-#define ISX_UID(buf) ( \
-(buf[0] == 'X' || buf[0] == 'x') \
- && (buf[1] == '-') \
- && (buf[2] == 'U' || buf[2] == 'u') \
- && (buf[3] == 'I' || buf[3] == 'i') \
- && (buf[4] == 'D' || buf[4] == 'd') \
- && (buf[5] == ':' || buf[5] == ' ' || buf[5] == '\t'))
-
-/* Skip prepend spaces. */
-#define SKIPSPACE(p) while (*p == ' ') p++
-
-#define ATOI(a,i) \
-do { \
- SKIPSPACE(a); \
- for (i = 0; *a >= '0' && *a <= '9'; a++) \
- i = 10 * i + (*a - '0'); \
-} while (0)
/* Notifications ADD_MESG. */
#define DISPATCH_ADD_MSG(mbox,mud) \
@@ -419,8 +209,6 @@ do \
} \
if (bailing != 0) \
{ \
- if (pcount) \
- *pcount = (mud)->messages_count; \
mu_locker_unlock (mbox->locker); \
return EINTR; \
} \
@@ -444,8 +232,6 @@ do \
MU_EVT_MAILBOX_PROGRESS, NULL); \
if (bailing != 0) \
{ \
- if (pcount) \
- *pcount = (mud)->messages_count; \
mu_locker_unlock (mbox->locker); \
return EINTR; \
} \
@@ -481,16 +267,29 @@ do \
} \
} while (0)
+#define ISSTATUS(buf) ( \
+(buf[0] == 'S' || buf[0] == 's') \
+ && (buf[1] == 'T' || buf[1] == 't') \
+ && (buf[2] == 'A' || buf[2] == 'a') \
+ && (buf[3] == 'T' || buf[3] == 't') \
+ && (buf[4] == 'U' || buf[4] == 'u') \