
Description | Cautions | Example | Errors | See Also
Name: |
long dx_fileseek(handle, offset, origin) | |
Inputs: |
int handle |
|
long offset |
| |
int origin |
| |
Returns: |
number of bytes read if success | |
-1 if failure | ||
Category: |
File Management | |
The dx_fileseek( ) function moves a file pointer associated with the file handle to a new location that is offset bytes from origin. The function returns the offset, in bytes, of the new position from the beginning of the file. See the _lseek function in the Microsoft Visual C++ Run-Time Library Reference for more information.
Use dx_fileseek( ) instead of _lseek to ensure the compatibility of applications with the libraries across various versions of Visual C++.
#include <stdio.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
int cd; /* channel descriptor */
DX_UIO myio; /* user definable I/O structure */
/*
* User defined I/O functions
*/
int my_read(fd,ptr,cnt)
int fd;
char * ptr;
unsigned cnt;
{
printf("My read\n");
return(dx_fileread(fd,ptr,cnt));
}
/*
* my write function
*/
int my_write(fd,ptr,cnt)
int fd;
char * ptr;
unsigned cnt;
{
printf("My write \n");
return(dx_filewrite(fd,ptr,cnt));
}
/*
* my seek function
*/
long my_seek(fd,offset,whence)
int fd;
long offset;
int whence;
{
printf("My seek\n");
return(dx_fileseek(fd,offset,whence));
}
void main(argc,argv)
int argc;
char *argv[];
{
.
. /* Other initialization */
.
DX_UIO uioblk;
/* Initialize the UIO structure */
uioblk.u_read=my_read;
uioblk.u_write=my_write;
uioblk.u_seek=my_seek;
/* Install my I/O routines */
dx_setuio(uioblk);
vodat_fd = dx_fileopen("JUNK.VOX",O_RDWR|O_BINARY);
/*This block uses standard I/O functions */
iott->io_type = IO_DEV|IO_CONT
iott->io_fhandle = vodat_fd;
iott->io_offset = 0;
iott->io_length = 20000;
/*This block uses my I/O functions */
iottp++;
iottp->io_type = IO_DEV|IO_UIO|IO_CONT
iottp->io_fhandle = vodat_fd;
iott->io_offset = 20001;
iott->io_length = 20000;
/*This block uses standard I/O functions */
iottp++
iott->io_type = IO_DEV|IO_CONT
iott->io_fhandle = vodat_fd;
iott->io_offset = 20002;
iott->io_length = 20000;
/*This block uses my I/O functions */
iott->io_type = IO_DEV|IO_UIO|IO_EOT
iott->io_fhandle = vodat_fd;
iott->io_offset = 10003;
iott->io_length = 20000;
devhandle = dx_open("dxxxB1C1", NULL);
dx_sethook(devhandle, DX-ONHOOK,EV_SYNC)
dx_wtring(devhandle,1,DX_OFFHOOK,EV_SYNC);
dx_clrdigbuf;
if(dx_rec(devhandle,iott,(DX_TPT*)NULL,RM_TONE|EV_SYNC) == -1) {
perror("");
exit(1);
}
dx_clrdigbuf(devhandle);
if(dx_play(devhandle,iott,(DX_TPT*)EV_SYNC) == -1 {
perror("");
exit(1);
}
dx_close(devhandle);
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.
Click here to contact Dialogic Customer Engineering
Copyright 2002, Dialogic Corporation