⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckuus4.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifndef NOICP/*  C K U U S 4 --  "User Interface" for Unix Kermit, part 4  *//*  Author: Frank da Cruz (fdc@columbia.edu, FDCCU@CUVMA.BITNET),  Columbia University Center for Computing Activities.  First released January 1985.  Copyright (C) 1985, 1992, Trustees of Columbia University in the City of New  York.  Permission is granted to any individual or institution to use this  software as long as it is not sold for profit.  This copyright notice must be  retained.  This software may not be included in commercial products without  written permission of Columbia University.*//*  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 */#ifndef NOCSETS				/* Character sets */#include "ckcxla.h"#endif /* NOCSETS */#ifndef AMIGA#ifndef MAC#include <signal.h>#include <setjmp.h>#endif /* MAC */#endif /* AMIGA */#ifdef SUNX25extern int revcall, closgr, cudata, npadx3;int x25ver;extern char udata[MAXCUDATA];extern CHAR padparms[MAXPADPARMS+1];extern struct keytab padx3tab[];#endif /* SUNX25 */#ifdef NETCONNextern char ipaddr[];#ifdef TNCODEextern int tn_duplex, tn_nlm;extern char *tn_term;#endif /* TNCODE */#endif /* NETCONN */#ifndef NOSPL/* This needs to be internationalized... */staticchar *months[] = {    "Jan", "Feb", "Mar", "Apr", "May", "Jun",    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};staticchar *wkdays[] = {    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};#endif /* NOSPL */#ifdef UNIXextern int ttyfd;#endif /* UNIX */#ifdef OS2extern int ttyfd;#endif /* OS2 */_PROTOTYP( static VOID shods, (char *) );extern struct keytab colxtab[];extern CHAR  eol, mypadc, mystch, padch, seol, stchr;extern char  kermrc[], ttname[],  *ckxsys, *versio, **xargv, *zinptr;extern int  atcapr, autopar, bctr, bctu, bgset, bigrbsiz, bigsbsiz, binary, carrier,  cdtimo, cmask, crunched, delay, duplex, ebq, ebqflg, escape, flow, fmask,  fncact, fncnv, incase, inecho, keep, local, lscapr, lscapu,  maxrps, maxsps, maxtry, mdmspd, mdmtyp, mypadn, ncolx,  nettype, network, nmac, noinit, npad, parity, pktlog, pkttim, rcflag,  retrans, rpackets, rptflg, rptq, rtimo, seslog, sessft, sosi, spackets,  spsiz, spsizf, spsizr, srvtim, stayflg, success, timeouts, tralog,  tsecs, ttnproto, turn, turnch, urpsiz, wmax, wslotn, wslotr, xargc, xargs,  zincnt, fdispla, tlevel, xitsta, spmax, insilence, cmdmsk, timint, timef;#ifdef VMS  extern int frecl;#endif /* VMS */extern long  ffc, filcnt, rptn, speed, tfc, tlci, tlco, vernum;#ifndef NOSPLextern char fspec[], myhost[];#endif /* NOSPL */extern char *tfnam[];			/* Command file names */#ifdef DCMDBUFextern struct cmdptr *cmdstk;extern char *line;#elseextern struct cmdptr cmdstk[];extern char line[];#endif /* DCMDBUF */extern char pktfil[],			/* Packet log file name */#ifdef DEBUG  debfil[],				/* Debug log file name */#endif /* DEBUG */#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, xmitp, xmitx, xmits, xmitw;#endif /* NOXMIT */#ifndef NOSPL/* Script programming language items */extern char **a_ptr[];			/* Arrays */extern int a_dim[];extern char inpbuf[], inchar[];		/* Buffers for INPUT and REINPUT */extern char *inpbp;			/* And pointer to same */static char *inpbps = inpbuf;		/* And another */extern int incount;			/* INPUT character count */extern int maclvl;			/* Macro invocation level */extern struct mtab *mactab;		/* Macro table */extern char *mrval[];extern int macargc[], cmdlvl;extern char *m_arg[MACLEVEL][10]; /* You have to put in the dimensions */extern char *g_var[GVARS];	  /* for external 2-dimensional arrays. */#ifdef DCMDBUFextern int *count;#elseextern int count[];#endif /* DCMDBUF */#endif /* NOSPL */#ifdef UNIXextern int haslock;			/* For UUCP locks */extern char flfnam[];extern int maxnam, maxpath;		/* Longest name, path length */#endif /* UNIX */#ifndef NODIAL/* DIAL-related variables */extern int nmdm, dialhng, dialtmo, dialksp, dialdpy, dialmnp, dialmhu;extern char *dialnum, *dialdir, *dialnpr;extern struct keytab mdmtab[];#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_ANSICextern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* Character set */extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* translation functions */#elseextern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])();	/* Character set */extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])();	/* translation functions. */#endif /* CK_ANSIC */#endif /* NOCSETS */#ifndef NOSPL/* Built-in variable names, maximum length VNAML (20 characters) */struct keytab vartab[] = {    "argc",      VN_ARGC,  0,    "args",      VN_ARGS,  0,    "cmdfile",   VN_CMDF,  0,    "cmdlevel",  VN_CMDL,  0,    "cmdsource", VN_CMDS,  0,    "count",     VN_COUN,  0,    "cpu",	 VN_CPU,   0,    "date",      VN_DATE,  0,    "day",       VN_DAY,   0,		/* Edit 181 */    "directory", VN_DIRE,  0,    "exitstatus",VN_EXIT,  0,    "filespec",  VN_FILE,  0,    "fsize",     VN_FFC,   0,    "home",      VN_HOME,  0,    "host",      VN_HOST,  0,    "input",     VN_IBUF,  0,    "inchar",    VN_ICHR,  0,    "incount",   VN_ICNT,  0,    "line",      VN_LINE,  0,    "local",     VN_LCL,   0,    "macro",     VN_MAC,   0,    "ndate",     VN_NDAT,  0,    "nday",      VN_NDAY,  0,    "ntime",     VN_NTIM,  0,    "platform",  VN_SYSV,  0,    "program",   VN_PROG,  0,    "return",    VN_RET,   0,    "speed",     VN_SPEE,  0,    "status",    VN_SUCC,  0,    "system",    VN_SYST,  0,    "tfsize",    VN_TFC,   0,    "time",      VN_TIME,  0,#ifdef UNIX    "ttyfd",     VN_TTYF,  0,#endif /* UNIX */#ifdef OS2    "ttyfd",     VN_TTYF,  0,#endif /* OS2 */    "version",   VN_VERS,  0};int nvars = (sizeof(vartab) / sizeof(struct keytab));#endif /* NOSPL */#ifndef NOSPLstruct keytab fnctab[] = {		/* Function names */    "character",  FN_CHR, 0,		/* Character from code */    "code",       FN_COD, 0,		/* Code from character */    "contents",   FN_CON, 0,		/* Definition (contents) of variable */    "definition", FN_DEF, 0,		/* Return definition of given macro */    "evaluate",   FN_EVA, 0,		/* Evaluate given arith expression */    "execute",    FN_EXE, 0,		/* Execute given macro */    "files",      FN_FC,  0,		/* File count */    "index",      FN_IND, 0,		/* Index (string search) */    "length",     FN_LEN, 0,		/* Return length of argument */    "literal",    FN_LIT, 0,		/* Return argument literally */    "lower",      FN_LOW, 0,		/* Return lowercased argument */    "lpad",       FN_LPA, 0,		/* Return left-padded argument */    "maximum",    FN_MAX, 0,		/* Return maximum of two arguments */    "minimim",    FN_MIN, 0,		/* Return minimum of two arguments */#ifdef COMMENT/* not needed because \feval() has it */    "modulus",    FN_MOD, 0,		/* Return modulus of two arguments */#endif /* COMMENT */    "nextfile",   FN_FIL, 0,		/* Next file in list */    "repeat",     FN_REP, 0,		/* Repeat argument given # of times */#ifndef NOFRILLS    "reverse",    FN_REV, 0,		/* Reverse the argument string */#endif /* NOFRILLS */    "right",      FN_RIG, 0,		/* Rightmost n characters */    "rpad",       FN_RPA, 0,		/* Right-pad the argument */    "substring",  FN_SUB, 0,		/* Extract substring from argument */    "upper",      FN_UPP, 0		/* Return uppercased argument */};int nfuncs = (sizeof(fnctab) / sizeof(struct keytab));#endif /* NOSPL */#ifndef NOSPL				/* Buffer for expansion of */#define VVBUFL 60			/* built-in variables. */char vvbuf[VVBUFL];#endif /* NOSPL */struct keytab disptb[] = {		/* Log file disposition */    "append",    1,  0,    "new",       0,  0};/*  P R E S C A N -- Quick look thru command-line args for init file name *//*  Also for -d (debug), -z (force foreground), -S (stay) */VOIDprescan() {    int yargc; char **yargv;    char x;    yargc = xargc;    yargv = xargv;    strcpy(kermrc,KERMRC);		/* Default init file name */#ifndef NOCMDL    while (--yargc > 0) {		/* Look for -y on command line */	yargv++;	if (**yargv == '-') {		/* Option starting with dash */	    x = *(*yargv+1);		/* Get option letter */	    if (x == 'Y') {		/* Is it Y (= no init file?) */		noinit = 1;		continue;	    } else if (x == 'y') {	/* Is it y? */		yargv++, yargc--;	/* Yes, count and check argument */		if (yargc < 1) fatal("missing name in -y");		strcpy(kermrc,*yargv);	/* Replace init file name */		rcflag = 1;		/* Flag that this has been done */		continue;	    } else if (x == 'd') {	/* Do this early as possible! */		debopn("debug.log",0);		continue;	    } else if (x == 'z') {	/* = SET BACKGROUND OFF */		bgset = 0;		continue;	    } else if (x == 'S') {		stayflg = 1;		continue;	    }	}    }#endif /* NOCMDL */}static int tr_int;			/* Flag if TRANSMIT interrupted */#ifndef MACSIGTYPtrtrap(foo) int foo; {			/* TRANSMIT interrupt trap */#ifdef __EMX__    signal(SIGINT, SIG_ACK);#endif    tr_int = 1;				/* (Need arg for ANSI C) */    SIGRETURN;}#endif /* MAC *//*  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.*/intgettcs(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 LATIN2	if (cs1 == FC_2LATIN || cs1 == FC_2LATIN ||	    cs1 == FC_CP852  || cs1 == FC_CP852 )	  tcs = TC_2LATIN;	else#endif /* LATIN2 */	  tcs = TC_1LATIN;    return(tcs);#endif /* NOCSETS */}#ifndef NOXMIT/*  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?***//*  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*/#define XMBUFS 120int#ifdef CK_ANSICtransmit(char * s, char t)#elsetransmit(s,t) char *s; char t;#endif /* CK_ANSIC *//* transmit */ {#ifdef MAC    extern char sstate;    int count = 100;#else    SIGTYP (* oldsig)();		/* For saving old interrupt trap. */#endif /* MAC */    long zz;    int z = 1;				/* Return code. 0=fail, 1=succeed. */    int x, c, i;			/* Workers... */    int myflow;    CHAR csave;    char *p;#ifndef NOCSETS    int tcs = TC_TRANSP;		/* Intermediate (xfer) char set */    int langsv = L_USASCII;		/* Save current language */    _PROTOTYP ( CHAR (*sxo), (CHAR) ) = NULL; /* Translation functions */    _PROTOTYP ( CHAR (*rxo), (CHAR) ) = NULL;    _PROTOTYP ( CHAR (*sxi), (CHAR) ) = NULL;    _PROTOTYP ( CHAR (*rxi), (CHAR) ) = NULL;#endif /* NOCSETS */    if (zopeni(ZIFILE,s) == 0) {	/* Open the file to be transmitted */	printf("?Can't open file %s\n",s);	return(0);    }    x = -1;				/* Open the communication line */    if (ttopen(ttname,&x,mdmtyp,cdtimo) < 0) {	/* (no harm if already open) */	printf("Can't open device %s\n",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 line\n");	    return(0);	}    } else {	if (ttpkt(zz,flow,parity) < 0) { /* Put the line in "packet mode" */	    printf("Can't condition line\n"); /* so Xon/Xoff will work, etc. */	    return(0);	}    }#ifndef NOCSETS    tcs = gettcs(tcsr,tcsl);		/* Get intermediate set. *//* Set up character set translations */    if (binary == 0) {	if (tcsr == tcsl || binary) {	/* Remote and local sets the same? */	    sxo = rxo = NULL;		/* Or file type is not text? */	    sxi = rxi = NULL;	} else {			/* Otherwise, set up */	    sxo = xls[tcs][tcsl];	/* translation function */	    rxo = xlr[tcs][tcsr];	/* pointers for output functions */	    sxi = xls[tcs][tcsr];	/* and for input functions. */	    rxi = xlr[tcs][tcsl];	}/*  This is to prevent use of zmstuff() and zdstuff() by translation functions.  They only work with disk i/o, not with communication i/o.  Luckily Russian  translation functions don't do any stuffing...*/	langsv = language;	language = L_USASCII;    }#endif /* NOCSETS */    i = 0;				/* Beginning of buffer. */#ifndef MAC#ifndef AMIGA

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -