src/chardev.c
/************************************************************************/
/*                                                                      */
/*                         C H A R _ b o u t s                          */
/*                                                                      */
/*      Given the argument vector:                                      */
/*      args[0] the file descriptor to write bytes to                   */
/*      args[1] the base address of the buffer to write from            */
/*      args[2] starting offset within the buffer to gt bytes from      */
/*      args[3] the number of bytes desired to write, maximum           */
/*      args[4] a FIXP cell to hold the errno, if an error occurs       */
/*                                                                      */
/*      write up to the specified number of bytes from the buffer,      */
/*      starting at the offset given.  Return the number of bytes       */
/*      actually written; will return if fewer bytes than desired are   */
/*      written.  If an error occurs in writing, 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 o u t s

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

write up to the specified number of bytes from the buffer,
starting at the offset given.  Return the number of bytes
actually written; will return if fewer bytes than desired are
written.  If an error occurs in writing, 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 o u t s Given the argument vector : args [ 0 ] the file descriptor to write bytes to args [ 1 ] the base address of the buffer to write from args [ 2 ] starting offset within the buffer to gt bytes from args [ 3 ] the number of bytes desired to write maximum args [ 4 ] a FIXP cell to hold the errno if an error occurs write up to the specified number of bytes from the buffer starting at the offset given . Return the number of bytes actually written ; will return if fewer bytes than desired are written . If an error occurs in writing 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_bouts(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]);
#ifdef BYTESWAP
  word_swap_page((unsigned short *)buffer, (nbytes + 3) >> 2);
#endif 
  TIMEOUT(rval = write(fd, buffer, nbytes));
#ifdef BYTESWAP
  word_swap_page((unsigned short *)buffer, (nbytes + 3) >> 2);
#endif 
  if (rval == -1) {
    *Lisp_errno = errno;
    return (NIL);
  }
  if (rval == 0) {
    *Lisp_errno = EWOULDBLOCK;
    return (NIL);
  }
  return (GetSmallp(rval));
#endif 
}
LispPTR CHAR_bouts ( 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 ] ) ; #ifdef BYTESWAP word_swap_page ( ( unsigned short * ) buffer , ( nbytes + 3 ) >> 2 ) ; #endif TIMEOUT ( rval = write ( fd , buffer , nbytes ) ) ; #ifdef BYTESWAP word_swap_page ( ( unsigned short * ) buffer , ( nbytes + 3 ) >> 2 ) ; #endif if ( rval == -1 ) { * Lisp_errno = errno ; return ( NIL ) ; } if ( rval == 0 ) { * Lisp_errno = EWOULDBLOCK ; return ( NIL ) ; } return ( GetSmallp ( rval ) ) ; #endif }
C H A R _ b o u t s
C H A R _ b o u t s
/* Write PAGE_SIZE bytes file contents from filepointer. */ /* BYTESWAP */ /* BYTESWAP */ /* DOS */