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

📄 config.c

📁 minicom的源码,linux下常用的串口程序.
💻 C
📖 第 1 页 / 共 4 页
字号:
        return;      case 'A':        w1 = wopen(11, 8, 73, 17, BSINGLE, stdattr, mfcolor, mbcolor, 0, 0, 1);        wtitle(w1, TMID, _("Program new command key"));        wputs(w1, _(	   "\n Press the new command key. If you want to use\n"	   " the META or ALT key enter:\n\n"	   "  o SPACE if your meta key sets the 8th bit high\n"	   "  o ESC   if your meta key sends the ESCAPE prefix (standard)\n"           "\n\n Press new command key: "));        wredraw(w1, 1);        c = wxgetch();        wclose(w1, 1);        if (c  == ' ')          strcpy(buf, N_("Meta-8th bit "));        else if (c == 27)          strcpy(buf, N_("Escape (Meta)"));        else          sprintf(buf, "^%c           ", (c & 0x1f) + 'A' - 1);        psets(P_ESCAPE, buf);        wlocate(w, mbslen (command_key) + 1, 1);        wputs(w, _(buf));        clr = 1;        alt_override = 0;        switch(P_ESCAPE[0]) {          case '^':            c = P_ESCAPE[1] & 31;            break;          case 'E':            c = 27;            break;          default:            c = 128;            break;        }        keyboard(KSETESC, c);        if (st)          show_status();        break;      case 'B':        if (P_BACKSPACE[0] == 'D')          psets(P_BACKSPACE, "BS");        else          psets(P_BACKSPACE, "DEL");        wlocate(w, mbslen (backspace_key) + 1, 2);        wprintf(w, "%s ", P_BACKSPACE);        keyboard(KSETBS, P_BACKSPACE[0] == 'B' ? 8 : 127);        break;      case 'C':        if (P_STATLINE[0] == 'e') {          psets(P_STATLINE, N_("disabled"));          tempst = 1;        } else {          psets(P_STATLINE, N_("enabled"));          /* See if it fits on screen */          if (LINES > 24)            tempst = 0;        }        wlocate(w, mbslen (status_line) + 1, 3);        wprintf(w, "%s ", _(P_STATLINE));        break;      case 'D':        psets(P_SOUND, yesno(P_SOUND[0] == 'N'));        wlocate(w, mbslen (alarm_sound) + 1, 4);        wprintf(w, "%s", _(P_SOUND));        break;      case 'E': /* fmg - letters cycle colors */        if (mfcolor == WHITE)          mfcolor = BLACK;        else          mfcolor++;        psets(P_MFG, J_col[mfcolor]);        wlocate(w, mbslen (foreground_color_menu) + 1, 5);        wprintf(w, "%s   ", _(J_col[mfcolor]));        break;      case 'F': /* fmg - letters cycle colors */        if (mbcolor == WHITE)          mbcolor = BLACK;        else          mbcolor++;        psets(P_MBG, J_col[mbcolor]);        wlocate(w, mbslen (background_color_menu) + 1, 6);        wprintf(w, "%s   ", _(J_col[mbcolor]));        break;      case 'G': /* fmg - letters cycle colors */        if (tfcolor == WHITE)          tfcolor = BLACK;        else          tfcolor++;        psets(P_TFG, J_col[tfcolor]);        wlocate(w, mbslen (foreground_color_term) + 1, 7);        wprintf(w, "%s   ", _(J_col[tfcolor]));        if (us)          vt_pinit(us, tfcolor, tbcolor);        break;      case 'H': /* fmg - letters cycle colors */        if (tbcolor == WHITE)          tbcolor = BLACK;        else          tbcolor++;        psets(P_TBG, J_col[tbcolor]);        wlocate(w, mbslen (background_color_term) + 1, 8);        wprintf(w, "%s   ", _(J_col[tbcolor]));        if (us)          vt_pinit(us, tfcolor, tbcolor);        break;      case 'I': /* fmg - letters cycle colors & redraw stat line */        if (sfcolor == WHITE)          sfcolor = BLACK;        else          sfcolor++;        /* fmg - this causes redraw of status line (if any)           in current color */        if (st) {          wclose(st,0);          st = wopen(0, LINES - 1, COLS - 1, LINES - 1, BNONE,                     XA_NORMAL, sfcolor, sbcolor, 1, 0, 1);          show_status();        }        psets(P_SFG, J_col[sfcolor]);        wlocate(w, mbslen (foreground_color_stat) + 1, 9);        wprintf(w, "%s   ", _(J_col[sfcolor]));        break;      case 'J': /* fmg - letters cycle colors & redraw stat line */        if (sbcolor == WHITE)          sbcolor = BLACK;        else          sbcolor++;        /* fmg - this causes redraw of status line (if any)           in current color */        if (st) {          wclose(st,0);          st = wopen(0, LINES - 1, COLS - 1, LINES - 1, BNONE,                     XA_NORMAL, sfcolor, sbcolor, 1, 0, 0);          show_status();        }        psets(P_SBG, J_col[sbcolor]);        wlocate(w, mbslen (background_color_stat) + 1, 10);        wprintf(w, "%s   ", _(J_col[sbcolor]));        break;      case 'K': /* MARK updated 02/17/95 - Config history size */        pgets(w, mbslen (history_buffer_size) + 1, 11,              P_HISTSIZE, 5, 5);        /* In case gibberish or a value was out of bounds, */        /* limit history buffer size between 0 to 5000 lines */        /* 5000 line history at 80 columns consumes about */        /* 800 kilobytes including chars and attrs bytes! */        if (atoi(P_HISTSIZE) <= 0)           strcpy(P_HISTSIZE,"0");        else if (atoi(P_HISTSIZE) >= 5000)          strcpy(P_HISTSIZE,"5000");        wlocate(w, mbslen (history_buffer_size) + 1, 11);        wprintf(w, "%s     ", P_HISTSIZE);        break;      case 'L': /* fmg - get local macros storage file */        pgets(w, mbslen (macros_file) + 1, 12, P_MACROS, 64, 64);        /* Try to open the file to read it in. */        fp = sfopen(pfix_home(P_MACROS), "r+");        if (fp == NULL) {          if (errno == EPERM) {            /* Permission denied, hacker! */            werror(_("ERROR: you do not have permission to create a file there!"));            once = 'J'; /* fmg - re-enter it! */            continue;          }          if (errno != ENOENT) {            /* File does exist, but cannot be opened. */            werror(_("ERROR: cannot open macro file %s"),                   pfix_home(P_MACROS));          }          continue;        }        /* Read macros from the file. */        werror(_("Reading macros"));        readmacs(fp, 0);        fclose(fp);        break;      case 'M': /* fmg - Bring up macro editing window */        domacros();        break;      case 'N':        psets(P_MACENAB, yesno(P_MACENAB[0] == 'N'));        wlocate(w, mbslen (macros_enabled) + 1, 14);        wprintf(w, "%s", _(P_MACENAB));        break;      case 'O': /* Character conversions - jl / 04.09.97 */        doconv();        wlocate(w, mbslen (character_conversion) + 1, 15);        wprintf(w, "%-16.16s", _(P_CONVF));        break;      case 'P':        psets(P_ADDLINEFEED, yesno(P_ADDLINEFEED[0] == 'N'));        wlocate(w, strlen (add_linefeed) + 1, 15);        wprintf(w, "%s", _(P_ADDLINEFEED));        break;      case 'Q':        psets(P_LOCALECHO, yesno(P_LOCALECHO[0] == 'N'));        wlocate(w, strlen (local_echo) + 1, 16);        wprintf(w, "%s", _(P_LOCALECHO));        break;     }  }}/* * This is the 'T' menu - terminal parameters. Does NOT set the new * terminal type, but returns it to the calling functions that has * to call init_emul itself. */int dotermmenu(void){  WIN *w;  int c;  int new_term = -1;  int old_stat = P_STATLINE[0];  char buf[8];  char *terminal_emulation  = _(" A - Terminal emulation  :");  char *backspace_key_sends = _(" B - Backspace key sends :");  char *status_line         = _(" C -      Status line is :");  char *msg_nl_delay        = _(" D -  Newline delay (ms) :");  char *msg_answerback      = _(" E -      ENQ answerback :");  char *question            = _("Change which setting?");  w = wopen(15, 7, 64, 15, BDOUBLE, stdattr, mfcolor, mbcolor, 0, 0, 1);  wtitle(w, TMID, _("Terminal settings"));  wprintf(w, "\n");  wprintf(w, "%s %s\n", terminal_emulation, terminal == VT100 ? "VT102" : "ANSI");  wprintf(w, "%s %s\n", backspace_key_sends, P_BACKSPACE);  wprintf(w, "%s %s\n", status_line, _(P_STATLINE));  wprintf(w, "%s %d\n", msg_nl_delay, vt_nl_delay);  wprintf(w, "%s %s\n", msg_answerback, P_ANSWERBACK);  wlocate(w, 4, 7);  wputs(w, question);  wredraw(w, 1);  while (1) {    wlocate(w, mbslen (question) + 5, 7);    c = rwxgetch();    switch(c) {      case '\n':        wclose(w, 1);        /* If status line enabled/disabled resize screen. */        if (P_STATLINE[0] != old_stat && new_term < 0)          init_emul(terminal, 0);        return new_term;      case 'A':        if (new_term < 0)          new_term = terminal;        if (new_term == VT100) {          new_term = ANSI;          psets(P_BACKSPACE, "BS");        } else {          new_term = VT100;          psets(P_BACKSPACE, "DEL");        }        wlocate(w, mbslen (terminal_emulation) + 1, 1);        wprintf(w, "%s ", new_term == VT100 ? "VT102" : "ANSI");        wlocate(w, mbslen (backspace_key_sends) + 1, 2);        wprintf(w, "%s ", P_BACKSPACE);        keyboard(KSETBS, P_BACKSPACE[0] == 'B' ? 8 : 127);        break;      case 'B':        if (P_BACKSPACE[0] == 'D')          psets(P_BACKSPACE, "BS");        else          psets(P_BACKSPACE, "DEL");        wlocate(w, mbslen (backspace_key_sends) + 1, 2);        wprintf(w, "%s ", P_BACKSPACE);        keyboard(KSETBS, P_BACKSPACE[0] == 'B' ? 8 : 127);        break;      case 'C':        if (P_STATLINE[0] == 'e') {          psets(P_STATLINE, N_("disabled"));          tempst = 1;        } else {          psets(P_STATLINE, N_("enabled"));          /* See if it fits on screen */          if (LINES > 24 || use_status)            tempst = 0;        }        wlocate(w, mbslen (status_line) + 1, 3);        wprintf(w, "%s ", _(P_STATLINE));        break;      case 'D':        sprintf(buf, "%d", vt_nl_delay);        wlocate(w, mbslen(msg_nl_delay) +1, 4);        wgets(w, buf, 4, 4);        vt_nl_delay = atoi(buf);        wlocate(w, mbslen(msg_nl_delay) +1, 4);        wprintf(w, "%-3d", vt_nl_delay);        break;      case 'E':        pgets(w, strlen(msg_answerback) + 1, 5, P_ANSWERBACK, 50, 50);        break;      default:        break;    }  }}/* * Save the configuration. */void vdodflsave(void){  dodflsave();}/* * Save the configuration. */int dodflsave(void){  FILE *fp;  /* Root saves new configuration */  if (real_uid == 0) {    if ((fp = fopen(parfile, "w")) == (FILE *)NULL) {      werror(_("Cannot write to %s"), parfile);      return -1;    }    writepars(fp, 1);    fclose(fp);    werror(_("Configuration saved"));  } else {    /* Mortals save their own configuration */    if ((fp = sfopen(pparfile, "w")) == (FILE *)NULL) {      werror(_("Cannot write to %s"), pparfile);      return -1;    }    writepars(fp, 0);    fclose(fp);    werror(_("Configuration saved"));  }  if (domacsave() < 0) /* fmg - something went wrong... */    return -1;  return 0;}/* * Save the macros. (fmg) */int domacsave(void){  FILE *fp;  /* fmg - do some basic silly-mortal checks and allow for recovery */  if (!strcmp(P_MACCHG,"CHANGED")) {    if (strlen(P_MACROS) == 0) { /* fmg - they might want to know... */      werror(_("ERROR: Macros have changed but no filename is set!"));      return -1;    } else {      if ((fp = sfopen(pfix_home(P_MACROS), "w")) == (FILE *)NULL) {        werror(_("Cannot write macros file %s"),               pfix_home(P_MACROS));        return -1;      }      writemacs(fp);      fclose(fp);      werror(_("Macros saved"));      strcpy(P_MACCHG,"SAVED"); /* fmg - reset after save */      return 0;    }  }  return 0;}/* * Save the configuration, ask a name for it. */static void donamsave(void){  char ifile[128];  char *s;  if (real_uid != 0) {    werror(_("You are not allowed to create a configuration"));    return;  }  ifile[0] = 0;  s = input(_("Give name to save this configuration?"), ifile);  if (s != (char *)0 && *s != 0) {    snprintf(parfile, sizeof(parfile), "%s/minirc.%s", CONFDIR, s);    dodflsave();  }}static void (*funcs1[])(void) = {  dopath,  doproto,  doserial,  domodem,  doscrkeyb,  vdodflsave,  donamsave,  NULL,  NULL};char some_string[32];static char const *menu1[] = {  N_("Filenames and paths"),  N_("File transfer protocols"),  N_("Serial port setup"),  N_("Modem and dialing"),  N_("Screen and keyboard"),  some_string,  N_("Save setup as.."),  N_("Exit"),  N_("Exit from Minicom"),  NULL,};int config(int setup){  int c;  char *s;  /* Find out extension of parameter file */  s = parfile + strlen(CONFDIR) + 8;  snprintf(some_string, sizeof(some_string), _("Save setup as %s"), s);  if (!setup)    menu1[8] = NULL;  c = wselect(13, 10, menu1, funcs1, _("configuration"), stdattr, mfcolor, mbcolor);  if (c == 9)    return 1;  return 0;}/* fmg 1/11/94 Color names for menu */const char *J_col[] =  { N_("BLACK"), N_("RED"), N_("GREEN"), N_("YELLOW"),    N_("BLUE"), N_("MAGENTA"), N_("CYAN"), N_("WHITE") };static const char *speeds[] =   { "300", "1200", "2400", "4800" ,     "9600", "19200", "38400", "57600", "115200", "230400", "Curr" };/* * Ask user for Baudrate, Bits and Parity */void get_bbp(char *ba, char *bi, char *pa, char *stopb, int curr_ok){  int c;

⌨️ 快捷键说明

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