xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_addheader.html (revision e2c0e292e8a7ca00ba99bcfccc9e637f45c3e8b1)
1d0cef73dSGregory Neil Shapiro<HTML>
2d0cef73dSGregory Neil Shapiro<HEAD><TITLE>smfi_addheader</TITLE></HEAD>
3d0cef73dSGregory Neil Shapiro<BODY>
4e92d3f3fSGregory Neil Shapiro<!--
54313cc83SGregory Neil Shapiro$Id: smfi_addheader.html,v 1.21 2013-11-22 20:51:39 ca Exp $
6e92d3f3fSGregory Neil Shapiro-->
7d0cef73dSGregory Neil Shapiro<H1>smfi_addheader</H1>
840266059SGregory Neil Shapiro
9d0cef73dSGregory Neil Shapiro<TABLE border="0" cellspacing=4 cellpadding=4>
1040266059SGregory Neil Shapiro<!---------- Synopsis ----------->
11d0cef73dSGregory Neil Shapiro<TR><TH valign="top" align=left width=100>SYNOPSIS</TH><TD>
12d0cef73dSGregory Neil Shapiro<PRE>
1340266059SGregory Neil Shapiro#include &lt;libmilter/mfapi.h&gt;
1440266059SGregory Neil Shapiroint smfi_addheader(
1540266059SGregory Neil Shapiro	SMFICTX *ctx,
1640266059SGregory Neil Shapiro	char *headerf,
1740266059SGregory Neil Shapiro	char *headerv
1840266059SGregory Neil Shapiro);
19d0cef73dSGregory Neil Shapiro</PRE>
2040266059SGregory Neil ShapiroAdd a header to the current message.
21d0cef73dSGregory Neil Shapiro</TD></TR>
2240266059SGregory Neil Shapiro
2340266059SGregory Neil Shapiro<!----------- Description ---------->
24d0cef73dSGregory Neil Shapiro<TR><TH valign="top" align=left>DESCRIPTION</TH><TD>
25d0cef73dSGregory Neil Shapiro<TABLE border="1" cellspacing=1 cellpadding=4>
26d0cef73dSGregory Neil Shapiro<TR align="left" valign=top>
27d0cef73dSGregory Neil Shapiro<TH width="80">Called When</TH>
28d0cef73dSGregory Neil Shapiro<TD>Called only from <A href="xxfi_eom.html">xxfi_eom</A>.</TD>
29d0cef73dSGregory Neil Shapiro</TR>
30d0cef73dSGregory Neil Shapiro<TR align="left" valign=top>
31d0cef73dSGregory Neil Shapiro<TH width="80">Effects</TH>
32d0cef73dSGregory Neil Shapiro<TD>Adds a header to the current message.</TD>
33d0cef73dSGregory Neil Shapiro</TR>
34d0cef73dSGregory Neil Shapiro</TABLE>
35*5b0945b5SGregory Neil Shapiro</TD></TR>
3640266059SGregory Neil Shapiro
3740266059SGregory Neil Shapiro<!----------- Arguments ---------->
38d0cef73dSGregory Neil Shapiro<TR><TH valign="top" align=left>ARGUMENTS</TH><TD>
39d0cef73dSGregory Neil Shapiro    <TABLE border="1" cellspacing=0>
40d0cef73dSGregory Neil Shapiro    <TR bgcolor="#dddddd"><TH>Argument</TH><TH>Description</TH></TR>
41d0cef73dSGregory Neil Shapiro    <TR valign="top"><TD>ctx</TD>
42d0cef73dSGregory Neil Shapiro	<TD>Opaque context structure.
43d0cef73dSGregory Neil Shapiro	</TD></TR>
44d0cef73dSGregory Neil Shapiro    <TR valign="top"><TD>headerf</TD>
45d0cef73dSGregory Neil Shapiro	<TD>The header name, a non-NULL, null-terminated string.
46d0cef73dSGregory Neil Shapiro	</TD></TR>
47d0cef73dSGregory Neil Shapiro    <TR valign="top"><TD>headerv</TD>
48d0cef73dSGregory Neil Shapiro	<TD>The header value to be added, a non-NULL, null-terminated string.
49d0cef73dSGregory Neil Shapiro	This may be the empty string.
50d0cef73dSGregory Neil Shapiro	</TD></TR>
51d0cef73dSGregory Neil Shapiro    </TABLE>
52d0cef73dSGregory Neil Shapiro</TD></TR>
5340266059SGregory Neil Shapiro
5440266059SGregory Neil Shapiro<!----------- Return values ---------->
55d0cef73dSGregory Neil Shapiro<TR>
56d0cef73dSGregory Neil Shapiro<TH valign="top" align=left>RETURN VALUES</TH>
5740266059SGregory Neil Shapiro
58d0cef73dSGregory Neil Shapiro<TD>smfi_addheader returns MI_FAILURE if:
59d0cef73dSGregory Neil Shapiro<UL><LI>headerf or headerv is NULL.
60d0cef73dSGregory Neil Shapiro    <LI>Adding headers in the current connection state is invalid.
61d0cef73dSGregory Neil Shapiro    <LI>Memory allocation fails.
62d0cef73dSGregory Neil Shapiro    <LI>A network error occurs.
63*5b0945b5SGregory Neil Shapiro    <LI><A HREF="smfi_register.html#SMFIF_ADDHDRS">SMFIF_ADDHDRS</A> is not set.
64d0cef73dSGregory Neil Shapiro</UL>
6540266059SGregory Neil ShapiroOtherwise, it returns MI_SUCCESS.
66d0cef73dSGregory Neil Shapiro</TD>
67d0cef73dSGregory Neil Shapiro</TR>
6840266059SGregory Neil Shapiro
6940266059SGregory Neil Shapiro<!----------- Notes ---------->
70d0cef73dSGregory Neil Shapiro<TR align="left" valign=top>
71d0cef73dSGregory Neil Shapiro<TH>NOTES</TH>
72d0cef73dSGregory Neil Shapiro<TD>
73d0cef73dSGregory Neil Shapiro<UL><LI>smfi_addheader does not change a message's existing headers.
74d0cef73dSGregory Neil ShapiroTo change a header's current value, use
75d0cef73dSGregory Neil Shapiro<A HREF="smfi_chgheader.html">smfi_chgheader</A>.
76*5b0945b5SGregory Neil Shapiro    <LI>A filter which calls smfi_addheader must have set the
77*5b0945b5SGregory Neil Shapiro        <A HREF="smfi_register.html#SMFIF_ADDHDRS">SMFIF_ADDHDRS</A> flag.
78d0cef73dSGregory Neil Shapiro    <LI>For smfi_addheader, filter order is important.
79d0cef73dSGregory Neil Shapiro	<B>Later filters will see the header changes made by earlier ones.</B>
80d0cef73dSGregory Neil Shapiro    <LI>Neither the name nor the value of the header is checked for
81d0cef73dSGregory Neil Shapiro    standards compliance.
82d0cef73dSGregory Neil Shapiro    However, each line of the header must be under 2048 characters
83d0cef73dSGregory Neil Shapiro    and should be under 998 characters.
84d0cef73dSGregory Neil Shapiro    If longer headers are needed, make them multi-line.
85d0cef73dSGregory Neil Shapiro    To make a multi-line header,
86d0cef73dSGregory Neil Shapiro    insert a line feed (ASCII 0x0a, or <TT>\n</TT> in C)
87d0cef73dSGregory Neil Shapiro    followed by at least one whitespace character
88d0cef73dSGregory Neil Shapiro    such as a space (ASCII 0x20) or tab (ASCII 0x09, or <TT>\t</TT> in C).
89d0cef73dSGregory Neil Shapiro    The line feed should NOT be preceded by a carriage return (ASCII 0x0d);
90d0cef73dSGregory Neil Shapiro    the MTA will add this automatically.
91d0cef73dSGregory Neil Shapiro    <B>It is the filter writer's responsibility to ensure that no standards
92d0cef73dSGregory Neil Shapiro    are violated.</B>
939bd497b8SGregory Neil Shapiro    <LI>The MTA adds a leading space to an added header value unless
949bd497b8SGregory Neil Shapiro    the flag
959bd497b8SGregory Neil Shapiro<A HREF="xxfi_negotiate.html#SMFIP_HDR_LEADSPC"><CODE>SMFIP_HDR_LEADSPC</CODE></A>
969bd497b8SGregory Neil Shapiro    is set, in which case the milter
979bd497b8SGregory Neil Shapiro    must include any desired leading spaces itself.
98d0cef73dSGregory Neil Shapiro</UL>
99d0cef73dSGregory Neil Shapiro</TD>
100d0cef73dSGregory Neil Shapiro</TR>
10140266059SGregory Neil Shapiro
10294c01205SGregory Neil Shapiro<!----------- Example code ---------->
103d0cef73dSGregory Neil Shapiro<TR>
104d0cef73dSGregory Neil Shapiro<TH valign="top" align=left>EXAMPLE</TH>
10594c01205SGregory Neil Shapiro
106d0cef73dSGregory Neil Shapiro<TD>
107d0cef73dSGregory Neil Shapiro <PRE>
10894c01205SGregory Neil Shapiro  int ret;
10994c01205SGregory Neil Shapiro  SMFICTX *ctx;
11094c01205SGregory Neil Shapiro
11194c01205SGregory Neil Shapiro  ...
11294c01205SGregory Neil Shapiro
11394c01205SGregory Neil Shapiro  ret = smfi_addheader(ctx, "Content-Type",
11494c01205SGregory Neil Shapiro                       "multipart/mixed;\n\tboundary=\"foobar\"");
115d0cef73dSGregory Neil Shapiro </PRE>
116d0cef73dSGregory Neil Shapiro</TD>
117d0cef73dSGregory Neil Shapiro</TR>
11894c01205SGregory Neil Shapiro
119d0cef73dSGregory Neil Shapiro</TABLE>
12040266059SGregory Neil Shapiro
121d0cef73dSGregory Neil Shapiro<HR size="1">
122d0cef73dSGregory Neil Shapiro<FONT size="-1">
1235dd76dd0SGregory Neil ShapiroCopyright (c) 2000-2003, 2006, 2009 Proofpoint, Inc. and its suppliers.
12440266059SGregory Neil ShapiroAll rights reserved.
125d0cef73dSGregory Neil Shapiro<BR>
12640266059SGregory Neil ShapiroBy using this file, you agree to the terms and conditions set
1275ef517c0SGregory Neil Shapiroforth in the LICENSE.
128d0cef73dSGregory Neil Shapiro</FONT>
129d0cef73dSGregory Neil Shapiro</BODY>
130d0cef73dSGregory Neil Shapiro</HTML>
131