1: #ifndef NOICP 2: 3: /* C K U U S 3 -- "User Interface" for Unix Kermit, part 3 */ 4: 5: /* 6: Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET), 7: Columbia University Center for Computing Activities. 8: First released January 1985. 9: Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New 10: York. Permission is granted to any individual or institution to use this 11: software as long as it is not sold for profit. This copyright notice must be 12: retained. This software may not be included in commercial products without 13: written permission of Columbia University. 14: */ 15: 16: /* SET command (but much material has been split off into ckuus7.c). */ 17: 18: /* 19: Kermit-specific includes. 20: Definitions here supersede those from system include files. 21: */ 22: #include "ckcdeb.h" /* Debugging & compiler things */ 23: #include "ckcasc.h" /* ASCII character symbols */ 24: #include "ckcker.h" /* Kermit application definitions */ 25: #include "ckcxla.h" /* Character set translation */ 26: #include "ckcnet.h" /* Network symbols */ 27: #include "ckuusr.h" /* User interface symbols */ 28: 29: /* Variables */ 30: 31: extern int size, spsiz, spmax, urpsiz, srvtim, 32: local, server, success, 33: flow, binary, delay, parity, escape, what, srvdis, 34: turn, duplex, backgrd, 35: turnch, bctr, mdmtyp, keep, maxtry, unkcs, network, 36: ebqflg, quiet, swcapr, nettype, 37: wslotr, lscapr, lscapu, 38: carrier, debses, 39: cdtimo, nlangs, bgset, pflag, msgflg, dblchar, 40: cmdmsk, spsizr, wildxpand, suspend, 41: techo, terror; 42: 43: extern char *ccntab[]; 44: 45: #ifndef NOSCRIPT 46: extern int secho; /* Whether SCRIPT cmd should echo */ 47: #endif /* NOSCRIPT */ 48: 49: #ifndef NOSPL 50: #ifdef DCMDBUF 51: extern int *count; 52: #else 53: extern int count[]; 54: #endif /* DCMDBUF */ 55: extern int mecho, merror; /* Macro echo, error */ 56: extern int incase; /* INPUT case */ 57: #endif /* NOSPL */ 58: 59: extern int bigsbsiz, bigrbsiz; /* Packet buffers */ 60: 61: extern long speed; /* Terminal speed */ 62: 63: extern CHAR sstate; /* Protocol start state */ 64: extern char ttname[]; /* Communication device name */ 65: #ifndef MAC 66: #ifndef NOSETKEY 67: extern KEY *keymap; /* Character map for SET KEY (1:1) */ 68: extern MACRO *macrotab; /* Macro map for SET KEY (1:string) */ 69: #ifdef OS2 70: int wideresult; /* for SET KEY, wide OS/2 scan codes */ 71: #endif /* OS2 */ 72: #endif /* NOSETKEY */ 73: #endif /* MAC */ 74: 75: #ifndef NOCSETS 76: /* system-independent character sets, defined in ckcxla.[ch] */ 77: extern struct csinfo tcsinfo[]; 78: extern struct langinfo langs[]; 79: 80: /* Other character-set related variables */ 81: extern int tcharset, tslevel, language; 82: #endif /* NOCSETS */ 83: 84: /* Declarations from cmd package */ 85: 86: #ifdef DCMDBUF 87: extern char *cmdbuf; /* Command buffer */ 88: extern char *line; 89: #else 90: extern char cmdbuf[]; /* Command buffer */ 91: extern char line[]; /* Character buffer for anything */ 92: #endif /* DCMDBUF */ 93: 94: /* From main ckuser module... */ 95: 96: extern char tmpbuf[], *tp, *lp; /* Temporary buffer */ 97: 98: extern int tlevel; /* Take Command file level */ 99: 100: #ifndef NOSPL 101: extern int cmdlvl; /* Overall command level */ 102: #endif /* NOSPL */ 103: 104: #ifdef UNIX 105: extern int sessft; /* Session-log file type */ 106: #endif /* UNIX */ 107: 108: 109: #ifdef VMS 110: int vms_msgs = 1; /* SET MESSAGES */ 111: #endif /* VMS */ 112: 113: /* Keyword tables for SET commands */ 114: 115: struct keytab chktab[] = { 116: "1", 1, 0, 117: "2", 2, 0, 118: "3", 3, 0, 119: "blank-free-2", 4, 0 120: }; 121: 122: /* For SET MODEM */ 123: 124: struct keytab autotab[] = { 125: "changes-speed", 1, 0, 126: "matches-speed", 0, 0 127: }; 128: 129: /* For SET CARRIER */ 130: 131: struct keytab crrtab[] = { 132: "auto", CAR_AUT, 0, 133: "off", CAR_OFF, 0, 134: "on", CAR_ON, 0 135: }; 136: int ncrr = 3; 137: 138: /* For SET DEBUG */ 139: 140: struct keytab dbgtab[] = { 141: "off", 0, 0, 142: "on", 1, 0, 143: "session", 2, 0 144: }; 145: int ndbg = 3; 146: 147: /* Transmission speeds */ 148: 149: /* Note, the values are encoded in cps rather than bps because 19200 and */ 150: /* 38400 are too big for some ints. All but 75bps are multiples of ten. */ 151: /* Result of lookup in this table must be multiplied by 10 to get actual */ 152: /* speed in bps. If this number is 70, it must be changed to 75. */ 153: /* If it is 888, this means 75/1200 split speed. 134.5 (IBM 2741) is not */ 154: /* supported, and split speed is not possible in AT&T UNIX. */ 155: 156: /* The values are generic, rather than specific to UNIX. We can't use */ 157: /* B75, B1200, B9600, etc, because non-UNIX versions of C-Kermit will not */ 158: /* necessarily have these symbols defined. */ 159: 160: /* Like all other keytabs, this one must be in "alphabetical" order, */ 161: /* rather than numeric order. */ 162: 163: struct keytab spdtab[] = { 164: "0", 0, CM_INV, 165: "110", 11, 0, 166: #ifdef OS2 167: #ifdef __32BIT__ 168: "115200",11520, 0, 169: #endif /* __32BIT__ */ 170: #endif /* OS2 */ 171: "1200", 120, 0, 172: #ifdef OS2 173: "14400", 1440, 0, 174: #endif /* OS2 */ 175: "150", 15, 0, 176: "19200", 1920, 0, 177: "200", 20, 0, 178: "2400", 240, 0, 179: "300", 30, 0, 180: "3600", 360, 0, 181: "38400", 3840, 0, 182: "4800", 480, 0, 183: "50", 5, 0, 184: #ifdef OS2 185: "57600", 5760, 0, 186: #endif /* OS2 */ 187: "600", 60, 0, 188: #ifdef OS2 189: "7200", 720, 0, 190: #endif /* OS2 */ 191: "75", 7, 0, 192: #ifdef ANYBSD 193: "75/1200",888, 0, /* Special code "888" for split speed */ 194: #endif /* ANYBSD */ 195: #ifdef OS2 196: #ifdef __32BIT__ 197: "76800", 7680, 0, 198: #endif /* __32BIT__ */ 199: #endif /* OS2 */ 200: "9600", 960, 0 201: }; 202: int nspd = (sizeof(spdtab) / sizeof(struct keytab)); /* how many speeds */ 203: 204: #ifndef NOCSETS 205: extern struct keytab lngtab[]; /* Languages for SET LANGUAGE */ 206: extern int nlng; 207: #endif /* NOCSETS */ 208: 209: /* Duplex keyword table */ 210: 211: struct keytab dpxtab[] = { 212: "full", 0, 0, 213: "half", 1, 0 214: }; 215: 216: /* SET FILE parameters */ 217: 218: struct keytab filtab[] = { 219: "bytesize", XYFILS, 0, 220: #ifndef NOCSETS 221: "character-set", XYFILC, 0, 222: #endif /* NOCSETS */ 223: "collision", XYFILX, 0, 224: "display", XYFILD, 0, 225: "incomplete", XYFILI, 0, 226: #ifdef VMS 227: "label", XYFILL, 0, 228: #endif /* VMS */ 229: "names", XYFILN, 0, 230: #ifdef VMS 231: "record-length", XYFILR, 0, 232: #endif /* VMS */ 233: "type", XYFILT, 0, 234: "warning", XYFILW, CM_INV 235: }; 236: int nfilp = (sizeof(filtab) / sizeof(struct keytab)); 237: 238: /* Flow Control */ 239: 240: struct keytab flotab[] = { /* SET FLOW-CONTROL keyword table */ 241: #ifdef CK_DTRCD 242: "dtr/cd", FLO_DTRC, 0, 243: #endif /* CK_DTRCD */ 244: #ifdef CK_DTRCTS 245: "dtr/cts",FLO_DTRT, 0, 246: #endif /* CK_DTRCTS */ 247: "keep", FLO_KEEP, 0, 248: "none", FLO_NONE, 0, 249: #ifdef CK_RTSCTS 250: "rts/cts", FLO_RTSC, 0, 251: #endif /* CK_RTSCTS */ 252: "xon/xoff", FLO_XONX, 0 253: }; 254: int nflo = (sizeof(flotab) / sizeof(struct keytab)); 255: 256: /* Handshake characters */ 257: 258: struct keytab hshtab[] = { 259: "bell", 007, 0, 260: "code", 998, 0, 261: "cr", 015, 0, 262: "esc", 033, 0, 263: "lf", 012, 0, 264: "none", 999, 0, /* (can't use negative numbers) */ 265: "xoff", 023, 0, 266: "xon", 021, 0 267: }; 268: int nhsh = (sizeof(hshtab) / sizeof(struct keytab)); 269: 270: struct keytab fttab[] = { /* File types */ 271: #ifdef VMS 272: "b", XYFT_B, CM_INV|CM_ABR, 273: #endif /* VMS */ 274: "binary", XYFT_B, 0, 275: #ifdef VMS 276: "block", XYFT_I, CM_INV, 277: "image", XYFT_I, 0, 278: "labeled", XYFT_L, 0, 279: #endif /* VMS */ 280: "text", XYFT_T, 0 281: }; 282: int nfttyp = (sizeof(fttab) / sizeof(struct keytab)); 283: 284: #ifndef NODIAL 285: extern struct keytab mdmtab[] ; /* Modem types (in module ckudia.c) */ 286: extern int nmdm; /* Number of them */ 287: #ifndef MINIDIAL 288: extern int tbmodel; /* Telebit model ID */ 289: #endif /* MINIDIAL */ 290: #endif /* NODIAL */ 291: 292: #ifdef UNIX 293: struct keytab wildtab[] = { /* SET WILDCARD-EXPANSION */ 294: "kermit", 0, 0, 295: "shell", 1, 0 296: }; 297: #endif /* UNIX */ 298: 299: #ifdef NETCONN 300: extern struct keytab netcmd[]; 301: extern int nnets; 302: #endif /* NETCONN */ 303: 304: #ifdef SUNX25 305: struct keytab x25tab[] = { 306: "call-user-data", XYUDAT, 0, 307: "closed-user-group", XYCLOS, 0, 308: "reverse-charge", XYREVC, 0 309: }; 310: int nx25 = (sizeof(x25tab) / sizeof(struct keytab)); 311: 312: struct keytab padx3tab[] = { 313: "break-action", PAD_BREAK_ACTION, 0, 314: "break-character", PAD_BREAK_CHARACTER, 0, 315: "character-delete", PAD_CHAR_DELETE_CHAR, 0, 316: "cr-padding", PAD_PADDING_AFTER_CR, 0, 317: "discard-output", PAD_SUPPRESSION_OF_DATA, 0, 318: "echo", PAD_ECHO, 0, 319: "editing", PAD_EDITING, 0, 320: "escape", PAD_ESCAPE, 0, 321: "forward", PAD_DATA_FORWARD_CHAR, 0, 322: "lf-padding", PAD_PADDING_AFTER_LF, 0, 323: "lf-insert", PAD_LF_AFTER_CR, 0, 324: "line-delete", PAD_BUFFER_DELETE_CHAR, 0, 325: "line-display", PAD_BUFFER_DISPLAY_CHAR, 0, 326: "line-fold", PAD_LINE_FOLDING, 0, 327: "pad-flow-control", PAD_FLOW_CONTROL_BY_PAD, 0, 328: "service-signals", PAD_SUPPRESSION_OF_SIGNALS, 0, 329: "timeout", PAD_DATA_FORWARD_TIMEOUT, 0, 330: /* Speed is read-only */ 331: "transmission-rate", PAD_LINE_SPEED, 0, 332: "user-flow-control", PAD_FLOW_CONTROL_BY_USER, 0 333: }; 334: int npadx3 = (sizeof(padx3tab) / sizeof(struct keytab)); 335: #endif /* SUNX25 */ 336: 337: /* Parity keyword table */ 338: 339: struct keytab partab[] = { 340: "even", 'e', 0, 341: "mark", 'm', 0, 342: "none", 0 , 0, 343: "odd", 'o', 0, 344: "space", 's', 0 345: }; 346: int npar = (sizeof(partab) / sizeof(struct keytab)); 347: 348: /* On/Off table */ 349: 350: struct keytab onoff[] = { 351: "off", 0, 0, 352: "on", 1, 0 353: }; 354: 355: struct keytab rltab[] = { 356: "local", 1, 0, 357: "off", 0, CM_INV, 358: "on", 1, CM_INV, 359: "remote", 0, 0 360: }; 361: int nrlt = (sizeof(rltab) / sizeof(struct keytab)); 362: 363: /* Incomplete File Disposition table */ 364: static 365: struct keytab ifdtab[] = { 366: "discard", 0, 0, 367: "keep", 1, 0 368: }; 369: 370: /* SET TAKE parameters table */ 371: static 372: struct keytab taktab[] = { 373: "echo", 0, 0, 374: "error", 1, 0, 375: "off", 2, CM_INV, /* For compatibility */ 376: "on", 3, CM_INV /* with MS-DOS Kermit... */ 377: }; 378: 379: /* SET MACRO parameters table */ 380: static 381: struct keytab smactab[] = { 382: "echo", 0, 0, 383: "error", 1, 0 384: }; 385: 386: #ifndef NOSCRIPT 387: static 388: struct keytab scrtab[] = { 389: "echo", 0, 0 390: }; 391: #endif /* NOSCRIPT */ 392: 393: /* Bytesize table */ 394: struct keytab byttab[] = { 395: "bytesize", 0, 0 396: }; 397: int nbytt = 1; 398: 399: #ifndef NOSERVER 400: /* Server parameters table */ 401: struct keytab srvtab[] = { 402: "display", XYSERD, 0, 403: "timeout", XYSERT, 0 404: }; 405: #endif /* NOSERVER */ 406: 407: /* SET TRANSFER/XFER table */ 408: 409: struct keytab tstab[] = { 410: #ifndef NOCSETS 411: "character-set", 1, 0, 412: #endif /* NOCSETS */ 413: "locking-shift", 2, 0 414: }; 415: int nts = (sizeof(tstab) / sizeof(struct keytab)); 416: 417: #ifndef NOCSETS 418: /* SET TRANSFER CHARACTER-SET table */ 419: 420: extern struct keytab tcstab[]; 421: extern int ntcs; 422: #endif /* NOCSETS */ 423: 424: /* SET TRANSFER LOCKING-SHIFT table */ 425: struct keytab lstab[] = { 426: "forced", 2, 0, 427: "off", 0, 0, 428: "on", 1, 0 429: }; 430: int nls = (sizeof(lstab) / sizeof(struct keytab)); 431: 432: /* SET TELNET table */ 433: #ifdef TNCODE 434: extern int tn_duplex, tn_nlm; 435: extern char *tn_term; 436: struct keytab tntab[] = { 437: "echo", CK_TN_EC, 0, 438: "newline-mode", CK_TN_NL, 0, 439: "terminal-type", CK_TN_TT, 0 440: }; 441: int ntn = (sizeof(tntab) / sizeof(struct keytab)); 442: #endif /* TNCODE */ 443: 444: struct keytab ftrtab[] = { /* Feature table */ 445: #ifndef NOCSETS /* 0 = we have it, 1 = we don't */ 446: "character-sets", 0, 0, 447: #else 448: "character-sets", 1, 0, 449: #endif /* NOCSETS */ 450: #ifndef NOCYRIL 451: "cyrillic", 0, 0, 452: #else 453: "cyrillic", 1, 0, 454: #endif /* NOCYRIL */ 455: 456: #ifndef NODEBUG 457: "debug", 0, 0, 458: #else 459: "debug", 1, 0, 460: #endif /* NODEBUG */ 461: 462: #ifndef NODIAL 463: "dial", 0, 0, 464: #else 465: "dial", 1, 0, 466: #endif /* NODIAL */ 467: 468: #ifdef DYNAMIC 469: "dynamic-memory", 0, 0, 470: #else 471: "dynamic-memory", 1, 0, 472: #endif /* DYNAMIC */ 473: 474: #ifdef CK_CURSES 475: "fullscreen-display", 0, 0, 476: #else 477: "fullscreen-display", 1, 0, 478: #endif /* CK_CURSES */ 479: #ifndef NOHELP 480: "help", 0, 0, 481: #else 482: "help", 1, 0, 483: #endif /* NOHELP */ 484: #ifndef NOSPL 485: "if-command", 0, 0, 486: #else 487: "if-command", 1, 0, 488: #endif /* NOSPL */ 489: #ifndef NOJC 490: #ifdef UNIX 491: "job-control", 0, 0, 492: #else 493: "job-control", 1, 0, 494: #endif /* UNIX */ 495: #else 496: "job-control", 1, 0, 497: #endif /* NOJC */ 498: #ifdef KANJI 499: "kanji", 0, 0, 500: #else 501: "kanji", 1, 0, 502: #endif /* KANJI */ 503: #ifndef NOCSETS 504: "latin1", 0, 0, 505: #else 506: "latin1", 1, 0, 507: #endif /* NOCSETS */ 508: #ifdef LATIN2 509: "latin2", 0, 0, 510: #else 511: "latin2", 1, 0, 512: #endif /* LATIN2 */ 513: #ifdef NETCONN 514: "network", 0, 0, 515: #else 516: "network", 1, 0, 517: #endif /* NETCONN */ 518: #ifndef NOPUSH 519: "push", 0, 0, 520: #else 521: "push", 1, 0, 522: #endif /* PUSH */ 523: #ifndef NOSCRIPT 524: "script-command", 0, 0, 525: #else 526: "script-command", 1, 0, 527: #endif /* NOSCRIPT */ 528: #ifndef NOSERVER 529: "server-mode", 0, 0, 530: #else 531: "server-mode", 1, 0, 532: #endif /* NOSERVER */ 533: #ifndef NOSHOW 534: "show-command", 0, 0, 535: #else 536: "show-command", 1, 0, 537: #endif /* NOSHOW */ 538: #ifndef NOXMIT 539: "transmit", 0, 0, 540: #else 541: "transmit", 1, 0 542: #endif /* NOXMIT */ 543: }; 544: int nftr = (sizeof(ftrtab) / sizeof(struct keytab)); 545: 546: int /* CHECK command */ 547: dochk() { 548: int x, y; 549: if ((y = cmkey(ftrtab,nftr,"","",xxstring)) < 0) return(y); 550: if ((x = cmcfm()) < 0) return(x); 551: if (msgflg) /* If at top level... */ 552: printf(" %svailable\n", y ? "Not a" : "A"); /* Print a message */ 553: else if (y && !backgrd) /* Or if not available and in */ 554: printf(" CHECK: feature not available\n"); /* command file or macro */ 555: return(success = 1 - y); 556: } 557: 558: #ifndef MAC 559: #ifndef NOSETKEY 560: int 561: set_key() { /* SET KEY */ 562: int y; 563: int kc; /* Key code */ 564: char *bind; /* Key binding */ 565: 566: if ((y = cmnum("numeric key code","",10,&kc,xxstring)) < 0) 567: return(y); 568: if (kc < 0 || kc >= KMSIZE) { 569: printf("?key code must be between 0 and %d\n", KMSIZE - 1); 570: return(-9); 571: } 572: #ifdef OS2 573: wideresult = -1; 574: #endif /* OS2 */ 575: if ((y = cmtxt("key definition","",&bind,xxstring)) < 0) 576: return(y); 577: if (macrotab[kc]) { /* Possibly free old macro from key */ 578: free(macrotab[kc]); 579: macrotab[kc] = NULL; 580: } 581: switch (strlen(bind)) { /* Action depends on length */ 582: #ifdef OS2 583: case 0: /* Reset to default binding */ 584: keymap[kc] = wideresult == -1 ? kc : 0; /* or bind to NUL */ 585: break; 586: case 1: /* Single character */ 587: keymap[kc] = wideresult == -1 ? (CHAR) *bind : wideresult; 588: break; 589: #else /* Not OS/2 */ 590: case 0: /* Reset to default binding */ 591: keymap[kc] = kc; 592: break; 593: case 1: /* Single character */ 594: keymap[kc] = (CHAR) *bind; 595: break; 596: #endif /* OS2 */ 597: 598: default: /* Character string */ 599: keymap[kc] = kc; 600: macrotab[kc] = (MACRO) malloc(strlen(bind)+1); 601: if (macrotab[kc]) 602: strcpy((char *) macrotab[kc], bind); 603: break; 604: } 605: return(1); 606: } 607: #endif /* NOSETKEY */ 608: #endif /* MAC */ 609: 610: /* D O P R M -- Set a parameter. */ 611: /* 612: Returns: 613: -2: illegal input 614: -1: reparse needed 615: 0: success 616: */ 617: int 618: doprm(xx,rmsflg) int xx, rmsflg; { 619: int i, x, y = 0, z; 620: long zz; 621: char *s; 622: 623: switch (xx) { 624: 625: #ifdef SUNX25 /* SET X25 ... */ 626: case XYX25: 627: return(setx25()); 628: 629: case XYPAD: /* SET PAD ... */ 630: return(setpadp()); 631: #endif /* SUNX25 */ 632: 633: case XYEOL: /* These have all been moved to set send/receive... */ 634: case XYLEN: /* Let the user know what to do. */ 635: case XYMARK: 636: case XYNPAD: 637: case XYPADC: 638: case XYTIMO: 639: printf("...Use SET SEND or SET RECEIVE instead.\n"); 640: printf("Type HELP SET SEND or HELP SET RECEIVE for more info.\n"); 641: return(success = 0); 642: 643: case XYATTR: /* File Attribute packets */ 644: return(setat(rmsflg)); 645: 646: case XYIFD: /* Incomplete file disposition */ 647: if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y); 648: if ((x = cmcfm()) < 0) return(x); 649: if (rmsflg) { 650: sstate = setgen('S', "310", y ? "1" : "0", ""); 651: return((int) sstate); 652: } else { 653: keep = y; 654: return(success = 1); 655: } 656: 657: #ifndef NOSPL 658: case XYINPU: /* SET INPUT */ 659: return(setinp()); 660: #endif /* NOSPL */ 661: 662: #ifdef NETCONN 663: case XYNET: /* SET NETWORK */ 664: if ((z = cmkey(netcmd,nnets,"","tcp/ip",xxstring)) < 0) 665: return(z); 666: if ((x = cmcfm()) < 0) return(x); 667: nettype = z; 668: if ( 669: (nettype != NET_DEC) && 670: (nettype != NET_SX25) && 671: (nettype != NET_TCPB)) { 672: printf("?Network type not supported\n"); 673: return(success = 0); 674: } else { 675: return(success = 1); 676: } 677: #endif /* NETCONN */ 678: 679: case XYHOST: /* SET HOST or SET LINE */ 680: case XYLINE: 681: return(setlin(xx,1)); 682: 683: #ifndef MAC 684: #ifndef NOSETKEY 685: case XYKEY: /* SET KEY */ 686: return(set_key()); 687: #endif /* NOSETKEY */ 688: #endif /* MAC */ 689: 690: #ifndef NOCSETS 691: case XYLANG: /* Language */ 692: if ((y = cmkey(lngtab,nlng,"","none",xxstring)) < 0) /* language code */ 693: return(y); 694: if ((x = cmcfm()) < 0) return(x); /* And confirmation of command */ 695: 696: /* Look up language and get associated character sets */ 697: for (i = 0; (i < nlangs) && (langs[i].id != y); i++) ; 698: if (i >= nlangs) { 699: printf("?internal error, sorry\n"); 700: return(success = 0); 701: } 702: language = i; /* All good, set the language, */ 703: return(success = 1); 704: #endif /* NOCSETS */ 705: 706: #ifndef MAC 707: case XYBACK: /* BACKGROUND */ 708: if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z); 709: if ((y = cmcfm()) < 0) return(y); 710: bgset = z; 711: success = 1; 712: bgchk(); 713: return(success); 714: #endif /* MAC */ 715: 716: case XYQUIE: /* QUIET */ 717: return(success = seton(&quiet)); 718: 719: case XYBUF: { /* BUFFERS */ 720: #ifdef DYNAMIC 721: int sb, rb; 722: if ((y = cmnum("send buffer size","",10,&sb,xxstring)) < 0) { 723: if (y == -3) printf("?two numbers required\n"); 724: return(y); 725: } 726: if (sb < 80) { 727: printf("?too small"); 728: return(-2); 729: } 730: if ((y = cmnum("receive buffer size","",10,&rb,xxstring)) < 0) { 731: if (y == -3) printf("?receive buffer size required\n"); 732: return(y); 733: } 734: if (rb < 80) { 735: printf("?too small"); 736: return(-2); 737: } 738: if ((y = cmcfm()) < 0) return(y); 739: if ((y = inibufs(sb,rb)) < 0) return(y); 740: y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet sizes */ 741: if (y != urpsiz) urpsiz = y; 742: y = adjpkl(spsiz,wslotr,bigsbsiz); 743: if (y != spsiz) spsiz = spmax = spsizr = y; 744: return(success = 1); 745: #else 746: printf("?Sorry, not available\n"); 747: return(success = 0); 748: #endif /* DYNAMIC */ 749: } 750: 751: case XYCHKT: /* BLOCK-CHECK */ 752: if ((x = cmkey(chktab,4,"","1",xxstring)) < 0) return(x); 753: if ((y = cmcfm()) < 0) return(y); 754: bctr = x; /* Set locally too, even if REMOTE SET */ 755: if (rmsflg) { 756: if (x == 4) { 757: tmpbuf[0] = 'B'; 758: tmpbuf[1] = '\0'; 759: } else sprintf(tmpbuf,"%d",x); 760: sstate = setgen('S', "400", tmpbuf, ""); 761: return((int) sstate); 762: } else { 763: return(success = 1); 764: } 765: 766: #ifndef MAC 767: /* 768: The Mac has no carrier... 769: */ 770: case XYCARR: /* CARRIER */ 771: if ((y = cmkey(crrtab,ncrr,"","auto",xxstring)) < 0) return(y); 772: if (y == CAR_ON) { 773: x = cmnum("Carrier wait timeout, seconds","0",10,&z,xxstring); 774: if (x < 0) return(z); 775: } 776: if ((x = cmcfm()) < 0) return(x); 777: carrier = ttscarr(y); 778: cdtimo = z; 779: return(success = 1); 780: #endif /* MAC */ 781: 782: #ifdef TNCODE 783: case XYTEL: /* TELNET */ 784: if ((z = cmkey(tntab,ntn,"parameter for TELNET negotiations", "", 785: xxstring)) < 0) return(z); 786: switch (z) { 787: case CK_TN_EC: /* ECHO */ 788: if ((x = cmkey(rltab,nrlt, 789: "initial TELNET echoing state","local",xxstring)) < 0) 790: return(x); 791: if ((y = cmcfm()) < 0) return(y); 792: tn_duplex = x; 793: return(success = 1); 794: 795: case CK_TN_TT: /* TERMINAL TYPE */ 796: if ((y = cmtxt("terminal type for TELNET connections","", 797: &s,xxstring)) < 0) 798: return(y); 799: if (tn_term) free(tn_term); /* Free any previous storage */ 800: if (s == NULL || *s == NUL) { /* If none given */ 801: tn_term = NULL; /* remove the override string */ 802: return(success = 1); 803: } else if (tn_term = malloc(strlen(s)+1)) { /* Make storage for new */ 804: strcpy(tn_term,s); /* Copy string into new storage */ 805: return(success = 1); 806: } else return(success = 0); 807: 808: case CK_TN_NL: /* NEWLINE-MODE */ 809: return(success = seton(&tn_nlm)); 810: 811: default: 812: return(-2); 813: } 814: #endif /* TNCODE */ 815: 816: default: 817: break; 818: } 819: 820: switch (xx) { 821: #ifndef NOSPL 822: case XYCOUN: /* SET COUNT */ 823: x = cmnum("Positive number","0",10,&z,xxstring); 824: if (x < 0) return(x); 825: if ((x = cmcfm()) < 0) return(x); 826: if (z < 0) { 827: printf("?A positive number, please\n"); 828: return(0); 829: } 830: debug(F101,"XYCOUN: z","",z); 831: return(success = setnum(&count[cmdlvl],z,0,10000)); 832: #endif /* NOSPL */ 833: 834: #ifndef NOSPL 835: case XYCASE: 836: return(success = seton(&incase)); 837: #endif /* NOSPL */ 838: 839: case XYCMD: /* COMMAND ... */ 840: if ((y = cmkey(byttab,nbytt,"","bytesize",xxstring)) < 0) return(y); 841: if ((y = cmnum("bytesize for command characters, 7 or 8","7",10,&x, 842: xxstring)) < 0) 843: return(y); 844: if (x != 7 && x != 8) { 845: printf("\n?The choices are 7 and 8\n"); 846: return(success = 0); 847: } 848: if ((y = cmcfm()) < 0) return(y); 849: if (x == 7) cmdmsk = 0177; 850: else if (x == 8) cmdmsk = 0377; 851: return(success = 1); 852: 853: case XYDFLT: /* SET DEFAULT = CD */ 854: return(success = docd()); 855: 856: case XYDEBU: /* SET DEBUG { on, off, session } */ 857: if ((y = cmkey(dbgtab,ndbg,"","",xxstring)) < 0) return(y); 858: if ((x = cmcfm()) < 0) return(x); 859: switch (y) { 860: case 0: /* 0 = all debugging off. */ 861: debses = 0; 862: #ifdef DEBUG 863: if (deblog) doclslog(LOGD); 864: #endif /* DEBUG */ 865: return(success = 1); 866: 867: case 1: /* 1 = log debugging to debug.log */ 868: #ifdef DEBUG 869: deblog = debopn("debug.log", 0); 870: return(success = deblog ? 1 : 0); 871: #else 872: printf("?Sorry, debug log feature not enabled\n"); 873: return(success = 0); 874: #endif /* DEBUG */ 875: 876: case 2: /* 2 = session. */ 877: return(success = debses = 1); 878: } 879: 880: case XYDELA: /* SET DELAY */ 881: y = cmnum("Number of seconds before starting to send","5",10,&x,xxstring); 882: if (x < 0) x = 0; 883: return(success = setnum(&delay,x,y,999)); 884: 885: default: 886: break; 887: } 888: 889: switch (xx) { 890: 891: #ifndef NODIAL 892: case XYDIAL: /* SET DIAL */ 893: return(setdial()); 894: #endif /* NODIAL */ 895: 896: #ifdef COMMENT /* Unused at present */ 897: case XYDOUB: 898: if ((x = cmfld("Character to double","none",&s,xxstring)) < 0) { 899: if (x == -3) { 900: dblchar = -1; 901: if (msgflg) printf("Doubling Off\n"); 902: return(success = 1); 903: } else return(x); 904: } 905: strcpy(line,s); 906: lp = line; 907: if ((x = cmcfm()) < 0) return(x); 908: if (!xxstrcmp(lp,"none",4)) { 909: dblchar = -1; 910: if (msgflg) printf("Doubling Off\n"); 911: return(success = 1); 912: } 913: if ((int)strlen(lp) != 1) return(-2); 914: dblchar = *lp & 0xFF; 915: if (msgflg) printf("Doubled: %d\n",dblchar); 916: return(success = 1); 917: #endif /* COMMENT */ 918: 919: case XYDUPL: /* SET DUPLEX */ 920: if ((y = cmkey(dpxtab,2,"","full",xxstring)) < 0) return(y); 921: if ((x = cmcfm()) < 0) return(x); 922: duplex = y; 923: return(success = 1); 924: 925: case XYLCLE: /* LOCAL-ECHO (= DUPLEX) */ 926: return(success = seton(&duplex)); 927: 928: case XYESC: /* SET ESCAPE */ 929: sprintf(tmpbuf,"%d",DFESC); 930: y = cmnum("Decimal ASCII code for CONNECT-mode escape character", 931: tmpbuf, 10,&x,xxstring); 932: success = setcc(&escape,x,y); 933: #ifdef COMMENT 934: /* This is what SHOW ESCAPE is for. */ 935: if (success && msgflg) 936: printf(" CONNECT-mode escape character: %d (Ctrl-%c, %s)\n", 937: escape,ctl(escape),(escape == 127 ? "DEL" : ccntab[escape])); 938: #endif /* COMMENT */ 939: return(success); 940: 941: default: 942: break; 943: } 944: 945: switch (xx) { 946: case XYFILE: /* SET FILE */ 947: return(setfil(rmsflg)); 948: 949: case XYFLOW: /* FLOW-CONTROL */ 950: /* 951: Note: flotab[] keyword table (defined above) only includes the legal 952: flow-control options for each implementation, controlled by symbols 953: defined in ckcdeb.h. 954: */ 955: if ((y = cmkey(flotab,nflo,"","xon/xoff",xxstring)) < 0) return(y); 956: if ((x = cmcfm()) < 0) return(x); 957: flow = y; 958: debug(F101,"set flow","",flow); 959: return(success = 1); 960: 961: case XYHAND: /* HANDSHAKE */ 962: if ((y = cmkey(hshtab,nhsh,"","none",xxstring)) < 0) return(y); 963: if (y == 998) { 964: if ((x = cmnum("ASCII value","",10,&y,xxstring)) < 0) 965: return(x); 966: if ((y < 1) || ((y > 31) && (y != 127))) { 967: printf("?Character must be in ASCII control range\n"); 968: return(-9); 969: } 970: } 971: if ((x = cmcfm()) < 0) return(x); 972: turn = (y > 0127) ? 0 : 1 ; 973: turnch = y; 974: return(success = 1); 975: 976: #ifndef NOSPL 977: case XYMACR: /* SET MACRO */ 978: if ((y = cmkey(smactab,2,"","",xxstring)) < 0) return(y); 979: switch (y) { 980: case 0: return(success = seton(&mecho)); 981: case 1: return(success = seton(&merror)); 982: default: return(-2); 983: } 984: #endif /* NOSPL */ 985: 986: #ifndef NODIAL 987: case XYMODM: /* SET MODEM */ 988: if ((x = cmkey(mdmtab,nmdm,"type of modem","none", xxstring)) < 0) 989: return(x); 990: if ((z = cmcfm()) < 0) return(z); 991: mdmtyp = x; 992: #ifndef MINIDIAL 993: tbmodel = 0; /* If it's a Telebit, we don't know the model yet */ 994: #endif /* MINIDIAL */ 995: return(success = 1); 996: #endif /* NODIAL */ 997: 998: case XYMSGS: 999: #ifdef VMS 1000: if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z); 1001: if ((y = cmcfm()) < 0) return(y); 1002: vms_msgs = z; 1003: printf("Sorry, SET MESSAGES not implemented yet\n"); 1004: return(success = 0); 1005: #endif /* VMS */ 1006: default: 1007: break; 1008: } 1009: 1010: switch (xx) { 1011: 1012: case XYPARI: /* PARITY */ 1013: if ((y = cmkey(partab,npar,"","none",xxstring)) < 0) return(y); 1014: if ((x = cmcfm()) < 0) return(x); 1015: 1016: /* If parity not none, then we also want 8th-bit prefixing */ 1017: 1018: if (parity = y) ebqflg = 1; else ebqflg = 0; 1019: return(success = 1); 1020: 1021: #ifndef NOFRILLS 1022: case XYPROM: /* SET PROMPT */ 1023: /* 1024: Note: xxstring not invoked here. Instead, it is invoked every time the 1025: prompt is issued. This allows the prompt string to contain variables 1026: that can change, like \v(dir), \v(time), etc. 1027: */ 1028: #ifdef MAC 1029: if ((x = cmtxt("Program's command prompt","Mac-Kermit>",&s,NULL)) < 0) 1030: #else 1031: if ((x = cmtxt("Program's command prompt","C-Kermit>",&s,NULL)) < 0) 1032: #endif /* MAC */ 1033: return(x); 1034: if (*s == '{') { /* Remove enclosing braces, if any */ 1035: x = (int)strlen(s); 1036: if (s[x-1] == '}') { 1037: s[x-1] = NUL; 1038: s++; 1039: } 1040: } 1041: #ifdef COMMENT 1042: /* 1043: Let's not do this any more -- we don't do it anywhere else. 1044: */ 1045: else if (*s == '"') { /* For compatibility with pre-5A */ 1046: x = (int)strlen(s); 1047: if (s[x-1] == '"') { 1048: s[x-1] = NUL; 1049: s++; 1050: } 1051: } 1052: #endif /* COMMENT */ 1053: cmsetp(s); /* Set the prompt */ 1054: return(success = 1); 1055: #endif /* NOFRILLS */ 1056: 1057: case XYRETR: /* RETRY: per-packet retry limit */ 1058: y = cmnum("Maximum retries per packet","10",10,&x,xxstring); 1059: if (x < 0) x = 0; 1060: if ((x = setnum(&maxtry,x,y,999)) < 0) return(x); 1061: if (maxtry <= wslotr) { 1062: printf("?Retry limit must be greater than window size\n"); 1063: return(success = 0); 1064: } 1065: sprintf(tmpbuf,"%d",maxtry); 1066: if (rmsflg) { 1067: sstate = setgen('S', "403", tmpbuf, ""); 1068: return((int) sstate); 1069: } else return(success = x); 1070: 1071: #ifndef NOSERVER 1072: case XYSERV: /* SET SERVER items */ 1073: if ((y = cmkey(srvtab,2,"","",xxstring)) < 0) return(y); 1074: switch (y) { 1075: case XYSERT: 1076: tp = tmpbuf; 1077: sprintf(tp,"%d",DSRVTIM); 1078: if ((y = cmnum("interval for server NAKs, 0 = none",tp,10,&x, 1079: xxstring)) < 0) 1080: return(y); 1081: if (x < 0) { 1082: printf("\n?Specify a positive number, or 0 for no server NAKs\n"); 1083: return(0); 1084: } 1085: if ((y = cmcfm()) < 0) return(y); 1086: sprintf(tp,"%d",x); 1087: if (rmsflg) { 1088: sstate = setgen('S', "404", tp, ""); 1089: return((int) sstate); 1090: } else { 1091: srvtim = x; /* Set the server timeout variable */ 1092: return(success = 1); 1093: } 1094: case XYSERD: /* SERVER DISPLAY */ 1095: return(success = seton(&srvdis)); /* ON or OFF... */ 1096: default: 1097: return(-2); 1098: } 1099: #endif /* NOSERVER */ 1100: 1101: #ifdef UNIX 1102: #ifndef NOJC 1103: case XYSUSP: /* SET SUSPEND */ 1104: seton(&suspend); /* on or off... */ 1105: return(success = 1); 1106: #endif /* NOJC */ 1107: #endif /* UNIX */ 1108: 1109: case XYTAKE: /* SET TAKE */ 1110: if ((y = cmkey(taktab,4,"","",xxstring)) < 0) return(y); 1111: switch (y) { 1112: case 0: return(success = seton(&techo)); 1113: case 1: return(success = seton(&terror)); 1114: case 2: techo = 0; return(success = 1); /* For compatibility with */ 1115: case 3: techo = 1; return(success = 1); /* MS-DOS Kermit */ 1116: default: return(-2); 1117: } 1118: 1119: #ifndef NOSCRIPT 1120: case XYSCRI: /* SET SCRIPT */ 1121: if ((y = cmkey(scrtab,1,"","echo",xxstring)) < 0) return(y); 1122: switch (y) { 1123: case 0: return(success = seton(&secho)); 1124: default: return(-2); 1125: } 1126: #endif /* NOSCRIPT */ 1127: 1128: default: 1129: break; 1130: } 1131: 1132: switch (xx) { 1133: case XYTERM: /* SET TERMINAL */ 1134: return(settrm()); 1135: 1136: default: 1137: break; 1138: } 1139: 1140: switch (xx) { 1141: 1142: /* SET SEND/RECEIVE protocol parameters. */ 1143: 1144: case XYRECV: 1145: case XYSEND: 1146: return(setsr(xx,rmsflg)); 1147: 1148: #ifdef UNIX 1149: case XYSESS: /* SESSION-LOG */ 1150: if ((x = cmkey(fttab,2,"type of file","text",xxstring)) < 0) 1151: return(x); 1152: if ((y = cmcfm()) < 0) return(y); 1153: sessft = x; 1154: return(success = 1); 1155: #endif /* UNIX */ 1156: 1157: case XYSPEE: /* SET SPEED */ 1158: if (network) { 1159: printf("\n?Speed cannot be set for network connections\n"); 1160: return(success = 0); 1161: } 1162: lp = line; 1163: sprintf(lp,"Transmission rate for %s in bits per second",ttname); 1164: 1165: if ((x = cmkey(spdtab,nspd,line,"",xxstring)) < 0) { 1166: if (x == -3) printf("?value required\n"); 1167: return(x); 1168: } 1169: if ((y = cmcfm()) < 0) return(y); 1170: if (!local) { 1171: printf("?Sorry, you must SET LINE first\n"); 1172: return(success = 0); 1173: } 1174: zz = (long) x * 10L; 1175: if (zz == 70) zz = 75; /* (see spdtab[] def) */ 1176: if (ttsspd(x) < 0) { /* Call ttsspd with cps, not bps! */ 1177: printf("?Unsupported line speed - %ld\n",zz); 1178: return(success = 0); 1179: } else { 1180: speed = zz; 1181: if (pflag && 1182: #ifndef NOSPL 1183: cmdlvl == 0 1184: #else 1185: tlevel < 0 1186: #endif /* NOSPL */ 1187: ) { 1188: if (speed == 8880) 1189: printf("%s, 75/1200 bps\n",ttname); 1190: else 1191: printf("%s, %ld bps\n",ttname,speed); 1192: } 1193: return(success = 1); 1194: } 1195: 1196: case XYXFER: /* SET TRANSFER */ 1197: if ((y = cmkey(tstab,nts,"","character-set",xxstring)) < 0) return(y); 1198: #ifndef NOCSETS 1199: if (y == 1) { /* character-set */ 1200: if ((y = cmkey(tcstab,ntcs,"","transparent",xxstring)) < 0) return(y); 1201: if ((x = cmcfm()) < 0) return(x); 1202: if (rmsflg) { 1203: sstate = setgen('S', "405", tcsinfo[y].designator, ""); 1204: return((int) sstate); 1205: } else { 1206: tslevel = (y == TC_TRANSP) ? 0 : 1; /* transfer syntax level */ 1207: tcharset = y; /* transfer character set */ 1208: return(success = 1); 1209: } 1210: } else 1211: #endif /* NOCSETS */ 1212: if (y == 2) { /* LOCKING-SHIFT options */ 1213: if ((y = cmkey(lstab,nls,"","on",xxstring)) < 0) 1214: return(y); 1215: if ((x = cmcfm()) < 0) return(x); 1216: lscapr = (y == 1) ? 1 : 0; /* ON: requested = 1 */ 1217: lscapu = (y == 2) ? 2 : 0; /* FORCED: used = 1 */ 1218: return(success = 1); 1219: } else return(-2); 1220: 1221: #ifndef NOXMIT 1222: case XYXMIT: /* SET TRANSMIT */ 1223: return(setxmit()); 1224: #endif /* NOXMIT */ 1225: 1226: #ifndef NOCSETS 1227: case XYUNCS: /* UNKNOWN-CHARACTER-SET */ 1228: if ((y = cmkey(ifdtab,2,"","discard",xxstring)) < 0) return(y); 1229: if ((x = cmcfm()) < 0) return(x); 1230: unkcs = y; 1231: return(success = 1); 1232: #endif /* NOCSETS */ 1233: 1234: #ifdef UNIX 1235: case XYWILD: /* WILDCARD-EXPANSION */ 1236: if ((y = cmkey(wildtab,2,"who expands wildcards","kermit",xxstring)) < 0) 1237: return(y); 1238: if ((x = cmcfm()) < 0) return(x); 1239: wildxpand = y; 1240: return(success = 1); 1241: #endif /* UNIX */ 1242: 1243: case XYWIND: /* WINDOW-SLOTS */ 1244: y = cmnum("Number of sliding-window slots, 1 to 31","1",10,&x,xxstring); 1245: y = setnum(&z,x,y,31); 1246: if (y < 0) return(y); 1247: if (z < 1) z = 1; 1248: #ifdef COMMENT 1249: /* This is unreasonable */ 1250: if (maxtry < z) { 1251: printf("?Window slots must be less than retry limit\n"); 1252: return(success = 0); 1253: } 1254: #endif /* COMMENT */ 1255: if (rmsflg) { /* Set remote window size */ 1256: tp = tmpbuf; 1257: sprintf(tp,"%d",z); 1258: sstate = setgen('S', "406", tp, ""); 1259: return((int) sstate); 1260: } 1261: wslotr = z; /* Set local window size */ 1262: swcapr = (wslotr > 1) ? 1 : 0; /* Set window bit in capas word? */ 1263: if (wslotr > 1) { /* Window size > 1? */ 1264: y = adjpkl(urpsiz,wslotr,bigrbsiz); /* Maybe adjust packet size */ 1265: if (y != urpsiz) { /* Did it change? */ 1266: urpsiz = y; 1267: if (msgflg) 1268: printf( 1269: " Adjusting receive packet-length to %d for %d window slots\n", 1270: urpsiz, wslotr); 1271: } 1272: } 1273: return(success = 1); 1274: 1275: default: 1276: if ((x = cmcfm()) < 0) return(x); 1277: printf("Not working yet - %s\n",cmdbuf); 1278: return(success = 0); 1279: } 1280: } 1281: #endif /* NOICP */