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) ...@@ -133,22 +133,36 @@ mh_err_memory (int fatal)
133 static char *my_name; 133 static char *my_name;
134 static char *my_email; 134 static char *my_email;
135 135
136 void 136 static char *
137 mh_get_my_name (char *name) 137 mh_get_my_name (void)
138 { 138 {
139 if (!name) 139 if (!my_name)
140 { 140 {
141 struct passwd *pw = getpwuid (getuid ()); 141 struct passwd *pw = getpwuid (getuid ());
142 if (!pw) 142 if (!pw)
143 { 143 {
144 mu_error (_("cannot determine my username")); 144 mu_error (_("cannot determine my username"));
145 return; 145 my_name = mu_strdup ("unknown");
146 } 146 }
147 name = pw->pw_name; 147 else
148 my_name = mu_strdup (pw->pw_name);
148 } 149 }
150 return my_name;
151 }
149 152
150 my_name = mu_strdup (name); 153 char *
151 my_email = mu_get_user_email (name); 154 mh_my_email (void)
155 {
156 char *username = mh_get_my_name ();
157 if (!my_email)
158 {
159 const char *p = mh_global_profile_get ("Local-Mailbox", NULL);
160 if (p)
161 my_email = mu_strdup (p);
162 else
163 my_email = mu_get_user_email (username);
164 }
165 return my_email;
152 } 166 }
153 167
154 int 168 int
...@@ -176,9 +190,7 @@ mh_is_my_name (const char *name) ...@@ -176,9 +190,7 @@ mh_is_my_name (const char *name)
176 for (p++; *p; p++) 190 for (p++; *p; p++)
177 *p = mu_toupper (*p); 191 *p = mu_toupper (*p);
178 192
179 if (!my_email) 193 if (emailcmp (mh_my_email (), pname) == 0)
180 mh_get_my_name (NULL);
181 if (emailcmp (my_email, pname) == 0)
182 rc = 1; 194 rc = 1;
183 else 195 else
184 { 196 {
...@@ -222,14 +234,6 @@ mh_is_my_name (const char *name) ...@@ -222,14 +234,6 @@ mh_is_my_name (const char *name)
222 return rc; 234 return rc;
223 } 235 }
224 236
225 char *
226 mh_my_email ()
227 {
228 if (!my_email)
229 mh_get_my_name (NULL);
230 return my_email;
231 }
232
233 static int 237 static int
234 make_dir_hier (const char *p, mode_t perm) 238 make_dir_hier (const char *p, mode_t perm)
235 { 239 {
......
...@@ -80,5 +80,18 @@ scan +mbox1 -reverse | sed 's/ *$//' ...@@ -80,5 +80,18 @@ scan +mbox1 -reverse | sed 's/ *$//'
80 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves 80 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
81 ]) 81 ])
82 82
83 MH_CHECK([Local mailbox],[scan05 local-mailbox],[
84 MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox],[700])
85 echo "Local-Mailbox: gray@example.net" >> $MH
86 scan | sed 's/ *$//'
87 ],
88 [0],
89 [ 1 12/28 Foo Bar Jabberwocky<<`Twas brillig, and the slithy toves
90 2 12/28 Bar Re: Jabberwocky<<It seems very pretty, but it's
91 3 07/13 To:Foo Bar Simple MIME<<------- =_aaaaaaaaaa0 Content-Type:
92 4 07/13 To:Foo Bar Nested MIME<<------- =_aaaaaaaaaa0 Content-Type:
93 5 07/13 To:Foo Bar Empty MIME Parts<<------- =_aaaaaaaaaa0 Content-
94 ])
95
83 m4_popdef[MH_KEYWORDS]) 96 m4_popdef[MH_KEYWORDS])
84 # End of scan.at 97 # End of scan.at
......