home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
LIBSRC.ZOO
/
libsrc
/
local
/
lseek.c
< prev
next >
Wrap
Text File
|
1992-02-16
|
847b
|
43 lines
#define INCL_DOSFILEMGR
#define INCL_DOSERRORS
#include <os2.h>
#include <sys/file.h>
#include <errno.h>
ULONG Dos32SetFilePtr() asm ("Dos32SetFilePtr");
int lseek (int fd, long offset, int whence)
{
ULONG rc;
ULONG NewPos;
if (whence == L_SET)
rc = Dos32SetFilePtr (fd, offset, FILE_BEGIN, &NewPos);
else
if (whence == L_INCR)
rc = Dos32SetFilePtr (fd, offset, FILE_CURRENT, &NewPos);
else
if (whence == L_XTND)
rc = Dos32SetFilePtr (fd, offset, FILE_END, &NewPos);
else
{
errno = EINVAL;
return (-1);
}
if (rc)
{
if (rc == ERROR_INVALID_HANDLE)
{
errno = EBADF;
return (-1);
}
errno = EIO;
return (-1);
}
return (NewPos);
}