src/chardev.c
/************************************************************************/
/*                                                                      */
/*                         C H A R _ b i n s                            */
/*                                                                      */
/*      Given the argument vector:                                      */
/*      args[0] the file id to read bytes from                          */
/*      args[1] the base address of the buffer to read into             */
/*      args[2] starting offset within the buffer to put bytes at       */
/*      args[3] the number of bytes desired to read, maximum            */
/*      args[4] a FIXP cell to hold the errno, if an error occurs       */
/*                                                                      */
/*      Read up to the specified number of bytes into the buffer,       */
/*      starting at the offset given.  Return the number of bytes       */
/*      actually read; will return if fewer bytes than desired are      */
/*      read.  If an error occurs in reading, return NIL, and put       */
/*      the Unix errno into the FIXP cell given.  EWOULDBLOCK is an     */
/*      error that can occur--and bins returns NIL, so Lisp code has    */
/*      to handle that case itself.                                     */
/*                                                                      */
/************************************************************************/
C H A R _ b i n s

Given the argument vector:
args[0] the file id to read bytes from
args[1] the base address of the buffer to read into
args[2] starting offset within the buffer to put bytes at
args[3] the number of bytes desired to read, maximum
args[4] a FIXP cell to hold the errno, if an error occurs

Read up to the specified number of bytes into the buffer,
starting at the offset given.  Return the number of bytes
actually read; will return if fewer bytes than desired are
read.  If an error occurs in reading, return NIL, and put
the Unix errno into the FIXP cell given.  EWOULDBLOCK is an
error that can occur--and bins returns NIL, so Lisp code has
to handle that case itself.
C H A R _ b i n s Given the argument vector : args [ 0 ] the file id to read bytes from args [ 1 ] the base address of the buffer to read into args [ 2 ] starting offset within the buffer to put bytes at args [ 3 ] the number of bytes desired to read maximum args [ 4 ] a FIXP cell to hold the errno if an error occurs Read up to the specified number of bytes into the buffer starting at the offset given . Return the number of bytes actually read ; will return if fewer bytes than desired are read . If an error occurs in reading return NIL and put the Unix errno into the FIXP cell given . EWOULDBLOCK is an error that can occur -- and bins returns NIL so Lisp code has to handle that case itself .
LispPTR CHAR_bins(LispPTR *args)
{
#ifndef DOS
  register int fd, rval;
  char *buffer;
  int nbytes;
  Lisp_errno = (int *)(Addr68k_from_LADDR(args[4]));
  ERRSETJMP(NIL);
  fd = LispNumToCInt(args[0]);
  buffer = ((char *)(Addr68k_from_LADDR(args[1]))) + LispNumToCInt(args[2]);
  nbytes = LispNumToCInt(args[3]);
  TIMEOUT(rval = read(fd, buffer, nbytes));
  if (rval == 0) {
    *Lisp_errno = EWOULDBLOCK;
    return (NIL);
  }
  if (rval == -1) {
    *Lisp_errno = errno;
    return (NIL);
  }
#ifdef BYTESWAP
  word_swap_page((unsigned short *)buffer, (nbytes + 3) >> 2);
#endif 
  return (GetSmallp(rval));
#endif 
}
LispPTR CHAR_bins ( LispPTR * args ) { #ifndef DOS register int fd , rval ; char * buffer ; int nbytes ; Lisp_errno = ( int * ) ( Addr68k_from_LADDR ( args [ 4 ] ) ) ; ERRSETJMP ( NIL ) ; fd = LispNumToCInt ( args [ 0 ] ) ; buffer = ( ( char * ) ( Addr68k_from_LADDR ( args [ 1 ] ) ) ) + LispNumToCInt ( args [ 2 ] ) ; nbytes = LispNumToCInt ( args [ 3 ] ) ; TIMEOUT ( rval = read ( fd , buffer , nbytes ) ) ; if ( rval == 0 ) { * Lisp_errno = EWOULDBLOCK ; return ( NIL ) ; } if ( rval == -1 ) { * Lisp_errno = errno ; return ( NIL ) ; } #ifdef BYTESWAP word_swap_page ( ( unsigned short * ) buffer , ( nbytes + 3 ) >> 2 ) ; #endif return ( GetSmallp ( rval ) ) ; #endif }
C H A R _ b i n s
C H A R _ b i n s
/* Read PAGE_SIZE bytes file contents from filepointer. */ /* BYTESWAP */ /* DOS */