ckuus4.c
资源名称:cku197.tar.Z [点击查看]
上传用户:dufan58
上传日期:2007-01-05
资源大小:3407k
文件大小:380k
源码类别:
通讯/手机编程
开发平台:
Windows_Unix
- #include "ckcsym.h"
- /* C K U U S 4 -- "User Interface" for C-Kermit, part 4 */
- /*
- Author: Frank da Cruz <fdc@columbia.edu>,
- Columbia University Academic Information Systems, New York City.
- Copyright (C) 1985, 2000,
- Trustees of Columbia University in the City of New York.
- All rights reserved. See the C-Kermit COPYING.TXT file or the
- copyright text in the ckcmai.c module for disclaimer and permissions.
- */
- /*
- File ckuus4.c -- Functions moved from other ckuus*.c modules to even
- out their sizes.
- */
- #include "ckcdeb.h"
- #include "ckcasc.h"
- #include "ckcker.h"
- #include "ckuusr.h"
- #include "ckuver.h"
- #include "ckcnet.h" /* Network symbols */
- #include "ckcxla.h" /* Character sets */
- #ifdef CK_AUTHENTICATION
- #include "ckuath.h"
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_SSL
- #include "ck_ssl.h"
- #endif /* CK_SSL */
- #ifdef VMS
- #include <errno.h> /* For v(errno) */
- extern char * ckvmserrstr(unsigned long);
- #ifndef OLD_VMS
- #include <lib$routines.h> /* Not for VAX C 2.4 */
- #else
- #include <libdef.h>
- #endif /* OLD_VMS */
- _PROTOTYP(int vmsttyfd, (void) );
- #endif /* VMS */
- #ifdef OS2
- #ifndef NT
- #define INCL_NOPM
- #define INCL_VIO /* Needed for ckocon.h */
- #include <os2.h>
- #undef COMMENT
- #else
- #include <windows.h>
- #include <tapi.h>
- #include "ckntap.h"
- #define APIRET ULONG
- #endif /* NT */
- #include "ckocon.h"
- #include "ckoetc.h"
- int StartedFromDialer = 0;
- HWND hwndDialer = 0;
- LONG KermitDialerID = 0;
- #ifdef putchar
- #undef putchar
- #endif /* putchar */
- #define putchar(x) conoc(x)
- #ifdef CK_PID
- #include <process.h>
- #endif /* CK_PID */
- #endif /* OS2 */
- extern xx_strp xxstring;
- #ifdef DEC_TCPIP
- #include <descrip>
- #include <dvidef>
- #include <dcdef>
- #endif /* DEC_TCPIP */
- #ifdef FNFLOAT
- #include <math.h> /* Floating-point functions */
- #endif /* FNFLOAT */
- extern int quiet, network, xitsta, escape, nopush, xferstat,
- exitonclose, tn_exit, ttnproto, autodl, flow, byteorder;
- extern char * k_info_dir;
- #ifndef MAC
- #ifndef AMIGA
- extern int ttyfd;
- #endif /* MAC */
- #endif /* AMIGA */
- #ifdef TNCODE
- extern int tn_nlm, tn_b_nlm, tn_b_xfer, tn_sb_bug;
- extern int tn_rem_echo;
- extern int tn_b_meu, tn_b_ume;
- #endif /* TNCODE */
- char * xferfile = NULL;
- int xferlog = 0;
- extern int local, xargc, stayflg, rcflag, bgset, cfilef,
- inserver, srvcdmsg, success;
- extern char cmdfil[], *versio, *ckxsys, **xargv;
- #ifdef DEBUG
- extern char debfil[]; /* Debug log file name */
- #endif /* DEBUG */
- extern int noinit;
- #ifndef NOICP /* Most of this file... */
- #ifndef AMIGA
- #ifndef MAC
- #include <signal.h>
- #endif /* MAC */
- #endif /* AMIGA */
- #ifdef STRATUS /* Stratus Computer, Inc. VOS */
- #ifdef putchar
- #undef putchar
- #endif /* putchar */
- #define putchar(x) conoc(x)
- #ifdef getchar
- #undef getchar
- #endif /* getchar */
- #define getchar(x) coninc(0)
- #endif /* STRATUS */
- #ifdef ANYX25
- extern int revcall, closgr, cudata;
- int x25ver;
- extern char udata[];
- #ifndef IBMX25
- extern int npadx3;
- extern CHAR padparms[];
- extern struct keytab padx3tab[];
- #endif /* !IBMX25 */
- #ifdef IBMX25
- /* global variables only available for IBM X.25 - possibly interesting for
- * other implementations
- */
- extern x25addr_t local_nua;
- extern x25addr_t remote_nua;
- #endif /* IBMX25 */
- #endif /* ANYX25 */
- #ifdef NETCONN
- #ifndef NODIAL
- extern int nnetdir;
- extern char *netdir[];
- #endif /* NODIAL */
- extern char ipaddr[];
- #ifdef CK_NETBIOS
- extern unsigned short netbiosAvail;
- extern unsigned long NetbeuiAPI;
- extern unsigned char NetBiosName[];
- extern unsigned char NetBiosAdapter;
- extern unsigned char NetBiosLSN;
- #endif /* CK_NETBIOS */
- #ifdef TCPSOCKET
- extern char myipaddr[];
- extern int tcp_rdns;
- #ifdef CK_DNS_SRV
- extern int tcp_dns_srv;
- #endif /* CK_DNS_SRV */
- #ifndef NOTCPOPTS
- #ifdef SOL_SOCKET
- #ifdef SO_LINGER
- extern int tcp_linger;
- extern int tcp_linger_tmo;
- #endif /* SO_LINGER */
- #ifdef SO_DONTROUTE
- extern int tcp_dontroute;
- #endif /* SO_DONTROUTE */
- #ifdef TCP_NODELAY
- extern int tcp_nodelay;
- #endif /* TCP_NODELAY */
- #ifdef SO_SNDBUF
- extern int tcp_sendbuf;
- #endif /* SO_SNDBUF */
- #ifdef SO_RCVBUF
- extern int tcp_recvbuf;
- #endif /* SO_RCVBUF */
- #ifdef SO_KEEPALIVE
- extern int tcp_keepalive;
- #endif /* SO_KEEPALIVE */
- #endif /* SOL_SOCKET */
- #endif /* NOTCPOPTS */
- #endif /* TCPSOCKET */
- #endif /* NETCONN */
- extern char * floname[];
- #ifndef NOSPL
- extern int fndiags; /* Function diagnostics on/off */
- int ispattern = 0;
- #ifdef CK_APC
- extern int apcactive; /* Nonzero = APC command was rec'd */
- extern int apcstatus; /* Are APC commands being processed? */
- #ifdef DCMDBUF
- extern char *apcbuf; /* APC command buffer */
- #else
- extern char apcbuf[];
- #endif /* DCMDBUF */
- #endif /* CK_APC */
- extern char evalbuf[]; /* EVALUATE result */
- extern char uidbuf[], pwbuf[], prmbuf[];
- _PROTOTYP( static char * fneval, (char *, char * [], int, char * ) );
- _PROTOTYP( static VOID myflsh, (void) );
- _PROTOTYP( static char * getip, (char *) );
- static char hexdigits[16] = {
- '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
- };
- extern char * tempdir;
- #ifdef CK_REXX
- extern char rexxbuf[];
- #endif /* CK_REXX */
- extern int tfline[];
- /* These need to be internationalized... */
- static
- char *wkdays[] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- #endif /* NOSPL */
- char *months[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
- #ifdef OS2
- _PROTOTYP (int os2getcp, (void) );
- #ifdef TCPSOCKET
- extern char tcpname[];
- #endif /* TCPSOCKET */
- extern char startupdir[],exedir[];
- extern int tcp_avail;
- #ifdef DECNET
- extern int dnet_avail;
- #endif /* DECNET */
- #ifdef SUPERLAT
- extern int slat_avail;
- #endif /* SUPERLAT */
- extern int tt_type, max_tt;
- extern struct tt_info_rec tt_info[];
- extern int tt_rows[], tt_cols[];
- #else /* OS2 */
- extern int tt_rows, tt_cols;
- #endif /* OS2 */
- #ifdef CK_TAPI
- extern int tttapi;
- extern int tapipass;
- extern struct keytab * tapilinetab;
- extern struct keytab * _tapilinetab;
- extern int ntapiline;
- #endif /* CK_TAPI */
- #ifdef VMS
- extern char startupdir[];
- #endif /* VMS */
- #ifdef UNIX
- extern char startupdir[];
- #endif /* UNIX */
- extern struct keytab colxtab[];
- extern int ncolx;
- extern char ttname[], *zinptr, *kermrc;
- extern char inidir[];
- extern int activecmd, remonly, cmd_rows, cmd_cols, parity, seslog,
- sessft, sosi, hwparity, tsecs, xargs, zincnt, tlevel, insilence, cmdmsk,
- timint, timef, inbufsize, dialog, binary, carrier, cdtimo, cmask, duplex,
- fmask, inecho, nettype, nmac, turnch, turn, kbchar;
- #ifndef NOXFER
- extern CHAR eol, mypadc, mystch, padch, seol, stchr, * epktmsg, feol;
- extern char *cksysid;
- extern struct ck_p ptab[];
- extern int
- protocol, prefixing, xfrbel, xfrcan, xfrint, xfrchr, xfrnum, pktpaus,
- lscapr, lscapu, xfermode, dest, slostart, maxrps, maxsps, maxtry, mypadn,
- npad, pkttim, bigrbsiz, bigsbsiz, keep, atcapr, autopar, bctr, bctu,
- crunched, ckdelay, ebq, ebqflg, pktlog, retrans, rpackets, rptflg, rptq,
- rtimo, spackets, spsiz, spsizf, spsizr, timeouts, fncact, fncnv, urpsiz,
- wmax, wslotn, wslotr, fdispla, spmax, fnrpath, fnspath, crc16;
- #endif /* NOXFER */
- #ifdef OS2
- extern int zxpn;
- extern int viewonly;
- #endif /* OS2 */
- #ifndef NOXFER
- #ifdef GFTIMER
- extern CKFLOAT fptsecs, fpxfsecs;
- #endif /* GFTIMER */
- extern long xfsecs, tfcps;
- #ifdef CK_TMPDIR
- extern char *dldir;
- #endif /* CK_TMPDIR */
- #endif /* NOXFER */
- #ifdef RECURSIVE
- extern int recursive;
- #endif /* RECURSIVE */
- #ifdef VMS
- extern int frecl;
- #endif /* VMS */
- extern long
- ffc, filcnt, rptn, speed, tfc, tlci, tlco, ccu, ccp, vernum, xvernum;
- #ifndef NOSPL
- extern char fspec[], myhost[];
- #endif /* NOSPL */
- extern char *tfnam[]; /* Command file names */
- #ifdef DCMDBUF
- extern struct cmdptr *cmdstk;
- extern char *line, *tmpbuf;
- #else
- extern struct cmdptr cmdstk[];
- extern char line[], tmpbuf[], kermrcb[];
- #endif /* DCMDBUF */
- extern char pktfil[], /* Packet log file name */
- #ifdef TLOG
- trafil[], /* Transaction log file name */
- #endif /* TLOG */
- sesfil[]; /* Session log file name */
- #ifndef NOXMIT /* TRANSMIT command variables */
- extern char xmitbuf[];
- extern int xmitf, xmitl, xmitx, xmits, xmitw, xmitt;
- #endif /* NOXMIT */
- extern int cmdlvl;
- #ifndef NOSPL
- /* Script programming language items */
- extern char **a_ptr[]; /* Arrays */
- extern int a_dim[];
- static char * inpmatch = NULL;
- extern char * inpbuf, inchar[]; /* Buffers for INPUT and REINPUT */
- extern char *inpbp; /* And pointer to same */
- static char *r3 = (char *)0;
- extern int incount; /* INPUT character count */
- extern int m_found; /* MINPUT result */
- extern int maclvl; /* Macro invocation level */
- extern struct mtab *mactab; /* Macro table */
- extern char *mrval[];
- extern int macargc[], topargc;
- extern char *m_line[];
- extern char *m_arg[MACLEVEL][10]; /* You have to put in the dimensions */
- extern char *g_var[GVARS]; /* for external 2-dimensional arrays. */
- #ifdef DCMDBUF
- extern int *count, *inpcas;
- #else
- extern int count[], inpcas[];
- #endif /* DCMDBUF */
- #endif /* NOSPL */
- #ifdef UNIX
- extern int haslock; /* For UUCP locks */
- extern char flfnam[];
- #ifndef USETTYLOCK
- extern char lock2[];
- #endif /* USETTYLOCK */
- #endif /* UNIX */
- #ifdef OS2ORUNIX
- extern int maxnam, maxpath; /* Longest name, path length */
- #endif /* OS2ORUNIX */
- extern int mdmtyp, mdmsav;
- #ifndef NODIAL
- /* DIAL-related variables */
- extern char modemmsg[];
- extern MDMINF *modemp[]; /* Pointers to modem info structs */
- extern int nmdm, dialhng, dialtmo, dialksp, dialdpy, dialsrt, dialmhu, dialsta;
- extern int dialrtr, dialint, dialrstr, dialcon, dialcq, dialfld;
- extern int mdmspd, dialec, dialdc, dialmth, dialmauto, dialesc;
- extern char *dialnum, *dialini, *dialdir[], *dialcmd, *dialnpr,
- *dialdcon, *dialdcoff, *dialecon, *dialecoff, *dialhcmd, *diallac,
- *dialhwfc, *dialswfc, *dialnofc, *dialpulse, *dialtone, *dialname,
- *dialaaon, *dialaaoff, *dialmac;
- extern char *diallcc, *dialixp, *dialixs, *dialldp, *diallds,
- *dialpxi, *dialpxo, *dialsfx, *dialtfp;
- extern char *diallcp, *diallcs;
- extern int ntollfree, ndialpxx, nlocalac;
- extern char *dialtfc[], *diallcac[], *dialpxx[], *matchpxx;
- extern int ndialpucc, ndialtocc;
- extern char *dialtocc[], *dialpucc[];
- extern int ndialdir, dialcnf, dialcvt, dialidt, dialpace;
- extern long dialmax, dialcapas;
- extern struct keytab mdmtab[];
- #ifdef BIGBUFOK
- #define ARGBUFSIZ 8191
- #else
- #define ARGBUFSIZ 1023
- #endif /* BIGBUFOK */
- #ifdef BIGBUFOK
- extern char * dialmsg[];
- #endif /* BIGBUFOK */
- #endif /* NODIAL */
- #ifndef NOCSETS
- /* Translation stuff */
- extern int fcharset, tcharset, tslevel, language, nlng, tcsr, tcsl;
- extern struct keytab lngtab[];
- extern struct csinfo fcsinfo[], tcsinfo[];
- extern struct langinfo langs[];
- #ifdef CK_ANSIC
- extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* Character set */
- extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* translation functions */
- #else
- extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(); /* Character set */
- extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(); /* translation functions. */
- #endif /* CK_ANSIC */
- #ifdef UNICODE
- extern int ucsbom, ucsorder;
- #endif /* UNICODE */
- #endif /* NOCSETS */
- #ifndef NOSPL
- /* Built-in variable names, maximum length VNAML (20 characters) */
- struct keytab vartab[] = {
- "_line", VN_TFLN, CM_INV, /* 192 */
- #ifdef OS2
- "_regname", VN_REGN, CM_INV, /* 1.1.12 */
- "_regorg", VN_REGO, CM_INV, /* 1.1.12 */
- "_regnum", VN_REGS, CM_INV, /* 1.1.12 */
- #endif /* OS2 */
- "apcactive", VN_APC, CM_INV, /* 192 */
- "argc", VN_ARGC, 0,
- "args", VN_ARGS, 0,
- "authname", VN_AUTHN, 0, /* 196 */
- "authstate", VN_AUTHS, 0, /* 195 */
- "authtype", VN_AUTHT, 0, /* 195 */
- "blockcheck",VN_BLK, 0, /* 195 */
- #ifdef BROWSER
- "browser", VN_BROWSR,0, /* 193 */
- "browsopts", VN_BROPT, 0, /* 193 */
- "browsurl", VN_URL, 0, /* 193 */
- #endif /* BROWSER */
- "byteorder", VN_BYTE, 0, /* 195 */
- #ifndef NOCSETS
- "charset", VN_CSET, 0, /* 192 */
- #endif /* NOCSETS */
- "cmdbufsize",VN_CMDBL, 0, /* 195 */
- "cmdfile", VN_CMDF, 0,
- "cmdlevel", VN_CMDL, 0,
- "cmdsource", VN_CMDS, 0,
- "cols", VN_COLS, 0, /* 190 */
- "connection",VN_CONN, 0, /* 190 */
- "count", VN_COUN, 0,
- #ifndef NOXFER
- "cps", VN_CPS, 0, /* 190 */
- #endif /* NOXFER */
- "cpu", VN_CPU, 0,
- #ifndef NOXFER
- "crc16", VN_CRC16, 0, /* 192 */
- "ctty", VN_TTYNAM,0, /* 196 */
- #endif /* NOXFER */
- "cx_time", VN_CXTIME,0, /* 195 */
- #ifndef NODIAL
- "d$ac", VN_D_AC, 0, /* 192 */
- "d$cc", VN_D_CC, 0, /* 192 */
- "d$ip", VN_D_IP, 0, /* 192 */
- "d$lc", VN_D_LCP, 0, /* 193 */
- "d$lcp", VN_D_LCP, CM_INV, /* 193 */
- "d$lp", VN_D_LP, 0, /* 192 */
- "d$px", VN_D_PXX, 0, /* 195 */
- "d$pxx", VN_D_PXX, CM_INV, /* 195 */
- #endif /* NODIAL */
- "date", VN_DATE, 0,
- "day", VN_DAY, 0,
- #ifndef NODIAL
- "dialcount", VN_DRTR, 0, /* 195 */
- "dialnumber",VN_DNUM, 0, /* 192 */
- "dialresult",VN_MDMSG, 0, /* 192 */
- "dialstatus",VN_DIAL, 0, /* 190 */
- "dialsuffix",VN_PDSFX, 0, /* 193 */
- "dialtype", VN_DTYPE, 0, /* 193 */
- #endif /* NODIAL */
- "directory", VN_DIRE, 0,
- #ifndef NODIAL
- "dm_lp", VN_DM_LP, 0, /* 195 */
- "dm_sp", VN_DM_SP, 0, /* 195 */
- "dm_pd", VN_DM_PD, 0, /* 195 */
- "dm_td", VN_DM_TD, 0, /* 195 */
- "dm_wa", VN_DM_WA, 0, /* 195 */
- "dm_wd", VN_DM_WD, 0, /* 195 */
- "dm_rc", VN_DM_RC, 0, /* 195 */
- #endif /* NODIAL */
- #ifndef NOXFER
- "download", VN_DLDIR, 0, /* 192 */
- #endif /* NOXFER */
- "editor", VN_EDITOR,0,
- "editfile", VN_EDFILE,0,
- "editopts", VN_EDOPT, 0,
- "errno", VN_ERRNO, 0, /* 192 */
- "errstring", VN_ERSTR, 0, /* 192 */
- "escape", VN_ESC, 0, /* 193 */
- "evaluate", VN_EVAL, 0, /* 190 */
- #ifdef OS2
- "exedir", VN_EXEDIR,0, /* 192 */
- #endif /* OS2 */
- "exitstatus",VN_EXIT, 0,
- #ifdef CKCHANNELIO
- "f_count", VN_FCOU, 0, /* 195 */
- "f_error", VN_FERR, 0, /* 195 */
- "f_max", VN_FMAX, 0, /* 195 */
- "fileerror", VN_FERR, CM_INV, /* 195 */
- "filemax", VN_FERR, CM_INV, /* 195 */
- #endif /* CKCHANNELIO */
- "filename", VN_FNAM, 0, /* 193 */
- "filenumber",VN_FNUM, 0, /* 193 */
- "filespec", VN_FILE, 0,
- "fsize", VN_FFC, 0, /* 190 */
- "ftype", VN_MODE, 0, /* 190 */
- "herald", VN_HERALD,0,
- "home", VN_HOME, 0,
- "host", VN_HOST, 0,
- "hwparity", VN_HWPAR, 0, /* 195 */
- "input", VN_IBUF, 0,
- "inchar", VN_ICHR, 0,
- "incount", VN_ICNT, 0,
- "inidir", VN_INI, 0, /* 192 */
- "inmatch", VN_MATCH, 0, /* 196 */
- "instatus", VN_ISTAT, 0, /* 192 */
- "intime", VN_INTIME,0, /* 193 */
- "inwait", VN_INTMO, 0, /* 195 */
- "ipaddress", VN_IPADDR,0, /* 192 */
- "kbchar", VN_KBCHAR,0, /* 196 */
- #ifdef OS2
- "keyboard", VN_KEYB, 0,
- #endif /* OS2 */
- #ifdef CK_KERBEROS
- "krb4errmsg", VN_K4EMSG,0,
- "krb4errno", VN_K4ENO, 0,
- "krb4principal", VN_K4PRN, 0,
- "krb4realm", VN_K4RLM, 0,
- "krb4service", VN_K4SRV, 0,
- "krb5cc", VN_K5CC, 0,
- "krb5errmsg", VN_K5EMSG,0,
- "krb5errno", VN_K5ENO, 0,
- "krb5principal", VN_K5PRN, 0,
- "krb5realm", VN_K5RLM, 0,
- "krb5service", VN_K5SRV, 0,
- #endif /* CK_KERBEROS */
- "line", VN_LINE, 0,
- "local", VN_LCL, 0,
- #ifdef UNIX
- "lockdir", VN_LCKDIR,0, /* 195 */
- "lockpid", VN_LCKPID,0, /* 195 */
- #endif /* UNIX */
- "maclevel", VN_MACLVL,0, /* 195 */
- "macro", VN_MAC, 0,
- #ifdef FNFLOAT
- "math_e", VN_MA_E, 0, /* 195 */
- "math_pi", VN_MA_PI, 0, /* 195 */
- "math_precision", VN_MA_PR, 0, /* 195 */
- #endif /* FNFLOAT */
- "minput", VN_MINP, 0, /* 192 */
- "model", VN_MODL, 0, /* 193 */
- "modem", VN_MDM, 0,
- #ifdef OS2
- "mousecurx", VN_MOU_X, 0, /* K95 1.1.14 */
- "mousecury", VN_MOU_Y, 0, /* K95 1.1.14 */
- #endif /* OS2 */
- #ifndef NODIAL
- "m_aa_off", VN_M_ECX, 0, /* all 192... */
- "m_aa_on", VN_M_AAO, 0,
- "m_dc_off", VN_M_DCX, 0,
- "m_dc_on", VN_M_DCO, 0,
- "m_dial", VN_M_DCM, 0,
- "m_ec_off", VN_M_ECX, 0,
- "m_ec_on", VN_M_ECO, 0,
- "m_fc_hw", VN_M_HWF, 0,
- "m_fc_no", VN_M_NFC, 0,
- "m_fc_sw", VN_M_SWF, 0,
- "m_hup", VN_M_HUP, 0,
- "m_init", VN_M_INI, 0,
- "m_name", VN_M_NAM, 0, /* 195 */
- "m_pulse", VN_M_PDM, 0,
- "m_sig_cd", VN_MS_CD, 0, /* 195 */
- "m_sig_cts", VN_MS_CTS,0, /* 195 */
- "m_sig_dsr", VN_MS_DSR,0, /* 195 */
- "m_sig_dtr", VN_MS_DTR,0, /* 195 */
- "m_sig_ri", VN_MS_RI, 0, /* 195 */
- "m_sig_rts", VN_MS_RTS,0, /* 195 */
- "m_tone", VN_M_TDM, 0,
- #endif /* NODIAL */
- "name", VN_NAME, 0,
- "ndate", VN_NDAT, 0,
- "nday", VN_NDAY, 0,
- "newline", VN_NEWL, 0,
- "ntime", VN_NTIM, 0,
- "osname", VN_OSNAM, 0, /* 193 */
- "osrelease", VN_OSREL, 0, /* 193 */
- "osversion", VN_OSVER, 0, /* 193 */
- #ifndef NOXFER
- "packetlen", VN_RPSIZ, 0, /* 192 */
- #endif /* NOXFER */
- "parity", VN_PRTY, 0, /* 190 */
- "password", VN_PWD, CM_INV, /* 192 */
- #ifdef PEXITSTAT
- "pexitstat", VN_PEXIT, 0, /* 193 */
- #endif /* PEXITSTAT */
- #ifdef CK_PID
- "pid", VN_PID, 0, /* 193 */
- #endif /* CK_PID */
- "platform", VN_SYSV, 0,
- "printer", VN_PRINT, 0, /* 193 */
- "program", VN_PROG, 0,
- "prompt", VN_PRM, CM_INV, /* 192 */
- #ifndef NOXFER
- "protocol", VN_PROTO, 0, /* 192 */
- "p_8bit", VN_P_8BIT,0, /* 193 */
- "p_ctl", VN_P_CTL, 0, /* 193 */
- "p_rpt", VN_P_RPT, 0, /* 193 */
- "query", VN_QUE, 0, /* 190 */
- #endif /* NOXFER */
- "return", VN_RET, 0,
- #ifdef CK_REXX
- "rexx", VN_REXX, 0, /* 190 */
- #endif /* CK_REXX */
- "rows", VN_ROWS, 0, /* 190 */
- #ifdef OS2
- "select", VN_SELCT, 0, /* 192 */
- #endif /* OS2 */
- "sendlist", VN_SNDL, 0,
- "serial", VN_SERIAL,0, /* 195 */
- "setlinemsg",VN_SLMSG, 0, /* 195 */
- "speed", VN_SPEE, 0,
- #ifdef OS2
- "space", VN_SPA, 0,
- "startup", VN_STAR, 0, /* 190 */
- #else
- #ifdef UNIX
- "startup", VN_STAR, 0, /* 193 */
- #else
- #ifdef VMS
- "startup", VN_STAR, 0, /* 193 */
- #endif /* VMS */
- #endif /* UNIX */
- #endif /* OS2 */
- "status", VN_SUCC, 0,
- #ifndef NOXFER
- "sysid", VN_SYSI, 0,
- #endif /* NOXFER */
- "system", VN_SYST, 0,
- "terminal", VN_TTYP, 0,
- #ifdef OS2
- "termkey", VN_TRMK, CM_INV, /* 192 */
- #endif /* OS2 */
- "test", VN_TEST, 0, /* 193 */
- "textdir", VN_TXTDIR,0, /* 195 */
- #ifndef NOXFER
- "tfsize", VN_TFC, 0,
- "tftime", VN_TFTIM, 0, /* 195 */
- #endif /* NOXFER */
- "time", VN_TIME, 0,
- "tmpdir", VN_TEMP, 0, /* 192 */
- #ifdef CK_TRIGGER
- "trigger", VN_TRIG, 0, /* 193 */
- #endif /* CK_TRIGGER */
- #ifdef CK_TTYFD
- "ttyfd", VN_TTYF, 0,
- #endif /* CK_TTYFD */
- "ty_ln", VN_TY_LN, 0, /* 195 */
- "ty_lc", VN_TY_LC, 0, /* 195 */
- "ty_lm", VN_TY_LM, 0, /* 195 */
- #ifdef BROWSER
- "url", VN_URL, CM_INV, /* 193 */
- #endif /* BROWSER */
- "userid", VN_UID, 0, /* 192 */
- "version", VN_VERS, 0,
- #ifndef NOXFER
- "window", VN_WINDO, 0, /* 192 */
- #endif /* NOXFER */
- #ifdef IBMX25
- "x25local_nua", VN_X25LA, 0, /* 193 */
- "x25remote_nua", VN_X25RA, 0, /* 193 */
- #endif /* IBMX25 */
- #ifdef CK_SSL
- "x509_issuer", VN_X509_I, 0,
- "x509_subject", VN_X509_S, 0,
- #endif /* CK_SSL */
- #ifndef NOXFER
- "xferstatus",VN_XFSTAT,0, /* 193 */
- "xfermsg", VN_XFMSG, 0, /* 193 */
- "xfer_badpacket", VN_XF_BC, 0, /* 195 */
- "xfer_timeout", VN_XF_TM, 0, /* 195 */
- "xfer_retransmit",VN_XF_RX, 0, /* 195 */
- #endif /* NOXFER */
- "xprogram", VN_XPROG, 0, /* 193 */
- "xversion", VN_XVNUM, 0 /* 192 */
- };
- int nvars = (sizeof(vartab) / sizeof(struct keytab));
- #endif /* NOSPL */
- #ifndef NOSPL
- struct keytab fnctab[] = { /* Function names */
- #ifdef OS2
- ".oox", FN_OOX, CM_INV, /* ... */
- #endif /* OS2 */
- #ifdef CKCHANNELIO
- "_eof", FN_FEOF, 0,
- "_errmsg", FN_FERMSG, 0,
- "_getblock", FN_FGBLK, 0,
- "_getchar", FN_FGCHAR, 0,
- "_getline", FN_FGLINE, 0,
- "_handle", FN_FILNO, 0,
- "_line", FN_NLINE, 0,
- "_pos", FN_FPOS, 0,
- "_putblock", FN_FPBLK, 0,
- "_putchar", FN_FPCHAR, 0,
- "_putline", FN_FPLINE, 0,
- "_status", FN_FSTAT, 0,
- #endif /* CKCHANNELIO */
- "aaconvert", FN_AADUMP, 0, /* Associative Array conversion */
- "absolute", FN_ABS, 0, /* Absolute value */
- "arraylook", FN_ALOOK,0, /* Array lookup */
- "b64decode", FN_FMB64,0, /* Base-64 conversion */
- "b64encode", FN_TOB64,0, /* ... */
- "basename", FN_BSN, 0, /* Basename */
- "break", FN_BRK, 0, /* Break (as in Snobol) */
- "ca", FN_CAP, CM_INV|CM_ABR, /* Abbreviation for capitablize */
- "cap", FN_CAP, CM_INV|CM_ABR, /* Abbreviation for capitablize */
- "capitalize", FN_CAP, 0, /* First Letter -> uppercase */
- "caps", FN_CAP, CM_INV, /* ditto */
- "character", FN_CHR, 0, /* Character from code */
- "checksum", FN_CHK, 0, /* Checksum */
- "code", FN_COD, 0, /* Code from character */
- #ifndef NOPUSH
- "command", FN_CMD, 0, /* Output from a command */
- #endif /* NOPUSH */
- "contents", FN_CON, 0, /* Definition (contents) of variable */
- "crc16", FN_CRC, 0, /* CRC-16 */
- #ifdef OS2
- "crypt", FN_CRY, CM_INV,
- #endif /* OS2 */
- "cvtdate", FN_DTIM, 0, /* Convert free date/time to std */
- #ifdef ZFCDAT
- "date", FN_FD, 0, /* File modification/creation date */
- #endif /* ZFCDAT */
- "day", FN_DAY, 0, /* Day of week */
- "dayofyear", FN_JDATE,0, /* Date to Day of Year */
- "definition", FN_DEF, 0, /* Return definition of given macro */
- #ifndef NODIAL
- "dialconvert",FN_PNCVT,0, /* Convert portable phone number */
- #endif /* NODIAL */
- "dimension", FN_DIM, 0, /* Dimension of array */
- "directories",FN_DIR, 0, /* List of directories */
- "dirname", FN_DNAM, 0, /* Directory part of filename */
- "doy", FN_JDATE,CM_INV, /* Date to Day of Year */
- "doy2date", FN_DATEJ,0, /* Day of Year to date */
- #ifdef FN_ERRMSG
- "errstring", FN_ERRMSG,0, /* Error code to message */
- #endif /* FN_ERRMSG */
- "evaluate", FN_EVA, 0, /* Evaluate given arith expression */
- "execute", FN_EXE, 0, /* Execute given macro */
- "files", FN_FC, 0, /* File count */
- #ifdef FNFLOAT
- "fpabsolute", FN_FPABS, 0, /* Floating-point absolute value */
- "fpadd", FN_FPADD, 0, /* FP add */
- "fpcosine", FN_FPCOS, 0, /* FP cosine */
- "fpdivide", FN_FPDIV, 0, /* FP divide */
- "fpexp", FN_FPEXP, 0, /* FP e to the x */
- "fpint", FN_FPINT, 0, /* FP to integer */
- "fplog10", FN_FPLOG, 0, /* FP base-10 logarithm */
- "fplogn", FN_FPLN, 0, /* FP natural logarithm */
- "fpmaximum", FN_FPMAX, 0, /* FP maxinum */
- "fpminimum", FN_FPMIN, 0, /* FP mininum */
- "fpmodulus", FN_FPMOD, 0, /* FP modulus */
- "fpmultiply", FN_FPMUL, 0, /* FP multiply */
- "fpraise", FN_FPPOW, 0, /* FP raise to a power */
- "fpround", FN_FPROU, 0, /* FP round */
- "fpsine", FN_FPSIN, 0, /* FP sine */
- "fpsqrt", FN_FPSQR, 0, /* FP square root */
- "fpsubtract", FN_FPSUB, 0, /* FP subtract */
- "fptangent", FN_FPTAN, 0, /* FP tangent */
- #endif /* FNFLOAT */
- "hex2ip", FN_HEX2IP,0, /* Hex to IP address */
- "hex2n", FN_HEX2N, CM_INV, /* Hex to decimal number */
- "hexify", FN_HEX, 0, /* Hexify (string) */
- "index", FN_IND, 0, /* Index (string search) */
- "ip2hex", FN_IP2HEX,0, /* IP address to hex */
- "ipaddress", FN_IPA, 0, /* Find and return IP address */
- "jdate", FN_JDATE, CM_INV, /* Date to Day of Year */
- #ifdef CK_KERBEROS
- "krbflags", FN_KRB_FG, 0, /* Kerberos functions */
- "krbisvalid", FN_KRB_IV, 0,
- "krbnextticket", FN_KRB_NX, 0,
- "krbtickets", FN_KRB_TK, 0,
- "krbtimeleft", FN_KRB_TT, 0,
- #endif /* CK_KERBEROS */
- "left", FN_LEF, 0, /* Leftmost n characters of string */
- "length", FN_LEN, 0, /* Return length of argument */
- "literal", FN_LIT, 0, /* Return argument literally */
- "lop", FN_STL, 0, /* Lop */
- "lower", FN_LOW, 0, /* Return lowercased argument */
- "lpad", FN_LPA, 0, /* Return left-padded argument */
- "ltrim", FN_LTR, 0, /* Left-Trim */
- "maximum", FN_MAX, 0, /* Return maximum of two arguments */
- "minimim", FN_MIN, 0, /* Return minimum of two arguments */
- "mjd", FN_MJD, 0, /* Date to Modified Julian Date */
- "mjd2date", FN_MJD2, 0, /* MJD to Date */
- "modulus", FN_MOD, CM_INV, /* Return modulus of two arguments */
- "n2hex", FN_2HEX, CM_INV, /* Number to hex */
- "n2octal", FN_2OCT, CM_INV, /* Number to octal */
- "n2time", FN_N2TIM,0, /* Number to hh:mm:ss */
- "nday", FN_NDAY, 0, /* Numeric day of week */
- "nextfile", FN_FIL, 0, /* Next file in list */
- "ntime", FN_NTIM, 0, /* Time to seconds since midnight */
- "oct2n", FN_OCT2N,CM_INV, /* Octal to decimal number */
- "pathname", FN_FFN, 0, /* Full file name */
- "pattern", FN_PATTERN, 0, /* Pattern (for INPUT) */
- #ifdef CK_PERMS
- "permissions",FN_PERM, 0, /* Permissions of file */
- #else
- "permissions",FN_PERM, CM_INV, /* Permissions of file */
- #endif /* CK_PERMS */
- "radix", FN_RADIX,0, /* Radix conversion */
- #ifndef NORANDOM
- "random", FN_RAND, 0, /* Random number */
- #endif /* NORANDOM */
- #ifndef NOPUSH
- "rawcommand", FN_RAW, 0, /* Output from a command (raw) */
- #endif /* NOPUSH */
- #ifdef RECURSIVE
- "rdirectories", FN_RDIR, 0, /* Recursive directory list */
- "rfiles", FN_RFIL, 0, /* Recursive file list */
- #endif /* RECURSIVE */
- "rep", FN_REP, CM_INV|CM_ABR,
- "repeat", FN_REP, 0, /* Repeat argument given # of times */
- "replace", FN_RPL, 0, /* Replace characters in string */
- "reverse", FN_REV, 0, /* Reverse the argument string */
- "right", FN_RIG, 0, /* Rightmost n characters of string */
- "rindex", FN_RIX, 0, /* Right index */
- "rpad", FN_RPA, 0, /* Right-pad the argument */
- "rsearch", FN_RSEARCH, 0, /* R-L Search for pattern in string */
- #ifdef OS2
- "scrncurx", FN_SCRN_CX, 0, /* Screen Cursor X Pos */
- "scrncury", FN_SCRN_CY, 0, /* Screen Cursor Y Pos */
- "scrnstr", FN_SCRN_STR, 0, /* Screen String */
- #endif /* OS2 */
- "search", FN_SEARCH, 0, /* L-R Search for pattern in string */
- "size", FN_FS, 0, /* File size */
- "span", FN_SPN, 0, /* Span - like Snobol */
- "split", FN_SPLIT,0, /* Split string into words */
- "stripb", FN_STB, 0, /* Strip enclosing braces/brackets */
- "stripn", FN_STN, 0, /* Strip n chars */
- "stripx", FN_STX, 0, /* Strip "extension" */
- "substring", FN_SUB, 0, /* Extract substring from argument */
- "tablelook", FN_TLOOK,0, /* Table lookup */
- "time", FN_TIME, 0, /* Free-format time to hh:mm:ss */
- "tod2secs", FN_NTIM, CM_INV, /* Time-of-day-to-secs-since-midnite */
- "trim", FN_TRM, 0, /* Trim */
- "unhexify", FN_UNH, 0, /* Unhexify */
- "upper", FN_UPP, 0, /* Return uppercased argument */
- "verify", FN_VER, 0, /* Verify */
- "word", FN_WORD, 0, /* Extract a word */
- "", 0, 0
- };
- int nfuncs = (sizeof(fnctab) / sizeof(struct keytab)) - 1;
- #endif /* NOSPL */
- #ifndef NOSPL /* Buffer for expansion of */
- #ifdef BIGBUFOK /* built-in variables. */
- #define VVBUFL 1024
- #else
- #define VVBUFL 256
- #endif /* BIGBUFOK */
- char vvbuf[VVBUFL+1];
- #endif /* NOSPL */
- struct keytab disptb[] = { /* Log file disposition */
- "append", 1, 0,
- "new", 0, 0
- };
- #ifdef FNFLOAT
- /* I N I T F L O A T -- Deduce floating-point precision by inspection */
- int fp_rounding = 0; /* Nonzero if printf("%f") rounds */
- int fp_digits = 0; /* Digits of floating point precision */
- #ifdef COMMENT
- /* For looking at internal floating-point representations */
- static char fp_xbuf[128];
- static char *
- tohex(s, n) CHAR * s; int n; {
- int x;
- char * p = fp_xbuf;
- while (n-- > 0) {
- x = (*s >> 4) & 0x0f;
- *p++ = hexdigits[x];
- x = *s++ & 0x0f;
- *p++ = hexdigits[x];
- }
- *p = NUL;
- return((char *)fp_xbuf);
- }
- #endif /* COMMENT */
- VOID
- initfloat() {
- char buf[256];
- int i, x, y;
- #ifdef COMMENT
- /* For looking at internal floating-point representations */
- double a[] = { 0.0, 0.5, 0.05, 0.005, 0.0005, 0.00005, 0.5e-20,
- 1.0, -1.0, 2.0, -2.0, 3.0, -3.0, 4.0, -4.0 };
- int n = sizeof(a) / sizeof(double);
- union blah {
- CHAR xbuf[32];
- double f;
- } u;
- #endif /* COMMENT */
- sprintf(buf,"%0.250f",(10.0 / 3.0));
- for (i = 2; i < 250 && buf[i] == '3'; i++) ;
- x = i - 1;
- debug(F111,"initfloat 10.0/3.0",buf,x);
- sprintf(buf,"%0.250f",(4.0 / 9.0));
- for (i = 2; i < 250 && buf[i] == '4'; i++) ;
- y = i - 1;
- debug(F111,"initfloat 4.0/9.0",buf,y);
- fp_digits = (x < y) ? x : y;
- sprintf(buf,"%0.6f",(7.0 / 9.0));
- if (buf[7] == '8') fp_rounding = 1;
- debug(F111,"initfloat 7.0/9.0",buf,fp_rounding);
- debug(F101,"initfloat precision","",fp_digits);
- #ifdef COMMENT
- for (i = 0; i < n; i++) {
- memset(u.xbuf,0,32);
- u.f = a[i];
- sprintf(buf,"initfloat %f", u.f);
- debug(F110,buf,tohex(u.xbuf,8),0);
- }
- #endif /* COMMENT */
- }
- #endif /* FNFLOAT */
- /*
- P R E S C A N -- A quick look through the command-line options for
- items that must be handled before the initialization file is executed.
- */
- #ifdef NT
- extern int StartedFromDialer;
- #endif /* NT */
- #ifdef OS2
- extern int k95stdio;
- unsigned long startflags = 0L;
- #endif /* OS2 */
- static char *
- findinpath(arg) char * arg; {
- #ifdef OS2
- extern char startupdir[], exedir[], inidir[];
- char * scriptenv, * keymapenv;
- int len;
- #endif /* OS2 */
- #ifdef DCMDBUF
- extern char * cmdbuf;
- #else
- extern char cmdbuf[];
- #endif /* DCMDBUF */
- char takepath[4096];
- char * s;
- int x, z;
- /* Set up search path... */
- #ifdef OS2
- #ifdef NT
- scriptenv = getenv("K95SCRIPTS");
- keymapenv = getenv("K95KEYMAPS");
- #else /* NT */
- scriptenv = getenv("K2SCRIPTS");
- keymapenv = getenv("K2KEYMAPS");
- #endif /* NT */
- if (!scriptenv)
- scriptenv = getenv("CK_SCRIPTS");
- if (!scriptenv)
- scriptenv = "";
- if (!keymapenv)
- keymapenv = getenv("CK_KEYMAPS");
- if (!keymapenv)
- keymapenv = "";
- debug(F110,"startupdir",startupdir,0);
- debug(F110,"inidir",inidir,0);
- debug(F110,"exedir",exedir,0);
- len = strlen(scriptenv) + strlen(keymapenv) + 3*strlen(startupdir)
- + 3*strlen(inidir) + 3*strlen(zhome()) + 3*strlen(exedir)
- + 4*strlen("SCRIPTS/") + 4*strlen("KEYMAPS/") + 16;
- if (len >= 4096) {
- takepath[0] = ' ';
- debug(F111,"findinpath error - path length too long","len",len);
- } else
- sprintf(takepath,
- /* semicolon-separated path list */
- "%s%s%s%s%s;%s%s;%s%s;%s;%s%s;%s%s;%s;%s%s;%s%s",
- scriptenv,
- (scriptenv[0] && scriptenv[strlen(scriptenv)-1]==';')?"":";",
- keymapenv,
- (keymapenv[0] && keymapenv[strlen(keymapenv)-1]==';')?"":";",
- startupdir,
- startupdir, "SCRIPTS/",
- startupdir, "KEYMAPS/",
- inidir,
- inidir, "SCRIPTS/",
- inidir, "KEYMAPS/",
- zhome(),
- zhome(), "SCRIPTS/",
- zhome(), "KEYMAPS/",
- exedir,
- exedir, "SCRIPTS/",
- exedir, "KEYMAPS/"
- );
- #else /* not OS2 */
- #ifndef NOSPL
- z = 1024; /* Look in home directory */
- s = takepath;
- zzstring("\v(home)",&s,&z);
- #else
- takepath[0] = ' ';
- #endif /* NOSPL */
- #endif /* OS2 */
- /*
- All the logic for searching the take path is in the command parser.
- So even though we aren't parsing commands, we initialize and call the
- parser from here, with the purported filename stuffed into the command
- buffer, followed by some carriage returns to make the parser return.
- If the file is not found, or otherwise not accessible, the parser prints
- an appropriate message, and then we just exit.
- */
- cmdini(); /* Allocate command buffers etc */
- cmini(0); /* Initialize them */
- /* Stuff filename into command buf with braces in case of spaces */
- sprintf(cmdbuf,"{%s}",arg);
- debug(F110,"prescan cmdbuf",cmdbuf,0);
- strcat(cmdbuf,"rr"); /* And some carriage returns */
- if (cmifip("","",&s,&x,0,takepath,xxstring) < 0)
- return(NULL);
- cmres();
- return(s);
- }
- static int tr_int; /* Flag if TRANSMIT interrupted */
- #ifndef MAC
- SIGTYP
- #ifdef CK_ANSIC
- trtrap(int foo) /* TRANSMIT interrupt trap */
- #else
- trtrap(foo) int foo; /* TRANSMIT interrupt trap */
- #endif /* CK_ANSIC */
- /* trtrap */ {
- #ifdef __EMX__
- signal(SIGINT, SIG_ACK);
- #endif
- tr_int = 1; /* (Need arg for ANSI C) */
- SIGRETURN;
- }
- #endif /* MAC */
- #endif /* NOICP */
- int arg_x = 0;
- static int x_prescan = 0;
- /*
- The argument y once meant something but I can't imagine what so now
- it's ignored. (Prior to 22 Aug 98, prescan() was called twice by main(),
- and the arg differentiated the two calls. But this caused all sorts of
- problems & confusion, so I commented out the second call. This issue might
- need to be revisited.)
- */
- VOID
- prescan(dummy) int dummy; { /* Arg is ignored. */
- extern int howcalled;
- int yargc; char **yargv;
- char x;
- char *yp;
- int z;
- if (x_prescan) /* Only run once */
- return;
- x_prescan = 1;
- yargc = xargc; /* Make copy of arg vector */
- yargv = xargv;
- #ifndef NOICP
- #ifdef DCMDBUF
- if (!kermrc)
- if (!(kermrc = (char *) malloc(KERMRCL+1)))
- fatal("prescan: no memory for kermrc");
- #endif /* DCMDBUF */
- ckstrncpy(kermrc,KERMRC,KERMRCL); /* Default init file name */
- #endif /* NOICP */
- #ifdef IKSD
- if (howcalled == I_AM_IKSD) /* Internet Kermit Service daemon */
- inserver = 1; /* (See inserver section of ckcmai) */
- else
- #endif /* IKSD */
- if (howcalled != I_AM_KERMIT) /* I'm called "telnet" or... */
- return;
- /* Command line options for Kermit */
- #ifndef NOCMDL
- #ifndef NOICP
- if (yargc > 1
- && *yargv[1] != '-'
- && strcmp(yargv[1],"=")
- #ifdef KERBANG
- && strcmp(yargv[1],"+")
- #endif /* KERBANG */
- ) { /* Filename as 1st argument */
- char *s;
- int x, y;
- x = isabsolute(yargv[1]);
- if (!x) /* If not absolute */
- s = findinpath(yargv[1]);
- else
- s = yargv[1];
- if (!s)
- doexit(BAD_EXIT,xitsta);
- zfnqfp(s,CKMAXPATH,cmdfil); /* In case of CD in file */
- yargc -= 1; /* Skip past the filename */
- yargv += 1; /* Otherwise we'll get an error */
- }
- #endif /* NOICP */
- while (--yargc > 0) { /* Go through command-line args */
- yargv++;
- yp = *yargv+1; /* Pointer for bundled args */
- if (**yargv == '=') /* Same rules as cmdlin()... */
- return;
- debug(F110,"prescan *yargv",*yargv,0);
- #ifndef NOICP
- #ifdef KERBANG
- if (!strcmp(*yargv,"+")) {
- char * s;
- yargv++;
- noinit = 1;
- if (!*yargv)
- return;
- cfilef = 1;
- s = findinpath(*yargv);
- if (s) {
- zfnqfp(s,CKMAXPATH,cmdfil);
- return;
- } else
- doexit(BAD_EXIT,xitsta);
- }
- #endif /* KERBANG */
- #endif /* NOICP */
- if (!strcmp(*yargv,"--")) /* getopt() conformance */
- return;
- #ifdef VMS
- else if (**yargv == '/')
- continue;
- #endif /* VMS */
- else if (**yargv == '-') { /* Got an option (begins with dash) */
- x = *(*yargv+1); /* Get option letter */
- while (x) { /* Allow for bundled options */
- debug(F000,"prescan arg","",x);
- switch (x) {
- #ifndef NOICP
- case '+':
- case '-':
- if (doxarg(yargv,1) < 0) {
- fatal("Extended argument error");
- }
- yargv++, yargc--;
- yp = *yargv;
- break;
- #endif /* NOICP */
- case '7': /* Undocumented... */
- sstelnet = 1; /* (because it doesn't work) */
- break;
- #ifdef IKSD
- case 'A': {
- char * p;
- inserver = 1; /* Flag that we are doing this */
- srvcdmsg = 2; /* Preset this */
- /* See inserver section of ckcmai.c for more settings */
- #ifdef NT
- if (*(yp+1)) {
- fatal("invalid argument bundling after -A");
- }
- /* Support for Pragma Systems Telnet/Terminal Servers */
- p = getenv("PRAGMASYS_INETD_SOCK");
- if (p && atoi(p) != 0) {
- ttname[0] = '$';
- ckstrncpy(&ttname[1],p,TTNAMLEN-1);
- break;
- }
- yargv++, yargc--;
- if (yargc < 1 || **yargv == '-') {
- fatal("-A argument missing");
- } else {
- ttname[0] = '$';
- ckstrncpy(&ttname[1],*yargv,TTNAMLEN-1);
- }
- #endif /* NT */
- break;
- }
- #endif /* IKSD */
- #ifdef OS2
- case 'W':
- if (*(yp+1))
- fatal("invalid argument bundling after -W");
- yargv++, yargc--;
- if (yargc < 1)
- fatal("Window handle missing");
- #ifdef COMMENT
- if (dummy) {
- yargv++, yargc--;
- break;
- } else {
- #endif /* COMMENT */
- hwndDialer = (HWND) atol(*yargv);
- StartedFromDialer = 1;
- yargv++, yargc--;
- KermitDialerID = atol(*yargv) ;
- #ifdef COMMENT
- }
- #endif /* COMMENT */
- break;
- case '#': /* K95 initialization options */
- if (*(yp+1)) {
- fatal("invalid argument bundling");
- }
- yargv++, yargc--;
- if (yargc < 1)
- fatal("-# argument missing");
- startflags |= atol(*yargv);
- break;
- #endif /* OS2 */
- #ifndef NOSPL
- case 'M': /* My User Name */
- if (*(yp+1)) {
- fatal("invalid argument bundling");
- }
- yargv++, yargc--;
- if ((yargc < 1) || (**yargv == '-')) {
- fatal("missing username");
- }
- if ((int)strlen(*yargv) > UIDBUFLEN) {
- fatal("username too long");
- }
- #ifdef IKSD
- if (!inserver)
- #endif /* IKSD */
- ckstrncpy(uidbuf,*yargv,UIDBUFLEN);
- break;
- #endif /* NOSPL */
- case 'R': /* Remote-only advisory */
- #ifdef CK_IFRO
- remonly = 1;
- #endif /* CK_IFRO */
- break;
- case 'S': /* STAY */
- stayflg = 1;
- break;
- case 'h':
- noinit = 1;
- #ifdef OS2
- startflags |= 2; /* No network DLLs */
- startflags |= 4; /* No TAPI DLLs */
- startflags |= 8; /* No Security DLLs */
- startflags |= 16; /* No Zmodem DLLs */
- #endif /* OS2 */
- break;
- #ifndef NOICP
- case 'Y': /* No init file */
- noinit = 1;
- break;
- #endif /* NOICP */
- case 'd': /* = SET DEBUG ON */
- #ifdef DEBUG
- if (!deblog) {
- extern int debtim;
- deblog = debopn("debug.log",0);
- /* debtim = 1; */
- }
- #endif /* DEBUG */
- break;
- case 'x': /* Server */
- arg_x = 1; /* Note in advance */
- break;
- #ifndef NOICP
- case 'y': /* Alternative init file */
- yargv++, yargc--;
- if (yargc < 1) fatal("missing name in -y");
- /* Replace init file name */
- ckstrncpy(kermrc,*yargv,KERMRCL);
- rcflag = 1; /* Flag that this has been done */
- debug(F111,"prescan kermrc",kermrc,rcflag);
- break;
- #endif /* NOICP */
- case 'z': /* = SET BACKGROUND OFF */
- bgset = 0;
- break;
- #ifdef CK_NETBIOS
- case 'N':
- {
- int n ;
- yargv++, yargc--;
- #ifdef COMMENT
- if (y)
- break;
- #endif /* COMMENT */
- if (strlen(*yargv) != 1 || (*yargv)[0] == 'X') {
- NetBiosAdapter = -1;
- } else {
- n = atoi(*yargv);
- if (n >= 0 && n <= 9)
- NetBiosAdapter = n;
- else
- NetBiosAdapter = -1;
- }
- }
- break;
- #endif /* CK_NETBIOS */
- default:
- break;
- }
- if (!yp)
- break;
- x = *++yp; /* See if options are bundled */
- }
- }
- }
- #endif /* NOCMDL */
- }
- /* G E T T C S -- Get Transfer (Intermediate) Character Set */
- /*
- Given two file character sets, this routine picks out the appropriate
- "transfer" character set to use for translating between them.
- The transfer character set number is returned.
- Translation between two file character sets is done, for example,
- by the CONNECT, TRANSMIT, and TRANSLATE commands.
- Translation between Kanji character sets is not yet supported.
- */
- int
- gettcs(cs1,cs2) int cs1, cs2; {
- #ifdef NOCSETS /* No character-set support */
- return(0); /* so no translation */
- #else
- int tcs = TC_TRANSP;
- #ifdef KANJI
- /* Kanji not supported yet */
- if (fcsinfo[cs1].alphabet == AL_JAPAN ||
- fcsinfo[cs2].alphabet == AL_JAPAN )
- tcs = TC_TRANSP;
- else
- #endif /* KANJI */
- #ifdef CYRILLIC
- /*
- I can't remember why we don't test both sets here, but I think there
- must have been a reason...
- */
- if (fcsinfo[cs2].alphabet == AL_CYRIL)
- tcs = TC_CYRILL;
- else
- #endif /* CYRILLIC */
- #ifdef HEBREW
- if (fcsinfo[cs1].alphabet == AL_HEBREW ||
- fcsinfo[cs2].alphabet == AL_HEBREW )
- tcs = TC_HEBREW;
- else
- #endif /* HEBREW */
- #ifdef GREEK
- if (fcsinfo[cs1].alphabet == AL_GREEK ||
- fcsinfo[cs2].alphabet == AL_GREEK )
- tcs = TC_GREEK;
- else
- #endif /* GREEK */
- /* Roman sets ... */
- #ifdef LATIN2 /* East European */
- if (cs1 == FC_2LATIN || cs2 == FC_2LATIN || /* Latin-2 */
- cs1 == FC_CP852 || cs2 == FC_CP852 || /* CP852 */
- cs1 == FC_CP1250 || cs2 == FC_CP1250 || /* Windows Latin-2 */
- cs1 == FC_MAZOVIA || cs2 == FC_MAZOVIA) /* Polish Mazovia */
- tcs = TC_2LATIN;
- else
- #endif /* LATIN2 */
- /* West European Euro-aware */
- if (cs1 == FC_CP858 || cs1 == FC_9LATIN ||
- cs2 == FC_CP858 || cs2 == FC_9LATIN)
- tcs = TC_9LATIN;
- else /* Traditional West European */
- tcs = TC_1LATIN;
- return(tcs);
- #endif /* NOCSETS */
- }
- #ifndef NOLOCAL
- /* D O C O N E C T -- Do the connect command */
- /*
- q = 0 means issue normal informational message about how to get back, etc.
- q != 0 means to skip the message.
- */
- int
- doconect(q) int q; {
- int x, z; /* Return code */
- extern int what;
- #ifdef CK_AUTODL
- extern CHAR ksbuf[];
- #endif /* CK_AUTODL */
- #ifndef NOKVERBS /* Keyboard macro material */
- extern int keymac, keymacx;
- #endif /* NOKVERBS */
- extern int justone;
- int qsave; /* For remembering "quiet" value */
- #ifdef OS2
- extern int term_io;
- extern int display_demo;
- int term_io_save;
- #endif /* OS2 */
- int is_tn = 0;
- #ifdef IKSD
- if (inserver) {
- if (!quiet)
- printf("?Sorry, IKSD cannot CONNECT.rn");
- return(success = 0);
- }
- #endif /* IKSD */
- is_tn =
- #ifdef TNCODE
- (local && network && ttnproto == NP_TELNET) || (!local && sstelnet)
- #else
- 0
- #endif /* TNCODE */
- ;
- /*
- Saving, changing, and restoring the global "quiet" variable around calls
- to conect() to control whether the verbose CONNECT message is printed is
- obviously less elegant than passing a parameter to conect(), but we do it
- this way to avoid the need to change all of the ck?con.c modules. NOTE:
- it is important to restore the value immediately upon return in case there
- is an autodownload or APC.
- */
- qsave = quiet; /* Save it */
- if (!quiet && q > -1)
- quiet = q; /* Use argument temporarily */
- conres(); /* Put console back to normal */
- debug(F101,"doconect justone 1","",justone);
- #ifdef CK_AUTODL
- ksbuf[0] = NUL; /* Autodownload packet buffer */
- #endif /* CK_AUTODL */
- #ifdef OS2
- display_demo = 1; /* Remember to display demo */
- #endif /* OS2 */
- #ifdef IKS_OPTION
- if (is_tn && TELOPT_U(TELOPT_KERMIT) && ttchk() >= 0
- #ifdef OS2
- && !viewonly
- #endif /* OS2 */
- ) {
- /* If the remote side is in a state of IKS START-SERVER */
- /* we request that the state be changed. We will detect */
- /* a failure to adhere to the request when we call ttinc() */
- if (!iks_wait(KERMIT_REQ_STOP,0) && !tcp_incoming) {
- if (!quiet) {
- printf("rnEnter Client/Server Mode... Use:rnrn");
- printf(
- " REMOTE LOGIN <user> <password> to log in to the server if necessary.rn");
- printf(" SEND and GET for file transfer.rn");
- printf(" REMOTE commands for file management.rn");
- printf(" FINISH to terminate Client/Server mode.rn");
- printf(" BYE to terminate and close connection.rn");
- printf(" REMOTE HELP for additional information.rnrn");
- }
- quiet = qsave;
- return(0); /* Failure */
- }
- }
- /* Let our peer know our state. */
- #ifdef CK_AUTODL
- if (is_tn && TELOPT_ME(TELOPT_KERMIT)
- #ifdef OS2
- && !viewonly
- #endif /* OS2 */
- ) {
- if (autodl && !TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {
- tn_siks(KERMIT_START); /* Send Kermit-Server Start */
- } else if (!autodl && TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {
- tn_siks(KERMIT_STOP);
- }
- }
- #else /* CK_AUTODL */
- if (TELOPT_SB(TELOPT_KERMIT).kermit.me_start) {
- tn_siks(KERMIT_STOP);
- }
- #endif /* CK_AUTODL */
- #endif /* IKS_OPTION */
- debug(F101,"doconect flow","",flow);
- x = conect(); /* Connect the first time */
- #ifdef IKS_OPTION
- if (TELOPT_U(TELOPT_KERMIT) &&
- TELOPT_SB(TELOPT_KERMIT).kermit.u_start &&
- !tcp_incoming && !quiet && ttchk() >= 0
- ) {
- printf("rnEnter Client/Server Mode... Use:rnrn");
- printf(
- " REMOTE LOGIN <user> <password> to log in to the server if necessary.rn");
- printf(" SEND and GET for file transfer.rn");
- printf(" REMOTE commands for file management.rn");
- printf(" FINISH to terminate Client/Server mode.rn");
- printf(" BYE to terminate and close connection.rn");
- printf(" REMOTE HELP for additional information.rnrn");
- }
- #endif /* IKS_OPTION */
- quiet = qsave; /* Restore "quiet" value */
- debug(F101,"doconect justone 2","",justone);
- #ifdef NETCONN
- if (network && tn_exit && ttchk() < 0)
- doexit(GOOD_EXIT,xitsta); /* Exit with good status */
- #endif /* NETCONN */
- #ifdef OS2ORUNIX
- /* Exit on disconnect if the port is not open or carrier detect */
- if (exitonclose && (ttchk() < 0))
- doexit(GOOD_EXIT,xitsta);
- #endif /* OS2ORUNIX */
- #ifdef CKCONINTB4CB
- /* The order makes a difference in HP-UX 8.00. */
- /* The other order makes it think it's in the background when it */
- /* returns from CONNECT (Apr 1999). */
- setint();
- concb((char)escape); /* Restore console for commands */
- #else
- /* This is how it has always been so better leave it */
- /* this way for all non-HP-UX-8.00 builds. */
- concb((char)escape); /* Restore console for commands */
- setint();
- #endif /* CKCONINTB4CB */
- #ifdef OS2
- term_io_save = term_io; /* Disable I/O by emulator */
- term_io = 0;
- #endif /* OS2 */
- #ifdef CK_APC
- /*
- If an APC command was received during CONNECT mode, we define it now
- as a macro, execute the macro, and then return to CONNECT mode.
- We do this in a WHILE loop in case additional APCs come during subsequent
- CONNECT sessions.
- */
- debug(F101,"doconect apcactive","",apcactive);
- debug(F101,"doconect success","",success);
- while (x > 0 && (apcactive == APC_LOCAL ||
- (apcactive == APC_REMOTE && apcstatus != APC_OFF))) {
- debug(F101,"doconect justone 3","",justone);
- if (mlook(mactab,"_apc_commands",nmac) == -1) {
- debug(F110,"doconect about to execute APC",apcbuf,0);
- domac("_apc_commands",apcbuf,cmdstk[cmdlvl].ccflgs|CF_APC);
- delmac("_apc_commands");
- #ifdef DEBUG
- } else {
- debug(F100,"doconect APC in progress","",0);
- #endif /* DEBUG */
- }
- debug(F101,"doconect apcactive after domac","",apcactive);
- if (!apcactive) { /* In case CLEAR APC was in APC */
- debug(F101,"doconect quit APC loop: apcactive","",apcactive);
- break;
- }
- /* Also don't reconnect if autodownload failed - very confusing! */
- /* Let them view the local screen to see what happened. */
- #ifndef NOXFER
- debug(F101,"doconect xferstat","",xferstat);
- if (apcactive == APC_LOCAL & !xferstat) {
- debug(F101,"doconect quit APC loop: xferstat","",xferstat);
- apcactive = APC_INACTIVE;
- break;
- }
- #endif /* NOXFER */
- #ifdef OS2
- msleep(250);
- #endif /* OS2 */
- debug(F101,"doconect justone 4","",justone);
- qsave = quiet; /* Do this again... */
- if (!quiet && q > -1)
- quiet = q;
- #ifdef CK_AUTODL
- ksbuf[0] = NUL;
- #endif /* CK_AUTODL */
- #ifdef IKS_OPTION
- #ifdef CK_AUTODL
- if (is_tn &&
- TELOPT_ME(TELOPT_KERMIT) &&
- !TELOPT_SB(TELOPT_KERMIT).kermit.me_start &&
- autodl
- #ifdef CK_APC
- && !apcactive
- #endif /* CK_APC */
- #ifdef OS2
- && !viewonly
- #endif /* OS2 */
- ) {
- tn_siks(KERMIT_START); /* Send Kermit-Server Start */
- }
- #endif /* CK_AUTODL */
- #endif /* IKS_OPTION */
- x = conect(); /* Re-CONNECT. */
- #ifdef COMMENT
- #ifdef IKS_OPTION
- #ifdef CK_AUTODL
- if (is_tn && TELOPT_ME(TELOPT_KERMIT) && autodl
- #ifdef CK_APC
- && !apcactive
- #endif /* CK_APC */
- #ifdef OS2
- && !viewonly
- #endif /* OS2 */
- ) {
- tn_siks(KERMIT_STOP); /* Send Kermit-Server Stop */
- }
- #endif /* CK_AUTODL */
- #endif /* IKS_OPTION */
- #endif /* COMMENT */
- #ifdef OS2
- term_io = term_io_save;
- #endif /* OS2 */
- quiet = qsave;
- debug(F101,"doconect justone 5","",justone);
- #ifdef NETCONN
- if (network && ttchk() < 0) {
- if (tn_exit || exitonclose)
- doexit(GOOD_EXIT,xitsta);
- else
- break;
- }
- #endif /* NETCONN */
- #ifdef OS2ORUNIX
- /* If connection dropped */
- if (ttchk() < 0) {
- concb((char)escape); /* Restore console. */
- if (exitonclose)
- doexit(GOOD_EXIT,xitsta);
- else
- break;
- }
- #endif /* OS2ORUNIX */
- } /* Loop back for more. */
- #endif /* CK_APC */
- #ifndef NOKVERBS
- if ((keymac > 0) && (keymacx > -1)) { /* Executing a keyboard macro? */
- /* Set up the macro and return */
- /* Do not clear the keymac flag */
- return(dodo(keymacx,NULL,CF_KMAC|cmdstk[cmdlvl].ccflgs));
- }
- #endif /* NOKVERBS */
- #ifdef OS2
- term_io = term_io_save;
- #endif /* OS2 */
- #ifdef CKCONINTB4CB
- /* The order makes a difference in HP-UX 8.00. */
- /* The other order makes it think it's in the background when it */
- /* returns from CONNECT (Apr 1999). */
- setint();
- concb((char)escape); /* Restore console for commands */
- #else
- /* This is how it has always been so better leave it */
- /* this way for all non-HP-UX-8.00 builds. */
- concb((char)escape); /* Restore console for commands */
- setint();
- #endif /* CKCONINTB4CB */
- what = W_COMMAND; /* Back in command mode. */
- return(x); /* Done. */
- }
- #endif /* NOLOCAL */
- #ifndef NOICP
- #ifdef COMMENT
- /*
- It seemed that this was needed for OS/2, in which v(cmdfile) and other
- file-oriented variables or functions can return filenames containing
- backslashes, which are subsequently interpreted as quotes rather than
- directory separators (e.g. see commented section for VN_CMDF below).
- But the problem can't be cured at this level. Example:
- type v(cmdfile)
- Without doubling, the filename is parsed correctly, but then when passed
- to UNIX 'cat' through the shell, the backslash is removed, and then cat
- can't open the file. With doubling, the filename is not parsed correctly
- and the TYPE command fails immediately with a "file not found" error.
- */
- /*
- Utility routine to double all backslashes in a string.
- s1 is pointer to source string, s2 is pointer to destination string,
- n is length of destination string, both NUL-terminated.
- Returns 0 if OK, -1 if not OK (destination string too short).
- */
- int
- dblbs(s1,s2,n) char *s1, *s2; int n; {
- int i = 0;
- while (*s1) {
- if (*s1 == '\') {
- if (++i > n) return(-1);
- *s2++ = '\';
- }
- if (++i > n) return(-1);
- *s2++ = *s1++;
- }
- *s2 = NUL;
- return(0);
- }
- #endif /* COMMENT */
- char *
- gmdmtyp() { /* Get modem type */
- #ifndef NODIAL
- int i, x;
- x = mdmtyp;
- if (x < 0) /* In case of network dialing */
- x = mdmsav;
- if (x < 1)
- return("none");
- else
- for (i = 0; i < nmdm; i++)
- if ((mdmtab[i].kwval == x) && (mdmtab[i].flgs == 0))
- return(mdmtab[i].kwd);
- #endif /* NODIAL */
- return("none");
- }
- #ifndef NOXMIT
- #ifndef NOLOCAL
- /* T R A N S M I T -- Raw upload */
- /* Obey current line, duplex, parity, flow, text/binary settings. */
- /* Returns 0 upon apparent success, 1 on obvious failure. */
- /***
- Things to add:
- . Make both text and binary mode obey set file bytesize.
- . Maybe allow user to specify terminators other than CR?
- . Maybe allow user to specify prompts other than single characters?
- . Make STATISTICS also work for TRANSMIT.
- . If TRANSMIT is done without echo, make some kind of (optional) display.
- . Make the same optimization for binary-mode transmit that was done for
- text-mode (in the no-echo / no-prompt / no-pause case).
- ***/
- /* T R A N S M I T -- Raw upload */
- /* s is the filename, t is the turnaround (prompt) character */
- /*
- Maximum number of characters to buffer.
- Must be less than LINBUFSIZ
- */
- #ifdef OS2
- #define XMBUFS 4096 /* For compatibility with XYZmodem */
- #else /* OS2 */
- #define XMBUFS 1024
- #endif /* OS2 */
- #ifdef TNCODE
- #ifndef IAC
- #define IAC 255
- #endif /* IAC */
- #endif /* TNCODE */
- #define OUTXBUFSIZ 15
- static CHAR inxbuf[OUTXBUFSIZ+1]; /* Host-to-screen expansion buffer */
- static int inxcount = 0; /* and count */
- static CHAR outxbuf[OUTXBUFSIZ+1]; /* Keyboard-to-host expansion buf */
- static int outxcount = 0; /* and count */
- /* T R A N S M I T -- Unguarded non-protocol file transmission */
- /*
- Call with:
- char * s: Name of file to transmit.
- char t: Turnaround char for text-mode transmission (normally LF).
- int xlate: nonzero = charset translation for text-mode xfer, 0 = skip.
- int binary: nonzero = transmit in binary mode, 0 = in text mode.
- */
- int
- #ifdef CK_ANSIC
- transmit(char * s, char t, int xlate, int binary)
- #else
- transmit(s,t,xlate,binary) char *s; char t; int xlate, binary;
- #endif /* CK_ANSIC */
- /* transmit */ {
- #ifdef MAC
- extern char sstate;
- int count = 100;
- #else
- #ifdef OS2
- #ifdef NT
- SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */
- #else /* NT */
- SIGTYP (* volatile oldsig)(int);
- #endif /* NT */
- #else /* OS2 */
- SIGTYP (* oldsig)();
- #endif /* OS2 */
- #endif /* MAC */
- int eof = 0; /* End of File flag */
- int eol = 0; /* End of Line flag */
- int rc = 1; /* Return code. 0=fail, 1=succeed. */
- int myflow; /* Local copy of global flow... */
- int is_tn = 0; /* Do Telnet negotiations */
- int xbufsiz = XMBUFS; /* Size of TRANSMIT buffer */
- int k, x, c, i; /* Int workers... */
- int control = 0; /* Echo loop control */
- long nbytes = 0; /* File byte count */
- long zz; /* Long worker */
- char *p; /* Char * worker */
- #ifdef PIPESEND
- extern int pipesend;
- #endif /* PIPESEND */
- #ifndef NOCSETS
- int tcs = TC_TRANSP; /* Intermediate (xfer) char set */
- int langsv = L_USASCII; /* Save current language */
- int unicode = 0;
- int tcssize = 0;
- #ifdef CK_ANSIC /* ANSI C prototypes... */
- CHAR (*sxo)(CHAR);
- CHAR (*rxo)(CHAR);
- CHAR (*sxi)(CHAR);
- CHAR (*rxi)(CHAR);
- #else /* Not ANSI C... */
- CHAR (*sxo)();
- CHAR (*rxo)();
- CHAR (*sxi)();
- CHAR (*rxi)();
- #endif /* CK_ANSIC */
- #ifdef UNICODE
- union ck_short uc;
- int bomorder = 0;
- #ifdef CK_ANSIC
- extern int (*xl_ufc[MAXFCSETS+1])(USHORT); /* Unicode to FCS */
- extern USHORT (*xl_fcu[MAXFCSETS+1])(CHAR); /* FCS to Unicode */
- extern int (*xuf)(USHORT);
- extern USHORT (*xfu)(CHAR);
- #else
- extern int (*xl_ufc[MAXFCSETS+1])();
- extern USHORT (*xl_fcu[MAXFCSETS+1])();
- extern int (*xuf)();
- extern USHORT (*xfu)();
- #endif /* CK_ANSIC */
- #endif /* UNICODE */
- #endif /* NOCSETS */
- debug(F101,"xmit t","",t);
- debug(F101,"xmit xlate","",xlate);
- debug(F101,"xmit binary","",binary);
- #ifdef PIPESEND
- if (pipesend) {
- if (nopush) return(-2);
- if (zxcmd(ZIFILE,s) < 1) {
- printf("?Can't start command: %sn",s);
- return(0);
- }
- } else
- #endif /* PIPESEND */
- if (zopeni(ZIFILE,s) == 0) { /* Open the file to be transmitted */
- printf("?Can't open file %sn",s);
- return(0);
- }
- x = -1; /* Open the communication channel */
- if (ttopen(ttname,&x,mdmtyp,cdtimo) < 0) { /* (no harm if already open) */
- printf("Can't open device %sn",ttname);
- return(0);
- }
- zz = x ? speed : -1L;
- if (binary) { /* Binary file transmission */
- myflow = (flow == FLO_XONX) ? FLO_NONE : flow;
- if (ttvt(zz,myflow) < 0) { /* So no Xon/Xoff! */
- printf("Can't condition linen");
- return(0);
- }
- } else {
- if (ttpkt(zz,flow,parity) < 0) { /* Put the line in "packet mode" */
- printf("Can't condition linen"); /* so Xon/Xoff will work, etc. */
- return(0);
- }
- }
- is_tn =
- #ifdef TNCODE
- (local && network && (ttnproto == NP_TELNET)) || (!local && sstelnet)
- #else
- 0
- #endif /* TNCODE */
- ;
- #ifndef NOCSETS
- /* Set up character set translations */
- tcs = 0; /* "Transfer" or "Other" charset */
- sxo = rxo = NULL; /* Initialize byte-to-byte functions */
- sxi = rxi = NULL;
- unicode = 0; /* Assume Unicode won't be involved */
- if (!binary && xlate) { /* Set up charset translations */
- /*
- In the SENDING direction, we are converting from the local file's
- character-set (fcharset) to the remote terminal charset (tcsr). In the
- RECEIVING direction (echoing) we are converting from the remote end of the
- terminal charset (tcsr) to its local end (tcsl), which is not necessarily
- the same as the file character-set. Especially when the file character
- set is UCS-2, which is not a valid terminal character set. The various
- combinations are represented in this table:
- FCS = File Character Set
- RCS = Remote Terminal Character Set
- CCS = Console (Local Terminal) Character Set
- 8 4 2 1
- FCS FCS RCS CCS
- UCS UTF UTF UTF
- 0 0 0 0 = 0 = No translation
- 0 0 0 1 = 1 = FCS -> RCS, Echo RCS -> UTF
- 0 0 1 0 = 2 = FCS -> UTF, Echo UTF -> CCS
- 0 0 1 1 = 3 = FCS -> UTF, Echo no translation
- 0 1 0 0 = 4 = UTF -> RCS, Echo RCS -> CCS
- 0 1 0 1 = 5 = UTF -> RCS, Echo RCS -> UTF
- 0 1 1 0 = 6 = UTF -> UTF, Echo UTF -> CCS
- 0 1 1 1 = 7 = No translation
- 1 0 0 0 = 8 = UCS -> RCS, Echo RCS -> CCS
- 1 0 0 1 = 9 = UCS -> RCS, Echo RCS -> UTF
- 1 0 1 0 = 10 = UCS -> UTF, Echo UTF -> CCS
- 1 0 1 1 = 11 = UCS -> UTF, Echo no translation
- */
- #ifdef UNICODE
- xfu = NULL; /* Unicode translation functions */
- xuf = NULL;
- bomorder = ucsorder; /* UCS-2 byte order */
- if (fcharset == FC_UCS2) /* File charset is UCS-2 */
- unicode |= 8;
- else if (fcharset == FC_UTF8) /* File charset is UTF-8 */
- unicode |= 4;
- if (tcsr == FC_UTF8) /* Remote term charset is UTF-8 */
- unicode |= 2;
- if (tcsl == FC_UTF8) /* Local term charset is UTF-8 */
- unicode |= 1;
- #endif /* UNICODE */
- /*
- When Unicode not involved -- TCS is the intermediate (xfer) set, and:
- sxo = File-to-Intermediate charset function
- rxo = Intermediate-to-Remote-Terminal charset function
- sxi = Remote-Terminal-to-Intermediate
- rxi = Intermediate-to-Local-Terminal
- */
- tcs = gettcs(tcsr,fcharset); /* Get intermediate set. */
- sxo = xls[tcs][fcharset]; /* translation function */
- rxo = xlr[tcs][tcsr]; /* pointers for output functions */
- sxi = xls[tcs][tcsr]; /* and for input functions. */
- rxi = xlr[tcs][tcsl];
- /*
- At this point we have unicode nonzero if Unicode is involved in the
- conversion, and to 0 if it is.
- The following is to prevent use of zmstuff() and zdstuff() by translation
- functions (stuffing works with file i/o, not with communication i/o).
- */
- langsv = language; /* Save current SET LANGUAGE */
- language = L_USASCII; /* No language-specific translations */
- }
- #endif /* NOCSETS */
- i = 0; /* Beginning of buffer. */
- #ifndef MAC
- #ifndef AMIGA
- oldsig = signal(SIGINT, trtrap); /* Save current interrupt trap. */
- #endif /* AMIGA */
- #endif /* MAC */
- tr_int = 0; /* Have not been interrupted (yet). */
- rc = 1; /* Return code presumed good. */
- #ifdef VMS
- conres();
- #endif /* VMS */
- #ifndef NOCSETS
- debug(F101,"XMIT unicode","",unicode);
- #ifdef UNICODE
- debug(F101,"XMIT bomorder","",bomorder);
- #endif /* UNICODE */
- #endif /* NOCSETS */
- c = 0; /* Initial condition */
- while (c > -1 && !eof) { /* Loop for all characters in file */
- eol = 0;
- #ifdef MAC
- /*
- * It is expensive to run the miniparser so don't do it for
- * every character.
- */
- if (--count < 0) {
- count = 100;
- miniparser(1);
- if (sstate == 'a') {
- sstate = ' ';
- goto xmitfail;
- }
- }
- #else /* Not MAC */
- if (tr_int) { /* Interrupted? */
- printf("^C...n"); /* Print message */
- goto xmitfail;
- }
- #endif /* MAC */
- c = zminchar(); /* Get a file character */
- debug(F000,"XMIT zminchar","",c);
- if (c < -1) { /* Other error */
- printf("?Input errorn");
- goto xmitfail;
- } else if (c > -1) {
- nbytes++;
- c &= fmask; /* Apply SET FILE BYTESIZE mask */
- } else if (c == -1) {
- eof = 1;
- debug(F101,"XMIT eof","",eof);
- }
- if (binary) { /* If binary file, */
- if (c == -1) /* break if error, */
- goto xmitexit;
- if (ttoc(dopar((char) c)) < 0) { /* else just send the char */
- printf("?Can't transmit charactern");
- goto xmitfail;
- }
- #ifdef TNCODE
- if (c == IAC && is_tn) /* Quote Telnet IAC */
- ttoc((char)IAC);
- #endif /* TNCODE */
- if (xmitw) /* Pause if requested */
- msleep(xmitw);
- if (xmitx) { /* SET TRANSMIT ECHO ON? */
- if (duplex) { /* Yes, for half duplex */
- #ifdef OS2
- /* Echo to emulator */
- scriptwrtbuf((USHORT)(c & cmdmsk));
- #endif /* OS2 */
- if (conoc((char)(c & cmdmsk)) < 0) /* echo locally. */
- goto xmitfail;
- } else { /* For full duplex, */
- int i, n; /* display whatever is there. */
- n = ttchk(); /* See how many chars are waiting */
- if (n < 0) { /* Connection dropped? */
- printf("?Connection lostn");
- goto xmitfail;
- }
- for (i = 0; i < n; i++) { /* Read and echo that many. */
- x = ttinc(xmitt); /* Timed read just in case. */
- if (x > -1) { /* If no timeout */
- if (parity) x &= 0x7f; /* display the char, */
- #ifdef OS2
- /* Echo to emulator */
- scriptwrtbuf((USHORT)x);
- #endif /* OS2 */
- if (conoc((char)(x & cmdmsk)) < 0) {
- printf("?Output errorn");
- goto xmitfail;
- }
- } else if (x == -2) {
- printf("Connection closed.n");
- ttclos(1);
- goto xmitfail;
- } else if (x == -3) {
- printf(
- "Session Limit exceeded - closing connection.n"
- );
- ttclos(1);
- goto xmitfail;
- } else {
- printf("?Communications errorn");
- goto xmitfail;
- }
- }
- }
- } else ttflui(); /* Not echoing, just flush input. */
- } else { /* Text mode, line at a time. */
- #ifdef UNICODE
- if (fcharset == FC_UCS2 && xlate) { /* Special for UCS-2 */
- char xbuf[8];
- x = 1 - (nbytes & 1); /* Odd or even byte */
- if (x == 0) /* Note: 1 = the 1st, 0 = 2nd, etc */
- uc.x_short = 0;
- if (bomorder) /* Little Endian */
- x = 1 - x; /* Save byte in appropriate half */
- debug(F101,"XMIT UCS2 x","",x);
- uc.x_char[x] = (CHAR) (c & 0xff);
- if (nbytes & 1) /* First byte, go back for next */
- continue;
- if (nbytes == 2) { /* UCS-2 Byte Order Mark */
- if (uc.x_short == (USHORT) 0xfeff) {
- debug(F100,"XMIT UCS2 BOM FEFF","",bomorder);
- continue;
- } else if (uc.x_short == (USHORT) 0xfffe) {
- bomorder = 1 - bomorder;
- debug(F100,"XMIT UCS2 BOM FFFE (swap)","",bomorder);
- continue;
- }
- }
- sprintf(xbuf,"%04X",uc.x_short);
- debug(F111,"XMIT UCS2",xbuf,uc.x_short);
- if (nbytes & 1) /* Special eol test for UCS-2 */
- if (uc.x_short == 'n')
- eol = 1;
- #ifdef COMMENT
- if (uc.x_short == 0x2028 || uc.x_short == 0x2029)
- eol = 1;
- #endif /* COMMENT */
- } else
- #endif /* UNICODE */
- if (c == 'n') { /* Normal eol test otherwise */
- eol = 1;
- }
- if (eol) { /* End of line? */
- int stuff = -1;
- debug(F101,"XMIT eol length","",i);
- if (i == 0) { /* Blank line? */
- if (xmitf) /* Yes, insert fill if asked. */
- line[i++] = dopar((char) xmitf);
- }
- if (i == 0 || ((char) line[i-1]) != ((char) dopar(CR)))
- line[i++] = dopar(CR); /* Terminate it with CR */
- if (xmitl) {
- stuff = LF;
- #ifdef TNCODE
- } else if (is_tn && (tn_nlm != TNL_CR)) {
- /* TELNET NEWLINE ON/OFF/RAW */
- stuff = (tn_nlm == TNL_CRLF) ? LF : NUL;
- #endif /* TNCODE */
- }
- if (stuff > -1)
- line[i++] = dopar((char)stuff);
- line[i] = NUL;
- debug(F111,"XMIT eol line",line,i);
- } else if (c != -1) { /* Not a newline, regular character */
- int k, x;
- outxbuf[0] = c; /* In case of no translation */
- outxcount = 1; /* Assume result is one byte */
- #ifndef NOCSETS
- switch (unicode) {
- case 0: /* No Unicode involved */
- case 1:
- if (xlate) { /* If not /TRANSPARENT */
- /* Local-to-intermediate */
- if (sxo) c = (*sxo)((char)c);
- /* Intermediate-to-remote */
- if (rxo) c = (*rxo)((char)c);
- outxbuf[0] = c;
- }
- break;
- #ifdef UNICODE
- case 2: /* Local byte to UTF-8 */
- case 3:
- xfu = xl_fcu[fcharset];
- tcssize = fcsinfo[fcharset].size;
- outxcount =
- b_to_u((CHAR)c,outxbuf,OUTXBUFSIZ,tcssize);
- break;
- case 4: /* Local UTF-8 to remote byte */
- case 5:
- xuf = xl_ufc[tcsr];
- x = u_to_b((CHAR)c); /* Convert to byte */
- if (x == -1) { /* If more input bytes needed */
- continue; /* go back and get them */
- } else if (x == -2) { /* LS or PS (shouldn't happen) */
- outxbuf[0] = CR;
- } else if (x == -9) { /* UTF-8 error */
- outxbuf[0] = '?'; /* Insert error char */
- outxbuf[1] = u_to_b2(); /* Insert next char */
- outxcount = 2;
- } else {
- outxbuf[0] = /* Otherwise store result */
- (unsigned)(x & 0xff);
- }
- break;
- case 6: /* UTF-8 to UTF-8 */
- case 7:
- break;
- case 8: /* UCS-2 to byte */
- case 9:
- xuf = xl_ufc[tcsr];
- outxbuf[0] = (*xuf)(uc.x_short);
- break;
- case 10:
- case 11: { /* UCS-2 to UTF-8 */
- int j;
- CHAR * buf = NULL;
- x = ucs2_to_utf8(uc.x_short,&buf);
- if (x < 0) {
- outxbuf[0] = 0xff; /* (= U+FFFD) */
- outxbuf[1] = 0xbd;
- x = 2;
- }
- for (j = 0; j < x; j++)
- outxbuf[j] = buf[j];
- outxcount = x;
- break;
- }
- #endif /* UNICODE */
- }
- #endif /* NOCSETS */
- outxbuf[outxcount] = NUL;
- debug(F111,"XMIT outxbuf",outxbuf,outxcount);
- /*
- Now the input character (1 or more bytes) is translated into the output
- expansion buffer (1 or more bytes); outxcount = number of bytes to add to
- the TRANSMIT line buffer, which we do here, taking care of parity, SI/SO
- processing, and quoting Telnet IACs.
- */
- for (k = 0; k < outxcount; k++) {
- c = outxbuf[k];
- if (xmits && parity && (c & 0200)) { /* If shifting */
- line[i++] = dopar(SO); /* needs to be done, */
- line[i++] = dopar((char)c); /* do it here, */
- line[i++] = dopar(SI); /* crudely. */
- } else {
- line[i++] = dopar((char)c);
- #ifdef TNCODE
- if (c == IAC && is_tn)
- line[i++] = IAC;
- #endif /* TNCODE */
- }
- }
- }
- /*
- Send characters if buffer full, or at end of line, or at end of file.
- (End of line only if echoing, waiting for a prompt, or pausing.)
- */
- debug(F000,"XMIT c",ckitoa(i),c);
- if (i >= xbufsiz || eof || (eol && (xmitx || xmitw || t))) {
- p = line;
- line[i] = ' ';
- debug(F111,"transmit buf",p,i);
- if (ttol((CHAR *)p,i) < 0) { /* try to send it. */
- printf("Can't TRANSMIT buffern");
- rc = 0;
- break;
- }
- i = 0; /* Reset buffer pointer. */
- /*
- Now we handle the echo. If the user wants to see it, or if we have to
- wait for the turnaround character, t. If the echo is being displayed,
- and terminal character-set translation is required, we do it here.
- */
- if (duplex && xmitx) { /* If local echo, echo it */
- if (parity || cmdmsk == 0x7f) { /* Strip hi bits */
- char *ss = line; /* if necessary */
- while (*ss) {
- *ss &= 0x7f;
- ss++;
- }
- }
- #ifdef OS2
- { /* Echo to emulator */
- char *ss = p;
- while (*ss) {
- scriptwrtbuf((USHORT)*ss);
- ss++;
- }
- }
- #endif /* OS2 */
- if (conoll(p) < 0)
- goto xmitfail;
- }
- if (xmitw) /* Sleep TRANSMIT PAUSE interval */
- msleep(xmitw);
- control = 0; /* Readback loop control */
- if (t != 0 && eol) /* TRANSMIT PROMPT given and at EOL */
- control |= 1;
- if (xmitx && !duplex) /* Echo desired and is remote */
- control |= 2;
- if (control) { /* Do this if reading back the echo */
- int n;
- x = 0;
- while (1) {
- if (control & 1) { /* Termination criterion */
- if (x == t) /* for turnaround */
- break;
- } else if (control & 2) { /* And for echoing */
- if ((n = ttchk()) < 1)
- break;
- }
- if ((x = ttinc(xmitt)) < 0) { /* Read with timeout */
- switch (x) {
- case -2:
- printf("Connection closed.n");
- ttclos(1);
- goto xmitfail;
- case -3:
- printf(
- "Session Limit exceeded - closing connection.n"
- );
- ttclos(1); /* full thru... */
- goto xmitfail;
- default:
- printf("?Timeoutn");
- goto xmitfail;
- }
- }
- if (x > -1 && (control & 2)) { /* Echo any echoes */
- if (parity)
- x &= 0x7f;
- c = x;
- #ifdef OS2
- scriptwrtbuf((USHORT)x);
- #endif /* OS2 */
- inxbuf[0] = c;
- inxcount = 1;
- #ifndef NOCSETS
- switch (unicode & 3) { /* Remote bits */
- case 0:
- if (xlate) {
- if (sxi) c = (*sxi)((CHAR)c);
- if (rxi) c = (*rxi)((CHAR)c);
- inxbuf[0] = c;
- }
- break;
- #ifdef UNICODE
- case 1: /* Remote Byte to local UTF-8 */
- xfu = xl_fcu[tcsr];
- tcssize = fcsinfo[tcsr].size;
- inxcount =
- b_to_u((CHAR)c,
- inxbuf,
- OUTXBUFSIZ,
- tcssize
- );
- break;
- case 2: /* Remote UTF-8 to local Byte */
- xuf = xl_ufc[tcsl];
- x = u_to_b((CHAR)c);
- if (x < 0)
- continue;
- inxbuf[0] = (unsigned)(x & 0xff);
- break;
- case 3: /* UTF-8 to UTF-8 */
- break;
- #endif /* UNICODE */
- }
- #endif /* NOCSETS */
- inxbuf[inxcount] = NUL;
- if (conxo(inxcount,(char *)inxbuf) < 0)
- goto xmitfail;
- }
- }
- } else /* Not echoing */
- ttflui(); /* Just flush input buffer */
- } /* End of buffer-dumping block */
- } /* End of text mode */
- if (eof) {
- rc = 1;
- goto xmitexit;
- }
- } /* End of character-reading loop */
- xmitfail: /* Failure exit point */
- rc = 0;
- xmitexit: /* General exit point */
- if (rc > 0) {
- if (*xmitbuf) { /* Anything to send at EOF? */
- p = xmitbuf; /* Yes, point to string. */
- while (*p) /* Send it. */
- ttoc(dopar(*p++)); /* Don't worry about echo here. */
- }
- }
- #ifndef AMIGA
- #ifndef MAC
- signal(SIGINT,oldsig); /* Put old signal action back. */
- #endif /* MAC */
- #endif /* AMIGA */
- #ifdef VMS
- concb(escape); /* Put terminal back, */
- #endif /* VMS */
- zclose(ZIFILE); /* Close file, */
- #ifndef NOCSETS
- language = langsv; /* restore language, */
- #endif /* NOCSETS */
- ttres(); /* and terminal modes, */
- return(rc); /* and return successfully. */
- }
- #endif /* NOLOCAL */
- #endif /* NOXMIT */
- #ifndef NOCSETS
- _PROTOTYP( CHAR (*sxx), (CHAR) ); /* Local translation function */
- _PROTOTYP( CHAR (*rxx), (CHAR) ); /* Local translation function */
- _PROTOTYP( CHAR zl1as, (CHAR) ); /* Latin-1 to ascii */
- _PROTOTYP( CHAR xl1as, (CHAR) ); /* ditto */
- /* X L A T E -- Translate a local file from one character set to another */
- /*
- Translates input file (fin) from character set csin to character set csout
- and puts the result in the output file (fout). The two character sets are
- file character sets from fcstab.
- */
- int
- xlate(fin, fout, csin, csout) char *fin, *fout; int csin, csout; {
- #ifndef MAC
- #ifdef OS2
- #ifdef NT
- SIGTYP (* oldsig)(int); /* For saving old interrupt trap. */
- extern int wherex[], wherey[];
- extern int k95stdout;
- extern unsigned char colorcmd;
- #else /* NT */
- SIGTYP (* volatile oldsig)(int); /* For saving old interrupt trap. */
- #endif /* NT */
- #else /* OS2 */
- SIGTYP (* oldsig)();
- #endif /* OS2 */
- #endif /* MAC */
- #ifdef CK_ANSIC
- int (*fn)(char); /* Output function pointer */
- #else
- int (*fn)();
- #endif /* CK_ANSIC */
- extern int xlatype;
- int filecode; /* Code for output file */
- int scrnflg = 0;
- int z = 1; /* Return code. */
- int x, c, tcs; /* Workers */
- int bytewise = 0;
- ffc = 0L;
- if (zopeni(ZIFILE,fin) == 0) { /* Open the file to be translated */
- printf("?Can't open input file %sn",fin);
- return(0);
- }
- #ifdef MAC
- /*
- If user specified no output file, it goes to the screen. For the Mac,
- this must be done a special way (result goes to a new window); the Mac
- doesn't have a "controlling terminal" device name.
- */
- filecode = !strcmp(fout,CTTNAM) ? ZCTERM : ZOFILE;
- #else
- #ifdef VMS
- filecode = !strcmp(fout,CTTNAM) ? ZCTERM : ZMFILE;
- #else
- #ifdef OS2
- filecode = (!stricmp(fout,"con") || !stricmp(fout,"con:")) ?
- ZCTERM : ZMFILE;
- #else /* OS2 */
- filecode = ZOFILE;
- #endif /* OS2 */
- #endif /* VMS */
- #endif /* MAC */
- if (zopeno(filecode,fout,NULL,NULL) == 0) { /* And the output file */
- printf("?Can't open output file %sn",fout);
- return(0);
- }
- #ifndef AMIGA
- #ifndef MAC
- oldsig = signal(SIGINT, trtrap); /* Save current interrupt trap. */
- #endif /* MAC */
- #endif /* AMIGA */
- scrnflg = (filecode == ZCTERM); /* Set output function */
- if (scrnflg)
- fn = NULL;
- else if (filecode == ZMFILE)
- fn = putmfil;
- else
- fn = putfil;
- tr_int = 0; /* Have not been interrupted (yet). */
- z = 1; /* Return code presumed good. */
- if (!scrnflg && !quiet)
- printf("%s (%s) => %s (%s)nn", /* Say what we're doing. */
- fin, fcsinfo[csin].keyword,
- fout,fcsinfo[csout].keyword
- );
- #ifndef UNICODE
- /*
- Non-Unicode picks the "most appropriate" transfer character set as the
- intermediate set, which results in loss of any characters that the source
- and target sets have in common, but are lacking from the intermediate set.
- */
- #ifdef KANJI
- /* Special handling for Japanese... */
- if (fcsinfo[csin].alphabet == AL_JAPAN ||
- fcsinfo[csout].alphabet == AL_JAPAN) {
- USHORT eu;
- int c, x, y;
- xpnbyte(-1,0,0,NULL); /* Reset output machine */
- xlatype = XLA_JAPAN;
- while ((c = xgnbyte(FC_JEUC,csin)) > -1) { /* Get an EUC byte */
- if (tr_int) { /* Interrupted? */
- printf("^C...n"); /* Print message */
- z = 0;
- break;
- }
- /* Send EUC byte to output machine */
- if ((x = xpnbyte(c,TC_JEUC,csout,fn)) < 0) {
- z = -1;
- break;
- }
- }
- goto xxlate;
- }
- #endif /* KANJI */
- /* Regular bytewise conversion... */
- tcs = gettcs(csin,csout); /* Get intermediate set. */
- if (csin == csout) { /* Input and output sets the same? */
- sxx = rxx = NULL; /* If so, no translation. */
- } else { /* Otherwise, set up */
- if (tcs < 0 || tcs > MAXTCSETS ||
- csin < 0 || csin > MAXFCSETS ||
- csout < 0 || csout > MAXFCSETS) {
- debug(F100,"XLATE csets out of range","",0);
- sxx = rxx = NULL;
- } else {
- sxx = xls[tcs][csin]; /* translation function */
- rxx = xlr[tcs][csout]; /* pointers. */
- if (rxx == zl1as) rxx = xl1as;
- }
- }
- while ((c = zminchar()) != -1) { /* Loop for all characters in file */
- if (tr_int) { /* Interrupted? */
- printf("^C...n"); /* Print message */
- z = 0;
- break;
- }
- if (sxx) c = (*sxx)((CHAR)c); /* From fcs1 to tcs */
- if (rxx) c = (*rxx)((CHAR)c); /* from tcs to fcs2 */
- if (zchout(filecode,(char)c) < 0) { /* Output xlated character */
- z = -1;
- break;
- }
- }
- goto xxlate; /* Done. */
- #else /* UNICODE */
- /*
- Use Unicode as the intermediate character set. It's simple and gives
- little or no loss, but the overhead is a bit higher.
- */
- initxlate(csin,csout); /* Set up translation functions */
- #ifdef NT
- if (isunicode() && /* NT console is Unicode based */
- csout == FC_UCS2 && /* And we're translating to UCS-2 */
- filecode == ZCTERM && /* for the real screen... */
- !k95stdout
- ) {
- union {
- USHORT ucs2;
- UCHAR bytes[2];
- } output;
- while (1) { /* In this case we go two-by-two. */
- if ((c = xgnbyte(FC_UCS2,csin)) < 0)
- break;
- output.bytes[0] = c;
- if ((c = xgnbyte(FC_UCS2,csin)) < 0)
- break;
- output.bytes[1] = c;
- if (tr_int) { /* Interrupted? */
- printf("^C...n"); /* Print message */
- z = 0;
- break;
- }
- VscrnWrtUCS2StrAtt(VCMD,
- &output.ucs2,
- 1,
- wherey[VCMD],
- wherex[VCMD],
- &colorcmd
- );
- }
- } else
- #endif /* NT */
- /* General case: Get next byte translated from fcs to UCS-2 */
- while ((c = xgnbyte(FC_UCS2,csin)) > -1) {
- if (tr_int) { /* Interrupted? */
- printf("^C...n"); /* Print message */
- z = 0;
- break;
- }
- debug(F001,"XLATE c","",c);
- /* And then send UCS-2 byte to translate-and-output machine */
- if ((x = xpnbyte(c,TC_UCS2,csout,fn)) < 0) {
- z = -1;
- break;
- }
- }
- #endif /* UNICODE */
- #ifndef UNICODE
- xxlate: /* Common exit point */
- #endif /* UNICODE */
- #ifndef AMIGA
- #ifndef MAC
- signal(SIGINT,oldsig); /* Put old signal action back. */
- #endif /* MAC */
- #endif /* AMIGA */
- tr_int = 0;
- if (z < 0) {
- if (z == -1)
- printf("?File output error: %sn",ck_errstr());
- z = 0;
- }
- zclose(ZIFILE); /* Close files */
- zclose(filecode); /* ... */
- return(success = z); /* and return status. */
- }
- #endif /* NOCSETS */
- static char hompthbuf[CKMAXPATH+1];
- char *
- homepath() {
- int x;
- hompthbuf[0] = NUL;
- #ifdef UNIXOROSK
- x = ckstrncpy(hompthbuf,zhome(),CKMAXPATH+1);
- if (x <= 0) {
- hompthbuf[0] = '/';
- hompthbuf[1] = NUL;
- } else if (x < CKMAXPATH - 2 && hompthbuf[x-1] != '/') {
- hompthbuf[x] = '/';
- hompthbuf[x+1] = NUL;
- }
- return(hompthbuf);
- #else
- #ifdef STRATUS
- if (strlen(zhome()) < CKMAXPATH)
- sprintf(hompthbuf,"%s>",zhome());
- return(hompthbuf);
- #else
- return(zhome());
- #endif /* STRATUS */
- #endif /* UNIXOROSK */
- }
- /* D O L O G -- Do the log command */
- int
- dolog(x) int x; {
- int y, disp; char *s = NULL, * p = NULL;
- extern int isguest;
- #ifdef ZFNQFP
- struct zfnfp * fnp;
- #endif /* ZFNQFP */
- if (isguest) {
- printf("?Anonymous log creation not allowedn");
- return(-9);
- }
- switch (x) { /* Which log... */
- #ifdef DEBUG
- case LOGD:
- y = cmofi("Name of debugging log file","debug.log",&s,xxstring);
- break;
- #endif /* DEBUG */
- case LOGP:
- y = cmofi("Name of packet log file","packet.log",&s,xxstring);
- break;
- #ifndef NOLOCAL
- case LOGS:
- y = cmofi("Name of session log file","session.log",&s,xxstring);
- break;
- #endif /* NOLOCAL */
- #ifdef TLOG
- case LOGT:
- y = cmofi("Name of transaction log file","transact.log",&s,
- xxstring);
- break;
- #endif /* TLOG */
- #ifdef CKLOGDIAL
- case LOGM: {
- int m, n;
- char mypath[CKMAXPATH+1];
- m = ckstrncpy(mypath,homepath(),CKMAXPATH);
- n = strlen(CXLOGFILE);
- if (m + n < CKMAXPATH)
- strcat(mypath,CXLOGFILE);
- else
- ckstrncpy(mypath,CXLOGFILE,CKMAXPATH);
- y = cmofi("Name of connection log file",mypath,&s,xxstring);
- break;
- }
- #endif /* CKLOGDIAL */
- default:
- printf("n?Unknown log designator - %dn",x);
- return(-2);
- }
- if (y < 0) return(y);
- if (y == 2) {
- printf("?Sorry, %s is a directory namen",s);
- return(-9);
- }
- #ifdef ZFNQFP
- #ifdef OS2ORUNIX
- if (*s != '|') /* Allow for pipes */
- #else
- #ifdef OSK
- if (*s != '|')
- #endif /* OSK */
- #endif /* OS2ORUNIX */
- if (fnp = zfnqfp(s,TMPBUFSIZ - 1,tmpbuf)) {
- if (fnp->fpath)
- if ((int) strlen(fnp->fpath) > 0)
- s = fnp->fpath;
- } /* else if error keep original string */
- #endif /* ZFNQFP */
- ckstrncpy(line,s,LINBUFSIZ);
- s = line;
- #ifdef MAC
- y = 0;
- #else
- p = "new";
- #ifdef TLOG
- if ((x == LOGT && tlogfmt == 2) || x == LOGM)
- p = "append";
- #endif /* TLOG */
- if ((y = cmkey(disptb,2,"Disposition",p,xxstring)) < 0)
- return(y);
- #endif /* MAC */
- disp = y;
- if ((y = cmcfm()) < 0) return(y);
- switch (x) {
- #ifdef DEBUG
- case LOGD:
- return(deblog = debopn(s,disp));
- #endif /* DEBUG */
- #ifndef NOXFER
- case LOGP:
- return(pktlog = pktopn(s,disp));
- #endif /* NOXFER */
- #ifndef NOLOCAL
- case LOGS:
- return(seslog = sesopn(s,disp));
- #endif /* NOLOCAL */
- #ifdef TLOG
- case LOGT:
- return(tralog = traopn(s,disp));
- #endif /* TLOG */
- #ifdef CKLOGDIAL
- case LOGM:
- return(dialog = diaopn(s,disp,0));
- #endif /* CKLOGDIAL */
- default:
- return(-2);
- }
- }
- #ifndef NOXFER
- int
- pktopn(s,disp) char *s; int disp; {
- static struct filinfo xx;
- int y;
- if (!s)
- s = "";
- if (!*s)
- return(0);
- debug(F111,"pktopn",s,disp);
- zclose(ZPFILE);
- #ifdef OS2ORUNIX
- if (s[0] == '|') { /* Pipe */
- char * p = s + 1;
- debug(F110,"pktopn p",p,0);
- while (*p) {
- if (*p != ' ')
- break;
- else
- p++;
- }
- debug(F110,"pktopn pipe",p,0);
- pktlog = zxcmd(ZPFILE,p);
- debug(F101,"pktopn seslog","",seslog);
- } else { /* File */
- #endif /* OS2ORUNIX */
- if (disp) {
- xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0;
- xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = ' ';
- xx.lblopts = 0;
- pktlog = zopeno(ZPFILE,s,NULL,&xx);
- } else pktlog = zopeno(ZPFILE,s,NULL,NULL);
- if (!pktlog)
- printf("?%s - %sn",s,ck_errstr());
- #ifdef OS2ORUNIX
- }
- #endif /* OS2ORUNIX */
- if (pktlog > 0)
- ckstrncpy(pktfil,s,CKMAXPATH+1);
- else
- *pktfil = ' ';
- return(pktlog);
- }
- #endif /* NOXFER */
- int
- traopn(s,disp) char *s; int disp; {
- #ifdef TLOG
- static struct filinfo xx;
- int y;
- if (!s)
- s = "";
- if (!*s)
- return(0);
- debug(F111,"traopn",s,disp);
- debug(F101,"traopn tlogfmt","",tlogfmt);
- zclose(ZTFILE);
- #ifdef OS2ORUNIX
- if (tlogfmt == 2) { /* FTP format is special... */
- if (!disp) /* Append? */
- if (zchki(s) > -1) /* No - does file exist? */
- (VOID) zdelet(s); /* Yes - delete it. */
- xferlog = 1;
- ckstrncpy(trafil,s,CKMAXPATH);
- xferfile = s;
- return(1);
- }
- if (s[0] == '|') { /* Pipe */
- char * p = s + 1;
- debug(F110,"traopn p",p,0);
- while (*p) {
- if (*p != ' ')
- break;
- else
- p++;
- }
- debug(F110,"traopn pipe",p,0);
- tralog = zxcmd(ZTFILE,p);
- debug(F101,"traopn tralog","",tralog);
- }
- #endif /* OS2ORUNIX */
- if (s[0] != '|') { /* File */
- if (disp) {
- xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0;
- xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = ' ';
- xx.lblopts = 0;
- tralog = zopeno(ZTFILE,s,NULL,&xx);
- } else tralog = zopeno(ZTFILE,s,NULL,NULL);
- }
- if (!tralog)
- printf("?%s - %sn",s,ck_errstr());
- if (tralog > 0 && tlogfmt > 0) {
- ckstrncpy(trafil,s,CKMAXPATH);
- tlog(F110,"Transaction Log:",versio,0L);
- #ifndef MAC
- tlog(F100,ckxsys,"",0L);
- #endif /* MAC */
- ztime(&s);
- tlog(F100,s,"",0L);
- } else
- *trafil = ' ';
- return(tralog);
- #else
- return(0);
- #endif /* TLOG */
- }
- #ifndef NOLOCAL
- int
- sesopn(s,disp) char * s; int disp; {
- static struct filinfo xx;
- int y;
- if (!s)
- s = "";
- if (!*s)
- return(0);
- debug(F111,"sesopn",s,disp);
- zclose(ZSFILE);
- #ifdef OS2ORUNIX
- if (s[0] == '|') { /* Pipe */
- char * p = s + 1;
- debug(F110,"sesopn p",p,0);
- while (*p) {
- if (*p != ' ')
- break;
- else
- p++;
- }
- debug(F110,"sesopn pipe",p,0);
- seslog = zxcmd(ZSFILE,p);
- debug(F101,"sesopn seslog","",seslog);
- } else { /* File */
- #endif /* OS2ORUNIX */
- if (disp) {
- xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0;
- xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = ' ';
- xx.lblopts = 0;
- seslog = zopeno(ZSFILE,s,NULL,&xx);
- } else
- seslog = zopeno(ZSFILE,s,NULL,NULL);
- if (!seslog)
- printf("?%s - %sn",s,ck_errstr());
- #ifdef OS2ORUNIX
- }
- #endif /* OS2ORUNIX */
- if (seslog > 0)
- ckstrncpy(sesfil,s,CKMAXPATH+1);
- else
- *sesfil = ' ';
- return(seslog);
- }
- #endif /* NOLOCAL */
- #endif /* NOICP */
- int
- debopn(s,disp) char *s; int disp; {
- #ifdef DEBUG
- #ifdef CK_UTSNAME
- extern char unm_mch[], unm_nam[], unm_rel[], unm_ver[], unm_mod[];
- #endif /* CK_UTSNAME */
- #ifdef OS2
- extern char ckxsystem[];
- #endif /* OS2 */
- char *tp;
- static struct filinfo xx;
- if (!s)
- s = "";
- if (!*s)
- return(0);
- zclose(ZDFILE);
- #ifdef OS2ORUNIX
- if (s[0] == '|') { /* Pipe */
- char * p = s + 1;
- debug(F110,"debopn p",p,0);
- while (*p) {
- if (*p != ' ')
- break;
- else
- p++;
- }
- debug(F110,"debopn pipe",p,0);
- deblog = zxcmd(ZDFILE,p);
- debug(F101,"debopn deblog","",deblog);
- } else { /* File */
- #endif /* OS2ORUNIX */
- if (disp) {
- xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0;
- xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = ' ';
- xx.lblopts = 0;
- deblog = zopeno(ZDFILE,s,NULL,&xx);
- } else
- deblog = zopeno(ZDFILE,s,NULL,NULL);
- if (!deblog)
- printf("?%s - %sn",s,ck_errstr());
- #ifdef OS2ORUNIX
- }
- #endif /* OS2ORUNIX */
- if (deblog > 0) {
- ckstrncpy(debfil,s,CKMAXPATH+1);
- debug(F110,"Debug Log ",versio,0);
- #ifndef MAC
- #ifdef OS2
- debug(F110,ckxsys,ckxsystem,0);
- #else /* OS2 */
- debug(F100,ckxsys,"",0);
- #endif /* OS2 */
- #endif /* MAC */
- #ifdef CK_UTSNAME
- if (unm_mch[0]) {
- debug(F110,"uname machine",unm_mch,0);
- if (unm_mod[0])
- debug(F110,"uname model ",unm_mod,0);
- debug(F110,"uname sysname",unm_nam,0);
- debug(F110,"uname release",unm_rel,0);
- debug(F110,"uname version",unm_ver,0);
- }
- #ifdef KTARGET
- {
- char * s; /* Makefile target */
- s = KTARGET;
- if (!s) s = "";
- if (!*s) s = "(unknown)";
- debug(F110,"build target",s,0);
- }
- #endif /* KTARGET */
- deblog = 0;
- ztime(&tp);
- deblog = 1;
- debug(F100,tp,"",0);
- #endif /* UTSNAME */
- debug(F101,"byteorder","",byteorder);
- } else *debfil = ' ';
- return(deblog);
- #else
- return(0);
- #endif /* MAC */
- }
- static char ndatbuf[10];
- /* C K D A T E -- Returns current date/time in standard format */
- static char nowbuf[18];
- char *
- ckdate() {
- extern struct keytab cmonths[];
- int x;
- char * t; /* Substitute today's date */
- char dbuf[32];
- ztime(&t);
- /* 012345678901234567890123 */
- /* Sat Jul 4 12:16:43 1998 */
- ckstrncpy(dbuf,t,32);
- t = dbuf;
- debug(F110,"ckdate dbuf",dbuf,0);
- nowbuf[0] = t[20];
- nowbuf[1] = t[21];
- nowbuf[2] = t[22];
- nowbuf[3] = t[23];
- nowbuf[4] = NUL;
- debug(F110,"ckdate nowbuf",nowbuf,0);
- t[7] = NUL;
- if ((x = lookup(cmonths,t+4,12,NULL)) < 0) {
- debug(F110,"ckdate bad month",t,0);
- return("<BAD_MONTH>");
- }
- sprintf(nowbuf+4,"%02d",x);
- nowbuf[6] = (t[8] == SP) ? '0' : t[8];
- nowbuf[7] = t[9];
- nowbuf[8] = ' ';
- nowbuf[9] = NUL;
- debug(F110,"ckdate nowbuf",nowbuf,0);
- for (x = 11; x < 19; x++) nowbuf[x-2] = t[x];
- nowbuf[17] = NUL;
- debug(F110,"ckdate nowbuf",nowbuf,0);
- return((char *)nowbuf);
- }
- #ifndef NOICP
- #ifdef CKLOGDIAL
- /*
- fc = 0 for initial open, meaning open, then close immediately.
- fc > 0 for subsequent opens, meaning open for use, leave open.
- */
- int
- diaopn(s,disp,fc) char *s; int disp, fc; {
- extern char diafil[];
- static struct filinfo xx;
- int y;
- if (!s)
- s = "";
- if (!*s)
- return(0);
- debug(F110,"diaopn log",s,0);
- debug(F101,"diaopn fc",s,fc);
- debug(F101,"diaopn disp 1",s,disp);
- if (fc) disp = 1; /* Force append if open for use */
- debug(F101,"diaopn disp 2",s,disp);
- zclose(ZDIFIL); /* In case a log was already open */
- #ifdef OS2ORUNIX
- if (s[0] == '|') { /* Pipe */
- char * p = s + 1;
- debug(F110,"diaopn p",p,0);
- while (*p) {
- if (*p != ' ')
- break;
- else
- p++;
- }
- debug(F110,"diaopn pipe",p,0);
- dialog = zxcmd(ZDIFIL,p);
- debug(F101,"diaopn dialog","",dialog);
- } else { /* File */
- #endif /* OS2ORUNIX */
- if (disp) {
- xx.bs = 0; xx.cs = 0; xx.rl = 0; xx.org = 0; xx.cc = 0;
- xx.typ = 0; xx.dsp = XYFZ_A; xx.os_specific = ' ';
- xx.lblopts = 0;
- dialog = zopeno(ZDIFIL,s,NULL,&xx);
- } else dialog = zopeno(ZDIFIL,s,NULL,NULL);
- if (!dialog)
- printf("?%s - %sn",s,ck_errstr());
- #ifdef OS2ORUNIX
- }
- #endif /* OS2ORUNIX */
- if (dialog > 0)
- ckstrncpy(diafil,s,CKMAXPATH+1);
- else
- *diafil = ' ';
- if (fc == 0) /* Initial open */
- zclose(ZDIFIL); /* close it */
- return(dialog);
- }
- #endif /* CKLOGDIAL */
- #ifndef NOSHOW
- /* SHOW command routines */
- char *
- shoxm() {
- char * s;
- switch (binary) {
- case XYFT_T: s = "text"; break;
- #ifdef VMS
- case XYFT_B: s = "binary fixed"; break;
- case XYFT_I: s = "image"; break;
- case XYFT_L: s = "labeled"; break;
- case XYFT_U: s = "binary undef"; break;
- #else
- #ifdef MAC
- case XYFT_B: s = "binary"; break;
- case XYFT_M: s = "macbinary"; break;
- #else
- case XYFT_B: s = "binary"; break;
- #ifdef CK_LABELED
- case XYFT_L: s = "labeled"; break;
- #endif /* CK_LABELED */
- #endif /* MAC */
- #endif /* VMS */
- default: s = "unknown"; break;
- }
- return(s);
- }
- #ifndef NOXFER
- VOID /* SHOW TRANSFER */
- shoxfer() {
- extern int docrc, usepipes;
- printf("n");
- printf(" Transfer Bell: %sn",showoff(xfrbel));
- printf(" Transfer Interruption: %sn",showoff(xfrint));
- printf(" Transfer Cancellation: %sn",showoff(xfrcan));
- #ifndef NOCSETS
- printf(" Transfer Character-set: ");
- if (tcharset == TC_TRANSP)
- printf("Transparentn");
- else
- printf("%sn",tcsinfo[tcharset].keyword);
- #endif /* NOCSETS */
- printf(" Transfer CRC-calculation: %sn",showoff(docrc));
- printf(" Transfer Display: ");
- switch (fdispla) {
- case XYFD_N: printf("%sn","none"); break;
- case XYFD_R: printf("%sn","serial"); break;
- case XYFD_C: printf("%sn","fullscreen"); break;
- case XYFD_S: printf("%sn","crt"); break;
- case XYFD_B: printf("%sn","brief"); break;
- }
- printf(" Transfer Locking-shift: ");
- if (lscapu == 2) {
- printf("forced");
- } else {
- printf("%s", (lscapr ? "enabled" : "disabled"));
- if (lscapr) printf(",%s%s", (lscapu ? " " : " not "), "used");
- }
- printf("n Transfer Mode: %sn",
- xfermode == XMODE_A ?
- "automatic" :
- "manual"
- );
- printf(" Transfer Pipes: %sn", showoff(usepipes));
- printf(" Transfer Protocol: %sn",ptab[protocol].p_name);
- printf(" Transfer Slow-start: %sn",showoff(slostart));
- printf("n");
- }
- #endif /* NOXFER */
- VOID
- shoflow() {
- int i, x;
- extern int cxflow[], cxtype, ncxname, nfloname;
- extern char * cxname[];
- printf("nConnection type: %sn",cxname[cxtype]);
- printf("Current flow-control: %sn", floname[flow]);
- printf("nDefaults by connection type:n");
- debug(F111,"shoflow cxtype",cxname[cxtype],cxtype);
- debug(F101,"shoflow flow","",flow);
- for (i = 0; i < ncxname; i++) {
- #ifdef NOLOCAL
- if (i > 0) break;
- #endif /* NOLOCAL */
- #ifndef NETCONN
- if (i > 2) break;
- #endif /* NETCONN */
- #ifndef DECNET
- if (i == CXT_DECNET) continue;
- #endif /* DECNET */
- #ifndef DECNET
- #ifndef SUPERLAT
- if (i == CXT_LAT) continue;
- #endif /* SUPERLAT */
- #endif /* DECNET */
- #ifndef CK_NETBIOS
- if (i == CXT_NETBIOS) continue;
- #endif /* CK_NETBIOS */
- #ifndef NPIPE
- if (i == CXT_NPIPE) continue;
- #endif /* NPIPE */
- #ifndef SSH
- if (i == CXT_SSH) continue;
- #endif /* SSH */
- #ifndef NETCMD
- if (i == CXT_PIPE) continue;
- #endif /* NETCMD */
- #ifndef ANYX25
- if (i == CXT_X25) continue;
- #endif /* ANYX25 */
- x = cxflow[i];
- debug(F101,"shoflow x","",x);
- if (x < nfloname)
- printf(" %-14s: %sn",cxname[i],floname[x]);
- else
- printf(" %-14s: (%d)n",cxname[i],x);
- }
- printf("n");
- }
- #ifndef NOLOCAL
- #ifdef ANYX25
- int
- shox25(n) int n; {
- if (nettype == NET_SX25) {
- printf("SunLink X.25 V%d.%d",x25ver / 10,x25ver % 10);
- if (ttnproto == NP_X3) printf(", PAD X.3, X.28, X.29 protocol,");
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf(" Reverse charge call %s",
- revcall ? "selected" : "not selected");
- printf (", Closed user group ");
- if (closgr > -1)
- printf ("%d",closgr);
- else
- printf ("not selected");
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf(" Call user data %s.n", cudata ? udata : "not selected");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- } else if (nettype == NET_VX25) {
- if (ttnproto == NP_X3) printf(", PAD X.3, X.28, X.29 protocol,");
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf(" Reverse charge call %s",
- revcall ? "selected" : "not selected");
- printf (", Closed user group [unsupported]");
- if (closgr > -1)
- printf ("%d",closgr);
- else
- printf ("not selected");
- printf (",");
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf(" Call user data %s.n", cudata ? udata : "not selected");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- } else if (nettype == NET_IX25) {
- printf("AIX NPI X.25n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf("n Reverse charge call %s",
- revcall ? "selected" : "not selected");
- printf (", Closed user group [unsupported]");
- if (closgr > -1)
- printf ("%d",closgr);
- else
- printf ("not selected");
- printf (",");
- printf("n Call user data %s.n", cudata ? udata : "not selected");
- }
- return(n);
- }
- #ifndef IBMX25
- int
- shopad(n) int n; {
- int i;
- printf("nX.3 PAD Parameters:n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- for (i = 0; i < npadx3; i++) {
- printf(" [%d] %s %dn",padx3tab[i].kwval,padx3tab[i].kwd,
- padparms[padx3tab[i].kwval]);
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- }
- return(n);
- }
- #endif /* IBMX25 */
- #endif /* ANYX25 */
- VOID
- shoparc() {
- extern int reliable, stopbits, clsondisc;
- int i; char *s;
- long zz;
- printf("Communications Parameters:n");
- if (network
- #ifdef IKSD
- || inserver
- #endif /* IKSD */
- ) {
- printf(" Host: %s%s",ttname,reliable == SET_ON ? " (reliable)" : "");
- } else {
- printf(" %s: %s%s, speed: ",
- #ifdef OS2
- "Port",
- #else
- "Line",
- #endif /* OS2 */
- ttname,
- #ifdef CK_TTYFD
- (local &&
- #ifdef VMS
- vmsttyfd() < 0
- #else
- ttyfd == -1
- #endif /* VMS */
- ) ?
- " (closed)" :
- (reliable == SET_ON ? " (reliable)" : "")
- #else
- ""
- #endif /* CK_TTYFD */
- );
- if (
- #ifdef CK_TTYFD
- #ifdef VMS
- vmsttyfd() < 0
- #else
- ttyfd == -1
- #endif /* VMS */
- ||
- #endif /* CK_TTYFD */
- (zz = ttgspd()) < 0) {
- printf("unknown");
- } else {
- if (speed == 8880) printf("75/1200");
- else if (speed == 134) printf("134.5");
- else printf("%ld",zz);
- }
- }
- if (network
- #ifdef IKSD
- || inserver
- #endif /* IKSD */
- )
- printf("n Mode: ");
- else
- printf(", mode: ");
- if (local) printf("local"); else printf("remote");
- if (network == 0
- #ifdef IKSD
- && !inserver
- #endif/* IKSD */
- ) {
- #ifdef CK_TAPI
- if (tttapi && !tapipass )
- printf(", modem: %s","TAPI");
- else
- #endif /* CK_TAPI */
- printf(", modem: %s",gmdmtyp());
- } else {
- #ifdef NETCONN
- if (nettype == NET_TCPA) printf(", TCP/IP");
- if (nettype == NET_TCPB) printf(", TCP/IP");
- if (nettype == NET_DEC) {
- if (ttnproto == NP_LAT) printf(", DECnet LAT");
- else if ( ttnproto == NP_CTERM ) printf(", DECnet CTERM");
- else printf(", DECnet");
- }
- if (nettype == NET_SLAT) printf(", Meridian Technologies' SuperLAT");
- #ifdef NETFILE
- if (nettype == NET_FILE) printf(", local file");
- #endif /* NETFILE */
- #ifdef NETCMD
- if (nettype == NET_CMD) printf(", pipe");
- #endif /* NETCMD */
- #ifdef NETPTY
- if (nettype == NET_PTY) printf(", psuedoterminal");
- #endif /* NETPTY */
- #ifdef NETDLL
- if (nettype == NET_DLL) printf(", dynamic load library");
- #endif /* NETDLL */
- #ifdef SSH
- if (nettype == NET_SSH) printf(", Secure Shell");
- #endif /* SSH */
- if (nettype == NET_PIPE) printf(", Named Pipes");
- #ifdef ANYX25
- if (shox25(0) < 0) return;
- #endif /* ANYX25 */
- if (ttnproto == NP_TELNET) {
- printf(", telnet protocol");
- if (0
- #ifdef CK_ENCRYPTION
- || ck_tn_encrypting() && ck_tn_decrypting()
- #endif /* CK_ENCRYPTION */
- #ifdef CK_SSL
- || tls_active_flag || ssl_active_flag
- #endif /* CK_SSL */
- )
- printf(" (SECURE)");
- }
- #ifdef RLOGCODE
- else if (ttnproto == NP_RLOGIN || ttnproto == NP_K4LOGIN ||
- ttnproto == NP_K5LOGIN)
- printf(", rlogin protocol");
- else if (ttnproto == NP_EK4LOGIN || ttnproto == NP_EK5LOGIN)
- printf(", rlogin protocol (SECURE)");
- #endif /* RLOGCODE */
- #endif /* NETCONN */
- }
- printf("n");
- if (hwparity && local && !network)
- s = parnam((char)hwparity);
- else
- s = parnam((char)parity);
- printf(" Parity: %s%s",hwparity ? "hardware " : "", s);
- #ifndef NOLOCAL
- if (local && !network) {
- int sb;
- char c;
- c = s[0];
- if (islower(c)) c = toupper(c);
- sb = stopbits;
- if (sb < 1) {
- sb = (speed <= 110L) ? 2 : 1;
- printf(", stop-bits: (default)");
- } else {
- printf(", stop-bits: %d",sb);
- }
- if (hwparity)
- printf(" (8%c%d)",c,sb);
- else if (parity)
- printf(" (7%c%d)",c,sb);
- else
- printf(" (8N%d)",sb);
- printf("n D");
- } else
- printf(", d");
- #endif /* NOLOCAL */
- printf("uplex: %s, ", duplex ? "half" : "full");
- debug(F101,"shoparp flow","",flow);
- printf("flow: %s", floname[flow]);
- printf(", handshake: ");
- if (turn) printf("%dn",turnch); else printf("nonen");
- #ifdef COMMENT
- if (local && !network) { /* SET CARRIER-WATCH */
- #endif /* COMMENT */
- if (carrier == CAR_OFF) s = "off";
- else if (carrier == CAR_ON) s = "on";
- else if (carrier == CAR_AUT) s = "auto";
- else s = "unknown";
- printf(" Carrier-watch: %s", s);
- if (carrier == CAR_ON) {
- if (cdtimo) printf(", timeout: %d sec", cdtimo);
- else printf(", timeout: none");
- }
- #ifdef COMMENT
- }
- #endif /* COMMENT */
- printf(", close-on-disconnect: %sn",showoff(clsondisc));
- #ifdef UNIX
- #ifndef NOUUCP
- if (local && !network && haslock && *flfnam) /* UUCP lockfile, UNIX only */
- printf(" Lockfile: %s",flfnam);
- #ifndef USETTYLOCK
- if (local && !network && haslock && lock2[0])
- printf("n Secondary lockfile: %s",lock2);
- #endif /* USETTYLOCK */
- #else
- #ifdef QNX
- {
- extern int qnxportlock, qnxopencount();
- if (local)
- printf(" Qnx-port-lock: %s, Open count: %dn",
- showoff(qnxportlock),
- qnxopencount()
- );
- else
- printf(" Qnx-port-lock: %sn", showoff(qnxportlock));
- }
- #endif /* QNX */
- #endif /* NOUUCP */
- #endif /* UNIX */
- printf("n");
- if (local) {
- int i;
- i = parity ? 7 : 8;
- if (i == 8) i = (cmask == 0177) ? 7 : 8;
- printf(" Terminal bytesize: %d,",i);
- printf(" escape character: %d (^%c)n",escape,ctl(escape));
- }
- }
- #ifdef TNCODE
- #ifdef CK_AUTHENTICATION
- _PROTOTYP(int ck_tn_authenticated, (VOID));
- extern int forward_flag, forwarded_tickets;
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_ENCRYPTION
- _PROTOTYP(int ck_tn_encrypting, (VOID));
- _PROTOTYP(int ck_tn_decrypting, (VOID));
- #endif /* CK_ENCRYPTION */
- int
- shotopt(n) int n; {
- int opt;
- printf("%20s %12s %12s %12s %12snn",
- "Telnet Option","Me (client)","U (client)",
- "Me (server)","U (server)");
- n += 2;
- if (n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- for ( opt = TELOPT_FIRST; opt <= TELOPT_LAST; opt++) {
- switch (opt) {
- case TELOPT_AUTHENTICATION:
- case TELOPT_ENCRYPTION:
- case TELOPT_TTYPE:
- case TELOPT_NAWS:
- case TELOPT_BINARY:
- case TELOPT_NEWENVIRON:
- case TELOPT_SNDLOC:
- case TELOPT_XDISPLOC:
- case TELOPT_SGA:
- case TELOPT_ECHO:
- case TELOPT_KERMIT:
- case TELOPT_START_TLS:
- case TELOPT_FORWARD_X:
- break;
- default:
- continue;
- }
- #ifdef COMMENT
- /* Some compilers choke on this: "too many instructions generated" */
- printf("%20s %12s %12s %12s %12sn",
- TELOPT(opt),
- TELOPT_MODE(TELOPT_DEF_C_ME_MODE(opt)),
- TELOPT_MODE(TELOPT_DEF_C_U_MODE(opt)),
- TELOPT_MODE(TELOPT_DEF_S_ME_MODE(opt)),
- TELOPT_MODE(TELOPT_DEF_S_U_MODE(opt))
- );
- #else
- printf("%20s ",
- TELOPT(opt)
- );
- printf("%12s %12s ",
- TELOPT_MODE(TELOPT_DEF_C_ME_MODE(opt)),
- TELOPT_MODE(TELOPT_DEF_C_U_MODE(opt))
- );
- printf("%12s %12sn",
- TELOPT_MODE(TELOPT_DEF_S_ME_MODE(opt)),
- TELOPT_MODE(TELOPT_DEF_S_U_MODE(opt))
- );
- #endif /* COMMENT */
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- if (sstelnet)
- printf("%20s %12s %12s %12s %12sn",
- "",
- "",
- "",
- (TELOPT_ME(opt)?"WILL":"WONT"),
- (TELOPT_U(opt)?"WILL":"WONT")
- );
- else
- printf("%20s %12s %12s %12s %12sn",
- "",
- (TELOPT_ME(opt)?"WILL":"WONT"),
- (TELOPT_U(opt)?"WILL":"WONT"),
- "",
- ""
- );
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- }
- return(n);
- }
- int
- shotel(n) int n; {
- extern int tn_duplex;
- #ifdef CK_ENVIRONMENT
- extern int tn_env_flg;
- extern char tn_env_acct[];
- extern char tn_env_disp[];
- extern char tn_env_job[];
- extern char tn_env_prnt[];
- extern char tn_env_sys[];
- #endif /* CK_ENVIRONMENT */
- #ifdef CK_SNDLOC
- extern char * tn_loc;
- #endif /* CK_SNDLOC */
- printf("SET TELNET parameters:n echo: %sn NVT newline-mode: ",
- tn_duplex ? "local" : "remote");
- switch (tn_nlm) {
- case TNL_CRNUL: printf("%sn","off (cr-nul)"); break;
- case TNL_CRLF: printf("%sn","on (cr-lf)"); break;
- case TNL_CR: printf("%sn","raw (cr)"); break;
- case TNL_LF: printf("%sn","(lf)"); break;
- }
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- #ifdef CK_AUTHENTICATION
- {
- int type = ck_tn_authenticated();
- printf(" authentication: ");
- switch (sstelnet ?
- TELOPT_U_MODE(TELOPT_AUTHENTICATION) :
- TELOPT_ME_MODE(TELOPT_AUTHENTICATION)
- ) {
- case TN_NG_AC: printf( "accepted " ); break;
- case TN_NG_RF: printf( "refused " ); break;
- case TN_NG_RQ: printf( "requested"); break;
- case TN_NG_MU: printf( "required "); break;
- }
- #ifdef CK_SSL
- if ((ssl_active_flag || tls_active_flag) &&
- ck_tn_auth_valid() == AUTH_VALID &&
- (!TELOPT_U(TELOPT_AUTHENTICATION) ||
- type == AUTHTYPE_NULL ||
- type == AUTHTYPE_AUTO))
- printf(" in use: X.509 certificaten");
- else
- #endif /* CK_SSL */
- printf(" in use: %sn",AUTHTYPE_NAME(type));
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- if (forward_flag)
- printf(" credentials forwarding requested %sn",
- forwarded_tickets ? "and completed" :
- "but not completed");
- else
- printf(" credentials forwarding disabledn");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- }
- #endif /* CK_AUTHENTICATION */
- #ifdef CK_ENCRYPTION
- {
- int i,x;
- int e_type = ck_tn_encrypting();
- int d_type = ck_tn_decrypting();
- char * e_str = NULL, * d_str = NULL;
- static struct keytab * tnetbl = NULL;
- static int ntnetbl = 0;
- x = ck_get_crypt_table(&tnetbl,&ntnetbl);
- for (i = 0; i < ntnetbl; i++) {
- if (e_type == tnetbl[i].kwval)
- e_str = tnetbl[i].kwd;
- if (d_type == tnetbl[i].kwval)
- d_str = tnetbl[i].kwd;
- }
- printf(" encryption: ");
- switch (TELOPT_ME_MODE(TELOPT_ENCRYPTION)) {
- /* This should be changed to report both ME and U modes */
- case TN_NG_AC: printf( "accepted " ); break;
- case TN_NG_RF: printf( "refused " ); break;
- case TN_NG_RQ: printf( "requested"); break;
- case TN_NG_MU: printf( "required "); break;
- }
- printf(" in use: ");
- switch ((e_type ? 1 : 0) | (d_type ? 2 : 0)) {
- case 0:
- printf("plain text in both directions");
- break;
- case 1:
- printf("%s output, plain text input",e_str);
- break;
- case 2:
- printf("plain text output, %s input",d_str);
- break;
- case 3:
- printf("%s output, %s input",e_str,d_str);
- break;
- }
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- }
- #endif /* CK_ENCRYPTION */
- #ifdef IKS_OPTION
- printf(" kermit: ");
- switch (TELOPT_U_MODE(TELOPT_KERMIT)) {
- case TN_NG_AC: printf( "u, accepted; " ); break;
- case TN_NG_RF: printf( "u, refused; " ); break;
- case TN_NG_RQ: printf( "u, requested; "); break;
- case TN_NG_MU: printf( "u, required; "); break;
- }
- switch (TELOPT_ME_MODE(TELOPT_KERMIT)) {
- case TN_NG_AC: printf( "me, accepted; " ); break;
- case TN_NG_RF: printf( "me, refused; " ); break;
- case TN_NG_RQ: printf( "me, requested; "); break;
- case TN_NG_MU: printf( "me, required; "); break;
- }
- if (TELOPT_U(TELOPT_KERMIT))
- printf(" u, %s",
- TELOPT_SB(TELOPT_KERMIT).kermit.u_start ?
- "started" :
- "stopped"
- );
- else
- printf(" u, n/a");
- if (TELOPT_ME(TELOPT_KERMIT))
- printf(" me, %s;",
- TELOPT_SB(TELOPT_KERMIT).kermit.me_start ?
- "started" :
- "stopped"
- );
- else
- printf(" me, n/a;");
- printf("n");
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- #endif /* IKS_OPTION */
- printf(" BINARY newline-mode: ");
- switch (tn_b_nlm) {
- case TNL_CRNUL: printf("%sn","off (cr-nul)"); break;
- case TNL_CRLF: printf("%sn","on (cr-lf)"); break;
- case TNL_CR: printf("%sn","raw (cr)"); break;
- case TNL_LF: printf("%sn","(lf)"); break;
- }
- if (++n > cmd_rows - 3) if (!askmore()) return(-1); else n = 0;
- printf(" binary-mode: ");
- switch (TELOPT_U_MODE(TELOPT_BINARY)) {
- case TN_NG_AC: printf( "u, accepted; " ); break;