The fc_net_write function is used to send a header and/or footer and a file that exists somewhere in the system. The fileName should be the full path name of a file.
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);
IO_OKAY if successful.
IO_ERROR if an error occurs.
FC_ERROR if an error in file handling occurs.
The following table describes parameters for the fc_net_write function.
Table 7–5 fc_net_write parameters
Parameter |
Description |
---|---|
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 the Flags table, below). |
PRIntervalTime timeout |
Timeout before this function aborts. |
Request *rq |
Pointer to the request. |
Session *sn |
Pointer to the session. |
The following table describes flags for fc_net_write.
Table 7–6 Flags for fc_net_write
Flag |
Description |
---|---|
FC_CNTLEN |
Supplies the Content-Length header and does a PROTOCOL_START_RESPONSE. |
FC_PROTO |
Does a PROTOCOL_START_RESPONSE. |
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; }