49 |
static list_t unix_gid_to_list __P((char *name)); |
static list_t unix_gid_to_list __P((char *name)); |
50 |
static list_t unix_passwd_to_list __P((void)); |
static list_t unix_passwd_to_list __P((void)); |
51 |
|
|
52 |
|
int yyerror __P((char *s)); |
53 |
|
int yylex __P((void)); |
54 |
|
|
55 |
%} |
%} |
56 |
|
|
57 |
%union { |
%union { |
216 |
} |
} |
217 |
|
|
218 |
static int mh_alias_get_internal __P((char *name, iterator_t start, |
static int mh_alias_get_internal __P((char *name, iterator_t start, |
219 |
list_t *return_list)); |
list_t *return_list, int *inclusive)); |
220 |
|
|
221 |
int |
int |
222 |
alias_expand_list (list_t name_list, iterator_t orig_itr) |
alias_expand_list (list_t name_list, iterator_t orig_itr, int *inclusive) |
223 |
{ |
{ |
224 |
iterator_t itr; |
iterator_t itr; |
225 |
|
|
231 |
list_t exlist; |
list_t exlist; |
232 |
|
|
233 |
iterator_current (itr, (void **)&name); |
iterator_current (itr, (void **)&name); |
234 |
if (mh_alias_get_internal (name, orig_itr, &exlist) == 0) |
if (mh_alias_get_internal (name, orig_itr, &exlist, inclusive) == 0) |
235 |
{ |
{ |
236 |
_insert_list (name_list, name, exlist); |
_insert_list (name_list, name, exlist); |
237 |
list_remove (name_list, name); |
list_remove (name_list, name); |
245 |
/* Look up the named alias. If found, return the list of recipient |
/* Look up the named alias. If found, return the list of recipient |
246 |
names associated with it */ |
names associated with it */ |
247 |
static int |
static int |
248 |
mh_alias_get_internal (char *name, iterator_t start, list_t *return_list) |
mh_alias_get_internal (char *name, iterator_t start, list_t *return_list, |
249 |
|
int *inclusive) |
250 |
{ |
{ |
251 |
iterator_t itr; |
iterator_t itr; |
252 |
int rc = 1; |
int rc = 1; |
267 |
{ |
{ |
268 |
struct mh_alias *alias; |
struct mh_alias *alias; |
269 |
iterator_current (itr, (void **)&alias); |
iterator_current (itr, (void **)&alias); |
270 |
|
if (inclusive) |
271 |
|
*inclusive |= alias->inclusive; |
272 |
if (aliascmp (alias->name, name) == 0) |
if (aliascmp (alias->name, name) == 0) |
273 |
{ |
{ |
274 |
*return_list = ali_list_dup (alias->rcpt_list); |
*return_list = ali_list_dup (alias->rcpt_list); |
275 |
alias_expand_list (*return_list, itr); |
alias_expand_list (*return_list, itr, inclusive); |
276 |
rc = 0; |
rc = 0; |
277 |
break; |
break; |
278 |
} |
} |
285 |
int |
int |
286 |
mh_alias_get (char *name, list_t *return_list) |
mh_alias_get (char *name, list_t *return_list) |
287 |
{ |
{ |
288 |
return mh_alias_get_internal (name, NULL, return_list); |
return mh_alias_get_internal (name, NULL, return_list, NULL); |
289 |
} |
} |
290 |
|
|
291 |
int |
int |
292 |
mh_alias_get_address (char *name, address_t *paddr) |
mh_alias_get_address (char *name, address_t *paddr, int *incl) |
293 |
{ |
{ |
294 |
iterator_t itr; |
iterator_t itr; |
295 |
list_t list; |
list_t list; |
296 |
|
const char *domain = NULL; |
297 |
if (mh_alias_get (name, &list)) |
|
298 |
|
if (mh_alias_get_internal (name, NULL, &list, incl)) |
299 |
return 1; |
return 1; |
300 |
if (list_is_empty (list)) |
if (list_is_empty (list)) |
301 |
{ |
{ |
309 |
{ |
{ |
310 |
char *item; |
char *item; |
311 |
address_t a; |
address_t a; |
312 |
|
char *ptr = NULL; |
313 |
|
|
314 |
iterator_current (itr, (void **)&item); |
iterator_current (itr, (void **)&item); |
315 |
|
if (incl && *incl) |
316 |
|
{ |
317 |
|
if (strchr (item, '@') == 0) |
318 |
|
{ |
319 |
|
if (!domain) |
320 |
|
mu_get_user_email_domain (&domain); |
321 |
|
asprintf (&ptr, "\"%s\" <%s@%s>", name, item, domain); |
322 |
|
} |
323 |
|
else |
324 |
|
asprintf (&ptr, "\"%s\" <%s>", name, item); |
325 |
|
item = ptr; |
326 |
|
} |
327 |
if (address_create (&a, item)) |
if (address_create (&a, item)) |
328 |
{ |
{ |
329 |
mh_error (_("Error expanding aliases -- invalid address `%s'"), |
mh_error (_("Error expanding aliases -- invalid address `%s'"), |
334 |
address_union (paddr, a); |
address_union (paddr, a); |
335 |
address_destroy (&a); |
address_destroy (&a); |
336 |
} |
} |
337 |
|
if (ptr) |
338 |
|
free (ptr); |
339 |
} |
} |
340 |
iterator_destroy (&itr); |
iterator_destroy (&itr); |
341 |
} |
} |
388 |
iterator_current (itr, (void **)&alias); |
iterator_current (itr, (void **)&alias); |
389 |
|
|
390 |
tmp = ali_list_dup (alias->rcpt_list); |
tmp = ali_list_dup (alias->rcpt_list); |
391 |
alias_expand_list (tmp, itr); |
alias_expand_list (tmp, itr, NULL); |
392 |
|
|
393 |
rc = fun (alias->name, tmp, data); |
rc = fun (alias->name, tmp, data); |
394 |
list_destroy (&tmp); |
list_destroy (&tmp); |