Changeset 8973acd in buchla-68k for libcio/read.c
- Timestamp:
- 07/15/2017 03:12:10 PM (7 years ago)
- Branches:
- master
- Children:
- ea232f9
- Parents:
- 7d0d347
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcio/read.c
r7d0d347 r8973acd 38 38 #include "ram.h" 39 39 40 static int16_t (*t_read[])(io_arg arg, int8_t*buff, int16_t len) = {40 static int16_t (*t_read[])(io_arg arg, void *buff, int16_t len) = { 41 41 42 42 _badfio, /* 0 - invalid type */ … … 52 52 */ 53 53 54 int16_t read(int16_t fd, int8_t *buff, uint16_t len)54 int16_t read(int16_t fd, void *buff, int16_t len) 55 55 { 56 56 register struct channel *chp; … … 73 73 */ 74 74 75 int16_t _getsec(struct fcb *fp, int8_t *buf, uint16_t len)75 int16_t _getsec(struct fcb *fp, void *buf, int16_t len) 76 76 { 77 77 if ((errno = ReadRN(fp, Wrkbuf)) NE 0) /* get current sector */ … … 98 98 */ 99 99 100 int16_t _filerd( struct fcb *fp, int8_t *buffer, uint16_t len)100 int16_t _filerd(io_arg arg, void *buffer, int16_t len) 101 101 { 102 register uint16_t l; 103 register uint16_t j, k; 104 register int32_t curpos, newpos; 102 struct fcb *fp; 103 int8_t *buffer8; 104 register int16_t l; 105 register int16_t j, k; 106 register int32_t cpos, npos; 107 108 fp = (struct fcb *)arg; 109 buffer8 = buffer; 105 110 106 111 l = 0; 107 c urpos = fp->offset + (fp->curlsn << FILESHFT);108 n ewpos = curpos + len;112 cpos = fp->offset + ((int32_t)fp->curlsn << FILESHFT); 113 npos = cpos + len; 109 114 110 115 #if DEBUGIT 111 116 if (fsdebug) 112 117 printf("_filerd(): len=%u, curpos=%ld, newpos=%ld, curlen=%ld\n", 113 len, c urpos, newpos, fp->curlen);118 len, cpos, npos, fp->curlen); 114 119 #endif 115 120 116 if (n ewpos GT fp->curlen) {121 if (npos GT fp->curlen) { 117 122 118 len = fp->curlen - curpos;123 len = (int16_t)(fp->curlen - cpos); 119 124 120 125 #if DEBUGIT … … 129 134 l = len; 130 135 131 if (_getsec(fp, buffer , l)) /* read what we can */136 if (_getsec(fp, buffer8, l)) /* read what we can */ 132 137 return(len); /* return if ERROR */ 133 138 } 134 139 135 if ( k = (len - l) / BPSEC)/* see what we still need */136 if ((j = blkrd(fp, buffer+ l, k)) NE 0)140 if ((k = (len - l) / BPSEC)) { /* see what we still need */ 141 if ((j = blkrd(fp, buffer8 + l, k)) NE 0) 137 142 return((k - j) * BPSEC + l); /* return bytes read */ 143 } 138 144 139 145 l += k * BPSEC; /* adjust l by what we just read */ 140 146 141 147 if (l < len) /* see if we still need a partial sector */ 142 if (_getsec(fp, buffer + l, len - l)) /* read partial sector */148 if (_getsec(fp, buffer8 + l, len - l)) /* read partial sector */ 143 149 return(l); /* return if ERROR or EOF */ 144 150
Note:
See TracChangeset
for help on using the changeset viewer.