⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 在MAC OS下的一个可以直接调试modem的工具minicom,类似于是在windows下的超级终端.
💻 C
📖 第 1 页 / 共 2 页
字号:
  /* MARK updated 02/17/95 - Customizable size for history buffer */  num_hist_lines = atoi(P_HISTSIZE);  if (num_hist_lines < 0)    num_hist_lines = 0;  if (num_hist_lines > 5000)    num_hist_lines = 5000;  /* Open a new main window, and define the configured history buffer size. */  us = mc_wopen(0, 0, COLS - 1, maxy,              BNONE, XA_NORMAL, tfcolor, tbcolor, 1, num_hist_lines, 0);  if (x >= 0) {    mc_wlocate(us, x, y);    mc_wsetattr(us, attr);  }  us->autocr = 0;  us->wrap = wrapln;  terminal = type;  lines = LINES - (st != NULL);  cols = COLS;  /* Install and reset the terminal emulator. */  if (do_init) {    vt_install(do_output, kb_handler, us);    vt_init(type, tfcolor, tbcolor, us->wrap, addlf);  } else    vt_pinit(us, -1, -1);  if (st)    show_status();}/* * Locate the cursor at the correct position in * the user screen. */static void ret_csr(void){  mc_wlocate(us, us->curx, us->cury);  mc_wflush();}/* * Show baudrate, parity etc. */void mode_status(void){  if (st) { /* if swich off status line - NOT print !!! (vlk@st.simbirsk.su) */    mc_wlocate(st, 20, 0);    if (portfd_is_socket) {      mc_wprintf(st, "unix-socket");    } else {      if (P_SHOWSPD[0] == 'l')        mc_wprintf(st, "%6ld %s%s%s", linespd, P_BITS, P_PARITY, P_STOPB);      else        mc_wprintf(st, "%6.6s %s%s%s", P_BAUDRATE, P_BITS, P_PARITY, P_STOPB);    }    ret_csr();  }}/* * Show offline or online time. * If real dcd is not supported, Online and Offline will be * shown in capitals. */void time_status(void){  if (!st || disable_online_time)    return;  mc_wlocate(st, 63, 0);  if (online < 0)    mc_wprintf(st, " %12.12s ", P_HASDCD[0] == 'Y' ? _("Offline") : _("OFFLINE"));  else    mc_wprintf(st, " %s %02ld:%02ld", P_HASDCD[0] == 'Y' ? _("Online") : _("ONLINE"),            online / 3600, (online / 60) % 60);  ret_csr();}/* * Show in which mode the cursor keys are (normal or application) */void curs_status(void){  mc_wlocate(st, 33, 0);  mc_wprintf(st, cursormode == NORMAL ? "NOR" : "APP");  ret_csr();}time_t old_online = -1;/* * Update the online time. */static void updtime(void){  if (old_online == online)    return;  if ((P_LOGCONN[0] == 'Y') && (old_online >= 0) && (online < 0)) {    do_log(_("Gone offline (%ld:%02ld:%02ld)"),           old_online / 3600, (old_online / 60) % 60, old_online % 60);  }  old_online = online;  if (st) {    time_status();    ret_csr();  }  mc_wflush();}/** * Get status of device. It might happen that the device disappears (e.g. * due to a USB-serial unplug). * * \return 1 if device seems ok, 0 if it seems not available */static int get_device_status(int fd){  struct termios t;  if (fd < 0)    return 0;  if (portfd_is_socket && portfd_is_connected)    return 1;  return !tcgetattr(fd, &t);}/* Update the timer display. This can also be called from updown.c */void timer_update(void){  static time_t t1, start;  int dcd_support = P_HASDCD[0] == 'Y';  /* See if we're online. */  if ((!dcd_support && bogus_dcd)      || (dcd_support && m_getdcd(portfd) == 1)) {    /* We are online at the moment. */    if (online < 0) {      /* This was a transition from off to online */      time(&start);      t1 = start;      online = 0;      updtime();#ifdef _DCDFLOW      /* DCD has gotten high, we can turn on hw flow control */      if (P_HASRTS[0] == 'Y')        m_sethwf(portfd, 1);#endif    }  } else {    /* We are offline at the moment. */#ifdef _DCDFLOW    if (online >= 0) {      /* DCD has dropped, turn off hw flow control. */      m_sethwf(portfd, 0);    }#endif    if (online >= 0 && old_online >= 0) {      /* First update the timer for call duration.. */      time(&t1);      online = t1 - start;      updtime();    }    /* ..and THEN notify that we are now offline */    online = -1;    updtime();  }  /* Update online time */  if (online >= 0) {    time(&t1);    online = t1 - start;    if (online > (old_online + 59))      updtime();  }}/* * Show the status line  */void show_status(void){  st->direct = 0;  mc_wlocate(st, 0, 0);  mc_wprintf(st,          _(" %7.7sZ for help |           |     | Minicom %-6.6s |       | "),          esc_key(), VERSION);  mode_status();  time_status();  curs_status();  mc_wlocate(st, 56, 0);  switch(terminal) {    case VT100:      mc_wputs(st, "VT102");      break;    case ANSI:      mc_wputs(st, "ANSI");      break;  }  mc_wredraw(st, 1);  ret_csr();}/* * Show the name of the script running now. */void scriptname(const char *s){  if (st == NULL)    return;  mc_wlocate(st, 39, 0);  if (*s == 0)    mc_wprintf(st, "Minicom %-6.6s", VERSION);  else    mc_wprintf(st, "script %-7.7s", s);  ret_csr();}/* * Show status line temporarily */static void showtemp(void){  if (st)    return;  st = mc_wopen(0, LINES - 1, COLS - 1, LINES - 1,             BNONE, st_attr, sfcolor, sbcolor, 1, 0, 1);  show_status();  tempst = 1;}/* * The main terminal loop: *	- If there are characters received send them *	  to the screen via the appropriate translate function. */int do_terminal(void){  char buf[128];  char *ptr;  int c;  int x;  int blen;  int zauto = 0;  static const char zsig[] = "**\030B00";  int zpos = 0;  const char *s;  dirflush = 0;  WIN *error_on_open_window = NULL;dirty_goto:  /* Show off or online time */  updtime();  /* If the status line was shown temporarily, delete it again. */  if (tempst) {    tempst = 0;    mc_wclose(st, 1);    st = NULL;  }  /* Auto Zmodem? */  if (P_PAUTO[0] >= 'A' && P_PAUTO[0] <= 'Z')    zauto = P_PAUTO[0];  /* Set the terminal modes */  setcbreak(2); /* Raw, no echo */  keyboard(KSTART, 0);  /* Main loop */  while (1) {    /* See if window size changed */    if (size_changed) {      size_changed = 0;#if 1      /* I got the resize code going again! Yeah! */      mc_wclose(us, 0);      us = NULL;      if (st)        mc_wclose(st, 0);      st = NULL;      mc_wclose(stdwin, 0);      if (win_init(tfcolor, tbcolor, XA_NORMAL) < 0)        leave(_("Could not re-initialize window system."));      /* Set the terminal modes */      setcbreak(2); /* Raw, no echo */      init_emul(terminal, 0);#else      werror(_("Resize not supported, screen may be messed up!"));#endif    }    /* Update the timer. */    timer_update();    /* check if device is ok, if not, try to open it */    if (!get_device_status(portfd_connected)) {      if (open_term(0, 0) < 0) {	if (!error_on_open_window)          error_on_open_window = mc_tell(_("Cannot open %s!"), dial_tty);      } else {	if (error_on_open_window) {          mc_wclose(error_on_open_window, 1);	  error_on_open_window = NULL;	}      }    }    /* Check for I/O or timer. */    x = check_io(portfd_connected, 0, 1000, buf, &blen);    /*  Send data from the modem to the screen. */    if ((x & 1) == 1) {      ptr = buf;      while (blen-- > 0) {        /* Auto zmodem detect */        if (zauto) {          if (zsig[zpos] == *ptr)            zpos++;          else            zpos = 0;        }        if (P_PARITY[0] == 'M' || P_PARITY[0] == 'S')          *ptr &= 0x7f;        vt_out(*ptr++);        if (zauto && zsig[zpos] == 0) {          dirflush = 1;          keyboard(KSTOP, 0);          updown('D', zauto - 'A');          dirflush = 0;          zpos = 0;          blen = 0;          goto dirty_goto;        }      }      mc_wflush();    }    /* Read from the keyboard and send to modem. */    if ((x & 2) == 2) {      /* See which key was pressed. */      c = keyboard(KGETKEY, 0);      if (c < 0) /* XXX - shouldn't happen */        c += 256;      /* Was this a command key? */      if ((escape == 128 && c > 224 && c < 252) ||          (escape != 27 && c == escape) ||          (c > K_META)) {        /* Stop keyserv process if we have it. */        keyboard(KSTOP, 0);        /* Show status line temporarily */        showtemp();        if (c == escape) /* CTRL A */          c = keyboard(KGETKEY, 0);        /* Restore keyboard modes */        setcbreak(1); /* Cbreak, no echo */        if (c > K_META)          c -= K_META;        if (c > 128)          c -= 128;        if (c > ' ') {          dirflush = 1;          m_flush(0);          return c;        }        /* CTRLA - CTRLA means send one CTRLA */#if 0        write(portfd, &c, 1);#else        vt_send(c);#endif        goto dirty_goto;      }      /* No, just a key to be sent. */      if (c >= K_F1 && c <= K_F10 && P_MACENAB[0] == 'Y') {        s = "";        switch(c) {          case K_F1: s = P_MAC1; break;          case K_F2: s = P_MAC2; break;          case K_F3: s = P_MAC3; break;          case K_F4: s = P_MAC4; break;          case K_F5: s = P_MAC5; break;          case K_F6: s = P_MAC6; break;          case K_F7: s = P_MAC7; break;          case K_F8: s = P_MAC8; break;          case K_F9: s = P_MAC9; break;          case K_F10: s = P_MAC10; break;        }        if (*s)          mputs(s, 1);        else          vt_send(c);      } else        vt_send(c);    }  }}

⌨️ 快捷键说明

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