xref: /freebsd/contrib/sendmail/libmilter/docs/smfi_chgheader.html (revision a7ec597c92be37562e4f76e105eeb7a3ba64d81a)
140266059SGregory Neil Shapiro<html>
240266059SGregory Neil Shapiro<head><title>smfi_chgheader</title></head>
340266059SGregory Neil Shapiro<body>
440266059SGregory Neil Shapiro<h1>smfi_chgheader</h1>
540266059SGregory Neil Shapiro
640266059SGregory Neil Shapiro<table border="0" cellspacing=4 cellpadding=4>
740266059SGregory Neil Shapiro<!---------- Synopsis ----------->
840266059SGregory Neil Shapiro<tr><th valign="top" align=left width=150>SYNOPSIS</th><td>
940266059SGregory Neil Shapiro<pre>
1040266059SGregory Neil Shapiro#include &lt;libmilter/mfapi.h&gt;
1140266059SGregory Neil Shapiroint smfi_chgheader(
1240266059SGregory Neil Shapiro	SMFICTX *ctx,
1340266059SGregory Neil Shapiro	char *headerf,
1440266059SGregory Neil Shapiro	mi_int32 hdridx,
1540266059SGregory Neil Shapiro	char *headerv
1640266059SGregory Neil Shapiro);
1740266059SGregory Neil Shapiro</pre>
1840266059SGregory Neil ShapiroChange or delete a message header.
1940266059SGregory Neil Shapiro</td></tr>
2040266059SGregory Neil Shapiro
2140266059SGregory Neil Shapiro<!----------- Description ---------->
2240266059SGregory Neil Shapiro<tr><th valign="top" align=left>DESCRIPTION</th><td>
2340266059SGregory Neil Shapiro<table border="1" cellspacing=1 cellpadding=4>
2440266059SGregory Neil Shapiro<tr align="left" valign=top>
2540266059SGregory Neil Shapiro<th width="80">Called When</th>
2640266059SGregory Neil Shapiro<td>Called only from <a href="xxfi_eom.html">xxfi_eom</a>.</td>
2740266059SGregory Neil Shapiro</tr>
2840266059SGregory Neil Shapiro<tr align="left" valign=top>
2940266059SGregory Neil Shapiro<th width="80">Effects</th>
3040266059SGregory Neil Shapiro<td>Changes a header's value for the current message.</td>
3140266059SGregory Neil Shapiro</tr>
3240266059SGregory Neil Shapiro</table>
3340266059SGregory Neil Shapiro
3440266059SGregory Neil Shapiro<!----------- Arguments ---------->
3540266059SGregory Neil Shapiro<tr><th valign="top" align=left>ARGUMENTS</th><td>
3640266059SGregory Neil Shapiro    <table border="1" cellspacing=0>
3740266059SGregory Neil Shapiro    <tr bgcolor="#dddddd"><th>Argument</th><th>Description</th></tr>
3840266059SGregory Neil Shapiro    <tr valign="top"><td>ctx</td>
3940266059SGregory Neil Shapiro	<td>Opaque context structure.
4040266059SGregory Neil Shapiro	</td></tr>
4140266059SGregory Neil Shapiro    <tr valign="top"><td>headerf</td>
4240266059SGregory Neil Shapiro	<td>The header name, a non-NULL, null-terminated string.
4340266059SGregory Neil Shapiro	</td></tr>
4440266059SGregory Neil Shapiro    <tr valign="top"><td>hdridx</td>
4540266059SGregory Neil Shapiro	<td>Header index value (1-based). A hdridx value of 1 will modify the first occurrence of a header named headerf.  If hdridx is greater than the number of times headerf appears, a new copy of headerf will be added.
4640266059SGregory Neil Shapiro	</td></tr>
4740266059SGregory Neil Shapiro    <tr valign="top"><td>headerv</td>
4840266059SGregory Neil Shapiro	<td>The new value of the given header.  headerv == NULL implies that the header should be deleted.
4940266059SGregory Neil Shapiro	</td></tr>
5040266059SGregory Neil Shapiro    </table>
5140266059SGregory Neil Shapiro</td></tr>
5240266059SGregory Neil Shapiro
5340266059SGregory Neil Shapiro<!----------- Return values ---------->
5440266059SGregory Neil Shapiro<tr>
5540266059SGregory Neil Shapiro<th valign="top" align=left>RETURN VALUES</th>
5640266059SGregory Neil Shapiro
5740266059SGregory Neil Shapiro<td>
5840266059SGregory Neil Shapirosmfi_chgheader will return MI_FAILURE if
5940266059SGregory Neil Shapiro<ul><li>headerf is NULL
6040266059SGregory Neil Shapiro    <li>Modifying headers in the current connection state is invalid.
6140266059SGregory Neil Shapiro    <li>Memory allocation fails.
6240266059SGregory Neil Shapiro    <li>A network error occurs.
6340266059SGregory Neil Shapiro    <li>SMFIF_CHGHDRS was not set when <a href="smfi_register.html">smfi_register</a> was called.
6440266059SGregory Neil Shapiro</ul>
6540266059SGregory Neil ShapiroOtherwise, it returns MI_SUCCESS.
6640266059SGregory Neil Shapiro</tr>
6740266059SGregory Neil Shapiro
6840266059SGregory Neil Shapiro<!----------- Notes ---------->
6940266059SGregory Neil Shapiro<tr align="left" valign=top>
7040266059SGregory Neil Shapiro<th>NOTES</th>
7140266059SGregory Neil Shapiro<td>
7240266059SGregory Neil Shapiro<ul><li>While smfi_chgheader may be used to add new headers, it is more efficient and far safer to use <a href="smfi_addheader.html">smfi_addheader</a>.
7340266059SGregory Neil Shapiro    <li>A filter which calls smfi_chgheader must have set the SMFIF_CHGHDRS flag in the smfiDesc_str passed to <a href="smfi_register.html">smfi_register</a>.
7440266059SGregory Neil Shapiro    <li>For smfi_chgheader, filter order is important.  <b>Later filters will see the header changes made by earlier ones.</b>
7540266059SGregory Neil Shapiro    <li>Neither the name nor the value of the header is checked for
7640266059SGregory Neil Shapiro    standards compliance.  However, each line of the header must be under
7740266059SGregory Neil Shapiro    2048 characters and should be under 998 characters.  If longer headers
7894c01205SGregory Neil Shapiro    are needed, make them multi-line.  To make a multi-line header, insert
7994c01205SGregory Neil Shapiro    a line feed (ASCII 0x0a, or <tt>\n</tt> in C) followed by at least
8094c01205SGregory Neil Shapiro    one whitespace character such as a space (ASCII 0x20) or tab (ASCII 0x09,
8194c01205SGregory Neil Shapiro    or <tt>\t</tt> in C).  The line feed should NOT be preceded by a
8294c01205SGregory Neil Shapiro    carriage return (ASCII 0x0d); the MTA will add this automatically.
8340266059SGregory Neil Shapiro    <b>It is the filter writer's responsibility to ensure that no standards
8440266059SGregory Neil Shapiro    are violated.</b>
8540266059SGregory Neil Shapiro</ul>
8640266059SGregory Neil Shapiro</td>
8740266059SGregory Neil Shapiro</tr>
8840266059SGregory Neil Shapiro
8994c01205SGregory Neil Shapiro<!----------- Example code ---------->
9094c01205SGregory Neil Shapiro<tr>
9194c01205SGregory Neil Shapiro<th valign="top" align=left>EXAMPLE</th>
9294c01205SGregory Neil Shapiro
9394c01205SGregory Neil Shapiro<td>
9494c01205SGregory Neil Shapiro <pre>
9594c01205SGregory Neil Shapiro  int ret;
9694c01205SGregory Neil Shapiro  SMFICTX *ctx;
9794c01205SGregory Neil Shapiro
9894c01205SGregory Neil Shapiro  ...
9994c01205SGregory Neil Shapiro
100a7ec597cSGregory Neil Shapiro  ret = smfi_chgheader(ctx, "Content-Type", 1,
10194c01205SGregory Neil Shapiro                       "multipart/mixed;\n\tboundary=\"foobar\"");
10294c01205SGregory Neil Shapiro </pre>
10394c01205SGregory Neil Shapiro</td>
10494c01205SGregory Neil Shapiro</tr>
10594c01205SGregory Neil Shapiro
10640266059SGregory Neil Shapiro</table>
10740266059SGregory Neil Shapiro
10840266059SGregory Neil Shapiro<hr size="1">
10940266059SGregory Neil Shapiro<font size="-1">
1105ef517c0SGregory Neil ShapiroCopyright (c) 2000-2003 Sendmail, Inc. and its suppliers.
11140266059SGregory Neil ShapiroAll rights reserved.
11240266059SGregory Neil Shapiro<br>
11340266059SGregory Neil ShapiroBy using this file, you agree to the terms and conditions set
1145ef517c0SGregory Neil Shapiroforth in the LICENSE.
11540266059SGregory Neil Shapiro</font>
11640266059SGregory Neil Shapiro</body>
11740266059SGregory Neil Shapiro</html>
118