No empty .Rs/.Re
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / fold_addr.c
blob61a31db0f3edd54d875feaf0ff3fb63f55b9b675
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* fold_addr 3
6 /* SUMMARY
7 /* address case folding
8 /* SYNOPSIS
9 /* #include <fold_addr.h>
11 /* char *fold_addr(addr, flags)
12 /* char *addr;
13 /* int flags;
14 /* DESCRIPTION
15 /* fold_addr() case folds an address according to the options
16 /* specified with \fIflags\fR. The result value is the address
17 /* argument.
19 /* Arguments
20 /* .IP addr
21 /* Null-terminated writable string with the address.
22 /* .IP flags
23 /* Zero or the bit-wise OR of:
24 /* .RS
25 /* .IP FOLD_ADDR_USER
26 /* Case fold the address local part.
27 /* .IP FOLD_ADDR_HOST
28 /* Case fold the address domain part.
29 /* .IP FOLD_ADDR_ALL
30 /* Alias for (FOLD_ADDR_USER | FOLD_ADDR_HOST).
31 /* .RE
32 /* SEE ALSO
33 /* msg(3) diagnostics interface
34 /* DIAGNOSTICS
35 /* Fatal errors: memory allocation problem.
36 /* LICENSE
37 /* .ad
38 /* .fi
39 /* The Secure Mailer license must be distributed with this software.
40 /* AUTHOR(S)
41 /* Wietse Venema
42 /* IBM T.J. Watson Research
43 /* P.O. Box 704
44 /* Yorktown Heights, NY 10598, USA
45 /*--*/
47 /* System library. */
49 #include <sys_defs.h>
50 #include <string.h>
52 /* Utility library. */
54 #include <stringops.h>
56 /* Global library. */
58 #include <fold_addr.h>
60 /* fold_addr - case fold mail address */
62 char *fold_addr(char *addr, int flags)
64 char *cp;
67 * Fold the address as appropriate.
69 switch (flags & FOLD_ADDR_ALL) {
70 case FOLD_ADDR_HOST:
71 if ((cp = strrchr(addr, '@')) != 0)
72 lowercase(cp + 1);
73 break;
74 case FOLD_ADDR_USER:
75 if ((cp = strrchr(addr, '@')) != 0) {
76 *cp = 0;
77 lowercase(addr);
78 *cp = '@';
79 break;
81 /* FALLTHROUGH */
82 case FOLD_ADDR_USER | FOLD_ADDR_HOST:
83 lowercase(addr);
84 break;
86 return (addr);