ckuus3.c
资源名称:cku197.tar.Z [点击查看]
上传用户:dufan58
上传日期:2007-01-05
资源大小:3407k
文件大小:232k
源码类别:
通讯/手机编程
开发平台:
Windows_Unix
- x = cmfdb(&sw); /* Parse switch or other thing */
- debug(F101,"setprinter cmfdb","",x);
- if (x < 0) /* Error */
- goto xsetprn; /* or reparse needed */
- if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
- break;
- if (cmresult.fdbaddr != &sw) /* Advanced usage :-) */
- break;
- c = cmgbrk(); /* Get break character */
- getval = (c == ':' || c == '='); /* to see how they ended the switch */
- n = cmresult.nresult; /* Numeric result = switch value */
- debug(F101,"setprinter switch","",n);
- switch (n) { /* Process the switch */
- case PRN_PS: /* Text to Postscript */
- pv[PRN_PS].ival = 1;
- pv[PRN_BID].ival = 0;
- pv[PRN_OUT].ival = 1;
- pv[PRN_RAW].ival = 0;
- break;
- case PRN_RAW: /* Non-Postscript */
- pv[PRN_PS].ival = 0;
- pv[PRN_RAW].ival = 1;
- break;
- case PRN_BID: /* Bidirectional */
- pv[PRN_BID].ival = 1;
- pv[PRN_OUT].ival = 0;
- pv[PRN_PS].ival = 0;
- pv[PRN_RAW].ival = 1;
- break;
- case PRN_OUT: /* Output-only */
- pv[PRN_OUT].ival = 1;
- pv[PRN_BID].ival = 0;
- pv[PRN_PS].ival = 0;
- pv[PRN_RAW].ival = 1;
- break;
- case PRN_NON: /* NONE */
- pv[n].ival = 1;
- pv[PRN_SPD].ival = 0;
- pv[PRN_PAR].ival = 0;
- pv[PRN_FLO].ival = FLO_KEEP;
- break;
- #ifdef UNIX
- case PRN_WIN:
- #endif /* UNIX */
- case PRN_DOS: /* DOS printer name */
- case PRN_FIL: /* Or filename */
- case PRN_PIP:
- if (pv[n].sval) free(pv[n].sval);
- pv[n].sval = NULL;
- pv[PRN_NON].ival = 0; /* Zero any previous selections */
- pv[PRN_WIN].ival = 0;
- pv[PRN_DOS].ival = 0;
- pv[PRN_FIL].ival = 0;
- pv[PRN_PIP].ival = 0;
- pv[n].ival = 1; /* Flag this one */
- if (!getval) break; /* No value wanted */
- if (n == PRN_FIL) { /* File, check accessibility */
- int wild = 0;
- if ((x = cmiofi("Filename","kermit.prn",&s,&wild,xxstring))< 0)
- if (x == -9) {
- if (zchko(s) < 0) {
- printf("Can't create "%s"n",s);
- return(x);
- }
- } else goto xsetprn;
- if (iswild(s)) {
- printf("?A single file pleasen");
- return(-9);
- }
- pv[PRN_SPD].ival = 0;
- pv[PRN_PAR].ival = 0;
- pv[PRN_FLO].ival = FLO_KEEP;
- } else if ((x = cmfld(n == PRN_DOS ? /* Value wanted - parse it */
- "DOS printer device name" : /* Help message */
- (n == PRN_PIP ?
- "Program name" :
- "Filename"),
- n == PRN_DOS ?
- "PRN" : /* Default */
- "",
- &s,
- xxstring
- )) < 0)
- goto xsetprn;
- s = brstrip(s); /* Strip enclosing braces */
- while (*s == SP) /* Strip leading blanks */
- s++;
- if (n == PRN_PIP) { /* If /PIPE: */
- if (*s == '|') { /* strip any extraneous pipe sign */
- s++;
- while (*s == SP)
- s++;
- }
- pv[PRN_SPD].ival = 0;
- pv[PRN_PAR].ival = 0;
- pv[PRN_FLO].ival = FLO_KEEP;
- }
- if ((y = strlen(s)) > 0) /* Anything left? */
- if (pv[n].sval = (char *) malloc(y+1)) /* Yes, keep it */
- strcpy(pv[n].sval,s);
- break;
- #ifdef NT
- case PRN_WIN: /* Windows queue name */
- if (pv[n].sval) free(pv[n].sval);
- pv[n].sval = NULL;
- pv[PRN_NON].ival = 0;
- pv[PRN_DOS].ival = 0;
- pv[PRN_FIL].ival = 0;
- pv[n].ival = 1;
- pv[PRN_SPD].ival = 0;
- pv[PRN_PAR].ival = 0;
- pv[PRN_FLO].ival = FLO_KEEP;
- if (!getval || !haveque)
- break;
- if ((x = cmkey(_printtab,nprint,"Print queue name",
- _printtab[printdef].kwd,xxstring)) < 0) {
- if (x != -2)
- goto xsetprn;
- if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
- s = atmbuf;
- if ((y = strlen(s)) > 0)
- if (pv[n].sval = (char *)malloc(y+1))
- strcpy(pv[n].sval,s);
- } else {
- if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
- s = printtab[x].kwd;
- if ((y = strlen(s)) > 0)
- if (pv[n].sval = (char *)malloc(y+1))
- strcpy(pv[n].sval,s);
- }
- break;
- #endif /* NT */
- case PRN_SEP: /* /JOB-HEADER (separator) */
- if (pv[n].sval) free(pv[n].sval);
- pv[n].sval = NULL;
- pv[n].ival = 1;
- if (!getval) break;
- if ((x = cmifi("Filename","",&s,&y,xxstring)) < 0)
- goto xsetprn;
- if (y) {
- printf("?Wildcards not allowedn");
- x = -9;
- goto xsetprn;
- }
- if ((y = strlen(s)) > 0)
- if (pv[n].sval = (char *) malloc(y+1))
- strcpy(pv[n].sval,s);
- break;
- case PRN_TMO: /* /TIMEOUT:number */
- pv[n].ival = 0;
- if (!getval) break;
- if ((x = cmnum("Seconds","0",10,&y,xxstring)) < 0)
- goto xsetprn;
- if (y > 999) {
- printf("?Sorry - 999 is the maximumn");
- x = -9;
- goto xsetprn;
- } else
- pv[n].ival = y;
- break;
- case PRN_TRM: /* /END-OF-JOB:string */
- if (pv[n].sval) free(pv[n].sval);
- pv[n].sval = NULL;
- pv[n].ival = 1;
- if (!getval) break;
- if ((x = cmfld("String (enclose in braces if it contains spaces)",
- "",&s,xxstring)) < 0)
- goto xsetprn;
- s = brstrip(s);
- if ((y = strlen(s)) > 0)
- if (pv[n].sval = (char *) malloc(y+1))
- strcpy(pv[n].sval,s);
- break;
- #ifdef BPRINT
- case PRN_FLO:
- if (!getval) break;
- if ((x = cmkey(flotab,nflo,
- "Serial printer-port flow control",
- "rts/cts",xxstring)) < 0)
- goto xsetprn;
- pv[n].ival = x;
- break;
- #ifndef NOLOCAL
- case PRN_SPD:
- if (!getval) break;
- if ((x = cmkey(spdtab, /* Speed (no default) */
- nspd,
- "Serial printer-port interface speed",
- "9600",
- xxstring)
- ) < 0)
- goto xsetprn;
- pv[n].ival = x;
- break;
- #endif /* NOLOCAL */
- case PRN_PAR:
- pv[n].ival = 0;
- if (!getval) break;
- if ((x = cmkey(partbl,npar,"Serial printer-port parity",
- "none",xxstring)) < 0)
- goto xsetprn;
- pv[n].ival = x;
- break;
- #endif /* BPRINT */
- #ifdef OS2
- case PRN_LEN:
- if (!getval) break;
- if ((x = cmnum("PS page length", "66",10,&y,xxstring)) < 0)
- goto xsetprn;
- pv[n].ival = y;
- break;
- case PRN_WID:
- if (!getval) break;
- if ((x = cmnum("PS page width", "80",10,&y,xxstring)) < 0)
- goto xsetprn;
- pv[n].ival = y;
- break;
- #endif /* OS2 */
- default:
- printf("?Unexpected switch value - %dn",cmresult.nresult);
- x = -9;
- goto xsetprn;
- }
- }
- line[0] = NUL; /* Initialize printer name value */
- switch (cmresult.fcode) { /* How did we get here? */
- case _CMOFI: /* They typed a filename */
- strcpy(line,cmresult.sresult); /* Name */
- wild = cmresult.nresult; /* Wild flag */
- if ((x = cmcfm()) < 0) /* Confirm the command */
- goto xsetprn;
- break;
- case _CMCFM: /* They entered the command */
- if (pv[PRN_DOS].ival > 0)
- strcpy(line,pv[PRN_DOS].sval ? pv[PRN_DOS].sval : "");
- else if (pv[PRN_WIN].ival > 0)
- strcpy(line,pv[PRN_WIN].sval ? pv[PRN_WIN].sval : "");
- else if (pv[PRN_FIL].ival > 0)
- strcpy(line,pv[PRN_FIL].sval ? pv[PRN_FIL].sval : "");
- else if (pv[PRN_PIP].ival > 0)
- strcpy(line,pv[PRN_PIP].sval ? pv[PRN_PIP].sval : "");
- break;
- default: /* By mistake */
- printf("?Unexpected function code: %dn",cmresult.fcode);
- x = -9;
- goto xsetprn;
- }
- #else /* No PRINTSWI */
- if ((x = cmofi("Printer or file name",defname,&s,xxstring)) < 0)
- return(x);
- if (x > 1) {
- printf("?Directory names not allowedn");
- return(-9);
- }
- while (*s == SP || *s == HT) s++; /* Trim leading whitespace */
- strcpy(line,s); /* Make a temporary safe copy */
- if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
- #endif /* PRINTSWI */
- #ifdef IKSD
- if (inserver && (isguest
- #ifndef NOSERVER
- || !ENABLED(en_pri)
- #endif /* NOSERVER */
- )) {
- printf("Sorry, printing disabledrn");
- return(success = 0);
- }
- #endif /* ISKD */
- #ifdef PRINTSWI
- #ifdef BPRINT
- if (printbidi) { /* If bidi printing active */
- #ifndef UNIX
- bprtstop(); /* Stop it before proceeding */
- #endif /* UNIX */
- printbidi = 0;
- }
- if (pv[PRN_SPD].ival > 0) {
- portspeed = (long) pv[PRN_SPD].ival * 10L;
- if (portspeed == 70L) portspeed = 75L;
- }
- if (pv[PRN_PAR].ival > 0)
- portparity = pv[PRN_PAR].ival;
- if (pv[PRN_FLO].ival > 0)
- portflow = pv[PRN_FLO].ival;
- #endif /* BPRINT */
- #endif /* PRINTSWI */
- s = line; /* Printer name, if given */
- #ifdef OS2ORUNIX
- #ifdef PRINTSWI
- if (pv[PRN_PIP].ival > 0) { /* /PIPE was given? */
- printpipe = 1;
- noprinter = 0;
- if (*s == '|') { /* It might still have a pipe sign */
- s++; /* if name give later */
- while (*s == SP) /* so remove it and spaces */
- s++;
- }
- } else
- #endif /* PRINTSWI */
- if (*s == '|') { /* Or pipe implied by name? */
- s++; /* Point past pipe sign */
- while (*s == SP) /* Gobble whitespace */
- s++;
- if (*s) {
- printpipe = 1;
- noprinter = 0;
- }
- }
- #ifdef PRINTSWI
- #ifdef BPRINT
- if (printpipe && pv[PRN_BID].ival > 0) {
- printf("?Sorry, pipes not allowed for bidirectional printern");
- return(-9);
- }
- #endif /* BPRINT */
- #endif /* PRINTSWI */
- #endif /* OS2ORUNIX */
- #ifdef OS2
- if ( pv[PRN_PS].ival > 0 ) {
- txt2ps = 1;
- ps_width = pv[PRN_WID].ival <= 0 ? 80 : pv[PRN_WID].ival;
- ps_length = pv[PRN_LEN].ival <= 0 ? 66 : pv[PRN_LEN].ival;
- }
- #endif /* OS2 */
- y = strlen(s); /* Length of name of new print file */
- if (y > 0
- #ifdef OS2
- && ((y != 3) || (ckstrcmp(s,"PRN",3,0) != 0))
- #endif /* OS2 */
- ) {
- if (printername) { /* Had a print file before? */
- free(printername); /* Remove its name */
- printername = NULL;
- }
- printername = (char *) malloc(y + 1); /* Allocate space for it */
- if (!printername) {
- printf("?Memory allocation failuren");
- return(-9);
- }
- strcpy(printername,s); /* Copy new name to new space */
- debug(F110,"printername",printername,0);
- }
- #ifdef PRINTSWI
- /* Set printer type from switches that were given explicitly */
- if (pv[PRN_NON].ival > 0) { /* No printer */
- printertype = PRT_NON;
- noprinter = 1;
- printpipe = 0;
- } else if (pv[PRN_FIL].ival > 0) { /* File */
- printertype = PRT_FIL;
- noprinter = 0;
- printpipe = 0;
- } else if (pv[PRN_PIP].ival > 0) { /* Pipe */
- printertype = PRT_PIP;
- noprinter = 0;
- printpipe = 1;
- } else if (pv[PRN_WIN].ival > 0) { /* Windows print queue */
- printertype = PRT_WIN;
- noprinter = 0;
- printpipe = 0;
- } else if (pv[PRN_DOS].ival > 0) { /* DOS device */
- printertype = PRT_DOS;
- noprinter = 0;
- printpipe = 0;
- } else if (line[0]) { /* Name given without switches */
- noprinter = 0;
- printertype = printpipe ? PRT_PIP : PRT_DOS;
- #ifdef NT
- if (!lookup(_printtab,line,nprint,&x)) {
- printertype = PRT_WIN;
- if (pv[PRN_WIN].sval) free(pv[PRN_WIN].sval);
- if (printername) { /* Had a print file before? */
- free(printername); /* Remove its name */
- printername = NULL;
- }
- pv[PRN_WIN].sval = NULL;
- pv[PRN_WIN].ival = 1;
- #ifdef COMMENT
- pv[PRN_NON].ival = 0; /* These aren't needed */
- pv[PRN_DOS].ival = 0;
- pv[PRN_FIL].ival = 0;
- #endif /* COMMENT */
- s = printtab[x].kwd; /* Get full new name */
- if ((y = strlen(s)) > 0) {
- makestr(&pv[PRN_WIN].sval,s);
- makestr(&printername,s);
- if (!printername) {
- printf("?Memory allocation failuren");
- return(-9);
- }
- debug(F110,"printername",printername,0);
- }
- }
- #endif /* NT */
- }
- #ifdef BPRINT
- /* Port parameters may be set for non-bidi mode */
- pportspeed = portspeed; /* Set parameters */
- pportparity = portparity;
- pportflow = portflow;
- if (pv[PRN_BID].ival > 0) { /* Bidirectional */
- #ifdef UNIX
- printbidi = 1; /* (just to test parsing...) */
- #else
- printbidi = bprtstart(); /* Start bidirectional printer */
- #endif /* UNIX */
- return(success = printbidi);
- } else
- printbidi = 0; /* Not BPRINTER, unset flag */
- #endif /* BPRINT */
- if (pv[PRN_TMO].ival > -1) { /* Take care of timeout */
- printtimo = pv[PRN_TMO].ival;
- }
- if (pv[PRN_TRM].ival > 0) { /* Termination string */
- if (printterm) {
- free(printterm);
- printterm = NULL;
- }
- if (pv[PRN_TRM].sval)
- makestr(&printterm,pv[PRN_TRM].sval);
- }
- if (pv[PRN_SEP].ival > 0) { /* and separator file */
- if (printsep) {
- free(printsep);
- printsep = NULL;
- }
- if (pv[PRN_SEP].sval)
- makestr(&printsep,pv[PRN_SEP].sval);
- }
- #endif /* PRINTSWI */
- #ifdef UNIXOROSK
- if (!printpipe
- #ifdef PRINTSWI
- && !noprinter
- #endif /* PRINTSWI */
- ) { /* File - check access */
- if (zchko(s) < 0) {
- printf("?Access denied - %sn",s);
- x = -9;
- goto xsetprn;
- }
- }
- #endif /* UNIXOROSK */
- x = 1; /* Return code */
- xsetprn: /* Common exit */
- #ifdef PRINTSWI
- for (i = 0; i <= PRN_MAX; i++) { /* Free malloc'd memory */
- if (pv[i].sval)
- free(pv[i].sval);
- }
- #endif /* PRINTSWI */
- success = (x > 0) ? 1 : 0;
- return(x);
- }
- /* D O P R M -- Set a parameter. */
- /*
- Returns:
- -2: illegal input
- -1: reparse needed
- 0: success
- */
- int
- doprm(xx,rmsflg) int xx, rmsflg; {
- int i = 0, x = 0, y = 0, z = 0;
- long zz = 0L;
- char *s = NULL, *p = NULL;
- #ifdef OS2
- char portbuf[64];
- long portspeed = 0L;
- int portparity = 0;
- int portflow = 0;
- #endif /* OS2 */
- #ifdef OS2
- if (xx == XYMSK)
- return(setmsk());
- #endif /* OS2 */
- if (xx == XYFLAG) { /* SET FLAG */
- extern int ooflag;
- return(success = seton(&ooflag));
- }
- if (xx == XYPRTR /* SET PRINTER (or BPRINTER) */
- #ifdef BPRINT
- || xx == XYBDCP
- #endif /* BPRINT */
- )
- return(setprinter(xx));
- switch (xx) {
- #ifdef ANYX25 /* SET X25 ... */
- case XYX25:
- return(setx25());
- #ifndef IBMX25
- case XYPAD: /* SET PAD ... */
- return(setpadp());
- #endif /* IBMX25 */
- #endif /* ANYX25 */
- #ifndef NOXFER
- case XYEOL: /* These have all been moved to set send/receive... */
- case XYLEN: /* Let the user know what to do. */
- case XYMARK:
- case XYNPAD:
- case XYPADC:
- case XYTIMO:
- printf("...Use SET SEND or SET RECEIVE instead.n");
- printf("Type HELP SET SEND or HELP SET RECEIVE for more info.n");
- return(success = 0);
- case XYATTR: /* File Attribute packets */
- return(setat(rmsflg));
- case XYIFD: /* Incomplete file disposition */
- if ((y = cmkey(ifdatab,3,"","auto",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (rmsflg) {
- sstate = setgen('S',
- "310",
- y == 0 ? "0" : (y == 1 ? "1" : "2"),
- ""
- );
- return((int) sstate);
- } else {
- keep = y;
- return(success = 1);
- }
- #endif /* NOXFER */
- #ifndef NOSPL
- case XYINPU: /* SET INPUT */
- return(setinp());
- #endif /* NOSPL */
- #ifdef NETCONN
- case XYNET: { /* SET NETWORK */
- struct FDB k1, k2;
- cmfdbi(&k1,_CMKEY,"","","",nnetkey, 0, xxstring, netkey, &k2);
- cmfdbi(&k2,_CMKEY,"","","",nnets, 0, xxstring, netcmd, NULL);
- #ifdef OS2 /* Hide network-type keywords for networks not installed */
- for (z = 0; z < nnets; z++) {
- if (netcmd[z].kwval == NET_TCPB && tcp_avail == 0)
- netcmd[z].flgs = CM_INV;
- #ifdef DECNET
- else if (netcmd[z].kwval == NET_DEC && dnet_avail == 0)
- netcmd[z].flgs = CM_INV;
- #endif /* DECNET */
- #ifdef CK_NETBIOS
- else if (netcmd[z].kwval == NET_BIOS && netbiosAvail == 0)
- netcmd[z].flgs = CM_INV;
- #endif /* CK_NETBIOS */
- #ifdef SUPERLAT
- else if (netcmd[z].kwval == NET_SLAT && slat_avail == 0)
- netcmd[z].flgs = CM_INV;
- #endif /* SUPERLAT */
- }
- if (tcp_avail) /* Default network type */
- strcpy(tmpbuf,"tcp/ip");
- #ifdef DECNET
- else if (dnet_avail)
- strcpy(tmpbuf,"decnet");
- #endif /* DECNET */
- #ifdef SUPERLAT
- else if (slat_avail)
- strcpy(tmpbuf,"superlat");
- #endif /* SUPERLAT */
- #ifdef CK_NETBIOS
- else if (netbiosAvail)
- strcpy(tmpbuf,"netbios");
- #endif /* CK_NETBIOS */
- else strcpy(tmpbuf,"named-pipe");
- #else
- #ifdef TCPSOCKET
- strcpy(tmpbuf,"tcp/ip");
- #else
- #ifdef ANYX25
- strcpy(tmpbuf,"x.25");
- #else
- strcpy(tmpbuf,"");
- #endif /* ANYX25 */
- #endif /* TCPSOCKET */
- #endif /* OS2 */
- x = cmfdb(&k1);
- if (x < 0) { /* Error */
- if (x == -2 || x == -9)
- printf("?No keywords match: "%s"n",atmbuf);
- return(x);
- }
- z = cmresult.nresult; /* Keyword value */
- if (cmresult.fdbaddr == &k1) { /* Which table? */
- #ifndef NOSPL
- #ifndef NODIAL
- if (z == XYNET_D)
- return(parsdir(1));
- #endif /* NODIAL */
- #endif /* NOSPL */
- if ((z = cmkey(netcmd,nnets,"",tmpbuf,xxstring)) < 0)
- return(z);
- }
- #ifdef NETCMD
- if (z == NET_CMD && nopush) {
- printf("n?Sorry, access to external commands is disabledn");
- return(-9);
- }
- #endif /* NETCMD */
- #ifndef NOPUSH
- #ifdef NETPTY
- if (z == NET_PTY && nopush) {
- printf("n?Sorry, access to external commands is disabledn");
- return(-9);
- }
- #endif /* NETPTY */
- #endif /* NOPUSH */
- #ifdef OS2
- if (z == NET_TCPB && tcp_avail == 0) {
- printf("n?Sorry, either TCP/IP is not available on this system orn
- necessary DLLs did not load. Use SHOW NETWORK to check network status.n");
- return(-9);
- #ifdef CK_NETBIOS
- } else if (z == NET_BIOS && netbiosAvail == 0) {
- printf("n?Sorry, NETBIOS is not available on this system.n") ;
- return(-9);
- #endif /* CK_NETBIOS */
- #ifdef DECNET
- } else if (z == NET_DEC && dnet_avail == 0) {
- printf("n?Sorry, DECnet is not available on this system.n") ;
- return(-9);
- #endif /* DECNET */
- #ifdef SUPERLAT
- } else if (z == NET_SLAT && slat_avail == 0) {
- printf("n?Sorry, SuperLAT is not available on this system.n") ;
- return(-9);
- #endif /* SUPERLAT */
- }
- #endif /* OS2 */
- #ifdef NPIPEORBIOS
- if (z == NET_PIPE || /* Named pipe -- also get pipename */
- z == NET_BIOS) { /* NETBIOS -- also get local name */
- char *defnam;
- #ifdef CK_NETBIOS
- char tmpnbnam[NETBIOS_NAME_LEN+1];
- #endif /* CK_NETBIOS */
- /* Construct default name */
- if (z == NET_PIPE) { /* Named pipe */
- defnam = "kermit"; /* Default name is always "kermit" */
- } else { /* NetBIOS */
- if (NetBiosName[0] != SP) { /* If there is already a name, */
- char *p = NULL;
- int n; /* use it as the default. */
- ckstrncpy(tmpnbnam,NetBiosName,NETBIOS_NAME_LEN+1);
- /* convert trailing spaces to NULs */
- p = &tmpnbnam[NETBIOS_NAME_LEN-1];
- while (*p == SP) {
- *p = NUL;
- p--;
- }
- defnam = tmpnbnam;
- } else if (*myhost) /* Otherwise use this PC's host name */
- defnam = (char *) myhost;
- else /* Otherwise use "kermit" */
- defnam = "kermit";
- }
- if ((y = cmtxt((z == NET_PIPE) ? "pipe name" : "local NETBIOS name",
- defnam, &s, xxstring)) < 0)
- return(y);
- #ifdef NPIPE
- pipename[0] = NUL;
- #endif /* NPIPE */
- if ((y = (int) strlen(s)) < 1) {
- printf("?You must also specify a %s namen",
- (z == NET_PIPE) ? "pipe" : "local NETBIOS" );
- return(-9);
- }
- #ifdef CK_NETBIOS
- if (z == NET_BIOS) {
- if ( !netbiosAvail ) {
- printf("?NETBIOS support is not available on this system.n") ;
- return(-9) ;
- }
- if ( y - NETBIOS_NAME_LEN > 0) {
- printf("?NETBIOS name too long, %ld maximumn",
- NETBIOS_NAME_LEN);
- return(-9);
- } else if ( !strcmp(s,tmpnbnam) ) {
- nettype = z; /* Returning to old connection... */
- return(success = 1); /* Done */
- } else if (strcmp(" ",NetBiosName)) {
- printf("?Local NETBIOS name already assigned to "%s"n",
- NetBiosName);
- return(-9) ;
- } else {
- NCB ncb ;
- APIRET rc ;
- strcpy(NetBiosName,s);
- for (x = y; x < NETBIOS_NAME_LEN; x++)
- NetBiosName[x] = SP;
- NetBiosName[NETBIOS_NAME_LEN] = NUL;
- printf("Verifying "%s" is a unique NetBIOS node name ...n",
- NetBiosName) ;
- rc = NCBAddName( NetbeuiAPI,
- &ncb, NetBiosAdapter, NetBiosName ) ;
- if ( rc ) {
- printf(
- "?Sorry, "%s" is already in use by another NetBIOS node.n",
- NetBiosName);
- for ( x=0; x < NETBIOS_NAME_LEN; x++)
- NetBiosName[x] = SP ;
- return(-9) ;
- }
- }
- }
- #endif /* CK_NETBIOS */
- #ifdef NPIPE
- if (z == NET_PIPE)
- ckstrncpy(pipename,s,PIPENAML);
- #endif /* NPIPE */
- } else
- #endif /* NPIPEORBIOS */
- #ifdef DECNET
- if (z == NET_DEC) {
- /* Determine if we are using LAT or CTERM */
- if ((y = cmkey(dnettab,ndnet,"DECNET protocol","lat",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- ttnproto = y;
- } else
- #endif /* DECNET */
- #ifdef NETDLL
- if (z == NET_DLL) {
- /* Find out which DLL they are using */
- char dllname[256]="";
- char * p=NULL;
- if ((x = cmifi("Dynamic load library","",&p,&y,xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of dynamic load library (dll) requiredn");
- return(-9);
- }
- return(x);
- }
- ckstrncpy(dllname,p,256);
- if ((x = cmcfm()) < 0) return(x);
- /* Try to load the dll */
- if (netdll_load(dllname) < 0)
- return(success = 0);
- else {
- nettype = z;
- return(success = 1);
- }
- } else
- #endif /* NETDLL */
- if ((x = cmcfm()) < 0) return(x);
- nettype = z;
- if (
- #ifdef DECNET
- (nettype != NET_DEC) &&
- #endif /* DECNET */
- #ifdef NPIPE
- (nettype != NET_PIPE) &&
- #endif /* NPIPE */
- #ifdef CK_NETBIOS
- (nettype != NET_BIOS) &&
- #endif /* CK_NETBIOS */
- #ifdef NETFILE
- (nettype != NET_FILE) &&
- #endif /* NETFILE */
- #ifdef NETCMD
- (nettype != NET_CMD) &&
- #endif /* NETCMD */
- #ifdef NETPTY
- (nettype != NET_PTY) &&
- #endif /* NETPTY */
- #ifdef NETDLL
- (nettype != NET_DLL) &&
- #endif /* NETDLL */
- #ifdef SSH
- (nettype != NET_SSH) &&
- #endif /* SSH */
- #ifdef SUPERLAT
- (nettype != NET_SLAT) &&
- #endif /* SUPERLAT */
- (nettype != NET_SX25) &&
- (nettype != NET_VX25) &&
- #ifdef IBMX25
- (nettype != NET_IX25) &&
- #endif /* IBMX25 */
- (nettype != NET_TCPB)) {
- printf("?Network type not supportedn");
- return(success = 0);
- } else {
- return(success = 1);
- }
- }
- #ifndef NOTCPOPTS
- #ifdef TCPSOCKET
- case XYTCP:
- if ((z = cmkey(tcpopt,ntcpopt,"TCP option","nodelay",xxstring)) < 0)
- return(z);
- switch (z) {
- case XYTCP_ADDRESS:
- if ((y = cmtxt("preferred IP Address for TCP connections","",
- &s,xxstring)) < 0)
- return(y);
- if (tcp_address) {
- free(tcp_address); /* Free any previous storage */
- tcp_address = NULL;
- }
- if (s == NULL || *s == NUL) { /* If none given */
- tcp_address = NULL; /* remove the override string */
- return(success = 1);
- } else if (tcp_address = malloc(strlen(s)+1)) { /* Make new storage */
- strcpy(tcp_address,s); /* Copy string to new storage */
- return(success = 1);
- } else
- return(success = 0);
- #ifdef SO_KEEPALIVE
- case XYTCP_KEEPALIVE:
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- success = keepalive(z) ;
- return(success);
- #endif /* SO_KEEPALIVE */
- #ifdef SO_DONTROUTE
- case XYTCP_DONTROUTE:
- if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- success = dontroute(z) ;
- return(success);
- #endif /* SO_DONTROUTE */
- #ifdef TCP_NODELAY
- case XYTCP_NODELAY:
- if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- success = no_delay(z) ;
- return(success);
- case XYTCP_NAGLE: /* The inverse of NODELAY */
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- success = no_delay(!z) ;
- return(success);
- #endif /* TCP_NODELAY */
- #ifdef SO_LINGER
- case XYTCP_LINGER:
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0)
- return(z);
- if (z) { /* if on, we need a timeout value */
- if ((x = cmnum("Linger timeout in 10th of a millisecond",
- "0",10,&y,xxstring)) < 0)
- return(x);
- } else
- y = 0;
- if ((x = cmcfm()) < 0)
- return(x);
- success = ck_linger(z,y);
- return(success);
- #endif /* SO_LINGER */
- #ifdef SO_SNDBUF
- case XYTCP_SENDBUF:
- x = cmnum("Send buffer size, bytes","8192",10,&z,xxstring);
- if (x < 0) return(x);
- if ((x = cmcfm()) < 0) return(x);
- success = sendbuf(z);
- return(success);
- #endif /* SO_SNDBUF */
- #ifdef SO_RCVBUF
- case XYTCP_RECVBUF:
- x = cmnum("Receive buffer size, bytes","8192",10,&z,xxstring);
- if (x < 0) return(x);
- if ((x = cmcfm()) < 0) return(x);
- /* Note: The following is not 16-bit safe */
- #ifndef QNX16
- if (x > 52248) {
- printf("?Warning: receive buffers larger than 52248 bytesn");
- printf(" may not be understood by all hosts. Performancen");
- printf(" may suffer.n");
- return(-9);
- }
- #endif /* QNX16 */
- success = recvbuf(z);
- return(success);
- #endif /* SO_RCVBUF */
- #ifdef VMS
- #ifdef DEC_TCPIP
- case XYTCP_UCX: { /* UCX 2.0 port swabbing bug */
- extern int ucx_port_bug;
- return(success = seton(&ucx_port_bug));
- }
- #endif /* DEC_TCPIP */
- #endif /* VMS */
- case XYTCP_RDNS: {
- extern int tcp_rdns;
- return(success = setonaut(&tcp_rdns));
- }
- #ifdef CK_DNS_SRV
- case XYTCP_DNS_SRV: {
- extern int tcp_dns_srv;
- return(success = setonaut(&tcp_dns_srv));
- }
- #endif /* CK_DNS_SRV */
- default:
- return(0);
- }
- #endif /* TCPSOCKET */
- #endif /* NOTCPOPTS */
- #endif /* NETCONN */
- }
- switch (xx) {
- #ifndef NOLOCAL
- #ifdef NETCONN
- case XYHOST: /* SET HOST */
- {
- z = ttnproto; /* Save protocol in case of failure */
- #ifdef DECNET
- if (nettype != NET_DEC)
- #endif /* DECNET */
- ttnproto = NP_NONE;
- if ((y = setlin(XYHOST,1,0)) < 0) {
- debug(F101,"SET HOST fail mdmtyp","",mdmtyp);
- ttnproto = z; /* Failed, restore protocol */
- success = 0;
- }
- didsetlin++;
- debug(F101,"SET HOST OK mdmtyp","",mdmtyp);
- return(y);
- }
- #endif /* NETCONN */
- case XYLINE: /* SET LINE (= SET PORT) */
- debug(F101,"setlin flow 1","",flow);
- x = setlin(xx,1,0);
- if (x > -1) didsetlin++;
- debug(F101,"setlin returns","",x);
- debug(F101,"setlin flow 2","",flow);
- debug(F101,"setlin local","",local);
- return(x);
- #endif /* NOLOCAL */
- #ifndef NOSETKEY
- case XYKEY: /* SET KEY */
- return(dosetkey());
- #endif /* NOSETKEY */
- #ifndef NOCSETS
- case XYLANG: /* Language */
- if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0) /* language code */
- return(y);
- if ((x = cmcfm()) < 0) return(x); /* And confirmation of command */
- /* Look up language and get associated character sets */
- for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ;
- if (i >= nlangs) {
- printf("?internal error, sorryn");
- return(success = 0);
- }
- language = i; /* All good, set the language, */
- return(success = 1);
- #endif /* NOCSETS */
- #ifndef MAC
- case XYBACK: /* BACKGROUND */
- if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- bgset = z;
- #ifdef VMS
- if (batch && bgset == 0) /* To enable echoing of commands */
- ckxech = 1; /* in VMS batch logs */
- #endif /* VMS */
- success = 1;
- bgchk();
- return(success);
- #endif /* MAC */
- case XYQUIE: { /* QUIET */
- #ifdef DCMDBUF
- extern int * xquiet;
- #else
- extern int xquiet[];
- #endif /* DCMDBUF */
- x = seton(&quiet);
- if (x < 0) return(x);
- xquiet[cmdlvl] = quiet;
- return(success = x);
- }
- #ifndef NOXFER
- case XYBUF: { /* BUFFERS */
- #ifdef DYNAMIC
- int sb, rb;
- if ((y = cmnum("Send buffer size","",10,&sb,xxstring)) < 0) {
- if (y == -3) printf("?Buffer size requiredn");
- return(y);
- }
- if (sb < 0) {
- if (*atmbuf == '-') printf("?Negative numbers can't be used heren");
- else printf("?Integer overflow, use a smaller number pleasen");
- return(-9);
- } else if (sb < 80) {
- printf("?Too smalln");
- return(-9);
- }
- if ((y = cmnum("Receive buffer size",ckitoa(sb),10,&rb,xxstring)) < 0)
- return(y);
- if (rb < 0) {
- if (*atmbuf == '-') printf("?Negative numbers can't be used heren");
- else printf("?Integer overflow, use a smaller number pleasen");
- return(-9);
- } else if (rb < 80) {
- printf("?Too smalln");
- return(-9);
- }
- if ((y = cmcfm()) < 0) return(y);
- if ((y = inibufs(sb,rb)) < 0) return(y);
- y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */
- if (y != urpsiz) urpsiz = y;
- y = adjpkl(spsiz,wslotr,bigsbsiz);
- if (y != spsiz) spsiz = spmax = spsizr = y;
- return(success = 1);
- #else
- printf("?Sorry, not availablen");
- return(success = 0);
- #endif /* DYNAMIC */
- }
- case XYCHKT: /* BLOCK-CHECK */
- if ((x = cmkey(chktab,4,"","3",xxstring)) < 0) return(x);
- if ((y = cmcfm()) < 0) return(y);
- bctr = x; /* Set locally too, even if REMOTE SET */
- if (rmsflg) {
- if (x == 4) {
- tmpbuf[0] = 'B';
- tmpbuf[1] = ' ';
- } else sprintf(tmpbuf,"%d",x);
- sstate = setgen('S', "400", tmpbuf, "");
- return((int) sstate);
- } else {
- return(success = 1);
- }
- #endif /* NOXFER */
- #ifndef NOLOCAL
- #ifndef MAC /* The Mac has no RS-232 */
- case XYCARR: /* CARRIER-WATCH */
- return(setdcd());
- #endif /* MAC */
- #endif /* NOLOCAL */
- }
- #ifdef TNCODE
- switch (xx) { /* Avoid long switch statements... */
- case XYTELOP: {
- int c, n; /* Workers */
- int getval = 0; /* Whether to get switch value */
- int tnserver = 0; /* Client by default */
- int opt = -1; /* Telnet Option */
- struct FDB sw, op; /* FDBs for each parse function */
- #ifdef CK_AUTHENTICATION
- extern int sl_topt_a_s_saved;
- extern int sl_topt_a_c_saved;
- extern int sl_topt_e_s_saved;
- extern int sl_topt_e_c_saved;
- #endif /* CK_AUTHENTICATION */
- #ifdef IKSD
- if (inserver) /* Server by default when IKSD */
- tnserver = 1;
- #endif /* IKSD */
- /* Set up chained parse functions... */
- cmfdbi(&op, /* First fdb - telopts*/
- _CMKEY, /* fcode */
- "/client, /server or", /* hlpmsg */
- "", /* default */
- "", /* addtl string data */
- ntnopt, /* addtl numeric data 1 */
- 0, /* addtl numeric data 2 */
- xxstring,
- tnopttab,
- &sw
- );
- cmfdbi(&sw, /* Second FDB - command switches */
- _CMKEY, /* fcode */
- "", /* hlpmsg */
- "", /* default */
- "", /* addtl string data */
- ntnoptsw, /* addtl numeric data 1: tbl size */
- 4, /* addtl numeric data 2: 4 = cmswi */
- xxstring, /* Processing function */
- tnoptsw, /* Keyword table */
- NULL /* Pointer to next FDB */
- );
- while (opt < 0) { /* Parse 0 or more switches */
- x = cmfdb(&op); /* Parse switch or other thing */
- debug(F101,"XYTELOP cmfdb","",x);
- if (x < 0) /* Error */
- return(x); /* or reparse needed */
- if (cmresult.fcode != _CMKEY) /* Break out if not a switch */
- break;
- c = cmgbrk(); /* Get break character */
- getval = (c == ':' || c == '='); /* see how switch ended */
- if (getval && !(cmresult.kflags & CM_ARG)) {
- printf("?This switch does not take argumentsn");
- return(-9);
- }
- z = cmresult.nresult; /* Numeric result = switch value */
- debug(F101,"XYTELOP switch","",z);
- switch (z) { /* Process the switch */
- case CK_TN_CLIENT:
- tnserver = 0;
- break;
- case CK_TN_SERVER:
- tnserver = 1;
- break;
- case CK_TN_EC:
- opt = TELOPT_ECHO;
- break;
- case CK_TN_TT:
- opt = TELOPT_TTYPE;
- break;
- case CK_TN_BM:
- opt = TELOPT_BINARY;
- break;
- case CK_TN_ENV:
- opt = TELOPT_NEWENVIRON;
- break;
- case CK_TN_LOC:
- opt = TELOPT_SNDLOC;
- break;
- case CK_TN_AU:
- opt = TELOPT_AUTHENTICATION;
- break;
- case CK_TN_FX:
- opt = TELOPT_FORWARD_X;
- break;
- case CK_TN_ENC:
- opt = TELOPT_ENCRYPTION;
- break;
- case CK_TN_IKS:
- opt = TELOPT_KERMIT;
- break;
- case CK_TN_TLS:
- opt = TELOPT_START_TLS;
- break;
- case CK_TN_XD:
- opt = TELOPT_XDISPLOC;
- break;
- case CK_TN_NAWS:
- opt = TELOPT_NAWS;
- break;
- case CK_TN_SGA:
- opt = TELOPT_SGA;
- break;
- case CK_TN_PHR:
- opt = TELOPT_PRAGMA_HEARTBEAT;
- break;
- case CK_TN_PSP:
- opt = TELOPT_SSPI_LOGON;
- break;
- case CK_TN_PLG:
- opt = TELOPT_PRAGMA_LOGON;
- break;
- case CK_TN_SAK:
- opt = TELOPT_IBM_SAK;
- break;
- case CK_TN_CPC:
- opt = TELOPT_COM_PORT;
- break;
- case CK_TN_FLW:
- opt = TELOPT_LFLOW;
- break;
- default:
- printf("?Unexpected value - %dn",z);
- return(-9);
- }
- #ifdef COMMENT
- if (cmresult.fdbaddr == &op)
- break;
- #endif /* COMMENT */
- }
- switch (opt) {
- case TELOPT_ECHO: /* Options only the Server WILL */
- case TELOPT_FORWARD_X:
- case TELOPT_SEND_URL:
- case TELOPT_IBM_SAK:
- if ((x = cmkey(tnnegtab,
- ntnnegtab,
- "desired server state",
- TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
- xxstring)
- ) < 0)
- return(x);
- if ((z = cmcfm()) < 0)
- return(z);
- if (tnserver) {
- TELOPT_DEF_S_ME_MODE(opt) = x;
- TELOPT_ME_MODE(opt) = x;
- } else {
- TELOPT_DEF_C_U_MODE(opt) = x;
- TELOPT_U_MODE(opt) = x;
- }
- break;
- case TELOPT_TTYPE: /* Options only the Client WILL */
- case TELOPT_NEWENVIRON:
- case TELOPT_SNDLOC:
- case TELOPT_AUTHENTICATION:
- case TELOPT_START_TLS:
- case TELOPT_XDISPLOC:
- case TELOPT_NAWS:
- case TELOPT_LFLOW:
- case TELOPT_COM_PORT:
- if ((x = cmkey(tnnegtab,
- ntnnegtab,
- "desired client state",
- TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
- xxstring)
- ) < 0)
- return(x);
- if ((z = cmcfm()) < 0)
- return(z);
- if (tnserver) {
- TELOPT_DEF_S_U_MODE(opt) = x;
- TELOPT_U_MODE(opt) = x;
- #ifdef CK_AUTHENTICATION
- if (opt == TELOPT_AUTHENTICATION)
- sl_topt_a_s_saved = 0;
- #endif /* CK_AUTHENTICATION */
- } else {
- TELOPT_DEF_C_ME_MODE(opt) = x;
- TELOPT_ME_MODE(opt) = x;
- #ifdef CK_AUTHENTICATION
- if (opt == TELOPT_AUTHENTICATION)
- sl_topt_a_c_saved = 0;
- #endif /* CK_AUTHENTICATION */
- }
- break;
- default:
- if ((x = cmkey(tnnegtab,
- ntnnegtab,
- tnserver ?
- "desired server state" :
- "desired client state",
- TELOPT_MODE(tnserver?TELOPT_DEF_S_ME_MODE(opt):TELOPT_DEF_C_ME_MODE(opt)),
- xxstring
- )
- ) < 0)
- return(x);
- if ((y = cmkey(tnnegtab,
- ntnnegtab,
- !tnserver ? "desired server state" :
- "desired client state",
- TELOPT_MODE(!tnserver?TELOPT_DEF_S_U_MODE(opt):TELOPT_DEF_C_U_MODE(opt)),
- xxstring
- )
- ) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- if (tnserver) {
- TELOPT_DEF_S_ME_MODE(opt) = x;
- TELOPT_ME_MODE(opt) = x;
- TELOPT_DEF_S_U_MODE(opt) = y;
- TELOPT_U_MODE(opt) = y;
- #ifdef CK_ENCRYPTION
- if (opt == TELOPT_ENCRYPTION)
- sl_topt_e_s_saved = 0;
- #endif /* CK_ENCRYPTION */
- } else {
- TELOPT_DEF_C_ME_MODE(opt) = x;
- TELOPT_ME_MODE(opt) = x;
- TELOPT_DEF_C_U_MODE(opt) = y;
- TELOPT_U_MODE(opt) = y;
- #ifdef CK_ENCRYPTION
- if (opt == TELOPT_ENCRYPTION)
- sl_topt_e_c_saved = 0;
- #endif /* CK_ENCRYPTION */
- }
- }
- return(success = 1);
- }
- case XYTEL: /* TELNET */
- if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "",
- xxstring)) < 0)
- return(z);
- switch (z) {
- case CK_TN_EC: /* ECHO */
- if ((x = cmkey(rltab,nrlt,
- "initial TELNET echoing state","local",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- tn_duplex = x;
- return(success = 1);
- case CK_TN_RE: /* REMOTE-ECHO */
- return(success = seton(&tn_rem_echo));
- case CK_TN_DB: /* DEBUG */
- return(success = seton(&tn_deb));
- case CK_TN_TT: /* TERMINAL TYPE */
- if ((y = cmtxt("terminal type for TELNET connections","",
- &s,xxstring)) < 0)
- return(y);
- if (tn_term) {
- free(tn_term); /* Free any previous storage */
- tn_term = NULL;
- }
- if (s == NULL || *s == NUL) { /* If none given */
- tn_term = NULL; /* remove the override string */
- return(success = 1);
- } else if (tn_term = malloc(strlen(s)+1)) { /* Make storage for new */
- strcpy(tn_term,s); /* Copy string into new storage */
- return(success = 1);
- } else return(success = 0);
- case CK_TN_NL: /* TELNET NEWLINE-MODE */
- if ((x = cmkey(tn_nlmtab,ntn_nlm,"","nvt",xxstring)) < 0)
- return(x);
- if (x == TN_NL_BIN) {
- if ((x = cmkey(tnlmtab,ntnlm,"","raw",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- tn_b_nlm = x;
- return(success = 1);
- } else if (x == TN_NL_NVT) {
- if ((x = cmkey(tnlmtab,ntnlm,"","on",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- tn_nlm = x;
- return(success = 1);
- } else {
- if ((y = cmcfm()) < 0)
- return(y);
- tn_nlm = x;
- return(success = 1);
- }
- case CK_TN_XF: /* BINARY-TRANSFER-MODE */
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- tn_b_xfer = z;
- return(success = 1);
- case CK_TN_NE: /* NO-ENCRYPT-DURING-XFER */
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- tn_no_encrypt_xfer = z;
- return(success = 1);
- case CK_TN_BM: /* BINARY-MODE */
- if ((x = cmkey(tnnegtab,ntnnegtab,"","refused",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- TELOPT_DEF_S_ME_MODE(TELOPT_BINARY) = x;
- TELOPT_DEF_S_U_MODE(TELOPT_BINARY) = x;
- TELOPT_DEF_C_ME_MODE(TELOPT_BINARY) = x;
- TELOPT_DEF_C_U_MODE(TELOPT_BINARY) = x;
- return(success = 1);
- #ifdef IKS_OPTION
- case CK_TN_IKS: /* KERMIT */
- if ((x = cmkey(tnnegtab,ntnnegtab,"DO","accept",xxstring)) < 0)
- return(x);
- if ((y = cmkey(tnnegtab,ntnnegtab,"WILL","accept",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- TELOPT_DEF_S_ME_MODE(TELOPT_KERMIT) = y;
- TELOPT_DEF_S_U_MODE(TELOPT_KERMIT) = x;
- TELOPT_DEF_C_ME_MODE(TELOPT_KERMIT) = y;
- TELOPT_DEF_C_U_MODE(TELOPT_KERMIT) = x;
- return(success = 1);
- #endif /* IKS_OPTION */
- #ifdef CK_SSL
- case CK_TN_TLS: /* START_TLS */
- if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
- return(x);
- if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- TELOPT_DEF_S_ME_MODE(TELOPT_START_TLS) = x;
- TELOPT_DEF_S_U_MODE(TELOPT_START_TLS) = y;
- TELOPT_DEF_C_ME_MODE(TELOPT_START_TLS) = x;
- TELOPT_DEF_C_U_MODE(TELOPT_START_TLS) = y;
- return(success = 1);
- #endif /* CK_SSL */
- #ifdef CK_NAWS
- case CK_TN_NAWS: /* NAWS */
- if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
- return(x);
- if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- TELOPT_DEF_S_ME_MODE(TELOPT_NAWS) = x;
- TELOPT_DEF_S_U_MODE(TELOPT_NAWS) = y;
- TELOPT_DEF_C_ME_MODE(TELOPT_NAWS) = x;
- TELOPT_DEF_C_U_MODE(TELOPT_NAWS) = y;
- return(success = 1);
- #endif /* CK_NAWS */
- #ifdef CK_AUTHENTICATION
- case CK_TN_AU: /* AUTHENTICATION */
- if ((x = cmkey(tnauthtab,ntnauth,"","accept",xxstring)) < 0)
- return(x);
- if (x == TN_AU_FWD) {
- extern int forward_flag;
- return(success = seton(&forward_flag));
- } else if (x == TN_AU_TYP) {
- extern int auth_type_user[];
- extern int sl_auth_type_user[];
- extern int sl_auth_saved;
- int i, j, atypes[AUTHTYPLSTSZ];
- for (i = 0; i < AUTHTYPLSTSZ; i++) {
- if ((y = cmkey(autyptab,nautyp,"",
- i == 0 ? "automatic" : "" ,
- xxstring)) < 0) {
- if (y == -3)
- break;
- return(y);
- }
- if (i > 0 && (y == AUTHTYPE_AUTO || y == AUTHTYPE_NULL)) {
- printf(
- "rn?Choice may only be used in first position.rn");
- return(-9);
- }
- for (j=0 ; j< i; j++) {
- if (atypes[j] == y) {
- printf("rn?Choice has already been used.rn");
- return(-9);
- }
- }
- atypes[i] = y;
- if (y == AUTHTYPE_NULL || y == AUTHTYPE_AUTO) {
- i++;
- break;
- }
- }
- if (i < AUTHTYPLSTSZ)
- atypes[i] = AUTHTYPE_NULL;
- if ((z = cmcfm()) < 0)
- return(z);
- sl_auth_saved = 0;
- for (i = 0; i < AUTHTYPLSTSZ; i++) {
- auth_type_user[i] = atypes[i];
- sl_auth_type_user[i] = 0;
- }
- } else if (x == TN_AU_HOW) {
- if ((y = cmkey(auhowtab,nauhow,"","any",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- tn_auth_how = y;
- } else if (x == TN_AU_ENC) {
- if ((y = cmkey(auenctab,nauenc,"","encrypt",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- tn_auth_enc = y;
- } else {
- if ((y = cmcfm()) < 0)
- return(y);
- TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = x;
- TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = x;
- }
- return(success = 1);
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_ENCRYPTION
- case CK_TN_ENC: { /* ENCRYPTION */
- int c, tmp = -1;
- int getval = 0;
- static struct keytab * tnetbl = NULL;
- static int ntnetbl = 0;
- if ((y = cmkey(tnenctab,ntnenc,"","accept",xxstring)) < 0)
- return(y);
- switch (y) {
- case TN_EN_TYP:
- x = ck_get_crypt_table(&tnetbl,&ntnetbl);
- debug(F101,"ck_get_crypt_table x","",x);
- debug(F101,"ck_get_crypt_table n","",ntnetbl);
- if (x < 1 || !tnetbl || ntnetbl < 1) /* Didn't get it */
- x = 0;
- if (!x) {
- printf("?Oops, types not loadedn");
- return(-9);
- }
- if ((x = cmkey(tnetbl,ntnetbl,"type of encryption",
- "automatic",xxstring)) < 0)
- return(x);
- if ((z = cmcfm()) < 0)
- return(z);
- cx_type = x;
- sl_cx_type = 0;
- break;
- case TN_EN_START:
- if ((z = cmcfm()) < 0)
- return(z);
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- ck_tn_enc_start();
- break;
- case TN_EN_STOP:
- if ((z = cmcfm()) < 0)
- return(z);
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- ck_tn_enc_stop();
- break;
- default:
- if ((z = cmcfm()) < 0)
- return(z);
- TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = y;
- TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = y;
- TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = y;
- TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = y;
- }
- return(success = 1);
- }
- #endif /* CK_ENCRYPTION */
- case CK_TN_BUG: /* BUG */
- if ((x = cmkey(tnbugtab,4,"","binary-me-means-u-too",xxstring)) < 0)
- return(x);
- if ((z = cmkey(onoff,2,"","off",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- switch (x) {
- case 0:
- tn_b_meu = z;
- break;
- case 1:
- tn_b_ume = z;
- break;
- case 2:
- tn_infinite = z;
- break;
- case 3:
- tn_sb_bug = z;
- break;
- }
- return(success = 1);
- #ifdef CK_ENVIRONMENT
- case CK_TN_XD: /* XDISPLOC */
- if ((x = cmkey(tnnegtab,ntnnegtab,"me","accept",xxstring)) < 0)
- return(x);
- if ((y = cmkey(tnnegtab,ntnnegtab,"u","accept",xxstring)) < 0)
- return(y);
- if ((z = cmcfm()) < 0)
- return(z);
- TELOPT_DEF_S_ME_MODE(TELOPT_XDISPLOC) = x;
- TELOPT_DEF_S_U_MODE(TELOPT_XDISPLOC) = y;
- TELOPT_DEF_C_ME_MODE(TELOPT_XDISPLOC) = x;
- TELOPT_DEF_C_U_MODE(TELOPT_XDISPLOC) = y;
- return(success = 1);
- case CK_TN_ENV: {
- char * msg = "value of telnet environment variable";
- extern int tn_env_flg;
- extern char tn_env_acct[], tn_env_disp[], tn_env_job[],
- tn_env_prnt[], tn_env_sys[];
- if ((x = cmkey(tnenvtab,ntnenv,"","",xxstring)) < 0)
- return(x);
- #ifdef COMMENT
- /* If we ever support USERVAR variables */
- if (x == TN_ENV_UVAR) {
- /* Get the user variable name */
- }
- #endif /* COMMENT */
- if (x == TN_ENV_OFF || x == TN_ENV_ON) {
- if ((y = cmcfm()) < 0) return(y);
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- tn_env_flg = x == TN_ENV_OFF ? 0 : 1;
- return(success = 1);
- }
- /* Not ON/OFF - Get the value */
- z = cmdgquo();
- cmdsquo(0);
- if ((y = cmtxt(msg,
- "", &s, xxstring)) < 0) {
- cmdsquo(z);
- return(y);
- }
- cmdsquo(z);
- #ifdef IKSD
- if (inserver)
- return(success = 0);
- #endif /* IKSD */
- if ((int)strlen(s) > 63) {
- printf("Sorry, too longn");
- return(-9);
- }
- switch (x) {
- case TN_ENV_USR:
- ckstrncpy(uidbuf,s,UIDBUFLEN);
- sl_uid_saved = 0;
- break;
- case TN_ENV_ACCT:
- ckstrncpy(tn_env_acct,s,64);
- break;
- case TN_ENV_DISP:
- ckstrncpy(tn_env_disp,s,64);
- break;
- case TN_ENV_JOB:
- ckstrncpy(tn_env_job,s,64);
- break;
- case TN_ENV_PRNT:
- ckstrncpy(tn_env_prnt,s,64);
- break;
- case TN_ENV_SYS:
- ckstrncpy(tn_env_sys,s,64);
- break;
- case TN_ENV_UVAR:
- printf("n?Not yet implementedn");
- break;
- }
- return(success = 1);
- }
- #endif /* CK_ENVIRONMENT */
- #ifdef CK_SNDLOC
- case CK_TN_LOC: { /* LOCATION */
- extern char * tn_loc;
- if ((y = cmtxt("Location string","",&s,xxstring)) < 0)
- return(y);
- if (!*s) s = NULL;
- makestr(&tn_loc,s);
- return(success = 1);
- }
- #endif /* CK_SNDLOC */
- case CK_TN_WAIT: /* WAIT-FOR-NEGOTIATIONS */
- if ((z = cmkey(onoff,2,"","on",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else
- 1
- #endif /* IKSDCONF */
- ) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- tn_wait_flg = z;
- sl_tn_saved = 0;
- return(success = 1);
- case CK_TN_PUID: { /* PROMPT-FOR-USERID */
- int i,len;
- if ((y = cmtxt("Prompt string","",&s,xxstring)) < 0)
- return(y);
- if (s == "") s = NULL;
- if (s) {
- s = brstrip(s);
- if (s == "") s = NULL;
- }
- /* we must check to make sure there are no % fields */
- len = strlen(s);
- for (i = 0; i < len; i++) {
- if (s[i] == '%') {
- if (s[i+1] != '%') {
- printf("%% fields are not used in this command.n");
- return(-9);
- }
- i++;
- }
- }
- makestr(&tn_pr_uid,s);
- return(success = 1);
- }
- default:
- return(-2);
- }
- }
- #endif /* TNCODE */
- switch (xx) {
- #ifndef NOSPL
- case XYCOUN: /* SET COUNT */
- x = cmnum("Positive number","0",10,&z,xxstring);
- if (x < 0) return(x);
- if ((x = cmcfm()) < 0) return(x);
- if (z < 0) {
- printf("?A positive number, pleasen");
- return(0);
- }
- debug(F101,"XYCOUN: z","",z);
- return(success = setnum(&count[cmdlvl],z,0,10000));
- #endif /* NOSPL */
- #ifndef NOSPL
- case XYCASE:
- return(success = seton(&inpcas[cmdlvl]));
- #endif /* NOSPL */
- case XYCMD: /* COMMAND ... */
- if ((y = cmkey(scmdtab,nbytt,"","",xxstring)) < 0) return(y);
- switch(y) {
- case 876:
- if ((y = cmcfm()) < 0) return(y);
- concb((char)escape);
- return(success = 1);
- case SCMD_BSZ:
- if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x,
- xxstring)) < 0)
- return(y);
- if (x != 7 && x != 8) {
- printf("n?The choices are 7 and 8n");
- return(success = 0);
- }
- if ((y = cmcfm()) < 0) return(y);
- if (x == 7) cmdmsk = 0177;
- else if (x == 8) cmdmsk = 0377;
- return(success = 1);
- #ifdef CK_RECALL
- case SCMD_RCL:
- if ((y = cmnum("maximum number of commands in recall buffer","10",
- 10,&x,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- return(success = cmrini(x));
- #endif /* CK_RECALL */
- #ifdef CK_RECALL
- case SCMD_RTR:
- return(success = seton(&cm_retry));
- #endif /* CK_RECALL */
- case SCMD_MOR: /* More-prompting */
- return(success = seton(&xaskmore));
- case SCMD_QUO:
- if ((x = seton(&y)) < 0) return(x);
- cmdsquo(y); /* Do it the right way */
- cmd_quoting = y; /* Also keep a global copy */
- /* Set string-processing function */
- #ifdef datageneral
- xxstring = y ? zzstring : (xx_strp) NULL;
- #else
- #ifdef CK_ANSIC
- xxstring = y ? zzstring : (xx_strp) NULL;
- #else
- xxstring = y ? zzstring : (xx_strp) NULL;
- #endif /* CK_ANSIC */
- #endif /* datageneral */
- return(success = 1);
- #ifdef OS2
- case SCMD_COL: { /* Command-screen colors */
- int fg, bg;
- fg = cmkey(ttyclrtab, nclrs,
- "foreground color and then background color",
- "white",
- xxstring);
- if (fg < 0)
- return(fg);
- if ((bg = cmkey(ttyclrtab,nclrs,
- "background color","black",xxstring)) < 0)
- return(bg);
- if ((y = cmcfm()) < 0)
- return(y);
- colorcmd = fg | bg << 4;
- return(success = 1);
- }
- case SCMD_SCR: /* Command Scrollback size */
- if ((y = cmnum("COMMAND scrollback buffer size, lines","512",10,&x,
- xxstring)) < 0)
- return(y);
- /* The max number of lines is the RAM */
- /* we can actually dedicate to a */
- /* scrollback buffer given the maximum */
- /* process memory space of 512MB */
- if (x < 256 || x > 2000000L) {
- printf("n?The size must be between 256 and 2,000,000.n");
- return(success = 0);
- }
- if ((y = cmcfm()) < 0) return(y);
- tt_scrsize[VCMD] = x;
- VscrnInit( VCMD ) ;
- return(success = 1);
- break;
- case SCMD_WID: {
- if ((y = cmnum("number of columns in display window during CONNECT",
- "80",10,&x,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- if (IsOS2FullScreen()) {
- if (x != 40 && x != 80 && x != 132) {
- printf("n?The width must be 40, 80,");
- #ifdef NT
- printf(" or 132 under Windows 95.n.");
- #else /* NT */
- printf(" or 132 in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- }
- } else {
- if (!IsWARPed() && x != 80) {
- printf("n?OS/2 version is pre-WARP: the width must equal ");
- printf("80 in a Windowed Sessionn.");
- return(success = 0);
- }
- if (x < 20 || x > MAXTERMCOL) {
- printf(
- "n?The width must be between 20 and %dn.",MAXTERMCOL);
- return(success = 0);
- }
- }
- if (x > 8192/(tt_rows[VCMD]+1)) {
- printf(
- "n?The max screen area is 8192 cells: %d(rows) x %d(cols) = %d cells.n",
- tt_rows[VCMD]+1,x,x*(tt_rows[VCMD]+1));
- return(success = 0);
- }
- tt_cols[VCMD] = x;
- VscrnSetWidth(VCMD, x);
- cmd_cols = x;
- SetCols(VCMD);
- return(success = 1);
- }
- case SCMD_HIG:
- if ((y = cmnum(
- "number of rows in display window during CONNECT",
- "25",10,&x,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- if (tt_modechg == TVC_DIS) {
- printf("n?SET TERMINAL VIDEO-CHANGE DISABLEDn");
- return(success = 0);
- }
- if (IsOS2FullScreen()) {
- if (x != 25 && x != 43 && x != 50 && x != 60) {
- printf("n?The height must be 25, 43, 50");
- #ifdef NT
- printf(" or 60 under Windows 95.n.");
- #else /* NT */
- printf(" or 60 in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- }
- } else if (tt_modechg == TVC_W95) {
- if (x != 25 && x != 43 && x != 50) {
- printf("n?The height must be 25, 43, 50");
- #ifdef NT
- printf(" under Windows 95.n.");
- #else /* NT */
- printf(" in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- }
- } else {
- if (x < 8 || x > MAXTERMROW ) {
- printf("n?The height must be between 8 and %dn.",MAXTERMROW);
- return(success = 0);
- }
- }
- if (x > 8192/tt_cols[VCMD]) {
- printf(
- "n?The max screen area is 8192 cells: %d(rows) x %d(cols) = %d cells.n",
- x,tt_cols[VCMD],x*tt_cols[VCMD]);
- return(success = 0);
- }
- tt_szchng[VCMD] = 1;
- tt_rows[VCMD] = cmd_rows = x;
- VscrnInit(VCMD);
- SetCols(VCMD);
- return(success = 1);
- case SCMD_CUR: {
- int row, col;
- position * ppos;
- ppos = VscrnGetCurPos(VCMD);
- #ifdef NT
- #define itoa _itoa
- #endif
- itoa(ppos->y+1, tmpbuf, 10);
- if ((y = cmnum("row (1-based)",tmpbuf,10,&row,xxstring)) < 0)
- return(y);
- itoa(ppos->x+1, tmpbuf, 10);
- if ((y = cmnum("col (1-based)",tmpbuf,10,&col,xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- VscrnSetCurPos( VCMD, (short) (col-1), (short) (row-1) ) ;
- VscrnIsDirty( VCMD );
- return(success=1);
- }
- #else
- case SCMD_WID:
- y = cmnum("Command screen width, characters","80",10,&x,xxstring);
- return(setnum(&cmd_cols,x,y,1024));
- case SCMD_HIG:
- y = cmnum("Command screen height, rows","24",10,&x,xxstring);
- return(setnum(&cmd_rows,x,y,1024));
- #endif /* OS2 */
- case SCMD_INT:
- return(seton(&cmdint));
- #ifdef CK_AUTODL
- case SCMD_ADL:
- return(seton(&cmdadl));
- #endif /* CK_AUTODL */
- default:
- return(-2);
- }
- }
- switch (xx) {
- case XYDFLT: /* SET DEFAULT = CD */
- return(success = docd(XXCWD));
- case XYDEBU: /* SET DEBUG { on, off, session } */
- if ((y = cmkey(dbgtab,ndbg,"","",xxstring)) < 0) {
- return(y);
- } else if (y == 3) { /* 3 = timestamp */
- debug(F101,"set debug y","",y);
- x = seton(&debtim);
- debug(F101,"set debug x","",x);
- if (x < 0)
- return(x);
- else
- return(success = 1);
- } else if ((x = cmcfm()) < 0)
- return(x);
- #ifdef IKSD
- if (inserver && isguest) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- debug(F101,"set debug y","",y);
- switch (y) {
- case 0: /* 0 = all debugging off. */
- debses = 0;
- #ifdef DEBUG
- if (deblog) doclslog(LOGD);
- #endif /* DEBUG */
- return(success = 1);
- case 1: /* 1 = log debugging to debug.log */
- #ifdef DEBUG
- deblog = debopn("debug.log", 0);
- return(success = deblog ? 1 : 0);
- #else
- printf("?Sorry, debug log feature not enabledn");
- return(success = 0);
- #endif /* DEBUG */
- case 2: /* 2 = session */
- return(success = debses = 1);
- default:
- return(-2);
- }
- break;
- #ifndef NOXFER
- case XYDELA: /* SET DELAY */
- y = cmnum("Number of seconds before starting to send","5",10,&x,xxstring);
- if (x < 0) x = 0;
- return(success = setnum(&ckdelay,x,y,999));
- #endif /* NOXFER */
- default:
- break;
- }
- switch (xx) {
- #ifndef NODIAL
- #ifdef CK_TAPI
- case XYTAPI:
- return(settapi());
- #endif /* CK_TAPI */
- case XYDIAL: /* SET MODEM or SET DIAL */
- return(setdial(-1));
- case XYMODM:
- return(setmodem());
- #endif /* NODIAL */
- #ifndef NOLOCAL
- case XYDUPL: /* SET DUPLEX */
- if ((y = cmkey(dpxtab,2,"","full",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- duplex = y;
- return(success = 1);
- case XYLCLE: /* LOCAL-ECHO (= DUPLEX) */
- return(success = seton(&duplex));
- case XYESC: /* SET ESCAPE */
- return(success = setcc(ckitoa(DFESC),&escape));
- #endif /* NOLOCAL */
- case XYEXIT: /* SET EXIT */
- if ((z = cmkey(xittab,nexit,"","",xxstring)) < 0)
- return(z);
- switch (z) {
- case 0: /* STATUS */
- y = cmnum("EXIT status code","",10,&x,xxstring);
- return(success = setnum(&xitsta,x,y,-1));
- case 1: /* WARNING */
- if ((z = cmkey(xitwtab,nexitw,"","",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- xitwarn = z;
- return(success = 1);
- case 2:
- success = seton(&exitonclose);
- #ifdef TCPSOCKET
- if (success) tn_exit = exitonclose;
- #endif /* TCPSOCKET */
- return(success);
- default:
- return(-2);
- } /* End of SET EXIT switch() */
- default:
- break;
- }
- switch (xx) {
- extern int cxflow[];
- case XYFILE: /* SET FILE */
- return(setfil(rmsflg));
- case XYFLOW: { /* FLOW-CONTROL */
- struct FDB k1, k2;
- cmfdbi(&k1,_CMKEY,
- /* This is because chained FDB's don't give chained help yet */
- #ifdef Plan9
- #ifdef CK_RTSCTS
- "Flow control type, one of the following:n
- keep none rts/ctsn
- or connection type",
- #else
- "Flow control type, one of the following:n
- keep nonen
- or connection type",
- #endif /* CK_RTSCTS */
- #else
- #ifdef CK_RTSCTS
- #ifdef CK_DTRCD
- "Flow control type, one of the following:n
- dtr/cd ctr/cts keep none rts/cts xon/xoffn
- or connection type",
- #else
- "Flow control type, one of the following:n
- keep none rts/cts xon/xoffn
- or connection type",
- #endif /* CK_DTRCD */
- #else
- "Flow control type, one of the following:n
- keep none xon/xoffn
- or connection type",
- #endif /* CK_RTSCTS */
- #endif /* Plan9 */
- "","",ncxtypesw, 4, xxstring, cxtypesw, &k2);
- cmfdbi(&k2,_CMKEY,"","","", nflo, 0, xxstring, flotab, NULL);
- x = cmfdb(&k1);
- if (x < 0) { /* Error */
- if (x == -2 || x == -9)
- printf("?No keywords or switches match: "%s"n",atmbuf);
- return(x);
- }
- z = cmresult.nresult; /* Keyword value */
- if (cmresult.fdbaddr == &k2) { /* Flow-control type keyword table */
- if ((x = cmcfm()) < 0) /* Set it immediately */
- return(x);
- flow = z;
- debug(F101,"set flow","",flow);
- #ifdef CK_SPEED
- if (flow == FLO_XONX) /* Xon/Xoff forces prefixing */
- ctlp[XON] = ctlp[XOFF] = ctlp[XON+128] = ctlp[XOFF+128] = 1;
- #endif /* CK_SPEED */
- autoflow = (flow == FLO_AUTO);
- return(success = 1); /* Done */
- }
- debug(F101,"set flow /blah 1","",z); /* SET FLOW /for-what */
- if ((y = cmkey(flotab,nflo,"Flow control type","none",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- debug(F101,"set flow /blah 2","",y);
- if (z != FLO_AUTO && z >= 0 && z <= CXT_MAX)
- cxflow[z] = y;
- debug(F101,"set flow","",flow);
- debug(F101,"set flow autoflow","",autoflow);
- return(success = 1);
- }
- case XYHAND: /* HANDSHAKE */
- if ((y = cmkey(hshtab,nhsh,"","none",xxstring)) < 0) return(y);
- if (y == 998) {
- if ((x = cmnum("ASCII value","",10,&y,xxstring)) < 0)
- return(x);
- if ((y < 1) || ((y > 31) && (y != 127))) {
- printf("?Character must be in ASCII control rangen");
- return(-9);
- }
- }
- if ((x = cmcfm()) < 0) return(x);
- turn = (y > 0127) ? 0 : 1 ;
- turnch = y;
- return(success = 1);
- #ifndef NOSPL
- case XYMACR: /* SET MACRO */
- if ((y = cmkey(smactab,2,"","",xxstring)) < 0) return(y);
- switch (y) {
- case 0: return(success = seton(&mecho));
- case 1: return(success = seton(&merror[cmdlvl]));
- default: return(-2);
- }
- #endif /* NOSPL */
- case XYMSGS:
- #ifdef VMS
- if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
- if ((y = cmcfm()) < 0) return(y);
- vms_msgs = z;
- printf("Sorry, SET MESSAGES not implemented yetn");
- return(success = 0);
- #endif /* VMS */
- default:
- break;
- }
- switch (xx) {
- case XYPARI: /* PARITY */
- if ((y = cmkey(partbl,npar,"","none",xxstring)) < 0)
- return(y);
- /* If parity not none, then we also want 8th-bit prefixing */
- #ifdef HWPARITY
- if (y == 'H') { /* Hardware */
- if ((x = cmkey(hwpartbl,nhwpar,"","even",xxstring)) < 0)
- return(x);
- }
- #endif /* HWPARITY */
- if ((z = cmcfm()) < 0)
- return(z);
- #ifdef HWPARITY
- if (y == 'H') { /* 8 data bits plus hardware parity */
- parity = 0;
- #ifndef NOXFER
- ebqflg = 0;
- #endif /* NOXFER */
- hwparity = x;
- } else { /* 7 data bits + software parity */
- hwparity = 0;
- #endif /* HWPARITY */
- parity = y;
- #ifndef NOXFER
- ebqflg = (parity) ? 1 : 0;
- #endif /* NOXFER */
- #ifdef HWPARITY
- }
- #endif /* HWPARITY */
- return(success = 1);
- #ifndef NOFRILLS
- case XYPROM: /* SET PROMPT */
- /*
- Note: xxstring not invoked here. Instead, it is invoked every time the
- prompt is issued. This allows the prompt string to contain variables
- that can change, like v(dir), v(time), etc.
- */
- sprintf(line,
- "{%s}", /* Default might have a trailing space */
- inserver ? ikprompt : ckprompt
- );
- if ((x = cmtxt("Program's command prompt",line,&s,NULL)) < 0)
- return(x);
- s = brstrip(s); /* Remove enclosing braces, if any */
- #ifdef COMMENT
- /*
- Let's not do this any more -- we don't do it anywhere else.
- */
- else if (*s == '"') { /* For compatibility with pre-5A */
- x = (int)strlen(s);
- if (s[x-1] == '"') {
- s[x-1] = NUL;
- s++;
- }
- }
- #endif /* COMMENT */
- cmsetp(s); /* Set the prompt */
- return(success = 1);
- #endif /* NOFRILLS */
- #ifndef NOXFER
- case XYRETR: /* RETRY: per-packet retry limit */
- y = cmnum("Maximum retries per packet","10",10,&x,xxstring);
- if (x < 0) x = 0;
- if ((x = setnum(&maxtry,x,y,999)) < 0) return(x);
- #ifdef COMMENT
- if (maxtry <= wslotr) {
- printf("?Retry limit must be greater than window sizen");
- return(success = 0);
- }
- #endif /* COMMENT */
- if (rmsflg) {
- sstate = setgen('S', "403", ckitoa(maxtry), "");
- return((int) sstate);
- } else return(success = x);
- #endif /* NOXFER */
- #ifndef NOSERVER
- case XYSERV: /* SET SERVER items */
- if ((y = cmkey(srvtab,nsrvt,"","",xxstring)) < 0) return(y);
- switch (y) {
- case XYSERI:
- if ((y = cmnum("Number of seconds, or 0 for no idle timeout",
- "0",10,&x,xxstring)) < 0)
- return(y);
- if (x < 0)
- x = 0;
- if ((y = cmcfm()) < 0)
- return(y);
- #ifndef OS2
- srvtim = 0;
- #endif /* OS2 */
- srvidl = x;
- return(success = 1);
- case XYSERT:
- if ((y = cmnum("Interval for server NAKs, 0 = none",ckitoa(DSRVTIM),
- 10,&x, xxstring)) < 0)
- return(y);
- if (x < 0) {
- printf("n?Specify a positive number, or 0 for no server NAKsn");
- return(0);
- }
- if ((y = cmcfm()) < 0) return(y);
- if (rmsflg) {
- sstate = setgen('S', "404", ckitoa(x), "");
- return((int) sstate);
- } else {
- #ifndef OS2
- srvidl = 0;
- #endif /* OS2 */
- srvtim = x; /* Set the server timeout variable */
- return(success = 1);
- }
- case XYSERD: /* SERVER DISPLAY */
- return(success = seton(&srvdis)); /* ON or OFF... */
- #ifndef NOSPL
- case XYSERP: /* SERVER GET-PATH */
- return(parsdir(2));
- #endif /* NOSPL */
- case XYSERL: /* SERVER LOGIN */
- return(cklogin());
- case XYSERC: /* SERVER CD-MESSAGE */
- x = rmsflg ?
- cmkey(onoff,2,"","",xxstring) :
- cmkey(cdmsg,3,"","",xxstring);
- if (x < 0)
- return(x);
- if (x == 2) { /* CD-MESSAGE FILE */
- if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
- return(x);
- if (!*s) {
- s = NULL;
- srvcdmsg = 0;
- }
- makestr(&cdmsgstr,s);
- makelist(cdmsgstr,cdmsgfile,8);
- return(success = 1);
- }
- if ((y = cmcfm()) < 0) /* CD-MESSAGE ON/OFF */
- return(y);
- if (rmsflg) {
- sstate = setgen('S', "420", x ? "1" : "0", "");
- return((int) sstate);
- } else {
- if (x > 0)
- srvcdmsg |= 1;
- else
- srvcdmsg &= 2;
- return(success = 1);
- }
- case XYSERK: /* SERVER KEEPALIVE */
- return(success = seton(&srvping)); /* ON or OFF... */
- default:
- return(-2);
- }
- #endif /* NOSERVER */
- }
- switch (xx) {
- #ifdef UNIX
- #ifndef NOJC
- case XYSUSP: /* SET SUSPEND */
- seton(&suspend); /* on or off... */
- return(success = 1);
- #endif /* NOJC */
- #endif /* UNIX */
- case XYTAKE: /* SET TAKE */
- if ((y = cmkey(taktab,4,"","",xxstring)) < 0) return(y);
- switch (y) {
- case 0: return(success = seton(&techo));
- #ifndef NOSPL
- case 1: return(success = seton(&takerr[cmdlvl]));
- #else
- case 1: return(success = seton(&takerr[tlevel]));
- #endif /* NOSPL */
- case 2: techo = 0; return(success = 1); /* For compatibility with */
- case 3: techo = 1; return(success = 1); /* MS-DOS Kermit */
- default: return(-2);
- }
- #ifndef NOSCRIPT
- case XYSCRI: /* SET SCRIPT */
- if ((y = cmkey(scrtab,1,"","echo",xxstring)) < 0) return(y);
- switch (y) {
- case 0: return(success = seton(&secho));
- default: return(-2);
- }
- #endif /* NOSCRIPT */
- default:
- break;
- }
- #ifndef NOLOCAL
- switch (xx) {
- case XYTERM: /* SET TERMINAL */
- x = settrm();
- success = (x > 0) ? 1 : 0;
- return(x);
- #ifdef NT
- case XYWIN95: /* SET WIN95 workarounds */
- x = setwin95();
- success = (x > 0 ? 1 : 0);
- return(x);
- #endif /* NT */
- #ifdef OS2
- case XYDLR: /* SET DIALER workarounds */
- x = setdialer();
- success = (x > 0 ? 1 : 0);
- return(x);
- case XYTITLE: /* SET TITLE of window */
- x = settitle();
- success = (x > 0 ? 1 : 0);
- return(x);
- #endif /* OS2 */
- #ifdef OS2MOUSE
- case XYMOUSE: /* SET MOUSE */
- return(success = setmou());
- #endif /* OS2MOUSE */
- case XYBELL: /* SET BELL */
- return( success = setbell() );
- #ifdef OS2
- case XYPRTY:
- return( success = setprty() );
- #endif /* OS2 */
- default:
- break;
- }
- #endif /* NOLOCAL */
- switch (xx) {
- /* SET SEND/RECEIVE protocol parameters. */
- #ifndef NOXFER
- case XYRECV:
- case XYSEND:
- return(setsr(xx,rmsflg));
- #endif /* NOXFER */
- #ifndef NOLOCAL /* Session log text/binary selection */
- #ifdef OS2ORUNIX /* UNIX needs it */
- #define _XYSESS
- #endif /* OS2ORUNIX */
- #ifdef OSK /* OS-9 too */
- #define _XYSESS
- #endif /* OSK */
- #ifdef _XYSESS
- case XYSESS: /* SESSION-LOG */
- if ((x = cmkey(sfttab,nsfttab,"type of file",
- #ifdef OS2
- "binary",
- #else /* OS2 */
- "text",
- #endif /* OS2 */
- xxstring
- )
- ) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- sessft = x;
- return(success = 1);
- #undef _XYSESS
- #endif /* _XYSESS */
- case XYSPEE: /* SET SPEED */
- lp = line;
- sprintf(lp,"Transmission rate for %s in bits per second",ttname);
- zz = -1L;
- if ((x = cmkey(spdtab,nspd,line,"",xxstring)) < 0) {
- if (x == -3) printf("?value requiredn");
- #ifdef USETCSETSPEED
- /* In this case, any number can be tried */
- /* There's a parse error message but the request still goes thru */
- if (rdigits(atmbuf))
- zz = atol(atmbuf);
- else
- #endif /* USETCSETSPEED */
- return(x);
- }
- if ((y = cmcfm()) < 0) return(y);
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- if (!local) {
- printf("?Sorry, you must SET LINE firstn");
- return(success = 0);
- } else if (network) {
- printf("n?Speed cannot be set for network connectionsn");
- return(success = 0);
- }
- /*
- Note: This way of handling speeds is not 16-bit safe for speeds greater
- than 230400. The argument to ttsspd() should have been a long.
- */
- #ifdef USETCSETSPEED
- if (zz > -1L)
- x = zz / 10L;
- #endif /* USETCSETSPEED */
- zz = (long) x * 10L;
- if (zz == 130L) zz = 134L;
- if (zz == 70L) zz = 75L; /* (see spdtab[] definition) */
- if (ttsspd(x) < 0) { /* Call ttsspd with cps, not bps! */
- printf("?Unsupported line speed - %ldn",zz);
- return(success = 0);
- } else {
- #ifdef CK_TAPI
- if (!tttapi || tapipass)
- speed = ttgspd(); /* Read it back */
- else
- speed = zz;
- #else /* CK_TAPI */
- speed = ttgspd(); /* Read it back */
- #endif /* CK_TAPI */
- if (speed != zz) { /* Call ttsspd with cps, not bps! */
- printf("?SET SPEED fails, speed is %ldn",speed);
- return(success = 0);
- }
- if (pflag && !cmdsrc()) {
- if (speed == 8880)
- printf("%s, 75/1200 bpsn",ttname);
- else if (speed == 134)
- printf("%s, 134.5 bpsn",ttname);
- else
- printf("%s, %ld bpsn",ttname,speed);
- }
- return(success = 1);
- }
- #endif /* NOLOCAL */
- #ifndef NOXFER
- case XYXFER: /* SET TRANSFER */
- if ((y = cmkey(rmsflg ? rtstab : tstab, /* (or REMOTE SET TRANSFER) */
- rmsflg ? nrts : nts,
- "","character-set",xxstring)) < 0) return(y);
- switch (y) {
- #ifdef XFRCAN
- case XYX_CAN: /* CANCELLATION */
- if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
- if (z == 0) { /* OFF */
- if ((y = cmcfm()) < 0) return(y);
- xfrcan = 0;
- } else {
- if ((y = cmnum("ASCII code for cancellation character","3",10,&x,
- xxstring)) < 0)
- return(y);
- if (x > 31 && x != 127) {
- printf("Cancel character must be in ASCII control rangen");
- return(-9);
- }
- if ((y = cmnum("How many required to cause cancellation",
- "2",10,&z, xxstring)) < 0)
- return(y);
- if (z < 2) {
- printf("Number must be 2 or greatern");
- return(-9);
- }
- if ((y = cmcfm()) < 0) return(y);
- xfrcan = 1; /* CANCELLATION ON */
- xfrchr = x; /* Using this character */
- xfrnum = z; /* Needing this many of them */
- }
- return(success = 1);
- #endif /* XFRCAN */
- #ifndef NOCSETS
- case XYX_CSE: /* CHARACTER-SET */
- if ((y = cmkey(tcstab,ntcs,"","transparent",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (rmsflg) {
- sstate = setgen('S', "405", tcsinfo[y].designator, "");
- return((int) sstate);
- } else {
- extern int s_cset, fcharset, axcset[];
- tslevel = (y == TC_TRANSP) ? 0 : 1; /* transfer syntax level */
- tcharset = y; /* transfer character set */
- if (s_cset == XMODE_A) /* If SEND CHARACTER-SET is AUTO */
- if (y > -1 && y <= MAXTCSETS)
- if (axcset[y] > -1 && axcset[y] > MAXFCSETS)
- fcharset = axcset[y]; /* Auto-pick file charset */
- setxlatype(tcharset,fcharset); /* Translation type */
- return(success = 1);
- }
- #endif /* NOCSETS */
- case XYX_LSH: /* LOCKING-SHIFT */
- if ((y = cmkey(lstab,nls,"","on",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- lscapr = (y == 1) ? 1 : 0; /* ON: requested = 1 */
- lscapu = (y == 2) ? 2 : 0; /* FORCED: used = 1 */
- return(success = 1);
- #ifdef CK_XYZ
- case XYX_PRO: /* Protocol */
- #ifndef OS2
- if (inserver) {
- printf("?Sorry, only Kermit protocol is availablen");
- return(-9);
- }
- #endif /* OS2 */
- return(setproto());
- #endif /* CK_XYZ */
- case XYX_MOD: /* Mode */
- if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (rmsflg) {
- sstate = setgen('S', "410", y == XMODE_A ? "0" : "1", "");
- return((int)sstate);
- }
- g_xfermode = y;
- xfermode = y;
- return(success = 1);
- #ifndef NOLOCAL
- case XYX_DIS: /* Display */
- return(doxdis());
- #endif /* NOLOCAL */
- case XYX_SLO: /* Slow-start */
- return(seton(&slostart));
- #ifndef NOSPL
- case XYX_CRC: /* CRC */
- return(seton(&docrc));
- #endif /* NOSPL */
- case XYX_BEL: /* Bell */
- return(seton(&xfrbel));
- #ifdef PIPESEND
- case XYX_PIP: /* Pipes */
- #ifndef NOPUSH
- if (nopush) {
- #endif /* NOPUSH */
- printf("Sorry, access to pipes is disabledn");
- return(-9);
- #ifndef NOPUSH
- } else
- #endif /* NOPUSH */
- return(seton(&usepipes));
- #endif /* PIPESEND */
- case XYX_INT: /* Interruption */
- return(seton(&xfrint));
- default:
- return(-2);
- }
- #endif /* NOXFER */
- }
- switch (xx) {
- #ifndef NOXMIT
- case XYXMIT: /* SET TRANSMIT */
- return(setxmit());
- #endif /* NOXMIT */
- #ifndef NOXFER
- #ifndef NOCSETS
- case XYUNCS: /* UNKNOWN-CHARACTER-SET */
- if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- unkcs = y;
- return(success = 1);
- #endif /* NOCSETS */
- #endif /* NOXFER */
- #ifndef NOPUSH
- #ifdef UNIX
- case XYWILD: /* WILDCARD-EXPANSION */
- if ((y = cmkey(wildtab,2,"who expands wildcards","kermit",xxstring)) < 0)
- return(y);
- if ((z = cmkey(wdottab,
- 2,
- "whether to match filenames that start with "."",
- "/no-match-dot-files",
- xxstring)
- ) < 0)
- return(z);
- if ((x = cmcfm()) < 0) return(x);
- if (nopush) {
- if (y > 0) {
- printf("Shell expansion is disabledn");
- return(success = 0);
- }
- }
- wildxpand = y;
- matchdot = z;
- return(success = 1);
- #endif /* UNIX */
- #endif /* NOPUSH */
- #ifndef NOXFER
- case XYWIND: /* WINDOW-SLOTS */
- if (protocol == PROTO_K) {
- y = cmnum("Window size for Kermit protocol, 1 to 32",
- "1", 10, &x, xxstring);
- y = setnum(&z,x,y,MAXWS); /* == 32 */
- }
- #ifdef CK_XYZ
- else if (protocol == PROTO_Z) {
- y = cmnum("Window size for ZMODEM protocol, 0 to 65535",
- "0", 10, &x, xxstring);
- y = setnum(&z,x,y,65535);
- }
- #endif /* CK_XYZ */
- else {
- y = cmnum("Window size for current protocol",
- "", 10, &x, xxstring);
- y = setnum(&z,x,y,65472); /* Doesn't matter - we won't use it */
- }
- if (y < 0) return(y);
- if (protocol == PROTO_K) {
- if (z < 1)
- z = 1;
- }
- #ifdef CK_XYZ
- else if (protocol == PROTO_Z) {
- /* Zmodem windowing is closer to Kermit packet length */
- /* than Kermit window size. If Window size is zero */
- /* an end of frame and CRC is sent only at the end of */
- /* the file (default). Otherwise, an End of Frame */
- /* and CRC are sent after Window Size number of bytes */
- if (z < 0) /* Disable windowing */
- z = 0;
- } else {
- printf("?SET WINDOW does not apply to %s protocoln",
- ptab[protocol].p_name
- );
- }
- #endif /* CK_XYZ */
- #ifdef COMMENT
- /* This is taken care of automatically now in protocol negotiation */
- if (maxtry < z) {
- printf("?Window slots must be less than retry limitn");
- return(success = 0);
- }
- #endif /* COMMENT */
- if (protocol == PROTO_K && rmsflg) { /* Set remote window size */
- wslotr = z; /* Set local window size too */
- ptab[protocol].winsize = wslotr;
- sstate = setgen('S', "406", ckitoa(z), "");
- return((int) sstate);
- }
- wslotr = z; /* Set requested window size here */
- ptab[protocol].winsize = wslotr; /* and in protocol-specific table */
- if (protocol == PROTO_K) { /* And for Kermit only... */
- swcapr = (wslotr > 1) ? 1 : 0; /* set window bit in capas word */
- if (wslotr > 1) { /* Window size > 1? */
- y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet size */
- if (y != urpsiz) { /* Did it change? */
- urpsiz = y;
- if (msgflg)
- printf(
- " Adjusting receive packet-length to %d for %d window slotsn",
- urpsiz,
- wslotr
- );
- }
- }
- }
- return(success = 1);
- #endif /* NOXFER */
- }
- switch (xx) {
- #ifndef NOSPL
- case XYOUTP: /* OUTPUT command parameters */
- if ((y = cmkey(outptab,noutptab,"OUTPUT command parameter","pacing",
- xxstring)) < 0)
- return(y);
- switch(y) { /* Which parameter */
- case OUT_PAC: /* PACING */
- y = cmnum("Milliseconds to pause between each OUTPUT character","100",
- 10,&x,xxstring);
- y = setnum(&z,x,y,16383); /* Verify and get confirmation */
- if (y < 0) return(y);
- if (z < 0) z = 0; /* (save some space) */
- pacing = z;
- return(success = 1);
- case OUT_ESC: /* Special-escapes */
- return(seton(&outesc));
- default: /* (shouldn't happen) */
- return(-2);
- }
- #endif /* NOSPL */
- #ifdef CK_SPEED
- case XYQCTL: {
- short *p;
- int zz;
- if ((z = cmkey(ctltab,2, "control-character prefixing option",""
- ,xxstring)) < 0)
- return(z);
- /* Make space for a temporary copy of the prefixing table */
- p = (short *)malloc(256 * sizeof(short));
- if (!p) {
- printf("?Internal error - malloc failuren");
- return(-9);
- }
- for (i = 0; i < 256; i++) p[i] = ctlp[i]; /* Copy current table */
- switch (z) {
- case 0: /* UNPREFIXED control character */
- case 1: /* PREFIXED control character */
- while (1) { /* Collect a list of numbers */
- #ifndef NOSPL
- x_ifnum = 1; /* Turn off complaints from eval() */
- #endif /* NOSPL */
- if ((x = cmnum((z == 0) ?
- "n Numeric ASCII value of control character that needs NO prefix,n
- or the word "all", or carriage return to complete the list" :
- "n Numeric ASCII value of control character that MUST BE prefixed,n
- or the word "all", or carriage return to complete the list",
- "",10,&y,xxstring
- )) < 0) {
- #ifndef NOSPL
- x_ifnum = 0;
- #endif /* NOSPL */
- if (x == -3) {
- if ((x = cmcfm()) < 0) return(x);
- break;
- }
- if (x == -2) {
- if (p) { free(p); p = NULL; }
- debug(F110,"SET CONTROL atmbuf",atmbuf,0);
- if (!ckstrcmp(atmbuf,"all",3,0) ||
- !ckstrcmp(atmbuf,"al",2,0) ||
- !ckstrcmp(atmbuf,"a",1,0)) {
- if ((x = cmcfm()) < 0) /* Get confirmation */
- return(x);
- if (z)
- prefixing = PX_ALL;
- #ifndef UNPREFIXZERO
- /* Set all values, but don't touch 0 */
- for (y = 1; y < 32; y++) ctlp[y] = (short) z;
- #else
- /* Zero too */
- for (y = 0; y < 32; y++) ctlp[y] = (short) z;
- #endif /* UNPREFIXZERO */
- for (y = 127; y < 160; y++) ctlp[y] = (short) z;
- ctlp[255] = (short) z;
- /* Watch out for XON and XOFF */
- if (flow == FLO_XONX && z == 0) {
- if (msgflg) {
- printf(
- " XON/XOFF characters 17, 19, 145, 147 not affected.n");
- printf(
- #ifdef CK_RTSCTS
- " SET FLOW NONE or RTS/CTS to transmit these characters unprefixed.n"
- #else
- " SET FLOW NONE to transmit these characters unprefixed.n"
- #endif /* CK_RTSCTS */
- );
- }
- ctlp[XON] =
- ctlp[XOFF] =
- ctlp[XON+128] =
- ctlp[XOFF+128] = 1;
- }
- #ifdef TNCODE
- /* Watch out for TELNET IAC */
- if (network && (ttnproto == NP_TELNET) && z == 0) {
- ctlp[255] = 1;
- if (parity == 'e' || parity == 'm') ctlp[127] = 1;
- ctlp[13] = 1;
- if (msgflg)
- printf(
- " TELNET IAC = 255, CR = 13, not affected.n");
- }
- #endif /* TNCODE */
- #ifndef UNPREFIXZERO
- #ifdef OS2
- if (z == 0 && protocol != PROTO_K)
- ctlp[0] = 0;
- #endif /* OS2 */
- #endif /* UNPREFIXZERO */
- return(success = 1);
- } else {
- printf("?Please specify a number or the word ALLn");
- return(-9);
- }
- } else {
- if (p) free(p);
- return(x);
- }
- }
- #ifndef NOSPL
- x_ifnum = 0;
- #endif /* NOSPL */
- #ifdef UNPREFIXZERO
- zz = 0;
- #else
- #ifndef OS2
- zz = 1 - z;
- #else
- zz = 0; /* Allow 0 (but only for Zmodem) */
- #endif /* OS2 */
- #endif /* UNPREFIXZERO */
- /* printf("x = %d, y = %d, z = %d, zz = %dn", x,y,z,zz); */
- if ((y > 31 && y < 127) || /* A specific numeric value */
- (y > 159 && y < 255) || /* Check that it is a valid */
- (y < zz) || /* control code. */
- (y > 255)) {
- printf("?Values allowed are: %d-31, 127-159, 255n",zz);
- if (p) free(p);
- return(-9);
- }
- x = y & 127; /* Get 7-bit value */
- if (z == 0) { /* If they are saying it is safe... */
- if (((flow == FLO_XONX) && /* If flow control is Xon/Xoff */
- (x == XON || x == XOFF)) /* XON & XOFF chars not safe. */
- ) {
- if (msgflg)
- printf("Sorry, not while Xon/Xoff is in effect.n");
- if (p) free(p);
- return(-9);
- }
- #ifdef TNCODE
- else if (network && (ttnproto == NP_TELNET)
- && (y == CR || (unsigned) y == (unsigned) 255)) {
- if (msgflg)
- printf("Sorry, not on a TELNET connection.n");
- if (p) free(p);
- return(-9);
- }
- #endif /* TNCODE */
- }
- p[y] = (char) z; /* All OK, set flag */
- } /* End of while loop */
- /*
- Get here only if they have made no mistakes. Copy temporary table back to
- permanent one, then free temporary table and return successfully.
- */
- for (i = 0; i < 256; i++) ctlp[i] = p[i];
- if (p) free(p);
- return(success = 1);
- default:
- return(-2);
- }
- }
- #endif /* CK_SPEED */
- }
- switch (xx) {
- #ifndef NOXFER
- case XYREPT:
- if ((y = cmkey(rpttab,2,"repeat-count compression parameter","",xxstring))
- < 0)
- return(y);
- switch(y) {
- case 0:
- return(success = seton(&rptena)); /* REPEAT COUNTS = ON, OFF */
- case 1: /* REPEAT MININUM number */
- printf("(not implemented yet, nothing happens)n");
- return(-9);
- case 2: /* REPEAT PREFIX char */
- if ((x = cmnum("ASCII value","",10,&z,xxstring)) < 0)
- return(x);
- if ((x = cmcfm()) < 0) return(x);
- if ((z > 32 && z < 63) || (z > 95 && z < 127)) {
- if (y == 1) rptmin = (CHAR) z; else myrptq = (CHAR) z;
- return(success = 1);
- } else {
- printf("?Illegal value for prefix charactern");
- return(-9);
- }
- }
- #endif /* NOXFER */
- #ifndef NOSPL
- case XYALRM: {
- #ifndef COMMENT
- int yy;
- long zz;
- zz = -1L;
- yy = x_ifnum;
- x_ifnum = 1; /* Turn off internal complaints */
- y = cmnum("Seconds from now, or time of day as hh:mm:ss",
- "0" ,10, &x, xxstring);
- x_ifnum = yy;
- if (y < 0) {
- if (y == -2) { /* Invalid number or expression */
- zz = tod2sec(atmbuf); /* Convert to secs since midnight */
- if (zz < 0L) {
- printf("?Number, expression, or time of day requiredn");
- return(-9);
- } else {
- char now[32]; /* Current time */
- char *p;
- long tnow;
- p = now;
- ztime(&p);
- tnow = atol(p+11) * 3600L + atol(p+14) * 60L + atol(p+17);
- if (zz < tnow) /* User's time before now */
- zz += 86400L; /* So make it tomorrow */
- zz -= tnow; /* Seconds from now. */
- }
- } else
- return(y);
- }
- if (x < 0) {
- printf("?Alarm time is in the past.n");
- return(-9);
- }
- if ((y = cmcfm()) < 0) return(y);
- if (zz > -1L) { /* Time of day given? */
- x = zz;
- if (zz != (long) x) {
- printf(
- "Sorry, arithmetic overflow - hh:mm:ss not usable on this platform.n"
- );
- return(-9);
- }
- }
- return(setalarm((long)x));
- }
- #else
- /*
- This is to allow long values where int and long are not the same, e.g.
- on 16-bit systems. But something is wrong with it.
- */
- if ((y = cmtxt("seconds from now", "0", &s, xxstring)) < 0)
- return(y);
- if (rdigits(s)) {
- return(setalarm(atol(s)));
- } else {
- printf("%s - not a numbern",s);
- return(-9);
- }
- #endif /* COMMENT */
- #endif /* NOSPL */
- #ifndef NOXFER
- case XYPROTO:
- return(setproto());
- #endif /* NOXFER */
- #ifdef CK_SPEED
- case XYPREFIX: {
- #ifdef COMMENT
- extern int clearrq;
- #endif /* COMMENT */
- if ((z = cmkey(pfxtab, 4, "control-character prefixing option",
- "", xxstring)) < 0)
- return(z);
- if ((x = cmcfm()) < 0) return(x);
- setprefix(z);
- #ifdef COMMENT
- if (hints && (z == PX_ALL || z == PX_CAU) && clearrq) {
- printf("Hint: use SET CLEAR-CHANNEL OFF to disable negotiation ofn");
- printf(" SET PREFIXING NONE during file transfers on reliablen");
- printf(" connections.n");
- }
- #endif /* COMMENT */
- return(success = 1);
- }
- #endif /* CK_SPEED */
- #ifndef NOSPL
- case XYLOGIN:
- if ((z = cmkey(logintab, 3, "value for login script","userid",
- xxstring)) < 0)
- return(z);
- x = cmdgquo();
- if (z == LOGI_PSW)
- cmdsquo(0);
- if ((y = cmtxt("text","", &s, NULL)) < 0) {
- cmdsquo(x);
- return(y);
- }
- cmdsquo(x);
- #ifdef IKSD
- if (inserver)
- return(success = 0);
- #endif /* IKSD */
- if ((int)strlen(s) > 63) {
- printf("Sorry, too longn");
- return(-9);
- }
- s = brstrip(s);
- switch(z) {
- case LOGI_UID:
- ckstrncpy(uidbuf,s,UIDBUFLEN);
- sl_uid_saved = 0;
- break;
- case LOGI_PSW:
- ckstrncpy(pwbuf,s,PWBUFL);
- pwflg = 1;
- #ifdef OS2
- pwcrypt = 1;
- #else /* OS2 */
- pwcrypt = 0;
- #endif /* OS2 */
- break;
- case LOGI_PRM:
- ckstrncpy(prmbuf,s,PWBUFL);
- }
- return(success = 1);
- #endif /* NOSPL */
- }
- switch (xx) {
- case XYSTARTUP:
- if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- DeleteStartupFile = (y != 0) ? 0 : 1;
- return(success = 1);
- case XYTMPDIR:
- x = cmdir("Name of temporary directory","",&s,xxstring);
- if (x == -3)
- s = "";
- else if (x < 0)
- return(x);
- if ((x = cmcfm()) < 0) return(x);
- makestr(&tempdir,s);
- return(tempdir ? 1 : 0);
- #ifndef NOXFER
- case XYDEST: /* DESTINATION */
- return(setdest());
- #endif /* NOXFER */
- #ifndef NOPUSH
- #ifndef NOFRILLS
- /* Editor, Browser, and FTP Client */
- case XYEDIT: /* EDITOR */
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- #ifdef OS2ORUNIX
- {
- char *p = getenv("PATH");
- char *e;
- e = editor[0] ? (char *) editor : getenv("EDITOR");
- if (!e) e = "";
- if (p)
- x = cmifip("Name of preferred editor",e,&s,&y,0,p,xxstring);
- else
- x = cmifi("Full path of preferred editor",e,&s,&y,xxstring);
- if (x < 0 && x != -3)
- return(x);
- }
- #else
- #ifdef VMS
- if ((y = cmtxt("DCL command for editing", "edit", &s, NULL)) < 0) {
- if (x != -3)
- return(x);
- }
- #else
- if ((x = cmifi("Full path of preferred editor","",&s,&y,xxstring)) < 0) {
- if (x != -3)
- return(x);
- }
- #endif /* VMS */
- #endif /* OS2ORUNIX */
- #ifdef VMS
- ckstrncpy(editor,s,CKMAXPATH);
- editopts[0] = NUL;
- #else
- if (y != 0) {
- printf("?A single file pleasen");
- return(-2);
- }
- strcpy(line,s);
- if ((x = cmtxt("editor command-line options","",&s,NULL)) < 0)
- return(x);
- ckstrncpy(tmpbuf,s,TMPBUFSIZ);
- if ((z = cmcfm()) < 0) return(z);
- if (line[0]) {
- zfnqfp(line,CKMAXPATH,editor);
- ckstrncpy(editopts,tmpbuf,128);
- } else {
- editor[0] = NUL;
- editopts[0] = NUL;
- }
- #endif /* VMS */
- return(success = 1);
- #ifdef BROWSER
- case XYFTP: /* SET FTP-CLIENT */
- case XYBROWSE: /* SET BROWSER */
- {
- char *p = getenv("PATH");
- char *app = (char *) browser, *opts = (char *) browsopts;
- extern char ftpapp[], ftpopts[];
- if (xx == XYFTP) {
- app = (char *)ftpapp;
- opts = (char *)ftpopts;
- }
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- #ifdef OS2ORUNIX
- if (p)
- x = cmifip(xx == XYBROWSE ?
- "Name of preferred browser" :
- "Name of preferred ftp client",
- #ifdef OS2
- xx == XYFTP ? "ftp.exe" : ""
- #else
- xx == XYFTP ? "ftp" : ""
- #endif /* OS2 */
- ,&s,&y,0,p,xxstring
- );
- else
- x = cmifi(xx == XYBROWSE ?
- "Full path of preferred browser" :
- "Full path of preferred ftp client",
- "",&s,&y,xxstring
- );
- if (x < 0 && x != -3)
- return(x);
- #else
- #ifdef VMS
- if ((x = cmtxt("DCL command to start your preferred Web browser",
- "", &s, NULL)) < 0) {
- if (x != -3)
- return(x);
- }
- #else
- if ((x = cmifi("Full path of preferred browser","",&s,&y,xxstring)
- ) < 0) {
- if (x != -3)
- return(x);
- }
- #endif /* VMS */
- #endif /* OS2ORUNIX */
- #ifdef VMS
- ckstrncpy(app,s,CKMAXPATH);
- *opts = NUL;
- #else
- if (y != 0) {
- printf("?A single file pleasen");
- return(-2);
- }
- strcpy(line,s);
- if ((x = cmtxt(xx == XYBROWSE ?
- "browser command-line options" :
- "ftp client command-line options",
- "",&s,NULL)
- ) < 0)
- return(x);
- ckstrncpy(tmpbuf,s,TMPBUFSIZ);
- if ((z = cmcfm()) < 0) return(z);
- if (line[0]) {
- zfnqfp(line,CKMAXPATH,app);
- ckstrncpy(opts, tmpbuf, 128);
- } else {
- *app = NUL;
- *opts = NUL;
- }
- #endif /* VMS */
- return(success = 1);
- }
- #endif /* BROWSER */
- #endif /* NOFRILLS */
- #endif /* NOPUSH */
- #ifdef CK_CTRLZ
- case XYEOF: { /* SET EOF */
- extern int eofmethod; extern struct keytab eoftab[];
- if ((x = cmkey(eoftab,3,"end-of-file detection method","",
- xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- eofmethod = x;
- return(success = 1);
- }
- #endif /* CK_CTRLZ */
- #ifdef SESLIMIT
- case XYLIMIT: { /* Session-Limit (length of session in seconds) */
- extern int seslimit;
- y = cmnum("Maximum length of session, seconds","0",10,&x,xxstring);
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else
- 1
- #endif /* IKSDCONF */
- ) {
- if ((z = cmcfm()) < 0)
- return(z);
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- return(setnum(&seslimit,x,y,86400));
- }
- #endif /* SESLIMIT */
- case XYRELY: { /* SET RELIABLE */
- extern int reliable, setreliable;
- if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- reliable = x;
- setreliable = (x != SET_AUTO);
- debug(F101,"set reliable","",reliable);
- return(success = 1);
- }
- #ifdef STREAMING
- case XYSTREAM: { /* SET STREAMING */
- extern int streamrq;
- if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- streamrq = x;
- return(success = 1);
- }
- #endif /* STREAMING */
- #ifdef CKSYSLOG
- case XYSYSL: {
- if ((x = cmkey(syslogtab,nsyslog,"","",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else
- 1
- #endif /* IKSDCONF */
- ) {
- printf("?Sorry, command disabled.n");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- ckxsyslog = x;
- return(success = 1);
- }
- #endif /* CKSYSLOG */
- #ifdef TLOG
- case XYTLOG: { /* SET TRANSACTION-LOG */
- extern int tlogsep;
- if ((x = cmkey(vbtab,nvb,"","verbose",xxstring)) < 0)
- return(x);
- if (x == 0) {
- if ((y = cmtxt("field separator",",",&s,NULL)) < 0) return(y);
- s = brstrip(s);
- if (*s) {
- if (s[1]) {
- printf("?A single character, please.n");
- return(-9);
- } else if ((*s >= '0' && *s <= '9') ||
- (*s >= 'A' && *s <= 'Z') ||
- (*s >= 'a' && *s <= 'z')) {
- printf("?A non-alphanumeric character, please.n");
- return(-9);
- } else
- tlogsep = *s;
- }
- } else {
- if ((y = cmcfm()) < 0) return(y);
- }
- #ifdef IKSD
- if (inserver && isguest) {
- printf("?Sorry, command disabled.n");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- tlogfmt = x;
- return(success = 1);
- }
- #endif /* TLOG */
- case XYCLEAR: { /* SET CLEARCHANNEL */
- extern int clearrq;
- if ((x = cmkey(ooatab,3,"","automatic",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- clearrq = x;
- return(success = 1);
- }
- #ifdef CK_AUTHENTICATION
- case XYAUTH: { /* SET AUTHENTICATION */
- #ifdef CK_KERBEROS
- int kv = 0;
- extern struct krb_op_data krb_op;
- #endif /* CK_KERBEROS */
- char * p = NULL;
- if ((x = cmkey(setauth,nsetauth,"authentication type","",xxstring)) < 0)
- return(x);
- switch (x) {
- #ifdef CK_KERBEROS
- case AUTH_KRB4: kv = 4; break; /* Don't assume values are the same */
- case AUTH_KRB5: kv = 5; break;
- #endif /* CK_KERBEROS */
- #ifdef CK_SRP
- case AUTH_SRP: break;
- #endif /* CK_SRP */
- #ifdef CK_SSL
- case AUTH_SSL:
- case AUTH_TLS:
- break;
- #endif /* CK_SSL */
- default:
- printf("?Authorization type not supported yet - "%s"n",atmbuf);
- return(-9);
- }
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else
- 1
- #endif /* IKSDCONF */
- ) {
- if ((y = cmcfm()) < 0) return(y);
- printf("?Sorry, command disabled.n");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH) {
- if ((y = cmcfm()) < 0) return(y);
- return(success = 0);
- }
- #endif /* CK_APC */
- switch(x) {
- #ifdef CK_KERBEROS
- case AUTH_KRB4:
- case AUTH_KRB5: {
- if ((x = cmkey(kv == 4 ? k4tab : k5tab,
- kv == 4 ? nk4tab : nk5tab,
- "Kerberos parameter","",xxstring)) < 0) {
- return(x);
- }
- s = "";
- switch (x) {
- #ifdef KRB4
- case XYKRBDBG:
- if (kv == 4) {
- if ((y = seton(&k4debug)) < 0)
- return(y);
- #ifdef NT
- ck_krb4_debug(k4debug);
- #endif /* NT */
- } else {
- return(-9);
- }
- break;
- #endif /* KRB4 */
- case XYKRBLIF:
- if ((y = cmnum("TGT lifetime","600",10,&z,xxstring)) < 0)
- return(y);
- break;
- case XYKRBPRE:
- if (kv == 4) {
- if ((y = seton(&krb4_d_preauth)) < 0)
- return(y);
- } else {
- return(-9);
- }
- break;
- case XYKRBINS:
- if ((y = cmtxt("Instance name","",&s,xxstring)) < 0)
- return(y);
- break;
- case XYKRBFWD:
- if (kv == 5) {
- if ((y = seton(&krb5_d_forwardable)) < 0)
- return(y);
- } else {
- return(-9);
- }
- break;
- case XYKRBPRX:
- if (kv == 5) {
- if ((y = seton(&krb5_d_proxiable)) < 0)
- return(y);
- } else {
- return(-9);
- }
- break;
- case XYKRBRNW:
- if ((y = cmnum("TGT renewable lifetime",
- "0",10,&z,xxstring)) < 0)
- return(y);
- break;
- case XYKRBADR:
- if (kv == 5) {
- if ((y = seton(&krb5_checkaddrs)) < 0)
- return(y);
- } else {
- if ((y = seton(&krb4_checkaddrs)) < 0)
- return(y);
- }
- break;
- case XYKRBGET:
- if (kv == 5) {
- if ((y = seton(&krb5_autoget)) < 0)
- return(y);
- } else {
- if ((y = seton(&krb4_autoget)) < 0)
- return(y);
- }
- break;
- case XYKRBDEL:
- if ((z = cmkey(kdestab,nkdestab,
- "Auto Destroy Tickets","never",xxstring)) < 0)
- return(z);
- break;
- case XYKRBPR:
- if ((y = cmtxt("User ID",uidbuf,&s,xxstring)) < 0)
- return(y);
- break;
- case XYKRBRL:
- if ((y = cmtxt("Name of realm","",&s,xxstring)) < 0)
- return(y);
- break;
- case XYKRBCC:
- if ((y = cmofi("Filename","",&s,xxstring)) < 0)
- return(y);
- break;
- case XYKRBSRV:
- if ((y = cmtxt("Name of service to use in ticket",
- (kv == 4 ? "rcmd" : "host"),
- &s,
- xxstring
- )) < 0)
- return(y);
- break;
- case XYKRBK5K4:
- if (kv == 5) {
- if ((y = seton(&krb5_d_getk4)) < 0)
- return(y);
- } else {
- return(-9);
- }
- break;
- case XYKRBPRM: /* Prompt */
- if ((z = cmkey(krbprmtab,2,"","",xxstring)) < 0)
- return(z);
- if ((y = cmtxt((z == KRB_PW_PRM) ?
- "Text of prompt;nmay contain "%s" to be replaced by principal name" :
- "Text of prompt",
- "",
- &s,
- xxstring
- )
- ) < 0)
- return(y);
- break;
- }
- strcpy(line,s);
- s = line;
- if ((y = cmcfm()) < 0)
- return(y);
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else /* IKSDCONF */
- 1
- #endif /* IKSDCONF */
- )
- return(success = 0);
- #endif /* IKSD */
- switch (x) { /* Copy value to right place */
- case XYKRBLIF: /* Lifetime */
- if (kv == 4)
- krb4_d_lifetime = z;
- else
- krb5_d_lifetime = z;
- break;
- case XYKRBRNW:
- if (kv == 5)
- krb5_d_renewable = z;
- break;
- case XYKRBPR: /* Principal */
- s = brstrip(s); /* Strip braces around. */
- if (kv == 4)
- makestr(&krb4_d_principal,s);
- else
- makestr(&krb5_d_principal,s);
- break;
- case XYKRBINS: /* Instance */
- if (kv == 4)
- makestr(&krb4_d_instance,s);
- else
- makestr(&krb5_d_instance,s);
- break;
- case XYKRBRL: /* Realm */
- if (kv == 4)
- makestr(&krb4_d_realm,s);
- else
- makestr(&krb5_d_realm,s);
- break;
- case XYKRBCC: /* Credentials cache */
- makestr(&krb5_d_cc,s);
- break;
- case XYKRBSRV: /* Service Name */
- if (kv == 4)
- makestr(&krb4_d_srv,s);
- else
- makestr(&krb5_d_srv,s);
- break;
- case XYKRBDEL:
- if (kv == 5)
- krb5_autodel = z;
- else
- krb4_autodel = z;
- break;
- case XYKRBPRM: /* Prompt */
- if (s == "") s = NULL;
- if (s) {
- s = brstrip(s);
- if (s == "") s = NULL;
- }
- switch (z) {
- case KRB_PW_PRM: { /* Password */
- /* Check that there are no more than */
- /* two % fields and % must followed by 's'. */
- int i,n,len;
- len = strlen(s);
- for (i = 0, n = 0; i < len; i++) {
- if (s[i] == '%') {
- if (s[i+1] != '%') {
- if (s[i+1] != 's') {
- printf(
- "Only %%s fields are permitted.n");
- return(-9);
- }
- if (++n > 2) {
- printf(
- "Only two %%s fields are permitted.n");
- return(-9);
- }
- }
- i++;
- }
- }
- if (kv == 5)
- makestr(&k5pwprompt,s);
- else
- makestr(&k4pwprompt,s);
- break;
- }
- case KRB_PR_PRM: { /* Principal */
- /* Check to make sure there are no % fields */
- int i,len;
- len = strlen(s);
- for (i = 0; i < len; i++) {
- if (s[i] == '%') {
- if (s[i+1] != '%') {
- printf(
- "%% fields are not used in this command.n");
- return(-9);
- }
- i++;
- }
- }
- if (kv == 5)
- makestr(&k5prprompt,s);
- else
- makestr(&k4prprompt,s);
- break;
- }
- }
- }
- break;
- }
- #endif /* CK_KERBEROS */
- #ifdef CK_SRP
- case AUTH_SRP: {
- if ((x = cmkey(srptab, nsrptab,
- "SRP parameter","",xxstring)) < 0) {
- return(x);
- }
- s = "";
- switch (x) {
- case XYSRPPRM: /* Prompt */
- if ((z = cmkey(srpprmtab,1,"","",xxstring)) < 0)
- return(z);
- if ((y = cmtxt(
- "Text of prompt;nmay contain one "%s" to be replaced by the username",
- "",
- &s,
- xxstring
- )
- ) < 0)
- return(y);
- break;
- }
- strcpy(line,s);
- s = line;
- if ((y = cmcfm()) < 0)
- return(y);
- switch (x) { /* Copy value to right place */
- case XYSRPPRM: /* Prompt */
- if (s == "") s = NULL;
- if (s) {
- s = brstrip(s);
- if (s == "") s = NULL;
- }
- switch (z) {
- case SRP_PW_PRM: { /* Password */
- /* Check %s fields */
- int i,n,len;
- len = strlen(s);
- for (i = 0, n = 0; i < len; i++) {
- if (s[i] == '%') {
- if (s[i+1] != '%') {
- if (s[i+1] != 's') {
- printf(
- "Only %%s fields are permitted.n");
- return(-9);
- }
- if (++n > 1) {
- printf(
- "Only one %%s field is permitted.n");
- return(-9);
- }
- }
- i++;
- }
- }
- makestr(&srppwprompt,s);
- break;
- }
- }
- }
- break;
- }
- #endif /* CK_SRP */
- #ifdef CK_SSL
- case AUTH_SSL:
- case AUTH_TLS: {
- if ((z = cmkey(ssltab, nssltab,
- (x == AUTH_SSL ? "SSL parameter" : "TLS parameter"),
- "",xxstring)) < 0)
- return(z);
- s = "";
- switch (z) {
- case XYSSLRCFL: /* SSL/TLS RSA Certs file */
- case XYSSLRKFL: /* SSL/TLS RSA Key File */
- case XYSSLDCFL: /* SSL/TLS DSA Certs file */
- case XYSSLDKFL: /* SSL/TLS DH Key File */
- case XYSSLDPFL: /* SSL/TLS DH Param File */
- case XYSSLCRL: /* SSL/TLS CRL File */
- case XYSSLVRFF: /* SSL/TLS Verify File */
- if ((y = cmifi("Filename","",&s,&x,xxstring)) < 0)
- return(y);
- if (x) {
- printf("?Wildcards not allowedn");
- return(-9);
- }
- strcpy(line,s);
- s = line;
- if ((y = cmcfm()) < 0)
- return(y);
- switch (z) {
- case XYSSLRCFL: /* SSL/TLS RSA Certs file */
- if (!s[0] && ssl_rsa_cert_file) {
- free(ssl_rsa_cert_file);
- ssl_rsa_cert_file = NULL;
- } else {
- makestr(&ssl_rsa_cert_file,s);
- if (!ssl_rsa_key_file)
- makestr(&ssl_rsa_key_file,s);
- }
- break;
- case XYSSLRKFL: /* SSL/TLS RSA Key File */
- if (!s[0] && ssl_rsa_key_file) {
- free(ssl_rsa_key_file);
- ssl_rsa_key_file = NULL;
- } else {
- makestr(&ssl_rsa_key_file,s);
- }
- break;
- case XYSSLDCFL: /* SSL/TLS DSA Certs file */
- if (!s[0] && ssl_dsa_cert_file) {
- free(ssl_dsa_cert_file);
- ssl_dsa_cert_file = NULL;
- } else {
- makestr(&ssl_dsa_cert_file,s);
- if (!ssl_dh_key_file)
- makestr(&ssl_dh_key_file,s);
- }
- break;
- case XYSSLDKFL: /* SSL/TLS DH Key File */
- if (!s[0] && ssl_dh_key_file) {
- free(ssl_dh_key_file);
- ssl_dh_key_file = NULL;
- } else {
- makestr(&ssl_dh_key_file,s);
- }
- break;
- case XYSSLDPFL: /* SSL/TLS DH Param File */
- if (!s[0] && ssl_dh_param_file) {
- free(ssl_dh_param_file);
- ssl_dh_param_file = NULL;
- } else {
- makestr(&ssl_dh_param_file,s);
- }
- break;
- case XYSSLCRL: /* SSL/TLS CRL File */
- if (!s[0] && ssl_crl_file) {
- free(ssl_crl_file);
- ssl_crl_file = NULL;
- } else {
- makestr(&ssl_crl_file,s);
- }
- break;
- case XYSSLVRFF: /* SSL/TLS Verify File */
- if (!s[0] && ssl_crl_file) {
- free(ssl_verify_file);
- ssl_verify_file = NULL;
- } else {
- makestr(&ssl_verify_file,s);
- }
- break;
- }
- break;
- case XYSSLCRLD:
- case XYSSLVRFD:
- if ((y = cmdir("Directory","",&s,xxstring)) < 0)
- return(y);
- strcpy(line,s);
- s = line;
- if ((y = cmcfm()) < 0)
- return(y);
- switch(z) {
- case XYSSLCRLD:
- if (!s[0] && ssl_crl_dir) {
- free(ssl_crl_dir);
- ssl_crl_dir = NULL;
- } else {
- makestr(&ssl_crl_dir,s);
- }
- break;
- case XYSSLVRFD:
- if (!s[0] && ssl_verify_dir) {
- free(ssl_verify_dir);
- ssl_verify_dir = NULL;
- } else {
- makestr(&ssl_verify_dir,s);
- }
- break;
- }
- break;
- case XYSSLCOK: /* SSL/TLS Certs-Ok flag */
- if ((y = seton(&ssl_certsok_flag)) < 0)
- return(y);
- break;
- case XYSSLDBG: /* SSL/TLS Debug flag */
- if ((y = seton(&ssl_debug_flag)) < 0)
- return(y);
- break;
- case XYSSLON: /* SSL/TLS Only flag */
- switch (x) {
- case AUTH_SSL:
- if ((y = seton(&ssl_only_flag)) < 0)
- return(y);
- break;
- case AUTH_TLS:
- if ((y = seton(&tls_only_flag)) < 0)
- return(y);
- break;
- }
- break;
- case XYSSLVRB: /* SSL/TLS Verbose flag */
- if ((y = seton(&ssl_verbose_flag)) < 0)
- return(y);
- break;
- case XYSSLVRF: /* SSL/TLS Verify flag */
- if ((x = cmkey(sslvertab, nsslvertab,
- "SSL/TLS verify mode",
- "peer-cert",xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- ssl_verify_flag = x;
- break;
- case XYSSLDUM:
- if ((y = seton(&ssl_dummy_flag)) < 0)
- return(y);
- break;
- case XYSSLCL: { /* SSL/TLS Cipher List */
- #ifdef COMMENT
- /* This code is used to generate a colon delimited */
- /* list of the ciphers currently in use to be used */
- /* as the default for cmtxt(). However, a better */
- /* default is simply the magic keyword "ALL". */
- CHAR def[1024] = "";
- if (ssl_con != NULL) {
- CHAR * p = NULL, *q = def;
- int i, len;
- for (i = 0; ; i++) {
- p = (CHAR *) SSL_get_cipher_list(ssl_con,i);
- if (p == NULL)
- break;
- len = strlen(p);
- if (q+len+1 >= def+1024)
- break;
- if (i != 0)
- *q++ = ':';
- strcpy(q,p);
- q += len;
- }
- }
- #endif /* COMMENT */
- char * p = getenv("SSL_CIPHER");
- if (!p)
- p = "ALL";
- if ((y = cmtxt(
- "Colon-delimited list of ciphers or ALL (case sensitive)",
- p,
- &s,
- xxstring
- )
- ) < 0)
- return(y);
- makestr(&ssl_cipher_list,s);
- if (ssl_con == NULL) {
- SSL_library_init();
- ssl_ctx = (SSL_CTX *)
- SSL_CTX_new((SSL_METHOD *)TLSv1_method());
- if (ssl_ctx != NULL)
- ssl_con= (SSL *) SSL_new(ssl_ctx);
- }
- if (ssl_con) {
- SSL_set_cipher_list(ssl_con,ssl_cipher_list);
- }
- break;
- }
- }
- break;
- }
- #endif /* CK_SSL */
- default:
- break;
- }
- return(success = 1);
- }
- #endif /* CK_AUTHENTICATION */
- #ifndef NOSPL
- case XYFUNC:
- if ((x = cmkey(functab,nfunctab,"","diagnostics",xxstring)) < 0)
- return(x);
- switch (x) {
- case FUNC_DI: return(seton(&fndiags));
- case FUNC_ER: return(seton(&fnerror));
- default: return(-2);
- }
- #endif /* NOSPL */
- case XYSLEEP: /* SET SLEEP / PAUSE */
- if ((x = cmkey(sleeptab,1,"","cancellation",xxstring)) < 0)
- return(x);
- return(seton(&sleepcan));
- case XYCD: /* SET CD */
- if ((x = cmkey(cdtab,ncdtab,"","",xxstring)) < 0)
- return(x);
- switch (x) {
- case XYCD_M: /* SET CD MESSAGE */
- if ((x = cmkey(cdmsg,ncdmsg,"","",xxstring)) < 0)
- return(x);
- if (x == 2) { /* CD MESSAGE FILE */
- if ((x = cmtxt("Name of file","",&s,NULL)) < 0)
- return(x);
- if (!*s) {
- s = NULL;
- #ifndef NOXFER
- srvcdmsg = 0;
- #endif /* NOXFER */
- }
- makestr(&cdmsgstr,s);
- makelist(cdmsgstr,cdmsgfile,8);
- return(success = 1);
- }
- if ((y = cmcfm()) < 0) return(y); /* CD-MESSAGE ON/OFF */
- #ifndef NOXFER
- if (x > 0)
- srvcdmsg |= 2;
- else
- srvcdmsg &= 1;
- #endif /* NOXFER */
- return(success = 1);
- case XYCD_P: { /* SET CD PATH */
- extern char * ckcdpath;
- if ((x = cmtxt("CD PATH string","",&s,xxstring)) < 0)
- return(x);
- makestr(&ckcdpath,s);
- return(success = 1);
- }
- }
- #ifndef NOLOCAL
- #ifdef HWPARITY
- case XYSTOP: /* STOP-BITS */
- if ((x = cmkey(stoptbl,2,"Stop bits for serial device","",
- xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- if (x > 0 && x < 3) {
- stopbits = x;
- return(success = 1);
- } else
- return(-2);
- #endif /* HWPARITY */
- case XYDISC: {
- extern int clsondisc;
- return(seton(&clsondisc));
- }
- case XYSERIAL: {
- /* char c; */
- extern int cmask;
- if ((x = cmkey(sertbl,nsertbl,
- "Serial device character size, parity, and stop bits",
- "8N1", xxstring)) < 0)
- return(x);
- strcpy(line,atmbuf); /* Copy associated keyword string */
- s = line;
- if ((y = cmcfm()) < 0)
- return(y);
- strcpy(line,sernam[x]);
- s = line;
- if (s[0] != '8' && s[0] != '7') /* Char size */
- return(-2);
- else
- z = s[0] - '0';
- if (isupper(s[1])) /* Parity */
- s[1] = tolower(s[1]);
- if (s[2] != '1' && s[2] != '2') /* Stop bits */
- return(-2);
- else
- stopbits = s[2] - '0';
- if (z == 8) { /* 8 bits + parity (or not) */
- parity = 0; /* Set parity */
- hwparity = (s[1] == 'n') ? 0 : s[1];
- cmask = 0xff; /* Also set TERM BYTESIZE to 8 */
- } else { /* 7 bits plus parity */
- parity = (s[1] == 'n') ? 0 : s[1];
- hwparity = 0;
- cmask = 0x7f; /* Also set TERM BYTESIZE to 7 */
- }
- return(success = 1);
- }
- case XYOPTS: { /* SET OPTIONS */
- extern int setdiropts();
- extern int settypopts();
- #ifdef CKPURGE
- extern int setpurgopts();
- #endif /* CKPURGE */
- if ((x = cmkey(optstab,noptstab,"for command","", xxstring)) < 0)
- return(x);
- switch (x) {
- #ifndef NOFRILLS
- case XXDEL:
- return(setdelopts());
- #endif /* NOFRILLS */
- case XXDIR:
- return(setdiropts());
- case XXTYP:
- return(settypopts());
- #ifdef CKPURGE
- case XXPURGE:
- return(setpurgopts());
- #endif /* CKPURGE */
- default:
- return(-2);
- }
- }
- #endif /* NOLOCAL */
- #ifndef NOXFER
- case XYQ8FLG: {
- extern int q8flag;
- return(seton(&q8flag));
- }
- case XYTIMER: {
- extern int asktimer;
- y = cmnum("Time limit for ASK command, seconds","0",10,&x,xxstring);
- #ifdef QNX16
- return(setnum(&asktimer,x,y,32767));
- #else
- return(setnum(&asktimer,x,y,86400));
- #endif /* QNX16 */
- }
- case XYFACKB: {
- extern int fackbug;
- return(seton(&fackbug));
- }
- #endif /* NOXFER */
- case XYHINTS:
- return(seton(&hints));
- #ifndef NOSPL
- case XYEVAL: {
- extern int oldeval;
- if ((x = cmkey(oldnew,2,"","", xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0)
- return(y);
- oldeval = x;
- return(success = 1);
- }
- #endif /* NOSPL */
- #ifndef NOXFER
- case XYFACKP: {
- extern int fackpath;
- return(seton(&fackpath));
- }
- #endif /* NOXFER */
- case XYQNXPL: {
- extern int qnxportlock;
- return(seton(&qnxportlock));
- }
- default:
- if ((x = cmcfm()) < 0) return(x);
- printf("Not implemented - %sn",cmdbuf);
- return(success = 0);
- }
- }
- /*
- H U P O K -- Is Hangup OK?
- Issues a warning and gets OK from user depending on whether a connection
- seems to be open and what the SET EXIT WARNING setting is. Returns:
- 0 if not OK to hang up or exit (i.e. user said No);
- nonzero if OK.
- Argument x is used to differentiate the EXIT command from SET LINE / HOST.
- */
- int
- hupok(x) int x; { /* Returns 1 if OK, 0 if not OK */
- int y, z = 1;
- #ifdef VMS
- extern int batch;
- if (batch) /* No warnings in batch */
- return(1);
- #else
- #ifdef UNIX
- if (backgrd) /* No warnings in background */
- return(1);
- #endif /* UNIX */
- #endif /* VMS */
- debug(F101,"hupok local","",local);
- if (!local) /* No warnings in remote mode */
- return(1);
- debug(F101,"hupok x","",x);
- debug(F101,"hupok xitwarn","",xitwarn);
- debug(F101,"hupok network","",network);
- debug(F101,"hupok haveline","",haveline);
- if ((local && xitwarn) || /* Is a connection open? */
- (!x && xitwarn == 2)) { /* Or Always give warning on EXIT */
- int needwarn = 0;
- if (network) {
- if (ttchk() >= 0)
- needwarn = 1;
- /* A connection seems to be open but it can't possibly be */
- if (!haveline)
- needwarn = 0;
- if (needwarn) {
- if (strcmp(ttname,"*"))
- printf(
- " A network connection to %s might still be active.n",
- ttname
- );
- else
- printf(
- " An incoming network connection might still be active.n"
- );
- }
- } else { /* Serial connection */
- if (carrier == CAR_OFF) /* SET CARRIER OFF */
- needwarn = 0; /* so we don't care about carrier. */
- else if ((y = ttgmdm()) >= 0) /* else, get modem signals */
- needwarn = (y & BM_DCD); /* Check for carrier */
- else /* If we can't get modem signals... */
- needwarn = (ttchk() >= 0);
- /* A connection seems to be open but it can't possibly be */
- if (!haveline)
- needwarn = 0;
- if (needwarn)
- printf(
- " A serial connection might still be active on %s.n",
- ttname
- );
- }
- /* If a warning was issued, get user's permission to EXIT. */
- if (needwarn || !x && xitwarn == 2 && local) {
- z = getyesno(x ? "OK to close? " : "OK to exit? ",0);
- debug(F101,"hupok getyesno","",z);
- if (z < -3) z = 0;
- }
- }
- return(z);
- }
- #ifndef NOSHOW
- VOID
- shoctl() { /* SHOW CONTROL-PREFIXING */
- #ifdef CK_SPEED
- int i;
- #ifdef OS2
- int zero;
- #endif /* OS2 */
- printf(
- "ncontrol quote = %d, applied to (0 = unprefixed, 1 = prefixed):nn",
- myctlq);
- #ifdef OS2
- #ifndef UNPREFIXZERO
- zero = ctlp[0];
- if (protocol == PROTO_K) /* Zero can't be unprefixed */
- ctlp[0] = 1; /* for Kermit */
- #endif /* UNPREFIXZERO */
- #endif /* OS2 */
- for (i = 0; i < 16; i++) {
- printf(" %3d: %d %3d: %d ",i,ctlp[i], i+16, ctlp[i+16]);
- if (i == 15)
- printf(" 127: %d",ctlp[127]);
- else
- printf(" ");
- printf(" %3d: %d %3d: %d ",i+128,ctlp[i+128], i+144, ctlp[i+144]);
- if (i == 15) printf(" 255: %d",ctlp[255]);
- printf("n");
- }
- printf("n");
- #ifndef UNPREFIXZERO
- #ifdef OS2
- ctlp[0] = zero;
- #endif /* OS2 */
- #endif /* UNPREFIXZERO */
- #endif /* CK_SPEED */
- }
- #ifndef NOXFER
- VOID
- shodbl() { /* SHOW DOUBLE/IGNORE */
- #ifdef CKXXCHAR
- int i, n = 0;
- printf("nSET SEND DOUBLE characters:n");
- for (i = 0; i < 255; i++) {
- if (dblt[i] & 2) {
- n++;
- printf(" %d", i);
- }
- }
- if (n == 0)
- printf(" (none)");
- n = 0;
- printf("nSET RECEIVE IGNORE characters:n");
- for (i = 0; i < 255; i++) {
- if (dblt[i] & 1) {
- n++;
- printf(" %d", i);
- }
- }
- if (n == 0)
- printf(" (none)");
- printf("nn");
- #endif /* CKXXCHAR */
- }
- #endif /* NOXFER */
- #endif /* NOSHOW */
- #ifndef NOPUSH
- #ifdef CK_REXX
- /*
- Rexx command. Note, this is not OS/2-specific, because Rexx also runs
- on other systems where C-Kermit also runs, like the Amiga.
- */
- #define REXBUFL 100 /* Change this if neccessary */
- char rexxbuf[REXBUFL] = { ' ' }; /* Rexx's return value (string) */
- int
- dorexx() {
- int x, y;
- char *rexxcmd;
- if ((x = cmtxt("Rexx command","",&rexxcmd,xxstring)) < 0)
- return(x);
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- #ifdef CK_APC
- /* Don't let this be set remotely */
- if (apcactive == APC_LOCAL ||
- apcactive == APC_REMOTE && apcstatus != APC_UNCH)
- return(success = 0);
- #endif /* CK_APC */
- strcpy(line,rexxcmd);
- rexxcmd = line;
- #ifdef OS2
- return(os2rexx(rexxcmd,rexxbuf,REXBUFL));
- #else /* !OS2 */
- printf("Sorry, nothing happens.n");
- return(success = 0);
- #endif /* OS2 */
- }
- #endif /* CK_REXX */
- #endif /* NOPUSH */
- #endif /* NOICP */