Commit a273efe0 a273efe0a7716b83b3561ba69bb837c6a7f11b96 by Alain Magloire

* mail/from.c: Use address_get_personal() for a more

	pretty print when showing the headers.
1 parent 8cc9f7db
2001-06-26 Alain Magloire
* mail/from.c: Use address_get_personal() for a more
pretty print when showing the headers.
2001-06-26 Sergey Poznyakoff
* mail/util.c:
Added extra argument to util_msglist_command(), controlling
......
......@@ -29,10 +29,10 @@ mail_from (int argc, char **argv)
else
{
message_t msg;
header_t hdr;
header_t hdr = NULL;
envelope_t env;
attribute_t attr;
char *from, *subj;
char *from = NULL, *subj = NULL;
int froml, subjl;
char date[80], st[10];
int cols = util_getcols () - 6;
......@@ -41,20 +41,34 @@ mail_from (int argc, char **argv)
const char *p;
struct tm tm;
mu_timezone tz;
if (mailbox_get_message (mbox, cursor, &msg) != 0)
return 1;
if (util_isdeleted (cursor))
return 1;
froml = cols / 3;
subjl = cols * 2 / 3;
if (froml + subjl > cols)
subjl--;
from = malloc (froml * sizeof (char));
subj = malloc (subjl * sizeof (char));
message_get_header (msg, &hdr);
if (header_aget_value (hdr, MU_HEADER_FROM, &from) == 0)
{
address_t address = NULL;
if (address_create (&address, from) == 0)
{
char p[128];
size_t len = strlen (from);
*p = '\0';
address_get_personal (address, 1, p, sizeof p, NULL);
if (*p && len)
{
strncpy (from, p, len - 1);
from[len - 1] = '\0';
}
else
address_get_email (address, 1, from, strlen (from), NULL);
address_destroy (&address);
}
}
header_aget_value (hdr, MU_HEADER_SUBJECT, &subj);
if (from == NULL || subj == NULL)
{
......@@ -63,10 +77,6 @@ mail_from (int argc, char **argv)
return 1;
}
message_get_header (msg, &hdr);
header_get_value (hdr, MU_HEADER_FROM, from, froml, NULL);
header_get_value (hdr, MU_HEADER_SUBJECT, subj, subjl, NULL);
message_get_attribute (msg, &attr);
attribute_get_flags (attr, &flags);
......@@ -91,9 +101,18 @@ mail_from (int argc, char **argv)
message_lines (msg, &m_lines);
snprintf (st, sizeof(st), "%3ld/%-5ld", m_lines, m_size);
fprintf (ofile, "%c%c%4d %-18.18s %-16.16s %s %12.12s\n",
/* The "From" field will take a third of the screen.
Subject will take the rest.
FIXME: This is not quiet correct we use fix sizes
18, 16 for the other fields.
*/
froml = cols / 3;
subjl = cols - froml - strlen (st) - strlen (date);
fprintf (ofile, "%c%c%4d %-18.18s %-16.16s %s %.*s\n",
cursor == realcursor ? '>' : ' ', cflag, cursor,
from, date, st, subj);
from, date, st, (subjl < 0) ? 0 : subjl, subj);
free (from);
free (subj);
......