home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LIBSRC.ZOO / libsrc / local / dup.c < prev    next >
Text File  |  1992-02-16  |  494b  |  31 lines

  1. #define INCL_DOSFILEMGR
  2. #define INCL_DOSERRORS
  3. #include <os2.h>
  4. #include <errno.h>
  5.  
  6. ULONG Dos32DupHandle() asm ("Dos32DupHandle");
  7.  
  8. int dup (int oldd, int newd)
  9. {
  10.    int newdesc = newd;
  11.    ULONG rc;
  12.  
  13.    rc = Dos32DupHandle (oldd, (PHFILE)&newd);
  14.  
  15.    if (rc)
  16.       if (rc == ERROR_TOO_MANY_OPEN_FILES)
  17.       {
  18.          errno = EMFILE;
  19.          return (-1);
  20.       }
  21.       else
  22.       {
  23.          errno = EBADF;
  24.          return (-1);
  25.       }
  26.  
  27.    return (newdesc);
  28. }
  29.  
  30.  
  31.