(mh_is_my_name): Honor Alternate-Mailboxes variable, use wildcard matching.
Showing
1 changed file
with
40 additions
and
1 deletions
... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
25 | #include <unistd.h> | 25 | #include <unistd.h> |
26 | #include <errno.h> | 26 | #include <errno.h> |
27 | #include <fcntl.h> | 27 | #include <fcntl.h> |
28 | #include <fnmatch.h> | ||
28 | 29 | ||
29 | char mh_list_format[] = | 30 | char mh_list_format[] = |
30 | "%4(msg)%<(cur)+%| %>%<{replied}-%?{encrypted}E%| %>" | 31 | "%4(msg)%<(cur)+%| %>%<{replied}-%?{encrypted}E%| %>" |
... | @@ -142,11 +143,49 @@ mh_get_my_name (char *name) | ... | @@ -142,11 +143,49 @@ mh_get_my_name (char *name) |
142 | } | 143 | } |
143 | 144 | ||
144 | int | 145 | int |
146 | emailcmp (char *pattern, char *name) | ||
147 | { | ||
148 | char *p; | ||
149 | |||
150 | p = strchr (pattern, '@'); | ||
151 | if (p) | ||
152 | for (p++; *p; p++) | ||
153 | *p = toupper (*p); | ||
154 | |||
155 | return fnmatch (pattern, name, 0); | ||
156 | } | ||
157 | |||
158 | int | ||
145 | mh_is_my_name (char *name) | 159 | mh_is_my_name (char *name) |
146 | { | 160 | { |
161 | char *pname, *p; | ||
162 | int rc = 0; | ||
163 | |||
164 | pname = strdup (name); | ||
165 | p = strchr (pname, '@'); | ||
166 | if (p) | ||
167 | for (p++; *p; p++) | ||
168 | *p = toupper (*p); | ||
169 | |||
147 | if (!my_email) | 170 | if (!my_email) |
148 | mh_get_my_name (NULL); | 171 | mh_get_my_name (NULL); |
149 | return strcasecmp (name, my_email) == 0; | 172 | if (emailcmp (my_email, pname) == 0) |
173 | rc = 1; | ||
174 | else | ||
175 | { | ||
176 | char *nlist = mh_global_profile_get ("Alternate-Mailboxes", NULL); | ||
177 | if (nlist) | ||
178 | { | ||
179 | char *p, *sp; | ||
180 | |||
181 | p = strtok_r (nlist, ",", &sp); | ||
182 | do | ||
183 | rc = emailcmp (p, pname) == 0; | ||
184 | while (rc == 0 && (p = strtok_r (NULL, ",", &sp))); | ||
185 | } | ||
186 | } | ||
187 | free (pname); | ||
188 | return rc; | ||
150 | } | 189 | } |
151 | 190 | ||
152 | char * | 191 | char * | ... | ... |
-
Please register or sign in to post a comment