Commit 29d84e71 29d84e71986f154374d02ed1975cd667dbd1b4ef by Alain Magloire

* mail/util.c (util_expand_msglist): Implement expansion of

        :d       All deleted messages
        :n       All new messages
        :o       All old messages
        :r       All messages that have already been read
        :u       All unread messages
        /string  All messages with string in the subject line
                 (the case of characters in string is ignored)
1 parent 284950f5
2001-06-29 Alain Magloire
* mail/util.c (util_expand_msglist): Implement expansion of
:d All deleted messages
:n All new messages
:o All old messages
:r All messages that have already been read
:u All unread messages
/string All messages with string in the subject line
(the case of characters in string is ignored)
2001-06-27 Alain Magloire
* configure.in: We were not checking for thread support
......
......@@ -152,41 +152,69 @@ util_expand_msglist (const int argc, char **argv, int **list)
}
else if (argv[i][0] == '/')
{
/* FIXME: all messages with pattern following / in
/* All messages with pattern following / in
the subject line, case insensitive */
/* This currently appears to be quit b0rked */
message_t msg;
header_t hdr;
char subj[128];
int j = 1, k = 0, l2 = 0;
int len = strlen (&argv[i][1]);
int j;
for (j = 1; j <= total; j++)
{
message_t msg = NULL;
header_t hdr = NULL;
char *subject = NULL;
size_t subjlen;
char *pattern;
size_t patlen;
int k;
mailbox_get_message (mbox, j, &msg);
message_get_header (msg, &hdr);
header_get_value (hdr, MU_HEADER_SUBJECT, subj, 128, NULL);
l2 = strlen (subj);
for (k = 0; i < strlen (subj); k++)
{
if (l2-k >= len && !strncasecmp (&argv[i][1], &subj[k], len))
header_aget_value (hdr, MU_HEADER_SUBJECT, &subject);
subjlen = (subject) ? strlen (subject) : 0;
for (k = 0; k < subjlen; k++)
subject[k] = toupper ((int)subject[k]);
pattern = strdup (&argv[i][1]);
patlen = (pattern) ? strlen (pattern) : 0;
for (k = 0; k < patlen; k++)
pattern[k] = toupper ((int)pattern[k]);
if (pattern && subject && strstr (subject, pattern))
{
current = util_ll_add (current, j);
k = 128;
}
}
free (pattern);
free (subject);
}
}
else if (argv[i][0] == ':')
{
/* FIXME: all messages of type argv[i][1] */
/* All messages of type argv[i][1] */
int j;
for (j = 1; j <= total; j++)
{
message_t msg = NULL;
attribute_t attr= NULL;
mailbox_get_message (mbox, j, &msg);
message_get_attribute (msg, &attr);
if ((argv[i][1] == 'd' && attribute_is_deleted (attr))
|| (argv[i][1] == 'n' && attribute_is_recent (attr))
|| (argv[i][1] == 'o' && attribute_is_seen (attr))
|| (argv[i][1] == 'r' && attribute_is_read (attr))
|| (argv[i][1] == 'u' && !attribute_is_read (attr)))
current = util_ll_add (current, j);
}
}
else if (isalpha(argv[i][0]))
{
/* FIXME: all messages from sender argv[i] */
/* Annoying we can use address_create() for that
but to compare against what? The email ? */
}
else if (strchr (argv[i], '-') != NULL)
{
/* message range */
/* Message range. */
int j, x, y;
char *arg = strdup (argv[i]);
for (j=0; j < strlen (arg); j++)
......@@ -201,7 +229,7 @@ util_expand_msglist (const int argc, char **argv, int **list)
}
else
{
/* single message */
/* Single message. */
current = util_ll_add (current, strtol (argv[i], NULL, 10));
}
}
......@@ -920,8 +948,3 @@ util_save_outgoing (message_t msg, char *savefile)
free (filename);
}
}
......
......@@ -85,7 +85,7 @@ main(int argc, char **argv)
msgset (argc - 1, &argv[1], &set, &n);
else
{
char *av[] = { "*" };
const char *av[] = { "*" };
msgset (1, av, &set, &n);
}
......