home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / dos / fread.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-27  |  1.6 KB  |  88 lines

  1. /*
  2.     (C) 1995 AROS - The Amiga Replacement OS
  3.     $Id: fread.c,v 1.2 1997/01/27 00:36:20 ldp Exp $
  4.     $Log: fread.c,v $
  5.     Revision 1.2  1997/01/27 00:36:20  ldp
  6.     Polish
  7.  
  8.     Revision 1.1  1996/11/25 15:50:57  aros
  9.     Two new functions
  10.  
  11.     Desc:
  12.     Lang: english
  13. */
  14. #include "dos_intern.h"
  15.  
  16. /*****************************************************************************
  17.  
  18.     NAME */
  19. #include <proto/dos.h>
  20.  
  21.     AROS_LH4(LONG, FRead,
  22.  
  23. /*  SYNOPSIS */
  24.     AROS_LHA(BPTR , fh, D1),
  25.     AROS_LHA(APTR , block, D2),
  26.     AROS_LHA(ULONG, blocklen, D3),
  27.     AROS_LHA(ULONG, number, D4),
  28.  
  29. /*  LOCATION */
  30.     struct DosLibrary *, DOSBase, 54, Dos)
  31.  
  32. /*  FUNCTION
  33.     Read a number of blocks from a file.
  34.  
  35.     INPUTS
  36.     fh - Read from this file
  37.     block - The data is put here
  38.     blocklen - This is the size of a single block
  39.     number - The number of blocks
  40.  
  41.     RESULT
  42.     The number of blocks written to the file or EOF on error. IoErr()
  43.     gives additional information in case of an error.
  44.  
  45.     NOTES
  46.  
  47.     EXAMPLE
  48.  
  49.     BUGS
  50.  
  51.     SEE ALSO
  52.     Open(), FWrite(), FPutc(), Close()
  53.  
  54.     INTERNALS
  55.  
  56.     HISTORY
  57.     29-10-95    digulla automatically created from
  58.                 dos_lib.fd and clib/dos_protos.h
  59.  
  60. *****************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.     AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
  64.     ULONG   read;
  65.     ULONG   len;
  66.     UBYTE * ptr;
  67.     LONG    c;
  68.  
  69.     ptr = block;
  70.     len = 0;
  71.  
  72.     for (read=0; read<number; read++)
  73.     {
  74.     for (len=blocklen; len--; )
  75.     {
  76.         c = FGetC (fh);
  77.  
  78.         if (c < 0)
  79.         return EOF;
  80.  
  81.         *ptr ++ = c;
  82.     }
  83.     }
  84.  
  85.     return read;
  86.     AROS_LIBFUNC_EXIT
  87. } /* FRead */
  88.