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

  1. /* dup.c (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes */
  2.  
  3. #include <sys/emx.h>
  4. #include <io.h>
  5. #include <errno.h>
  6.  
  7. int dup (int handle)
  8. {
  9.   int new;
  10.  
  11.   new = __dup (handle);
  12.   if (new < 0)
  13.     return (new);
  14.   if (new >= _nfiles)
  15.     {
  16.       __close (new);
  17.       errno = EMFILE;
  18.       return (-1);
  19.     }
  20.   _files[new] = _files[handle];
  21.   _lookahead[new] = _lookahead[handle];
  22.   return (new);
  23. }
  24.