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

📄 ckcmai.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#include "ckcasc.h"			/* ASCII character symbols */#include "ckcdeb.h"			/* Debug & other symbols */#include "ckcker.h"			/* Kermit symbols */#include "ckcnet.h"			/* Network symbols */#ifndef NOSPL#include "ckuusr.h"#endif /* NOSPL */#ifdef OS2ONLY#define INCL_VIO			/* Needed for ckocon.h */#include <os2.h>#endif /* OS2ONLY */#ifdef NT#include "ckntap.h"#endif /* NT */#ifndef NOSERVER/* Text message definitions.. each should be 256 chars long, or less. */#ifdef pdp11char *hlptxt = "PDP-11 C-Kermit Server - no help available.\n";#else#ifdef MACchar *hlptxt = "\r\Mac Kermit Server Commands:\r\\r\    BYE\r\    FINISH\r\    GET filespec\r\    REMOTE CD directory\r\    REMOTE HELP\r\    SEND filespec\r\\r\0";#else#ifdef AMIGAchar *hlptxt = "Amiga C-Kermit server responds to:\n\\n\GET filespec, SEND filespec, FINISH, BYE, REMOTE HELP\n\\n\0";#else#ifdef OS2char *hlptxt = "Kermit server responds to:\r\n\\r\n\GET files      REMOTE CD [dir]         REMOTE DIRECTORY [files]\r\n\REGET files    REMOTE COPY [f1] [f2]   REMOTE HOST command\r\n\RETRIEVE files REMOTE PRINT files      REMOTE TYPE files\r\n\SEND files     REMOTE RENAME [f1] [f2] REMOTE SET parameter value\r\n\FINISH         REMOTE SPACE [dir]      REMOTE QUERY type variable\r\n\BYE            REMOTE DELETE files     REMOTE ASSIGN variable value\r\n\               REMOTE LOGIN user pswd  REMOTE HELP\r\n\\r\n\0";#else#ifdef MINIXchar *hlptxt = "C-Kermit Server commands:\n\GET REGET SEND BYE FINISH REMOTE: CD DEL DIR HELP HOST SET SPACE TYPE WHO\n\0";#else#ifdef VMSchar *hlptxt = "VMS C-Kermit server responds to:\r\n\\r\n\GET files      REMOTE CD [dir]     REMOTE DIRECTORY [files]\r\n\REGET files    REMOTE SPACE [dir]  REMOTE HOST command\r\n\RETRIEVE files REMOTE DELETE files REMOTE WHO [user]\r\n\SEND files     REMOTE PRINT files  REMOTE SET parameter value\r\n\MAIL files     REMOTE HELP         REMOTE QUERY type variable\r\n\BYE            REMOTE LOGIN        REMOTE ASSIGN variable value\r\n\FINISH         REMOTE TYPE files\r\n\\0";#else#ifdef datageneralchar *hlptxt = "AOS/VS C-Kermit server responds to:\n\\n\GET files   REMOTE CD [dir]     REMOTE DIRECTORY [filespec]\n\REGET files REMOTE SPACE [dir]  REMOTE HOST command\n\SEND files  REMOTE TYPE file    REMOTE DELETE files\n\BYE         REMOTE WHO          REMOTE SET\n\FINISH      REMOTE LOGIN        REMOTE QUERY type variable\n\RETREIVE files                  REMOTE ASSIGN variable value\n\\0";#else#ifdef NOSPLchar *hlptxt = "C-Kermit Server REMOTE Commands:\n\\n\GET files      REMOTE CD [dir]     REMOTE DIRECTORY [files]\n\SEND files     REMOTE SPACE [dir]  REMOTE HOST command\n\MAIL files     REMOTE DELETE files REMOTE WHO [user]\n\RETRIEVE files REMOTE PRINT files  REMOTE TYPE files\n\FINISH         REMOTE HELP         REMOTE SET parameter value\n\BYE\n\\n\0";#elsechar *hlptxt = "C-Kermit Server REMOTE Commands:\n\\n\GET files      REMOTE CD [dir]     REMOTE HOST command\n\REGET files    REMOTE SPACE [dir]  REMOTE DIRECTORY [files]\n\RETRIEVE files REMOTE DELETE files REMOTE LOGIN user password\n\SEND files     REMOTE PRINT files  REMOTE SET parameter value\n\RESEND files   REMOTE TYPE files   REMOTE QUERY type variable\n\MAIL file user REMOTE WHO [user]   REMOTE ASSIGN variable value\n\FINISH, BYE    REMOTE HELP\n";#endif /* NOSPL */#endif /* datageneral */#endif /* VMS */#endif /* MINIX */#endif /* OS2 */#endif /* AMIGA */#endif /* MAC */#endif /* pdp11 */#ifdef MINIXchar *srvtxt = "\r\n\Entering server mode.\r\n\0";#else#ifdef OLDMSG/*  It seems there was a large installation that was using C-Kermit 5A(165)  or thereabouts, which had deployed thousands of MS-DOS Kermit scripts in  scattered locations that looked for strings in the old server message,  which changed in 5A(183), August 1992.*/char *srvtxt = "\r\n\C-Kermit server starting.  Return to your local machine by typing\r\n\its escape sequence for closing the connection, and issue further\r\n\commands from there.  To shut down the C-Kermit server, issue the\r\n\FINISH or BYE command and then reconnect.\n\\r\n\0";#else#ifdef OSKchar *srvtxt = "\r\012\Entering server mode.  If your local Kermit software is menu driven, use\r\012\the menus to send commands to the server.  Otherwise, enter the escape\r\012\sequence to return to your local Kermit prompt and issue commands from\r\012\there. Use SEND and GET for file transfer. Use REMOTE HELP for a list of\r\012\other available services.  Use BYE or FINISH to end server mode.\r\012\0";#else /* UNIX, VMS, AOS/VS, and all others */char *srvtxt = "\r\n\Entering server mode.  If your local Kermit software is menu driven, use\r\n\the menus to send commands to the server.  Otherwise, enter the escape\r\n\sequence to return to your local Kermit prompt and issue commands from\r\n\there.  Use SEND and GET for file transfer.  Use REMOTE HELP for a list of\r\n\other available services.  Use BYE or FINISH to end server mode.\r\n\0";#endif /* OSK */#endif /* OLDMSG */#endif /* MINIX */#else  /* server mode disabled */char *hlptxt = "";char *srvtxt = "";#endif /* NOSERVER *//* Declarations for Send-Init Parameters */struct ck_p ptab[NPROTOS] = {		/* Initialize the Kermit part ... */    "Kermit",    DRPSIZ,				/* Receive packet size */    DSPSIZ,				/* Send packet size */    0,					/* Send-packet-size-set flag */    DFWSIZ,				/* Window size */#ifdef NEWDEFAULTS    PX_CAU,				/* Control char unprefixing... */#else    PX_ALL,#endif /* NEWDEFAULTS */#ifdef VMS				/* Default filename collision action */    XYFX_X,				/* REPLACE for VAX/VMS */#else    XYFX_B,				/* BACKUP for everybody else */#endif /* VMS */#ifdef OS2				/* Flag for file name conversion */    XYFN_L,				/* Literal for OS2 */#else    XYFN_C,				/* Converted for others */#endif /* OS2 */    1,				/* Send pathnames OFF (1 = strip) */    1,				/* Receive pathnames OFF  (ditto) */    NULL,                       /* Host receive initiation string (binary) */    NULL,                       /* Host receive initiation string (text)   */    NULL,			/* External protocol send command (binary) */    NULL,			/* External protocol send command (text)   */    NULL,			/* External protocol receive command (bin) */    NULL			/* External protocol receive command (txt) */#ifdef CK_XYZ,    "XMODEM",  128,128,-1,-1,    -1,-1,-1,1,1,NULL,NULL,NULL,NULL,NULL,NULL,    "YMODEM",   -1, -1,-1,-1,    -1,-1,-1,1,1,NULL,NULL,NULL,NULL,NULL,NULL,    "YMODEM-g", -1, -1,-1,-1,    -1,-1,-1,1,1,NULL,NULL,NULL,NULL,NULL,NULL,    "ZMODEM",   -1, -1,-1,-1,PX_WIL,-1,-1,1,1,NULL,NULL,NULL,NULL,NULL,NULL,    "Other",    -1, -1,-1,-1,    -1,-1,-1,1,1,NULL,NULL,NULL,NULL,NULL,NULL#endif /* CK_XYZ */};int spsiz = DSPSIZ,                     /* Current packet size to send */    spmax = DSPSIZ,			/* Biggest packet size we can send */    spsizr = DSPSIZ,			/* Send-packet size requested */    spsizf = 0,                         /* Flag to override size negotiation */    rpsiz = DRPSIZ,                     /* Biggest we want to receive */    urpsiz = DRPSIZ,			/* User-requested receive pkt size */    maxrps = MAXRP,			/* Maximum incoming long packet size */    maxsps = MAXSP,			/* Maximum outbound l.p. size */    maxtry = MAXTRY,			/* Maximum retries per packet */    wslots = 1,				/* Window size currently in use */    wslotr = DFWSIZ,			/* Window size from SET WINDOW */    wslotn = 1,				/* Window size negotiated in S-pkt */    timeouts = 0,			/* For statistics reporting */    spackets = 0,			/*  ... */    rpackets = 0,			/*  ... */    retrans = 0,			/*  ... */    crunched = 0,			/*  ... */    wmax = 0,				/*  ... */    wcur = 0,				/*  ... */#ifdef OS2    srvidl = 0,                         /* Server idle timeout */#endif /* OS2 */    srvdis = 1,				/* Server file xfer display */    srvtim = DSRVTIM,			/* Server command wait timeout *//*  timint is the timeout interval I use when waiting for a packet.  pkttim is the SET RECEIVE TIMEOUT value, sent to the other Kermit.  rtimo is the SET SEND TIMEOUT value.  rtimo is the initial value of  timint.  timint is changed by the value in the incoming negotiation  packet unless a SET SEND TIMEOUT command was given.*/    timint = DMYTIM,                    /* Timeout interval I use */    pkttim = URTIME,			/* Timeout I want you to use */    rtimo = DMYTIM,			/* Normal packet wait timeout */    timef = 0,                          /* Flag to override what you ask */#ifdef CK_TIMERS    rttflg = 1,				/* Use dynamic round-trip timers */#else    rttflg = 0,				/* Use fixed timer */#endif /* CK_TIMERS */    mintime = 1,			/* Minimum timeout */    maxtime = 0,			/* Maximum timeout */    npad = MYPADN,                      /* How much padding to send */    mypadn = MYPADN,                    /* How much padding to ask for */    bctr = DFBCT,			/* Block check type requested */    bctu = 1,                           /* Block check type used */    bctl = 1,				/* Block check length */    ebq =  MYEBQ,                       /* 8th bit prefix */    ebqflg = 0,                         /* 8th-bit quoting flag */    rqf = -1,				/* Flag used in 8bq negotiation */    rq = 0,				/* Received 8bq bid */    sq = 'Y',				/* Sent 8bq bid */    rpt = 0,                            /* Repeat count */    rptq = MYRPTQ,                      /* Repeat prefix */    rptflg = 0,                         /* Repeat processing flag */    rptena = 1,				/* Repeat processing enabled */    xfrcan = 1,				/* Transfer cancellation enabled */    xfrchr = 3,				/* Transfer cancel char = Ctrl-C */    xfrnum = 3;				/* Need three of them. */int epktflg = 0;			/* E-PACKET command active */int capas  = 9,				/* Position of Capabilities */    lpcapb = 2,				/* Long Packet capability */    lpcapr = 1,				/*  requested */    lpcapu = 0,				/*  used */    swcapb = 4,				/* Sliding Window capability */    swcapr = 1,				/*  requested (allowed) */    swcapu = 0,				/*  used */    atcapb = 8,				/* Attribute capability */    atcapr = 1,				/*  requested */    atcapu = 0,				/*  used */    rscapb = 16,			/* RESEND capability */    rscapr = 1,				/*  requested by default */    rscapu = 0,				/*  used */    lscapb = 32,			/* Locking Shift capability */    lscapr = 1,				/*  requested by default */    lscapu = 0;				/*  used *//* Flags for whether to use particular attributes */int atenci = 1,				/* Encoding in */    atenco = 1,				/* Encoding out */    atdati = 1,				/* Date in */    atdato = 1,				/* Date out */    atdisi = 1,				/* Disposition in/out */    atdiso = 1,    atleni = 1,				/* Length in/out (both kinds) */    atleno = 1,    atblki = 1,				/* Blocksize in/out */    atblko = 1,    attypi = 1,				/* File type in/out */    attypo = 1,    atsidi = 1,				/* System ID in/out */    atsido = 1,    atsysi = 1,			       /* System-dependent parameters in/out */    atsyso = 1;#ifdef STRATUSint atfrmi = 1,				/* Format in/out */    atfrmo = 1,    atcrei = 1,				/* Creator ID in/out */    atcreo = 1,    atacti = 1,				/* Account in/out */    atacto = 1;#endif /* STRATUS */CHAR padch = MYPADC,                    /* Padding character to send */    mypadc = MYPADC,                    /* Padding character to ask for */    seol = MYEOL,                       /* End-Of-Line character to send */    eol = MYEOL,                        /* End-Of-Line character to look for */    ctlq = CTLQ,                        /* Control prefix in incoming data */    myctlq = CTLQ,                      /* Outbound control character prefix */    myrptq = MYRPTQ;			/* Repeat prefix I want to use */int rptmin = 3;				/* Repeat-count minimum */char whoareu[16] = { NUL, NUL };	/* System ID of other Kermit */int sysindex = -1;			/* and index to its system ID struct */int myindex  = -1;char * cksysid =			/* My system ID */#ifdef UNIX    "U1"#else#ifdef VMS    "D7"#else#ifdef OSK    "UD"#else#ifdef AMIGA    "L3"#else#ifdef MAC    "A3"#else#ifdef OS2#ifdef NT    "UN"#else /* NT */    "UO"#endif /* NT */#else /* OS2 */#ifdef datageneral    "F3"#else#ifdef GEMDOS    "K2"#else#ifdef STRATUS    "MV"#else    ""#endif /* STRATUS */#endif /* GEMDOS */#endif /* datageneral */#endif /* OS2 */#endif /* MAC */#endif /* AMIGA */#endif /* OSK */#endif /* VMS */#endif /* UNIX */    ;char uidbuf[64] = { NUL, NUL };struct zattr iattr;			/* Incoming file attributes *//* File related variables, mainly for the benefit of (Open)VMS */#ifdef NLCHAR				/* Text-file line terminator */CHAR feol = NLCHAR;#elseCHAR feol = 0;#endifint fblksiz = DBLKSIZ;		/* File blocksize */int frecl = DLRECL;		/* File record length */int frecfm = XYFF_S;		/* File record format (default = stream) */int forg = XYFO_S;		/* File organization (sequential) */int fcctrl = XYFP_N;		/* File carriage control (ctrl chars) */#ifdef VMS/* VMS labeled file default options - name only. */int lf_opts = LBL_NAM;#else#ifdef OS2/* OS/2 labeled file default options, all attributes but archived. */unsigned long int lf_opts = LBL_EXT|LBL_HID|LBL_RO|LBL_SYS;#elseint lf_opts = 0;#endif /* OS2 */#endif /* VMS *//* Packet-related variables */int pktnum = 0,                         /* Current packet number */    sndtyp = 0,				/* Type of packet just sent */    rcvtyp = 0,				/* Type of packet just received */    rsn,				/* Received packet sequence number */    rln,				/* Received packet length */    size,                               /* Current size of output pkt data */    osize,                              /* Previous output packet data size */    maxsize,                            /* Max size for building data field */    spktl = 0,				/* Length packet being sent */    rpktl = 0,				/* Length of packet just received */    pktpaus = 0,			/* Interpacket pause interval, msec */    rprintf,				/* REMOTE PRINT flag */    rmailf;				/* MAIL flag */CHAR#ifdef pdp11    srvcmd[MAXRP+4],#else#ifdef DYNAMIC    *srvcmd = (CHAR *)0,		/* Where to decode server command */    *pktmsg = (CHAR *)0,		/* Packet error message */#else    srvcmd[MAXRP+4],    pktmsg[81],#endif /* DYNAMIC */#endif /* pdp11 */    padbuf[96],				/* Buffer for send-padding */    *recpkt,

⌨️ 快捷键说明

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