예제 #1
0
static u_char IPXCloseSocket(u_short port)
{
  ipx_socket_t *mysock;
  far_t ECBPtr;

  /* see if this socket is actually open */
  n_printf("IPX: close socket %x\n", port);
  mysock = ipx_find_socket(port);
  if (mysock == NULL) {
    n_printf("IPX: close of unopened socket\n");
    return (RCODE_SOCKET_NOT_OPEN);
  }
  /* cancel all pending events on this socket */
  n_printf("IPX: canceling all listen events on socket %x\n", port);
  ECBPtr = mysock->listenList;
  while (FARt_PTR(ECBPtr)) {
    if (IPXCancelEvent(ECBPtr) != RCODE_SUCCESS)
      return RCODE_CANNOT_CANCEL_EVENT;
    ECBPtr = mysock->listenList;
  }
  n_printf("IPX: canceling all AES events on socket %x\n", port);
  ECBPtr = mysock->AESList;
  while (FARt_PTR(ECBPtr)) {
    if (IPXCancelEvent(ECBPtr) != RCODE_SUCCESS)
      return RCODE_CANNOT_CANCEL_EVENT;
    ECBPtr = mysock->AESList;
  }
  /* now close the file descriptor for the socket, and free it */
  n_printf("IPX: closing file descriptor on socket %x\n", port);
  remove_from_io_select(mysock->fd);
  close(mysock->fd);
  ipx_remove_socket(mysock);
  n_printf("IPX: successfully closed socket %x\n", port);
  return (RCODE_SUCCESS);
}
예제 #2
0
static void midotmdty_done(void)
{
    const char *cmd1 = "CLOSE\n";
    const char *cmd2 = "QUIT\n";
    char buf[255];
    int n, status;

    if (TMDTY_CAPT)
	remove_from_io_select(data_sock, 1);

    write(ctrl_sock_out, cmd1, strlen(cmd1));
    n = read(ctrl_sock_in, buf, sizeof(buf) - 1);
    buf[n] = 0;
    S_printf("\tClose: %s\n", buf);
    if (!strstr(buf, "already closed")) {
	shutdown(data_sock, 2);
	close(data_sock);
    }
    write(ctrl_sock_out, cmd2, strlen(cmd2));
    n = read(ctrl_sock_in, buf, sizeof(buf) - 1);
    buf[n] = 0;
    S_printf("\tQuit: %s\n", buf);

    close(ctrl_sock_out);
    if (tmdty_pid != -1) {
	waitpid(tmdty_pid, &status, 0);
	tmdty_pid = -1;
    }
}
예제 #3
0
파일: mid_i_pipe.c 프로젝트: stuaxo/dosemu2
static void midipipe_done(void *arg)
{
    if (pipe_fd == -1)
	return;
    remove_from_io_select(pipe_fd);
    close(pipe_fd);
    pipe_fd = -1;
}
예제 #4
0
void ioselect_done(void)
{
    int i;
    for (i = 0; i < MAX_FD; i++) {
	if (io_callback_func[i].func) {
	    remove_from_io_select(i);
	    close(i);
	}
    }
}
예제 #5
0
파일: mhpdbg.c 프로젝트: andrewbird/dosemu2
void mhp_close(void)
{
   if (mhpdbg.fdin == -1) return;
   if (mhpdbg.active) {
     mhp_putc(1); /* tell debugger terminal to also quit */
     mhp_send();
   }
   remove_from_io_select(mhpdbg.fdin);
   unlink(pipename_in);
   free(pipename_in);
   unlink(pipename_out);
   free(pipename_out);
   mhpdbg.fdin = mhpdbg.fdout = -1;
   mhpdbg.active = 0;
}
예제 #6
0
static void raw_keyboard_close(void)
{
  if (kbd_fd != -1) {
    k_printf("KBD(raw): raw_keyboard_close: resetting keyboard to original mode\n");
    remove_from_io_select(kbd_fd);
    if (config.console_keyb == KEYB_RAW) {
      ioctl(kbd_fd, KDSKBMODE, save_mode);

      k_printf("KBD(raw): resetting LEDs to normal mode\n");
      ioctl(kbd_fd, KDSETLED, LED_NORMAL);
    }
    k_printf("KBD(raw): Resetting TERMIOS structure.\n");
    if (tcsetattr(kbd_fd, TCSAFLUSH, &save_termios) < 0) {
      k_printf("KBD(raw): Resetting keyboard termios failed.\n");
    }
    kbd_fd = -1;
  }
}