
Description | Cautions | Errors | Example | See Also
|
Name: |
int dx_setdevuio(chdev, setuiop, getuiopp) |
|
|
Inputs: |
int chdev |
|
|
DX_UIO *setuiop |
|
|
|
DX_UIO **getuiopp |
|
|
|
short evtlen |
Length of the data block in bytes |
|
|
unsigned short flags |
SENDSELF/SENDOTHERS/SENDALL |
|
|
Returns: |
0 if successful |
|
|
-1 error return code |
||
|
Includes: |
dxxxlib.h |
|
| srllib.h | ||
|
Mode: |
Synchronous |
|
The dx_setdevuio( ) function will enable the application to install and retrieve user-defined I/O functions on a per Dialogic channel device basis. The user I/O functions installed using this function will be used on all subsequent I/O operations performed on the channel even if the application installs global user I/O functions for all devices using the dx_setuio( ) function. The user I/O functions are installed by installing a pointer to a DX_UIO structure which contains addresses of the user-defined I/O functions.
The first argument to the function is chdev, the descriptor of a Dialogic channel device. This specifies the channel for which the user-defined I/O functions will be installed. The second argument, setuiop, is a pointer to an application-defined global DX_UIO structure which contains the addresses of the user-defined I/O functions. This pointer to the DX_UIO structure will be stored in the Dialogic Voice DLL for the specified chdev channel device. The application must not overwrite the DX_UIO structure until dx_setdevuio( ) has been called again for this device with the pointer to another DX_UIO structure. The third argument, getuiopp, is the address of a pointer to a DX_UIO structure. Any previously installed I/O functions for the chdev device are returned to the application as a pointer to DX_UIO structure in getuiopp. If this is the first time dx_setdevuio( ) is called for a device, then getuiopp will be filled with the pointer to the global DX_UIO structure which may contain addresses of the user-defined I/O function that apply to all devices.
Either of setuiop or getuiopp may be NULL, but not both at the same time. If getuiopp is NULL, the dx_setdevuio( ) function will only install the user I/O functions specified via the DX_UIO pointer in setuiop but will not return the address of the previously installed DX_UIO structure. If setuiop is NULL, then the previously installed DX_UIO structure pointer will be returned in getuiopp but no new functions will be installed.
The DX_UIO structure pointed to by setuiop must not be altered until the next call to dx_setdevuio( ) with new values for user-defined I/O functions.
For proper operation, it is the application's responsibility to properly define the three DX_UIO user routines; u_read, u_write and u_seek. Refer to the DX_UIO structure in the chapter on Data Structures for more information.
If the function returns -1 to indicate an error, use the SRL Standard Attribute function ATDV_LASTERR( ) to obtain the error code or you can use ATDV_ERRMSGP( ) to obtain a descriptive error message. The error codes returned by ATDV_LASTERR( ) are:
Equate |
Returned When |
EDX_BADPARM |
Invalid Parameter |
EDX_BADDEV |
Invalid Device Descriptor |
#include "windows.h"
#include "srllib.h"
#include "dxxxlib.h"
int chdev; /* channel descriptor */
DX_UIO devio; /* User defined I/O functions */
DX_UIO *getiop; /* Retrieve I/O functions */
int appread(fd, ptr, cnt)
int fd;
char *ptr;
unsigned cnt;
{
printf("appread: Read request\n");
return(read(fd, ptr, cnt));
}
int appwrite(fd, ptr, cnt)
int fd;
char *ptr;
unsigned cnt;
{
printf("appwrite: Write request\n");
return(write(fd, ptr, cnt));
}
int appseek(fd, offset, whence)
int fd;
long offset;
int whence;
{
printf("appseek: Seek request\n");
return(lseek(fd, offset, whence));
}
main(argc, argv) int argc; char *argv[]; { /* Open channel */ if ((chdev = dx_open("dxxxB1C1",0)) == -1) { printf("Cannot open channel\n"); /* Perform system error processing */ exit(1); } . . /* Other initialization */ . /* Initialize the device specific UIO structure */ devio.u_read = appread; devio.u_write = appwrite; devio.u_seek = appseek; /* Install the applications I/O routines */ if (dx_setdevuio(chdev, &devio, &getiop) == -1) { printf("error registering the UIO routines = %d\n", ATDV_LASTERR(chdev) ); }}
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation