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

📄 ckcfns.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
char *fnsv = "C-Kermit functions, 8.0.223, 1 May 2003";char *nm[] =  { "Disabled", "Local only", "Remote only", "Enabled" };/*  C K C F N S  --  System-independent Kermit protocol support functions.  *//*  ...Part 1 (others moved to ckcfn2,3 to make this module smaller) *//*  Author: Frank da Cruz <fdc@columbia.edu>,  Columbia University Academic Information Systems, New York City.  Copyright (C) 1985, 2004,    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.*//* System-dependent primitives defined in:   ck?tio.c -- terminal (communications) i/o   cx?fio.c -- file i/o, directory structure*/#include "ckcsym.h"			/* Needed for Stratus VOS */#include "ckcasc.h"			/* ASCII symbols */#include "ckcdeb.h"			/* Debug formats, typedefs, etc. */#include "ckcker.h"			/* Symbol definitions for Kermit */#include "ckcxla.h"			/* Character set symbols */#include "ckcnet.h"                     /* VMS definition of TCPSOCKET */#ifdef OS2#ifdef OS2ONLY#include <os2.h>#endif /* OS2ONLY */#include "ckocon.h"#endif /* OS2 */int docrc  = 0;				/* Accumulate CRC for \v(crc16) */long crc16 = 0L;			/* File CRC = \v(crc16) */int gnferror = 0;			/* gnfile() failure reason */extern CHAR feol;extern int byteorder, xflg, what, fmask, cxseen, czseen, nscanfile, sysindex;extern int xcmdsrc, dispos, matchfifo;extern long ffc;extern int inserver;extern int nolinks;#ifdef VMSORUNIXextern int zgfs_dir;#ifdef CKSYMLINKextern int zgfs_link;#endif /* CKSYMLINK */#endif /* VMSORUNIX */#ifndef NOXFER#ifndef NOICP#ifndef NOSPLextern char * clcmds;extern int haveurl;#ifdef CK_APCextern int apcactive, adl_ask;#endif /* CK_APC */#endif /* NOSPL */#endif /* NOICP */extern int remfile;/* (move these prototypes to the appropriate .h files...) */#ifdef COMMENT/* Not used */#ifdef VMS_PROTOTYP( int getvnum, (char *) );#endif /* VMS */#endif /* COMMENT */_PROTOTYP( static int bgetpkt, (int) );#ifndef NOCSETS_PROTOTYP( int lookup, (struct keytab[], char *, int, int *) );#endif /* NOCSETS */#ifndef NOSPL_PROTOTYP( int zzstring, (char *, char **, int *) );#endif /* NOSPL */#ifdef OS2ORUNIX_PROTOTYP( long zfsize, (char *) );#endif /* OS2ORUNIX */#ifdef OS2#include <io.h>#ifdef OS2ONLY#include <os2.h>#endif /* OS2ONLY */#endif /* OS2 */#ifdef VMS#include <errno.h>#endif /* VMS *//* Externals from ckcmai.c */extern int srvcdmsg, srvidl, idletmo;extern char * cdmsgfile[];extern int spsiz, spmax, rpsiz, timint, srvtim, rtimo, npad, ebq, ebqflg, rpt, rptq, rptflg, capas, keep, fncact, pkttim, autopar, spsizr, xitsta;extern int pktnum, bctr, bctu, bctl, clfils, sbufnum, protocol, size, osize, spktl, nfils, ckwarn, timef, spsizf, sndtyp, rcvtyp, success;extern int parity, turn, network, whatru, fsecs, justone, slostart, ckdelay, displa, mypadn, moving, recursive, nettype;extern long filcnt, flci, flco, tlci, tlco, tfc, fsize, sendstart, rs_len;extern long filrej, oldcps, cps, peakcps, ccu, ccp, calibrate, filestatus;extern int fblksiz, frecl, frecfm, forg, fcctrl, fdispla, skipbup;extern int spackets, rpackets, timeouts, retrans, crunched, wmax, wcur;extern int hcflg, binary, fncnv, b_save, f_save, server;extern int nakstate, discard, rejection, local, xfermode, interrupted;extern int rq, rqf, sq, wslots, wslotn, wslotr, winlo, urpsiz, rln;extern int fnspath, fnrpath, eofmethod, diractive, whatru2, wearealike;extern int atcapr, atcapb, atcapu;extern int lpcapr, lpcapb, lpcapu;extern int swcapr, swcapb, swcapu;extern int lscapr, lscapb, lscapu;extern int rscapr, rscapb, rscapu;extern int rptena, rptmin;extern int sseqtbl[];extern int numerrs, nzxopts;extern long rptn;extern int maxtry;extern int stdouf;extern int sendmode;extern int carrier, ttprty;extern int g_fnrpath;#ifdef TCPSOCKETextern int ttnproto;#endif /* TCPSOCKET */#ifndef NOSPLextern int sndxin, sndxhi, sndxlo;#endif /* NOSPL */extern int g_binary, g_fncnv;#ifdef GFTIMERextern CKFLOAT fpfsecs;#endif /* GFTIMER */#ifdef OS2extern struct zattr iattr;#endif /* OS2 */#ifdef PIPESENDextern int usepipes;#endif /* PIPESEND */extern int pipesend;#ifdef STREAMINGextern int streamrq, streaming, streamed, streamok;#endif /* STREAMING */extern int reliable, clearrq, cleared, urclear;extern int  atenci, atenco, atdati, atdato, atleni, atleno, atblki, atblko,  attypi, attypo, atsidi, atsido, atsysi, atsyso, atdisi, atdiso;extern int bigsbsiz, bigrbsiz;extern char *versio;extern char *filefile;extern char whoareu[], * cksysid;#ifndef NOSERVERextern int ngetpath;extern char * getpath[];extern int fromgetpath;#endif /* NOSERVER */#ifdef CK_LOGINextern int isguest;#endif /* CK_LOGIN */extern int srvcmdlen;extern CHAR *srvcmd, * epktmsg;extern CHAR padch, mypadc, eol, seol, ctlq, myctlq, sstate, myrptq;extern CHAR *data, padbuf[], stchr, mystch;extern CHAR *srvptr;extern CHAR *rdatap;extern char *cmarg, *cmarg2, **cmlist, filnam[], ofilnam[];extern char *rfspec, *prfspec, *rrfspec, *prrfspec, *sfspec, *psfspec, *rfspec;extern char fspec[];extern int fspeclen;#ifndef NOMSENDextern struct filelist * filehead, * filenext;extern int addlist;#endif /* NOMSEND */_PROTOTYP( int lslook, (unsigned int b) ); /* Locking Shift Lookahead */_PROTOTYP( int szeof, (CHAR *s) );_PROTOTYP( VOID fnlist, (void) );#endif /* NOXFER *//* Character set Translation */#ifndef NOCSETSextern int tcharset, fcharset, dcset7, dcset8;extern int fcs_save, tcs_save;extern int ntcsets, xlatype, cseqtab[];extern struct csinfo tcsinfo[], fcsinfo[];extern int r_cset, s_cset, afcset[];#ifdef UNICODEextern int ucsorder, fileorder;#endif /* UNICODE */_PROTOTYP( CHAR ident, (CHAR) );	/* Identity translation function *//* Arrays of and pointers to character translation functions */#ifdef CK_ANSICextern CHAR (*rx)(CHAR); /* Pointer to input character translation function */extern CHAR (*sx)(CHAR); /* Pointer to output character translation function */extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* Byte-to-Byte Send */extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])(CHAR); /* Byte-to-Byte Recv */#ifdef UNICODEextern int (*xut)(USHORT);	/* Translation function UCS to TCS */extern int (*xuf)(USHORT);	/* Translation function UCS to FCS */extern USHORT (*xtu)(CHAR);	/* Translation function TCS to UCS */extern USHORT (*xfu)(CHAR);	/* Translation function FCS to UCS */#endif /* UNICODE */#else /* The same declarations again for non-ANSI comilers... */extern CHAR (*rx)();extern CHAR (*sx)();extern CHAR (*xls[MAXTCSETS+1][MAXFCSETS+1])();extern CHAR (*xlr[MAXTCSETS+1][MAXFCSETS+1])();#ifdef UNICODEextern int (*xut)();extern int (*xuf)();extern USHORT (*xtu)();extern USHORT (*xfu)();#endif /* UNICODE */#endif /* CK_ANSIC */#endif /* NOCSETS *//* (PWP) external def. of things used in buffered file input and output */#ifdef DYNAMICextern char *zinbuffer, *zoutbuffer;#elseextern char zinbuffer[], zoutbuffer[];#endif /* DYNAMIC */extern char *zinptr, *zoutptr;extern int zincnt, zoutcnt, zobufsize, xfrxla;extern long crcta[], crctb[];		/* CRC-16 generation tables */extern int rseqtbl[];			/* Rec'd-packet sequence # table */#ifndef NOXFER/* Criteria used by gnfile()... */char sndafter[19]   = { NUL, NUL };char sndbefore[19]  = { NUL, NUL };char sndnafter[19]  = { NUL, NUL };char sndnbefore[19] = { NUL, NUL };char *sndexcept[NSNDEXCEPT]  = { NULL, NULL };char *rcvexcept[NSNDEXCEPT]  = { NULL, NULL };long sndsmaller = -1L;long sndlarger  = -1L;/* Variables defined in this module but shared by other modules. */int xfrbel = 1;char * ofperms = "";			/* Output file permissions */int autopath = 0;			/* SET RECEIVE PATHNAMES AUTO flag */#ifdef CALIBRATE#define CAL_O 3#define CAL_M 253int cal_j = 0;CHARcal_a[] = { 16, 45, 98,  3, 52, 41, 14,  7, 76,165,122, 11,104, 77,166, 15,160, 93, 18, 19,112, 85, 54, 23,232,213, 90, 27, 12, 81,126, 31,  4,205, 34, 35,144, 73,110, 39, 28,133,218, 43,156, 65,102, 47, 84, 61, 50, 51,208,117, 86, 55,  8,245, 74, 59, 44,125,222, 63, 80,  1,162, 67,116,105,206, 71,120,  9,250, 75, 88, 97,  6, 79,100,221, 82, 83, 36, 89, 94, 87, 40, 21,106, 91,236,145,150, 95,228, 33,130, 99,148,137,198,103,108,169, 42,107,184,129, 78,111,  0, 49,114,115, 32,121,254,119,172, 57,138,123,152,177, 22,127,240,193,  2,131,176,  5, 38,135,204,229, 10,139,200,161,174,143,128, 17,146,147, 68,153, 30,151, 72,217,170,155, 24,209, 62,159, 64,225,194,163,244,201, 70,167,216,197,234,171,188,109,230,175,212,113,178,179,132,185,190,183,136,249,202,187, 92,241,118,191, 48,237, 66,195, 96,233,142,199,248, 37, 58,203, 60, 13,134,207, 20, 29,210,211,164,149,182,215,220, 25, 26,219,124,157,246,223,180,141,226,227,192,101,238,231, 56, 69,154,235,252,173, 46,239,224,253,242,243,196, 53,214,247,168,181,186,251,140,189,158,255};#endif /* CALIBRATE */char * rf_err = "Error receiving file";	/* rcvfil() error message */#ifdef CK_SPEEDshort ctlp[256] = {		/* Control-Prefix table */  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* C0  */  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* G0  */  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, /* DEL */  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* C1  */  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* G1  */  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1  /* 255 */};#endif /* CK_SPEED */int sndsrc;		/* Flag for where to get names of files to send: */					/* -1: znext() function */					/*  0: stdin */					/* >0: list in cmlist or other list */					/* -9: calibrate */int  memstr;				/* Flag for input from memory string */int  funcstr;				/* Flag for input from function */int  bestlen = 0;int  maxsend = 0;int gnf_binary = 0;			/* Prevailing xfer mode for gnfile */#ifdef pdp11#define MYINITLEN 32#else#define MYINITLEN 100#endif /* pdp11 */CHAR myinit[MYINITLEN];			/* Copy of my Send-Init data *//* Variables local to this module */#ifdef TLOG#ifndef XYZ_INTERNALstatic#endif /* XYZ_INTERNAL */char *fncnam[] = {  "rename", "replace", "backup", "append", "discard", "ask",  "update", "dates-differ", ""};#endif /* TLOG */static char *memptr;			/* Pointer for memory strings */#ifdef VMSextern int batch;#elseextern int backgrd;#endif /* VMS */#ifdef CK_CTRLZstatic int lastchar = 0;#endif /* CK_CTRLZ */#ifdef CK_ANSICstatic int (*funcptr)(void);		/* Pointer for function strings */#elsestatic int (*funcptr)();#endif /* CK_ANSIC */#ifdef pdp11#define CMDSTRL 50static char cmdstr[50];			/* System command string. */#else#ifdef BIGBUFOK#define CMDSTRL 1024#else#define CMDSTRL 256#endif /* BIGBUFOK */static char cmdstr[CMDSTRL+1];#endif /* pdp11 */static int drain;			/* For draining stacked-up ACKs. */static int first;			/* Flag for first char from input */static CHAR t;				/* Current character */#ifdef COMMENTstatic CHAR next;			/* Next character */#endif /* COMMENT */static int ebqsent = 0;			/* 8th-bit prefix bid that I sent */static int lsstate = 0;			/* Locking shift state */static int lsquote = 0;			/* Locking shift quote */extern int quiet;/*  E N C S T R  --  Encode a string from memory. *//*  Call this instead of getpkt() if source is a string, rather than a file.  Note: Character set translation is never done in this case.*/#ifdef COMMENT#define ENCBUFL 200#ifndef pdp11CHAR encbuf[ENCBUFL];#else/* This is gross, but the pdp11 root segment is out of space *//* Will allocate it in ckuusr.c. */extern CHAR encbuf[];#endif /* pdp11 */#endif /* COMMENT *//*  Encode packet data from a string in memory rather than from a file.  Returns the length of the encoded string on success, -1 if the string  could not be completely encoded into the currently negotiated data  field length.*/int#ifdef CK_ANSICencstr(CHAR *s)#else /* CK_ANSIC */encstr(s) CHAR* s;#endif /* CK_ANSIC */{/*  Recoded 30 Jul 94 to use the regular data buffer and the negotiated  maximum packet size.  Previously we were limited to the length of encbuf[].  Also, to return a failure code if the entire encoded string would not fit.  Modified 14 Jul 98 to return length of encoded string.*/    int m, rc, slen; char *p;    if (!data) {			/* Watch out for null pointers. */

⌨️ 快捷键说明

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