
Description | Cautions | Example | Errors | If this
Name: |
int dx_fileopen(filep, flags, pmode) | |
Inputs: |
const char *filep |
|
int flags |
| |
int pmode |
| |
Returns: |
file handle if success | |
-1 if failure | ||
Category: |
File Management | |
The dx_fileopen( ) function opens a file specified by filep, and prepares the file for reading and writing, as specified by flags. See the _open function in the Microsoft Visual C++ Run-Time Library Reference for more information.
Use dx_fileopen( ) instead of _open to ensure the compatibility of applications with the libraries across various versions of Visual C++.
/* Play a voice file. Terminate on receiving 4 digits or at end of file*/
#include <fcntl.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
main()
{
int chdev;
DX_IOTT iott;
DV_TPT tpt;
DV_DIGIT dig;
.
.
/* Open the device using dx_open( ). Get channel device descriptor in
* chdev.
*/
if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) {
/* process error */
}
/* set up DX_IOTT */
iott.io_type = IO_DEV|IO_EOT;
iott.io_bufp = 0;
iott.io_offset = 0;
iott.io_length = -1; /* play till end of file */
if((iott.io_handle = dx_fileopen("prompt.vox", O_RDONLY|O_BINARY)) == -1) {
/* process error */
}
/* set up DV_TPT */
dx_clrtpt(&tpt,1);
tpt.tp_type = IO_EOT; /* only entry in the table */
tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */
tpt.tp_length = 4; /* terminate on four digits */
tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */
/* clear previously entered digits */
if (dx_clrdigbuf(chdev) == -1) {
/* process error */
}
/* Now play the file */
if (dx_play(chdev,&iott,&tpt,EV_SYNC) == -1) {
/* process error */
}
/* get digit using dx_getdig( ) and continue processing. */
.
.
if (dx_fileclose(iott.io_handle) == -1) {
/* process error */
}
}
If this function returns -1 to indicate failure, a system error has occurred; use dx_fileerrno( ) to obtain the system error value. Refer to the dx_fileerrno( ) function for a list of the possible system error values.See Also
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation