home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / biblioteki / c_library / asyncio / source / writecharasync.c < prev   
C/C++ Source or Header  |  1977-12-31  |  697b  |  32 lines

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