📄 ckuus3.c
字号:
+ 2*strlen(zhome()) + 2*strlen(exedir) + 4*strlen("PHONES/") + 12; if (len < 4096) sprintf(dirpath,"%s%s%s;%s%s;%s;%s%s;%s;%s%s", /* Semicolon-separated path list */ env, (env[0] && env[strlen(env)-1] == ';') ? "" : ";", startupdir, startupdir, "PHONES/", inidir, inidir, "PHONES/", zhome(), zhome(), "PHONES/", exedir, exedir, "PHONES/" );#else#ifdef UNIX y = 1024; s = dirpath; zzstring("\\v(home)",&s,&y);#endif /* UNIX */#endif /* OS2 */ y = cmifip( "Names of one or more directory files, separated by spaces", "",&s,&x,0,#ifdef OS2ORUNIX dirpath,#else NULL,#endif /* OS2ORUNIX */ xxstring ); } else { /* List of directory names */ x = 0; y = cmdir("Directory name","",&s,xxstring); } if (y < 0) { if (y == -3) { /* EOL or user typed <CR> */ if ((y = cmcfm()) < 0) return(y); for (i = 0; i < max; i++) { /* Clear these */ if (i < nxdir && xdir[i]) { free(xdir[i]); } xdir[i] = (i < dd) ? pp[i] : NULL; }#ifndef NODIAL if (cx == 0) ndialdir = dd;#ifdef NETCONN if (cx == 1) nnetdir = dd;#endif /* NETCONN */#endif /* NODIAL */#ifndef NOSERVER if (cx == 2) ngetpath = dd;#endif /* NOSERVER */ return(success = 1); } else { /* Parse error */ for (i = 0; i < dd; i++) { /* Free temp storage */ if (pp[i]) free(pp[i]); /* but don't change */ pp[i] = NULL; /* anything else */ } return(y); } } if (x) { printf("?Wildcards not allowed\n"); return(-9); }#ifdef CK_TMPDIR if (cx == 2 && !isdir(s)) { printf("?Not a directory - %s\n", s); return(-9); }#endif /* CK_TMPDIR */#ifdef ZFNQFP /* Get fully qualified pathname */ if (fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf)) { if (fnp->fpath) if ((int) strlen(fnp->fpath) > 0) s = fnp->fpath; }#endif /* ZFNQFP */ c = NUL; x = strlen(s); if (x > 0) /* Get last char */ c = s[x-1]; debug(F000,"parsdir s",s,c); if ((pp[dd] = malloc(strlen(s)+2)) == NULL) { printf("?Internal error - malloc\n"); for (i = 0; i < dd; i++) { /* Free temp storage */ if (pp[i]) free(pp[i]); pp[i] = NULL; } return(-9); } else { /* Have storage for name */ strcpy(pp[dd],s); /* Copy string into new storage */ debug(F111,"parsdir pp[dd] 1",pp[dd],dd);#ifndef NOXFER if (cx == 2) { /* If we are parsing directories */ char dirsep[2]; extern int myindex; /* Append directory separator if */ extern struct sysdata sysidlist[]; /* it is missing... */ debug(F101,"parsdir myindex","",myindex); if (myindex > -1) if (sysidlist[myindex].sid_unixlike) if (c != sysidlist[myindex].sid_dirsep) { dirsep[0] = sysidlist[myindex].sid_dirsep; dirsep[1] = NUL; strcat(pp[dd], (char *) dirsep); } }#endif /* NOXFER */ debug(F111,"parsdir pp[dd] 2",pp[dd],dd); if (++dd > max) { printf("?Too many directories - %d max\n", max); for (i = 0; i < dd; i++) { /* Free temp storage */ if (pp[i]) free(pp[i]); pp[i] = NULL; } } } }#endif /* CK_PARSDIR */}#endif /* NOSPL */#ifndef NOSERVERstatic intcklogin() { int x; char * s; char username[LOGINLEN+1]; char password[LOGINLEN+1]; char account[LOGINLEN+1]; extern char * x_user, * x_passwd, * x_acct; extern int x_login, x_logged; username[0] = NUL; password[0] = NUL; account[0] = NUL; x = cmfld("username", "", &s, xxstring); if (x != -3) { if (x < 0) return(x); if ((int)strlen(s) > LOGINLEN) { printf("\"%s\" - too long, %d max\n", s, LOGINLEN); return(-9); } strcpy(username,s); x = cmfld("password", "", &s, xxstring); if (x != -3) { if (x < 0) return(x); if ((int)strlen(s) > LOGINLEN) { printf("\"%s\" - too long, %d max\n", s, LOGINLEN); return(-9); } strcpy(password,s); x = cmfld("account", "", &s, xxstring); if (x != -3) { if (x < 0) return(x); if ((int)strlen(s) > LOGINLEN) { printf("\"%s\" - too long, %d max\n", s, LOGINLEN); return(-9); } strcpy(account,s); if ((x = cmcfm()) < 0) return(x); } } } makestr(&x_user,username); makestr(&x_passwd,password); makestr(&x_acct,account); x_login = (x_user) ? 1 : 0; x_logged = 0; return(1);}#endif /* NOSERVER */#ifndef NOLOCALstatic intsetdcd() { int x, y, z = 0; if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y); if (y == CAR_ON) { x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring); if (x < 0) return(x); } if ((x = cmcfm()) < 0) return(x); carrier = ttscarr(y); cdtimo = z; return(1);}#endif /* NOLOCAL */extern struct keytab yesno[];extern int nyesno;static struct keytab qyesno[] = { /* Yes/No/Quit keyword table */ "no", 0, 0, "ok", 1, 0, "quit", 2, 0, "yes", 1, 0};static int nqyesno = (sizeof(qyesno) / sizeof(struct keytab));/* Ask question, get yes/no answer */intgetyesno(msg, quit) char * msg; int quit; {#ifdef CK_RECALL int sv_recall; /* For turning off command recall */ extern int on_recall; /* around Password prompting */#endif /* CK_RECALL */ int y, z;#ifdef OS2 extern int vmode; int vmode_sav = vmode;#ifdef COMMENT if (win95_popup#ifdef IKSD && !inserver#endif /* IKSD */ ) return(popup_readyesno(vmode,prmpt,quit));#endif /* COMMENT */ if (vmode == VTERM) { vmode = VCMD; VscrnIsDirty(VTERM); VscrnIsDirty(VCMD); }#endif /* OS2 */#ifdef VMS/* In VMS, whenever a TAKE file or macro is active, we restore the original console modes so Ctrl-C/Ctrl-Y can work. But here we go interactive again, so we have to temporarily put them back.*/ if (!cmdsrc()) concb((char)escape);#endif /* VMS */#ifdef CK_RECALL sv_recall = on_recall; /* Save and turn off command recall */ on_recall = 0;#endif /* CK_RECALL */ cmsavp(psave,PROMPTL); /* Save old prompt */ cmsetp(msg); /* Make new prompt */ z = 0; /* Initialize answer to No. */ cmini(ckxech); /* Initialize parser. */ do { prompt(NULL); /* Issue prompt. */ if (quit) y = cmkey(qyesno,nqyesno,"","",NULL); /* Get Yes or No */ else y = cmkey(yesno,nyesno,"","",NULL); /* Get Yes or No */ if (y < 0) { if (y == -4) { /* EOF */ z = y; break; } else if (y == -3) /* No answer? */ printf(" Please respond Yes or No%s\n", quit ? " or Quit" : ""); cmini(ckxech); } else { z = y; /* Save answer */ y = cmcfm(); /* Get confirmation */ } } while (y < 0); /* Continue till done */ cmsetp(psave); /* Restore real prompt */#ifdef CK_RECALL on_recall = sv_recall; /* Restore command recall */#endif /* CK_RECALL */#ifdef VMS if (cmdlvl > 0) /* In VMS and not at top level, */ conres(); /* restore console again. */#endif /* VMS */#ifdef OS2 if (vmode != vmode_sav) { vmode = VTERM; VscrnIsDirty(VCMD); VscrnIsDirty(VTERM); }#endif /* OS2 */ 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 (!ckstrcmp(line,"push",(int)strlen(line),0)) { 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 */#ifdef PIPESEND if (!ckstrcmp(line,"pipes",(int)strlen(line),0)) { if (msgflg) /* If at top level... */ printf(" pipes%s available\n", (nopush || protocol != PROTO_K) ? " not" : ""); else if ((nopush || protocol != PROTO_K) && !backgrd) printf(" CHECK: pipes not available\n"); return(success = 1 - nopush); }#endif /* PIPESEND */ y = lookup(ftrtab,line,nftr,&x); /* Look it up */ debug(F111,"dochk",ftrtab[x].kwd,y); 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 NOLOCAL#ifdef CKLOGDIAL/* Connection log and elapsed-time reporting */extern char cxlogbuf[]; /* Log record buffer */extern char diafil[]; /* Log file name */extern int dialog, cx_active; /* Flags */static int cx_prev = 0L; /* Elapsed time of previous session */VOIDdologend() { /* Write record to connection log */ long d1, d2, t1, t2; char buf[32], * p; debug(F101,"dologend dialog","",dialog); debug(F101,"dologend cxlogbuf[0]","",cxlogbuf[0]);#ifdef CKSYSLOG debug(F101,"dologend ckxlogging","",ckxlogging);#endif /* CKSYSLOG */ if (!cx_active || !cxlogbuf[0]) /* No active record */ return; cx_active = 0; /* Record is not active */ debug(F110,"dologend cxlogbuf 1",cxlogbuf,0); d1 = mjd((char *)cxlogbuf); /* Get start date of this session */ ckstrncpy(buf,ckdate(),31); /* Get current date */ d2 = mjd(buf); /* Convert them to mjds */ p = cxlogbuf; /* Get start time */ p[11] = NUL; p[14] = NUL; /* Convert to seconds */ t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15); p[11] = ':'; p[14] = ':'; p = buf; /* Get end time */ p[11] = NUL; p[14] = NUL; t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15); t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */ debug(F101,"dologend t2","",t2); if (t2 > -1L) { cx_prev = t2; p = hhmmss(t2); debug(F110,"dologend hhmmss",p,0); strncat(cxlogbuf,"E=",CXLOGBUFL); /* Append to log record */ strncat(cxlogbuf,p,CXLOGBUFL); debug(F110,"dologend cxlogbuf 2",cxlogbuf,0); } else cx_prev = 0L; debug(F101,"dologend cx_prev","",cx_prev); if (dialog) { /* If logging */ int x; x = diaopn(diafil,1,1); /* Open log in append mode */ debug(F101,"dologend diaopn","",x); x = zsoutl(ZDIFIL,cxlogbuf); /* Write the record */ debug(F101,"dologend zsoutl","",x); x = zclose(ZDIFIL); /* Close the log */ debug(F101,"dologend zclose","",x); }#ifdef CKSYSLOG debug(F101,"dologend ckxlogging","",ckxlogging); if (ckxlogging) { int x; x = ckindex("T=DIAL",cxlogbuf,0,0,1); debug(F111,"dologend ckxsyslog",cxlogbuf,ckxsyslog); debug(F111,"dologend ckindex","T=DIAL",x); if (x > 0) { if (ckxsyslog >= SYSLG_DI) { debug(F110,"dologend syslog",cxlogbuf+18,0); cksyslog(SYSLG_DI,1,"CONNECTION",(char *)(cxlogbuf+18),""); } else if (ckxsyslog >= SYSLG_AC) { debug(F110,"dologend syslog",cxlogbuf+18,0); cksyslog(SYSLG_AC,1,"CONNECTION",(char *)(cxlogbuf+18),""); } } }#endif /* CKSYSLOG */}/* D O L O G S H O W -- Show session/connection info *//* Call with fc == 1 to show, fc == 0 to only calculate. *//* Returns session elapsed time in seconds. *//* If no session active, returns elapsed time of previous session, if any, *//* otherwise 0 */longdologshow(fc) int fc; { /* SHOW (current) CONNECTION */ long d1, d2, t1, t2 = 0; char c, buf1[32], buf2[32], * info[32], * p, * s; char xbuf[CXLOGBUFL+1]; int i, x = 0, z; if (!cxlogbuf[0]) { if (fc) { if (didsetlin) printf(" No record.\n"); else printf(" No connection.\n"); } return(cx_prev); } debug(F101,"dologshow local","",local); debug(F101,"dologshow cx_active","",cx_active); if (local) z = ttchk(); /* See if we have an open connection */ else z = cx_active ? 1 : -2; if (z < 0L) { if (!fc) return(cx_prev); else t2 = cx_prev; } debug(F101,"dologshow ttchk","",z); debug(F101,"dologshow cx_prev","",cx_prev); ckstrncpy(buf1,cxlogbuf,17); /* Copy of just the timestamp */ buf1[17] = NUL; /* Terminate it */ ckstrncpy(xbuf,cxlogbuf+18,CXLOGBUFL); /* Copy that can be poked */ xwords(xbuf,31,info,1); /* Break up into fields */ d1 = mjd(buf1); /* Convert start time to MJD */ ckstrncpy(buf2,ckdate(),31); /* Current date */ d2 = mjd(buf2); /* Convert to MJD */ p = buf1; /* Point to start time */ p[11] = NUL; p[14] = NUL; /* Convert to seconds */ t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15); p[11] = ':'; p[14] = ':'; p = buf2; /* Ditto for current time */ p[11] = NUL; p[14] = NUL; if (z > -1L) { t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15); t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Elapsed time so far */ } if (fc) { p = NULL; if (t2 > -1L) /* Convert seconds to hh:mm:ss */ p = hhmmss(t2); if (z > -1) s = "Active"; else if (z == -2) s = "Closed"; else s = "Unknown"; printf("\n"); /* Show results */ printf(" Status: %s\n",s); printf(" Opened: %s\n",buf1); printf(" User: %s\n",i
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -