summaryrefslogtreecommitdiff
path: root/mh
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2017-05-31 14:34:55 +0300
committerSergey Poznyakoff <gray@gnu.org>2017-05-31 14:34:55 +0300
commit82c5c521e859246cc12c5f8d63fabd5b013d3487 (patch)
treef2aa7c7380a201c560ddeb96e795a8b8d61309e8 /mh
parent744c4a9c94064a0dae7d2ed8237ac8129e65510c (diff)
downloadmailutils-82c5c521e859246cc12c5f8d63fabd5b013d3487.tar.gz
mailutils-82c5c521e859246cc12c5f8d63fabd5b013d3487.tar.bz2
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.
Diffstat (limited to 'mh')
-rw-r--r--mh/mh_init.c40
-rw-r--r--mh/tests/scan.at13
2 files changed, 35 insertions, 18 deletions
diff --git a/mh/mh_init.c b/mh/mh_init.c
index eb898fa83..714c06781 100644
--- a/mh/mh_init.c
+++ b/mh/mh_init.c
@@ -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)
{
diff --git a/mh/tests/scan.at b/mh/tests/scan.at
index 7bf849a42..118a51b8b 100644
--- a/mh/tests/scan.at
+++ b/mh/tests/scan.at
@@ -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

Return to:

Send suggestions and report system problems to the System administrator.