xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_addheader.html (revision e92d3f3ffe83a6ed7eaafac70da9cf4fafe13243)
140266059SGregory Neil Shapiro<html>
240266059SGregory Neil Shapiro<head><title>smfi_addheader</title></head>
340266059SGregory Neil Shapiro<body>
4e92d3f3fSGregory Neil Shapiro<!--
5e92d3f3fSGregory Neil Shapiro$Id: smfi_addheader.html,v 1.15 2004/05/04 17:55:50 ca Exp $
6e92d3f3fSGregory Neil Shapiro-->
740266059SGregory Neil Shapiro<h1>smfi_addheader</h1>
840266059SGregory Neil Shapiro
940266059SGregory Neil Shapiro<table border="0" cellspacing=4 cellpadding=4>
1040266059SGregory Neil Shapiro<!---------- Synopsis ----------->
1140266059SGregory Neil Shapiro<tr><th valign="top" align=left width=150>SYNOPSIS</th><td>
1240266059SGregory 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);
1940266059SGregory Neil Shapiro</pre>
2040266059SGregory Neil ShapiroAdd a header to the current message.
2140266059SGregory Neil Shapiro</td></tr>
2240266059SGregory Neil Shapiro
2340266059SGregory Neil Shapiro<!----------- Description ---------->
2440266059SGregory Neil Shapiro<tr><th valign="top" align=left>DESCRIPTION</th><td>
2540266059SGregory Neil Shapiro<table border="1" cellspacing=1 cellpadding=4>
2640266059SGregory Neil Shapiro<tr align="left" valign=top>
2740266059SGregory Neil Shapiro<th width="80">Called When</th>
2840266059SGregory Neil Shapiro<td>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td>
2940266059SGregory Neil Shapiro</tr>
3040266059SGregory Neil Shapiro<tr align="left" valign=top>
3140266059SGregory Neil Shapiro<th width="80">Effects</th>
3240266059SGregory Neil Shapiro<td>Adds a header to the current message.</td>
3340266059SGregory Neil Shapiro</tr>
3440266059SGregory Neil Shapiro</table>
3540266059SGregory Neil Shapiro
3640266059SGregory Neil Shapiro<!----------- Arguments ---------->
3740266059SGregory Neil Shapiro<tr><th valign="top" align=left>ARGUMENTS</th><td>
3840266059SGregory Neil Shapiro    <table border="1" cellspacing=0>
3940266059SGregory Neil Shapiro    <tr bgcolor="#dddddd"><th>Argument</th><th>Description</th></tr>
4040266059SGregory Neil Shapiro    <tr valign="top"><td>ctx</td>
4140266059SGregory Neil Shapiro	<td>Opaque context structure.
4240266059SGregory Neil Shapiro	</td></tr>
4340266059SGregory Neil Shapiro    <tr valign="top"><td>headerf</td>
4440266059SGregory Neil Shapiro	<td>The header name, a non-NULL, null-terminated string.
4540266059SGregory Neil Shapiro	</td></tr>
4640266059SGregory Neil Shapiro    <tr valign="top"><td>headerv</td>
4740266059SGregory Neil Shapiro	<td>The header value to be added, a non-NULL, null-terminated string.  This may be the empty string.
4840266059SGregory Neil Shapiro	</td></tr>
4940266059SGregory Neil Shapiro    </table>
5040266059SGregory Neil Shapiro</td></tr>
5140266059SGregory Neil Shapiro
5240266059SGregory Neil Shapiro<!----------- Return values ---------->
5340266059SGregory Neil Shapiro<tr>
5440266059SGregory Neil Shapiro<th valign="top" align=left>RETURN VALUES</th>
5540266059SGregory Neil Shapiro
5640266059SGregory Neil Shapiro<td>smfi_addheader returns MI_FAILURE if:
5740266059SGregory Neil Shapiro<ul><li>headerf or headerv is NULL.
5840266059SGregory Neil Shapiro    <li>Adding headers in the current connection state is invalid.
5940266059SGregory Neil Shapiro    <li>Memory allocation fails.
6040266059SGregory Neil Shapiro    <li>A network error occurs.
6140266059SGregory Neil Shapiro    <li>SMFIF_ADDHDRS was not set when <a href="smfi_register.html">smfi_register</a> was called.
6240266059SGregory Neil Shapiro</ul>
6340266059SGregory Neil ShapiroOtherwise, it returns MI_SUCCESS.
6440266059SGregory Neil Shapiro</td>
6540266059SGregory Neil Shapiro</tr>
6640266059SGregory Neil Shapiro
6740266059SGregory Neil Shapiro<!----------- Notes ---------->
6840266059SGregory Neil Shapiro<tr align="left" valign=top>
6940266059SGregory Neil Shapiro<th>NOTES</th>
7040266059SGregory Neil Shapiro<td>
7140266059SGregory Neil Shapiro<ul><li>smfi_addheader does not change a message's existing headers.
7240266059SGregory Neil ShapiroTo change a header's current value, use <a
7340266059SGregory Neil Shapirohref="smfi_chgheader.html">smfi_chgheader</a>.
7440266059SGregory Neil Shapiro    <li>A filter which calls smfi_addheader must have set the SMFIF_ADDHDRS flag in the smfiDesc_str passed to <a href="smfi_register.html">smfi_register</a>.
75e92d3f3fSGregory Neil Shapiro    <li>For smfi_addheader, filter order is important.  <b>Later filters will see the header changes made by earlier ones.</b>
7640266059SGregory Neil Shapiro    <li>Neither the name nor the value of the header is checked for
7740266059SGregory Neil Shapiro    standards compliance.  However, each line of the header must be under
7840266059SGregory Neil Shapiro    2048 characters and should be under 998 characters.  If longer headers
7994c01205SGregory Neil Shapiro    are needed, make them multi-line.  To make a multi-line header, insert
8094c01205SGregory Neil Shapiro    a line feed (ASCII 0x0a, or <tt>\n</tt> in C) followed by at least
8194c01205SGregory Neil Shapiro    one whitespace character such as a space (ASCII 0x20) or tab (ASCII 0x09,
8294c01205SGregory Neil Shapiro    or <tt>\t</tt> in C).  The line feed should NOT be preceded by a
8394c01205SGregory Neil Shapiro    carriage return (ASCII 0x0d); the MTA will add this automatically.
8440266059SGregory Neil Shapiro    <b>It is the filter writer's responsibility to ensure that no standards
8540266059SGregory Neil Shapiro    are violated.</b>
8640266059SGregory Neil Shapiro</ul>
8740266059SGregory Neil Shapiro</td>
8840266059SGregory Neil Shapiro</tr>
8940266059SGregory Neil Shapiro
9094c01205SGregory Neil Shapiro<!----------- Example code ---------->
9194c01205SGregory Neil Shapiro<tr>
9294c01205SGregory Neil Shapiro<th valign="top" align=left>EXAMPLE</th>
9394c01205SGregory Neil Shapiro
9494c01205SGregory Neil Shapiro<td>
9594c01205SGregory Neil Shapiro <pre>
9694c01205SGregory Neil Shapiro  int ret;
9794c01205SGregory Neil Shapiro  SMFICTX *ctx;
9894c01205SGregory Neil Shapiro
9994c01205SGregory Neil Shapiro  ...
10094c01205SGregory Neil Shapiro
10194c01205SGregory Neil Shapiro  ret = smfi_addheader(ctx, "Content-Type",
10294c01205SGregory Neil Shapiro                       "multipart/mixed;\n\tboundary=\"foobar\"");
10394c01205SGregory Neil Shapiro </pre>
10494c01205SGregory Neil Shapiro</td>
10594c01205SGregory Neil Shapiro</tr>
10694c01205SGregory Neil Shapiro
10740266059SGregory Neil Shapiro</table>
10840266059SGregory Neil Shapiro
10940266059SGregory Neil Shapiro<hr size="1">
11040266059SGregory Neil Shapiro<font size="-1">
1115ef517c0SGregory Neil ShapiroCopyright (c) 2000-2003 Sendmail, Inc. and its suppliers.
11240266059SGregory Neil ShapiroAll rights reserved.
11340266059SGregory Neil Shapiro<br>
11440266059SGregory Neil ShapiroBy using this file, you agree to the terms and conditions set
1155ef517c0SGregory Neil Shapiroforth in the LICENSE.
11640266059SGregory Neil Shapiro</font>
11740266059SGregory Neil Shapiro</body>
11840266059SGregory Neil Shapiro</html>
119