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