📄 ckuus3.c
字号:
printf(" Please respond Yes or No\n"); cmini(ckxech); } else { z = y; /* Save answer */ y = cmcfm(); /* Get confirmation */ } } while (y < 0); /* Continue till done */ cmsetp(psave); /* Restore real prompt */#ifdef VMS if (cmdlvl > 0) /* In VMS and not at top level, */ conres(); /* restore console again. */#endif /* VMS */ return(z);}int /* CHECK command */dochk() { int x, y; if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0) return(y); strcpy(line,atmbuf); if ((y = cmcfm()) < 0) return(y);#ifndef NOPUSH if (!xxstrcmp(atmbuf,"push",(int)strlen(atmbuf))) { if (msgflg) /* If at top level... */ printf(" push%s available\n", nopush ? " not" : ""); else if (nopush && !backgrd) printf(" CHECK: push not available\n"); return(success = 1 - nopush); }#endif /* NOPUSH */ y = lookup(ftrtab,line,nftr,&x); /* Look it up */ if (msgflg) /* If at top level... */ printf(" %s%s available\n", ftrtab[x].kwd, y ? " not" : ""); else if (y && !backgrd) printf(" CHECK: %s not available\n", ftrtab[x].kwd); return(success = 1 - y);}#ifndef NODIAL/* Parse a DIAL-related string, stripping enclosing braces, if any.*/static intdialstr(p,msg) char **p; char *msg; { int x; char *s; if ((x = cmtxt(msg, "", &s, xxstring)) < 0) return(x); s = brstrip(s); /* Strip braces around. */ makestr(p,s); return(success = 1);}VOIDinitmdm(x) int x; { MDMINF * p, * u; int m; mdmtyp = x; /* Set global modem type */ debug(F101,"initmdm mdmtyp","",mdmtyp); debug(F101,"initmdm usermdm","",usermdm); if (x < 1) return; m = usermdm ? usermdm : mdmtyp; p = modemp[m - 1]; /* Point to modem info struct, and */ debug(F101,"initmdm p","",p); if (p) { dialec = p->capas & CKD_EC; /* set DIAL ERROR-CORRECTION, */ dialdc = p->capas & CKD_DC; /* DIAL DATA-COMPRESSION, and */ mdmspd = p->capas & CKD_SB ? 0 : 1; /* DIAL SPEED-MATCHING from it. */ dialfc = FLO_AUTO; /* Modem's local flow control.. */ } else if (mdmtyp > 0) { printf("WARNING: modem info for \"%s\" not filled in yet\n", gmdmtyp() ); }/* Reset or set the SET DIAL STRING items ... */ if (usermdm && p) { /* USER-DEFINED: copy info from specified template */ makestr(&dialini,p->wake_str); makestr(&dialmstr,p->dmode_str); makestr(&dialmprmt,p->dmode_prompt); makestr(&dialcmd,p->dial_str); makestr(&dialdcon,p->dc_on_str); makestr(&dialdcoff,p->dc_off_str); makestr(&dialecon,p->ec_on_str); makestr(&dialecoff,p->ec_off_str); makestr(&dialhcmd,p->hup_str); makestr(&dialhwfc,p->hwfc_str); makestr(&dialswfc,p->swfc_str); makestr(&dialnofc,p->nofc_str); makestr(&dialtone,p->tone); makestr(&dialpulse,p->pulse); makestr(&dialname,"This space available (use SET MODEM NAME)"); dialmax = p->max_speed; dialcapas = p->capas; dialesc = p->esc_char; } else { /* Not user-defined, so wipe out overrides */ if (dialini) free(dialini); dialini = NULL; /* Init-string */ if (dialmstr) free(dialmstr); dialmstr = NULL; /* Dial-mode-str */ if (dialmprmt) free(dialmprmt); dialmprmt = NULL; /* Dial-mode-pro */ if (dialcmd) free(dialcmd); dialcmd = NULL; /* Dial-command */ if (dialdcon) free(dialdcon); dialdcon = NULL; /* DC ON command */ if (dialdcoff) free(dialdcoff); dialdcoff = NULL; /* DC OFF command */ if (dialecon) free(dialecon); dialecon = NULL; /* EC ON command */ if (dialecoff) free(dialecoff); dialecoff = NULL; /* EC OFF command */ if (dialhcmd) free(dialhcmd); dialhcmd = NULL; /* Hangup command */ if (dialhwfc) free(dialhwfc); dialhwfc = NULL; /* Flow control... */ if (dialswfc) free(dialswfc); dialswfc = NULL; if (dialnofc) free(dialnofc); dialnofc = NULL; if (dialtone) free(dialtone); dialtone = NULL; /* Dialing method */ if (dialpulse) free(dialpulse); dialpulse = NULL; if (dialname) free(dialname); dialname = NULL; /* Modem name */ } if (autoflow) /* Maybe change flow control */ setflow();#ifndef MINIDIAL#ifdef OLDTBCODE tbmodel = 0; /* If it's a Telebit, we don't know the model yet */#endif /* OLDTBCODE */#endif /* MINIDIAL */}intsetmodem() { /* SET MODEM */ int x, y, z; long zz; char *s; if ((x = cmkeyx(setmdm,nsetmdm,"modem parameter","", xxstring)) < 0) { debug(F111,"setmodem cmkeyx","atmbuf",x); if (x == -9) { extern int cmflgs; debug(F101,"setmodem cmflgs","",cmflgs); if (!atmbuf[0]) return(-3); y = lookup(mdmtab,atmbuf,nmdm,&x); /* Maybe old SET MODEM <type> */ if (y == -2) { /* Look up in modem table.... */ printf("?Ambiguous modem type - %s\n",atmbuf); return(-9); } else if (y < 0) { printf("?\"%s\" does not match a keyword or modem type\n", atmbuf); return(-9); } if (!cmflgs) if ((x = cmcfm()) < 0) /* Confirm */ return(x); usermdm = 0; initmdm(y); /* Set it. */ return(success = 1); /* Done */ } else return(x); } switch (x) {#ifdef MDMHUP case XYDMHU: /* DIAL MODEM-HANGUP */ if ((y = cmkey(mdmhang,3,"how to hang up modem", "modem-command", xxstring)) < 0) return(y); if ((x = cmcfm()) < 0) return(x); dialmhu = y; return(success = 1);#endif /* MDMHUP */ case XYDCAP: zz = 0L; y = 0; while (y != -3) { if ((y = cmkey(mdmcap,nmdmcap, "capability of modem", "", xxstring)) < 0) { if (y == -3) break; else return(y); } zz |= y; } dialcapas = zz; if (autoflow) /* Maybe change flow control */ setflow(); return(success = 1); case XYDMAX: if ((x = cmkey(spdtab,nspd,line,"",xxstring)) < 0) { if (x == -3) printf("?value required\n"); return(x); } if ((y = cmcfm()) < 0) return(y); dialmax = (long) x * 10L; if (dialmax == 70) dialmax = 75; return(success = 1); case XYDSTR: /* These moved from SET DIAL */ case XYDDC: case XYDEC: case XYDESC: case XYDFC: case XYDKSP: case XYDSPD: case XYDDIA: return(setdial(x)); case XYDTYP: if ((y = cmkey(mdmtab,nmdm,"modem type","none", xxstring)) < 0) return(y); if (y == dialudt) { /* User-defined modem type */ if ((x = cmkey(mdmtab,nmdm,"based on existing modem type", "unknown", xxstring)) < 0) return(x); } if ((z = cmcfm()) < 0) return(z); usermdm = 0; usermdm = (y == dialudt) ? x : 0; initmdm(y); return(success = 1); case XYDNAM: return(dialstr(&dialname,"Descriptive name for modem")); case XYDMCD: /* SET MODEM CARRIER */ return(success = setdcd()); default: printf("Unexpected SET MODEM parameter\n"); return(-9); }}static int /* Set DIAL command options */setdial(y) int y; { int x, z; char *s; if (y < 0) if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0) return(y); switch (y) { case XYDHUP: /* DIAL HANGUP */ return(seton(&dialhng)); case XYDINI: /* DIAL INIT-STRING */ return(dialstr(&dialini,"Modem initialization string")); case XYDNPR: /* DIAL PREFIX */ return(dialstr(&dialnpr,"Telephone number prefix")); case XYDDIA: /* DIAL DIAL-COMMAND */ x = cmtxt("Dialing command for modem,\n\ include \"%s\" to stand for phone number,\n\ for example, \"set dial dial-command ATDT%s\\13\"", "", &s, xxstring); if (x < 0 && x != -3) /* Handle parse errors */ return(x); y = x = strlen(s); /* Get length of text */ if (x > 0 && *s == '{') { /* Strip enclosing braces, */ if (s[x-1] == '}') { /* if any. */ s[x-1] = NUL; s++; y -= 2; } } if (y > 0) { /* If there is any text (left), */ for (x = 0; x < y; x++) { /* make sure they included "%s" */ if (s[x] != '%') continue; if (s[x+1] == 's') break; } if (x == y) { printf("?Dial-command must contain \"%cs\" for phone number.\n",'%'); return(-9); } } if (dialcmd) { /* Free any previous string. */ free(dialcmd); dialcmd = (char *) 0; } if (y > 0) { dialcmd = malloc(y + 1); /* Allocate space for it */ strcpy(dialcmd,s); /* and make a safe copy. */ } return(success = 1); case XYDKSP: /* DIAL KERMIT-SPOOF */ return(seton(&dialksp)); case XYDTMO: /* DIAL TIMEOUT */ y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring); if (y < 0) return(y); y = cmnum("Kermit/modem timeout differential","10",10,&z,xxstring); if (y < 0) return(y); if ((y = cmcfm()) < 0) return(y); dialtmo = x; mdmwaitd = z; case XYDESC: /* DIAL ESCAPE-CHARACTER */ y = cmnum("ASCII value of character to escape back to modem", "43",10,&x,xxstring); return(setnum(&dialesc,x,y,128)); case XYDDPY: /* DIAL DISPLAY */ return(seton(&dialdpy)); case XYDSPD: /* DIAL SPEED-MATCHING */ /* used to be speed-changing */ if ((y = seton(&mdmspd)) < 0) return(y);#ifdef COMMENT mdmspd = 1 - mdmspd; /* so here we reverse the meaning */#endif /* COMMENT */ return(success = 1); case XYDMNP: /* DIAL MNP-ENABLE */ case XYDEC: /* DIAL ERROR-CORRECTION */ x = seton(&dialec); if (x > 0) if (!dialec) dialdc = 0; /* OFF also turns off compression */ return(x); case XYDDC: /* DIAL COMPRESSION */ x = seton(&dialdc); if (x > 0) if (dialdc) dialec = 1; /* ON also turns on error correction */ return(x);#ifdef MDMHUP case XYDMHU: /* DIAL MODEM-HANGUP */ return(seton(&dialmhu));#endif /* MDMHUP */ case XYDDIR: /* DIAL DIRECTORY (zero or more) */ return(parsdir(0)); /* 0 means DIAL */ case XYDSTR: /* DIAL STRING */ if ((y = cmkey(dial_str,ndstr,"","",xxstring)) < 0) return(y); switch (y) { case XYDS_AN: /* Autoanswer ON/OFF */ case XYDS_DC: /* Data compression ON/OFF */ case XYDS_EC: /* Error correction ON/OFF */ if ((x = cmkey(onoff,2,"","on",xxstring)) < 0) return(x); sprintf(tmpbuf,"Modem's command to %sable %s", x ? "en" : "dis", (y == XYDS_DC) ? "compression" : ((y == XYDS_EC) ? "error-correction" : "autoanswer") ); if (x) { if (y == XYDS_DC) return(dialstr(&dialdcon,tmpbuf)); else if (y == XYDS_EC) return(dialstr(&dialecon,tmpbuf)); else return(dialstr(&dialaaon,tmpbuf)); } else { if (y == XYDS_DC) return(dialstr(&dialdcoff,tmpbuf)); else if (y == XYDS_EC) return(dialstr(&dialecoff,tmpbuf)); else return(dialstr(&dialaaoff,tmpbuf)); } case XYDS_HU: /* hangup command */ return(dialstr(&dialhcmd,"Modem's hangup command")); case XYDS_HW: /* hwfc */ return(dialstr(&dialhwfc, "Modem's command to enable hardware flow control")); case XYDS_IN: /* init */ return(dialstr(&dialini,"Modem's initialization string")); case XYDS_NF: /* no flow control */ return(dialstr(&dialnofc, "Modem's command to disable local flow control")); case XYDS_PX: /* prefix */ return(dialstr(&dialnpr,"Telephone number prefix for dialing")); case XYDS_SW: /* swfc */ return(dialstr(&dialswfc, "Modem's command to enable local software flow control")); case XYDS_DT: /* tone dialing */ return(dialstr(&dialtone, "Command to configure modem for tone dialing")); case XYDS_DP: /* pulse dialing */ return(dialstr(&dialpulse, "Command to configure modem for pulse dialing")); case XYDS_MS: /* dial mode string */ return(dialstr(&dialmstr, "Command to enter dial mode")); case XYDS_MP: /* dial mode prompt */ return(dialstr(&dialmprmt, "Modem response upon entering dial mode")); default: printf("?Unexpected SET DIAL STRING parameter\n"); } case XYDFC: /* DIAL FLOW-CONTROL */ if ((y = cmkey(dial_fc,4,"","auto",xxstring)) < 0) return(y); if ((x = cmcfm()) < 0) return(x); dialfc = y; return(success = 1); case XYDMTH: /* DIAL METHOD */ if ((y = cmkey(dial_m,3,"","default",xxstring)) < 0) return(y); if ((x = cmcfm()) < 0) /* DEFAULT means don't force */ return(x); /* any particular method, use */ dialmth = y; /* modem's default method. */ return(success = 1); case XYDRTM: y = cmnum("Number of times to try dialing a number", "1",10,&x,xxstring); return(setnum(&dialrtr,x,y,16383)); case XYDINT: y = cmnum("Seconds to wait between redial attempts", "30",10,&x,xxstring); return(setnum(&dialint,x,y,128)); case XYDLAC: /* DIAL AREA-CODE */ if ((x = dialstr(&diallac,"Area code you are calling from")) < 0) return(x); if (diallac) { if (!rdigits(diallac)) { printf("?Sorry, area code must be numeric\n"); if (*diallac == '(') printf("(please omit the parentheses)\n"); if (*diallac == '/') printf("(no slashes, please)\n"); if (diallac) free(diallac); diallac = NULL; return(-9); } } return(x); case XYDCNF: /* CONFIRMATION */ return(success = seton(&dialcnf)); case XYDCVT: /* CONVERT-DIRECTORY */ if ((y = cmkey(dcnvtab,3,"","ask",xxstring)) < 0) return(y); if ((x = cmcfm()) < 0) return(x); dialcvt = y; return(success = 1); case XYDLCC: /* DIAL COUNTRY-CODE */ x = dialstr(&diallcc,"Country code you are calling from"); if (x < 1) return(x); if (diallcc) { if (!rdigits(diallcc)) { printf("?Sorry, country code must be numeric\n"); if (*diallcc == '+') printf("(please omit the plus sign)\n"); if (diallcc) free(diallcc); diallcc = NULL; return(-9); } if (!strcmp(diallcc,"1")) { /* Set defaults for USA and Canada */ if (!dialldp) /* Long-distance prefix */ makestr(&dialldp,"1"); if (!dialixp) /* International dialing prefix */ makestr(&dialixp,"011"); if (ntollfree == 0) { /* Toll-free area codes */ if (dialtfc[0] = malloc(4)) { strcpy(dialtfc[0],"800"); ntollfree++; } if (dialtfc[1] = malloc(4)) { strcpy(dialtfc[1],"888"); ntollfree++; } } if (!dialtfp) /* Toll-free dialing prefix */ makestr(&dialtfp,"1"); } else if (!strcmp(diallcc,"358") && ((int) strcmp(zzndate(),"19961011") > 0) ) { /* Finland */ if (!dialldp) /* Long-distance prefix */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -