Commit 2a494015 2a494015fbf28402edf13e03ef35a7d4b287225c by Sergey Poznyakoff

See ChangeLog (2001-06-26)

1 parent 011e2cd7
......@@ -24,9 +24,10 @@
*/
/*
* Shared between mail_copy() and mail_save().
* mail_copy0() is shared between mail_copy() and mail_save().
* argc, argv -- argument count & vector
* mark -- whether we should mark the message as saved.
*/
int
mail_copy0 (int argc, char **argv, int mark)
{
......@@ -36,6 +37,7 @@ mail_copy0 (int argc, char **argv, int mark)
int *msglist = NULL;
int num = 0, i = 0;
int sender = 0;
size_t total_size = 0, total_lines = 0, size;
if (isupper (argv[0][0]))
sender = 1;
......@@ -64,18 +66,26 @@ mail_copy0 (int argc, char **argv, int mark)
return 1;
}
fprintf (ofile, "%s\n", filename);
for (i = 0; i < num; i++)
{
mailbox_get_message (mbox, msglist[i], &msg);
mailbox_append_message (mbx, msg);
message_size (msg, &size);
total_size += size;
message_lines (msg, &size);
total_lines += size;
if (mark)
{
/*FIXME: mark as saved */;
attribute_t attr;
message_get_attribute (msg, &attr);
attribute_set_userflag (attr, MAIL_ATTRIBUTE_SAVED);
}
}
fprintf (ofile, "\"%s\" %3ld/%-5ld\n", filename, total_lines, total_size);
mailbox_close (mbx);
mailbox_destroy (&mbx);
......
......@@ -25,7 +25,7 @@ int
mail_delete (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_delete, argc, argv);
return util_msglist_command (mail_delete, argc, argv, 0);
else
{
message_t msg;
......
......@@ -26,7 +26,7 @@ int
mail_dp (int argc, char **argv)
{
if (argc > 1)
util_msglist_command (mail_delete, argc, argv);
util_msglist_command (mail_delete, argc, argv, 0);
else
util_do_command ("delete");
util_do_command ("next");
......
......@@ -25,7 +25,7 @@ int
mail_edit (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_edit, argc, argv);
return util_msglist_command (mail_edit, argc, argv, 1);
else
{
char *file = tempnam(getenv("TMPDIR"), "mu");
......
......@@ -29,7 +29,7 @@ mail_hold (int argc, char **argv)
attribute_t attr;
if (argc > 1)
return util_msglist_command (mail_hold, argc, argv);
return util_msglist_command (mail_hold, argc, argv, 1);
else
{
if (mailbox_get_message (mbox, cursor, &msg))
......
......@@ -51,6 +51,7 @@
#include <mailutils/list.h>
#include <mailutils/iterator.h>
#include <mailutils/address.h>
#include <mailutils/mutil.h>
#include <argcv.h>
#include <getline.h>
......@@ -141,7 +142,7 @@ int mail_z __P((int argc, char **argv));
void mail_mainloop __P((char *(*input) __P((void *, int)), void *closure, int do_history));
int mail_copy0 __P((int argc, char **argv, int mark));
int mail_send0 __P((char *to, char *cc, char *bcc, char *subj));
int mail_send0 __P((char *to, char *cc, char *bcc, char *subj, int save_to));
int mail_mbox_commit __P((void));
int mail_is_alt_name __P((char *name));
int mail_header_is_visible __P((char *str));
......@@ -155,7 +156,7 @@ int mail_eq __P((int argc, char **argv)); /* command = */
int util_expand_msglist __P((const int argc, char **argv, int **list));
int util_do_command __P((const char *cmd, ...));
int util_msglist_command __P((function_t *func, int argc, char **argv));
int util_msglist_command __P((function_t *func, int argc, char **argv, int set_cursor));
function_t* util_command_get __P((char *cmd));
char **util_command_completion __P((char *cmd, int start, int end));
char *util_command_generator __P((char *text, int state));
......@@ -163,6 +164,7 @@ char *util_stripwhite __P((char *string));
struct mail_command_entry util_find_entry __P((char *cmd));
int util_getcols __P((void));
int util_getlines __P((void));
int util_screen_lines __P((void));
struct mail_env_entry *util_find_env __P((char *var));
int util_printenv __P((int set));
int util_isdeleted __P((int message));
......@@ -176,7 +178,9 @@ void util_slist_add __P((list_t *list, char *value));
void util_slist_destroy __P((list_t *list));
char *util_slist_to_string __P((list_t list, char *delim));
void util_strcat __P((char **dest, char *str));
void util_escape_percent (char **str);
void util_escape_percent __P((char **str));
char *util_outfolder_name __P((char *str));
void util_save_outgoing __P((message_t msg, char *savefile));
char *alias_expand __P((char *name));
void alias_destroy __P((char *name));
......@@ -191,6 +195,7 @@ char *readline __P((const char *prompt));
/* Message attributes */
#define MAIL_ATTRIBUTE_MBOXED 0x0001
#define MAIL_ATTRIBUTE_SAVED 0x0002
#ifdef __cplusplus
}
......
......@@ -28,7 +28,7 @@ int
mail_print (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_print, argc, argv);
return util_msglist_command (mail_print, argc, argv, 1);
else
{
message_t mesg;
......@@ -39,6 +39,7 @@ mail_print (int argc, char **argv)
off_t off = 0;
size_t n = 0, lines = 0;
FILE *out = ofile;
attribute_t attr;
if (mailbox_get_message (mbox, cursor, &mesg) != 0)
return 1;
......@@ -87,6 +88,9 @@ mail_print (int argc, char **argv)
if (out != ofile)
pclose (out);
message_get_attribute (mesg, &attr);
attribute_set_read (attr);
return 0;
}
return 1;
......
......@@ -28,7 +28,7 @@ int
mail_reply(int argc, char **argv)
{
if (argc > 1)
return util_msglist_command(mail_reply, argc, argv);
return util_msglist_command(mail_reply, argc, argv, 1);
else
{
message_t msg;
......@@ -84,7 +84,7 @@ mail_reply(int argc, char **argv)
fprintf(ofile, "Cc: %s\n", cc);
fprintf(ofile, "Subject: %s\n\n", subj);
return mail_send0(to, cc, NULL, subj);
return mail_send0(to, cc, NULL, subj, 0);
}
return 1;
}
......
......@@ -25,7 +25,7 @@ int
mail_size (int argc, char **argv)
{
if (argc > 1)
util_msglist_command (mail_size, argc, argv);
util_msglist_command (mail_size, argc, argv, 1);
else
{
unsigned int s = 0;
......
......@@ -35,7 +35,7 @@ const struct mail_command_entry mail_command_table[] = {
{ "el", "else", 1, mail_else, "el[se]" },
{ "en", "endif", 1, mail_endif, "en[dif]" },
{ "ex", "exit", 0, mail_exit, "ex[it]" },
{ "F", "Followup", 0, mail_followup, "F[ollowup] [msglist]" },
{ "F", "Followup", 0, mail_followup,"F[ollowup] [msglist]" },
{ "fi", "file", 0, mail_file, "fi[le] [file]" },
{ "fold", "folder", 0, mail_file, "fold[er] [file]" },
{ "folders", "folders", 0, mail_folders,"folders" },
......
......@@ -25,7 +25,7 @@ int
mail_top (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_top, argc, argv);
return util_msglist_command (mail_top, argc, argv, 1);
else
{
message_t msg;
......
......@@ -25,7 +25,7 @@ int
mail_undelete (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_undelete, argc, argv);
return util_msglist_command (mail_undelete, argc, argv, 1);
else
{
message_t msg;
......
......@@ -25,14 +25,24 @@ int
mail_visual (int argc, char **argv)
{
if (argc > 1)
return util_msglist_command (mail_visual, argc, argv);
return util_msglist_command (mail_visual, argc, argv, 1);
else
{
message_t msg = NULL;
attribute_t attr = NULL;
char *file = tempnam(getenv("TMPDIR"), "mu");
util_do_command ("copy %s", file);
util_do_command ("copy %s", file); /* NOTE: copy does not set flags */
util_do_command ("shell %s %s", getenv("VISUAL"), file);
remove (file);
free (file);
/* Mark as read */
mailbox_get_message (mbox, cursor, &msg);
message_get_attribute (msg, &attr);
attribute_set_read (attr);
return 0;
}
return 1;
......