Commit 82c5c521 82c5c521e859246cc12c5f8d63fabd5b013d3487 by Sergey Poznyakoff

mh: check Local-Mailbox setting

* mh/mh_init.c (mh_my_email): If Local-Mailbox is set, use
its value.
* mh/tests/scan.at: Add test for Local-Mailbox.
1 parent 744c4a9c
......@@ -133,22 +133,36 @@ mh_err_memory (int fatal)
static char *my_name;
static char *my_email;
void
mh_get_my_name (char *name)
static char *
mh_get_my_name (void)
{
if (!name)
if (!my_name)
{
struct passwd *pw = getpwuid (getuid ());
if (!pw)
{
mu_error (_("cannot determine my username"));
return;
my_name = mu_strdup ("unknown");
}
name = pw->pw_name;
else
my_name = mu_strdup (pw->pw_name);
}
return my_name;
}
my_name = mu_strdup (name);
my_email = mu_get_user_email (name);
char *
mh_my_email (void)
{
char *username = mh_get_my_name ();
if (!my_email)
{
const char *p = mh_global_profile_get ("Local-Mailbox", NULL);
if (p)
my_email = mu_strdup (p);
else
my_email = mu_get_user_email (username);
}
return my_email;
}
int
......@@ -176,9 +190,7 @@ mh_is_my_name (const char *name)
for (p++; *p; p++)
*p = mu_toupper (*p);
if (!my_email)
mh_get_my_name (NULL);
if (emailcmp (my_email, pname) == 0)
if (emailcmp (mh_my_email (), pname) == 0)
rc = 1;
else
{
......@@ -222,14 +234,6 @@ mh_is_my_name (const char *name)
return rc;
}
char *
mh_my_email ()
{
if (!my_email)
mh_get_my_name (NULL);
return my_email;
}
static int
make_dir_hier (const char *p, mode_t perm)
{
......
......@@ -80,5 +80,18 @@ scan +mbox1 -reverse | sed 's/ *$//'
1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
])
MH_CHECK([Local mailbox],[scan05 local-mailbox],[
MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox],[700])
echo "Local-Mailbox: gray@example.net" >> $MH
scan | sed 's/ *$//'
],
[0],
[ 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
3 07/13 To:Foo Bar Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
4 07/13 To:Foo Bar Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
5 07/13 To:Foo Bar Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
])
m4_popdef[MH_KEYWORDS])
# End of scan.at
......