_dup.c

来自「UNIX下SH的实现源码」· C语言 代码 · 共 31 行

C
31
字号
/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
#ifdef __DJGPP__

#include <libc/stubs.h>
#include <unistd.h>
#include <dpmi.h>
#include <errno.h>
#include <io.h>
#include <libc/dosio.h>
#include <sys/fsext.h>

int
_dup(int fd)
{
  __dpmi_regs r;

  r.h.ah = 0x45;
  r.x.bx = fd;
  __dpmi_int(0x21, &r);
  if (r.x.flags & 1)
  {
    errno = __doserr_to_errno(r.x.ax);
    return -1;
  }
  setmode(r.x.ax, __file_handle_modes[fd]);
  return r.x.ax;
}

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?