2019-06-16 17:04:17 +00:00
|
|
|
#include <stdio.h>
|
2007-04-27 22:42:41 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
2019-06-16 17:04:17 +00:00
|
|
|
#include <sys/types.h>
|
2007-04-27 22:42:41 +00:00
|
|
|
#include <unistd.h>
|
2019-06-16 17:04:17 +00:00
|
|
|
#include <cpm.h>
|
|
|
|
#include "cpmsys.h"
|
2007-04-27 22:42:41 +00:00
|
|
|
|
|
|
|
off_t lseek(int fd, off_t offset, int whence)
|
|
|
|
{
|
2019-06-16 17:04:17 +00:00
|
|
|
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;
|
2019-06-16 18:04:07 +00:00
|
|
|
return offset;
|
2007-04-27 22:42:41 +00:00
|
|
|
}
|