📄 ckcftp.c
字号:
#ifdef FTP_KRB4 { "kerberos4", FTA_K4, 0 },#endif /* FTP_KRB4 */#ifdef FTP_GSSAPI { "kerberos5", FTA_GK5, CM_INV },#endif /* FTP_GSSAPI */#ifdef FTP_KRB4 { "kerberos_iv",FTA_K4, CM_INV },#endif /* FTP_KRB4 */#ifdef FTP_GSSAPI { "kerberos_v", FTA_GK5, CM_INV },#endif /* FTP_GSSAPI */#ifdef FTP_KRB4 { "krb4", FTA_K4, CM_INV },#endif /* FTP_KRB4 */#ifdef FTP_GSSAPI { "krb5", FTA_GK5, CM_INV },#endif /* FTP_GSSAPI */#ifdef FTP_SRP { "srp", FTA_SRP, 0 },#endif /* FTP_SRP */#ifdef CK_SSL { "ssl", FTA_SSL, 0 }, { "tls", FTA_TLS, 0 },#endif /* CK_SSL */ { "", 0, 0 }};static int nftpauth = (sizeof(ftpauth) / sizeof(struct keytab)) - 1;#ifdef FTP_SRP#define SRP_CIPHER 1#define SRP_HASH 2static struct keytab ftpsrp[] = { /* SET FTP SRP command table */ { "cipher", SRP_CIPHER, 0 }, { "hash", SRP_HASH, 0 }, { "", 0, 0 }};static int nftpsrp = (sizeof(ftpsrp) / sizeof(struct keytab)) - 1;#endif /* FTP_SRP */#endif /* FTP_SECURITY */static struct keytab ftpset[] = { /* SET FTP commmand table */ { "anonymous-password", FTS_APW, 0 },#ifdef FTP_SECURITY { "authtype", FTS_ATP, 0 }, { "autoauthentication", FTS_AUT, 0 }, { "autoencryption", FTS_CRY, 0 },#endif /* FTP_SECURITY */ { "autologin", FTS_LOG, 0 }, { "bug", FTS_BUG, 0 },#ifndef NOCSETS { "character-set-translation",FTS_XLA, 0 },#endif /* NOCSETS */ { "collision", FTS_FNC, 0 },#ifdef FTP_SECURITY { "command-protection-level", FTS_CPL, 0 }, { "cpl", FTS_CPL, CM_INV }, { "credential-forwarding", FTS_CFW, 0 }, { "da", FTS_DAT, CM_INV|CM_ABR }, { "data-protection-level", FTS_DPL, 0 },#endif /* FTP_SECURITY */ { "dates", FTS_DAT, 0 }, { "debug", FTS_DBG, 0 }, { "display", FTS_DIS, 0 },#ifdef FTP_SECURITY { "dpl", FTS_DPL, CM_INV },#endif /* FTP_SECURITY */ { "error-action", FTS_ERR, 0 }, { "filenames", FTS_CNV, 0 }, { "get-filetype-switching", FTS_GFT, 0 }, { "passive-mode", FTS_PSV, 0 }, { "pasv", FTS_PSV, CM_INV }, { "permissions", FTS_PRM, 0 }, { "progress-messages", FTS_TST, 0 }, { "send-port-commands", FTS_SPC, 0 },#ifndef NOCSETS { "server-character-set", FTS_CSR, 0 },#endif /* NOCSETS */ { "server-time-offset", FTS_STO, 0 },#ifdef FTP_SRP { "srp", FTS_SRP, 0 },#else { "srp", FTS_SRP, CM_INV },#endif /* FTP_SRP */ { "type", FTS_TYP, 0 }, { "unique-server-names", FTS_USN, 0 }, { "verbose-mode", FTS_VBM, 0 }, { "", 0, 0 }};static int nftpset = (sizeof(ftpset) / sizeof(struct keytab)) - 1;/* GET and PUT switches are approximately the same as Kermit GET and SEND, and use the same SND_xxx definitions, but hijack a couple for FTP use. Don't just make up new ones, since the number of SND_xxx options must be known in advance for the switch-parsing arrays.*/#define SND_USN SND_PRO /* /UNIQUE instead of /PROTOCOL */#define SND_PRM SND_PIP /* /PERMISSIONS instead of /PIPES */#define SND_TEN SND_CAL /* /TENEX instead of /CALIBRATE */static struct keytab putswi[] = { /* FTP PUT switch table */ { "/after", SND_AFT, CM_ARG },#ifdef PUTARRAY { "/array", SND_ARR, CM_ARG },#endif /* PUTARRAY */ { "/as", SND_ASN, CM_ARG|CM_INV|CM_ABR }, { "/as-name", SND_ASN, CM_ARG }, { "/ascii", SND_TXT, CM_INV }, { "/b", SND_BIN, CM_INV|CM_ABR }, { "/before", SND_BEF, CM_ARG }, { "/binary", SND_BIN, 0 },#ifdef PUTPIPE { "/command", SND_CMD, CM_PSH },#endif /* PUTPIPE */#ifdef COMMENT/* This works but it's dangerous */#ifdef DOUPDATE { "/dates-differ", SND_DIF, CM_INV },#endif /* DOUPDATE */#endif /* COMMENT */ { "/delete", SND_DEL, 0 },#ifdef UNIXOROSK { "/dotfiles", SND_DOT, 0 },#endif /* UNIXOROSK */ { "/error-action", SND_ERR, CM_ARG }, { "/except", SND_EXC, CM_ARG }, { "/filenames", SND_NAM, CM_ARG },#ifdef PIPESEND#ifndef NOSPL { "/filter", SND_FLT, CM_ARG|CM_PSH },#endif /* NOSPL */#endif /* PIPESEND */#ifdef CKSYMLINK { "/followlinks", SND_LNK, 0 },#endif /* CKSYMLINK */#ifdef VMS { "/image", SND_IMG, 0 },#else { "/image", SND_BIN, CM_INV },#endif /* VMS */ { "/larger-than", SND_LAR, CM_ARG }, { "/listfile", SND_FIL, CM_ARG },#ifndef NOCSETS { "/local-character-set", SND_CSL, CM_ARG },#endif /* NOCSETS */#ifdef CK_TMPDIR { "/move-to", SND_MOV, CM_ARG },#endif /* CK_TMPDIR */ { "/nobackupfiles", SND_NOB, 0 },#ifdef UNIXOROSK { "/nodotfiles", SND_NOD, 0 },#endif /* UNIXOROSK */#ifdef CKSYMLINK { "/nofollowlinks", SND_NLK, 0 },#endif /* CKSYMLINK */ { "/not-after", SND_NAF, CM_ARG }, { "/not-before", SND_NBE, CM_ARG },#ifdef UNIX { "/permissions", SND_PRM, CM_ARG },#else { "/permissions", SND_PRM, CM_ARG|CM_INV },#endif /* UNIX */ { "/quiet", SND_SHH, 0 },#ifdef FTP_RESTART { "/recover", SND_RES, 0 },#endif /* FTP_RESTART */#ifdef RECURSIVE { "/recursive", SND_REC, 0 },#endif /* RECURSIVE */ { "/rename-to", SND_REN, CM_ARG },#ifdef FTP_RESTART { "/restart", SND_RES, CM_INV },#endif /* FTP_RESTART */#ifndef NOCSETS { "/server-character-set", SND_CSR, CM_ARG },#endif /* NOCSETS */ { "/server-rename-to", SND_SRN, CM_ARG }, { "/simulate", SND_SIM, 0 }, { "/since", SND_AFT, CM_INV|CM_ARG }, { "/smaller-than", SND_SMA, CM_ARG },#ifdef COMMENT { "/starting-at", SND_STA, CM_ARG },#endif /* COMMENT */#ifdef RECURSIVE { "/subdirectories", SND_REC, CM_INV },#endif /* RECURSIVE */ { "/tenex", SND_TEN, 0 }, { "/text", SND_TXT, 0 },#ifndef NOCSETS { "/transparent", SND_XPA, 0 },#endif /* NOCSETS */ { "/type", SND_TYP, CM_ARG },#ifdef DOUPDATE { "/update", SND_UPD, 0 },#endif /* DOUPDATE */ { "/unique-server-names", SND_USN, 0 }, { "", 0, 0 }};static int nputswi = (sizeof(putswi) / sizeof(struct keytab)) - 1;static struct keytab getswi[] = { /* FTP [M]GET switch table */ { "/after", SND_AFT, CM_INV }, { "/as", SND_ASN, CM_ARG|CM_INV|CM_ABR }, { "/as-name", SND_ASN, CM_ARG }, { "/ascii", SND_TXT, CM_INV }, { "/before", SND_BEF, CM_INV }, { "/binary", SND_BIN, 0 }, { "/collision", SND_COL, CM_ARG },#ifdef PUTPIPE { "/command", SND_CMD, CM_PSH },#endif /* PUTPIPE */ { "/delete", SND_DEL, 0 }, { "/error-action", SND_ERR, CM_ARG }, { "/except", SND_EXC, CM_ARG }, { "/filenames", SND_NAM, CM_ARG },#ifdef PIPESEND#ifndef NOSPL { "/filter", SND_FLT, CM_ARG|CM_PSH },#endif /* NOSPL */#endif /* PIPESEND */#ifdef VMS { "/image", SND_IMG, 0 },#else { "/image", SND_BIN, CM_INV },#endif /* VMS */ { "/larger-than", SND_LAR, CM_ARG }, { "/listfile", SND_FIL, CM_ARG },#ifndef NOCSETS { "/local-character-set", SND_CSL, CM_ARG },#endif /* NOCSETS */ { "/match", SND_PAT, CM_ARG }, { "/ml", SND_MLS, CM_INV|CM_ABR }, { "/mls", SND_MLS, CM_INV|CM_ABR }, { "/mlsd", SND_MLS, 0 }, { "/mlst", SND_MLS, CM_INV },#ifdef CK_TMPDIR { "/move-to", SND_MOV, CM_ARG },#endif /* CK_TMPDIR */ { "/namelist", SND_NML, CM_ARG }, { "/nlst", SND_NLS, 0 }, { "/nobackupfiles", SND_NOB, 0 }, { "/nodotfiles", SND_NOD, 0 },#ifdef DOUPDATE { "/dates-differ", SND_DIF, CM_INV },#endif /* DOUPDATE */ { "/not-after", SND_NAF, CM_INV }, { "/not-before", SND_NBE, CM_INV }, { "/permissions", SND_PRM, CM_INV }, { "/quiet", SND_SHH, 0 },#ifdef FTP_RESTART { "/recover", SND_RES, 0 },#endif /* FTP_RESTART */#ifdef RECURSIVE { "/recursive", SND_REC, 0 },#endif /* RECURSIVE */ { "/rename-to", SND_REN, CM_ARG },#ifdef FTP_RESTART { "/restart", SND_RES, CM_INV },#endif /* FTP_RESTART */#ifndef NOCSETS { "/server-character-set", SND_CSR, CM_ARG },#endif /* NOCSETS */ { "/server-rename-to", SND_SRN, CM_ARG }, { "/smaller-than", SND_SMA, CM_ARG },#ifdef RECURSIVE { "/subdirectories", SND_REC, CM_INV },#endif /* RECURSIVE */ { "/text", SND_TXT, 0 }, { "/tenex", SND_TEN, 0 },#ifndef NOCSETS { "/transparent", SND_XPA, 0 },#endif /* NOCSETS */ { "/to-screen", SND_MAI, 0 },#ifdef DOUPDATE { "/update", SND_UPD, CM_INV },#endif /* DOUPDATE */ { "", 0, 0 }};static int ngetswi = (sizeof(getswi) / sizeof(struct keytab)) - 1;static struct keytab delswi[] = { /* FTP [M]DELETE switch table */ { "/error-action", SND_ERR, CM_ARG }, { "/except", SND_EXC, CM_ARG }, { "/filenames", SND_NAM, CM_ARG }, { "/larger-than", SND_LAR, CM_ARG }, { "/nobackupfiles", SND_NOB, 0 },#ifdef UNIXOROSK { "/nodotfiles", SND_NOD, 0 },#endif /* UNIXOROSK */ { "/quiet", SND_SHH, 0 },#ifdef RECURSIVE { "/recursive", SND_REC, 0 },#endif /* RECURSIVE */ { "/smaller-than", SND_SMA, CM_ARG },#ifdef RECURSIVE { "/subdirectories", SND_REC, CM_INV },#endif /* RECURSIVE */ { "", 0, 0 }};static int ndelswi = (sizeof(delswi) / sizeof(struct keytab)) - 1;static struct keytab fntab[] = { /* Filename conversion keyword table */ { "automatic", 2, CNV_AUTO }, { "converted", 1, CNV_CNV }, { "literal", 0, CNV_LIT }};static int nfntab = (sizeof(fntab) / sizeof(struct keytab));static struct keytab ftptyp[] = { /* SET FTP TYPE table */ { "ascii", FTT_ASC, 0 }, { "binary", FTT_BIN, 0 }, { "tenex", FTT_TEN, 0 }, { "text", FTT_ASC, CM_INV }, { "", 0, 0 }};static int nftptyp = (sizeof(ftptyp) / sizeof(struct keytab)) - 1;#ifdef FTP_SECURITYstatic struct keytab ftppro[] = { /* SET FTP PROTECTION-LEVEL table */ { "clear", FPL_CLR, 0 }, { "confidential", FPL_CON, 0 }, { "private", FPL_PRV, 0 }, { "safe", FPL_SAF, 0 }, { "", 0, 0 }};static int nftppro = (sizeof(ftppro) / sizeof(struct keytab)) - 1;#endif /* FTP_SECURITY *//* Definitions for FTP from RFC765. *//* Reply codes */#define REPLY_PRELIM 1 /* Positive preliminary */#define REPLY_COMPLETE 2 /* Positive completion */#define REPLY_CONTINUE 3 /* Positive intermediate */#define REPLY_TRANSIENT 4 /* Transient negative completion */#define REPLY_ERROR 5 /* Permanent negative completion */#define REPLY_SECURE 6 /* Security encoded message *//* Form codes and names */#define FORM_N 1 /* Non-print */#define FORM_T 2 /* Telnet format effectors */#define FORM_C 3 /* Carriage control (ASA) *//* Structure codes and names */#define STRU_F 1 /* File (no record structure) */#define STRU_R 2 /* Record structure */#define STRU_P 3 /* Page structure *//* Mode types and names */#define MODE_S 1 /* Stream */#define MODE_B 2 /* Block */#define MODE_C 3 /* Compressed *//* Protection levels and names */#define PROT_C 1 /* Clear */#define PROT_S 2 /* Safe */#define PROT_P 3 /* Private */#define PROT_E 4 /* Confidential */#ifdef COMMENT /* Not used */#ifdef FTP_NAMESchar *strunames[] = {"0", "File", "Record", "Page" };char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" };char *modenames[] = {"0", "Stream", "Block", "Compressed" };char *levelnames[] = {"0", "Clear", "Safe", "Private", "Confidential" };#endif /* FTP_NAMES *//* Record Tokens */#define REC_ESC '\377' /* Record-mode Escape */#define REC_EOR '\001' /* Record-mode End-of-Record */#define REC_EOF '\002' /* Record-mode End-of-File *//* Block Header */#define BLK_EOR 0x80 /* Block is End-of-Record */#define BLK_EOF 0x40 /* Block is End-of-File */#define BLK_REPLY_ERRORS 0x20 /* Block might have errors */#define BLK_RESTART 0x10 /* Block is Restart Marker */#define BLK_BYTECOUNT 2 /* Bytes in this block */#endif /* COMMENT */#define RADIX_ENCODE 0 /* radix_encode() function codes */#define RADIX_DECODE 1/* The default setpbsz() value in the Unix FTP client is 1<<20 (1MB). This results in a serious performance degradation due to the increased number of page faults and the inability to overlap encrypt/decrypt, file i/o, and network i/o. So instead we set the value to 1<<13 (8K), about half the size of the typical TCP window. Maybe we should add a command to allow the value to be changed.*/#define DEFAULT_PBSZ 1<<13/* Prototypes */_PROTOTYP(int remtxt, (char **) );_PROTOTYP(char * gskreason, (int) );_PROTOTYP(static int ftpclose,(void));_PROTOTYP(static int zzsend, (int, CHAR));_PROTOTYP(static int getreply,(int,int,int,int,int));_PROTOTYP(static int radix_encode,(CHAR[], CHAR[], int, int *, int));_PROTOTYP(static int setpbsz,(unsigned int));_PROTOTYP(static int recvrequest,(char *,char *,char *,char *, int,int,char *,int,int,int));_PROTOTYP(static int ftpcmd,(char *,char *,int,int,int));_PROTOTYP(static int fts_cpl,(int));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -