|
|
1.1 root 1: #ifndef NOICP
2:
3: /* C K U U S 7 -- "User Interface" for Unix Kermit, part 7 */
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 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: /*
17: This file created from parts of ckuus3.c, which became to big for
18: Mark Williams Coherent compiler to handle.
19: */
20:
21: /*
22: Definitions here supersede those from system include files.
23: */
24: #include "ckcdeb.h" /* Debugging & compiler things */
25: #include "ckcasc.h" /* ASCII character symbols */
26: #include "ckcker.h" /* Kermit application definitions */
27: #include "ckcxla.h" /* Character set translation */
28: #include "ckcnet.h" /* Network symbols */
29: #include "ckuusr.h" /* User interface symbols */
30:
31: static int x, y = 0, z;
32: static char *s;
33:
34: static int mdmsav = -1; /* Save modem type around network */
35: static int oldplex = -1; /* Duplex holder around network */
36:
37: extern int success, nfilp, fmask, fncnv, frecl, nfttyp, binary, warn, msgflg;
38: extern int cmask, maxrps, wslotr, bigsbsiz, bigrbsiz, urpsiz, rpsiz, spsiz;
39: extern int spsizr, spsizf, maxsps, spmax, pflag, bctr, npad, timef, timint;
40: extern int pkttim, rtimo, local, nfils, displa, atcapr, nettype, escape;
41: extern int mdmtyp, duplex, dfloc, network, cdtimo, fncact, mypadn;
42: extern int tnlm, sosi, tlevel, lf_opts, backgrd, flow, fdispla;
43: extern int
44: atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,
45: attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;
46:
47: extern long speed;
48:
49: extern CHAR sstate, eol, seol, stchr, mystch, mypadc, padch;
50:
51: extern char *cmarg, *cmarg2, *dftty;
52:
53: extern char tmpbuf[], *tp, *lp; /* Temporary buffer & pointers */
54: #ifndef NOFRILLS
55: extern char optbuf[]; /* Buffer for MAIL or PRINT options */
56: extern int rprintf; /* REMOTE PRINT flag */
57: #endif /* NOFRILLS */
58: extern char ttname[];
59:
60: extern struct keytab onoff[], filtab[], fttab[], rltab[];
61: extern int nrlt;
62:
63: #ifdef DCMDBUF
64: extern char *atxbuf; /* Atom buffer */
65: extern char *cmdbuf; /* Command buffer */
66: extern char *line; /* Character buffer for anything */
67: #ifdef CK_CURSES
68: /* This needs cleaning up... */
69: #ifdef UNIX
70: extern char *trmbuf; /* Termcap buffer */
71: #endif /* UNIX */
72: #ifdef OS2
73: extern char *trmbuf; /* Termcap buffer */
74: #endif /* OS2 */
75: #ifdef OSK
76: extern char *trmbuf; /* Termcap buffer */
77: #endif /* OSK */
78: #ifdef AMIGA
79: extern char *trmbuf; /* Termcap buffer */
80: #endif /* AMIGA */
81: #endif /* CK_CURSES */
82: #else
83: extern char atxbuf[]; /* Atom buffer */
84: extern char cmdbuf[]; /* Command buffer */
85: extern char line[]; /* Character buffer for anything */
86: #ifdef CK_CURSES
87: #ifdef UNIX
88: extern char trmbuf[]; /* Termcap buffer */
89: #endif /* UNIX */
90: #endif /* CK_CURSES */
91: #endif /* DCMDBUF */
92:
93: #ifndef NOCSETS
94: extern struct keytab fcstab[]; /* For 'set file character-set' */
95: extern struct keytab ttcstab[];
96: extern int nfilc, fcharset, ntermc, tcsr, tcsl;
97: #endif /* NOCSETS */
98:
99: #ifndef NOSPL
100: extern int cmdlvl; /* Overall command level */
101: #endif /* NOSPL */
102:
103: #ifdef TNCODE
104: extern int tn_init;
105: #endif /* TNCODE */
106:
107: #ifdef SUNX25
108: extern int revcall, closgr, cudata, nx25, npadx3;
109: extern char udata[MAXCUDATA];
110: extern CHAR padparms[MAXPADPARMS+1];
111: extern struct keytab x25tab[], padx3tab[];
112: #endif /* SUNX25 */
113:
114: #ifdef CK_CURSES
115: #ifndef VMS
116: _PROTOTYP(int tgetent,(char *, char *));
117: #endif /* VMS */
118: #endif /* CK_CURSES */
119:
120: #ifndef NODIAL
121: extern int dialhng, dialtmo, dialksp, dialdpy, dialmnp, dialmhu;
122: extern int mdmspd;
123: extern char *dialini, *dialdir, *dialcmd, *dialnpr;
124: extern FILE * dialfd;
125:
126:
127: struct keytab dialtab[] = {
128: "dial-command", XYDDIA, 0,
129: "directory", XYDDIR, 0,
130: "display", XYDDPY, 0,
131: "hangup", XYDHUP, 0,
132: "init-string", XYDINI, 0,
133: "kermit-spoof", XYDKSP, 0,
134: "mnp-enable", XYDMNP, 0,
135: #ifdef MDMHUP
136: "modem-hangup", XYDMHU, 0,
137: #endif /* MDMHUP */
138: "prefix", XYDNPR, 0,
139: "speed-matching", XYDSPD, 0,
140: "timeout", XYDTMO, 0
141: };
142: int ndial = (sizeof(dialtab) / sizeof(struct keytab));
143: #endif /* NODIAL */
144:
145: #ifndef NOXMIT
146: /* set transmit */
147: #define XMITF 0
148: #define XMITL 1
149: #define XMITP 2
150: #define XMITE 3
151: #define XMITX 4
152: #define XMITS 5
153: #define XMITW 6
154:
155: #ifndef NOXMIT
156: #define XMBUFL 50
157: extern int xmitf, xmitl, xmitp, xmitx, xmits, xmitw;
158: char xmitbuf[XMBUFL+1] = { NUL }; /* TRANSMIT eof string */
159: #endif /* NOXMIT */
160:
161: struct keytab xmitab[] = {
162: "echo", XMITX, 0,
163: "eof", XMITE, 0,
164: "fill", XMITF, 0,
165: "linefeed", XMITL, 0,
166: "locking-shift", XMITS, 0,
167: "pause", XMITW, 0,
168: "prompt", XMITP, 0
169: };
170: int nxmit = (sizeof(xmitab) / sizeof(struct keytab));
171: #endif /* NOXMIT */
172:
173: /* For SET FILE COLLISION */
174: /* Some of the following may be possible for some C-Kermit implementations */
175: /* but not others. Those that are not possible for your implementation */
176: /* should be ifdef'd out. */
177:
178: struct keytab colxtab[] = { /* SET FILE COLLISION options */
179: "append", XYFX_A, 0, /* append to old file */
180: #ifdef COMMENT
181: "ask", XYFX_Q, 0, /* ask what to do (not implemented) */
182: #endif
183: "backup", XYFX_B, 0, /* rename old file */
184: "discard", XYFX_D, 0, /* don't accept new file */
185: "no-supersede", XYFX_D, CM_INV, /* ditto (MSK compatibility) */
186: "overwrite", XYFX_X, 0, /* overwrite the old file == file warning off */
187: "rename", XYFX_R, 0, /* rename the incoming file == file warning on */
188: "update", XYFX_U, 0, /* replace if newer */
189: };
190: int ncolx = (sizeof(colxtab) / sizeof(struct keytab));
191:
192: static struct keytab rfiltab[] = { /* for REMOTE SET FILE */
193: "collision", XYFILX, 0,
194: "record-length", XYFILR, 0,
195: "type", XYFILT, 0
196: };
197: int nrfilp = (sizeof(rfiltab) / sizeof(struct keytab));
198:
199: struct keytab fntab[] = { /* File naming */
200: "converted", 1, 0,
201: "literal", 0, 0
202: };
203:
204: /* Terminal parameters table */
205: struct keytab trmtab[] = {
206: #ifdef OS2
207: "arrow-keys", XYTARR, 0,
208: #endif /* OS2 */
209: "bytesize", XYTBYT, 0,
210: #ifndef NOCSETS
211: "character-set", XYTCS, 0,
212: #endif /* NOCSETS */
213: #ifdef OS2
214: "color", XYTCOL, 0,
215: #endif /* OS2 */
216: "cr-display", XYTCRD, 0,
217: #ifdef OS2
218: "cursor", XYTCUR, 0,
219: #endif /* OS2 */
220: "echo", XYTEC, 0,
221: #ifdef OS2
222: "keypad-mode", XYTKPD, 0,
223: #endif /* OS2 */
224: "locking-shift", XYTSO, 0,
225: "newline-mode", XYTNL, 0
226: #ifdef OS2
227: , "type", XYTTYP, 0,
228: "wrap", XYTWRP, 0
229: #endif /* OS2 */
230: };
231: int ntrm = (sizeof(trmtab) / sizeof(struct keytab));
232:
233: struct keytab crdtab[] = { /* Carriage-return display */
234: "crlf", 1, 0,
235: "normal", 0, 0
236: };
237: extern int tt_crd; /* Carriage-return display variable */
238:
239: #ifdef OS2
240: /*
241: OS/2 serial communication devices.
242: */
243: struct keytab os2devtab[] = {
244: "1", 1, CM_INV, /* Invisible synonyms, like */
245: "2", 2, CM_INV, /* "set port 1" */
246: "3", 3, CM_INV,
247: "4", 4, CM_INV,
248: "5", 5, CM_INV,
249: "6", 6, CM_INV,
250: "7", 7, CM_INV,
251: "8", 8, CM_INV,
252: "com1", 1, 0, /* Real device names */
253: "com2", 2, 0,
254: "com3", 3, 0,
255: "com4", 4, 0,
256: "com5", 5, 0,
257: "com6", 6, 0,
258: "com7", 7, 0,
259: "com8", 7, 0
260: };
261: int nos2dev = (sizeof(os2devtab) / sizeof(struct keytab));
262:
263: /*
264: Terminal parameters that can be set by SET commands.
265: Used by the ck?con.c terminal emulator code.
266: For now, only use for OS/2. Should add these for Macintosh.
267: */
268: int tt_arrow = 1; /* Arrow key mode */
269: int tt_keypad = 0; /* Keypad mode */
270: int tt_wrap = 1; /* Autowrap */
271: int tt_type = TT_VT102; /* Terminal type */
272: int tt_cursor = 0; /* Cursor type */
273: #endif /* OS2 */
274:
275: #ifdef OS2
276: struct keytab akmtab[] = { /* Arrow key mode */
277: "application", 1, 0,
278: "cursor", 0, 0
279: };
280: struct keytab kpmtab[] = { /* Keypad mode */
281: "application", 0, 0,
282: "numeric", 1, 0
283: };
284:
285: struct keytab ttycoltab[] = { /* Items to be colored */
286: "help", 4, 0, /* Help screen */
287: "normal", 0, 0, /* Normal screen text */
288: "reverse", 1, 0, /* Reverse video */
289: "status", 3, 0, /* Status line */
290: "underlined", 2, 0 /* Underlined text */
291: };
292: int ncolors = 5;
293:
294: struct keytab ttyclrtab[] = { /* Colors */
295: "black", 0, 0,
296: "blue", 1, 0,
297: "brown", 6, 0,
298: "cyan", 3, 0,
299: "dgray", 8, 0,
300: "green", 2, 0,
301: "lblue", 9, 0,
302: "lcyan", 11, 0,
303: "lgray", 7, 0,
304: "lgreen", 10, 0,
305: "lmagenta", 13, 0,
306: "lred", 12, 0,
307: "magenta", 5, 0,
308: "red", 4, 0,
309: "white", 15, 0,
310: "yellow", 14, 0
311: };
312: int nclrs = 16;
313:
314: struct keytab ttycurtab[] = {
315: "full", 2, 0,
316: "half", 1, 0,
317: "underline", 0, 0
318: };
319: int ncursors = 3;
320: #endif /* OS2 */
321:
322: #ifdef OS2
323: struct keytab ttyptab[] = {
324: #ifdef COMMENT
325: /*
326: Not supported yet...
327: The idea is to let the console driver handle the escape sequences.
328: */
329: "none", TT_NONE, 0,
330: #endif /* COMMENT */
331: #ifdef OS2PM
332: "tek4014", TT_TEK40, 0,
333: #endif /* OS2PM */
334: "vt102", TT_VT102, 0,
335: "vt52", TT_VT52, 0
336: };
337: int nttyp = 2;
338: #endif /* OS2 */
339:
340: /* #ifdef VMS */
341: struct keytab fbtab[] = { /* Binary record types for VMS */
342: "fixed", XYFT_B, 0, /* Fixed is normal for binary */
343: "undefined", XYFT_U, 0 /* Undefined if they ask for it */
344: };
345: int nfbtyp = (sizeof(fbtab) / sizeof(struct keytab));
346: /* #endif */
347:
348: #ifdef VMS
349: struct keytab lbltab[] = { /* Labeled File info */
350: "acl", LBL_ACL, 0,
351: "backup-date", LBL_BCK, 0,
352: "name", LBL_NAM, 0,
353: "owner", LBL_OWN, 0,
354: "path", LBL_PTH, 0
355: };
356: int nlblp = (sizeof(lbltab) / sizeof(struct keytab));
357: #endif /* VMS */
358:
359: struct keytab fdtab[] = { /* SET FILE DISPLAY options */
360: #ifdef MAC /* Macintosh */
361: "fullscreen", XYFD_R, 0, /* Full-screen but not curses */
362: "none", XYFD_N, 0,
363: "off", XYFD_N, CM_INV,
364: "on", XYFD_R, CM_INV,
365: "quiet", XYFD_N, CM_INV
366:
367: #else /* Not Mac */
368: "crt", XYFD_S, 0, /* CRT display */
369: #ifdef CK_CURSES
370: #ifdef COMMENT
371: "curses", XYFD_C, CM_INV, /* Full-screen, curses */
372: #endif /* COMMENT */
373: "fullscreen", XYFD_C, 0, /* Full-screen, whatever the method */
374: #endif /* CK_CURSES */
375: "none", XYFD_N, 0, /* No display */
376: "off", XYFD_N, CM_INV, /* Ditto */
377: "on", XYFD_R, CM_INV, /* On = Serial */
378: "quiet", XYFD_N, CM_INV, /* No display */
379: "serial", XYFD_R, 0 /* Serial */
380: #endif /* MAC */
381: };
382: int nfdtab = (sizeof(fdtab) / sizeof(struct keytab));
383:
384: struct keytab rsrtab[] = { /* For REMOTE SET RECEIVE */
385: "packet-length", XYLEN, 0,
386: "timeout", XYTIMO, 0
387: };
388: int nrsrtab = (sizeof(rsrtab) / sizeof(struct keytab));
389:
390: /* Send/Receive Parameters */
391:
392: struct keytab srtab[] = {
393: "end-of-packet", XYEOL, 0,
394: "packet-length", XYLEN, 0,
395: "pad-character", XYPADC, 0,
396: "padding", XYNPAD, 0,
397: "start-of-packet", XYMARK, 0,
398: "timeout", XYTIMO, 0
399: };
400: int nsrtab = (sizeof(srtab) / sizeof(struct keytab));
401:
402: /* REMOTE SET */
403:
404: struct keytab rmstab[] = {
405: "attributes", XYATTR, 0,
406: "block-check", XYCHKT, 0,
407: "file", XYFILE, 0,
408: "incomplete", XYIFD, 0,
409: "receive", XYRECV, 0,
410: "retry", XYRETR, 0,
411: "server", XYSERV, 0,
412: "transfer", XYXFER, 0,
413: "window", XYWIND, 0
414: };
415: int nrms = (sizeof(rmstab) / sizeof(struct keytab));
416:
417: struct keytab attrtab[] = {
418: "all", AT_XALL, 0,
419: #ifdef COMMENT
420: "blocksize", AT_BLKS, 0, /* not used */
421: #endif /* COMMENT */
422: "character-set", AT_ENCO, 0,
423: "date", AT_DATE, 0,
424: "disposition", AT_DISP, 0,
425: "encoding", AT_ENCO, CM_INV,
426: "length", AT_LENK, 0,
427: "off", AT_ALLN, 0,
428: "on", AT_ALLY, 0,
429: #ifdef COMMENT
430: "os-specific", AT_SYSP, 0, /* not used by UNIX or VMS */
431: #endif /* COMMENT */
432: "system-id", AT_SYSI, 0,
433: "type", AT_FTYP, 0,
434: };
435: int natr = (sizeof(attrtab) / sizeof(struct keytab)); /* how many attributes */
436:
437: #ifndef NOSPL
438: extern int indef, intime, incase, inecho, insilence;
439: struct keytab inptab [] = { /* SET INPUT parameters */
440: "case", IN_CAS, 0,
441: "default-timeout", IN_DEF, CM_INV,
442: "echo", IN_ECH, 0,
443: "silence", IN_SIL, 0,
444: "timeout-action", IN_TIM, 0
445: };
446: int ninp = (sizeof(inptab) / sizeof(struct keytab));
447:
448: struct keytab intimt[] = { /* SET INPUT TIMEOUT parameters */
449: "proceed", 0, 0, /* 0 = proceed */
450: "quit", 1, 0 /* 1 = quit */
451: };
452:
453: struct keytab incast[] = { /* SET INPUT CASE parameters */
454: "ignore", 0, 0, /* 0 = ignore */
455: "observe", 1, 0 /* 1 = observe */
456: };
457: #endif /* NOSPL */
458:
459: /* The following routines broken out of doprm() to give compilers a break. */
460:
461: /* S E T O N -- Parse on/off (default on), set parameter to result */
462:
463: int
464: seton(prm) int *prm; {
465: int x, y;
466: if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
467: if ((x = cmcfm()) < 0) return(x);
468: *prm = y;
469: return(1);
470: }
471:
472: /* S E T N U M -- Set parameter to result of cmnum() parse. */
473: /*
474: Call with pointer to integer variable to be set,
475: x = number from cnum parse, y = return code from cmnum,
476: max = maximum value to accept, -1 if no maximum.
477: Returns -9 on failure, after printing a message, or 1 on success.
478: */
479: int
480: setnum(prm,x,y,max) int x, y, *prm, max; {
481: extern int cmflgs;
482: debug(F101,"setnum","",y);
483: if (y == -3) {
484: printf("\n?Value required\n");
485: return(-9);
486: }
487: if (y == -2) {
488: printf("%s?Not a number: %s\n",cmflgs == 1 ? "" : "\n", atxbuf);
489: return(-9);
490: }
491: if (y < 0) return(y);
492: if (max > -1 && x > max) {
493: printf("?Sorry, %d is the maximum\n",max);
494: return(-9);
495: }
496: if ((y = cmcfm()) < 0) return(y);
497: *prm = x;
498: return(1);
499: }
500:
501: /* S E T C C -- Set parameter to an ASCII control character value. */
502:
503: int
504: setcc(prm,x,y) int x, y, *prm; {
505: if (y == -3) {
506: printf("\n?Value required\n");
507: return(-3);
508: }
509: if (y < 0) return(y);
510: if ((x > 037) && (x != 0177)) {
511: printf("\n?Not in ASCII control range - %d\n",x);
512: return(-2);
513: }
514: if ((y = cmcfm()) < 0) return(y);
515: *prm = x;
516: return(1);
517: }
518:
519: #ifndef NODIAL
520: _PROTOTYP(static int dialstr,(char **, char *));
521: /*
522: Parse a DIAL-related string, stripping enclosing braces, if any.
523: */
524: static int
525: dialstr(p,msg) char **p; char *msg; {
526: int x;
527: if ((x = cmtxt(msg, "", &s, xxstring)) < 0)
528: return(x);
529: if (*s == '{') { /* Strip enclosing braces, if any */
530: x = strlen(s);
531: if (s[x-1] == '}') {
532: s[x-1] = NUL;
533: s++;
534: }
535: }
536: if (*p) { /* Free any previous string. */
537: free(*p);
538: *p = (char *) 0;
539: }
540: if ((x = strlen(s)) > 0) {
541: *p = malloc(x + 1); /* Allocate space for it */
542: strcpy(*p,s); /* and make a safe copy. */
543: } else *p = (char *) 0;
544: return(success = 1);
545: }
546:
547: int /* Set DIAL command options */
548: setdial() {
549: if ((y = cmkey(dialtab,ndial,"","",xxstring)) < 0) return(y);
550: switch (y) {
551: case XYDHUP: /* DIAL HANGUP */
552: return(success = seton(&dialhng));
553: case XYDINI: /* DIAL INIT-STRING */
554: return(dialstr(&dialini,"Modem dialer initialization string"));
555: case XYDNPR: /* DIAL NUMBER-PREFIX */
556: return(dialstr(&dialnpr,"Modem dialer telephone number prefix"));
557: case XYDDIA: /* DIAL DIAL-COMMAND */
558: x = cmtxt("Dialing command for modem,\n\
559: include \"%s\" to stand for phone number,\n\
560: for example, \"set dial dial-command ATDT%s\\13\"",
561: "",
562: &s,
563: xxstring);
564: if (x < 0 && x != -3) /* Handle parse errors */
565: return(x);
566: y = x = strlen(s); /* Get length of text */
567: if (x > 0 && *s == '{') { /* Strip enclosing braces, */
568: if (s[x-1] == '}') { /* if any. */
569: s[x-1] = NUL;
570: s++;
571: y -= 2;
572: }
573: }
574: if (y > 0) { /* If there is any text (left), */
575: for (x = 0; x < y; x++) { /* make sure they included "%s" */
576: if (s[x] != '%') continue;
577: if (s[x+1] == 's') break;
578: }
579: if (x == y) {
580: printf(
581: "?Dial-command must contain \"%cs\" for phone number.\n",'%');
582: return(-9);
583: }
584: }
585: if (dialcmd) { /* Free any previous string. */
586: free(dialcmd);
587: dialcmd = (char *) 0;
588: }
589: if (y > 0) {
590: dialcmd = malloc(y + 1); /* Allocate space for it */
591: strcpy(dialcmd,s); /* and make a safe copy. */
592: }
593: return(success = 1);
594: case XYDKSP: /* DIAL KERMIT-SPOOF */
595: return(success = seton(&dialksp));
596: case XYDTMO: /* DIAL TIMEOUT */
597: y = cmnum("Seconds to wait for call completion","0",10,&x,xxstring);
598: return(success = setnum(&dialtmo,x,y,10000));
599: case XYDDPY: /* DIAL DISPLAY */
600: return(success = seton(&dialdpy));
601: case XYDSPD: /* DIAL SPEED-MATCHING */
602: /* used to be speed-changing */
603: if ((y = seton(&mdmspd)) < 0) return(y);
604: #ifdef COMMENT
605: mdmspd = 1 - mdmspd; /* so here we reverse the meaning */
606: #endif /* COMMENT */
607: return(success = 1);
608: case XYDMNP: /* DIAL MNP-ENABLE */
609: return(success = seton(&dialmnp));
610: #ifdef MDMHUP
611: case XYDMHU: /* DIAL MODEM-HANGUP */
612: return(success = seton(&dialmhu));
613: #endif /* MDMHUP */
614: case XYDDIR: /* DIAL DIRECTORY */
615: if ((y = cmifi("Name of dialing directory file","",&s,&y,
616: xxstring)) < 0) {
617: if (y == -3) {
618: if (dialdir) free(dialdir); /* Free any previous storage */
619: dialdir = NULL;
620: return(success = 1);
621: } else return(y);
622: }
623: if (y) {
624: printf("?Wildcards not allowed\n");
625: return(-9);
626: }
627: strcpy(line,s); /* Make safe copy of dial string */
628: if ((y = cmcfm()) < 0) return(y); /* Confirm the command */
629: if (dialdir) free(dialdir); /* Free previous filename storage */
630: if (dialfd) { /* Close previous file, if any */
631: fclose(dialfd);
632: dialfd = NULL;
633: }
634: s = line; /* Point back to dial string */
635: if (s == NULL || *s == NUL) { /* If no name given */
636: dialdir = NULL; /* remove the name string */
637: return(success = 1);
638: } else if ((dialdir = malloc(strlen(s)+1)) == NULL) {
639: return(success = 0); /* Can't malloc storage for name */
640: } else { /* Have storage for name */
641: strcpy(dialdir,s); /* Copy string into new storage */
642: if ((dialfd = fopen(dialdir,"r")) == NULL) { /* Open the file */
643: perror(dialdir); /* Can't, print message saying why */
644: success = 0; /* We didn't succeed */
645: return(-9); /* Fail, message already printed */
646: }
647: return(success = 1); /* Everything is OK */
648: }
649:
650: default:
651: printf("?Unexpected SET DIAL parameter\n");
652: return(-2);
653: }
654: }
655: #endif /* NODIAL */
656:
657: int
658: setfil(rmsflg) int rmsflg; {
659: if (rmsflg) {
660: if ((y = cmkey(rfiltab,nrfilp,"Remote file parameter","",
661: xxstring)) < 0) {
662: if (y == -3) {
663: printf("?Remote file parameter required\n");
664: return(-9);
665: } else return(y);
666: }
667: } else {
668: if ((y = cmkey(filtab,nfilp,"File parameter","",xxstring)) < 0)
669: return(y);
670: }
671: switch (y) {
672: #ifdef COMMENT /* Not needed */
673: case XYFILB: /* Blocksize */
674: sprintf(tmpbuf,"%d",DBLKSIZ);
675: if ((y = cmnum("file block size",tmpbuf,10,&z,xxstring)) < 0)
676: return(y);
677: if ((x = cmcfm()) < 0) return(x);
678: if (rmsflg) {
679: sprintf(tmpbuf,"%d",z);
680: sstate = setgen('S', "311", tmpbuf, "");
681: return((int) sstate);
682: } else {
683: fblksiz = z;
684: return(success = 1);
685: }
686: #endif /* COMMENT */
687:
688: case XYFILS: /* Byte size */
689: if ((y = cmnum("file byte size (7 or 8)","8",10,&z,xxstring)) < 0)
690: return(y);
691: if (z != 7 && z != 8) {
692: printf("\n?The choices are 7 and 8\n");
693: return(0);
694: }
695: if ((y = cmcfm()) < 0) return(y);
696: if (z == 7) fmask = 0177;
697: else if (z == 8) fmask = 0377;
698: return(success = 1);
699:
700: #ifndef NOCSETS
701: case XYFILC: /* Character set */
702: if ((x = cmkey(fcstab,nfilc,"local file code","ascii", xxstring)) < 0)
703: return(x);
704: if ((z = cmcfm()) < 0) return(z);
705: fcharset = x;
706: return(success = 1);
707: #endif /* NOCSETS */
708:
709: case XYFILD: /* Display */
710: if ((x = cmkey(fdtab,nfdtab,"file transfer display style","",
711: xxstring)) < 0)
712: return(x);
713: if ((z = cmcfm()) < 0) return(z);
714: #ifdef CK_CURSES
715: if (x == XYFD_C) {
716: #ifdef VMS
717: lp = line;
718: #else
719: lp = trmbuf;
720: #endif /* VMS */
721: #ifndef MYCURSES
722: s = getenv("TERM");
723: if (tgetent(lp,s) < 1) {
724: #ifdef VMS
725: printf("Sorry, terminal type not supported: %s\n",s);
726: #else
727: printf("Sorry, terminal type unknown: %s\n",s);
728: #endif /* VMS */
729: return(success = 0);
730: }
731: #endif /* MYCURSES */
732: line[0] = '\0';
733: }
734: #endif /* CK_CURSES */
735: fdispla = x; /* It's OK. */
736: return(success = 1);
737:
738: case XYFILN: /* Names */
739: if ((x = cmkey(fntab,2,"how to handle filenames","converted",
740: xxstring)) < 0)
741: return(x);
742: if ((z = cmcfm()) < 0) return(z);
743: fncnv = x;
744: return(success = 1);
745:
746: case XYFILR: /* Record length */
747: sprintf(tmpbuf,"%d",DLRECL);
748: if ((y = cmnum("file record length",tmpbuf,10,&z,xxstring)) < 0)
749: return(y);
750: if ((x = cmcfm()) < 0) return(x);
751: if (rmsflg) {
752: sprintf(tmpbuf,"%d",z);
753: sstate = setgen('S', "312", tmpbuf, "");
754: return((int) sstate);
755: } else {
756: frecl = z;
757: return(success = 1);
758: }
759:
760: #ifdef COMMENT
761: case XYFILO: /* Organization */
762: if ((x = cmkey(forgtab,nforg,"file organization","sequential",
763: xxstring)) < 0)
764: return(x);
765: if ((y = cmcfm()) < 0) return(y);
766: if (rmsflg) {
767: sprintf(tmpbuf,"%d",x);
768: sstate = setgen('S', "314", tmpbuf, "");
769: return((int) sstate);
770: } else {
771: forg = x;
772: return(success = 1);
773: }
774: #endif /* COMMENT */
775:
776: #ifdef COMMENT /* Not needed */
777: case XYFILF: /* Format */
778: if ((x = cmkey(frectab,nfrec,"file record format","stream",
779: xxstring)) < 0)
780: return(x);
781: if ((y = cmcfm()) < 0) return(y);
782: if (rmsflg) {
783: sprintf(tmpbuf,"%d",x);
784: sstate = setgen('S', "313", tmpbuf, "");
785: return((int) sstate);
786: } else {
787: frecfm = x;
788: return(success = 1);
789: }
790: #endif /* COMMENT */
791:
792: #ifdef COMMENT
793: case XYFILP: /* Printer carriage control */
794: if ((x = cmkey(fcctab,nfcc,"file carriage control","newline",
795: xxstring)) < 0)
796: return(x);
797: if ((y = cmcfm()) < 0) return(y);
798: if (rmsflg) {
799: sprintf(tmpbuf,"%d",x);
800: sstate = setgen('S', "315", tmpbuf, "");
801: return((int) sstate);
802: } else {
803: fcctrl = x;
804: return(success = 1);
805: }
806: #endif /* COMMENT */
807:
808: case XYFILT: /* Type */
809: if ((x = cmkey(fttab,nfttyp,"type of file","text",xxstring)) < 0)
810: return(x);
811: #ifdef COMMENT
812: if ((y = cmnum("file byte size (7 or 8)","8",10,&z,xxstring)) < 0)
813: return(y);
814: if (z != 7 && z != 8) {
815: printf("\n?The choices are 7 and 8\n");
816: return(0);
817: }
818: #endif /* COMMENT */
819:
820: #ifdef VMS
821: /* Allow VMS users to choose record format for binary files */
822: if ((x == XYFT_B) && (rmsflg == 0)) {
823: if ((x = cmkey(fbtab,nfbtyp,"VMS record format","fixed",
824: xxstring)) < 0)
825: return(x);
826: }
827: #endif /* VMS */
828: if ((y = cmcfm()) < 0) return(y);
829: if (rmsflg) {
830: sstate = setgen('S', "300", x ? "1" : "0", "");
831: return((int) sstate);
832: } else {
833: binary = x;
834: #ifdef COMMENT
835: if (z == 7) fmask = 0177;
836: else if (z == 8) fmask = 0377;
837: #endif /* COMMENT */
838: return(success = 1);
839: }
840:
841: case XYFILX: /* Collision Action */
842: if ((x = cmkey(colxtab,ncolx,"Filename collision action","backup",
843: xxstring)) < 0)
844: return(x);
845: if ((y = cmcfm()) < 0) return(y);
846: fncact = x;
847: if (rmsflg) {
848: sprintf(tmpbuf,"%d",fncact);
849: sstate = setgen('S', "302", tmpbuf, "");
850: return((int) sstate);
851: } else {
852: if (fncact == XYFX_R) warn = 1; /* SET FILE WARNING implications */
853: if (fncact == XYFX_X) warn = 0; /* ... */
854: return(success = 1);
855: }
856:
857: case XYFILW: /* Warning/Write-Protect */
858: seton(&warn);
859: if (warn)
860: fncact = XYFX_R;
861: else
862: fncact = XYFX_X;
863: return(success = 1);
864:
865: #ifdef VMS
866: case XYFILL: /* LABELED FILE parameters */
867: if ((x = cmkey(lbltab,nlblp,"VMS labeled file feature","",
868: xxstring)) < 0)
869: return(x);
870: if ((success = seton(&y)) < 0)
871: return(success);
872: if (y) /* Set or reset the selected bit */
873: lf_opts |= x; /* in the options bitmask. */
874: else
875: lf_opts &= ~x;
876: return(success);
877: #endif /* VMS */
878:
879: case XYFILI: /* INCOMPLETE */
880: return(doprm(XYIFD,rmsflg));
881:
882: default:
883: printf("?unexpected file parameter\n");
884: return(-2);
885: }
886: }
887:
888: int
889: settrm() {
890: if ((y = cmkey(trmtab,ntrm,"","",xxstring)) < 0) return(y);
891: #ifdef MAC
892: printf("\n?Sorry, not implemented yet. Please use the Settings menu.\n");
893: return(-9);
894: #else
895: switch (y) {
896: case XYTBYT: /* SET TERMINAL BYTESIZE */
897: if ((y = cmnum("bytesize for terminal connection","8",10,&x,
898: xxstring)) < 0)
899: return(y);
900: if (x != 7 && x != 8) {
901: printf("\n?The choices are 7 and 8\n");
902: return(success = 0);
903: }
904: if ((y = cmcfm()) < 0) return(y);
905: if (x == 7) cmask = 0177;
906: else if (x == 8) cmask = 0377;
907: return(success = 1);
908:
909: case XYTSO: /* SET TERMINAL LOCKING-SHIFT */
910: return(success = seton(&sosi));
911:
912: case XYTNL: /* SET TERMINAL NEWLINE-MODE */
913: return(success = seton(&tnlm));
914:
915: #ifdef OS2
916: case XYTCOL: /* SET TERMINAL COLOR */
917: if ((x = cmkey(ttycoltab,ncolors,"","normal",xxstring)) < 0) {
918: return(x);
919: } else {
920: extern int colornormal, colorreverse, colorunderline,
921: colorstatus, colorhelp, scrninitialised;
922: int fg, bg;
923: if ((fg = cmkey(ttyclrtab,nclrs,
924: "foreground color","black",xxstring)) < 0)
925: return(fg);
926: if ((bg = cmkey(ttyclrtab,nclrs,
927: "background color","cyan",xxstring)) < 0)
928: return(bg);
929: if ((y = cmcfm()) < 0)
930: return(y);
931: switch (x) {
932: case 0:
933: colornormal = fg | bg << 4;
934: break;
935: case 1:
936: colorreverse = fg | bg << 4;
937: break;
938: case 2:
939: colorunderline = fg | bg << 4;
940: break;
941: case 3:
942: colorstatus = fg | bg << 4;
943: break;
944: case 4:
945: colorhelp = fg | bg << 4;
946: break;
947: default:
948: printf("%s - invalid\n",cmdbuf);
949: return(-9);
950: break;
951: }
952: scrninitialised = 0;
953: }
954: return(success = 1);
955:
956: case XYTCUR: /* SET TERMINAL CURSOR */
957: if ((x = cmkey(ttycurtab,ncursors,"","underline",xxstring)) < 0)
958: return(x);
959: if ((y = cmcfm()) < 0) return(y);
960: tt_cursor = x;
961: return(success = 1);
962:
963: case XYTTYP: /* SET TERMINAL TYPE */
964: if ((x = cmkey(ttyptab,nttyp,"","vt102",xxstring)) < 0) return(x);
965: if ((y = cmcfm()) < 0) return(y);
966: tt_type = x;
967: return(success = 1);
968:
969: case XYTARR: /* SET TERMINAL ARROW-KEYS */
970: if ((x = cmkey(akmtab,2,"","",xxstring)) < 0) return(x);
971: if ((y = cmcfm()) < 0) return(y);
972: tt_arrow = x; /* 0 = application, 1 = cursor */
973: return(success = 1);
974:
975: case XYTKPD: /* SET TERMINAL KEYPAD-MODE */
976: if ((x = cmkey(kpmtab,2,"","",xxstring)) < 0) return(x);
977: if ((y = cmcfm()) < 0) return(y);
978: tt_keypad = x; /* 0 = application, 1 = numeric */
979: return(success = 1);
980:
981: case XYTWRP: /* SET TERMINAL WRAP */
982: seton(&tt_wrap);
983: return(success = 1);
984: #endif /* OS2 */
985:
986: #ifndef NOCSETS
987: case XYTCS: /* SET TERMINAL CHARACTER-SET */
988: /* set terminal character-set <remote> <local> */
989: if ((x = cmkey(ttcstab,ntermc,
990: "remote terminal character-set","",xxstring)) < 0)
991: return(x);
992: if (x == FC_TRANSP) { /* TRANSPARENT? */
993: if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
994: tcsr = tcsl = FC_USASCII; /* Make them both the same */
995: return(success = 1);
996: }
997:
998: /* Not transparent, so get local set to translate it into */
999:
1000: s = ""; /* Make current file char set */
1001: for (y = 0; y <= nfilc; y++) /* be the default... */
1002: if (fcstab[y].kwval == fcharset) {
1003: s = fcstab[y].kwd;
1004: break;
1005: }
1006: if ((y = cmkey(fcstab,nfilc,
1007: "local character-set",s,xxstring)) < 0)
1008: return(y);
1009: if ((z = cmcfm()) < 0) return(z); /* Confirm the command */
1010: tcsr = x; /* Remote character set */
1011: tcsl = y; /* Local character set */
1012: return(success = 1);
1013: #endif /* NOCSETS */
1014:
1015: case XYTEC: /* SET TERMINAL ECHO */
1016: if ((x = cmkey(rltab,nrlt,"which side echos during CONNECT",
1017: "remote", xxstring)) < 0) return(x);
1018: if ((y = cmcfm()) < 0) return(y);
1019: duplex = x;
1020: return(success = 1);
1021:
1022: case XYTCRD: /* SET TERMINAL CR-DISPLAY */
1023: if ((x = cmkey(crdtab,2,"", "normal", xxstring)) < 0) return(x);
1024: if ((y = cmcfm()) < 0) return(y);
1025: tt_crd = x;
1026: return(success = 1);
1027:
1028: default: /* Shouldn't get here. */
1029: return(-2);
1030: }
1031: #endif /* MAC */
1032: }
1033:
1034: int /* SET SEND/RECEIVE */
1035: setsr(xx, rmsflg) int xx; int rmsflg; {
1036: if (xx == XYRECV)
1037: strcpy(line,"Parameter for inbound packets");
1038: else
1039: strcpy(line,"Parameter for outbound packets");
1040:
1041: if (rmsflg) {
1042: if ((y = cmkey(rsrtab,nrsrtab,line,"",xxstring)) < 0) {
1043: if (y == -3) {
1044: printf("?Remote receive parameter required\n");
1045: return(-9);
1046: } else return(y);
1047: }
1048: } else {
1049: if ((y = cmkey(srtab,nsrtab,line,"",xxstring)) < 0) return(y);
1050: }
1051: switch (y) {
1052:
1053: case XYEOL:
1054: y = cmnum("Decimal ASCII code for packet terminator","13",10,&x,
1055: xxstring);
1056: if ((y = setcc(&z,x,y)) < 0) return(y);
1057: if (xx == XYRECV) eol = z; else seol = z;
1058: return(success = y);
1059:
1060: case XYLEN:
1061: y = cmnum("Maximum number of characters in a packet","90",10,&x,
1062: xxstring);
1063: if (xx == XYRECV) { /* Receive... */
1064: if ((y = setnum(&z,x,y,maxrps)) < 0)
1065: return(y);
1066: if (z < 10) {
1067: printf("Sorry, 10 is the minimum\n");
1068: return(-9);
1069: }
1070: if (rmsflg) {
1071: tp = tmpbuf;
1072: sprintf(tp,"%d",z);
1073: sstate = setgen('S', "401", tp, "");
1074: return((int) sstate);
1075: } else {
1076: if (z > MAXRP) z = MAXRP;
1077: y = adjpkl(z,wslotr,bigrbsiz);
1078: if (y != z) {
1079: urpsiz = y;
1080: if (
1081: #ifndef NOSPL
1082: cmdlvl == 0
1083: #else
1084: tlevel < 0
1085: #endif /* NOSPL */
1086: )
1087: if (msgflg) printf(
1088: " Adjusting receive packet-length to %d for %d window slots\n",
1089: y, wslotr);
1090: }
1091: urpsiz = y;
1092: rpsiz = (y > 94) ? 94 : y;
1093: }
1094: } else { /* Send... */
1095: if ((y = setnum(&z,x,y,maxsps)) < 0)
1096: return(y);
1097: if (z < 10) {
1098: printf("Sorry, 10 is the minimum\n");
1099: return(-9);
1100: }
1101: if (z > MAXSP) z = MAXSP;
1102: spsiz = z; /* Set it */
1103: y = adjpkl(spsiz,wslotr,bigsbsiz);
1104: if (y != spsiz &&
1105: #ifndef NOSPL
1106: cmdlvl == 0
1107: #else
1108: tlevel < 0
1109: #endif /* NOSPL */
1110: )
1111: if (msgflg)
1112: printf("Adjusting packet size to %d for %d window slots\n",
1113: y,wslotr);
1114: spsiz = spmax = spsizr = y; /* Set it and flag that it was set */
1115: spsizf = 1; /* to allow overriding Send-Init. */
1116: }
1117: if (pflag &&
1118: #ifndef NOSPL
1119: cmdlvl == 0
1120: #else
1121: tlevel < 0
1122: #endif /* NOSPL */
1123: ) {
1124: if (z > 94 && msgflg) {
1125: printf("Extended-length packets requested.\n");
1126: if (bctr < 2 && z > 200) printf("\
1127: Remember to SET BLOCK 2 or 3 for long packets.\n");
1128: }
1129: if (speed <= 0L) speed = ttgspd();
1130: #ifdef COMMENT
1131: /*
1132: Kermit does this now itself.
1133: */
1134: if (speed <= 0L && z > 200 && msgflg) {
1135: printf("\
1136: Make sure your timeout interval is long enough for %d-byte packets.\n",z);
1137: }
1138: #endif /* COMMENT */
1139: }
1140: return(success = y);
1141:
1142: case XYMARK:
1143: y = cmnum("Code for packet-start character","1",10,&x,xxstring);
1144: #ifdef UNIX
1145: /*
1146: Printable start-of-packet works for UNIX and VMS only!
1147: */
1148: if ((y = setnum(&z,x,y,126)) < 0) return(y);
1149: #else
1150: #ifdef VMS
1151: if ((y = setnum(&z,x,y,126)) < 0) return(y);
1152: #else
1153: if ((y = setcc(&z,x,y)) < 0) return(y);
1154: #endif /* VMS */
1155: #endif /* UNIX */
1156: if (xx == XYRECV) stchr = z; else mystch = z;
1157: return(success = y);
1158:
1159:
1160: case XYNPAD: /* PADDING */
1161: y = cmnum("How many padding characters for inbound packets","0",10,&x,
1162: xxstring);
1163: if ((y = setnum(&z,x,y,94)) < 0) return(y);
1164: if (xx == XYRECV) mypadn = z; else npad = z;
1165: return(success = y);
1166:
1167: case XYPADC: /* PAD-CHARACTER */
1168: y = cmnum("Decimal ASCII code for packet padding character","0",10,&x,
1169: xxstring);
1170: if ((y = setcc(&z,x,y)) < 0) return(y);
1171: if (xx == XYRECV) mypadc = z; else padch = z;
1172: return(success = y);
1173:
1174: case XYTIMO: /* TIMEOUT */
1175: if (xx == XYRECV) {
1176: char buf[16]; /* Construct default */
1177: sprintf(buf,"%d",URTIME);
1178: y = cmnum("Packet timeout interval",buf,10,&x,xxstring);
1179: if ((y = setnum(&z,x,y,94)) < 0) return(y);
1180:
1181: if (rmsflg) { /* REMOTE SET RECEIVE TIMEOUT */
1182: tp = tmpbuf; /* Tell Kermit server what */
1183: sprintf(tp,"%d",z); /* timeout to ask me to use. */
1184: sstate = setgen('S', "402", tp, "");
1185: return((int) sstate);
1186: } else { /* SET RECEIVE TIMEOUT */
1187: pkttim = z; /* Value to put in my negotiation */
1188: } /* packet for other Kermit to use */
1189:
1190: } else { /* SET SEND TIMEOUT */
1191: y = cmnum("Packet timeout interval","",10,&x,xxstring);
1192: if (y == -3) { /* They cancelled a previous */
1193: x = DMYTIM; /* SET SEND command, so restore */
1194: y = 0; /* the default */
1195: timef = 0; /* and turn off the override flag */
1196: } else { /* They gave a number */
1197: timef = 1; /* so turn on the override flag */
1198: }
1199: if ((y = setnum(&z,x,y,94)) < 0)
1200: return(y);
1201: timint = rtimo = z; /* Override value for me to use */
1202: }
1203: return(success = 1);
1204:
1205: default:
1206: return(-2);
1207: } /* End of SET SEND/RECEIVE... */
1208: }
1209:
1210: #ifndef NOXMIT
1211: int
1212: setxmit() {
1213: if ((y = cmkey(xmitab,nxmit,"","",xxstring)) < 0) return(y);
1214: switch (y) {
1215: case XMITE: /* EOF */
1216: y = cmtxt("Characters to send at end of file,\n\
1217: Use backslash codes for control characters","",&s,xxstring);
1218: if (y < 0) return(y);
1219: if ((int)strlen(s) > XMBUFL) {
1220: printf("?Too many characters, %d maximum\n",XMBUFL);
1221: return(-2);
1222: }
1223: strcpy(xmitbuf,s);
1224: return(success = 1);
1225:
1226: case XMITF: /* Fill */
1227: y = cmnum("Numeric code for blank-line fill character","0",10,&x,
1228: xxstring);
1229: if ((y = setnum(&z,x,y,127)) < 0) return(y);
1230: xmitf = z;
1231: return(success = 1);
1232: case XMITL: /* Linefeed */
1233: return(success = seton(&xmitl));
1234: case XMITS: /* Locking-Shift */
1235: return(success = seton(&xmits));
1236: case XMITP: /* Prompt */
1237: y = cmnum("Numeric code for host's prompt character, 0 for none",
1238: "10",10,&x,xxstring);
1239: if ((y = setnum(&z,x,y,127)) < 0) return(y);
1240: xmitp = z;
1241: return(success = 1);
1242: case XMITX: /* Echo */
1243: return(success = seton(&xmitx));
1244: case XMITW: /* Pause */
1245: y = cmnum("Number of milliseconds to pause between binary characters\n\
1246: or text lines during transmission","0",10,&x,xxstring);
1247: if ((y = setnum(&z,x,y,1000)) < 0) return(y);
1248: xmitw = z;
1249: return(success = 1);
1250: default:
1251: return(-2);
1252: }
1253: }
1254: #endif /* NOXMIT */
1255:
1256: /* D O R M T -- Do a remote command */
1257:
1258: #ifdef ATTSV
1259: #ifndef aegis
1260: #ifndef datageneral
1261: #define CK_NEED_SIG
1262: #endif /* datageneral */
1263: #endif /* aegis */
1264: #endif /* ATTSV */
1265:
1266: VOID rmsg() {
1267: if (pflag)
1268: printf(
1269: #ifdef CK_NEEDSIG
1270:
1271: " Type your escape character, %s, followed by X or E to cancel.\n",
1272: dbchr(escape)
1273: #else
1274: " Press the X or E key to cancel.\n"
1275: #endif /* CK_NEEDSIG */
1276: );
1277: }
1278:
1279: int
1280: dormt(xx) int xx; {
1281: int x, y, retcode;
1282: char *s, sbuf[50], *s2;
1283:
1284:
1285: if (xx < 0) return(xx);
1286:
1287: if (xx == XZSET) { /* REMOTE SET */
1288: if ((y = cmkey(rmstab,nrms,"","",xxstring)) < 0) {
1289: if (y == -3) {
1290: printf("?Parameter name required\n");
1291: return(-9);
1292: } else return(y);
1293: }
1294: return(doprm(y,1));
1295: }
1296:
1297: switch (xx) { /* Others... */
1298:
1299: case XZCWD: /* CWD */
1300: if ((x = cmtxt("Remote directory name","",&s,xxstring)) < 0) return(x);
1301: debug(F111,"XZCWD: ",s,x);
1302: *sbuf = NUL;
1303: s2 = sbuf;
1304:
1305: /* The following is commented out, because there is practically no */
1306: /* computer in the world that requires a password for directory changing. */
1307: /* (The DEC-20 was the only one, and they're mostly all gone.) */
1308: #ifdef DIRPWDPR
1309: if (*s != NUL) { /* If directory name given, */
1310: /* get password on separate line. */
1311: if (tlevel > -1) { /* From take file... */
1312:
1313: if (fgets(sbuf,50,tfile[tlevel]) == NULL)
1314: fatal("take file ends prematurely in 'remote cwd'");
1315: debug(F110," pswd from take file",s2,0);
1316: for (x = (int)strlen(sbuf);
1317: x > 0 && (sbuf[x-1] == NL || sbuf[x-1] == CR);
1318: x--)
1319: sbuf[x-1] = '\0';
1320:
1321: } else { /* From terminal... */
1322:
1323: printf(" Password: "); /* get a password */
1324: #ifdef OS2
1325: while (((x = isatty(0) ? coninc(0) :
1326: getchar()) != NL) && (x != CR)) { /* with no echo */
1327: #else
1328: while (((x = getchar()) != NL) && (x != CR)) { /* with no echo */
1329: #endif /* OS2 */
1330: if ((x &= 0177) == '?') {
1331: printf("? Password of remote directory\n Password: ");
1332: s2 = sbuf;
1333: *sbuf = NUL;
1334: }
1335: else if (x == ESC) /* Mini command line editor... */
1336: putchar(BEL);
1337: else if (x == BS || x == 0177)
1338: s2--;
1339: else if (x == 025) { /* Ctrl-U */
1340: s2 = sbuf;
1341: *sbuf = NUL;
1342: }
1343: else
1344: *s2++ = x;
1345: }
1346: *s2 = NUL;
1347: putchar('\n');
1348: }
1349: s2 = sbuf;
1350: } else s2 = "";
1351: #endif /* DIRPWDPR */
1352:
1353: debug(F110," password",s2,0);
1354: sstate = setgen('C',s,s2,"");
1355: retcode = 0;
1356: break;
1357:
1358: case XZDEL: /* Delete */
1359: if ((x = cmtxt("Name of remote file(s) to delete","",&s,xxstring)) < 0) {
1360: if (x == -3) {
1361: printf("?Name of remote file(s) required\n");
1362: return(-9);
1363: } else return(x);
1364: }
1365: if (local) ttflui(); /* If local, flush tty input buffer */
1366: retcode = sstate = rfilop(s,'E');
1367: break;
1368:
1369: case XZDIR: /* Directory */
1370: if ((x = cmtxt("Remote directory or file specification","",&s,
1371: xxstring)) < 0)
1372: return(x);
1373: if (local) ttflui(); /* If local, flush tty input buffer */
1374: rmsg();
1375: retcode = sstate = setgen('D',s,"","");
1376: break;
1377:
1378: case XZHLP: /* Help */
1379: if ((x = cmcfm()) < 0) return(x);
1380: sstate = setgen('H',"","","");
1381: retcode = 0;
1382: break;
1383:
1384: #ifndef NOPUSH
1385: case XZHOS: /* Host */
1386: if ((x = cmtxt("Command for remote system","",&cmarg,xxstring)) < 0)
1387: return(x);
1388: if ((int)strlen(cmarg) < 1) {
1389: if (x == -3) {
1390: printf("?Remote host command required\n");
1391: return(-9);
1392: } else return(x);
1393: }
1394: rmsg();
1395: retcode = sstate = 'c';
1396: break;
1397: #endif /* NOPUSH */
1398:
1399: #ifndef NOFRILLS
1400: case XZKER:
1401: if ((x = cmtxt("Command for remote Kermit","",&cmarg,xxstring)) < 0)
1402: return(x);
1403: if ((int)strlen(cmarg) < 1) {
1404: if (x == -3) {
1405: printf("?Remote Kermit command required\n");
1406: return(-9);
1407: } else return(x);
1408: }
1409: retcode = sstate = 'k';
1410: rmsg();
1411: break;
1412:
1413: case XZLGI: { /* Login */
1414: char *p1, *p2, *p3;
1415: if ((x = cmfld("User ID","",&s,xxstring)) < 0) return(x);
1416: if ((p1 = malloc((int)strlen(s) + 1)) == NULL) {
1417: printf("Internal error: malloc\n");
1418: return(-2);
1419: } else strcpy(p1,s);
1420: if ((x = cmfld("Password","",&s,xxstring)) < 0) return(x);
1421: if ((p2 = malloc((int)strlen(s) + 1)) == NULL) {
1422: printf("Internal error: malloc\n");
1423: return(-2);
1424: } else strcpy(p2,s);
1425: if ((x = cmtxt("Account or carriage return","",
1426: &s,xxstring)) < 0 && x != -3)
1427: return(x);
1428: if ((p3 = malloc((int)strlen(s) + 1)) == NULL) {
1429: printf("Internal error: malloc\n");
1430: return(-2);
1431: } else strcpy(p3,s);
1432: sstate = setgen('I',p1,p2,p3);
1433: if (p3) free(p3);
1434: if (p2) free(p2);
1435: if (p1) free(p1);
1436: retcode = 0;
1437: break;
1438: }
1439:
1440: case XZLGO: /* Logout */
1441: if ((x = cmcfm()) < 0) return(x);
1442: sstate = setgen('I',"","","");
1443: retcode = 0;
1444: break;
1445:
1446: case XZPRI: /* Print */
1447: if (!atdiso || !atcapr) { /* Disposition attribute off? */
1448: printf("?Disposition Attribute is Off\n");
1449: return(-2);
1450: }
1451: cmarg = "";
1452: cmarg2 = "";
1453: if ((x = cmifi("Local file(s) to print on remote printer","",&s,&y,
1454: xxstring)) < 0) {
1455: if (x == -3) {
1456: printf("?Name of local file(s) required\n");
1457: return(-9);
1458: }
1459: return(x);
1460: }
1461: strcpy(line,s); /* Make a safe copy of filename */
1462: *optbuf = NUL; /* Wipe out any old options */
1463: if ((x = cmtxt("Options for remote print command","",&s,xxstring)) < 0)
1464: return(x);
1465: strcpy(optbuf,s); /* Make a safe copy of options */
1466: if ((int)strlen(optbuf) > 94) { /* Make sure this is legal */
1467: printf("?Option string too long\n");
1468: return(-9);
1469: }
1470: nfils = -1; /* Expand file list internally */
1471: cmarg = line; /* Point to file list. */
1472: rprintf = 1; /* REMOTE PRINT modifier for SEND */
1473: sstate = 's'; /* Set start state to SEND */
1474: if (local) displa = 1;
1475: retcode = 0;
1476: break;
1477: #endif /* NOFRILLS */
1478:
1479: case XZSPA: /* Space */
1480: if ((x = cmtxt("Confirm, or remote directory name","",&s,xxstring)) < 0)
1481: return(x);
1482: retcode = sstate = setgen('U',s,"","");
1483: break;
1484:
1485: #ifndef NOFRILLS
1486: case XZTYP: /* Type */
1487: if ((x = cmtxt("Remote file specification","",&s,xxstring)) < 0)
1488: return(x);
1489: if ((int)strlen(s) < 1) {
1490: printf("?Remote filename required\n");
1491: return(-9);
1492: }
1493: rmsg();
1494: retcode = sstate = rfilop(s,'T');
1495: break;
1496: #endif /* NOFRILLS */
1497:
1498: #ifndef NOFRILLS
1499: case XZWHO:
1500: if ((x = cmtxt("Remote user name, or carriage return","",&s,xxstring)) < 0)
1501: return(x);
1502: retcode = sstate = setgen('W',s,"","");
1503: break;
1504: #endif /* NOFRILLS */
1505:
1506: default:
1507: if ((x = cmcfm()) < 0) return(x);
1508: printf("?Not implemented - %s\n",cmdbuf);
1509: return(-2);
1510: }
1511: if (local) ttflui(); /* If local, flush tty input buffer */
1512: return(retcode);
1513: }
1514:
1515:
1516: /* R F I L O P -- Remote File Operation */
1517:
1518: CHAR
1519: #ifdef CK_ANSIC
1520: rfilop(char * s, char t)
1521: #else
1522: rfilop(s,t) char *s, t;
1523: #endif /* CK_ANSIC */
1524: /* rfilop */ {
1525: if (*s == NUL) {
1526: printf("?File specification required\n");
1527: return((CHAR) 0);
1528: }
1529: debug(F111,"rfilop",s,t);
1530: return(setgen(t,s,"",""));
1531: }
1532:
1533: #ifdef SUNX25
1534: int
1535: setx25() {
1536: if ((y = cmkey(x25tab,nx25,"X.25 call options","",xxstring)) < 0)
1537: return(y);
1538: switch (y) {
1539: case XYUDAT:
1540: if ((z = cmkey(onoff,2,"X.25 call user data","",xxstring))
1541: < 0) return(z);
1542: if (z == 0) {
1543: if ((z = cmcfm()) < 0) return(z);
1544: cudata = 0; /* disable call user data */
1545: return (success = 1);
1546: }
1547: if ((x = cmtxt("X.25 call user data string","",&s,xxstring)) < 0)
1548: return(x);
1549: if ((int)strlen(s) == 0) {
1550: return (-3);
1551: } else if ((int)strlen(s) > MAXCUDATA) {
1552: printf("?The length must be > 0 and <= %d\n",MAXCUDATA);
1553: return(-2);
1554: }
1555: if ((y = cmcfm()) < 0) return(y);
1556: strcpy(udata,s);
1557: cudata = 1; /* X.25 call user data specified */
1558: return (success = 1);
1559: case XYCLOS:
1560: if ((z = cmkey(onoff,2,"X.25 closed user group call","",xxstring))
1561: < 0) return(z);
1562: if (z == 0) {
1563: if ((z = cmcfm()) < 0) return(z);
1564: closgr = -1; /* disable closed user group */
1565: return (success = 1);
1566: }
1567: if ((y = cmnum("0 <= cug index >= 99","",10,&x,xxstring)) < 0)
1568: return(y);
1569: if (x < 0 || x > 99) {
1570: printf("?The choices are 0 <= cug index >= 99\n");
1571: return(-2);
1572: }
1573: if ((y = cmcfm()) < 0) return(y);
1574: closgr = x; /* closed user group selected */
1575: return (success = 1);
1576:
1577: case XYREVC:
1578: if((z = cmkey(onoff,2,"X.25 reverse charge call","",xxstring)) < 0)
1579: return(z);
1580: if ((x = cmcfm()) < 0) return(x);
1581: revcall = z;
1582: return (success = 1);
1583: }
1584: }
1585:
1586: int
1587: setpadp() {
1588: if ((y = cmkey(padx3tab,npadx3,"PAD X.3 parameter name","",xxstring)) < 0)
1589: return(y);
1590: x = y;
1591: switch (x) {
1592: case PAD_BREAK_CHARACTER:
1593: if ((y = cmnum("PAD break character value","",10,&z,xxstring)) < 0)
1594: return(y);
1595: if ((y = cmcfm()) < 0) return(y);
1596: break;
1597: case PAD_ESCAPE:
1598: if ((y = cmnum("PAD escape","",10,&z,xxstring)) < 0) return(y);
1599: if (z != 0 && z != 1) {
1600: printf("?The choices are 0 or 1\n");
1601: return(-2);
1602: }
1603: if ((y = cmcfm()) < 0) return(y);
1604: break;
1605: case PAD_ECHO:
1606: if ((y = cmnum("PAD echo","",10,&z,xxstring)) < 0) return(y);
1607: if (z != 0 && z != 1) {
1608: printf("?The choices are 0 or 1\n");
1609: return(-2);
1610: }
1611: if ((y = cmcfm()) < 0) return(y);
1612: break;
1613: case PAD_DATA_FORWARD_CHAR:
1614: if ((y = cmnum("PAD data forward char","",10,&z,xxstring)) < 0)
1615: return(y);
1616: if (z != 0 && z != 2) {
1617: printf("?The choices are 0 or 2\n");
1618: return(-2);
1619: }
1620: if ((y = cmcfm()) < 0) return(y);
1621: break;
1622: case PAD_DATA_FORWARD_TIMEOUT:
1623: if ((y = cmnum("PAD data forward timeout","",10,&z,xxstring)) < 0)
1624: return(y);
1625: if (z < 0 || z > 255) {
1626: printf("?The choices are 0 or 1 <= timeout <= 255\n");
1627: return(-2);
1628: }
1629: if ((y = cmcfm()) < 0) return(y);
1630: break;
1631: case PAD_FLOW_CONTROL_BY_PAD:
1632: if ((y = cmnum("PAD pad flow control","",10,&z,xxstring)) < 0)
1633: return(y);
1634: if (z != 0 && z != 1) {
1635: printf("?The choices are 0 or 1\n");
1636: return(-2);
1637: }
1638: if ((y = cmcfm()) < 0) return(y);
1639: break;
1640: case PAD_SUPPRESSION_OF_SIGNALS:
1641: if ((y = cmnum("PAD service","",10,&z,xxstring)) < 0) return(y);
1642: if (z != 0 && z != 1) {
1643: printf("?The choices are 0 or 1\n");
1644: return(-2);
1645: }
1646: if ((y = cmcfm()) < 0) return(y);
1647: break;
1648:
1649: case PAD_BREAK_ACTION:
1650: if ((y = cmnum("PAD break action","",10,&z,xxstring)) < 0) return(y);
1651: if (z != 0 && z != 1 && z != 2 && z != 5 && z != 8 && z != 21) {
1652: printf("?The choices are 0, 1, 2, 5, 8 or 21\n");
1653: return(-2);
1654: }
1655: if ((y = cmcfm()) < 0) return(y);
1656: break;
1657:
1658: case PAD_SUPPRESSION_OF_DATA:
1659: if ((y = cmnum("PAD data delivery","",10,&z,xxstring)) < 0) return(y);
1660: if (z != 0 && z != 1) {
1661: printf("?The choices are 0 or 1\n");
1662: return(-2);
1663: }
1664: if ((y = cmcfm()) < 0) return(y);
1665: break;
1666:
1667: case PAD_PADDING_AFTER_CR:
1668: if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
1669: if (z < 0 || z > 7) {
1670: printf("?The choices are 0 or 1 <= crpad <= 7\n");
1671: return(-2);
1672: }
1673: if ((y = cmcfm()) < 0) return(y);
1674: break;
1675:
1676: case PAD_LINE_FOLDING:
1677: if ((y = cmnum("PAD linefold","",10,&z,xxstring)) < 0) return(y);
1678: if (z < 0 || z > 255) {
1679: printf("?The choices are 0 or 1 <= linefold <= 255\n");
1680: return(-2);
1681: }
1682: if ((y = cmcfm()) < 0) return(y);
1683: break;
1684:
1685: case PAD_LINE_SPEED:
1686: if ((y = cmnum("PAD baudrate","",10,&z,xxstring)) < 0) return(y);
1687: if (z < 0 || z > 18) {
1688: printf("?The choices are 0 <= baudrate <= 18\n");
1689: return(-2);
1690: }
1691: if ((y = cmcfm()) < 0) return(y);
1692: break;
1693:
1694: case PAD_FLOW_CONTROL_BY_USER:
1695: if ((y = cmnum("PAD terminal flow control","",10,&z,xxstring)) < 0)
1696: return(y);
1697: if (z != 0 && z != 1) {
1698: printf("?The choices are 0 or 1\n");
1699: return(-2);
1700: }
1701: if ((y = cmcfm()) < 0) return(y);
1702: break;
1703:
1704: case PAD_LF_AFTER_CR:
1705: if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
1706: if (z < 0 || z == 3 || z > 7) {
1707: printf("?The choices are 0, 1, 2, 4, 5, 6 or 7\n");
1708: return(-2);
1709: }
1710: if ((y = cmcfm()) < 0) return(y);
1711: break;
1712:
1713: case PAD_PADDING_AFTER_LF:
1714: if ((y = cmnum("PAD lfpad","",10,&z,xxstring)) < 0) return(y);
1715: if (z < 0 || z > 7) {
1716: printf("?The choices are 0 or 1 <= lfpad <= 7\n");
1717: return(-2);
1718: }
1719: if ((y = cmcfm()) < 0) return(y);
1720: break;
1721:
1722: case PAD_EDITING:
1723: if ((y = cmnum("PAD edit control","",10,&z,xxstring)) < 0) return(y);
1724: if (z != 0 && z != 1) {
1725: printf("?The choices are 0 or 1\n");
1726: return(-2);
1727: }
1728: if ((y = cmcfm()) < 0) return(y);
1729: break;
1730:
1731: case PAD_CHAR_DELETE_CHAR:
1732: if ((y = cmnum("PAD char delete char","",10,&z,xxstring)) < 0)
1733: return(y);
1734: if (z < 0 || z > 127) {
1735: printf("?The choices are 0 or 1 <= chardelete <= 127\n");
1736: return(-2);
1737: }
1738: if ((y = cmcfm()) < 0) return(y);
1739: break;
1740:
1741: case PAD_BUFFER_DELETE_CHAR:
1742: if ((y = cmnum("PAD buffer delete char","",10,&z,xxstring)) < 0)
1743: return(y);
1744: if (z < 0 || z > 127) {
1745: printf("?The choices are 0 or 1 <= bufferdelte <= 127\n");
1746: return(-2);
1747: }
1748: if ((y = cmcfm()) < 0) return(y);
1749: break;
1750:
1751: case PAD_BUFFER_DISPLAY_CHAR:
1752: if ((y = cmnum("PAD display line char","",10,&z,xxstring)) < 0)
1753: return(y);
1754: if (z < 0 || z > 127) {
1755: printf("?The choices are 0 or 1 <= displayline <= 127\n");
1756: return(-2);
1757: }
1758: if ((y = cmcfm()) < 0) return(y);
1759: break;
1760: }
1761: padparms[x] = z;
1762: return(success = 1);
1763: }
1764: #endif /* SUNX25 */
1765:
1766: int
1767: setat(rmsflg) int rmsflg; {
1768: int xx;
1769: if ((y = cmkey(attrtab,natr,"File Attribute packets","",xxstring)) < 0)
1770: return(y);
1771: if (y == AT_XALL) { /* ATTRIBUTES ALL ON or ALL OFF */
1772: if ((z = seton(&xx)) < 0) return(z);
1773: if (rmsflg) {
1774: printf("Sorry, command not available\n");
1775: return(-9);
1776: } else {
1777: atenci = xx; /* Encoding in */
1778: atenco = xx; /* Encoding out */
1779: atdati = xx; /* Date in */
1780: atdato = xx; /* Date out */
1781: atdisi = xx; /* Disposition in/out */
1782: atdiso = xx;
1783: atleni = xx; /* Length in/out (both kinds) */
1784: atleno = xx;
1785: atblki = xx; /* Blocksize in/out */
1786: atblko = xx;
1787: attypi = xx; /* File type in/out */
1788: attypo = xx;
1789: atsidi = xx; /* System ID in/out */
1790: atsido = xx;
1791: atsysi = xx; /* System-dependent params in/out */
1792: atsyso = xx;
1793: }
1794: return(z);
1795: } else if (y == AT_ALLY || y == AT_ALLN) { /* ATTRIBUTES ON or OFF */
1796: if ((x = cmcfm()) < 0) return(x);
1797: atcapr = (y == AT_ALLY) ? 1 : 0;
1798: if (rmsflg) {
1799: sstate = setgen('S', "132", atcapr ? "1" : "0", "");
1800: return((int) sstate);
1801: } else return(success = 1);
1802: }
1803: /* Otherwise, it's an individual attribute that wants turning off/on */
1804:
1805: if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
1806: if ((x = cmcfm()) < 0) return(x);
1807:
1808: /* There are better ways to do this... */
1809: /* The real problem is that we're not separating the in and out cases */
1810: /* and so we have to arbitrarily pick the "in" case, i.e tell the remote */
1811: /* server to ignore incoming attributes of the specified type, rather */
1812: /* than telling it not to send them. The protocol does not (yet) define */
1813: /* codes for "in-and-out-at-the-same-time". */
1814:
1815: switch(y) {
1816: case AT_DISP:
1817: if (rmsflg) {
1818: sstate = setgen('S', "142", z ? "1" : "0", "");
1819: return((int) sstate);
1820: }
1821: atdisi = atdiso = z; break;
1822: case AT_ENCO:
1823: if (rmsflg) {
1824: sstate = setgen('S', "141", z ? "1" : "0", "");
1825: return((int) sstate);
1826: }
1827: atenci = atenco = z; break;
1828: case AT_DATE:
1829: if (rmsflg) {
1830: sstate = setgen('S', "135", z ? "1" : "0", "");
1831: return((int) sstate);
1832: }
1833: atdati = atdato = z; break;
1834: case AT_LENB:
1835: case AT_LENK:
1836: if (rmsflg) {
1837: sstate = setgen('S', "133", z ? "1" : "0", "");
1838: return((int) sstate);
1839: }
1840: atleni = atleno = z; break;
1841: case AT_BLKS:
1842: if (rmsflg) {
1843: sstate = setgen('S', "139", z ? "1" : "0", "");
1844: return((int) sstate);
1845: }
1846: atblki = atblko = z; break;
1847: case AT_FTYP:
1848: if (rmsflg) {
1849: sstate = setgen('S', "134", z ? "1" : "0", "");
1850: return((int) sstate);
1851: }
1852: attypi = attypo = z; break;
1853: case AT_SYSI:
1854: if (rmsflg) {
1855: sstate = setgen('S', "145", z ? "1" : "0", "");
1856: return((int) sstate);
1857: }
1858: atsidi = atsido = z; break;
1859: case AT_SYSP:
1860: if (rmsflg) {
1861: sstate = setgen('S', "147", z ? "1" : "0", "");
1862: return((int) sstate);
1863: }
1864: atsysi = atsyso = z; break;
1865: default:
1866: printf("?Not available\n");
1867: return(-2);
1868: }
1869: return(1);
1870: }
1871:
1872: #ifndef NOSPL
1873: int
1874: setinp() {
1875: if ((y = cmkey(inptab,ninp,"","",xxstring)) < 0) return(y);
1876: switch (y) {
1877: case IN_DEF: /* SET INPUT DEFAULT-TIMEOUT */
1878: z = cmnum("Positive number","",10,&x,xxstring);
1879: return(success = setnum(&indef,x,z,94));
1880: case IN_TIM: /* SET INPUT TIMEOUT-ACTION */
1881: if ((z = cmkey(intimt,2,"","",xxstring)) < 0) return(z);
1882: if ((x = cmcfm()) < 0) return(x);
1883: intime = z;
1884: return(success = 1);
1885: case IN_CAS: /* SET INPUT CASE */
1886: if ((z = cmkey(incast,2,"","",xxstring)) < 0) return(z);
1887: if ((x = cmcfm()) < 0) return(x);
1888: incase = z;
1889: return(success = 1);
1890: case IN_ECH: /* SET INPUT ECHO */
1891: return(success = seton(&inecho));
1892: case IN_SIL: /* SET INPUT SILENCE */
1893: z = cmnum("Positive number","",10,&x,xxstring);
1894: return(success = setnum(&insilence,x,z,-1));
1895: }
1896: return(0);
1897: }
1898: #endif /* NOSPL */
1899:
1900: /*
1901: setlin -- parse name of and then open a communication device.
1902: Call with:
1903: xx == XXLINE for a serial (tty) line, XXHOST for a network host,
1904: zz == 0 means if user doesn't give a device name, continue current
1905: active connection (if any);
1906: zz != 0 means if user doesn't give a device name, then close the
1907: current connection and restore the default communication device.
1908: */
1909: int
1910: setlin(xx, zz) int xx, zz; {
1911: if (xx == XYHOST) { /* SET HOST <hostname> */
1912: #ifndef NETCONN
1913: printf("?Network connections not supported\n");
1914: return(-9);
1915: #else
1916: if (
1917: (nettype != NET_DEC) &&
1918: (nettype != NET_SX25) &&
1919: (nettype != NET_TCPB)) {
1920: printf("?Network type not supported\n");
1921: return(-9);
1922: }
1923: if (nettype != NET_TCPB) { /* Not a TCP/IP connection */
1924: /* Just get a text string */
1925: if ((x = cmtxt( zz ?
1926: "Network host name,\n or carriage return to close an open connection" :
1927: "Network host name,\n or carriage return to resume an open connection",
1928: "",&s,xxstring)) < 0)
1929: return(x);
1930:
1931: } else { /* TCP/IP connection... */
1932:
1933: /* Parse for host and service separately. */
1934:
1935: if ((x = cmfld( zz ?
1936: "IP host name or number,\n or carriage return to close an open connection" :
1937: "IP host name or number,\n or carriage return to resume an open connection",
1938: "",&s,xxstring)) < 0) {
1939: if (x != -3) /* Parse error */
1940: return(x); /* return it */
1941: else if (!zz) /* No hostname given */
1942: return(1); /* and none required, */
1943: } /* continue current connection. */
1944: if (*s) { /* If they gave a host name... */
1945: strcpy(line,s); /* make a copy */
1946: /* Check for "host:service" */
1947: for ( ; (*s != '\0') && (*s != ':'); s++) ;
1948:
1949: /* If no service given, let them type one now. */
1950:
1951: if (!*s) {
1952: if ((x = cmfld(
1953: "TCP service name or number,\n or carriage return for telnet (23)",
1954: "23",&s,xxstring)) < 0 && x != -3)
1955: return(x);
1956: if (*s) { /* If they gave a service, */
1957: strcat(line,":"); /* concatenate it to the hostname */
1958: strcat(line,s); /* separated by a colon, because */
1959: } /* this is how ttopen() wants it. */
1960: }
1961: if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
1962: s = line;
1963: }
1964: }
1965:
1966: /* New connection wanted. */
1967:
1968: ttflui(); /* Clear away buffered up junk */
1969: ttclos(0); /* Close old connection, if any */
1970: if (oldplex > -1) /* Restore duplex setting. */
1971: duplex = oldplex;
1972: if (*s) { /* They gave a hostname */
1973: x = 1; /* Network connection always local */
1974: mdmsav = mdmtyp; /* Remember old modem type */
1975: mdmtyp = -nettype; /* Special code for network */
1976: if (nettype == NET_TCPB) { /* For TCP/IP telnet connections */
1977: oldplex = duplex; /* Remember previous duplex */
1978: duplex = 0; /* Set full duplex and let */
1979: } /* negotiations change if necessary. */
1980: } else { /* They just said "set host" */
1981: if (network && msgflg)
1982: printf(" Closing connection\n");
1983: s = dftty; /* So go back to normal */
1984: x = dfloc; /* default tty, location, */
1985: network = 0; /* No more network connection. */
1986: duplex = oldplex; /* Restore old duplex setting. */
1987: if (mdmtyp < 0) { /* Switching from net to async? */
1988: if (mdmsav > -1) /* Restore modem type from last */
1989: mdmtyp = mdmsav; /* SET MODEM command, if any. */
1990: else
1991: mdmtyp = 0;
1992: }
1993: }
1994: #endif /* NETCONN */
1995: }
1996:
1997: /* Serial tty device, possibly modem, connection... */
1998:
1999: if (xx == XYLINE) { /* SET LINE */
2000: #ifdef OS2 /* or SET PORT */
2001: if ((x = cmkey(os2devtab,nos2dev,"serial communication device name",
2002: "com1", xxstring)) < 0) {
2003: debug(F101,"OS2 SET PORT x","",x);
2004: if (x != -9) return(x);
2005: s = atxbuf; /* Doesn't match keyword */
2006: if (*s == '_') s++; /* Secret notation for file handle */
2007: else return(-9);
2008: } else if (x >= 1 && x <= 8) { /* Regular COM port */
2009: s = os2devtab[x+7].kwd; /* Use its real name */
2010: } else s = atxbuf; /* Something else, believe it */
2011: #else
2012: if ((x = cmtxt("Communication device name",dftty,&s,xxstring)) < 0)
2013: return(x);
2014: #endif /* OS2 */
2015:
2016: if (local) ttflui(); /* Clear away buffered up junk */
2017: ttclos(0); /* Close old line, if any was open */
2018: if (*s) { /* They gave a device name */
2019: x = -1; /* Let ttopen decide about it */
2020: } else { /* They just said "set line" */
2021: s = dftty; /* so go back to normal tty */
2022: x = dfloc; /* and mode. */
2023: }
2024: if (mdmtyp < 0) { /* Switching from net to async? */
2025: if (mdmsav > -1) /* Restore modem type from last */
2026: mdmtyp = mdmsav; /* SET MODEM command, if any. */
2027: else
2028: mdmtyp = 0;
2029: mdmsav = -1;
2030: }
2031: if (oldplex > -1) { /* Restore previous duplex setting. */
2032: duplex = oldplex;
2033: oldplex = -1;
2034: }
2035: network = 0; /* No more network. */
2036: }
2037: #ifdef COMMENT
2038: /*
2039: The following is removed, not so much because it's a horrible hack, but
2040: because it only works if the SET FLOW command was given *before* the SET
2041: LINE command, whereas normally these commands can be given in any order.
2042: */
2043: #ifdef NEXT
2044: /*
2045: This is a horrible hack, but it's nice for users. On the NeXT, you select
2046: RTS/CTS hardware flow control not by system calls, but by referring to the
2047: device with a different name. If the user has asked for RTS/CTS flow
2048: control on a NeXT, but used the non-RTS/CTS device name in the SET LINE
2049: command, we make the appropriate substitute here. I wonder how much bigger
2050: this section of code will grow as the years go by...
2051: */
2052: if ((flow == FLO_RTSC) && /* RTS/CTS flow control selected */
2053: strcmp(s,dftty)) { /* ...on external port? */
2054: y = strlen(s); /* Yes, insert "f" as next-to-last */
2055: if (s[y-2] != 'f') { /* character in device name if not */
2056: strcpy(line,s); /* already there... */
2057: line[y] = line[y-1]; /* So /dev/cua => /dev/cufa, etc. */
2058: line[y-1] = 'f';
2059: line[y+1] = '\0';
2060: s = line;
2061: }
2062: }
2063: #endif /* NEXT */
2064: #endif /* COMMENT */
2065:
2066: if ((y = ttopen(s,&x,mdmtyp,cdtimo)) < 0 ) { /* Open the new line */
2067: if (y == -2) {
2068: printf("?Timed out, no carrier.\n");
2069: printf("Try SET CARRIER OFF and SET LINE again, or else\n");
2070: printf("SET MODEM, SET LINE, and then DIAL.\n");
2071: } else if (y == -3) {
2072: printf("Sorry, access to lock denied: %s\n",s);
2073: } else if (y == -4) {
2074: printf("Sorry, access to device denied: %s\n",s);
2075: } else if (y == -5) {
2076: #ifdef VMS
2077: printf("Sorry, device is in use or otherwise unavailable: %s\n",s);
2078: #else
2079: printf("Sorry, device is in use: %s\n",s);
2080: #endif /* VMS */
2081: } else { /* Other error. */
2082: #ifndef VMS
2083: if (errno) {
2084: tp = tmpbuf;
2085: sprintf(tp,"Sorry, can't open connection: %s",s);
2086: perror(tp);
2087: } else
2088: #endif /* VMS */
2089: printf("Sorry, can't open connection: %s\n",s);
2090: }
2091: local = dfloc; /* Go back to normal */
2092: #ifndef MAC
2093: strcpy(ttname,dftty); /* Restore default tty name */
2094: #endif /* MAC */
2095: speed = ttgspd();
2096: network = 0; /* No network connection active */
2097: return(success = 0); /* Return failure */
2098: }
2099: if (x > -1) local = x; /* Opened ok, set local/remote. */
2100: network = (mdmtyp < 0); /* Remember connection type. */
2101: #ifdef TNCODE
2102: if (network) tn_init = 0; /* Say telnet not init'd yet. */
2103: #endif /* TNCODE */
2104: strcpy(ttname,s); /* Copy name into real place. */
2105: speed = ttgspd(); /* Get the current speed. */
2106: debug(F111,"set line ",ttname,local);
2107: #ifdef NETCONN
2108: #ifdef SUNX25
2109: if (nettype == NET_SX25) duplex = 1; /* Duplex half */
2110: #endif /* SUNX25 */
2111: #endif /* NETCONN */
2112: return(success = 1);
2113: }
2114: #endif /* NOICP */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.