| Last change
 on this file since 6262b5c was             6262b5c, checked in by Thomas Lopatic <thomas@…>, 8 years ago | 
        
          | 
Added include files for global functions and variables.
 | 
        
          | 
              
Property                 mode
 set to                 100644 | 
        
          | File size:
            1008 bytes | 
      
      
| 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 "all.h" | 
|---|
| 9 |  | 
|---|
| 10 | extern  int16_t _seek(struct fcb *fcp); | 
|---|
| 11 |  | 
|---|
| 12 | /* | 
|---|
| 13 | ============================================================================= | 
|---|
| 14 | posit(fd, pos) -- position file 'fd' at sector 'pos'. | 
|---|
| 15 | ============================================================================= | 
|---|
| 16 | */ | 
|---|
| 17 |  | 
|---|
| 18 | int16_t posit(int16_t fd, uint16_t pos) | 
|---|
| 19 | { | 
|---|
| 20 | register struct fcb *fp; | 
|---|
| 21 |  | 
|---|
| 22 | if ((fd < 0) OR (fd > MAXCHAN)) { | 
|---|
| 23 |  | 
|---|
| 24 | errno = EBADF; | 
|---|
| 25 | return(FAILURE); | 
|---|
| 26 | } | 
|---|
| 27 |  | 
|---|
| 28 | fp = chantab[fd].c_arg; | 
|---|
| 29 |  | 
|---|
| 30 | if ((chantab[fd].c_seek EQ 0) | 
|---|
| 31 | OR ((pos << FILESHFT) > fp->curlen)) { | 
|---|
| 32 |  | 
|---|
| 33 | errno = EINVAL; | 
|---|
| 34 | fp->modefl |= FC_ERR; | 
|---|
| 35 | return(FAILURE); | 
|---|
| 36 | } | 
|---|
| 37 |  | 
|---|
| 38 | fp->curlsn = pos; | 
|---|
| 39 | fp->offset = 0; | 
|---|
| 40 |  | 
|---|
| 41 | if (_seek(fp) < 0) { | 
|---|
| 42 |  | 
|---|
| 43 | errno = EIO; | 
|---|
| 44 | fp->modefl |= FC_ERR; | 
|---|
| 45 | return(FAILURE); | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | return(SUCCESS); | 
|---|
| 49 | } | 
|---|
| 50 |  | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.