ckuus7.c
资源名称:cku197.tar.Z [点击查看]
上传用户:dufan58
上传日期:2007-01-05
资源大小:3407k
文件大小:362k
源码类别:
通讯/手机编程
开发平台:
Windows_Unix
- }
- }
- if (x > 8192/(tt_rows[VTERM]+1)) {
- printf(
- "n?The max screen area is 8192 cells: %d(rows) x %d(cols) = %d cells.n",
- tt_rows[VTERM]+1,x,x*(tt_rows[VTERM]+1));
- return(success = 0);
- }
- tt_cols[VTERM] = x;
- tt_cols_usr = x;
- VscrnSetWidth( VTERM, x);
- #ifdef TNCODE
- if (TELOPT_ME(TELOPT_NAWS))
- tn_snaws();
- #endif /* TNCODE */
- #ifdef RLOGCODE
- if (TELOPT_ME(TELOPT_NAWS))
- rlog_naws();
- #endif /* RLOGCODE */
- /*
- We do not set tt_szchng here because that would result in the screen buffer
- being reallocated and the screen cleared. But that is not necessary when
- only the screen width is being changed since the buffer allocates the full
- width
- */
- #else /* Not OS/2 */
- tt_cols = x;
- #endif /* OS2 */
- return(success = 1);
- }
- case XYTHIG:
- if ((y = cmnum(
- #ifdef OS2
- "number of rows in display window during CONNECT, not including status line",
- tt_status?"24":"25",
- #else
- "24","number of rows on your screen",
- #endif /* OS2 */
- 10,&x,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- #ifdef OS2
- if (tt_modechg == TVC_DIS) {
- printf("n?SET TERMINAL VIDEO-CHANGE DISABLEDn");
- return(success = 0);
- }
- if (IsOS2FullScreen()) {
- if (tt_status && x != 24 && x != 42 && x != 49 && x != 59) {
- printf("n?The height must be 24, 42, 49");
- #ifdef NT
- printf(" or 59 under Windows 95.n.");
- #else /* NT */
- printf(" or 59 in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- } else if (!tt_status &&
- x != 25 &&
- x != 43 &&
- x != 50) {
- printf("n?The height must be 25, 43, 50");
- #ifdef NT
- printf(" or 60 under Windows 95.n.");
- #else /* NT */
- printf(" or 60 in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- }
- } else if (tt_modechg == TVC_W95) {
- if (tt_status && x != 24 && x != 42 && x != 49) {
- printf("n?The height must be 24, 42, 49");
- #ifdef NT
- printf(" under Windows 95.n.");
- #else /* NT */
- printf(" in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- } else if (!tt_status &&
- x != 25 &&
- x != 43 &&
- x != 50) {
- printf("n?The height must be 25, 43, 50");
- #ifdef NT
- printf(" under Windows 95.n.");
- #else /* NT */
- printf(" in a Full Screen session.n.");
- #endif /* NT */
- return(success = 0);
- }
- } else {
- if (x < 8 || x > MAXTERMROW ) {
- printf("n?The height must be between 8 and %dn.",MAXTERMROW);
- return(success = 0);
- }
- }
- if (x > 8192/tt_cols[VTERM]) {
- printf(
- "n?The max screen area is 8192 cells: %d(rows) x %d(cols) = %d cells.n",
- x,tt_cols[VTERM],x*tt_cols[VTERM]);
- return(success = 0);
- }
- tt_szchng[VTERM] = 1;
- tt_rows[VTERM] = x;
- VscrnInit( VTERM ); /* Height set here */
- #ifdef TNCODE
- if (TELOPT_ME(TELOPT_NAWS))
- tn_snaws();
- #endif /* TNCODE */
- #ifdef RLOGCODE
- if (TELOPT_ME(TELOPT_NAWS))
- rlog_naws();
- #endif /* RLOGCODE */
- #else /* Not OS/2 */
- tt_rows = x;
- #endif /* OS2 */
- return(success = 1);
- #ifdef OS2
- case XYTPRN: { /* Print Mode */
- extern bool xprint, cprint, aprint, uprint;
- if ((y = cmkey(prnmtab,nprnmtab,"","off", xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- switch (y) {
- case 0:
- if (cprint || uprint || aprint || xprint)
- printeroff();
- cprint = xprint = uprint = aprint = 0;
- break;
- case 1:
- if (!(cprint || uprint || aprint || xprint))
- printeron();
- aprint = 1;
- cprint = xprint = uprint = 0;
- break;
- case 2:
- if (!(cprint || uprint || aprint || xprint))
- printeron();
- cprint = 1;
- aprint = xprint = uprint = 0;
- break;
- case 3:
- if (!(cprint || uprint || aprint || xprint))
- printeron();
- uprint = 1;
- aprint = xprint = cprint = 0;
- break;
- }
- return(1);
- }
- #else
- #ifdef XPRINT
- case XYTPRN: {
- extern int tt_print;
- if ((x = seton(&tt_print)) < 0)
- return(x);
- return(success = 1);
- }
- #endif /* XPRINT */
- #endif /* OS2 */
- #ifdef OS2
- case XYTSCNM: {
- extern int decscnm, decscnm_usr;
- if ((y = cmkey(normrev,4,"",
- decscnm_usr?"reverse":"normal",
- xxstring)
- ) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- decscnm_usr = y;
- if (decscnm != decscnm_usr)
- flipscreen(VTERM);
- return(1);
- }
- case XYTOPTI:
- if ((y = cmkey(onoff,2,"",tt_diff_upd?"on":"off",
- xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- tt_diff_upd = y;
- return(1);
- case XYTUPD: {
- int mode, delay;
- if ((mode = cmkey(scrnupd,nscrnupd,"","fast",xxstring)) < 0) {
- return(mode);
- } else {
- y = cmnum(
- "Pause between FAST screen updates in CONNECT mode, milliseconds",
- "100",10,&x,xxstring
- );
- if (x < 0 || x > 1000 ) {
- printf(
- "n?The update rate must be between 0 and 1000 milliseconds.n"
- );
- return(success = 0);
- }
- if ((y = cmcfm()) < 0) return(y);
- updmode = tt_updmode = mode;
- return(setnum(&tt_update,x,y,10000));
- }
- }
- case XYTCTRL:
- if ((x = cmkey(termctrl,ntermctrl,"","7",xxstring)) < 0) {
- return(x);
- } else {
- if ((y = cmcfm()) < 0)
- return(y);
- switch ( x ) {
- case 8:
- send_c1 = send_c1_usr = TRUE;
- break;
- case 7:
- default:
- send_c1 = send_c1_usr = FALSE;
- break;
- }
- }
- return(success = TRUE);
- break;
- #ifdef PCFONTS
- case XYTFON:
- if ( !IsOS2FullScreen() ) {
- printf(
- "n?SET TERMINAL FONT is only supported in Full Screen sessions.n");
- return(success = FALSE);
- }
- if ((x = cmkey(termfont,ntermfont,"","default",xxstring)) < 0) {
- return(x);
- } else {
- if ((y = cmcfm()) < 0) return(y);
- if ( !os2LoadPCFonts() ) {
- tt_font = x;
- return(success = TRUE);
- } else {
- printf(
- "n?PCFONTS.DLL is not available in CKERMIT executable directory.n");
- return(success = FALSE);
- }
- }
- break;
- #endif /* PCFONTS */
- case XYTVCH: {
- extern int pheight, marginbot, cmd_rows, cmd_cols;
- if ((x = cmkey(tvctab,ntvctab,"",isWin95()?"win95-safe":"enabled",
- xxstring)) < 0)
- return(x);
- if ((y = cmcfm()) < 0) return(y);
- if (x != tt_modechg) {
- switch (x) {
- case TVC_DIS:
- /* When disabled the heights of all of the virtual screens */
- /* must be equal to the physical height of the console */
- /* window and may not be changed. */
- /* The width of the window may not be altered. */
- tt_modechg = TVC_ENA; /* Termporary */
- if (marginbot > pheight-(tt_status?1:0))
- marginbot = pheight-(tt_status?1:0);
- tt_szchng[VCMD] = 1 ;
- tt_rows[VCMD] = pheight;
- VscrnInit(VCMD);
- SetCols(VCMD);
- cmd_rows = y;
- tt_szchng[VTERM] = 2 ;
- tt_rows[VTERM] = pheight - (tt_status?1:0);
- VscrnInit(VTERM);
- break;
- case TVC_ENA:
- /* When enabled the physical height of the console windows */
- /* should be adjusted to the height of the virtual screen */
- /* The width may be set to anything. */
- /* nothing to do */
- break;
- case TVC_W95:
- /* Win95-safe mode allows the physical height to change */
- /* but restricts it to a width of 80 and a height equal to */
- /* 25, 43, or 50. Must be adjusted now. */
- /* The virtual heights must be equal to the above. */
- if (pheight != 25 && pheight != 43 && pheight != 50) {
- if (pheight < 25)
- y = 25;
- else if (pheight < 43)
- y = 43;
- else
- y = 50;
- } else
- y = pheight;
- tt_modechg = TVC_ENA; /* Temporary */
- tt_szchng[VCMD] = 1;
- tt_rows[VCMD] = y;
- tt_cols[VCMD] = 80;
- VscrnInit(VCMD);
- SetCols(VCMD);
- cmd_rows = y;
- cmd_cols = 80;
- marginbot = y-(tt_status?1:0);
- tt_szchng[VTERM] = 2;
- tt_rows[VTERM] = y - (tt_status?1:0);
- tt_cols[VTERM] = 80;
- VscrnInit(VTERM);
- break;
- }
- tt_modechg = x;
- }
- return(1);
- }
- case XYTSTAT: {
- extern int marginbot;
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (y != tt_status || y != tt_status_usr) {
- /* Might need to fixup the margins */
- if ( marginbot == VscrnGetHeight(VTERM)-(tt_status?1:0) )
- if (y) {
- marginbot--;
- } else {
- marginbot++;
- }
- tt_status_usr = tt_status = y;
- if (y) {
- tt_szchng[VTERM] = 2;
- tt_rows[VTERM]--;
- VscrnInit(VTERM); /* Height set here */
- #ifdef TNCODE
- if (TELOPT_ME(TELOPT_NAWS))
- tn_snaws();
- #endif /* TNCODE */
- #ifdef RLOGCODE
- if (TELOPT_ME(TELOPT_NAWS))
- rlog_naws();
- #endif /* RLOGCODE */
- } else {
- tt_szchng[VTERM] = 1;
- tt_rows[VTERM]++;
- VscrnInit(VTERM); /* Height set here */
- #ifdef TNCODE
- if (TELOPT_ME(TELOPT_NAWS))
- tn_snaws();
- #endif /* TNCODE */
- #ifdef RLOGCODE
- if (TELOPT_ME(TELOPT_NAWS))
- rlog_naws();
- #endif /* RLOGCODE */
- }
- }
- return(1);
- }
- #endif /* OS2 */
- #ifdef NT
- case XYTATTBUG:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- tt_attr_bug = y;
- return(1);
- #endif /* NT */
- #ifdef OS2
- case XYTSGRC:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- sgrcolors = y;
- return(1);
- case XYTSEND:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- tt_senddata = y;
- return(1);
- case XYTSEOB:
- if ((y = cmkey(ttyseobtab,2,"","us_cr",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- wy_blockend = y;
- return(1);
- case XYTATTR:
- if ((x = cmkey(ttyattrtab,nattrib,"","underline",xxstring)) < 0)
- return(x);
- switch (x) {
- case TTATTBLI:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- trueblink = y;
- #ifndef KUI
- if ( !trueblink && trueunderline ) {
- trueunderline = 0;
- printf("Warning: Underline being simulated by color.n");
- }
- #endif /* KUI */
- break;
- case TTATTREV:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- truereverse = y;
- break;
- case TTATTUND:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- trueunderline = y;
- #ifndef KUI
- if (!trueblink && trueunderline) {
- trueblink = 1;
- printf("Warning: True blink mode is active.n");
- }
- #endif /* KUI */
- break;
- case TTATTPRO: { /* Set default Protected Character attribute */
- extern vtattrib WPattrib; /* current WP Mode Attrib */
- extern vtattrib defWPattrib; /* default WP Mode Attrib */
- vtattrib wpa = {0,0,0,0,0,1,0,0,0}; /* Protected */
- int done = 0;
- x = 0;
- while (!done) {
- if ((y = cmkey(ttyprotab,nprotect,"",
- x?"done":"dim",xxstring)) < 0)
- return(y);
- switch (y) {
- case TTATTNOR:
- break;
- case TTATTBLI: /* Blinking doesn't work */
- wpa.blinking = TRUE;
- break;
- case TTATTREV:
- wpa.reversed = TRUE;
- break;
- case TTATTUND:
- wpa.underlined = TRUE;
- break;
- case TTATTBLD:
- wpa.bold = TRUE;
- break;
- case TTATTDIM:
- wpa.dim = TRUE;
- break;
- case TTATTINV:
- wpa.invisible = TRUE ;
- break;
- case TTATTDONE:
- done = TRUE;
- break;
- }
- x = 1; /* One attribute has been chosen */
- }
- if ((x = cmcfm()) < 0) return(x);
- WPattrib = defWPattrib = wpa;
- break;
- }
- }
- return(1);
- case XYTKEY: { /* SET TERMINAL KEY */
- int t, x, y;
- int clear = 0, deflt = 0;
- int confirmed = 0;
- int flag = 0;
- int kc = -1; /* Key code */
- int litstr = 0; /* Literal String? */
- char *s = NULL; /* Key binding */
- #ifndef NOKVERBS
- char *p = NULL; /* Worker */
- #endif /* NOKVERBS */
- con_event defevt;
- extern int os2gks;
- extern int mskkeys;
- extern int initvik;
- struct FDB kw,sw,nu,cm;
- defevt.type = error;
- if ((t = cmkey(ttkeytab,nttkey,"","",xxstring)) < 0)
- return(t);
- cmfdbi(&nu, /* First FDB - command switches */
- _CMNUM, /* fcode */
- "/literal, keycode, or action",
- "", /* default */
- "", /* addtl string data */
- 10, /* addtl numeric data 1: radix */
- 0, /* addtl numeric data 2: 0 */
- xxstring, /* Processing function */
- NULL, /* Keyword table */
- &sw /* Pointer to next FDB */
- ); /* */
- cmfdbi(&sw, /* Second FDB - switches */
- _CMKEY, /* fcode */
- "",
- "", /* default */
- "", /* addtl string data */
- nstrmswitab, /* addtl numeric data 1: tbl size */
- 4, /* addtl numeric data 2: 4 = cmswi */
- xxstring, /* Processing function */
- strmswitab, /* Keyword table */
- &kw /* Pointer to next FDB */
- );
- cmfdbi(&kw, /* Third FDB - command switches */
- _CMKEY, /* fcode */
- "/literal, keycode, or action",
- "", /* default */
- "", /* addtl string data */
- nstrmkeytab, /* addtl numeric data 1: tbl size */
- 0, /* addtl numeric data 2 */
- xxstring, /* Processing function */
- strmkeytab, /* Keyword table */
- &cm /* Pointer to next FDB */
- );
- cmfdbi(&cm, /* Final FDB - Confirmation */
- _CMCFM, /* fcode */
- "",
- "", /* default */
- "", /* addtl string data */
- 0, /* addtl numeric data 1: tbl size */
- 0, /* addtl numeric data 2: 4 = cmswi */
- xxstring, /* Processing function */
- NULL, /* Keyword table */
- NULL /* Pointer to next FDB */
- );
- while (kc < 0) {
- x = cmfdb(&nu); /* Parse something */
- if (x < 0)
- return(x);
- switch (cmresult.fcode) {
- case _CMCFM:
- printf(" Press key to be defined: ");
- conbin((char)escape); /* Put terminal in binary mode */
- os2gks = 0; /* Turn off Kverb preprocessing */
- kc = congks(0); /* Get character or scan code */
- os2gks = 1; /* Turn on Kverb preprocessing */
- concb((char)escape); /* Restore terminal to cbreak mode */
- if (kc < 0) { /* Check for error */
- printf("?Error reading keyn");
- return(0);
- }
- shokeycode(kc,t); /* Show current definition */
- flag = 1; /* Remember it's a multiline command */
- break;
- case _CMNUM:
- kc = cmresult.nresult;
- break;
- case _CMKEY:
- if (cmresult.fdbaddr == &sw) { /* Switch */
- if (cmresult.nresult == 0)
- litstr = 1;
- } else if (cmresult.fdbaddr == &kw) { /* Keyword */
- if (cmresult.nresult == 0)
- clear = 1;
- else
- deflt = 1;
- if ((x = cmcfm()) < 0)
- return(x);
- if (clear)
- clearkeymap(t);
- else if (deflt)
- defaultkeymap(t);
- initvik = 1;
- return(1);
- }
- }
- }
- /* Normal SET TERMINAL KEY <terminal> <scancode> <value> command... */
- if (mskkeys)
- kc = msktock(kc);
- if (kc < 0 || kc >= KMSIZE) {
- printf("?key code must be between 0 and %dn", KMSIZE - 1);
- return(-9);
- }
- if (kc == escape) {
- printf("Sorry, %d is the CONNECT-mode escape charactern",kc);
- return(-9);
- }
- wideresult = -1;
- if (flag) {
- cmsavp(psave,PROMPTL);
- cmsetp(" Enter new definition: ");
- cmini(ckxech);
- }
- def_again:
- if (flag) prompt(NULL);
- if ((y = cmtxt("key definition,n
- or Ctrl-C to cancel this command,n
- or Enter to restore default definition",
- "",&s,NULL)) < 0) {
- if (flag) /* Handle parse errors */
- goto def_again;
- else
- return(y);
- }
- s = brstrip(s);
- #ifndef NOKVERBS
- p = s; /* Save this place */
- #endif /* NOKVERBS */
- /*
- If the definition included any Kverbs, quote the backslash so the Kverb
- will still be in the definition when the key is pressed. We don't do this
- in zzstring(), because Kverbs are valid only in this context and nowhere
- else.
- We use this code active for all versions that support SET KEY, even if they
- don't support Kverbs, because otherwise K would behave differently for
- different versions.
- */
- for (x = 0, y = 0; s[x]; x++, y++) { /* Convert K to \K */
- if ((x > 0) &&
- (s[x] == 'K' || s[x] == 'k')
- ) { /* Have K */
- if ((x == 1 && s[x-1] == CMDQ) ||
- (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
- line[y++] = CMDQ; /* Make it \K */
- }
- if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
- line[y-1] = CMDQ; /* Have {K */
- line[y++] = '{'; /* Make it \{K */
- }
- }
- line[y] = s[x];
- }
- line[y++] = NUL; /* Terminate */
- s = line + y + 1; /* Point to after it */
- x = LINBUFSIZ - (int) strlen(line) - 1; /* Get remaining space */
- if ((x < (LINBUFSIZ / 2)) ||
- (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
- printf("?Key definition too longn");
- if (flag) cmsetp(psave);
- return(-9);
- }
- s = line + y + 1; /* Point to result. */
- #ifndef NOKVERBS
- /*
- Special case: see if the definition starts with a Kverb.
- If it does, point to it with p, otherwise set p to NULL.
- */
- p = s;
- if (*p++ == CMDQ) {
- if (*p == '{') p++;
- p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
- }
- #endif /* NOKVERBS */
- switch (strlen(s)) { /* Action depends on length */
- case 0: /* Clear individual key def */
- deletekeymap(t,kc);
- break;
- case 1:
- if (!litstr) {
- defevt.type = key; /* Single character */
- defevt.key.scancode = *s;
- break;
- }
- default: /* Character string */
- #ifndef NOKVERBS
- if (p) {
- y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
- /* Need exact match */
- debug(F101,"set key kverb lookup",0,y);
- if (y > -1) {
- defevt.type = kverb;
- defevt.kverb.id = y;
- break;
- }
- }
- #endif /* NOKVERBS */
- if (litstr) {
- defevt.type = literal;
- defevt.literal.string = (char *) malloc(strlen(s)+1);
- if (defevt.literal.string)
- strcpy(defevt.literal.string, s);
- } else {
- defevt.type = macro;
- defevt.macro.string = (char *) malloc(strlen(s)+1);
- if (defevt.macro.string)
- strcpy(defevt.macro.string, s);
- }
- break;
- }
- insertkeymap(t, kc, defevt);
- if (flag)
- cmsetp(psave);
- initvik = 1; /* Update VIK table */
- return(1);
- }
- #ifdef PCTERM
- case XYTPCTERM: /* PCTERM Keyboard Mode */
- if ((x = seton(&tt_pcterm)) < 0) return(x);
- return(success = 1);
- #endif /* PCTERM */
- #endif /* OS2 */
- #ifdef CK_TRIGGER
- case XYTRIGGER:
- if ((y = cmtxt("String to trigger automatic return to command mode",
- "",&s,xxstring)) < 0)
- return(y);
- makelist(s,tt_trigger,TRIGGERS);
- return(1);
- #endif /* CK_TRIGGER */
- #ifdef OS2
- case XYTSAC:
- if ((y = cmnum("ASCII value to use for spacing attributes",
- "32",10,&x,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- tt_sac = x;
- return(success = 1);
- case XYTKBDGL: { /* SET TERM KBD-FOLLOWS-GL/GR */
- extern int tt_kb_glgr; /* from ckoco3.c */
- if ((x = seton(&tt_kb_glgr)) < 0)
- return(x);
- return(success = 1);
- }
- #ifndef NOCSETS
- case XYTVTLNG: /* SET TERM DEC-LANGUAGE */
- if ((y = cmkey(vtlangtab,nvtlangtab,"VT language",
- "north-american",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- /* A real VT terminal would use the language to set the */
- /* default keyboard language for both 8-bit multinational */
- /* and 7-bit national modes. For 8-bit mode it would */
- /* set the terminal character-set to the ISO set if it */
- /* is not already set. */
- /* Latin-1 can be replaced by DEC Multinational */
- switch (y) {
- case VTL_NORTH_AM: /* North American */
- /* Multinational: Latin-1 */
- /* National: US_ASCII */
- dec_lang = y;
- dec_nrc = TX_ASCII;
- dec_kbd = TX_8859_1;
- break;
- case VTL_BRITISH :
- /* Multinational: Latin-1 */
- /* National: UK_ASCII */
- dec_lang = y;
- dec_nrc = TX_BRITISH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_FRENCH :
- case VTL_BELGIAN :
- case VTL_CANADIAN:
- /* Multinational: Latin-1 */
- /* National: FR_ASCII */
- dec_lang = y;
- dec_nrc = TX_FRENCH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_FR_CAN :
- /* Multinational: Latin-1 */
- /* National: FC_ASCII */
- dec_lang = y;
- dec_nrc = TX_CN_FRENCH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_DANISH :
- case VTL_NORWEGIA:
- /* Multinational: Latin-1 */
- /* National: NO_ASCII */
- dec_lang = y;
- dec_nrc = TX_NORWEGIAN;
- dec_kbd = TX_8859_1;
- break;
- case VTL_FINNISH :
- /* Multinational: Latin-1 */
- /* National: FI_ASCII */
- dec_lang = y;
- dec_nrc = TX_FINNISH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_GERMAN :
- /* Multinational: Latin-1 */
- /* National: GR_ASCII */
- dec_lang = y;
- dec_nrc = TX_GERMAN;
- dec_kbd = TX_8859_1;
- break;
- case VTL_DUTCH :
- /* Multinational: Latin-1 */
- /* National: DU_ASCII */
- dec_lang = y;
- dec_nrc = TX_DUTCH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_ITALIAN :
- /* Multinational: Latin-1 */
- /* National: IT_ASCII */
- dec_lang = y;
- dec_nrc = TX_ITALIAN;
- dec_kbd = TX_8859_1;
- break;
- case VTL_SW_FR :
- case VTL_SW_GR :
- /* Multinational: Latin-1 */
- /* National: CH_ASCII */
- dec_lang = y;
- dec_nrc = TX_SWISS;
- dec_kbd = TX_8859_1;
- break;
- case VTL_SWEDISH :
- /* Multinational: Latin-1 */
- /* National: SW_ASCII */
- dec_lang = y;
- dec_nrc = TX_SWEDISH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_SPANISH :
- /* Multinational: Latin-1 */
- /* National: SP_ASCII */
- dec_lang = y;
- dec_nrc = TX_SPANISH;
- dec_kbd = TX_8859_1;
- break;
- case VTL_PORTUGES:
- /* Multinational: Latin-1 */
- /* National: Portugese ASCII */
- dec_lang = y;
- dec_nrc = TX_PORTUGUESE;
- dec_kbd = TX_8859_1;
- break;
- case VTL_HEBREW :
- /* Multinational: Latin-Hebrew / DEC-Hebrew */
- /* National: DEC 7-bit Hebrew */
- dec_lang = y;
- dec_nrc = TX_HE7;
- dec_kbd = TX_8859_8;
- break;
- case VTL_GREEK :
- /* Multinational: Latin-Greek / DEC-Greek */
- /* National: DEC Greek NRC */
- /* is ELOT927 equivalent to DEC Greek???? */
- dec_lang = y;
- dec_nrc = TX_ELOT927;
- dec_kbd = TX_8859_7;
- break;
- #ifdef COMMENT
- case VTL_TURK_Q :
- case VTL_TURK_F :
- /* Multinational: Latin-Turkish / DEC-Turkish */
- /* National: DEC 7-bit Turkish */
- break;
- #endif /* COMMENT */
- case VTL_HUNGARIA:
- /* Multinational: Latin-2 */
- /* National: no national mode */
- dec_lang = y;
- dec_nrc = TX_HUNGARIAN;
- dec_kbd = TX_8859_2;
- break;
- case VTL_SLOVAK :
- case VTL_CZECH :
- case VTL_POLISH :
- case VTL_ROMANIAN:
- /* Multinational: Latin-2 */
- /* National: no national mode */
- dec_lang = y;
- dec_nrc = TX_ASCII;
- dec_kbd = TX_8859_2;
- break;
- case VTL_RUSSIAN :
- /* Multinational: Latin-Cyrillic / KOI-8 */
- /* National: DEC Russian NRC */
- dec_lang = y;
- dec_nrc = TX_KOI7;
- dec_kbd = TX_8859_5;
- break;
- case VTL_LATIN_AM:
- /* Multinational: not listed in table */
- /* National: not listed in table */
- dec_lang = y;
- dec_nrc = TX_ASCII;
- dec_kbd = TX_8859_1;
- break;
- #ifdef COMMENT
- case VTL_SCS :
- /* Multinational: Latin-2 */
- /* National: SCS NRC */
- break;
- #endif /* COMMENT */
- default:
- return(success = 0);
- }
- if (IS97801(tt_type_mode)) {
- SNI_bitmode(cmask == 0377 ? 8 : 7);
- }
- return(success = 1);
- #endif /* NOCSETS */
- case XYTVTNRC: { /* SET TERM DEC-NRC-MODE */
- extern int decnrcm_usr, decnrcm; /* from ckoco3.c */
- if ((x = seton(&decnrcm_usr)) < 0)
- return(x);
- decnrcm = decnrcm_usr;
- return(success = 1);
- }
- case XYTSNIPM: { /* SET TERM SNI-PAGEMODE */
- extern int sni_pagemode, sni_pagemode_usr;
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- sni_pagemode_usr = sni_pagemode = y;
- return(success = 1);
- }
- case XYTSNISM: { /* SET TERM SNI-SCROLLMODE */
- extern int sni_scroll_mode, sni_scroll_mode_usr;
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- sni_scroll_mode_usr = sni_scroll_mode = y;
- return(success = 1);
- }
- case XYTSNICC: { /* SET TERM SNI-CH.CODE */
- extern int sni_chcode_usr;
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- sni_chcode_usr = y;
- SNI_chcode(y);
- return(success = 1);
- }
- case XYTSNIFV: { /* SET TERM SNI-FIRMWARE-VERSIONS */
- extern CHAR sni_kbd_firmware[], sni_term_firmware[];
- CHAR kbd[7],term[7];
- if ((x = cmfld("Keyboard Firmware Version",sni_kbd_firmware,
- &s, xxstring)) < 0)
- return(x);
- if ((int)strlen(s) != 6) {
- printf("?Sorry - the firmware version must be 6 digits longn");
- return(-9);
- }
- for (i = 0; i < 6; i++) {
- if (!isdigit(s[i])) {
- printf("?Sorry - the firmware version can only contain digits [0-9]n");
- return(-9);
- }
- }
- strcpy(kbd,s);
- if ((x = cmfld("Terminal Firmware Version",sni_term_firmware,
- &s, xxstring)) < 0)
- return(x);
- if ((int)strlen(s) != 6) {
- printf("?Sorry - the firmware version must be 6 digits longn");
- return(-9);
- }
- for (i = 0; i < 6; i++) {
- if (!isdigit(s[i])) {
- printf("?Sorry - the firmware version can only contain digits [0-9]n");
- return(-9);
- }
- }
- strcpy(term,s);
- if ((x = cmcfm()) < 0) return(x);
- strcpy(sni_kbd_firmware,kbd);
- strcpy(sni_term_firmware,term);
- return(success = 1);
- }
- #endif /* OS2 */
- default: /* Shouldn't get here. */
- return(-2);
- }
- #endif /* MAC */
- #ifdef COMMENT
- /*
- This was supposed to shut up picky compilers but instead it makes
- most compilers complain about "statement not reached".
- */
- return(-2);
- #endif /* COMMENT */
- #ifdef OS2
- return(-2);
- #endif /* OS2 */
- }
- #ifdef OS2
- int
- settitle(void) {
- extern char usertitle[];
- if ((y = cmtxt("title text","",&s,xxstring)) < 0)
- return(y);
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- ckstrncpy(usertitle,s,64);
- os2settitle("",1);
- return(1);
- }
- static struct keytab dialertab[] = { /* K95 Dialer types */
- "backspace", 0, 0,
- "enter", 1, 0
- };
- static int ndialer = 2;
- int
- setdialer(void) {
- int t, x, y;
- int clear = 0, deflt = 0;
- int kc; /* Key code */
- char *s = NULL; /* Key binding */
- #ifndef NOKVERBS
- char *p = NULL; /* Worker */
- #endif /* NOKVERBS */
- con_event defevt;
- extern int os2gks;
- extern int mskkeys;
- extern int initvik;
- defevt.type = error;
- if (( x = cmkey(dialertab, ndialer,
- "Kermit-95 dialer work-arounds",
- "", xxstring)) < 0 )
- return(x);
- switch (x) {
- case 0: /* Backspace */
- kc = 264;
- break;
- case 1: /* Enter */
- kc = 269;
- break;
- default:
- printf("Illegal value in setdialer()n");
- return(-9);
- }
- if ((y = cmtxt("Key definition","",&s,xxstring)) < 0)
- return(y);
- #ifdef IKSD
- if (inserver) {
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- s = brstrip(s);
- #ifndef NOKVERBS
- p = s; /* Save this place */
- #endif /* NOKVERBS */
- /*
- If the definition included any Kverbs, quote the backslash so the Kverb
- will still be in the definition when the key is pressed. We don't do this
- in zzstring(), because Kverbs are valid only in this context and nowhere
- else.
- We use this code active for all versions that support SET KEY, even if they
- don't support Kverbs, because otherwise K would behave differently for
- different versions.
- */
- for (x = 0, y = 0; s[x]; x++, y++) { /* Convert K to \K */
- if ((x > 0) &&
- (s[x] == 'K' || s[x] == 'k')
- ) { /* Have K */
- if ((x == 1 && s[x-1] == CMDQ) ||
- (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
- line[y++] = CMDQ; /* Make it \K */
- }
- if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
- line[y-1] = CMDQ; /* Have {K */
- line[y++] = '{'; /* Make it \{K */
- }
- }
- line[y] = s[x];
- }
- line[y++] = NUL; /* Terminate */
- s = line + y + 1; /* Point to after it */
- x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
- if ((x < (LINBUFSIZ / 2)) ||
- (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
- printf("?Key definition too longn");
- return(-9);
- }
- s = line + y + 1; /* Point to result. */
- #ifndef NOKVERBS
- /*
- Special case: see if the definition starts with a Kverb.
- If it does, point to it with p, otherwise set p to NULL.
- */
- p = s;
- if (*p++ == CMDQ) {
- if (*p == '{') p++;
- p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
- }
- #endif /* NOKVERBS */
- /* Now reprogram the default value for all terminal types */
- /* remember to treat Wyse and Televideo terminals special */
- /* because of their use of Kverbs for Backspace and Enter */
- for (t = 0; t <= TT_MAX; t++) {
- if ( ISDG200(t) && kc == 264) {
- extern char * udkfkeys[] ;
- if (kc == 264) { /* Kdgbs */
- if (udkfkeys[83])
- free(udkfkeys[83]);
- udkfkeys[83] = strdup(s);
- }
- } else if (ISWYSE(t) || ISTVI(t)) {
- extern char * udkfkeys[] ;
- if (kc == 264) { /* Kwybs or Ktvibs */
- if (udkfkeys[32])
- free(udkfkeys[32]);
- udkfkeys[32] = strdup(s);
- }
- if (kc == 269) { /* Kwyenter and Kwyreturn */
- if (udkfkeys[39]) /* Ktvienter and Ktvireturn */
- free(udkfkeys[39]);
- udkfkeys[39] = strdup(s);
- if (udkfkeys[49])
- free(udkfkeys[49]);
- udkfkeys[49] = strdup(s);
- }
- } else {
- switch (strlen(s)) { /* Action depends on length */
- case 0: /* Clear individual key def */
- deletekeymap(t,kc);
- break;
- case 1:
- defevt.type = key; /* Single character */
- defevt.key.scancode = *s;
- break;
- default: /* Character string */
- #ifndef NOKVERBS
- if (p) {
- y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
- /* Exact match req'd */
- debug(F101,"set key kverb lookup",0,y);
- if (y > -1) {
- defevt.type = kverb;
- defevt.kverb.id = y;
- break;
- }
- }
- #endif /* NOKVERBS */
- defevt.type = macro;
- defevt.macro.string = (char *) malloc(strlen(s)+1);
- if (defevt.macro.string)
- strcpy(defevt.macro.string, s);
- break;
- }
- insertkeymap( t, kc, defevt ) ;
- initvik = 1; /* Update VIK table */
- }
- }
- return(1);
- }
- #endif /* OS2 */
- #ifdef NT
- int
- setwin95( void ) {
- int x, y, z;
- if (( y = cmkey(win95tab, nwin95,
- "Windows 95 specific work-arounds",
- "keyboard-translation",
- xxstring)) < 0 )
- return (y);
- switch (y) {
- case XYWPOPUP:
- if ((y = cmkey(onoff,2,"popups are used to prompt the user for data",
- "on",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- win95_popup = y;
- return(1);
- case XYW8_3:
- if ((y = cmkey(onoff,2,"8.3 FAT file names","off",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- win95_8_3 = y;
- return(1);
- case XYWSELECT:
- if ((y = cmkey(onoff,2,""select()" fails on write","off",
- xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- win95selectbug = y;
- return(1);
- case XYWAGR:
- if ((y = cmkey(onoff,2,"Right-Alt is Alt-Gr","off",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- win95altgr = y;
- return(1);
- case XYWOIO:
- if ((y = cmkey(onoff,2,"Use Overlapped I/O","on",xxstring)) < 0)
- return(y);
- if (y) {
- if ((x = cmnum("Maximum number of outstanding I/O requests",
- "10",10,&z,xxstring)) < 0)
- return(x);
- if (z < 1 || z > 30) {
- printf(
- "?Maximum outstanding I/O requests must be between 1 and 30.n");
- return(-9);
- }
- } else
- z = 1;
- if ((x = cmcfm()) < 0) return(x);
- owwait = !y;
- maxow = maxow_usr = z;
- return(1);
- case XYWKEY:
- #ifndef COMMENT
- printf("n?"Keyboard-Translation" is no longer required.n");
- return(-9);
- #else /* COMMENT */
- if (( z = cmkey(tcstab, ntcs,
- "Keyboard Character Set",
- "latin1-iso",
- xxstring)) < 0)
- return (z);
- if ((x = cmcfm()) < 0)
- return(x);
- win95kcsi = z;
- win95kl2 = (win95kcsi == TC_2LATIN);
- if (win95kcsi == TC_TRANSP) {
- win95kcs = NULL;
- } else {
- #ifdef UNICODE
- win95kcs = xlr[win95kcsi][tx2fc(tcsl)];
- #else /* UNICODE */
- win95kcs = xlr[win95kcsi][tcsl];
- #endif /* UNICODE */
- }
- return(1);
- #endif /* COMMENT */
- case XYWLUC:
- if ((y = cmkey(onoff,2,"Unicode-to-Lucida-Console substitutions",
- "on",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- win95lucida = y;
- return(1);
- default:
- printf("Illegal value in setwin95()n");
- return(-9);
- }
- }
- #endif /* NT */
- #ifdef OS2
- int
- setprty (
- #ifdef CK_ANSIC
- void
- #endif /* CK_ANSIC */
- /* setprty */ ) {
- int x, y, z;
- if (( y = cmkey(prtytab, nprty,
- "priority level of terminal and communication threads",
- "foreground-server",
- xxstring)) < 0 )
- return (y);
- if ((x = cmcfm()) < 0)
- return (x);
- #ifdef IKSD
- if (inserver &&
- #ifdef IKSDCONF
- iksdcf
- #else
- 1
- #endif /* IKSDCONF */
- ) {
- if ((y = cmcfm()) < 0) return(y);
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- priority = y;
- return(TRUE);
- }
- #endif /* OS2 */
- int
- setbell() {
- int z, y, x;
- if ((y = cmkey(beltab,nbeltab,
- #ifdef OS2
- "how console and terminal bells shouldnbe generated", "audible",
- #else
- "Whether Kermit should ring the terminal bell (beep)", "on",
- #endif /* OS2 */
- xxstring)) < 0)
- return(y);
- #ifdef IKSD
- if (inserver) {
- if ((y = cmcfm()) < 0) return(y);
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- switch (y) { /* SET BELL */
- case XYB_NONE:
- #ifdef OS2
- case XYB_VIS:
- #endif /* OS2 */
- if ((x = cmcfm()) < 0)
- return(x);
- #ifdef OS2
- tt_bell = y;
- #else
- tt_bell = 0;
- #endif /* OS2 */
- break;
- case XYB_AUD:
- #ifdef OS2
- if ((x = cmkey(audibletab, naudibletab,
- "how audible console and terminalnbells should be generated",
- "beep",xxstring))<0)
- return(x);
- if ((z = cmcfm()) < 0)
- return(z);
- tt_bell = y | x;
- #else
- /* This lets C-Kermit accept but ignore trailing K95 keywords */
- if ((x = cmtxt("Confirm with carriage return","",&s,xxstring)) < 0)
- return(x);
- tt_bell = 1;
- #endif /* OS2 */
- break;
- }
- return(1);
- }
- #ifdef OS2MOUSE
- int
- setmou(
- #ifdef CK_ANSIC
- void
- #endif /* CK_ANSIC */
- /* setmou */ ) {
- extern int initvik;
- int button = 0, event = 0;
- char * p;
- if ((y = cmkey(mousetab,nmtab,"","",xxstring)) < 0)
- return(y);
- #ifdef IKSD
- if (inserver) {
- if ((y = cmcfm()) < 0) return(y);
- printf("?Sorry, command disabled.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- if (y == XYM_ON) { /* MOUSE ACTIVATION */
- int old_mou = tt_mouse;
- if ((x = seton(&tt_mouse)) < 0)
- return(x);
- if (tt_mouse != old_mou)
- if (tt_mouse)
- os2_mouseon();
- else
- os2_mouseoff();
- return(1);
- }
- if (y == XYM_CLEAR) { /* Reset Mouse Defaults */
- if ((x = cmcfm()) < 0) return(x);
- mousemapinit(-1,-1);
- initvik = 1; /* Update VIK Table */
- return 1;
- }
- if (y != XYM_BUTTON) { /* Shouldn't happen. */
- printf("Internal parsing errorn");
- return(-9);
- }
- /* MOUSE EVENT ... */
- if ((button = cmkey(mousebuttontab,nmbtab,
- "Button number, one of the following","1",
- xxstring)) < 0)
- return(button);
- if ((y = cmkey(mousemodtab,nmmtab,
- "Keyboard modifier, one of the following",
- "none",xxstring)) < 0)
- return(y);
- event |= y; /* OR in the bits */
- if ((y = cmkey(mclicktab,nmctab,"","click",xxstring)) < 0)
- return(y);
- /* Two bits are assigned, if neither are set then it is button one */
- event |= y; /* OR in the bit */
- wideresult = -1;
- if ((y = cmtxt("definition,n
- or Ctrl-C to cancel this command,n
- or Enter to restore default definition",
- "",&s,NULL)) < 0) {
- return(y);
- }
- s = brstrip(s);
- p = s; /* Save this place */
- /*
- If the definition included any Kverbs, quote the backslash so the Kverb
- will still be in the definition when the key is pressed. We don't do this
- in zzstring(), because Kverbs are valid only in this context and nowhere
- else. This code copied from SET KEY, q.v. for addt'l commentary.
- */
- for (x = 0, y = 0; s[x]; x++, y++) { /* Convert K to \K */
- if ((x > 0) &&
- (s[x] == 'K' || s[x] == 'k')
- ) { /* Have K */
- if ((x == 1 && s[x-1] == CMDQ) ||
- (x > 1 && s[x-1] == CMDQ && s[x-2] != CMDQ)) {
- line[y++] = CMDQ; /* Make it \K */
- }
- if (x > 1 && s[x-1] == '{' && s[x-2] == CMDQ) {
- line[y-1] = CMDQ; /* Have {K */
- line[y++] = '{'; /* Make it \{K */
- }
- }
- line[y] = s[x];
- }
- line[y++] = NUL; /* Terminate */
- s = line + y + 1; /* Point to after it */
- x = LINBUFSIZ - (int) strlen(line) - 1; /* Calculate remaining space */
- if ((x < (LINBUFSIZ / 2)) ||
- (zzstring(line, &s, &x) < 0)) { /* Expand variables, etc. */
- printf("?Key definition too longn");
- return(-9);
- }
- s = line + y + 1; /* Point to result. */
- #ifndef NOKVERBS
- /*
- Special case: see if the definition starts with a Kverb.
- If it does, point to it with p, otherwise set p to NULL.
- */
- p = s;
- if (*p++ == CMDQ) {
- if (*p == '{') p++;
- p = (*p == 'k' || *p == 'K') ? p + 1 : NULL;
- }
- #else
- p = NULL;
- #endif /* NOKVERBS */
- /* free the old definition if necessary */
- if (mousemap[button][event].type == macro) {
- free( mousemap[button][event].macro.string);
- mousemap[button][event].macro.string = NULL;
- }
- switch (strlen(s)) { /* Action depends on length */
- case 0: /* Reset to default binding */
- mousemapinit( button, event );
- break;
- case 1: /* Single character */
- mousemap[button][event].type = key;
- mousemap[button][event].key.scancode = *s;
- break;
- default: /* Character string */
- #ifndef NOKVERBS
- if (p) {
- y = xlookup(kverbs,p,nkverbs,&x); /* Look it up */
- debug(F101,"set mouse kverb lookup",0,y); /* need exact match */
- if (y > -1) {
- /* Assign the kverb to the event */
- mousemap[button][event].type = kverb;
- mousemap[button][event].kverb.id = F_KVERB | y;
- break;
- }
- }
- #endif /* NOKVERBS */
- /* Otherwise, it's a macro, so assign the macro to the event */
- mousemap[button][event].type = macro;
- mousemap[button][event].macro.string = (MACRO) malloc(strlen(s)+1);
- if (mousemap[button][event].macro.string)
- strcpy((char *) mousemap[button][event].macro.string, s);
- break;
- }
- initvik = 1; /* Update VIK Table */
- return(1);
- }
- #endif /* OS2MOUSE */
- #endif /* NOLOCAL */
- #ifndef NOXFER
- int /* SET SEND/RECEIVE */
- setsr(xx, rmsflg) int xx; int rmsflg; {
- if (xx == XYRECV)
- strcpy(line,"Parameter for inbound packets");
- else
- strcpy(line,"Parameter for outbound packets");
- if (rmsflg) {
- if ((y = cmkey(rsrtab,nrsrtab,line,"",xxstring)) < 0) {
- if (y == -3) {
- printf("?Remote receive parameter requiredn");
- return(-9);
- } else return(y);
- }
- } else {
- if ((y = cmkey(srtab,nsrtab,line,"",xxstring)) < 0) return(y);
- }
- switch (y) {
- case XYQCTL: /* CONTROL-PREFIX */
- if ((x = cmnum("ASCII value of control prefix","",10,&y,xxstring)) < 0)
- return(x);
- if ((x = cmcfm()) < 0) return(x);
- if ((y > 32 && y < 63) || (y > 95 && y < 127)) {
- if (xx == XYRECV)
- ctlq = (CHAR) y; /* RECEIVE prefix, use with caution! */
- else
- myctlq = (CHAR) y; /* SEND prefix, OK to change */
- return(success = 1);
- } else {
- printf("?Illegal value for prefix charactern");
- return(-9);
- }
- case XYEOL:
- if ((y = setcc("13",&z)) < 0)
- return(y);
- if (z > 31) {
- printf("Sorry, the legal values are 0-31n");
- return(-9);
- }
- if (xx == XYRECV)
- eol = (CHAR) z;
- else
- seol = (CHAR) z;
- return(success = y);
- case XYLEN:
- y = cmnum("Maximum number of characters in a packet","90",10,&x,
- xxstring);
- if (xx == XYRECV) { /* Receive... */
- if ((y = setnum(&z,x,y,maxrps)) < 0)
- return(y);
- if (protocol != PROTO_K) {
- printf("?Sorry, this command does not apply to %s protocol.n",
- ptab[protocol].p_name
- );
- printf("Use SET SEND PACKET-LENGTH for XYZMODEMn");
- return(-9);
- }
- if (z < 10) {
- printf("Sorry, 10 is the minimumn");
- return(-9);
- }
- if (rmsflg) {
- sstate = setgen('S', "401", ckitoa(z), "");
- return((int) sstate);
- } else {
- if (protocol == PROTO_K) {
- if (z > MAXRP) z = MAXRP;
- y = adjpkl(z,wslotr,bigrbsiz);
- if (y != z) {
- urpsiz = y;
- if (!cmdsrc())
- if (msgflg) printf(
- " Adjusting receive packet-length to %d for %d window slotsn",
- y, wslotr);
- }
- urpsiz = y;
- ptab[protocol].rpktlen = urpsiz;
- rpsiz = (y > 94) ? 94 : y;
- } else {
- #ifdef CK_XYZ
- if ((protocol == PROTO_X || protocol == PROTO_XC) &&
- z != 128 && z != 1024) {
- printf("Sorry, bad packet length for XMODEM.n");
- printf("Please use 128 or 1024.n");
- return(-9);
- }
- #endif /* CK_XYZ */
- urpsiz = rpsiz = z;
- }
- }
- } else { /* Send... */
- if ((y = setnum(&z,x,y,maxsps)) < 0)
- return(y);
- if (z < 10) {
- printf("Sorry, 10 is the minimumn");
- return(-9);
- }
- if (protocol == PROTO_K) {
- if (z > MAXSP) z = MAXSP;
- spsiz = z; /* Set it */
- y = adjpkl(spsiz,wslotr,bigsbsiz);
- if (y != spsiz && !cmdsrc())
- if (msgflg)
- printf("Adjusting packet size to %d for %d window slotsn",
- y,wslotr);
- } else
- y = z;
- #ifdef CK_XYZ
- if ((protocol == PROTO_X || protocol == PROTO_XC) &&
- z != 128 && z != 1024) {
- printf("Sorry, bad packet length for XMODEM.n");
- printf("Please use 128 or 1024.n");
- return(-9);
- }
- #endif /* CK_XYZ */
- spsiz = spmax = spsizr = y; /* Set it and flag that it was set */
- spsizf = 1; /* to allow overriding Send-Init. */
- ptab[protocol].spktflg = spsizf;
- ptab[protocol].spktlen = spsiz;
- }
- if (pflag && protocol == PROTO_K && !cmdsrc()) {
- if (z > 94 && !reliable && msgflg) {
- /* printf("Extended-length packets requested.n"); */
- if (bctr < 2 && z > 200) printf("
- Remember to SET BLOCK 2 or 3 for long packets.n");
- }
- if (speed <= 0L) speed = ttgspd();
- #ifdef COMMENT
- /*
- Kermit does this now itself.
- */
- if (speed <= 0L && z > 200 && msgflg) {
- printf("
- Make sure your timeout interval is long enough for %d-byte packets.n",z);
- }
- #endif /* COMMENT */
- }
- return(success = y);
- case XYMARK:
- #ifdef DOOMSDAY
- /*
- Printable start-of-packet works for UNIX and VMS only!
- */
- x_ifnum = 1;
- y = cmnum("Code for packet-start character","1",10,&x,xxstring);
- x_ifnum = 0;
- if ((y = setnum(&z,x,y,126)) < 0) return(y);
- #else
- if ((y = setcc("1",&z)) < 0)
- return(y);
- #endif /* DOOMSDAY */
- if (xx == XYRECV)
- stchr = (CHAR) z;
- else {
- mystch = (CHAR) z;
- #ifdef IKS_OPTION
- /* If IKS negotiation in use */
- if (TELOPT_U(TELOPT_KERMIT) || TELOPT_ME(TELOPT_KERMIT))
- tn_siks(KERMIT_SOP); /* Report change to other side */
- #endif /* IKS_OPTION */
- }
- return(success = y);
- case XYNPAD: /* PADDING */
- y = cmnum("How many padding characters for inbound packets","0",10,&x,
- xxstring);
- if ((y = setnum(&z,x,y,94)) < 0) return(y);
- if (xx == XYRECV)
- mypadn = (CHAR) z;
- else
- npad = (CHAR) z;
- return(success = y);
- case XYPADC: /* PAD-CHARACTER */
- if ((y = setcc("0",&z)) < 0) return(y);
- if (xx == XYRECV) mypadc = z; else padch = z;
- return(success = y);
- case XYTIMO: /* TIMEOUT */
- if (xx == XYRECV) {
- y = cmnum("Packet timeout interval",ckitoa(URTIME),10,&x,xxstring);
- if ((y = setnum(&z,x,y,94)) < 0) return(y);
- if (rmsflg) { /* REMOTE SET RECEIVE TIMEOUT */
- sstate = setgen('S', "402", ckitoa(z), "");
- return((int) sstate);
- } else { /* SET RECEIVE TIMEOUT */
- pkttim = z; /* Value to put in my negotiation */
- } /* packet for other Kermit to use */
- } else { /* SET SEND TIMEOUT */
- #ifdef CK_TIMERS
- extern int rttflg, mintime, maxtime;
- int tmin = 0, tmax = 0;
- #endif /* CK_TIMERS */
- y = cmnum("Packet timeout interval","",10,&x,xxstring);
- if (y == -3) { /* They cancelled a previous */
- x = DMYTIM; /* SET SEND command, so restore */
- timef = 0; /* and turn off the override flag */
- y = cmcfm();
- }
- #ifdef CK_TIMERS
- if (y < 0) return(y);
- if (x < 0) {
- printf("?Out of range - %dn",x);
- return(-9);
- }
- if ((z = cmkey(timotab,2,"","dynamic",xxstring)) < 0) return(z);
- if (z) {
- if ((y = cmnum("Minimum timeout to allow",
- "1",10,&tmin,xxstring)) < 0)
- return(y);
- if (tmin < 1) {
- printf("?Out of range - %dn",x);
- return(-9);
- }
- if ((y = cmnum("Maximum timeout to allow",
- "0",10,&tmax,xxstring)) < 0)
- return(y);
- /* 0 means let Kermit choose, < 0 means no maximum */
- }
- if ((y = cmcfm()) < 0)
- return(y);
- rttflg = z; /* Round-trip timer flag */
- z = x;
- #else
- if ((y = setnum(&z,x,y,94)) < 0)
- return(y);
- #endif /* CK_TIMERS */
- timef = 1; /* Turn on the override flag */
- timint = rtimo = z; /* Override value for me to use */
- #ifdef CK_TIMERS
- if (rttflg) { /* Lower and upper bounds */
- mintime = tmin;
- maxtime = tmax;
- }
- #endif /* CK_TIMERS */
- }
- return(success = 1);
- case XYFPATH: /* PATHNAMES */
- if (xx == XYRECV) {
- y = cmkey(rpathtab,nrpathtab,"","auto",xxstring);
- } else {
- y = cmkey(pathtab,npathtab,"","off",xxstring);
- }
- if (y < 0) return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (xx == XYRECV) { /* SET RECEIVE PATHNAMES */
- fnrpath = y;
- ptab[protocol].fnrp = fnrpath;
- } else { /* SET SEND PATHNAMES */
- fnspath = y;
- ptab[protocol].fnsp = fnspath;
- }
- return(success = 1); /* Note: 0 = ON, 1 = OFF */
- /* In other words, ON = leave pathnames ON, OFF = take them off. */
- case XYPAUS: /* SET SEND/RECEIVE PAUSE */
- y = cmnum("Milliseconds to pause between packets","0",10,&x,xxstring);
- if ((y = setnum(&z,x,y,15000)) < 0)
- return(y);
- pktpaus = z;
- return(success = 1);
- #ifdef CKXXCHAR /* SET SEND/RECEIVE IGNORE/DOUBLE */
- case XYIGN:
- case XYDBL: {
- int i, zz;
- short *p;
- extern short dblt[];
- extern int dblflag, ignflag;
- /* Make space for a temporary copy of the ignore/double table */
- zz = y;
- #ifdef COMMENT
- if (zz == XYIGN && xx == XYSEND) {
- blah blah who cares
- }
- if (zz == XYDBL && xx == XYRECV) {
- blah blah
- }
- #endif /* COMMENT */
- p = (short *)malloc(256 * sizeof(short));
- if (!p) {
- printf("?Internal error - malloc failuren");
- return(-9);
- }
- for (i = 0; i < 256; i++) p[i] = dblt[i]; /* Copy current table */
- while (1) { /* Collect a list of numbers */
- #ifndef NOSPL
- x_ifnum = 1; /* Turn off complaints from eval() */
- #endif /* NOSPL */
- if ((x = cmnum(zz == XYDBL ?
- "Character to double" :
- "Character to ignore",
- "",10,&y,xxstring
- )) < 0) {
- #ifndef NOSPL
- x_ifnum = 0;
- #endif /* NOSPL */
- if (x == -3) /* Done */
- break;
- if (x == -2) {
- if (p) { free(p); p = NULL; }
- debug(F110,"SET S/R DOUBLE/IGNORE atmbuf",atmbuf,0);
- if (!ckstrcmp(atmbuf,"none",4,0) ||
- !ckstrcmp(atmbuf,"non",3,0) ||
- !ckstrcmp(atmbuf,"no",2,0) ||
- !ckstrcmp(atmbuf,"n",1,0)) {
- if ((x = cmcfm()) < 0) /* Get confirmation */
- return(x);
- for (y = 0; y < 256; y++)
- dblt[y] &= (zz == XYDBL) ? 1 : 2;
- if (zz == XYDBL) dblflag = 0;
- if (zz == XYIGN) ignflag = 0;
- return(success = 1);
- } else {
- printf(
- "?Please specify a number or the word NONEn");
- return(-9);
- }
- } else {
- free(p);
- p = NULL;
- return(x);
- }
- }
- #ifndef NOSPL
- x_ifnum = 0;
- #endif /* NOSPL */
- if (y < 0 || y > 255) {
- printf("?Please enter a character code in range 0-255n");
- free(p);
- p = NULL;
- return(-9);
- }
- p[y] |= (zz == XYDBL) ? 2 : 1;
- if (zz == XYDBL) dblflag = 1;
- if (zz == XYIGN) ignflag = 1;
- } /* End of while loop */
- if ((x = cmcfm()) < 0) return(x);
- /*
- Get here only if they have made no mistakes. Copy temporary table back to
- permanent one, then free temporary table and return successfully.
- */
- if (p) {
- for (i = 0; i < 256; i++) dblt[i] = p[i];
- free(p);
- p = NULL;
- }
- return(success = 1);
- }
- #endif /* CKXXCHAR */
- #ifdef PIPESEND
- case XYFLTR: { /* SET { SEND, RECEIVE } FILTER */
- if ((y = cmtxt((xx == XYSEND) ?
- "Filter program for sending files -n
- use \v(filename) to substitute filename" :
- "Filter program for receiving files -n
- use \v(filename) to substitute filename",
- "",&s,NULL)) < 0)
- return(y);
- if (!*s) { /* Removing a filter... */
- if (xx == XYSEND && sndfilter) {
- free(sndfilter);
- sndfilter = NULL;
- } else if (rcvfilter) {
- free(rcvfilter);
- rcvfilter = NULL;
- }
- return(success = 1);
- } /* Adding a filter... */
- s = brstrip(s); /* Strip any braces */
- y = strlen(s);
- if (xx == XYSEND) { /* For SEND filter... */
- for (x = 0; x < y; x++) { /* make sure they included "v(...)" */
- if (s[x] != '\') continue;
- if (s[x+1] == 'v') break;
- }
- if (x == y) {
- printf(
- "?Filter must contain a replacement variable for filename.n"
- );
- return(-9);
- }
- }
- if (xx == XYSEND) {
- makestr(&sndfilter,s);
- } else {
- makestr(&rcvfilter,s);
- }
- return(success = 1);
- }
- #endif /* PIPESEND */
- case XYINIL:
- y = cmnum("Max length for protocol init string","-1",10,&x,xxstring);
- if ((y = setnum(&z,x,y,-1)) < 0)
- return(y);
- if (xx == XYSEND)
- sprmlen = z;
- else
- rprmlen = z;
- return(success = 1);
- #ifndef NOCSETS
- case XYCSET: { /* CHARACTER-SET-SELECTION */
- extern struct keytab xfrmtab[];
- extern int r_cset, s_cset;
- if ((y = cmkey(xfrmtab,2,"","automatic",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0)
- return(x);
- if (xx == XYSEND)
- s_cset = y;
- else
- r_cset = y;
- return(success = 1);
- }
- #endif /* NOCSETS */
- case XYBUP:
- if ((y = cmkey(onoff,2,"","on",xxstring)) < 0)
- return(y);
- if ((x = cmcfm()) < 0) return(x);
- if (xx == XYSEND) {
- extern int skipbup;
- skipbup = (y == 0) ? 1 : 0;
- return(success = 1);
- } else {
- printf(
- "?Please use SET FILE COLLISION to choose the desired actionn");
- return(-9);
- }
- case XYMOVE:
- y = cmdir("Directory to move file(s) to after successful transfer",
- "",&s,xxstring);
- if (y < 0 && y != -3)
- return(y);
- strcpy(line,s);
- s = brstrip(line);
- if ((x = cmcfm()) < 0)
- return(x);
- if (xx == XYSEND) {
- if (*s) {
- makestr(&snd_move,s);
- makestr(&g_snd_move,s);
- } else {
- makestr(&snd_move,NULL);
- makestr(&g_snd_move,NULL);
- }
- } else {
- if (*s) {
- makestr(&rcv_move,s);
- makestr(&g_rcv_move,s);
- } else {
- makestr(&rcv_move,NULL);
- makestr(&g_rcv_move,NULL);
- }
- }
- return(success = 1);
- case XYRENAME:
- y = cmdir("Template to rename file(s) to after successful transfer",
- "",&s,NULL);
- if (y < 0 && y != -3)
- return(y);
- strcpy(line,s);
- s = brstrip(line);
- if ((x = cmcfm()) < 0)
- return(x);
- if (xx == XYSEND) {
- if (*s) {
- makestr(&snd_rename,s);
- makestr(&g_snd_rename,s);
- } else {
- makestr(&snd_rename,NULL);
- makestr(&g_snd_rename,NULL);
- }
- } else {
- if (*s) {
- makestr(&rcv_rename,s);
- makestr(&g_rcv_rename,s);
- } else {
- makestr(&rcv_rename,NULL);
- makestr(&g_rcv_rename,NULL);
- }
- }
- return(success = 1);
- #ifdef VMS
- case 887: /* VERSION-NUMBERS */
- if (xx == XYSEND) {
- extern int vmssversions;
- return(seton(&vmssversions));
- } else {
- extern int vmsrversions;
- return(seton(&vmsrversions));
- }
- #endif /* VMS */
- default:
- return(-2);
- } /* End of SET SEND/RECEIVE... */
- }
- #endif /* NOXFER */
- #ifndef NOXMIT
- int
- setxmit() {
- if ((y = cmkey(xmitab,nxmit,"","",xxstring)) < 0) return(y);
- switch (y) {
- case XMITE: /* EOF */
- y = cmtxt("Characters to send at end of file,n
- Use backslash codes for control characters","",&s,xxstring);
- if (y < 0) return(y);
- if ((int)strlen(s) > XMBUFL) {
- printf("?Too many characters, %d maximumn",XMBUFL);
- return(-2);
- }
- strcpy(xmitbuf,s);
- return(success = 1);
- case XMITF: /* Fill */
- y = cmnum("Numeric code for blank-line fill character","0",10,&x,
- xxstring);
- if ((y = setnum(&z,x,y,127)) < 0) return(y);
- xmitf = z;
- return(success = 1);
- case XMITL: /* Linefeed */
- return(seton(&xmitl));
- case XMITS: /* Locking-Shift */
- return(seton(&xmits));
- case XMITP: /* Prompt */
- y = cmnum("Numeric code for host's prompt character, 0 for none",
- "10",10,&x,xxstring);
- if ((y = setnum(&z,x,y,127)) < 0) return(y);
- xmitp = z;
- return(success = 1);
- case XMITX: /* Echo */
- return(seton(&xmitx));
- case XMITW: /* Pause */
- y = cmnum("Number of milliseconds to pause between binary charactersn
- or text lines during transmission","0",10,&x,xxstring);
- if ((y = setnum(&z,x,y,1000)) < 0) return(y);
- xmitw = z;
- return(success = 1);
- case XMITT: /* Timeout */
- y = cmnum("Seconds to wait for each character to echo",
- "1",10,&x,xxstring);
- if ((y = setnum(&z,x,y,1000)) < 0) return(y);
- xmitt = z;
- return(success = 1);
- default:
- return(-2);
- }
- }
- #endif /* NOXMIT */
- /* D O R M T -- Do a remote command */
- VOID
- rmsg() {
- if (pflag)
- printf(
- #ifdef CK_NEED_SIG
- " Type your escape character, %s, followed by X or E to cancel.n",
- dbchr(escape)
- #else
- " Press the X or E key to cancel.n"
- #endif /* CK_NEED_SIG */
- );
- }
- #ifndef NOXFER
- static int xzcmd = 0; /* Global copy of REMOTE cmd index */
- /* R E M C F M -- Confirm a REMOTE command */
- /*
- Like cmcfm(), but allows for a redirection indicator on the end,
- like "> filename" or "| command". Returns what cmcfm() would have
- returned: -1 if reparse needed, etc etc blah blah. On success,
- returns 1 with:
- char * remdest containing the name of the file or command.
- int remfile set to 1 if there is to be any redirection.
- int rempipe set to 1 if remdest is a command, 0 if it is a file.
- */
- static int
- remcfm() {
- int x;
- char *s;
- char c;
- remfile = 0;
- rempipe = 0;
- if ((x = cmtxt(
- "> filename, | command,n
- or type carriage return to confirm the command",
- "",&s,xxstring)) < 0)
- return(x);
- if (remdest) {
- free(remdest);
- remdest = NULL;
- }
- debug(F101,"remcfm local","",local);
- debug(F110,"remcfm s",s,0);
- debug(F101,"remcfm cmd","",xzcmd);
- if (!*s) { /* No redirection indicator */
- if (!local &&
- (xzcmd == XZDIR || xzcmd == XZTYP ||
- xzcmd == XZXIT || xzcmd == XZSPA ||
- xzcmd == XZHLP || xzcmd == XZPWD ||
- xzcmd == XZLGI || xzcmd == XZLGO ||
- xzcmd == XZWHO || xzcmd == XZHOS)) {
- printf("?"%s" has no effect in remote moden",cmdbuf);
- return(-9);
- } else
- return(1);
- }
- c = *s; /* We have something */
- if (c != '>' && c != '|') { /* Is it > or | ? */
- printf("?Not confirmedn"); /* No */
- return(-9);
- }
- s++; /* See what follows */
- if (c == '>' && *s == '>') { /* Allow for ">>" too */
- s++;
- remappd = 1; /* Append to output file */
- }
- while (*s == SP || *s == HT) s++; /* Strip intervening whitespace */
- if (!*s) {
- printf("?%s missingn", c == '>' ? "Filename" : "Command");
- return(-9);
- }
- if (c == '>' && zchko(s) < 0) { /* Check accessibility */
- printf("?Access denied - %sn", s);
- return(-9);
- }
- remfile = 1; /* Set global results */
- rempipe = (c == '|');
- if (rempipe
- #ifndef NOPUSH
- && nopush
- #endif /* NOPUSH */
- ) {
- printf("?Sorry, access to external commands is disabled.n");
- return(-9);
- }
- makestr(&remdest,s);
- #ifndef NODEBUG
- if (deblog) {
- debug(F101,"remcfm remfile","",remfile);
- debug(F101,"remcfm remappd","",remappd);
- debug(F101,"remcfm rempipe","",rempipe);
- debug(F110,"remcfm remdest",remdest, 0);
- }
- #endif /* NODEBUG */
- return(1);
- }
- /* R E M T X T -- Like remcfm()... */
- /*
- ... but for REMOTE commands that end with cmtxt().
- Here we must decipher braces to discover whether the trailing
- redirection indicator is intended for local use, or to be sent out
- to the server, as in:
- remote host blah blah > file This end
- remote host { blah blah } > file This end
- remote host { blah blah > file } That end
- remote host { blah blah > file } > file Both ends
- Pipes too:
- remote host blah blah | cmd This end
- remote host { blah blah } | cmd This end
- remote host { blah blah | cmd } That end
- remote host { blah blah | cmd } | cmd Both ends
- Or both:
- remote host blah blah | cmd > file This end, etc etc...
- Note: this really only makes sense for REMOTE HOST, but why be picky?
- Call after calling cmtxt(), with pointer to string that cmtxt() parsed,
- as in "remtxt(&s);".
- Returns:
- 1 on success with braces & redirection things removed & pointer updated,
- -9 on failure (bad indirection), after printing error message.
- */
- static int
- remtxt(p) char ** p; {
- int i, x, bpos, ppos;
- char c, *s, *q;
- remfile = 0; /* Initialize global results */
- rempipe = 0;
- remappd = 0;
- if (remdest) {
- free(remdest);
- remdest = NULL;
- }
- s = *p;
- if (!s) /* No redirection indicator */
- s = "";
- if (!*s) { /* Ditto */
- if (!local &&
- (xzcmd == XZDIR || xzcmd == XZTYP ||
- xzcmd == XZXIT || xzcmd == XZSPA ||
- xzcmd == XZHLP || xzcmd == XZPWD ||
- xzcmd == XZLGI || xzcmd == XZLGO ||
- xzcmd == XZWHO || xzcmd == XZHOS)) {
- printf("?"%s" has no effect in remote moden",cmdbuf);
- if (hints) {
- printf("Hint: try again with an output redirector.n");
- }
- return(-9);
- } else
- return(1);
- }
- bpos = -1; /* Position of > (bracket) */
- ppos = -1; /* Position of | (pipe) */
- x = strlen(s); /* Length of cmtxt() string */
- for (i = x-1; i >= 0; i--) { /* Search right to left. */
- c = s[i];
- if (c == '}') /* Break on first right brace */
- break; /* Don't look at contents of braces */
- else if (c == '>') /* Record position of > */
- bpos = i;
- else if (c == '|') /* and of | */
- ppos = i;
- }
- if (bpos < 0 && ppos < 0) { /* No redirectors. */
- if (!local &&
- (xzcmd == XZDIR || xzcmd == XZTYP ||
- xzcmd == XZXIT || xzcmd == XZSPA ||
- xzcmd == XZHLP || xzcmd == XZPWD ||
- xzcmd == XZLGI || xzcmd == XZLGO ||
- xzcmd == XZWHO || xzcmd == XZHOS)) {
- printf("?"%s" has no effect in remote moden",cmdbuf);
- if (hints) {
- printf("Hint: try again with an output redirector.n");
- }
- return(-9);
- }
- s = brstrip(s); /* Remove outer braces if any. */
- *p = s; /* Point to result */
- return(1); /* and return. */
- }
- remfile = 1; /* It's | or > */
- i = -1; /* Get leftmost symbol */
- if (bpos > -1) /* Bracket */
- i = bpos;
- if (ppos > -1 && (ppos < bpos || bpos < 0)) { /* or pipe */
- i = ppos;
- rempipe = 1;
- }
- c = s[i]; /* Copy of symbol */
- if (c == '>' && s[i+1] == '>') /* ">>" for append? */
- remappd = 1; /* It's not just a flag it's a number */
- q = s + i + 1 + remappd; /* Point past symbol in string */
- while (*q == SP || *q == HT) q++; /* and any intervening whitespace */
- if (!*q) {
- printf("?%s missingn", c == '>' ? "Filename" : "Command");
- return(-9);
- }
- if (c == '>' && zchko(q) < 0) { /* (Doesn't work for | cmd > file) */
- printf("?Access denied - %sn", q);
- return(-9);
- }
- makestr(&remdest,q); /* Create the destination string */
- q = s + i - 1; /* Point before symbol */
- while (q > s && (*q == SP || *q == HT)) /* Strip trailing whitespace */
- q--;
- *(q+1) = NUL; /* Terminate the string. */
- s = brstrip(s); /* Remove any braces */
- *p = s; /* Set return value */
- #ifndef NODEBUG
- if (deblog) {
- debug(F101,"remtxt remfile","",remfile);
- debug(F101,"remtxt remappd","",remappd);
- debug(F101,"remtxt rempipe","",rempipe);
- debug(F110,"remtxt remdest",remdest, 0);
- debug(F110,"remtxt command",s,0);
- }
- #endif /* NODEBUG */
- return(1);
- }
- int
- plogin(xx) int xx; {
- char *p1 = NULL, *p2 = NULL, *p3 = NULL;
- int psaved = 0, rc = 0;
- #ifdef CK_RECALL
- int sv_recall = -1; /* For turning off command recall */
- extern int on_recall; /* around Password prompting */
- #endif /* CK_RECALL */
- debug(F101,"plogin local","",local);
- if (!local || (network && ttchk() < 0)) {
- printf("?No connectionn");
- return(-9);
- }
- if ((x = cmfld("User ID","",&s,xxstring)) < 0) { /* Get User ID */
- if (x != -3) return(x);
- }
- y = strlen(s);
- if (y > 0) {
- if ((p1 = malloc(y + 1)) == NULL) {
- printf("?Internal error: mallocn");
- rc = -9;
- goto XZXLGI;
- } else
- strcpy(p1,s);
- if ((rc = cmfld("Password","",&s,xxstring)) < 0)
- if (rc != -3) goto XZXLGI;
- y = strlen(s);
- if (y > 0) {
- if ((p2 = malloc(y + 1)) == NULL) {
- printf("?Internal error: mallocn");
- rc = -9;
- goto XZXLGI;
- } else
- strcpy(p2,s);
- if ((rc = cmfld("Account","",&s,xxstring)) < 0)
- if (rc != -3) goto XZXLGI;
- y = strlen(s);
- if (y > 0) {
- if ((p3 = malloc(y + 1)) == NULL) {
- printf("?Internal error: mallocn");
- rc = -9;
- goto XZXLGI;
- } else
- strcpy(p3,s);
- }
- }
- }
- if ((rc = remtxt(&s)) < 0) /* Confirm & handle redirectors */
- goto XZXLGI;
- if (!p1) { /* No Userid specified... */
- /* Prompt for username, password, and account */
- #ifdef CK_RECALL
- sv_recall = on_recall;
- on_recall = 0;
- #endif /* CK_RECALL */
- cmsavp(psave,PROMPTL); /* Save old prompt */
- psaved = 1;
- debug(F110,"REMOTE LOGIN saved",psave,0);
- cmsetp("Username: "); /* Make new prompt */
- concb((char)escape); /* Put console in cbreak mode */
- cmini(1);
- prompt(xxstring);
- rc = -9;
- for (x = -1; x < 0; ) { /* Prompt till they answer */
- cmres(); /* Reset the parser */
- x = cmtxt("","",&s,NULL); /* Get a literal line of text */
- }
- y = strlen(s);
- if (y < 1) {
- printf("?Canceledn");
- goto XZXLGI;
- }
- if ((p1 = malloc(y + 1)) == NULL) {
- printf("?Internal error: mallocn");
- goto XZXLGI;
- } else
- strcpy(p1,s);
- cmsetp("Password: "); /* Make new prompt */
- concb((char)escape); /* Put console in cbreak mode */
- cmini(0); /* No echo */
- prompt(xxstring);
- for (x = -1; x < 0 && x != -3; ) { /* Get answer */
- cmres(); /* Reset the parser */
- x = cmtxt("","",&s,NULL); /* Get literal line of text */
- }
- if ((p2 = malloc((int)strlen(s) + 1)) == NULL) {
- printf("?Internal error: mallocn");
- goto XZXLGI;
- } else
- strcpy(p2,s);
- printf("rn");
- if ((rc = cmcfm()) < 0)
- goto XZXLGI;
- }
- sstate = setgen('I',p1,p2,p3); /* Get here with at least user ID */
- rc = 0;
- XZXLGI: /* Common exit point */
- if (psaved)
- cmsetp(psave); /* Restore original prompt */
- #ifdef CK_RECALL
- if (sv_recall > -1) /* Put back command recall */
- on_recall = sv_recall;
- #endif /* CK_RECALL */
- if (p3) { free(p3); p3 = NULL; } /* Free malloc'd storage */
- if (p2) { free(p2); p2 = NULL; }
- if (p1) { free(p1); p1 = NULL; }
- if (rc > -1) {
- if (local && rc > -1) /* If local, flush tty input buffer */
- ttflui();
- }
- return(rc);
- }
- #ifdef OS2
- int
- dormt(xx) int xx; {
- int rc = 0;
- extern int term_io;
- int term_io_sav = term_io;
- term_io = 0;
- rc = xxdormt(xx);
- term_io = term_io_sav;
- return rc;
- }
- int
- xxdormt(xx) int xx;
- #else /* OS2 */
- int
- dormt(xx) int xx;
- #endif /* OS2 */
- { /* REMOTE commands */
- int x, y, retcode;
- char *s, sbuf[50], *s2;
- remfile = 0; /* Clear these */
- rempipe = 0;
- remappd = 0;
- if (xx < 0) return(xx); /* REMOTE what? */
- xzcmd = xx; /* Make global copy of arg */
- if (xx == XZSET) { /* REMOTE SET */
- if ((y = cmkey(rmstab,nrms,"","",xxstring)) < 0) {
- if (y == -3) {
- printf("?Parameter name requiredn");
- return(-9);
- } else return(y);
- }
- return(doprm(y,1));
- }
- switch (xx) { /* Others... */
- case XZCWD: /* CWD (CD) */
- if ((x = cmtxt("Remote directory name","",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- debug(F111,"XZCWD: ",s,x);
- *sbuf = NUL;
- s2 = sbuf;
- /*
- The following is commented out because since the disappearance of the
- DECSYSTEM-20 from the planet, no known computer requires a password for
- changing directory.
- */
- #ifdef DIRPWDPR
- if (*s != NUL) { /* If directory name given, */
- /* get password on separate line. */
- if (tlevel > -1) { /* From take file... */
- if (fgets(sbuf,50,tfile[tlevel]) == NULL)
- fatal("take file ends prematurely in 'remote cwd'");
- debug(F110," pswd from take file",s2,0);
- for (x = (int)strlen(sbuf);
- x > 0 && (sbuf[x-1] == NL || sbuf[x-1] == CR);
- x--)
- sbuf[x-1] = ' ';
- } else { /* From terminal... */
- printf(" Password: "); /* get a password */
- #ifdef IKSD
- if (!local && inserver) {
- x = coninc(0);
- } else
- #endif /* IKSD */
- #ifdef OS2
- x = is_a_tty(0) ? coninc(0) : /* with no echo ... */
- getchar();
- #else /* OS2 */
- x = getchar();
- #endif /* OS2 */
- while ((x != NL) && (x != CR)) {
- if ((x &= 0177) == '?') {
- printf("? Password of remote directoryn Password: ");
- s2 = sbuf;
- *sbuf = NUL;
- } else if (x == ESC) /* Mini command line editor... */
- bleep(BP_WARN);
- else if (x == BS || x == 0177)
- s2--;
- else if (x == 025) { /* Ctrl-U */
- s2 = sbuf;
- *sbuf = NUL;
- } else
- *s2++ = x;
- /* Get the next character */
- #ifdef IKSD
- if (!local && inserver) {
- x = coninc(0);
- } else
- #endif /* IKSD */
- #ifdef OS2
- x = is_a_tty(0) ? coninc(0) : /* with no echo ... */
- getchar();
- #else /* OS2 */
- x = getchar();
- #endif /* OS2 */
- }
- *s2 = NUL;
- putchar('n');
- }
- s2 = sbuf;
- } else s2 = "";
- #endif /* DIRPWDPR */
- debug(F110," password",s2,0);
- sstate = setgen('C',s,s2,"");
- retcode = 0;
- break;
- case XZDEL: /* Delete */
- if ((x = cmtxt("Name of remote file(s) to delete",
- "",&s,xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of remote file(s) requiredn");
- return(-9);
- } else return(x);
- }
- if ((x = remtxt(&s)) < 0)
- return(x);
- if (local) ttflui(); /* If local, flush tty input buffer */
- retcode = sstate = rfilop(s,'E');
- break;
- case XZDIR: /* Directory */
- if ((x = cmtxt("Remote directory or file specification","",&s,
- xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- if (local) ttflui(); /* If local, flush tty input buffer */
- rmsg();
- retcode = sstate = setgen('D',s,"","");
- break;
- case XZHLP: /* Help */
- if ((x = remcfm()) < 0) return(x);
- sstate = setgen('H',"","","");
- retcode = 0;
- break;
- case XZHOS: /* Host */
- if ((x = cmtxt("Command for remote system","",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- if ((y = (int)strlen(s)) < 1)
- return(x);
- strcpy(line,s);
- cmarg = line;
- rmsg();
- retcode = sstate = 'c';
- break;
- #ifndef NOFRILLS
- case XZKER:
- if ((x = cmtxt("Command for remote Kermit","",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- if ((int)strlen(s) < 1) {
- if (x == -3) {
- printf("?Remote Kermit command requiredn");
- return(-9);
- } else return(x);
- }
- strcpy(line,s);
- cmarg = line;
- retcode = sstate = 'k';
- rmsg();
- break;
- case XZLGI: /* Login */
- return(plogin(XXREM));
- case XZLGO: { /* Logout */
- extern int bye_active;
- if ((x = remcfm()) < 0) return(x);
- sstate = setgen('I',"","","");
- retcode = 0;
- bye_active = 1; /* Close connection when done */
- break;
- }
- case XZPRI: /* Print */
- if (!atdiso || !atcapr) { /* Disposition attribute off? */
- printf("?Disposition Attribute is Offn");
- return(-2);
- }
- cmarg = "";
- cmarg2 = "";
- if ((x = cmifi("Local file(s) to print on remote printer","",&s,&y,
- xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of local file(s) requiredn");
- return(-9);
- }
- return(x);
- }
- strcpy(line,s); /* Make a safe copy of filename */
- *optbuf = NUL; /* Wipe out any old options */
- if ((x = cmtxt("Options for remote print command","",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- strcpy(optbuf,s); /* Make a safe copy of options */
- if ((int)strlen(optbuf) > 94) { /* Make sure this is legal */
- printf("?Option string too longn");
- return(-9);
- }
- nfils = -1; /* Expand file list internally */
- cmarg = line; /* Point to file list. */
- rprintf = 1; /* REMOTE PRINT modifier for SEND */
- sstate = 's'; /* Set start state to SEND */
- if (local) displa = 1;
- retcode = 0;
- break;
- #endif /* NOFRILLS */
- case XZSPA: /* Space */
- if ((x = cmtxt("Confirm, or remote directory name",
- "",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- retcode = sstate = setgen('U',s,"","");
- break;
- #ifndef NOFRILLS
- case XZTYP: /* Type */
- if ((x = cmtxt("Remote file specification","",&s,xxstring)) < 0)
- return(x);
- if ((int)strlen(s) < 1) {
- printf("?Remote filename requiredn");
- return(-9);
- }
- if ((x = remtxt(&s)) < 0)
- return(x);
- rmsg();
- retcode = sstate = rfilop(s,'T');
- break;
- #endif /* NOFRILLS */
- #ifndef NOFRILLS
- case XZWHO:
- if ((x = cmtxt("Remote user name, or carriage return",
- "",&s,xxstring)) < 0)
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- retcode = sstate = setgen('W',s,"","");
- break;
- #endif /* NOFRILLS */
- case XZPWD: /* PWD */
- if ((x = remcfm()) < 0) return(x);
- sstate = setgen('A',"","","");
- retcode = 0;
- break;
- #ifndef NOSPL
- case XZQUE: { /* Query */
- char buf[2];
- extern char querybuf[], * qbufp;
- extern int qbufn;
- if ((y = cmkey(vartyp,nvartyp,"","",xxstring)) < 0)
- return(y);
- if ((x = cmtxt(y == 'F' ? "Remote function invocation" :
- ('K' ? "Remote variable name or function":
- "Remote variable name"),
- "",
- &s,
- (y == 'K') ? xxstring : NULL
- )) < 0) /* Don't evaluate */
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- query = 1; /* QUERY is active */
- qbufp = querybuf; /* Initialize query response buffer */
- qbufn = 0;
- querybuf[0] = NUL;
- buf[0] = (char) (y & 127);
- buf[1] = NUL;
- retcode = sstate = setgen('V',"Q",(char *)buf,s);
- break;
- }
- case XZASG: { /* Assign */
- char buf[VNAML];
- if ((y = cmfld("Remote variable name","",&s,NULL)) < 0) /* No eval */
- return(y);
- strcpy(buf,s);
- if ((x = cmtxt("Assignment for remote variable",
- "",&s,xxstring)) < 0) /* Evaluate this one */
- return(x);
- if ((x = remtxt(&s)) < 0)
- return(x);
- #ifdef COMMENT
- /*
- Server commands can't be long packets. In principle there's no reason
- why they shouldn't be, except that we don't know at this point if the
- server is capable of accepting long packets because we haven't started
- the protocol yet. In practice, allowing a long packet here breaks a lot
- of assumptions, causes buffer overruns and crashes, etc. To be fixed
- later. (But since this is commented out, evidently I fixed it later...)
- */
- if ((int)strlen(s) > 85) { /* Allow for encoding expansion */
- printf("?Sorry, value is too long - 85 characters maxn");
- return(-9);
- }
- #endif /* COMMENT */
- retcode = sstate = setgen('V',"S",(char *)buf,s);
- break;
- }
- #endif /* NOSPL */
- #ifndef MAXPATHLEN
- #define MAXPATHLEN 256
- #endif /* MAXPATHLEN */
- case XZCPY: { /* Copy */
- char buf[MAXPATHLEN+1];
- buf[MAXPATHLEN] = ' ';
- if ((x = cmfld("Name of remote file to copy","",&s,xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of remote file requiredn");
- return(-9);
- }
- else
- return(x);
- }
- ckstrncpy(buf,s,MAXPATHLEN);
- if ((x = cmfld("Name of remote destination file or directory",
- "",&s, xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of remote file or directory requiredn");
- return(-9);
- } else return(x);
- }
- strcpy(tmpbuf,s);
- if ((x = remcfm()) < 0)
- return(x);
- if (local) ttflui(); /* If local, flush tty input buffer */
- retcode = sstate = setgen('K',buf,tmpbuf,"");
- break;
- }
- case XZREN: { /* Rename */
- char buf[MAXPATHLEN+1];
- buf[MAXPATHLEN] = ' ';
- if ((x = cmfld("Name of remote file to rename",
- "",&s,xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of remote file requiredn");
- return(-9);
- } else return(x);
- }
- ckstrncpy(buf,s,MAXPATHLEN);
- if ((x = cmfld("New name of remote file","",&s, xxstring)) < 0) {
- if (x == -3) {
- printf("?Name of remote file requiredn");
- return(-9);
- } else return(x);
- }
- strcpy(tmpbuf,s);
- if ((x = remcfm()) < 0)
- return(x);
- if (local) ttflui(); /* If local, flush device buffer */
- retcode = sstate = setgen('R',buf,tmpbuf,"");
- break;
- }
- case XZMKD: /* mkdir */
- case XZRMD: /* rmdir */
- if ((x = cmtxt((xx == XZMKD) ?
- "Name of remote directory to create" :
- "Name of remote directory to delete",
- "",
- &s,
- xxstring
- )) < 0) {
- if (x == -3) {
- printf("?Name requiredn");
- return(-9);
- } else return(x);
- }
- if ((x = remtxt(&s)) < 0)
- return(x);
- if (local) ttflui(); /* If local, flush tty input buffer */
- retcode = sstate = rfilop(s, (char)(xx == XZMKD ? 'm' : 'd'));
- break;
- case XZXIT: /* Exit */
- if ((x = remcfm()) < 0) return(x);
- sstate = setgen('X',"","","");
- retcode = 0;
- break;
- default:
- if ((x = remcfm()) < 0) return(x);
- printf("?Not implemented - %sn",cmdbuf);
- return(-2);
- }
- if (local && retcode > -1) /* If local, flush tty input buffer */
- ttflui();
- return(retcode);
- }
- /* R F I L O P -- Remote File Operation */
- CHAR
- #ifdef CK_ANSIC
- rfilop(char * s, char t)
- #else
- rfilop(s,t) char *s, t;
- #endif /* CK_ANSIC */
- /* rfilop */ {
- if (*s == NUL) {
- printf("?File specification requiredn");
- return((CHAR) 0);
- }
- debug(F111,"rfilop",s,t);
- return(setgen(t,s,"",""));
- }
- #endif /* NOXFER */
- #ifdef ANYX25
- int
- setx25() {
- if ((y = cmkey(x25tab,nx25,"X.25 call options","",xxstring)) < 0)
- return(y);
- switch (y) {
- case XYUDAT:
- if ((z = cmkey(onoff,2,"X.25 call user data","",xxstring))
- < 0) return(z);
- if (z == 0) {
- if ((z = cmcfm()) < 0) return(z);
- cudata = 0; /* disable call user data */
- return (success = 1);
- }
- if ((x = cmtxt("X.25 call user data string","",&s,xxstring)) < 0)
- return(x);
- if ((int)strlen(s) == 0) {
- return (-3);
- } else if ((int)strlen(s) > MAXCUDATA) {
- printf("?The length must be > 0 and <= %dn",MAXCUDATA);
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- strcpy(udata,s);
- cudata = 1; /* X.25 call user data specified */
- return (success = 1);
- case XYCLOS:
- if ((z = cmkey(onoff,2,"X.25 closed user group call","",xxstring))
- < 0) return(z);
- if (z == 0) {
- if ((z = cmcfm()) < 0) return(z);
- closgr = -1; /* disable closed user group */
- return (success = 1);
- }
- if ((y = cmnum("0 <= cug index >= 99","",10,&x,xxstring)) < 0)
- return(y);
- if (x < 0 || x > 99) {
- printf("?The choices are 0 <= cug index >= 99n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- closgr = x; /* closed user group selected */
- return (success = 1);
- case XYREVC:
- if((z = cmkey(onoff,2,"X.25 reverse charge call","",xxstring)) < 0)
- return(z);
- if ((x = cmcfm()) < 0) return(x);
- revcall = z;
- return (success = 1);
- }
- }
- #ifndef IBMX25
- int
- setpadp() {
- if ((y = cmkey(padx3tab,npadx3,"PAD X.3 parameter name","",xxstring)) < 0)
- return(y);
- x = y;
- switch (x) {
- case PAD_BREAK_CHARACTER:
- if ((y = cmnum("PAD break character value","",10,&z,xxstring)) < 0)
- return(y);
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_ESCAPE:
- if ((y = cmnum("PAD escape","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_ECHO:
- if ((y = cmnum("PAD echo","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_DATA_FORWARD_CHAR:
- if ((y = cmnum("PAD data forward char","",10,&z,xxstring)) < 0)
- return(y);
- if (z != 0 && z != 2) {
- printf("?The choices are 0 or 2n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_DATA_FORWARD_TIMEOUT:
- if ((y = cmnum("PAD data forward timeout","",10,&z,xxstring)) < 0)
- return(y);
- if (z < 0 || z > 255) {
- printf("?The choices are 0 or 1 <= timeout <= 255n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_FLOW_CONTROL_BY_PAD:
- if ((y = cmnum("PAD pad flow control","",10,&z,xxstring)) < 0)
- return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_SUPPRESSION_OF_SIGNALS:
- if ((y = cmnum("PAD service","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_BREAK_ACTION:
- if ((y = cmnum("PAD break action","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1 && z != 2 && z != 5 && z != 8 && z != 21) {
- printf("?The choices are 0, 1, 2, 5, 8 or 21n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_SUPPRESSION_OF_DATA:
- if ((y = cmnum("PAD data delivery","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_PADDING_AFTER_CR:
- if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
- if (z < 0 || z > 7) {
- printf("?The choices are 0 or 1 <= crpad <= 7n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_LINE_FOLDING:
- if ((y = cmnum("PAD linefold","",10,&z,xxstring)) < 0) return(y);
- if (z < 0 || z > 255) {
- printf("?The choices are 0 or 1 <= linefold <= 255n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_LINE_SPEED:
- if ((y = cmnum("PAD baudrate","",10,&z,xxstring)) < 0) return(y);
- if (z < 0 || z > 18) {
- printf("?The choices are 0 <= baudrate <= 18n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_FLOW_CONTROL_BY_USER:
- if ((y = cmnum("PAD terminal flow control","",10,&z,xxstring)) < 0)
- return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_LF_AFTER_CR:
- if ((y = cmnum("PAD crpad","",10,&z,xxstring)) < 0) return(y);
- if (z < 0 || z == 3 || z > 7) {
- printf("?The choices are 0, 1, 2, 4, 5, 6 or 7n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_PADDING_AFTER_LF:
- if ((y = cmnum("PAD lfpad","",10,&z,xxstring)) < 0) return(y);
- if (z < 0 || z > 7) {
- printf("?The choices are 0 or 1 <= lfpad <= 7n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_EDITING:
- if ((y = cmnum("PAD edit control","",10,&z,xxstring)) < 0) return(y);
- if (z != 0 && z != 1) {
- printf("?The choices are 0 or 1n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_CHAR_DELETE_CHAR:
- if ((y = cmnum("PAD char delete char","",10,&z,xxstring)) < 0)
- return(y);
- if (z < 0 || z > 127) {
- printf("?The choices are 0 or 1 <= chardelete <= 127n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_BUFFER_DELETE_CHAR:
- if ((y = cmnum("PAD buffer delete char","",10,&z,xxstring)) < 0)
- return(y);
- if (z < 0 || z > 127) {
- printf("?The choices are 0 or 1 <= bufferdelte <= 127n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- case PAD_BUFFER_DISPLAY_CHAR:
- if ((y = cmnum("PAD display line char","",10,&z,xxstring)) < 0)
- return(y);
- if (z < 0 || z > 127) {
- printf("?The choices are 0 or 1 <= displayline <= 127n");
- return(-2);
- }
- if ((y = cmcfm()) < 0) return(y);
- break;
- }
- padparms[x] = z;
- return(success = 1);
- }
- #endif /* IBMX25 */
- #endif /* ANYX25 */
- #ifndef NOXFER
- int
- setat(rmsflg) int rmsflg; {
- int xx;
- if ((y = cmkey(attrtab,natr,"File Attribute packets","",xxstring)) < 0)
- return(y);
- if (y == AT_XALL) { /* ATTRIBUTES ALL ON or ALL OFF */
- if ((z = seton(&xx)) < 0) return(z);
- if (rmsflg) {
- printf("Sorry, command not availablen");
- return(-9);
- } else {
- atenci = xx; /* Encoding in */
- atenco = xx; /* Encoding out */
- atdati = xx; /* Date in */
- atdato = xx; /* Date out */
- atdisi = xx; /* Disposition in/out */
- atdiso = xx;
- atleni = xx; /* Length in/out (both kinds) */
- atleno = xx;
- atblki = xx; /* Blocksize in/out */
- atblko = xx;
- attypi = xx; /* File type in/out */
- attypo = xx;
- atsidi = xx; /* System ID in/out */
- atsido = xx;
- atsysi = xx; /* System-dependent params in/out */
- atsyso = xx;
- #ifdef CK_PERMS /* Protection */
- atlpri = xx; /* Local in */
- atlpro = xx; /* Local out */
- atgpri = xx; /* Generic in */
- atgpro = xx; /* Generic out */
- #endif /* CK_PERMS */
- #ifdef STRATUS
- atfrmi = xx; /* Format in/out */
- atfrmo = xx;
- atcrei = xx; /* Creator id in/out */
- atcreo = xx;
- atacti = xx; /* Account in/out */
- atacto = xx;
- #endif /* STRATUS */
- }
- return(z);
- } else if (y == AT_ALLY || y == AT_ALLN) { /* ATTRIBUTES ON or OFF */
- if ((x = cmcfm()) < 0) return(x);
- atcapr = (y == AT_ALLY) ? 1 : 0;
- if (rmsflg) {
- sstate = setgen('S', "132", atcapr ? "1" : "0", "");
- return((int) sstate);
- } else return(success = 1);
- }
- /* Otherwise, it's an individual attribute that wants turning off/on */
- if ((z = cmkey(onoff,2,"","",xxstring)) < 0) return(z);
- if ((x = cmcfm()) < 0) return(x);
- /* There are better ways to do this... */
- /* The real problem is that we're not separating the in and out cases */
- /* and so we have to arbitrarily pick the "in" case, i.e tell the remote */
- /* server to ignore incoming attributes of the specified type, rather */
- /* than telling it not to send them. The protocol does not (yet) define */
- /* codes for "in-and-out-at-the-same-time". */
- switch (y) {
- #ifdef CK_PERMS
- /* We're lumping local and generic protection together for now... */
- case AT_LPRO:
- case AT_GPRO:
- if (rmsflg) {
- sstate = setgen('S', "143", z ? "1" : "0", "");
- return((int) sstate);
- }
- atlpri = atlpro = atgpri = atgpro = z; break;
- #endif /* CK_PERMS */
- case AT_DISP:
- if (rmsflg) {
- sstate = setgen('S', "142", z ? "1" : "0", "");
- return((int) sstate);
- }
- atdisi = atdiso = z; break;
- case AT_ENCO:
- if (rmsflg) {
- sstate = setgen('S', "141", z ? "1" : "0", "");
- return((int) sstate);
- }
- atenci = atenco = z; break;
- case AT_DATE:
- if (rmsflg) {
- sstate = setgen('S', "135", z ? "1" : "0", "");
- return((int) sstate);
- }
- atdati = atdato = z; break;
- case AT_LENB:
- case AT_LENK:
- if (rmsflg) {
- sstate = setgen('S', "133", z ? "1" : "0", "");
- return((int) sstate);
- }
- atleni = atleno = z; break;
- case AT_BLKS:
- if (rmsflg) {
- sstate = setgen('S', "139", z ? "1" : "0", "");
- return((int) sstate);
- }
- atblki = atblko = z; break;
- case AT_FTYP:
- if (rmsflg) {
- sstate = setgen('S', "134", z ? "1" : "0", "");
- return((int) sstate);
- }
- attypi = attypo = z; break;
- #ifdef STRATUS
- case AT_CREA:
- if (rmsflg) {
- sstate = setgen('S', "136", z ? "1" : "0", "");
- return((int) sstate);
- }
- atcrei = atcreo = z; break;
- case AT_ACCT:
- if (rmsflg) {
- sstate = setgen('S', "137", z ? "1" : "0", "");
- return((int) sstate);
- }
- atacti = atacto = z; break;
- #endif /* STRATUS */
- case AT_SYSI:
- if (rmsflg) {
- sstate = setgen('S', "145", z ? "1" : "0", "");
- return((int) sstate);
- }
- atsidi = atsido = z; break;
- #ifdef STRATUS
- case AT_RECF:
- if (rmsflg) {
- sstate = setgen('S', "146", z ? "1" : "0", "");
- return((int) sstate);
- }
- atfrmi = atfrmo = z; break;
- #endif /* STRATUS */
- case AT_SYSP:
- if (rmsflg) {
- sstate = setgen('S', "147", z ? "1" : "0", "");
- return((int) sstate);
- }
- atsysi = atsyso = z; break;
- default:
- printf("?Not availablen");
- return(-2);
- }
- return(1);
- }
- #endif /* NOXFER */
- #ifndef NOSPL
- int
- setinp() {
- if ((y = cmkey(inptab,ninp,"","",xxstring)) < 0) return(y);
- switch (y) {
- #ifdef OS2
- case IN_PAC: /* SET INPUT PACING */
- z = cmnum("milliseconds","0",10,&x,xxstring);
- return(setnum(&tt_inpacing,x,z,1000));
- case IN_TRM: /* SET INPUT TERMINAL */
- return(seton(&interm));
- #endif /* OS2 */
- case IN_DEF: /* SET INPUT DEFAULT-TIMEOUT */
- z = cmnum("Positive number","",10,&x,xxstring);
- return(setnum(&indef,x,z,94));
- case IN_TIM: /* SET INPUT TIMEOUT-ACTION */
- if ((z = cmkey(intimt,2,"","",xxstring)) < 0) return(z);
- if ((x = cmcfm()) < 0) return(x);
- intime[cmdlvl] = z;
- return(success = 1);
- case IN_CAS: /* SET INPUT CASE */
- if ((z = cmkey(incast,2,"","",xxstring)) < 0) return(z);
- if ((x = cmcfm()) < 0) return(x);
- inpcas[cmdlvl] = z;
- return(success = 1);
- case IN_ECH: /* SET INPUT ECHO */
- return(seton(&inecho));
- case IN_SIL: /* SET INPUT SILENCE */
- z = cmnum("Seconds of inactivity before INPUT fails","",10,&x,
- xxstring);
- return(setnum(&insilence,x,z,-1));
- case IN_BUF: /* SET INPUT BUFFER-SIZE */
- if ((z = cmnum("Number of bytes in INPUT buffer",
- ckitoa(INPBUFSIZ),10,&x, xxstring)) < 0)
- return(z);
- if ((y = cmcfm()) < 0) return(y);
- inbufsize = 0;
- if (inpbuf) {
- free(inpbuf);
- inpbuf = NULL;
- inpbp = NULL;
- }
- if (!(s = (char *)malloc(x + 1)))
- return(0);
- inpbuf = s;
- inpbp = s;
- inbufsize = x;
- for (x = 0; x <= inbufsize; x++)
- inpbuf[x] = NUL;
- return(success = 1);
- #ifdef CK_AUTODL
- case IN_ADL: /* AUTODOWNLOAD */
- return(seton(&inautodl));
- #endif /* CK_AUTODL */
- case IN_CAN: /* SET INPUT INTERRUPTS */
- return(seton(&inintr));
- }
- return(0);
- }
- #endif /* NOSPL */
- #ifdef NETCONN
- VOID
- ndreset() {
- #ifndef NODIAL /* This depends on DIAL... */
- int i=0, j=0;
- if (!ndinited) /* Don't free garbage... */
- return;
- for (i = 0; i < nhcount; i++) { /* Clean out previous list */
- if (nh_p[i])
- free(nh_p[i]);
- nh_p[i] = NULL;
- if (nh_p2[i])
- free(nh_p2[i]);
- nh_p2[i] = NULL;
- for (j = 0; j < 4; j++) {
- if (nh_px[j][i])
- free(nh_px[j][i]);
- nh_px[j][i] = NULL;
- }
- }
- #endif /* NODIAL */
- }
- VOID
- ndinit() { /* Net directory pointers */
- #ifndef NODIAL /* This depends on DIAL... */
- int i, j;
- if (ndinited++) /* Don't do this more than once. */
- return;
- for (i = 0; i < MAXDDIR; i++) { /* Init all pointers to NULL */
- netdir[i] = NULL;
- }
- for (i = 0; i < MAXDNUMS; i++) {
- nh_p[i] = NULL;
- nh_p2[i] = NULL;
- for (j = 0; j < 4; j++)
- nh_px[j][i] = NULL;
- }
- #endif /* NODIAL */
- }
- #ifndef NODIAL
- #ifdef NETCONN
- VOID /* Get net defaults from environment */
- getnetenv() {
- char *p = NULL;
- makestr(&p,getenv("K_NET_DIRECTORY")); /* Dialing directories */
- if (p) {
- int i;
- xwords(p,MAXDDIR,netdir,0);
- for (i = 0; i < MAXDDIR; i++) { /* Fill in any gaps... */
- if (!netdir[i+1])
- break;
- else
- netdir[i] = netdir[i+1];
- debug(F111,"netdir[i]",netdir[i],i);
- }
- nnetdir = i;
- }
- }
- #endif /* NETCONN */
- #endif /* NODIAL */
- int
- #ifdef CK_ANSIC
- lunet(char *s) /* s = name to look up */
- #else
- lunet(s) char *s;
- #endif /* CK_ANSIC */
- /* lunet */ {
- #ifndef NODIAL /* This depends on DIAL... */
- int n, n1, t, dd = 0;
- int ambiguous = 0;
- FILE * f;
- char *line = NULL;
- extern int dialdpy;
- int netdpy = dialdpy;
- char *info[8];
- nhcount = 0; /* Set this before returning */
- if (!s || nnetdir < 1) /* Validate arguments */
- return(-1);
- if (isdigit(*s) || *s == '*' || *s == '.')
- return(0);
- if ((n1 = (int) strlen(s)) < 1) /* Length of string to look up */
- return(-1);
- if (!(line = malloc(1024))) /* Allocate input buffer */
- return(-1);
- lu_again:
- f = NULL; /* Network directory file descriptor */
- t = nhcount = 0; /* Match count */
- dd = 0; /* Directory counter */
- dirline = 0;
- while (1) { /* We make one pass */
- if (!f) { /* Directory not open */
- if (dd >= nnetdir) /* No directories left? */
- break; /* Done. */
- if ((f = fopen(netdir[dd],"r")) == NULL) { /* Open it */
- perror(netdir[dd]); /* Can't, print message saying why */
- dd++;
- continue; /* But go on to next one. */
- }
- if (netdpy)
- printf("Opening %s...n",netdir[dd]);
- dd++;
- }
- line[0] = NUL;
- if (getnct(line,1023,f,1) < 0) { /* Read a line */
- if (f) { /* f can be clobbered! */
- fclose(f); /* Close the file */
- f = NULL; /* Indicate next one needs opening */
- }
- continue;
- }
- if (!line[0]) /* Empty line */
- continue;
- xwords(line,7,info,0); /* Parse it */
- if (!info[1] || !info[2] || !info[3]) /* Required fields */
- continue;
- if (*info[1] == ';') /* Full-line comment */
- continue;
- if ((n = (int) strlen(info[1])) < 1) /* Length of name-tag */
- continue;
- if (n < n1) /* Search name is longer */
- continue; /* Can't possibly match */
- if (ambiguous && n != n1)
- continue;
- if (ckstrcmp(s,info[1],n1,0)) /* Compare using length of */
- continue; /* search string s. */
- /* Have a match */
- makestr(&(nh_p[nhcount]), info[3]); /* address */
- makestr(&(nh_p2[nhcount]),info[2]); /* net type */
- makestr(&(nh_px[0][nhcount]),info[4]); /* net-specific stuff... */
- makestr(&(nh_px[1][nhcount]),info[5]);
- makestr(&(nh_px[2][nhcount]),info[6]);
- makestr(&(nh_px[3][nhcount]),info[7]);
- nhcount++; /* Count this match */
- if (nhcount > MAXDNUMS) { /* Watch out for too many */
- printf("Warning: %d matches found, %d maxn",
- nhcount,
- MAXDNUMS
- );
- nhcount = MAXDNUMS;
- break;
- }
- if (nhcount == 1) { /* First one - save entry name */
- if (n_name) { /* Free the one from before if any */
- free(n_name);
- n_name = NULL;
- }
- if (!(n_name = (char *)malloc(n + 1))) { /* Allocate new storage */
- printf("?memory allocation error - lunet:3n");
- if (line) {
- free(line);
- line = NULL;
- }
- nhcount = 0;
- return(-1);
- }
- t = n; /* Remember its length */
- strcpy(n_name,info[1]);
- } else { /* Second or subsequent one */
- if ((int) strlen(info[1]) == t) /* Lengths compare */
- if (!ckstrcmp(n_name,info[1],t,0)) /* Caseless compare OK */
- continue;
- /* Name given by user matches entries with different names */
- if (ambiguous) /* Been here before */
- break;
- ambiguous = 1; /* Now an exact match is required */
- ndreset(); /* Clear out previous list */
- goto lu_again; /* Do it all over again. */
- }
- }
- if (line) {
- free(line);
- line = NULL;
- }
- if (nhcount == 0 && ambiguous)
- printf("Ambiguous - "%s" different names in network directoryn",s);
- #else
- nhcount = 0;
- #endif /* NODIAL */
- return(nhcount);
- }
- #endif /* NETCONN */
- #ifndef NOLOCAL
- /* C L S C O N N X -- Close connection */
- int
- clsconnx(ask) int ask; {
- int x, rc = 0;
- debug(F101,"clsconnx local","",local);
- if (local) {
- x = ask ? hupok(1) : 1; /* Make sure it's OK to close */
- if (!x) {
- rc = -1;
- debug(F101,"clsconnx hupok says no","",rc);
- return(rc);
- }
- ttflui(); /* Clear away buffered up junk */
- #ifndef NODIAL
- #ifdef OS2ONLY
- /* Don't hangup a line that is shared with the SLIP or PPP driver */
- if (!ttslip && !ttppp)
- #endif /* OS2ONLY */
- mdmhup();
- #endif /* NODIAL */
- if (network && msgflg)
- printf(" Closing connectionn");
- ttclos(0); /* Close old connection, if any */
- rc = 1;
- {
- extern int wasclosed, whyclosed;
- if (wasclosed) {
- whyclosed = WC_CLOS;
- #ifndef NOSPL
- if (nmac) { /* Any macros defined? */
- int k; /* Yes */
- /* printf("ON_CLOSE CLSCONNXn"); */
- wasclosed = 0;
- k = mlook(mactab,"on_close",nmac); /* Look this up */
- if (k >= 0) { /* If found, */
- if (dodo(k,ckitoa(whyclosed),0) > -1) /* set it up, */
- parser(1); /* and execute it */
- }
- }
- #endif /* NOSPL */
- whyclosed = WC_REMO;
- wasclosed = 0;
- }
- }
- }
- #ifdef VMS /* Or maybe #ifndef UNIX? */
- else { /* Need to do this in VMS to */
- ttclos(0); /* free the tty channel number */
- rc = 1; /* obtained in ttopen() or else */
- } /* subsequent ttopen's won't work */
- #endif /* VMS */
- #ifdef CKLOGDIAL
- dologend();
- #endif /* CKLOGDIAL */
- haveline = 0;
- if (mdmtyp < 0) { /* Switching from net to async? */
- if (mdmsav > -1) /* Restore modem type from last */
- mdmtyp = mdmsav; /* SET MODEM command, if any. */
- else
- mdmtyp = 0;
- mdmsav = -1;
- }
- if (network)
- network = 0;
- #ifdef NETCONN
- if (oldplex > -1) { /* Restore previous duplex setting. */
- duplex = oldplex;
- oldplex = -1;
- }
- #endif /* NETCONN */
- #ifndef MAC
- strcpy(ttname,dftty); /* Restore default communication */
- #endif /* MAC */
- local = dfloc; /* device and local/remote status */
- if (local) {
- cxtype = CXT_DIRECT; /* Something reasonable */
- speed = ttgspd(); /* Get the current speed */
- } else {
- cxtype = CXT_REMOTE;
- speed = -1L;
- }
- #ifndef NOXFER
- if (xreliable > -1 && !setreliable) {
- reliable = xreliable;
- debug(F101,"clsconnx reliable A","",reliable);
- } else if (!setreliable) {
- reliable = SET_AUTO;
- debug(F101,"clsconnx reliable B","",reliable);
- }
- #endif /* NOXFER */
- setflow(); /* Revert flow control */
- return(rc);
- }
- VOID
- slrestor() {
- int x;
- #ifdef CK_AUTHENTICATION
- if (sl_auth_saved) {
- for (x = 0; x < AUTHTYPLSTSZ; x++)
- auth_type_user[x] = sl_auth_type_user[x];
- sl_auth_saved = 0;
- }
- if (sl_topt_a_s_saved) {
- TELOPT_DEF_S_U_MODE(TELOPT_AUTHENTICATION) = sl_topt_a_su;
- sl_topt_a_s_saved = 0;
- }
- if (sl_topt_a_c_saved) {
- TELOPT_DEF_C_ME_MODE(TELOPT_AUTHENTICATION) = sl_topt_a_cm;
- sl_topt_a_c_saved = 0;
- }
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_ENCRYPTION
- if (sl_cx_saved) {
- cx_type = sl_cx_type;
- sl_cx_saved = 0;
- }
- if (sl_topt_e_s_saved) {
- TELOPT_DEF_S_U_MODE(TELOPT_ENCRYPTION) = sl_topt_e_su;
- TELOPT_DEF_S_ME_MODE(TELOPT_ENCRYPTION) = sl_topt_e_sm;
- sl_topt_e_s_saved = 0;
- }
- if (sl_topt_e_c_saved) {
- TELOPT_DEF_C_U_MODE(TELOPT_ENCRYPTION) = sl_topt_e_cu;
- TELOPT_DEF_C_ME_MODE(TELOPT_ENCRYPTION) = sl_topt_e_cm;
- sl_topt_e_c_saved = 0;
- }
- #endif /* CK_ENCRYPTION */
- if (sl_uid_saved) {
- ckstrncpy(uidbuf,sl_uidbuf,UIDBUFLEN);
- sl_uid_saved = 0;
- }
- #ifdef TNCODE
- if (sl_tn_saved) {
- tn_wait_flg = sl_tn_wait;
- sl_tn_saved = 0;
- }
- #endif /* TNCODE */
- }
- /* S E T L I N -- parse name of and then open communication device. */
- /*
- Call with:
- xx == XYLINE for a serial (tty) line, XYHOST for a network host,
- zz == 0 means if user doesn't give a device name, continue current
- active connection (if any);
- zz != 0 means if user doesn't give a device name, then close the
- current connection and restore the default communication device.
- fc == 0 to just make the connection, 1 to also CONNECT (e.g. "telnet").
- */
- int netsave = -1;
- static char * tmpstring = NULL;
- static char * tmpusrid = NULL;
- int
- setlin(xx, zz, fc) int xx, zz, fc; {
- extern char pwbuf[], * g_pswd;
- extern int pwflg, pwcrypt, g_pflg, g_pcpt, nolocal;
- int wait;
- int tn_wait_sv;
- int mynet;
- int _local = -1;
- int c, i, haveswitch = 0;
- int getval = 0;
- int wild = 0; /* Filespec has wildcards */
- int cx = 0; /* Connect after */
- int sx = 0; /* Become server after */
- #ifdef CK_ENCRYPTION
- int encrypt = 0; /* Encrypted? */
- int e_type = -1; /* Telnet /ENCRYPT type */
- #endif /* CK_ENCRYPTION */
- #ifdef CK_AUTHENTICATION
- int a_type = -1; /* Authentication type */
- #endif /* CK_AUTHENTICATION */
- #ifdef VMS
- int shr = 0; /* Share serial device */
- #endif /* VMS */
- int confirmed = 0; /* Command has been entered */
- struct FDB sw, tx, nx;
- #ifdef OS2
- struct FDB fl;
- #endif /* OS2 */
- char * ss;
- #ifdef TCPSOCKET
- int rawflg = 0;
- #endif /* TCPSOCKET */
- #ifdef OS2
- #define SRVBUFSIZ PIPENAML
- #else /* OS2 */
- #define SRVBUFSIZ 63
- #endif /* OS2 */
- char srvbuf[SRVBUFSIZ+1];
- char hostname[15*65];
- #ifdef OS2
- #ifdef NT
- int xxtapi = 0;
- #else
- int xxslip = 0, xxppp = 0;
- #endif /* NT */
- #endif /* OS2 */
- debug(F101,"setline fc","",fc);
- debug(F101,"setline zz","",zz);
- #ifdef TNCODE
- tn_wait_sv = tn_wait_flg;
- wait = tn_wait_flg;
- #else
- tn_wait_sv = 0;
- wait = 0;
- #endif /* TNCODE */
- mynet = nettype;
- if (nolocal) {
- slmsg = "Making connections is disabled";
- printf("?Sorry, making connections is disabledn");
- return(-9);
- }
- if (netsave > -1)
- nettype = netsave;
- if (fc != 0 || zz == 0) /* Preset /CONNECT switch */
- cx = 1;
- debug(F101,"setline cx","",cx);
- *srvbuf = NUL;
- line[0] = NUL;
- s = line;
- #ifdef NETCONN
- #ifndef NOSPL
- #ifdef CK_SRP
- if (tmpstring)
- makestr(&tmpstring,NULL);
- #endif /* CK_SRP */
- #ifdef RLOGCODE
- if (tmpusrid)
- makestr(&tmpusrid,NULL);
- #endif /* RLOGCODE */
- #endif /* NOSPL */
- #endif /* NETCONN */
- autoflow = 1; /* Enable automatic flow setting */
- if (xx == XYHOST) { /* SET HOST <hostname> */
- #ifndef NETCONN
- slmsg = "Network connections not supported";
- printf("?%sn",slmsg);
- return(-9);
- #else /* NETCONN */
- #ifndef NOPUSH
- if ((mynet == NET_CMD || mynet == NET_PTY) && nopush) {
- slmsg = "Access to external commands is disabled";
- printf("?Sorry, access to external commands is disabledn");
- return(-9);
- }
- #endif /* NOPUSH */
- /*
- Here we parse optional switches and then the hostname or whatever,
- which depends on the network type. The tricky part is, the network type
- can be set by a switch.
- */
- #ifndef NOSPL
- makestr(&g_pswd,pwbuf); /* Save global pwbuf */
- g_pflg = pwflg; /* and flag */
- g_pcpt = pwcrypt;
- #endif /* NOSPL */
- confirmed = 0;
- haveswitch = 0;
- #ifdef NETFILE
- if (mynet != NET_FILE) {
- #endif /* NETFILE */
- ss = (mynet == NET_CMD || mynet == NET_PTY) ?
- "Command, or switch" :
- (mynet == NET_TCPA || mynet == NET_TCPB) ?
- "Hostname, ip-address, or switch" :
- "Host or switch";
- if (fc) {
- if (ttnproto == NP_TELNET || ttnproto == NP_KERMIT) {
- if (nshteltab) {
- haveswitch++;
- cmfdbi(&sw,_CMKEY,ss,"","",nshteltab,4,xxstring,
- shteltab,&nx);
- }
- }
- #ifdef RLOGCODE
- else if (ttnproto == NP_RLOGIN) {
- if (nshrlgtab) {
- haveswitch++;
- cmfdbi(&sw,_CMKEY,ss,"","",nshrlgtab,4,xxstring,
- shrlgtab,&nx);
- }
- }
- #endif /* RLOGCODE */
- } else {
- haveswitch++;
- cmfdbi(&sw,_CMKEY,ss,"","",nshtab,4,xxstring,shtab,&nx);
- }
- #ifdef NETFILE
- }
- #endif /* NETFILE */
- if (mynet == NET_TCPB || mynet == NET_SLAT) {
- cmfdbi(&nx,_CMFLD,"Host","","",0,0,xxstring,NULL,NULL);
- #ifdef NETFILE
- } else if (mynet == NET_FILE) {
- cmfdbi(&nx,_CMIFI,"Filename","","",0,0,xxstring,NULL,NULL);
- #endif /* NETFILE */
- #ifdef PTYORPIPE
- } else if (mynet == NET_CMD || mynet == NET_PTY) {
- cmfdbi(&nx,_CMTXT,"Command","","",0,0,xxstring,NULL,NULL);
- #endif /* PTYORPIPE */
- } else {
- cmfdbi(&nx,_CMTXT,"Host","","",0,0,xxstring,NULL,NULL);
- }
- while (1) {
- x = cmfdb(haveswitch ? &sw : &nx);
- debug(F101,"setlin cmfdb","",x);
- if (x < 0)
- if (x != -3)
- return(x);
- if (x == -3) {
- if ((x = cmcfm()) < 0) {
- return(x);
- } else {
- confirmed = 1;
- break;
- }
- }
- if (cmresult.fcode != _CMKEY) { /* Not a switch */
- strcpy(line,cmresult.sresult); /* Save the data that */
- s = line; /* was parsed... */
- if (cmresult.fcode == _CMIFI) {
- wild = cmresult.nresult;
- } else if (cmresult.fcode == _CMTXT) {
- confirmed = 1;
- }
- break; /* and break out of this loop */
- }
- c = cmgbrk(); /* Have switch - get break character */
- getval = (c == ':' || c == '='); /* Must parse an agument? */
- if (getval && !(cmresult.kflags & CM_ARG)) {
- printf("?This switch does not take argumentsn");
- return(-9);
- }
- if (!getval && (cmgkwflgs() & CM_ARG)) {
- printf("?This switch requires an argumentn");
- return(-9);
- }
- switch (cmresult.nresult) { /* It's a switch.. */
- case SL_CNX: /* /CONNECT */
- cx = 1;
- sx = 0;
- break;
- case SL_SRV: /* /SERVER */
- cx = 0;
- sx = 1;
- break;
- #ifdef NETCMD
- case SL_CMD: /* /COMMAND */
- netsave = mynet;
- mynet = NET_CMD;
- break;
- #endif /* NETCMD */
- #ifdef NETPTY
- case SL_PTY: /* /PTY */
- netsave = mynet;
- mynet = NET_PTY;
- break;
- #endif /* NETPTY */
- case SL_NET: /* /NETWORK-TYPE */
- if ((x = cmkey(netcmd,nnets,"","",xxstring)) < 0)
- return(x);
- mynet = x;
- break;
- #ifndef NOSPL
- case SL_PSW: /* /PASSWORD: */
- if (!getval)
- break;
- if ((x = cmfld("Password","",&s,xxstring)) < 0) {
- if (x == -3) {
- makestr(&tmpstring,"");
- } else {
- return(x);
- }
- } else {
- s = brstrip(s);
- if ((x = (int)strlen(s)) > PWBUFL) {
- slmsg = "Internal error";
- printf("?Sorry, too long - max = %dn",PWBUFL);
- return(-9);
- }
- makestr(&tmpstring,s);
- }
- break;
- #endif /* NOSPL */
- case SL_UID: /* /USERID: */
- if (!getval)
- break;
- if ((x = cmfld("Userid","",&s,xxstring)) < 0) {
- if (x == -3) {
- makestr(&tmpusrid,"");
- } else {
- return(x);
- }
- } else {
- s = brstrip(s);
- if ((x = (int)strlen(s)) > 63) {
- slmsg = "Internal error";
- printf("?Sorry, too long - max = %dn",63);
- return(-9);
- }
- makestr(&tmpusrid,s);
- }
- break;
- #ifdef CK_AUTHENTICATION
- #ifdef CK_SRP
- case SL_SRP:
- a_type = AUTHTYPE_SRP;
- break;
- #endif /* CK_SRP */
- #ifdef CK_SSL
- case SL_SSL:
- a_type = AUTHTYPE_SSL;
- break;
- #endif /* CK_SSL */
- #ifdef NT
- case SL_NTLM:
- a_type = AUTHTYPE_NTLM;
- break;
- #endif /* NT */
- #ifdef CK_KERBEROS
- case SL_KRB4:
- a_type = AUTHTYPE_KERBEROS_V4;
- if (ttnproto == NP_RLOGIN)
- ttnproto =
- #ifdef CK_ENCRYPTION
- encrypt ? NP_EK4LOGIN :
- #endif /* CK_ENCRYPTION */
- NP_K4LOGIN;
- else if (ttnproto == NP_K5LOGIN)
- ttnproto = NP_K4LOGIN;
- #ifdef CK_ENCRYPTION
- else if (ttnproto == NP_EK5LOGIN)
- ttnproto = NP_EK4LOGIN;
- #endif /* CK_ENCRYPTION */
- break;
- case SL_KRB5:
- a_type = AUTHTYPE_KERBEROS_V5;
- if (ttnproto == NP_RLOGIN)
- ttnproto =
- #ifdef CK_ENCRYPTION
- encrypt ? NP_EK5LOGIN :
- #endif /* CK_ENCRYPTION */
- NP_K5LOGIN;
- else if (ttnproto == NP_K4LOGIN)
- ttnproto = NP_K5LOGIN;
- #ifdef CK_ENCRYPTION
- else if (ttnproto == NP_EK4LOGIN)
- ttnproto = NP_EK5LOGIN;
- #endif /* CK_ENCRYPTION */
- break;
- #endif /* CK_KERBEROS */
- case SL_AUTH: {
- extern struct keytab autyptab[];
- extern int nautyp;
- if ((x = cmkey(autyptab,nautyp,"type of authentication",
- "automatic",xxstring)) < 0)
- return(x);
- a_type = x;
- break;
- }
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_ENCRYPTION
- case SL_ENC:
- switch (ttnproto) {
- case NP_K4LOGIN:
- ttnproto = NP_EK4LOGIN;
- encrypt = 1;
- break;
- case NP_K5LOGIN:
- ttnproto = NP_EK5LOGIN;
- encrypt = 1;
- break;
- case NP_KERMIT:
- case NP_TELNET: {
- static struct keytab * tnetbl = NULL;
- static int ntnetbl = 0;
- x = ck_get_crypt_table(&tnetbl,&ntnetbl);
- debug(F101,"ck_get_crypt_table x","",x);
- debug(F101,"ck_get_crypt_table n","",ntnetbl);
- if (x < 1 || !tnetbl || ntnetbl < 1) /* Didn't get it */
- x = 0;
- if (!x) {
- slmsg = "Internal error";
- printf("?Oops, types not loadedn");
- return(-9);
- }
- if ((x = cmkey(tnetbl,ntnetbl,"type of encryption",
- "automatic",xxstring)) < 0)
- return(x);
- e_type = x;
- break;
- }
- }
- break;
- #endif /* CK_ENCRYPTION */
- case SL_WAIT:
- wait = 1;
- break;
- case SL_NOWAIT:
- wait = 0;
- break;
- }
- }
- #ifdef NETFILE
- if (mynet == NET_FILE) /* Parsed by cmifi() */
- if ((x = cmcfm()) < 0) /* Needs confirmation */
- return(x);
- #endif /* NETFILE */
- #ifdef NETCMD
- if (mynet == NET_CMD || mynet == NET_PTY) {
- char *p = NULL;
- if (!confirmed) {
- if ((x = cmtxt("Rest of command","",&s,xxstring)) < 0)
- return(x);
- if (*s) {
- strncat(line," ",LINBUFSIZ);
- strncat(line,s,LINBUFSIZ);
- }
- s = line;
- }
- s = brstrip(s);
- makestr(&p,s);
- strcpy(line,p);
- makestr(&p,NULL);
- s = line;
- }
- debug(F110,"SUNDAY 2",line,0);
- #endif /* NETCMD */
- #ifdef NPIPE /* Named pipe */
- if (mynet == NET_PIPE) { /* Needs backslash twiddling */
- if (*s) {
- if (strcmp(s,"*")) { /* If remote, */
- strcpy(line,"\\"); /* begin with server name */
- strncat(line,s,LINBUFSIZ);
- } else {
- line[0]=' ';
- }
- strncat(line,"\pipe\", LINBUFSIZ); /* Make it a pipe name */
- strncat(line,pipename, LINBUFSIZ); /* Add name of pipe */
- s = line;
- }
- }
- #endif /* NPIPE */
- #ifdef SUPERLAT
- if (mynet == NET_SLAT) { /* Needs password, etc. */
- slat_pwd[0] = NUL; /* Erase any previous password */
- if (*s) { /* If they gave a host name... */
- if ((x = cmfld(
- "password,n or carriage return if no password required",
- "",
- &s,
- xxstring
- )) < 0 && x != -3)
- return(x);
- ckstrncpy(slat_pwd,s,18); /* Set the password, if any */
- }
- if ((x = cmcfm()) < 0) return(x); /* Confirm the command */
- s = line;
- }
- #endif /* SUPERLAT */
- #ifdef TCPSOCKET
- if (mynet == NET_TCPB) { /* TCP/IP connection */
- debug(F110,"setlin service 0",srvbuf,0);
- debug(F110,"setlin host s 2",s,0);
- if (*s) { /* If they gave a host name... */
- debug(F110,"setlin host s 1",s,0);
- #ifdef NOLISTEN
- if (mynet == NET_TCPB && *s == '*') {
- slmsg = "Incoming connections not supported";
- printf(
- "?Sorry, incoming connections not supported in this version of Kermit.n"
- );
- return(-9);
- }
- #endif /* NOLISTEN */
- #ifdef RLOGCODE
- /* Allow a username if rlogin is requested */
- if (ttnproto == NP_RLOGIN
- #ifdef CK_AUTHENTICATION
- #ifdef CK_KERBEROS
- || ttnproto == NP_K4LOGIN || ttnproto == NP_EK4LOGIN
- || ttnproto == NP_K4LOGIN || ttnproto == NP_EK4LOGIN
- #endif /* CK_KERBEROS */
- #endif /* CK_AUTHENTICATION */
- ) {
- int y;
- uidflag = 0;
- /* Check for "host:service" */
- for ( ; (*s != ' ') && (*s != ':'); s++) ;
- if (*s) { /* Service, save it */
- *s = NUL;
- ckstrncpy(srvbuf,++s,SRVBUFSIZ);
- } else { /* No :service, then use default. */
- #ifdef VMS
- switch (ttnproto) {
- case NP_RLOGIN:
- strcpy(srvbuf,"513"); /* Use "login" */
- break;
- case NP_K4LOGIN:
- case NP_K5LOGIN:
- strcpy(srvbuf,"543"); /* Use "klogin" */
- break;
- case NP_EK4LOGIN:
- case NP_EK5LOGIN:
- strcpy(srvbuf,"2105"); /* Use "eklogin" */
- break;
- }
- #else /* VMS */
- switch (ttnproto) {
- case NP_RLOGIN:
- strcpy(srvbuf,"login");
- break;
- case NP_K4LOGIN:
- case NP_K5LOGIN:
- strcpy(srvbuf,"klogin");
- break;
- case NP_EK4LOGIN:
- case NP_EK5LOGIN:
- strcpy(srvbuf,"eklogin");
- break;
- }
- #endif /* VMS */
- }
- if (!confirmed) {
- y = cmfld("Userid on remote system",
- uidbuf,&s,xxstring);
- if (y < 0 && y != -3)
- return(y);
- if ((int)strlen(s) > 63) {
- slmsg = "Internal error";
- printf("Sorry, too longn");
- return(-9);
- }
- makestr(&tmpusrid,s);
- }
- } else { /* TELNET or SET HOST */
- #endif /* RLOGCODE */
- /* s = line; */
- /* Check for "host:service" */
- for ( ; (*s != ' ') && (*s != ':'); s++) ;
- if (*s) { /* Service, save it */
- *s = NUL;
- ckstrncpy(srvbuf,++s,SRVBUFSIZ);
- } else if (!confirmed) {
- /* No :service, let them type one. */
- if (*line != '*') { /* Not incoming */
- if (ttnproto == NP_KERMIT) {
- if ((x = cmfld(
- "TCP service name or number",
- "kermit",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- #ifdef RLOGCODE
- } else if (ttnproto == NP_RLOGIN) {
- if ((x = cmfld(
- "TCP service name or number,n or carriage return for rlogin (513)",
- "login",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- #ifdef CK_AUTHENTICATION
- #ifdef CK_KERBEROS
- } else if (ttnproto == NP_K4LOGIN ||
- ttnproto == NP_K5LOGIN) {
- if ((x = cmfld(
- "TCP service name or number,n or carriage return for klogin (543)",
- "klogin",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- } else if (ttnproto == NP_EK4LOGIN ||
- ttnproto == NP_EK5LOGIN) {
- if ((x = cmfld(
- "TCP service name or number,n or carriage return for eklogin (2105)",
- "eklogin",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- #endif /* CK_KERBEROS */
- #endif /* CK_AUTHENTICATION */
- #endif /* RLOGCODE */
- } else {
- if ((x = cmfld(
- "TCP service name or number",
- "telnet",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- }
- } else { /* Incoming connection */
- if ((x = cmfld("TCP service name or number",
- "",&s,xxstring)
- ) < 0 && x != -3)
- return(x);
- }
- if (*s) /* If they gave a service, */
- ckstrncpy(srvbuf,s,SRVBUFSIZ); /* copy it */
- }
- #ifdef RLOGCODE
- }
- #endif /* RLOGCODE */
- if (!confirmed) {
- char * defproto;
- switch (ttnproto) {
- case NP_RLOGIN:
- defproto = "/rlogin";
- break;
- case NP_K4LOGIN:
- defproto = "/k4login";
- break;
- case NP_K5LOGIN:
- defproto = "/k5login";
- break;
- case NP_EK4LOGIN:
- defproto = "/ek4login";
- break;
- case NP_EK5LOGIN:
- defproto = "/ek5login";
- break;
- case NP_KERMIT:
- case NP_TELNET:
- defproto = "/telnet";
- break;
- default:
- defproto = "/default";
- }
- if ((x = cmkey(tcprawtab,ntcpraw,"Switch",defproto,
- xxstring)) < 0) {
- if (x != -3)
- return(x);
- else if ((x = cmcfm()) < 0)
- return(x);
- } else {
- rawflg = x;
- if ((x = cmcfm()) < 0)
- return(x);
- switch (rawflg) {
- #ifdef CK_SSL
- case NP_SSL:
- ttnproto = rawflg;
- ssl_only_flag = 1;
- tls_only_flag = 0;
- break;
- case NP_TLS:
- ttnproto = rawflg;
- ssl_only_flag = 0;
- tls_only_flag = 1;
- break;
- case NP_SSL_TELNET:
- ttnproto = NP_TELNET;
- ssl_only_flag = 1;
- tls_only_flag = 0;
- break;
- case NP_TLS_TELNET:
- ttnproto = NP_TELNET;
- ssl_only_flag = 0;
- tls_only_flag = 1;
- break;
- #endif /* CK_SSL */
- case NP_NONE:
- case NP_TCPRAW:
- case NP_RLOGIN:
- case NP_K4LOGIN:
- case NP_K5LOGIN:
- case NP_EK4LOGIN:
- case NP_EK5LOGIN:
- case NP_TELNET:
- case NP_KERMIT:
- default:
- ttnproto = rawflg;
- #ifdef CK_SSL
- ssl_only_flag = 0;
- tls_only_flag = 0;
- #endif /* CK_SSL */
- break;
- }
- }
- }
- }
- s = line;
- }
- #endif /* TCPSOCKET */
- if (!*s) {
- if (!network) {
- slmsg = "Hostname or address required";
- printf("?%sn",slmsg);
- return(-9);
- } else if (!zz) { /* No hostname given */
- #ifdef CKLOGDIAL
- #ifdef NETCONN
- dolognet();
- #endif /* NETCONN */
- #endif /* CKLOGDIAL */
- if (cx) {
- success = doconect(0);
- #ifdef CKLOGDIAL
- if (ttchk() < 0)
- dologend();
- #endif /* CKLOGDIAL */
- return(success);
- } else
- return(1);
- }
- }
- #ifndef NODIAL
- /* Look up in network directory */
- x = 0;
- debug(F101,"setlin mynet 1","",mynet);
- debug(F111,"setlin nnetdir",s,nnetdir);
- if (*s == '=') { /* If number starts with = sign */
- s++; /* strip it */
- while (*s == SP) s++; /* and any leading spaces */
- strcpy(line,s); /* Do this again. */
- s = line;
- debug(F110,"setlin host s 3",s,0);
- nhcount = 0;
- } else if (*s) { /* We want to look it up. */
- if (nnetdir > 0) /* If there is a directory... */
- x = lunet(line); /* (sets nhcount) */
- else /* otherwise */
- nhcount = 0; /* we didn't find any there */
- if (x < 0) { /* Internal error? */
- slmsg = "Network directory lookup error";
- printf("?Fatal network directory lookup error - %sn",line);
- return(-9);
- }
- debug(F111,"setlin lunet nhcount",line,nhcount);
- }
- #endif /* NODIAL */
- /* New connection wanted. Make a copy of the host name/address... */
- ckstrncpy(tmpbuf,s,TMPBUFSIZ); /* Because we are reusing line[] */
- s = tmpbuf; /* for net directory entries... */
- debug(F111,"setlin host s 5",s,mdmtyp);
- if (clsconnx(1) < 0) /* Close current connection */
- return(success = 0);
- if (*s) { /* They gave a hostname */
- _local = 1; /* Network connection always local */
- if (mdmsav < 0)
- mdmsav = mdmtyp; /* Remember old modem type */
- mdmtyp = -mynet; /* Special code for network */
- if (mynet == NET_TCPB) { /* For TCP/IP telnet connections */
- oldplex = duplex; /* Remember previous duplex */
- duplex = 0; /* Set full duplex and let */