Dialogic 6.2 Manuale Utente

Pagina di 441
Developing a Fax Application
November 2009
83
Accessing an Infopkt Stream from an Application
The function calls BfvFaxSendPage and BfvFaxNextPage are 
typically used in a loop. Both read infopkts from the infopkt stream 
for processing.
BfvFaxSendPage reads infopkts and processes them in a loop. 
When data (embedded or indirect) or strip parameter type infopkts 
are encountered, the indicated parameters and data format (ASCII 
or G3) commands are sent to the channel, the data is downloaded to 
the driver buffer, and the next infopkt is read. If any other type of 
infopkt is encountered, the current position in the infopkt stream 
remains unchanged, and the function returns to the calling routine.
BfvFaxNextPage reads infopkts from the current position in the 
infopkt stream. All consecutive infopkts of a new-page type,
INFOPKT_PAGE_PARAMETERS,
INFOPKT_T30_PARAMETERS,
INFOPKT_BEGINNING_OF_PAGE, or
INFOPKT_DOCUMENT_PARAMETERS,
are processed, and relevant data and a single end-of-page command 
are sent to the channel. If no infopkts of a new-page type are found, 
the current position in the infopkt stream remains unchanged, and 
the function returns to the calling routine.
A program to read a file containing infopkts could look like this:
BT_ZERO(args_infopkt);
 
args_infopkt.fname = "filename";
 
args_infopkt.fmode = "r";
 
ips = BfvInfopktOpen(&args_infopkt);
 
for (;;)
 
{
 
    BT_ZERO(args_infopkt);
 
    args_infopkt.ips = ips;
 
    args_infopkt.i_mode = INDIR_MODE_FOLLOW;
 
    if ((ip = BfvInfopktGet(&args_infopkt)) == NULL)
 
        break;
 
    process(ip);
 
}
With the flag set to INDIR_MODE_FOLLOW or 
INDIR_MODE_FOLLOW_NOUSER
BfvInfopktGet follows indirect 
infopkt links automatically, so the user sees only the actual data. 
Other flags let the user examine a file without following indirect 
infopkt links. See the BfvInfopktUser function in Volume 4, Fax