📄 ckuus6.c
字号:
else printf(" Lookup: \"%s\" - uniquely matches \"%s\"\n", s, d_name ); } if ((cx == XXLOOK) || (n > 1) && !quiet && !backgrd && dialdpy) { printf(" %d telephone number%sfound for \"%s\"%s\n", n, (n == 1) ? " " : "s ", s, (n > 0) ? ":" : "." ); s3 = getdname(); } for (i = 0; i < n; i++) { /* Convert */ dn_x[i] = -1; if (dncvt(i,cx) < 0) { if (cx != XXLOOK) { dialsta = DIA_DIR; return(-9); } } } if (dialsrt && n > 1) { /* Sort into optimal order */ for (i = 0; i < n-1; i++) { for (j = i+1; j < n; j++) { if (dn_x[j] < dn_x[i]) { t = dn_x[j]; dn_x[j] = dn_x[i]; dn_x[i] = t; p = dn_p[j]; dn_p[j] = dn_p[i]; dn_p[i] = p; p = dn_p2[j]; dn_p2[j] = dn_p2[i]; dn_p2[i] = p; } } } } if ((cx == XXLOOK) || (n > 1) && !quiet && !backgrd && dialdpy) { int nn = n; if (cx != XXLOOK) if (n > 12) nn = 12; for (i = 0; i < nn; i++) { printf("%3d. %-12s %-20s => %-20s (%d)\n",i+1, s3, dn_p[i], dn_p2[i] ? dn_p2[i] : "(processing failed)", dn_x[i] ); } if (cx != XXLOOK && n != nn) printf("And %d more...\n", n - nn); } } else if (n == 0) { /* Not found in directory */ makestr(&(dn_p[0]),literal ? s : dscopy); makestr(&d_name,literal ? s : dscopy); dncount = 1; n = 1; if (dncvt(0,cx) < 0) { /* In case they typed a */ dialsta = DIA_DIR; /* portable-format number ... */ return(-9); } }#ifdef NETCONN /* It's not good that the networks directory depends on NOT-NODIAL.. */ if (cx == XXLOOK && dscopy) { /* Networks here too... */ extern char *nh_p[], *nh_p2[], *n_name; extern char *nh_px[4][MAXDNUMS+1]; n = 0; if (nnetdir > 0) { /* Do we have a network directory? */ dirline = 0; n = lunet(dscopy); /* Look up what the user typed */ } if (n > -1) { int k; if (cx == XXLOOK && n == 0) printf(" Lookup: \"%s\" - not found\n",dscopy); else printf("%s %d network entr%s found for \"%s\"%s\n", cx == XXLOOK ? " Lookup:" : "", n, (n == 1) ? "y" : "ies", dscopy, (n > 0) ? ":" : "." ); for (i = 0; i < n; i++) { printf("%3d. %-12s => %-9s %s", i+1,n_name,nh_p2[i],nh_p[i]); for (k = 0; k < 4; k++) { if (nh_px[k][i]) printf(" %s",nh_px[k][i]); else break; } printf("\n"); } } }#endif /* NETCONN */ if (cx == XXLOOK) return(success = 1); } /* cx != XXANSW */#ifdef VMS conres(); /* So Ctrl-C/Y will work */#endif /* VMS *//* Some modems do not react well to parity. Also, if we are dialing through a TCP/IP TELNET modem server, parity can be fatally misinterpreted as TELNET negotiations. This should work even if the user interrupts the DIAL command, because the DIAL module has its own interrupt handler. BUT... if, for some reason, a dialing device actually *requires* parity (e.g. CCITT V.25bis says that even parity should be used), this might prevent successful dialing. For that reason, we don't do this for V.25bis modems.*/ sparity = parity; /* Save current parity */ if (dialcapas & CKD_V25 == 0) /* If not V.25bis... */ parity = 0; /* Set parity to NONE */ if (cx == XXANSW) { /* ANSWER */ success = ckdial("",0,0,1); goto dialfin; }/* Edit 192 adds the ability to dial repeatedly. */ i = 0; do { if (i > 0) printf("\nDial attempt %d of %d...\n", i+1, dialrtr); success = 0; /* And the ability to dial alternate numbers. */ /* Loop to dial each in a list of numbers for the same name... */ for (j = 0; j < n && !success; j++) { /* until one answers. */ s = dn_p2[j]; /* Next number in list */ if (dn_x[j] >= dialrstr) { /* Dial restriction */ printf("Restricted: %s, skipping...\n",dn_p[j]); continue; } if (!s) s = dn_p[j]; if (i == 0 && dialcnf) { printf("Dialing %s\n",s); x = getyesno(" Is this number correct? "); if (!x) { char **p;#ifdef CK_RECALL int sv_recall; extern int on_recall;#endif /* CK_RECALL */ cmsavp(psave,PROMPTL); cmsetp(#ifdef OS2" Please enter the correct number,\r\n or press Enter to skip: "#else" Please enter the correct number,\r\n or press Return to skip: "#endif /* OS2 */); cmini(ckxech); x = -1; if (pflag) prompt(NULL);#ifdef CK_RECALL sv_recall = on_recall; on_recall = 0;#endif /* CK_RECALL */ y = cmdgquo(); cmdsquo(0); while (x < 0) { x = cmtxt("Corrected phone number","",&s,NULL); cmres(); } if ((int) strlen(s) < 1) { cmsetp(psave); continue; } makestr(&(dn_p2[j]), s); cmdsquo(y);#ifdef CK_RECALL on_recall = sv_recall;#endif /* CK_RECALL */ cmsetp(psave); } }#ifdef COMMENT/* for testing without dialing ... */ success = 0;#else success = ckdial(s,i,j,partial ? 3 : 0); /* Dial it */ if (!success) if (dialsta < 8 || /* Break out if unrecoverable error */ dialsta == DIA_INTR || dialsta == DIA_ERR || previous == DIA_PART ) break;#endif /* COMMENT */ } if (success) /* Succeeded, leave the outer loop */ break; if (dialsta < 8 || /* Break out if unrecoverable error */ dialsta == DIA_INTR || dialsta == DIA_ERR || previous == DIA_PART) break; if (++i >= dialrtr) /* Break out if too many tries */ break; if (!backgrd && !quiet) { printf("\nWill redial in %d second%s- press any key to redial immediately.\n", dialint, dialint == 1 ? " " : "s " ); printf("Ctrl-C to cancel...\n"); } x = dialint; /* Redial interval */ while (x-- > 0) { if (y = conchk()) /* Did they type something? */ break; /* If so, wake up */ sleep(1); /* No interrupt, sleep a sec */ } } while (!success); dialfin: if (cx != XXLOOK) { bleep(success ? BP_NOTE : BP_FAIL);#ifdef OS2 setint(); /* Fix OS/2 interrupts */#endif /* OS2 */ if (sparity > -1) parity = sparity; /* Restore parity if we saved it */#ifdef OS2 ttres(); /* Restore DIAL device */#endif /* OS2 */#ifdef VMS concb((char)escape); /* Restore console */#endif /* VMS */#ifdef OS2 { /* Set session title */ char * p, name[72]; /* in window list. */ char * q; if (cx == XXANSW) { q = "Incoming call"; } else { if (d_name) q = d_name; else if (dialnum) q = dialnum; else if (ttname[0]) q = ttname; else q = ""; } p = name; if (success) { strncpy(name,q,48); while (*p) { /* Uppercase it for emphasis. */ if (islower(*p)) *p = toupper(*p); p++; } } else name[0] = '\0' ; os2settitle((char *) name, TRUE); }#endif /* OS2 */ } return(success);}#endif /* NODIAL *//* D O T Y P E -- Type a file */intdotype(file) char * file; { /* Do the TYPE command */#ifdef VMS char command[512]; sprintf(command,"type %s",file); /* Construct TYPE command */ conres(); /* Let user interrupt */ success = zshcmd((char *)command); /* Execute it */ concb((char)escape); /* Back to console CBREAK mode */ return(success);#else char * p, name[257]; #ifdef MAC int count = 100;#endif /* MAC */ int rc = 1; int c; int save; save = binary; /* Save file type */#ifdef OS2 if (*file) { strcpy( name, file ); /* Change / to \. */ p = name; while (*p) { if (*p == '/') *p = '\\'; p++; } } else return(0);#else strcpy(name, file);#endif /* OS2 */ if (zchki(name) == -2) /* It's a directory */ return(0); binary = 0; /* Set file type to text for zopeni */ if (!zopeni(ZIFILE, name)) { /* Not a directory, open it */ binary = save; /* Failed, restore file type */ return(0); /* and return */ } while ((c = zminchar()) != -1) { /* Loop for all characters in file */#ifdef MAC /* * It is expensive to run the miniparser so don't do it for * every character. */ if (--count < 0) { count = 100; miniparser(1); if (sstate == 'a') { sstate = '\0'; rc = 0; break; } }#else /* Not MAC */ if (putchar(c) == EOF) { /* Echo character on screen */ rc = 0; break; }#endif /* MAC */ } zclose(ZIFILE); /* Done, close the file */ binary = save; return(rc);#endif /* VMS */}int /* Do the DIRECTORY command */dodir() {#ifndef MAC char *dc;#endif /* MAC */#ifdef MAC/* This is a crude, do-it-yourself directory command. It shows all the files in the current directory: size and name of each file. Only regular files are shown. With a little more work, it could also show directories, and mark files as regular or directories, and it could also show dates. See sample code in zldir() routine in ckmfio.c.*/ char mac_name[65]; long mac_len, nfiles, nbytes; extern long mac_znextlen; /* See ckmfio.c for this. */ if ((y = cmcfm()) < 0) return(y); nfiles = nbytes = 0L; printf("\nDirectory of %s\n\n",zgtdir()); x = zxpand(":"); while (x-- > 0) { if (!znext(mac_name)) break; mac_len = zchki(mac_name); if (mac_len > -1L) { nfiles++; nbytes += mac_znextlen; printf("%10ld %s\n", mac_znextlen, mac_name); } } printf("\n%ld file%s, %ld byte%s\n\n", nfiles, (nfiles == 1) ? "" : "s", nbytes, (nbytes == 1) ? "" : "s" ); return(success = 1);#else#ifdef VMS if ((x = cmtxt("Directory/file specification","",&s,xxstring)) < 0) return(x); /* now do this the same as a shell command - helps with LAT */ conres(); /* Make console normal */ lp = line; if (!(dc = getenv("CK_DIR"))) dc = DIRCMD; sprintf(lp,"%s %s",dc,s); debug(F110,"DIR string", line, 0); x = zshcmd(lp); debug(F101,"DIR return code", "", x); concb((char)escape); return(success = (x > 0) ? 1 : 0);#else#ifdef AMIGA if ((x = cmtxt("Directory/file specification","",&s,xxstring)) < 0) return(x);#else#ifdef datageneral if ((x = cmtxt("Directory/file specification","+",&s,xxstring)) < 0) return(x);#else#ifdef OS2#ifdef ONETERMUPD { char name[257], *p = NULL; char * mstr = NULL, * dstr = NULL; long len, ndirs, nfiles, nbytes; short month, date, year, hour, minute, seconds; /* Note: cmifi2() parses a filespec OR a directory name */ x = cmifi2("Device, directory, and/or file specification", "*", &s, &y, 1, NULL, xxstring ); if (x == -4 || x == -1) return(x); if (x == -2) {#ifdef OS2 if (!ckindex(".",s,1,0,0) && !ckindex("*",s,1,0,0)) { if (s[1] == ':' && s[2] == NUL) /* e.g. "dir a:" */ sprintf(line,"%s*.*",s); else sprintf(line,"%s.*",s); s = line; if (zxpand(s) < 1) { printf("%s - not found\n",s); return(-9); } } else {#endif /* OS2 */ printf("%s - not found\n",s); return(-9);#ifdef OS2 }#endif /* OS2 */ } if ((y = cmcfm()) < 0) return(y); /* Lower-level functions change / to \. */ p = s; while (*p) { /* Change them back to \ */ if (*p == '/') *p = '\\'; p++; } ndirs = nfiles = nbytes = 0L; printf("\nDirectory of %s\n\n",s); if (zchki(s) == -2) { /* Found a directory */#ifdef OS2 if (p != s) { p--; if (*p == '\\' || *p == '/') strcat(s, "*.*"); else if (*p == ':') strcat(s, ".\\*.*"); else strcat(s, "\\*.*"); } else { strcat(s, "*.*"); }#else if (p != s) { p--; if (*p == '\\' || *p == '/') strcat(s, "*"); else if (*p == ':') strcat(s, "."); else strcat(s, "\\*"); } else { strcat(s, "*"); }#endif }#ifdef OS2 else if (!ckindex(".",s,1,0,0) && !ckindex("*",s,1,0,0)) { sprintf(line,"%s.*",s); s = line; }#endif /* OS2 */ x = zxpand(s);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -