home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / asyncio / src / writecharasync.c < prev    next >
C/C++ Source or Header  |  1997-06-04  |  692b  |  35 lines

  1. #include "async.h"
  2.  
  3.  
  4. _CALL LONG
  5. WriteCharAsync( _REG( a0 ) AsyncFile *file, _REG( d0 ) UBYTE ch )
  6. {
  7.     if( file->af_BytesLeft )
  8.     {
  9.         /* if there's any room left in the current buffer, directly write
  10.          * the byte into it, updating counters and stuff.
  11.          */
  12.  
  13.         *file->af_Offset = ch;
  14.         --file->af_BytesLeft;
  15.         ++file->af_Offset;
  16.  
  17.         /* one byte written */
  18.         return( 1 );
  19.     }
  20.  
  21.     /* there was no room in the current buffer, so call the main write
  22.      * routine. This will effectively send the current buffer out to disk,
  23.      * wait for the other buffer to come back, and then put the byte into
  24.      * it.
  25.      */
  26.  
  27.     {
  28.         TEXT    c;
  29.  
  30.         c = ch;        /* SAS/C workaround... */
  31.  
  32.         return( WriteAsync( file, &c, 1 ) );
  33.     }
  34. }
  35.