xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_addheader.html (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1<HTML>
2<HEAD><TITLE>smfi_addheader</TITLE></HEAD>
3<BODY>
4<!--
5$Id: smfi_addheader.html,v 1.21 2013-11-22 20:51:39 ca Exp $
6-->
7<H1>smfi_addheader</H1>
8
9<TABLE border="0" cellspacing=4 cellpadding=4>
10<!---------- Synopsis ----------->
11<TR><TH valign="top" align=left width=100>SYNOPSIS</TH><TD>
12<PRE>
13#include &lt;libmilter/mfapi.h&gt;
14int smfi_addheader(
15	SMFICTX *ctx,
16	char *headerf,
17	char *headerv
18);
19</PRE>
20Add a header to the current message.
21</TD></TR>
22
23<!----------- Description ---------->
24<TR><TH valign="top" align=left>DESCRIPTION</TH><TD>
25<TABLE border="1" cellspacing=1 cellpadding=4>
26<TR align="left" valign=top>
27<TH width="80">Called When</TH>
28<TD>Called only from <A href="xxfi_eom.html">xxfi_eom</A>.</TD>
29</TR>
30<TR align="left" valign=top>
31<TH width="80">Effects</TH>
32<TD>Adds a header to the current message.</TD>
33</TR>
34</TABLE>
35</TD></TR>
36
37<!----------- Arguments ---------->
38<TR><TH valign="top" align=left>ARGUMENTS</TH><TD>
39    <TABLE border="1" cellspacing=0>
40    <TR bgcolor="#dddddd"><TH>Argument</TH><TH>Description</TH></TR>
41    <TR valign="top"><TD>ctx</TD>
42	<TD>Opaque context structure.
43	</TD></TR>
44    <TR valign="top"><TD>headerf</TD>
45	<TD>The header name, a non-NULL, null-terminated string.
46	</TD></TR>
47    <TR valign="top"><TD>headerv</TD>
48	<TD>The header value to be added, a non-NULL, null-terminated string.
49	This may be the empty string.
50	</TD></TR>
51    </TABLE>
52</TD></TR>
53
54<!----------- Return values ---------->
55<TR>
56<TH valign="top" align=left>RETURN VALUES</TH>
57
58<TD>smfi_addheader returns MI_FAILURE if:
59<UL><LI>headerf or headerv is NULL.
60    <LI>Adding headers in the current connection state is invalid.
61    <LI>Memory allocation fails.
62    <LI>A network error occurs.
63    <LI><A HREF="smfi_register.html#SMFIF_ADDHDRS">SMFIF_ADDHDRS</A> is not set.
64</UL>
65Otherwise, it returns MI_SUCCESS.
66</TD>
67</TR>
68
69<!----------- Notes ---------->
70<TR align="left" valign=top>
71<TH>NOTES</TH>
72<TD>
73<UL><LI>smfi_addheader does not change a message's existing headers.
74To change a header's current value, use
75<A HREF="smfi_chgheader.html">smfi_chgheader</A>.
76    <LI>A filter which calls smfi_addheader must have set the
77        <A HREF="smfi_register.html#SMFIF_ADDHDRS">SMFIF_ADDHDRS</A> flag.
78    <LI>For smfi_addheader, filter order is important.
79	<B>Later filters will see the header changes made by earlier ones.</B>
80    <LI>Neither the name nor the value of the header is checked for
81    standards compliance.
82    However, each line of the header must be under 2048 characters
83    and should be under 998 characters.
84    If longer headers are needed, make them multi-line.
85    To make a multi-line header,
86    insert a line feed (ASCII 0x0a, or <TT>\n</TT> in C)
87    followed by at least one whitespace character
88    such as a space (ASCII 0x20) or tab (ASCII 0x09, or <TT>\t</TT> in C).
89    The line feed should NOT be preceded by a carriage return (ASCII 0x0d);
90    the MTA will add this automatically.
91    <B>It is the filter writer's responsibility to ensure that no standards
92    are violated.</B>
93    <LI>The MTA adds a leading space to an added header value unless
94    the flag
95<A HREF="xxfi_negotiate.html#SMFIP_HDR_LEADSPC"><CODE>SMFIP_HDR_LEADSPC</CODE></A>
96    is set, in which case the milter
97    must include any desired leading spaces itself.
98</UL>
99</TD>
100</TR>
101
102<!----------- Example code ---------->
103<TR>
104<TH valign="top" align=left>EXAMPLE</TH>
105
106<TD>
107 <PRE>
108  int ret;
109  SMFICTX *ctx;
110
111  ...
112
113  ret = smfi_addheader(ctx, "Content-Type",
114                       "multipart/mixed;\n\tboundary=\"foobar\"");
115 </PRE>
116</TD>
117</TR>
118
119</TABLE>
120
121<HR size="1">
122<FONT size="-1">
123Copyright (c) 2000-2003, 2006, 2009 Proofpoint, Inc. and its suppliers.
124All rights reserved.
125<BR>
126By using this file, you agree to the terms and conditions set
127forth in the LICENSE.
128</FONT>
129</BODY>
130</HTML>
131