![]() processReportOutputData() |
![]() DEVELOPER |
![]() |
processReportOutputData()
User-Supplied Report Capture Function
Report Output
Introduction
The caller supplied function processReportOutputData() is used for processing report output from the P4API. The actual name of the function can be anything. The name used is specified on a call to p4SetOutputFunction().
int processReportOutputData (
SESSION_HANDLE_T sessionHandle,
int nOutputFormat,
int nType,
int nLineCtrl,
int nDataLen,
const char *pDataBuffer
);
Parameters
kernelSessionHandle
[in] The kernel-session-id for a PROIV Virtual Machine session, as returned by a prior call to p4OpenPro4().
nOutputFormat
[in] The format of the data in the data buffer. Valid values are:
0 = plain print line (as displayed if the report was output to a printer).
1 = Simple DSL (Delimiter Separated List) format.
-1 = end of report
nType
[in] The type of data in this particular call. Valid values are:
0 = normal data.
nLineCtrl
[in] Line spacing indication. This specifying whether to output blank lines or a new page before outputting this record. This parameter would probably be ignored unless the user was just redirecting the data to a printer. Valid values are:
0 = no action.
-1 = start a new page.
> 0 = the number of blank lines required before this record.
nDataLen
[in] The length of the data in pDataBuffer.
pDataBuffer
[in] The report data. Undergoes codeset conversion if p4SetCode() is active.
Return Values
The function should return 0 if OK.
Remarks
An example of a report data process function, which just echoes the data to the standard output device, follows. This action is identical to what P4API does if no report output processor is defined.
int
processReportOutputData(
SESSION_HANDLE_T sessionHandle,
int nOutputFormat,
int nType
int nLineCtrl
int nDataLen
const char *pObuf)
{
printf("processReportOutputData: entry, session %lu\n",
(unsigned long) sessionHandle);
switch (nOutputFormat) {
case 0:
/* plain printline format - echo to stdout */
if (nLineCtrl == -1)
fprintf(stdout, "\f"); /* FormFeed */
else { /* n blank lines */
for (; nLineCtrl > 0; --nLineCtrl)
fprintf(stdout, "\n");
}
if (nDataLen >= 2) {
if (pObuf[nDataLen-1] == '\n')
--nDataLen;
if (pObuf[nDataLen-1] == '\r')
--nDataLen;
}
fprintf(stdout, "%.*s\n", nDataLen, pObuf);
break;
default:
/* other formats - echo to stdout with "\n" */
/* (ignore line control)*/
fprintf(stdout, "%.*s\n", nDataLen, pObuf);
break;
}
return 0;
}
Topic ID: 540195