home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Web / Utilities / wwwcount-2.3 / combine / readblk.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-19  |  1.7 KB  |  58 lines

  1. #include "combine.h"
  2.  
  3. /*
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. %                                                                             %
  6. %                                                                             %
  7. %                                                                             %
  8. %  R e a d D a t a B l o c k                                                  %
  9. %                                                                             %
  10. %                                                                             %
  11. %                                                                             %
  12. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  13. %
  14. %  Function ReadDataBlock reads data from the image file and returns it.  The
  15. %  amount of data is determined by first reading a count byte.  If
  16. %  ReadDataBlock cannot read the requested number of items, `-1' is returned
  17. %  indicating an error.
  18. %
  19. %  The format of the ReadData routine is:
  20. %
  21. %      status=ReadData(data,file)
  22. %
  23. %  A description of each parameter follows:
  24. %
  25. %    o status:  Function ReadData returns the number of characters read
  26. %      unless there is an error, otherwise `-1'.
  27. %
  28. %    o data:  Specifies an area to place the information reuested from
  29. %      the file.
  30. %
  31. %    o file:  Specifies a file to read the data.
  32. %
  33. %
  34. */
  35. int ReadDataBlock(data,file)
  36. char
  37.   *data;
  38.  
  39. FILE
  40.   *file;
  41. {
  42.   unsigned char
  43.     count;
  44.  
  45.   int
  46.     rc = 0;
  47.  
  48.   rc = Read_Data((char *) &count,1,1,file);
  49.   if (rc == 1)
  50.     return(rc);
  51.   if (count == 0)
  52.     return(rc);
  53.   rc=Read_Data(data,1,(int) count,file);
  54.   if (rc == 1)
  55.     return(rc);
  56.   return(count);
  57. }
  58.