|
Last change
on this file since 0580615 was 0580615, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
|
Point of no return.
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | =============================================================================
|
|---|
| 3 | posit.c -- position a file to a specific relative sector
|
|---|
| 4 | Version 4 -- 1987-06-29 -- D.N. Lynx Crowe
|
|---|
| 5 | =============================================================================
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | #include "biosdefs.h"
|
|---|
| 9 | #include "io.h"
|
|---|
| 10 | #include "errno.h"
|
|---|
| 11 | #include "stddefs.h"
|
|---|
| 12 |
|
|---|
| 13 | extern int _seek(struct fcb *fcp);
|
|---|
| 14 |
|
|---|
| 15 | /*
|
|---|
| 16 | =============================================================================
|
|---|
| 17 | posit(fd, pos) -- position file 'fd' at sector 'pos'.
|
|---|
| 18 | =============================================================================
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | int posit(int fd, unsigned pos)
|
|---|
| 22 | {
|
|---|
| 23 | register struct fcb *fp;
|
|---|
| 24 |
|
|---|
| 25 | if ((fd < 0) OR (fd > MAXCHAN)) {
|
|---|
| 26 |
|
|---|
| 27 | errno = EBADF;
|
|---|
| 28 | return(FAILURE);
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | fp = chantab[fd].c_arg;
|
|---|
| 32 |
|
|---|
| 33 | if ((chantab[fd].c_seek EQ 0)
|
|---|
| 34 | OR ((pos << FILESHFT) > fp->curlen)) {
|
|---|
| 35 |
|
|---|
| 36 | errno = EINVAL;
|
|---|
| 37 | fp->modefl |= FC_ERR;
|
|---|
| 38 | return(FAILURE);
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | fp->curlsn = pos;
|
|---|
| 42 | fp->offset = 0;
|
|---|
| 43 |
|
|---|
| 44 | if (_seek(fp) < 0) {
|
|---|
| 45 |
|
|---|
| 46 | errno = EIO;
|
|---|
| 47 | fp->modefl |= FC_ERR;
|
|---|
| 48 | return(FAILURE);
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | return(SUCCESS);
|
|---|
| 52 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.