home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TIFF / TFTOOL.ZIP / VIO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-11-02  |  1.5 KB  |  62 lines

  1. /* vio.c - virtual pseudo-file i/o
  2.  */
  3.  
  4. #include "aldtypes.h"    /* for WORD, DWORD, LPSTR, etc */
  5. #include "aldutils.h"    /* for copy prototype */
  6. #include "imtypes.h"
  7.  
  8. #include "stdio.h"
  9. #include "dloc.h"
  10. #include "vio.h"
  11.  
  12. #ifdef MACINTOSH
  13. int fseek (FILE *, long, int);
  14. int fread (char *, int, int, FILE *);
  15. #endif
  16.  
  17. extern DWORD    TiffStart;
  18.  
  19. /*************** LOCAL routines ***********************/
  20.  
  21.  
  22. /******************** external routines **********************/
  23.  
  24. RC VRead (pD, pos, BytesToRead, lpBuf)
  25. PDLOC    pD;        /* pointer to a structure that tells
  26.                  * where to go for the information 
  27.                  */
  28. DWORD    pos;    /* byte position, with respect to the beginning
  29.                  * of the "file", to start reading data from
  30.                  */
  31. WORD    BytesToRead;
  32. LPSTR    lpBuf;    /* where to put the data */
  33. {
  34.         register DLOC    *pDloc = (DLOC *)pD;
  35.         RC                err = SUCCESS;
  36.         int                red;
  37.         
  38.         /* DBMSG(("VRead: top.  %u\n", BytesToRead)); */
  39.         
  40.         if (pDloc->dlWhere == INFILE) {
  41.             if (err = fseek (pDloc->dlFp, (long) (pos+TiffStart), 0)) {
  42.                 DBMSG(( "VRead: fseek error\n"));
  43.                 DBMSG((" err=%u pos=%lu BytesToRead=%u\n",
  44.                  err,pos,BytesToRead));
  45.                 return err;
  46.             }
  47.             if ((red = fread (lpBuf, 1, BytesToRead, pDloc->dlFp)) == 0) {
  48.                 DBMSG(( "VRead: fread error\n"));
  49.                 DBMSG((" err=%u pos=%lu BytesToRead=%u\n",
  50.                  err,pos,BytesToRead));                        
  51.                 return -1;
  52.             }
  53.             /* ByteHexDump (BytesToRead, (LPBYTE)lpBuf); */
  54.             
  55.         } else {
  56.             DBMSG(("VRead: bad dlWhere\n"));
  57.             err = -1;
  58.         }
  59.         
  60. cu0:    /* DBMSG(("VRead: bottom\n")); */
  61.         return err;
  62. }