1 /* $NetBSD: smtp_misc.c,v 1.2 2020/03/18 19:05:20 christos Exp $ */ 2 3 /*++ 4 /* NAME 5 /* smtp_misc 3 6 /* SUMMARY 7 /* SMTP client address rewriting 8 /* SYNOPSIS 9 /* #include <smtp_addr.h> 10 /* 11 /* void smtp_rewrite_generic_internal( 12 /* VSTRING *dst, 13 /* const char *src); 14 /* 15 /* void smtp_quote_822_address_flags( 16 /* VSTRING *dst, 17 /* const char *src, 18 /* int flags); 19 /* 20 /* void smtp_quote_821_address( 21 /* VSTRING *dst, 22 /* const char *src); 23 /* DESCRIPTION 24 /* smtp_rewrite_generic_internal() rewrites a non-empty address 25 /* if generic mapping is enabled, otherwise copies it literally. 26 /* 27 /* smtp_quote_822_address_flags() is a wrapper around 28 /* quote_822_local_flags(), except for the empty address which 29 /* is copied literally. 30 /* 31 /* smtp_quote_821_address() is a wrapper around quote_821_local(), 32 /* except for the empty address or with "smtp_quote_rfc821_envelope 33 /* = no"; in those cases the address is copied literally. 34 /* DIAGNOSTICS 35 /* Fatal: out of memory. 36 /* LICENSE 37 /* .ad 38 /* .fi 39 /* The Secure Mailer license must be distributed with this software. 40 /* AUTHOR(S) 41 /* Wietse Venema 42 /* Google, Inc. 43 /* 111 8th Avenue 44 /* New York, NY 10011, USA 45 /*--*/ 46 47 /* 48 * System library. 49 */ 50 #include <sys_defs.h> 51 52 /* 53 * Utility library. 54 */ 55 #include <vstring.h> 56 57 /* 58 * Global library. 59 */ 60 #include <ext_prop.h> 61 #include <mail_params.h> 62 #include <quote_821_local.h> 63 #include <quote_822_local.h> 64 65 /* 66 * Application-specific. 67 */ 68 #include <smtp.h> 69 70 /* smtp_rewrite_generic_internal - generic non-empty address rewriting */ 71 72 void smtp_rewrite_generic_internal(VSTRING *dst, const char *src) 73 { 74 vstring_strcpy(dst, src); 75 if (*src && smtp_generic_maps) 76 smtp_map11_internal(dst, smtp_generic_maps, 77 smtp_ext_prop_mask & EXT_PROP_GENERIC); 78 } 79 80 /* smtp_quote_822_address_flags - quote non-empty header address */ 81 82 void smtp_quote_822_address_flags(VSTRING *dst, const char *src, int flags) 83 { 84 if (*src) { 85 quote_822_local_flags(dst, src, flags); 86 } else if (flags & QUOTE_FLAG_APPEND) { 87 vstring_strcat(dst, src); 88 } else { 89 vstring_strcpy(dst, src); 90 } 91 } 92 93 /* smtp_quote_821_address - quote non-empty envelope address */ 94 95 void smtp_quote_821_address(VSTRING *dst, const char *src) 96 { 97 if (*src && var_smtp_quote_821_env) { 98 quote_821_local(dst, src); 99 } else { 100 vstring_strcpy(dst, src); 101 } 102 } 103