summaryrefslogtreecommitdiff
path: root/src/global/sendopts.c
diff options
context:
space:
mode:
authorbeatrice <beatrice@dangofactory.net>2026-11-22 19:19:03 +0900
committerbeatrice <beatrice@dangofactory.net>2026-11-22 19:19:03 +0900
commitbd4611555e18fca7c66afaef0f094e15038b0459 (patch)
tree1b1a9109567b61ac259ead146f4bef21a0f886df /src/global/sendopts.c
parent2324a9e97a727bf95690c9fb8fdca0f52301940e (diff)
downloadpostfix-master.tar.gz
postfix-master.zip
Release tarball postfix-3.11.7.tar.gz (dist-generated files / local differences from tag)HEADlocal/postfixmaster
Diffstat (limited to 'src/global/sendopts.c')
-rw-r--r--src/global/sendopts.c92
1 files changed, 92 insertions, 0 deletions
diff --git a/src/global/sendopts.c b/src/global/sendopts.c
new file mode 100644
index 000000000..4bd1c9f8b
--- /dev/null
+++ b/src/global/sendopts.c
@@ -0,0 +1,92 @@
+/*++
+/* NAME
+/* sendopts 3
+/* SUMMARY
+/* Support for SMTPUTF8, REQUIRETLS, etc.
+/* SYNOPSIS
+/* #include <sendopts.h>
+/*
+/* const char *sendopts_strflags(
+/* int flags,
+/* int delim)
+/* DESCRIPTION
+/* Postfix queue files and IPC messages contain a sendopts field
+/* with flags that control SMTPUTF8, REQUIRETLS, etc. support. The
+/* flags are documented in sendopts(3h), and are based on information
+/* received with ESMTP requests or with message content.
+/*
+/* The SMTPUTF8 flags life cycle is documented in smtputf8(3h).
+/*
+/* sendopts_strflags() maps a sendopts flag value to printable
+/* string. The result is overwritten upon each call.
+/*
+/* Arguments:
+/* .IP flags
+/* A bitmask that is to be converted to text.
+/* .IP delim
+/* The character to separate output words with: one of ' ,|'.
+/* DIAGNOSTICS
+/* Panic: invalid delimiter. Fatal error: invalid flag.
+/* LICENSE
+/* .ad
+/* .fi
+/* The Secure Mailer license must be distributed with this software.
+/* AUTHOR(S)
+/* Wietse Venema
+/* porcupine.org
+/*--*/
+
+/* System library. */
+
+#include <sys_defs.h>
+#include <string.h>
+
+ /*
+ * Utility library.
+ */
+#include <msg.h>
+#include <vstring.h>
+#include <name_mask.h>
+
+ /*
+ * Global library.
+ */
+#include <sendopts.h>
+
+ /*
+ * Mapping from flags to printable string.
+ */
+static NAME_MASK sendopts_flag_map[] = {
+ "smtputf8_requested", SOPT_SMTPUTF8_REQUESTED,
+ "smtputf8_header", SOPT_SMTPUTF8_HEADER,
+ "smtputf8_sender", SOPT_SMTPUTF8_SENDER,
+ "smtputf8_recipient", SOPT_SMTPUTF8_RECIPIENT,
+ "requiretls_header", SOPT_REQUIRETLS_HEADER,
+ "requiretls_esmtp", SOPT_REQUIRETLS_ESMTP,
+ 0,
+};
+
+/* sendopts_strflags - map flags code to printable string */
+
+const char *sendopts_strflags(unsigned flags, int delim)
+{
+ const char myname[] = "sendopts_strflags";
+ static const char delims[] = " ,|";
+ static const int dflags[] = {0, NAME_MASK_COMMA, NAME_MASK_PIPE};
+ static VSTRING *result;
+ const char *cp;
+
+ if (flags == 0)
+ return ("none");
+
+ if (result == 0)
+ result = vstring_alloc(20);
+ else
+ VSTRING_RESET(result);
+
+ if ((cp = strchr(delims, delim)) == 0)
+ msg_panic("%s: bad delimiter: '%c'", myname, delim);
+
+ return (str_name_mask_opt(result, "sendopts_strflags", sendopts_flag_map,
+ flags, NAME_MASK_FATAL | dflags[cp - delims]));
+}