home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / EMXLIB8F.ZIP / EMX / LIB / IO / EOF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-02  |  499 b   |  26 lines

  1. /* eof.c (emx+gcc) -- Copyright (c) 1990-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <io.h>
  5. #include <errno.h>
  6.  
  7. int eof (int handle)
  8. {
  9.   long cur, len;
  10.  
  11.   if (handle < 0 || handle >= _nfiles)
  12.     {
  13.       errno = EBADF;
  14.       return (-1);
  15.     }
  16.   if (_files[handle] & F_EOF)         /* Ctrl-Z reached */
  17.     return (1);
  18.   cur = tell (handle);
  19.   if (cur < 0)
  20.     return (-1);
  21.   len = filelength (handle);
  22.   if (len < 0)
  23.     return (-1);
  24.   return (cur == len);
  25. }
  26.