Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / split_addr.c
blob2d324e2d50f4ae9c0116ea30099082d72ca33294
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* split_addr 3
6 /* SUMMARY
7 /* recipient localpart address splitter
8 /* SYNOPSIS
9 /* #include <split_addr.h>
11 /* char *split_addr(localpart, delimiter)
12 /* char *localpart;
13 /* int delimiter;
14 /* DESCRIPTION
15 /* split_addr() null-terminates \fIlocalpart\fR at the first
16 /* occurrence of the \fIdelimiter\fR character found, and
17 /* returns a pointer to the remainder.
19 /* Reserved addresses are not split: postmaster, mailer-daemon,
20 /* double-bounce. Addresses that begin with owner-, or addresses
21 /* that end in -request are not split when the owner_request_special
22 /* parameter is set.
23 /* LICENSE
24 /* .ad
25 /* .fi
26 /* The Secure Mailer license must be distributed with this software.
27 /* AUTHOR(S)
28 /* Wietse Venema
29 /* IBM T.J. Watson Research
30 /* P.O. Box 704
31 /* Yorktown Heights, NY 10598, USA
32 /*--*/
34 /* System library. */
36 #include <sys_defs.h>
37 #include <string.h>
39 #ifdef STRCASECMP_IN_STRINGS_H
40 #include <strings.h>
41 #endif
43 /* Utility library. */
45 #include <split_at.h>
47 /* Global library. */
49 #include <mail_params.h>
50 #include <mail_addr.h>
51 #include <split_addr.h>
53 /* split_addr - split address with extreme prejudice */
55 char *split_addr(char *localpart, int delimiter)
57 int len;
60 * Don't split these, regardless of what the delimiter is.
62 if (strcasecmp(localpart, MAIL_ADDR_POSTMASTER) == 0)
63 return (0);
64 if (strcasecmp(localpart, MAIL_ADDR_MAIL_DAEMON) == 0)
65 return (0);
66 if (strcasecmp(localpart, var_double_bounce_sender) == 0)
67 return (0);
70 * Backwards compatibility: don't split owner-foo or foo-request.
72 if (delimiter == '-' && var_ownreq_special != 0) {
73 if (strncasecmp(localpart, "owner-", 6) == 0)
74 return (0);
75 if ((len = strlen(localpart) - 8) > 0
76 && strcasecmp(localpart + len, "-request") == 0)
77 return (0);
81 * Safe to split this address. Do not split the address if the result
82 * would have a null localpart.
84 return (delimiter == *localpart ? 0 : split_at(localpart, delimiter));