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

📄 ckcftp.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
static int stouarg = 1;static int typesent = 0;static int havesigint = 0;static long havetype =  0;static long havesize = -1L;static char * havemdtm = NULL;static int mgetmethod = 0;		/* NLST or MLSD */static int mgetforced = 0;static int i, /* j, k, */ x, y, z;      /* Volatile temporaries */static int c0, c1;                      /* Temp variables for characters */static char putpath[CKMAXPATH+1] = { NUL, NUL };static char asnambuf[CKMAXPATH+1] = { NUL, NUL };#define RFNBUFSIZ 4096			/* Remote filename buffer size */static unsigned int maxbuf = 0, actualbuf = 0;static CHAR *ucbuf = NULL;static int ucbufsiz = 0;static unsigned int nout = 0;           /* Number of chars in ucbuf */static jmp_buf recvcancel;static jmp_buf sendcancel;static jmp_buf ptcancel;static jmp_buf jcancel;static int ptabflg = 0;/* Protection level symbols */#define FPL_CLR 1                       /* Clear */#define FPL_SAF 2                       /* Safe */#define FPL_PRV 3                       /* Private */#define FPL_CON 4                       /* Confidential *//* Symbols for file types returned by MLST/MLSD */#define FTYP_FILE 1			/* Regular file */#define FTYP_DIR  2			/* Directory */#define FTYP_CDIR 3			/* Current directory */#define FTYP_PDIR 4			/* Parent directory *//* File type symbols keyed to the file-type symbols from ckcker.h */#define FTT_ASC XYFT_T                  /* ASCII (text) */#define FTT_BIN XYFT_B                  /* Binary (image) */#define FTT_TEN XYFT_X                  /* TENEX (TOPS-20) *//* Server feature table - sfttab[0] > 0 means server supports FEAT and OPTS */static int sfttab[16] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };#define SFT_AUTH  1			/* FTP server feature codes */#define SFT_LANG  2#define SFT_MDTM  3#define SFT_MLST  4#define SFT_PBSZ  5#define SFT_PROT  6#define SFT_REST  7#define SFT_SIZE  8#define SFT_TVFS  9#define SFT_UTF8 10#define CNV_AUTO  2			/* FTP filename conversion */#define CNV_CNV   1#define CNV_LIT   0/* SET FTP values */static int                              /* SET FTP values... */  ftp_aut = 1,                          /* Auto-authentication */#ifdef FTP_SECURITY  ftp_cry = 1,                          /* Auto-encryption */  ftp_cfw = 0,                          /* Credential forwarding */#endif /* FTP_SECURITY */  ftp_cpl = FPL_CLR,                    /* Command protection level */  ftp_dpl = FPL_CLR,                    /* Data protection level */#ifdef FTP_PROXY  ftp_prx = 0,                          /* Use proxy */#endif /* FTP_PROXY */  sav_psv = -1,                         /* For saving passive mode */  ftp_psv = 1,                          /* Passive mode */  ftp_spc = 1,                          /* Send port commands */  ftp_typ = FTT_ASC,                    /* Type */  get_auto = 1,                         /* Automatic type switching for GET */  tenex = 0,                            /* Type is Tenex */  ftp_usn = 0,                          /* Unique server names */  ftp_prm = 0,                          /* Permissions */  ftp_cnv = CNV_AUTO,			/* Filename conversion (2 = auto) */  ftp_vbm = DEF_VBM,                    /* Verbose mode */  ftp_vbx = DEF_VBM,                    /* Sticky version of same */  ftp_err = 0,                          /* Error action */  ftp_fnc = -1;                         /* Filename collision action */#ifdef CK_SSLstatic int ftp_bug_use_ssl_v2 = 0;      /* use SSLv2 for AUTH SSL */#endif /* CK_SSL */static int#ifdef NOCSETS  ftp_csr = -1,                         /* Remote (server) character set */#else  ftp_csr = FC_UTF8,#endif /* NOCSETS */  ftp_xla = 0;                          /* Character-set translation on/off */int  ftp_csx = -1,                         /* Remote charset currently in use */  ftp_csl = -1;                         /* Local charset currently in use */static int g_ftp_typ = FTT_ASC;         /* For saving and restoring ftp_typ */char * ftp_nml = NULL;                  /* /NAMELIST */char * ftp_tmp = NULL;                  /* Temporary string */static char * ftp_acc = NULL;           /* Account string */static char * auth_type = NULL;         /* Authentication type */static char * srv_renam = NULL;         /* Server-rename string */FILE * fp_nml = NULL;                   /* Namelist file pointer */static int csocket = -1;                /* Control socket */static int connected = 0;               /* Connected to FTP server */static short ftp_port = 0;              /* FTP port */#ifdef FTPHOSTstatic int hostcmd = 0;                 /* Has HOST command been sent */#endif /* FTPHOST */static int form, mode, stru, bytesize, curtype = FTT_ASC;static char bytename[8];/* For parsing replies to FTP server command */static char *reply_parse, reply_buf[FTP_BUFSIZ], *reply_ptr;#ifdef FTP_PROXYstatic int proxy, unix_proxy#endif /* FTP_PROXY */static char pasv[64];                   /* Passive-mode port */static int passivemode = 0;static int sendport = 0;static int servertype = 0;              /* FTP server's OS type */static int testing = 0;static char ftpcmdbuf[FTP_BUFSIZ];/* Macro definitions */#define UC(b) ckitoa(((int)b)&0xff)#define nz(x) ((x) == 0 ? 1 : (x))/* Command tables and definitions */#define FTP_ACC  1                      /* FTP command keyword codes */#define FTP_APP  2#define FTP_CWD  3#define FTP_CHM  4#define FTP_CLS  5#define FTP_DEL  6#define FTP_DIR  7#define FTP_GET  8#define FTP_IDL  9#define FTP_MDE 10#define FTP_MDI 11#define FTP_MGE 12#define FTP_MKD 13#define FTP_MOD 14#define FTP_MPU 15#define FTP_OPN 16#define FTP_PUT 17#define FTP_PWD 18#define FTP_RGE 19#define FTP_REN 20#define FTP_RES 21#define FTP_HLP 22#define FTP_RMD 23#define FTP_STA 24#define FTP_SIT 25#define FTP_SIZ 26#define FTP_SYS 27#define FTP_UMA 28#define FTP_GUP 29#define FTP_USR 30#define FTP_QUO 31#define FTP_TYP 32#define FTP_FEA 33#define FTP_OPT 34#define FTP_CHK 35#define FTP_VDI 36#define FTP_ENA 37#define FTP_DIS 38struct keytab gprtab[] = {              /* GET-PUT-REMOTE keywords */    { "auto",    2, 0 },    { "ftp",     1, 0 },    { "kermit",  0, 0  }};static struct keytab qorp[] = {         /* QUIT or PROCEED keywords */    { "proceed", 0, 0 },                /* 0 = proceed */    { "quit",    1, 0 }                 /* 1 = quit */};static struct keytab ftpcmdtab[] = {    /* FTP command table */    { "account",   FTP_ACC, 0 },    { "append",    FTP_APP, 0 },    { "bye",       FTP_CLS, 0 },    { "cd",        FTP_CWD, 0 },    { "cdup",      FTP_GUP, 0 },    { "check",     FTP_CHK, 0 },    { "chmod",     FTP_CHM, 0 },    { "close",     FTP_CLS, 0 },    { "cwd",       FTP_CWD, CM_INV },    { "delete",    FTP_MDE, 0 },    { "directory", FTP_DIR, 0 },    { "disable",   FTP_DIS, 0 },    { "enable",    FTP_ENA, 0 },    { "features",  FTP_FEA, 0 },    { "get",       FTP_GET, 0 },    { "help",      FTP_HLP, 0 },    { "idle",      FTP_IDL, 0 },    { "login",     FTP_USR, CM_INV },    { "mdelete",   FTP_MDE, CM_INV },    { "mget",      FTP_MGE, 0 },    { "mkdir",     FTP_MKD, 0 },    { "modtime",   FTP_MOD, 0 },    { "mput",      FTP_MPU, 0 },    { "open",      FTP_OPN, 0 },    { "opt",       FTP_OPT, CM_INV|CM_ABR },    { "opts",      FTP_OPT, CM_INV },    { "options",   FTP_OPT, 0 },    { "put",       FTP_PUT, 0 },    { "pwd",       FTP_PWD, 0 },    { "quit",      FTP_CLS, CM_INV },    { "quote",     FTP_QUO, 0 },    { "reget",     FTP_RGE, 0 },    { "rename",    FTP_REN, 0 },    { "reset",     FTP_RES, 0 },    { "rmdir",     FTP_RMD, 0 },    { "send",      FTP_PUT, CM_INV },    { "site",      FTP_SIT, 0 },    { "size",      FTP_SIZ, 0 },    { "status",    FTP_STA, 0 },    { "system",    FTP_SYS, 0 },    { "type",      FTP_TYP, 0 },    { "umask",     FTP_UMA, 0 },    { "up",        FTP_GUP, CM_INV },    { "user",      FTP_USR, 0 },    { "vdirectory",FTP_VDI, 0 },    { "", 0, 0 }};static int nftpcmd = (sizeof(ftpcmdtab) / sizeof(struct keytab)) - 1;#define OPN_ANO 1			/* FTP OPEN switch codes */#define OPN_PSW 2#define OPN_USR 3#define OPN_ACC 4#define OPN_ACT 5#define OPN_PSV 6#define OPN_TLS 7#define OPN_NIN 8#define OPN_NOL 9#ifdef FTP_SECURITY#ifdef CK_SSL#define USETLSTABstatic struct keytab tlstab[] = {       /* FTP SSL/TLS switches */    { "/ssl",       OPN_TLS, 0    },    { "/tls",       OPN_TLS, 0    },    { "", 0, 0 }};static int ntlstab = (sizeof(tlstab) / sizeof(struct keytab)) - 1;#endif /* CK_SSL */#endif /* FTP_SECURITY */static struct keytab ftpswitab[] = {    /* FTP command switches */    { "/account",   OPN_ACC, CM_ARG },    { "/active",    OPN_ACT, 0      },    { "/anonymous", OPN_ANO, 0      },    { "/noinit",    OPN_NIN, 0      },    { "/nologin",   OPN_NOL, 0      },    { "/passive",   OPN_PSV, 0      },    { "/password",  OPN_PSW, CM_ARG },    { "/user",      OPN_USR, CM_ARG },    { "", 0, 0 }};static int nftpswi = (sizeof(ftpswitab) / sizeof(struct keytab)) - 1;/* FTP { ENABLE, DISABLE } items */#define ENA_FEAT 1#define ENA_MDTM 2#define ENA_MLST 3#define ENA_SIZE 4#define ENA_AUTH 5static struct keytab ftpenatab[] = {    { "AUTH",  ENA_AUTH, 0 },    { "FEAT",  ENA_FEAT, 0 },    { "MDTM",  ENA_MDTM, 0 },    { "ML",    ENA_MLST, CM_INV|CM_ABR },    { "MLS",   ENA_MLST, CM_INV|CM_ABR },    { "MLSD",  ENA_MLST, CM_INV },    { "MLST",  ENA_MLST, 0 },    { "SIZE",  ENA_SIZE, 0 },    { "", 0, 0 }};static int nftpena = (sizeof(ftpenatab) / sizeof(struct keytab)) - 1;/* SET FTP command keyword indices */#define FTS_AUT  1                      /* Autoauthentication */#define FTS_CRY  2                      /* Encryption */#define FTS_LOG  3                      /* Autologin */#define FTS_CPL  4                      /* Command protection level */#define FTS_CFW  5                      /* Credentials forwarding */#define FTS_DPL  6                      /* Data protection level */#define FTS_DBG  7                      /* Debugging */#define FTS_PSV  8                      /* Passive mode */#define FTS_SPC  9                      /* Send port commands */#define FTS_TYP 10                      /* (file) Type */#define FTS_USN 11                      /* Unique server names (for files) */#define FTS_VBM 12                      /* Verbose mode */#define FTS_ATP 13                      /* Authentication type */#define FTS_CNV 14                      /* Filename conversion */#define FTS_TST 15                      /* Test (progress) messages */#define FTS_PRM 16                      /* (file) Permissions */#define FTS_XLA 17                      /* Charset translation */#define FTS_CSR 18                      /* Server charset */#define FTS_ERR 19                      /* Error action */#define FTS_FNC 20                      /* Collision */#define FTS_SRP 21                      /* SRP options */#define FTS_GFT 22                      /* GET automatic file-type switching */#define FTS_DAT 23                      /* Set file dates */#define FTS_STO 24			/* Server time offset */#define FTS_APW 25			/* Anonymous password */#define FTS_DIS 26			/* File-transfer display style */#define FTS_BUG 27                      /* Bug(s) *//* FTP BUGS */#define FTB_SV2  1                      /* use SSLv2 */static struct keytab ftpbugtab[] = {    { "use-ssl-v2",     FTB_SV2,        0 }};static int nftpbug = (sizeof(ftpbugtab) / sizeof(struct keytab));/* FTP PUT options (mutually exclusive, not a bitmask) */#define PUT_UPD 1                       /* Update */#define PUT_RES 2                       /* Restart */#define PUT_SIM 4                       /* Simulation */#define PUT_DIF 8			/* Dates Differ */static struct keytab ftpcolxtab[] = { /* SET FTP COLLISION options */#ifndef MAC    { "append",    XYFX_A, 0 },         /* append to old file */#endif /* MAC */#ifdef COMMENT    { "ask",       XYFX_Q, 0 },         /* ask what to do (not implemented) */#endif    { "backup",    XYFX_B, 0 },         /* rename old file */#ifndef MAC    { "dates-differ", XYFX_M, 0 },	/* accept if dates differ */    { "discard",   XYFX_D, 0 },         /* don't accept new file */    { "no-supersede", XYFX_D, CM_INV }, /* ditto (MSK compatibility) */#endif /* MAC */    { "overwrite", XYFX_X, 0 },         /* overwrite the old file */    { "rename",    XYFX_R, 0 },         /* rename the incoming file */#ifndef MAC                             /* This crashes Mac Kermit. */    { "update",    XYFX_U, 0 },         /* replace if newer */#endif /* MAC */    { "", 0, 0 }};static int nftpcolx = (sizeof(ftpcolxtab) / sizeof(struct keytab)) - 1;#ifdef FTP_SECURITY/* FTP authentication options */#define FTA_AUTO 0                      /* Auto */#define FTA_SRP  1                      /* SRP */#define FTA_GK5  2                      /* Kerberos 5 */#define FTA_K4   3                      /* Kerberos 4 */#define FTA_SSL  4                      /* SSL */#define FTA_TLS  5                      /* TLS *//* FTP authentication types */#define FTPATYPS 8static int ftp_auth_type[FTPATYPS] = {#ifdef FTP_GSSAPI    FTA_GK5,                            /* GSSAPI Kerberos 5 */#endif /* FTP_GK5 */#ifdef FTP_SRP    FTA_SRP,                            /* SRP */#endif /* FTP_SRP */#ifdef FTP_KRB4    FTA_K4,                             /* Kerberos 4 */#endif /* FTP_KRB4 */#ifdef CK_SSL    FTA_TLS,                            /* TLS */    FTA_SSL,                            /* SSL */#endif /* CK_SSL */    0};static struct keytab ftpauth[] = {      /* SET FTP AUTHTYPE cmd table */    { "automatic", FTA_AUTO,  CM_INV },#ifdef FTP_GSSAPI    { "gssapi-krb5", FTA_GK5, 0 },#endif /* FTP_GSSAPI */#ifdef FTP_KRB4    { "k4",       FTA_K4,     CM_INV },#endif /* FTP_KRB4 */#ifdef FTP_GSSAPI    { "k5",        FTA_GK5,   CM_INV },#endif /* FTP_GSSAPI */

⌨️ 快捷键说明

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