1d0cef73dSGregory Neil Shapiro<HTML> 2d0cef73dSGregory Neil Shapiro<HEAD><TITLE>smfi_addheader</TITLE></HEAD> 3d0cef73dSGregory Neil Shapiro<BODY> 4e92d3f3fSGregory Neil Shapiro<!-- 5d0cef73dSGregory Neil Shapiro$Id: smfi_addheader.html,v 1.19 2006/12/21 18:30:35 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 <libmilter/mfapi.h> 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> 3540266059SGregory Neil Shapiro 3640266059SGregory Neil Shapiro<!----------- Arguments ----------> 37d0cef73dSGregory Neil Shapiro<TR><TH valign="top" align=left>ARGUMENTS</TH><TD> 38d0cef73dSGregory Neil Shapiro <TABLE border="1" cellspacing=0> 39d0cef73dSGregory Neil Shapiro <TR bgcolor="#dddddd"><TH>Argument</TH><TH>Description</TH></TR> 40d0cef73dSGregory Neil Shapiro <TR valign="top"><TD>ctx</TD> 41d0cef73dSGregory Neil Shapiro <TD>Opaque context structure. 42d0cef73dSGregory Neil Shapiro </TD></TR> 43d0cef73dSGregory Neil Shapiro <TR valign="top"><TD>headerf</TD> 44d0cef73dSGregory Neil Shapiro <TD>The header name, a non-NULL, null-terminated string. 45d0cef73dSGregory Neil Shapiro </TD></TR> 46d0cef73dSGregory Neil Shapiro <TR valign="top"><TD>headerv</TD> 47d0cef73dSGregory Neil Shapiro <TD>The header value to be added, a non-NULL, null-terminated string. 48d0cef73dSGregory Neil Shapiro This may be the empty string. 49d0cef73dSGregory Neil Shapiro </TD></TR> 50d0cef73dSGregory Neil Shapiro </TABLE> 51d0cef73dSGregory Neil Shapiro</TD></TR> 5240266059SGregory Neil Shapiro 5340266059SGregory Neil Shapiro<!----------- Return values ----------> 54d0cef73dSGregory Neil Shapiro<TR> 55d0cef73dSGregory Neil Shapiro<TH valign="top" align=left>RETURN VALUES</TH> 5640266059SGregory Neil Shapiro 57d0cef73dSGregory Neil Shapiro<TD>smfi_addheader returns MI_FAILURE if: 58d0cef73dSGregory Neil Shapiro<UL><LI>headerf or headerv is NULL. 59d0cef73dSGregory Neil Shapiro <LI>Adding headers in the current connection state is invalid. 60d0cef73dSGregory Neil Shapiro <LI>Memory allocation fails. 61d0cef73dSGregory Neil Shapiro <LI>A network error occurs. 62d0cef73dSGregory Neil Shapiro <LI>SMFIF_ADDHDRS was not set when <A href="smfi_register.html">smfi_register</A> was called. 63d0cef73dSGregory Neil Shapiro</UL> 6440266059SGregory Neil ShapiroOtherwise, it returns MI_SUCCESS. 65d0cef73dSGregory Neil Shapiro</TD> 66d0cef73dSGregory Neil Shapiro</TR> 6740266059SGregory Neil Shapiro 6840266059SGregory Neil Shapiro<!----------- Notes ----------> 69d0cef73dSGregory Neil Shapiro<TR align="left" valign=top> 70d0cef73dSGregory Neil Shapiro<TH>NOTES</TH> 71d0cef73dSGregory Neil Shapiro<TD> 72d0cef73dSGregory Neil Shapiro<UL><LI>smfi_addheader does not change a message's existing headers. 73d0cef73dSGregory Neil ShapiroTo change a header's current value, use 74d0cef73dSGregory Neil Shapiro<A HREF="smfi_chgheader.html">smfi_chgheader</A>. 75d0cef73dSGregory Neil Shapiro <LI>A filter which calls smfi_addheader must have set the SMFIF_ADDHDRS 76d0cef73dSGregory Neil Shapiro flag in the smfiDesc_str passed to 77d0cef73dSGregory Neil Shapiro <A href="smfi_register.html">smfi_register</A>. 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> 93d0cef73dSGregory Neil Shapiro <LI>The MTA adds a leading space to an added header value. 94d0cef73dSGregory Neil Shapiro</UL> 95d0cef73dSGregory Neil Shapiro</TD> 96d0cef73dSGregory Neil Shapiro</TR> 9740266059SGregory Neil Shapiro 9894c01205SGregory Neil Shapiro<!----------- Example code ----------> 99d0cef73dSGregory Neil Shapiro<TR> 100d0cef73dSGregory Neil Shapiro<TH valign="top" align=left>EXAMPLE</TH> 10194c01205SGregory Neil Shapiro 102d0cef73dSGregory Neil Shapiro<TD> 103d0cef73dSGregory Neil Shapiro <PRE> 10494c01205SGregory Neil Shapiro int ret; 10594c01205SGregory Neil Shapiro SMFICTX *ctx; 10694c01205SGregory Neil Shapiro 10794c01205SGregory Neil Shapiro ... 10894c01205SGregory Neil Shapiro 10994c01205SGregory Neil Shapiro ret = smfi_addheader(ctx, "Content-Type", 11094c01205SGregory Neil Shapiro "multipart/mixed;\n\tboundary=\"foobar\""); 111d0cef73dSGregory Neil Shapiro </PRE> 112d0cef73dSGregory Neil Shapiro</TD> 113d0cef73dSGregory Neil Shapiro</TR> 11494c01205SGregory Neil Shapiro 115d0cef73dSGregory Neil Shapiro</TABLE> 11640266059SGregory Neil Shapiro 117d0cef73dSGregory Neil Shapiro<HR size="1"> 118d0cef73dSGregory Neil Shapiro<FONT size="-1"> 119d0cef73dSGregory Neil ShapiroCopyright (c) 2000-2003, 2006 Sendmail, Inc. and its suppliers. 12040266059SGregory Neil ShapiroAll rights reserved. 121d0cef73dSGregory Neil Shapiro<BR> 12240266059SGregory Neil ShapiroBy using this file, you agree to the terms and conditions set 1235ef517c0SGregory Neil Shapiroforth in the LICENSE. 124d0cef73dSGregory Neil Shapiro</FONT> 125d0cef73dSGregory Neil Shapiro</BODY> 126d0cef73dSGregory Neil Shapiro</HTML> 127