Sun Java System Web Server 7.0 Update 7 NSAPI Developer's Guide

fc_net_write() Function

Use fc_net_write function is to send a header or a footer and a file that exists somewhere in the system. The fileName should be the full path name of a file.

Syntax

PRInt32 fc_net_write(const char *fileName, const char *hdr, 
                    const char *ftr, PRUint32 hlen,
                    PRUint32 flen, PRUint32 flags, 
                    PRIntervalTime timeout, Session *sn, Request *rq);

Return Values

IO_OKAY if successful.

IO_ERROR if an error occurs.

FC_ERROR if an error in file handling occurs.

Parameters

const char *fileName

File to be inserted

const char *hdr

Any header data, which can be NULL

const char *ftr

Any footer data, which can be NULL

PRUint32 hlen

Length of the header data in bytes, which can be 0

PRUint32 flen

Length of the footer data in bytes, which can be 0

PRUint32 flags

ORed directives for this function. See Flags.

PRIntervalTime timeout

Timeout before this function aborts

Request *rq

Pointer to the request

Session *sn

Pointer to the session

Flags

This section describes the flags for fc_net_write() function.

FC_CNTLEN

Supplies the Content-Length header and does a PROTOCOL_START_RESPONSE

FC_PROTO

Does a PROTOCOL_START_RESPONSE

Example

const char *fileName = "/docs/myads/file1.ad";
char *hdr = GenHdr(); // Implemented by plugin
char *ftr = GenFtr(); // Implemented by plugin

if(fc_net_write(fileName, hdr, ftr, strlen(hdr), strlen(ftr),
    FC_CNTLEN, PR_INTERVAL_NO_TIMEOUT, sn, rq) != IO_OKEY)
{
    ereport(LOG_FAILURE, "fc_net_write() failed");
    return REQ_ABORTED;
}