📄 ckcftp.c
字号:
/* C K C F T P -- FTP Client for C-Kermit */char *ckftpv = "FTP Client, 8.0.226, 7 Jan 2004";/* Authors: Jeffrey E Altman <jaltman@secure-endpoints.com> Secure Endpoints Inc., New York City Frank da Cruz <fdc@columbia.edu>, The Kermit Project, Columbia University. Copyright (C) 2000, 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. Portions of conditionally included code Copyright Regents of the University of California and The Stanford SRP Authentication Project; see notices below.*//* Pending... . Implement recursive NLST downloads by trying to CD to each filename. If it works, it's a directory; if not, it's a file -- GET it. But that won't work with servers like wu-ftpd that don't send directory names. Recursion with MLSD is done. . Make syslog entries for session? Files? . Messages are printed to stdout and stderr in random fashion. We should either print everything to stdout, or else be systematic about when to use stderr. . Implement mail (MAIL, MLFL, MSOM, etc) if any servers support it. . Adapt to VMS. Big job because of its record-oriented file system. RMS programmer required. There are probably also some VMS TCP/IP product-specific wrinkles, e.g. attribute preservation in VMS-to-VMS transfers using special options for Multinet or other FTP servers (find out about STRU VMS).*//* Quick FTP command reference: RFC765 (1980) and earlier: MODE S(tream), B(lock), C(ompressed) STRU F(ILE), R(ECORD), P(AGE) TYPE A(SCII) <format>, E(BCDIC) <format>, I(MAGE), L(OCAL) <bytesize> PORT - Port PASV - Passive mode USER - User PASS - Password ACCT - Account CWD - Change Working Directory REIN - Logout but not disconnect QUIT - Bye RETR - Retreive STOR - Store APPE - Append ALLO - Allocate REST - Restart RNFR - Rename from RNTO - Rename to ABOR - Cancel DELE - Delete LIST - Directory NLST - Name List SITE - Site parameters or commands STAT - Status HELP - Help NOOP - Noop RFC959 (1985): CDUP - Change to Parent Directory SMNT - Structure Mount STOU - Store Unique RMD - Remove Directory MKD - Make Directory PWD - Print Directory SYST - System RFC2389 (1998): FEAT - List Features (done) OPTS - Send options (done) RFC2640 (1999): LANG - Specify language for messages (not done) Pending (Internet Drafts): SIZE - File size (done) MDTM - File modification date-time (done) MLST - File name and attribute list (single file) (not done) MLSD - File list with attributes (multiple files) (done) MAIL, MLFL, MSOM - mail delivery (not done) Alphabetical syntax list: ABOR <CRLF> ACCT <SP> <account-information> <CRLF> ALLO <SP> <decimal-integer> [<SP> R <SP> <decimal-integer>] <CRLF> APPE <SP> <pathname> <CRLF> CDUP <CRLF> CWD <SP> <pathname> <CRLF> DELE <SP> <pathname> <CRLF> FEAT <CRLF> HELP [<SP> <string>] <CRLF> LANG [<SP> <language-tag> ] <CRLF> LIST [<SP> <pathname>] <CRLF> MKD <SP> <pathname> <CRLF> MLSD [<SP> <pathname>] <CRLF> MLST [<SP> <pathname>] <CRLF> MODE <SP> <mode-code> <CRLF> NLST [<SP> <pathname-or-wildcard>] <CRLF> NOOP <CRLF> OPTS <SP> <commandname> [ <SP> <command-options> ] <CRLF> PASS <SP> <password> <CRLF> PASV <CRLF> PORT <SP> <host-port> <CRLF> PWD <CRLF> QUIT <CRLF> REIN <CRLF> REST <SP> <marker> <CRLF> RETR <SP> <pathname> <CRLF> RMD <SP> <pathname> <CRLF> RNFR <SP> <pathname> <CRLF> RNTO <SP> <pathname> <CRLF> SITE <SP> <string> <CRLF> SIZE <SP> <pathname> <CRLF> SMNT <SP> <pathname> <CRLF> STAT [<SP> <pathname>] <CRLF> STOR <SP> <pathname> <CRLF> STOU <CRLF> STRU <SP> <structure-code> <CRLF> SYST <CRLF> TYPE <SP> <type-code> <CRLF> USER <SP> <username> <CRLF>*/#include "ckcsym.h" /* Standard includes */#include "ckcdeb.h"#ifndef NOFTP /* NOFTP = no FTP */#ifndef SYSFTP /* SYSFTP = use external ftp client */#ifdef TCPSOCKET /* Build only if TCP/IP included */#define CKCFTP_C/* Note: much of the following duplicates what was done in ckcdeb.h *//* but let's not mess with it unless it causes trouble. */#ifdef CK_ANSIC#include <stdarg.h>#else /* CK_ANSIC */#include <varargs.h>#endif /* CK_ANSIC */#include <signal.h>#ifdef OS2#ifdef OS2ONLY#include <os2.h>#endif /* OS2ONLY */#include "ckowin.h"#include "ckocon.h"#endif /* OS2 */#ifndef ZILOG#ifdef NT#include <setjmpex.h>#ifdef NTSIGextern int TlsIndex;#endif /* NTSIG */#else /* NT */#include <setjmp.h>#endif /* NT */#else#include <setret.h>#endif /* ZILOG */#include "ckcsig.h"#include <sys/stat.h>#include <ctype.h>#include <errno.h>#ifndef NOTIMEH#include <time.h>#endif /* NOTIMEH */#ifndef EPIPE#define EPIPE 32 /* Broken pipe error */#endif /* EPIPE *//* Kermit includes */#include "ckcasc.h"#include "ckcker.h"#include "ckucmd.h"#include "ckuusr.h"#include "ckcnet.h" /* Includes ckctel.h */#include "ckctel.h" /* (then why include it again?) */#include "ckcxla.h"/* How to get the struct timeval definition so we can call select(). The xxTIMEH symbols are defined in ckcdeb.h, overridden in various makefile targets. The problem is: maybe we have already included some header file that defined struct timeval, and maybe we didn't. If we did, we don't want to include another header file that defines it again or the compilation will fail. If we didn't, we have to include the header file where it's defined. But in some cases even that won't work because of strict POSIX constraints or somesuch, or because this introduces other conflicts (e.g. struct tm multiply defined), in which case we have to define it ourselves, but this can work only if we didn't already encounter a definition.*/#ifndef DCLTIMEVAL#ifdef SV68R3V6#define DCLTIMEVAL#else#ifdef SCO234#define DCLTIMEVAL#endif /* SCO234 */#endif /* SV68R3V6 */#endif /* DCLTIMEVAL */#ifdef DCLTIMEVAL/* Also maybe in some places the elements must be unsigned... */struct timeval { long tv_sec; long tv_usec;};#ifdef COMMENT/* Currently we don't use this... */struct timezone { int tz_minuteswest; int tz_dsttime;};#endif /* COMMENT */#else /* !DCLTIMEVAL */#ifndef NOSYSTIMEH#ifdef SYSTIMEH#include <sys/time.h>#endif /* SYSTIMEH */#endif /* NOSYSTIMEH */#ifndef NOSYSTIMEBH#ifdef SYSTIMEBH#include <sys/timeb.h>#endif /* SYSTIMEBH */#endif /* NOSYSTIMEBH */#endif /* DCLTIMEVAL */#include <sys/types.h>#include <stdio.h>#include <string.h>#ifdef HAVE_STDLIB_H#include <stdlib.h>#endif /* HAVE_STDLIB_H */#ifndef NOSETTIME#ifdef COMMENT/* This section moved to ckcdeb.h */#ifdef POSIX#define UTIMEH#else#ifdef HPUX9#define UTIMEH#else#ifdef OS2#define SYSUTIMEH#endif /* OS2 */#endif /* HPUX9 */#endif /* POSIX */#endif /* COMMENT */#ifdef SYSUTIMEH#include <sys/utime.h>#else#ifdef UTIMEH#include <utime.h>#define SYSUTIMEH#endif /* UTIMEH */#endif /* SYSUTIMEH */#endif /* NOSETTIME */#ifndef SCO_OSR504#ifdef SELECT_H#include <sys/select.h>#endif /* SELECT_H */#endif /* SCO_OSR504 *//* select() dialects... */#ifdef UNIX#define BSDSELECT /* BSD select() syntax/semantics */#else#ifdef OS2 /* OS/2 or Win32 */#ifdef NT#define BSDSELECT#else /* NT */#define IBMSELECT#endif /* NT */#endif /* OS2 */#endif /* UNIX *//* Other select() peculiarities */#ifdef HPUX#ifndef HPUX10 /* HP-UX 9.xx and earlier */#ifndef HPUX1100/* The three interior args to select() are (int *) rather than (fd_set *) */#ifndef INTSELECT#define INTSELECT#endif /* INTSELECT */#endif /* HPUX1100 */#endif /* HPUX10 */#endif /* HPUX */#ifdef CK_SOCKS /* SOCKS Internet relay package */#ifdef CK_SOCKS5 /* SOCKS 5 */#define accept SOCKSaccept#define bind SOCKSbind#define connect SOCKSconnect#define getsockname SOCKSgetsockname#define listen SOCKSlisten#else /* Not SOCKS 5 */#define accept Raccept#define bind Rbind#define connect Rconnect#define getsockname Rgetsockname#define listen Rlisten#endif /* CK_SOCKS5 */#endif /* CK_SOCKS */#ifndef NOHTTPextern char * tcp_http_proxy; /* Name[:port] of http proxy server */extern int tcp_http_proxy_errno;extern char * tcp_http_proxy_user;extern char * tcp_http_proxy_pwd;extern char * tcp_http_proxy_agent;#define HTTPCPYL 1024static char proxyhost[HTTPCPYL];#endif /* NOHTTP */int ssl_ftp_proxy = 0; /* FTP over SSL/TLS Proxy Server *//* Feature selection */#ifndef USE_SHUTDOWN/* We don't use shutdown() because (a) we always call it just before close() so it's redundant and unnecessary, and (b) it introduces a long pause on some platforms like SV/68 R3.*//* #define USE_SHUTDOWN */#endif /* USE_SHUTDOWN */#ifndef NORESEND#ifndef NORESTART /* Restart / recover */#ifndef FTP_RESTART#define FTP_RESTART#endif /* FTP_RESTART */#endif /* NORESTART */#endif /* NORESEND */#ifndef NOUPDATE /* Update mode */#ifndef DOUPDATE#define DOUPDATE#endif /* DOUPDATE */#endif /* NOUPDATE */#ifndef UNICODE /* Unicode required */#ifndef NOCSETS /* for charset translation */#define NOCSETS#endif /* NOCSETS */#endif /* UNICODE */#ifndef OS2#ifndef HAVE_MSECS /* Millisecond timer */#ifdef UNIX#ifdef GFTIMER#define HAVE_MSECS#endif /* GFTIMER */#endif /* UNIX */#endif /* HAVE_MSECS */#endif /* OS2 */#ifdef PIPESEND /* PUT from pipe */#ifndef PUTPIPE#define PUTPIPE#endif /* PUTPIPE */#endif /* PIPESEND */#ifndef NOSPL /* PUT from array */#ifndef PUTARRAY#define PUTARRAY#endif /* PUTARRAY */#endif /* NOSPL *//* Security... */#ifdef CK_SRP#define FTP_SRP#endif /* CK_SRP */#ifdef CK_KERBEROS#ifdef KRB4/* There is a conflict between the Key Schedule formats used internally within the standalone MIT KRB4 library and that used by Eric Young in OpenSSL and his standalone DES library. Therefore, KRB4 FTP AUTH cannot be supported when either of those two packages are used.*/#ifdef KRB524#define FTP_KRB4#else /* KRB524 */#ifndef CK_SSL#ifndef LIBDES#define FTP_KRB4#endif /* LIBDES */#endif /* CK_SSL */#endif /* KRB524 */#endif /* KRB4 */#ifdef KRB5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -