home *** CD-ROM | disk | FTP | other *** search
- #include "lib.h"
-
- #ifndef __MSHORT__
- asm(".text; .even; .globl _read; _read:"); /* dept of dirty tricks */
- #endif
-
- PUBLIC long lread(fd, buffer, nbytes)
- int fd;
- _VOIDSTAR buffer;
- long nbytes;
- {
- int n;
- long tot, left;
-
- if(nbytes <= 32767)
- {
- n = callm1(FS, READ, fd, (int)nbytes, 0, buffer, NIL_PTR, NIL_PTR);
- return((long)n);
- }
- for( tot = 0L, left = nbytes; left > 0L; )
- {
- n = (left > 32767) ? 32767 : (int)left;
- if((n = callm1(FS, READ, fd, n, 0, buffer, NIL_PTR, NIL_PTR)) < 0)
- return(n);
- if(n == 0) return(tot);
- tot += n;
- left -= n;
- (char *)buffer += n;
- }
- return(tot);
- }
-
- #ifdef __MSHORT__
- PUBLIC int read(fd, buffer, nbytes)
- int fd;
- _VOIDSTAR buffer;
- int nbytes;
- {
- return (int)lread(fd, buffer, (long)nbytes);
- }
- #endif
-