ack/plat/cpm/libsys/lseek.c

29 lines
586 B
C
Raw Normal View History

#include <stdio.h>
2007-04-27 22:42:41 +00:00
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
2007-04-27 22:42:41 +00:00
#include <unistd.h>
#include <cpm.h>
#include "cpmsys.h"
2007-04-27 22:42:41 +00:00
off_t lseek(int fd, off_t offset, int whence)
{
struct FCBE* fcbe = &__fd[fd];
__init_file_descriptors();
if (fcbe->fcb.dr == 0)
{
/* Can't seek the console. */
return 0;
}
if (whence == SEEK_END)
offset += fcbe->length<<7;
if (whence == SEEK_CUR)
offset += (U16(fcbe->fcb.r)<<7) | fcbe->offset;
U16(fcbe->fcb.r) = offset>>7;
fcbe->offset = offset & 0x7f;
return 0;
2007-04-27 22:42:41 +00:00
}