home *** CD-ROM | disk | FTP | other *** search
- /* Extras:GetBytes.h */
-
- /* ExtrasLib by Peter Hartley 1995-96
- * (K) All Rites Reversed - Copy What You Like
- */
-
- typedef struct
- {
- int handle;
- int offset;
- char *buffer;
- int buffsize;
- char **ptrp;
- char **endp;
- BOOL eof;
- } GetBytes_T;
-
- void GetBytes_Start( GetBytes_T *gb, int filehandle, char *buffer, int buffsize,
- char **ptrp, char **endp );
-
- os_error *GetBytes( GetBytes_T *gb, int needsize );
-
- /******************************************************************************
- Use as:
-
- char buffer[1024], *ptr, *end;
- GetBytes_T gb;
-
- GetBytes_Start( &gb, filehandle, buffer, 1024, &ptr, &end )
- er( GetBytes( &gb, 1024 ) );
- do {
- er( GetBytes( &gb, 256 ) );
- |* now there are at least 256 bytes of the file at *ptr *|
- ...increment ptr as required...
- } while ( ptr < end || !gb.eof );
-
- ******************************************************************************/
-