source: buchla-68k/libcio/posit.c@ 9519422

Last change on this file since 9519422 was 7258c6a, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Use standard integer types.

  • 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
13extern int16_t _seek(struct fcb *fcp);
14
15/*
16 =============================================================================
17 posit(fd, pos) -- position file 'fd' at sector 'pos'.
18 =============================================================================
19*/
20
21int16_t posit(int16_t fd, uint16_t 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.