home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / e / extralib / !ExtrasLib / h / GetBytes < prev    next >
Encoding:
Text File  |  1996-03-03  |  960 b   |  38 lines

  1. /* Extras:GetBytes.h */
  2.  
  3. /* ExtrasLib by Peter Hartley 1995-96
  4.  * (K) All Rites Reversed - Copy What You Like
  5.  */
  6.  
  7. typedef struct
  8. {
  9.   int    handle;
  10.   int    offset;
  11.   char  *buffer;
  12.   int    buffsize;
  13.   char **ptrp;
  14.   char **endp;
  15.   BOOL   eof;
  16. } GetBytes_T;
  17.  
  18. void GetBytes_Start( GetBytes_T *gb, int filehandle, char *buffer, int buffsize,
  19.                      char **ptrp, char **endp );
  20.  
  21. os_error *GetBytes( GetBytes_T *gb, int needsize );
  22.  
  23. /******************************************************************************
  24.   Use as:
  25.  
  26.     char buffer[1024], *ptr, *end;
  27.     GetBytes_T gb;
  28.  
  29.     GetBytes_Start( &gb, filehandle, buffer, 1024, &ptr, &end )
  30.     er( GetBytes( &gb, 1024 ) );
  31.     do {
  32.         er( GetBytes( &gb, 256 ) );
  33.         |* now there are at least 256 bytes of the file at *ptr *|
  34.         ...increment ptr as required...
  35.     } while ( ptr < end || !gb.eof );
  36.  
  37.  ******************************************************************************/
  38.