📄 ckcftp.c
字号:
#ifndef HEIMDAL#define FTP_GSSAPI#endif /* HEIMDAL */#endif /* KRB5 */#endif /* CK_KERBEROS *//* FTP_SECURITY is defined if any of the above is selected */#ifndef FTP_SECURITY#ifdef FTP_GSSAPI#define FTP_SECURITY#else#ifdef FTP_KRB4#define FTP_SECURITY#else#ifdef FTP_SRP#define FTP_SECURITY#else#ifdef CK_SSL#define FTP_SECURITY#endif /* CK_SSL */#endif /* FTP_SRP */#endif /* FTP_KRB4 */#endif /* FTP_GSSAPI */#endif /* FTP_SECURITY */#ifdef CK_DES#ifdef CK_SSL#ifndef LIBDES#define LIBDES#endif /* LIBDES */#endif /* CK_SSL */#endif /* CK_DES */#ifdef CRYPT_DLL#ifndef LIBDES#define LIBDES#endif /* LIBDES */#endif /* CRYPT_DLL */#ifdef FTP_KRB4#define des_cblock Block#define des_key_schedule Schedule#ifdef KRB524#ifdef NT#define _WINDOWS#endif /* NT */#include "kerberosIV/krb.h"#else /* KRB524 */#ifdef SOLARIS#ifndef sun/* For some reason lost in history the Makefile Solaris targets have -Usun */#define sun#endif /* sun */#endif /* SOLARIS */#include "krb.h"#define krb_get_err_text_entry krb_get_err_text#endif /* KRB524 */#endif /* FTP_KRB4 */#ifdef CK_SSL#ifdef FTP_KRB4#ifndef HEADER_DES_H#define HEADER_DES_H#endif /* HEADER_DES_H */#endif /* FTP_KRB4 */#include "ck_ssl.h"#endif /* CK_SSL */#ifdef FTP_SRP#ifdef HAVE_PWD_H#include "pwd.h"#endif /* HAVE_PWD_H */#include "t_pwd.h"#include "t_client.h"#include "krypto.h"#endif /* FTP_SRP */#ifdef FTP_GSSAPI#include <gssapi/gssapi.h>/* Need to include the krb5 file, because we're doing manual fallback from the v2 mech to the v1 mech. Once there's real negotiation, we can be generic again.*/#include <gssapi/gssapi_generic.h>#include <gssapi/gssapi_krb5.h>static gss_ctx_id_t gcontext;#endif /* FTP_GSSAPI */#ifdef OS2#ifdef FTP_SRP#define MAP_KRYPTO#ifdef SRPDLL#define MAP_SRP#endif /* SRPDLL */#endif /* FTP_SRP */#ifdef FTP_KRB4#define MAP_KRB4#ifdef CK_ENCRYPTION#define MAP_DES#endif /* CK_ENCRYPTION */#endif /* FTP_KRB4 */#ifdef FTP_GSSAPI#define MAP_GSSAPI#define GSS_OIDS#endif /* FTP_GSSAPI */#include "ckoath.h"extern int k95stdout, wherex[], wherey[];extern unsigned char colorcmd;#endif /* OS2 */#ifdef FTP_KRB4static char ftp_realm[REALM_SZ + 1];static KTEXT_ST ftp_tkt;#ifdef OS2static LEASH_CREDENTIALS ftp_cred;#else /* OS2 */static CREDENTIALS ftp_cred;#endif /* OS2 */static MSG_DAT ftp_msg_data;static des_key_schedule ftp_sched;static int foo[4] = {99,99,99,99};#endif /* FTP_KRB4 *//* getreply() function codes */#define GRF_AUTH 1 /* Reply to AUTH command */#define GRF_FEAT 2 /* Reply to FEAT command *//* Operational definitions */#define DEF_VBM 0 /* Default verbose mode *//* #define SETVBM */ /* (see getreply) */#define URL_ONEFILE /* GET, not MGET, for FTP URL */#define FTP_BUFSIZ 10240 /* Max size for FTP cmds & replies */#define SRVNAMLEN 32 /* Max length for server type name */#define PWDSIZ 256#define PASSBUFSIZ 256#define PROMPTSIZ 256#ifndef MGETMAX /* Max operands for MGET command */#define MGETMAX 1000#endif /* MGETMAX */#ifdef FTP_SRP#define FUDGE_FACTOR 100#endif /* FTP_SRP *//* Amount of growth from cleartext to ciphertext. krb_mk_priv adds this number bytes. Must be defined for each auth type. GSSAPI appears to add 52 bytes, but I'm not sure it is a constant--hartmans 3DES requires 56 bytes. Lets use 96 just to be sure.*/#ifdef FTP_GSSAPI#ifndef FUDGE_FACTOR#define FUDGE_FACTOR 96#endif /* FUDGE_FACTOR */#endif /* FTP_GSSAPI */#ifdef FTP_KRB4#ifndef FUDGE_FACTOR#define FUDGE_FACTOR 32#endif /* FUDGE_FACTOR */#endif /* FTP_KRB4 */#ifndef FUDGE_FACTOR /* In case no auth types define it */#define FUDGE_FACTOR 0#endif /* FUDGE_FACTOR */#ifndef MAXHOSTNAMELEN#define MAXHOSTNAMELEN 64#endif /* MAXHOSTNAMELEN */#define MAX_DNS_NAMELEN (15*(MAXHOSTNAMELEN + 1)+1)/* Fascist compiler toadying */#ifndef SENDARG2TYPE#ifdef COMMENT /* Might be needed here and there */#define SENDARG2TYPE const char *#else#define SENDARG2TYPE char *#endif /* COMMENT */#endif /* SENDARG2TYPE *//* Common text messages */static char *nocx = "?No FTP control connection\n";static char *fncnam[] = { "rename", "overwrite", "backup", "append", "discard", "ask", "update", "dates-differ", ""};/* Macro definitions *//* Used to speed up text-mode PUTs */#define zzout(fd,c) \((fd<0)?(-1):((nout>=ucbufsiz)?(zzsend(fd,c)):(ucbuf[nout++]=c)))#define CHECKCONN() if(!connected){printf(nocx);return(-9);}/* Externals */#ifdef CK_URLextern struct urldata g_url;#endif /* CK_URL */#ifdef DYNAMICextern char *zinbuffer, *zoutbuffer; /* Regular Kermit file i/o */#elseextern char zinbuffer[], zoutbuffer[];#endif /* DYNAMIC */extern char *zinptr, *zoutptr;extern int zincnt, zoutcnt, zobufsize, fncact;#ifdef CK_TMPDIRextern int f_tmpdir; /* Directory changed temporarily */extern char savdir[]; /* For saving current directory */extern char * dldir;#endif /* CK_TMPDIR */extern char * rfspec, * sfspec, * srfspec, * rrfspec; /* For WHERE command */extern xx_strp xxstring;extern struct keytab onoff[], txtbin[], rpathtab[];extern int nrpathtab, xfiletype, patterns, gnferror, moving, what, pktnum;extern int success, nfils, sndsrc, quiet, nopush, recursive, inserver, binary;extern int filepeek, nscanfile, fsecs, xferstat, xfermode, lastxfer, tsecs;extern int backgrd, spackets, rpackets, spktl, rpktl, xaskmore, cmd_rows;extern int nolinks, msgflg, keep;extern long fsize, ffc, tfc, filcnt, xfsecs, tfcps, cps, oldcps;#ifdef GFTIMERextern CKFLOAT fptsecs, fpfsecs, fpxfsecs;#elseextern long xfsecs;#endif /* GFTIMER */extern char filnam[], * filefile, myhost[];extern char * snd_move, * rcv_move, * snd_rename, * rcv_rename;extern int g_skipbup, skipbup, sendmode;extern int g_displa, fdispla, displa;#ifdef LOCUSextern int locus, autolocus;#endif /* LOCUS */#ifndef NOCSETSextern int nfilc, dcset7, dcset8, fileorder;extern struct csinfo fcsinfo[];extern struct keytab fcstab[];extern int fcharset;#endif /* NOCSETS */extern char sndbefore[], sndafter[], *sndexcept[]; /* Selection criteria */extern char sndnbefore[], sndnafter[], *rcvexcept[];extern CHAR feol;extern long sendstart, sndsmaller, sndlarger, rs_len;extern char * remdest;extern int remfile, remappd, rempipe;#ifndef NOSPLextern int cmd_quoting;#ifdef PUTARRAYextern int sndxlo, sndxhi, sndxin;extern char sndxnam[];extern char **a_ptr[]; /* Array pointers */extern int a_dim[]; /* Array dimensions */#endif /* PUTARRAY */#endif /* NOSPL */#ifndef NOMSEND /* MPUT and ADD SEND-LIST lists */extern char *msfiles[];extern int filesinlist;extern struct filelist * filehead;extern struct filelist * filetail;extern struct filelist * filenext;extern int addlist;extern char fspec[]; /* Most recent filespec */extern int fspeclen; /* Length of fspec[] buffer */#endif /* NOMSEND */extern int pipesend;#ifdef PIPESENDextern char * sndfilter, * rcvfilter;#endif /* PIPESEND */#ifdef CKROOTextern int ckrooterr;#endif /* CKROOT */#ifdef KRB4extern int krb4_autoget;_PROTOTYP(char * ck_krb4_realmofhost,(char *));#endif /* KRB4 */#ifdef KRB5extern int krb5_autoget;extern int krb5_d_no_addresses;_PROTOTYP(char * ck_krb5_realmofhost,(char *));#endif /* KRB5 */#ifdef DCMDBUFextern char *atmbuf; /* Atom buffer (malloc'd) */extern char *cmdbuf; /* Command buffer (malloc'd) */extern char *line; /* Big string buffer #1 */extern char *tmpbuf; /* Big string buffer #2 */#elseextern char atmbuf[]; /* The same, but static */extern char cmdbuf[];extern char line[];extern char tmpbuf[];#endif /* DCMDBUF */extern char * cmarg, * cmarg2, ** cmlist; /* For setting up file lists *//* Public variables declared here */#ifdef NOXFERint ftpget = 1; /* GET/PUT/REMOTE orientation FTP */#elseint ftpget = 2; /* GET/PUT/REMOTE orientation AUTO */#endif /* NOXFER */int ftpcode = -1; /* Last FTP response code */int ftp_cmdlin = 0; /* FTP invoked from command line */int ftp_fai = 0; /* FTP failure count */int ftp_deb = 0; /* FTP debugging */int ftp_dis = -1; /* FTP display style */int ftp_log = 1; /* FTP Auto-login */int sav_log = -1;int ftp_action = 0; /* FTP action from command line */int ftp_dates = 1; /* Set file dates from server */char ftp_reply_str[FTP_BUFSIZ] = ""; /* Last line of previous reply */char ftp_srvtyp[SRVNAMLEN] = { NUL, NUL }; /* Server's system type */char ftp_user_host[MAX_DNS_NAMELEN]= ""; /* FTP hostname specified by user */char * ftp_host = NULL; /* FTP hostname */char * ftp_logname = NULL; /* FTP username */char * ftp_rdir = NULL; /* Remote directory from cmdline */char * ftp_apw = NULL; /* Anonymous password *//* Definitions and typedefs needed for prototypes */#define sig_t my_sig_t#define sigtype SIGTYPtypedef sigtype (*sig_t)();/* Static global variables */static char ftpsndbuf[FTP_BUFSIZ+64];static char * fts_sto = NULL;static int ftpsndret = 0;static struct _ftpsnd { sig_t oldintr, oldintp; int reply; int incs, outcs; char * cmd, * local, * remote; int bytes; int restart; int xlate; char * lmode;} ftpsnd;/* This is just a first stab -- these strings should match how the corresponding FTP servers identify themselves.*/#ifdef UNIXstatic char * myostype = "UNIX";#else#ifdef VMS/* not yet... */static char * myostype = "VMS";#else#ifdef OS2#ifdef NTstatic char * myostype = "WIN32";#elsestatic char * myostype = "OS/2";#endif /* NT */#elsestatic char * myostype = "UNSUPPORTED";#endif /* OS2 */#endif /* VMS */#endif /* UNIX */static int noinit = 0; /* Don't send REST, STRU, MODE */static int alike = 0; /* Client/server like platforms */static int local = 1; /* Shadows Kermit global 'local' */static int dout = -1; /* Data connection file descriptor */static int dpyactive = 0; /* Data transfer is active */static int globaldin = -1; /* Data connection f.d. */static int out2screen = 0; /* GET output is to screen */static int forcetype = 0; /* Force text or binary mode */static int cancelfile = 0; /* File canceled */static int cancelgroup = 0; /* Group canceled */static int anonymous = 0; /* Logging in as anonymous */static int loggedin = 0; /* Logged in (or not) */static int puterror = 0; /* What to do on PUT error */static int geterror = 0; /* What to do on GET error */static int rfrc = 0; /* remote_files() return code */static int okrestart = 0; /* Server understands REST */static int printlines = 0; /* getreply()should print data lines */static int haveurl = 0; /* Invoked by command-line FTP URL */static int mdtmok = 1; /* Server supports MDTM */static int sizeok = 1;static int featok = 1;static int mlstok = 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -