Last change
on this file since 9bf0f86 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
Imported original source code.
|
-
Property mode
set to
100755
|
File size:
1.1 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();
|
---|
14 |
|
---|
15 | /*
|
---|
16 | =============================================================================
|
---|
17 | posit(fd, pos) -- position file 'fd' at sector 'pos'.
|
---|
18 | =============================================================================
|
---|
19 | */
|
---|
20 |
|
---|
21 | int
|
---|
22 | posit(fd, pos)
|
---|
23 | int fd;
|
---|
24 | unsigned pos;
|
---|
25 | {
|
---|
26 | register struct fcb *fp;
|
---|
27 |
|
---|
28 | if ((fd < 0) OR (fd > MAXCHAN)) {
|
---|
29 |
|
---|
30 | errno = EBADF;
|
---|
31 | return(FAILURE);
|
---|
32 | }
|
---|
33 |
|
---|
34 | fp = chantab[fd].c_arg;
|
---|
35 |
|
---|
36 | if ((chantab[fd].c_seek EQ 0)
|
---|
37 | OR ((pos << FILESHFT) > fp->curlen)) {
|
---|
38 |
|
---|
39 | errno = EINVAL;
|
---|
40 | fp->modefl |= FC_ERR;
|
---|
41 | return(FAILURE);
|
---|
42 | }
|
---|
43 |
|
---|
44 | fp->curlsn = pos;
|
---|
45 | fp->offset = 0;
|
---|
46 |
|
---|
47 | if (_seek(fp) < 0) {
|
---|
48 |
|
---|
49 | errno = EIO;
|
---|
50 | fp->modefl |= FC_ERR;
|
---|
51 | return(FAILURE);
|
---|
52 | }
|
---|
53 |
|
---|
54 | return(SUCCESS);
|
---|
55 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.