smfi_replacebody Function


The smfi_replacebody function replaces the body of the message.


#include <libmilter/mfapi.h>
int smfi_replacebody(
	SMFICTX *ctx,
	unsigned char *bodyp,
	int bodylen


The smfi_replacebody function replaces the body of the current message. If the function is called more than once, the subsequent calls results in data being appended to the new body. The function might be called more than once.

Because the message body might be large, setting the SMFIF_CHGBODY flag might significantly affect the filter performance.

If a filter sets the SMFIF_CHGBODY flag, but does not call the smfi_replacebody function, the original body remains unchanged.

Filter order is important for the smfi_replacebody function. New body contents is created by old filters in the new filter files.


Table 1. Arguments
Item Description
ctx The opaque context structure is maintained in the libmilter parameter.
bodyp A pointer to the start of the new body data, which does not have to be null-terminated. If the bodyp is NULL, it is treated as having length == 0. The body data should be in CR or LF form.
bodylen The number of data bytes pointed to by bodyp.

Return values

The smfi_replacebody function returns the MI_FAILURE value in the following cases. Otherwise the function returns MI_SUCCESS.
  • bodyp == NULL and bodylen > 0
  • Changing the body in the current connection state is invalid.
  • A network error occurs.
  • The SMFIF_CHGBODY flag was not set when the smfi_register function was called.

Related information