Sun Java System Messaging Server 6 2005Q4 MTA Developer's Reference

mtaEnqueueWriteLine()

Write a complete, single line of message data to the message being submitted.

Syntax


int mtaEnqueueWrite(mta_nq_t    *nq_ctx,
                    const char  *str1,
                    size_t       len1,
                    const char  *str2, ...);

Zero or more string pointer-length pairs can be supplied to this routine. The list of pairs must be terminated by a NULL call argument.

Arguments

Arguments  

Description  

nq_ctx

Pointer to an enqueue context created with mtaEnqueueStart().

str1

Pointer to a string of text to write to the message. The string must be NULL terminated if a value of zero is passed for len1.

len1

The length in bytes, not including any NULL terminator, of the string str1. If a value of zero is passed for this argument, then the string str1 must be NULL terminated.

str2

Pointer to a second string of text to write to the message. The string must be NULL terminated if a value of zero is passed for len2. If only supplying a single string, then pass a NULL value for this argument.

Description

After a message’s list of envelope recipient addresses has been supplied with mtaEnqueueTo(), the message itself must be supplied. This can be done by repeatedly calling mtaEnqueueWriteLine(). First the message’s header should be supplied, followed by a blank line, followed by any message content. Each call to this routine must supply a single, complete line of the message. The line should not include a line-feed terminator as mtaEnqueueWriteLine() will supply the terminator automatically.

Calling mtaEnqueueWriteLine() terminates the message’s envelope recipient list. Once the routine is called, mtaEnqueueTo() can no longer be called for the same enqueue context.

Return Values

Return Values  

Description  

0

Normal, successful completion. 

MTA_BADARGS

This value is returned for one of the following reasons: 

  1. A NULL value was supplied for the nq_ctx call argument.

  2. An invalid enqueue context was supplied for nq_ctx, or a required argument to an item code was NULL.

MTA_FCREATE

Unable to create a disk file. 

MTA_FIO

Error writing to a disk. 

MTA_ORDER

Call made out of order. No envelope recipient addresses have been supplied. 

MTA_THREAD

Simultaneous use of the enqueue context by two different threads was detected. 

Example

This code fragment writes out two header lines.


mtaEnqueueWriteLine(nq, "From: sue@siroe.com", 0, NULL);
mtaEnqueueWriteLine(nq, "Subject: test", 0, NULL);

This code fragment shows the header output as a result of the preceding code example.


From: sue@siroe.com
Subject: test

The following code fragment shows how to terminate the header by writing a blank line.

mtaEnqueueWriteLine(nq, "", 0, NULL);

The following code fragment that produces a Date: header line.


char buf[64];

mtaEnqueueWriteLine(nq,
                     "Date: ", 0,
                      mtaDateTime(buf, NULL, sizeof(buf), 0), 0,
                      NULL);