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

📄 ckcftp.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
_PROTOTYP(static int fts_dpl,(int));#ifdef FTP_SECURITY_PROTOTYP(static int ftp_auth, (void));#endif /* FTP_SECURITY */_PROTOTYP(static int ftp_user, (char *, char *, char *));_PROTOTYP(static int ftp_login, (char *));_PROTOTYP(static int ftp_reset, (void));_PROTOTYP(static int ftp_rename, (char *, char *));_PROTOTYP(static int ftp_umask, (char *));_PROTOTYP(static int secure_flush, (int));#ifdef COMMENT_PROTOTYP(static int secure_putc, (char, int));#endif /* COMMENT */_PROTOTYP(static int secure_write, (int, CHAR *, unsigned int));_PROTOTYP(static int scommand, (char *));_PROTOTYP(static int secure_putbuf, (int, CHAR *, unsigned int));_PROTOTYP(static int secure_getc, (int, int));_PROTOTYP(static int secure_getbyte, (int, int));_PROTOTYP(static int secure_read, (int, char *, int));_PROTOTYP(static int initconn, (void));_PROTOTYP(static int dataconn, (char *));_PROTOTYP(static int setprotbuf,(unsigned int));_PROTOTYP(static int sendrequest, (char *, char *, char *, int,int,int,int));_PROTOTYP(static char * radix_error,(int));_PROTOTYP(static char * ftp_hookup,(char *, int, int));_PROTOTYP(static CHAR * remote_files, (int, CHAR *, CHAR *, int));_PROTOTYP(static VOID mlsreset, (void));_PROTOTYP(static VOID secure_error, (char *fmt, ...));_PROTOTYP(static VOID lostpeer, (void));_PROTOTYP(static VOID cancel_remote, (int));_PROTOTYP(static VOID changetype, (int, int));_PROTOTYP(static sigtype cmdcancel, (int));#ifdef FTP_SRP_PROTOTYP(static int srp_reset, ());_PROTOTYP(static int srp_ftp_auth, (char *,char *,char *));_PROTOTYP(static int srp_put, (CHAR *, CHAR **, int, int *));_PROTOTYP(static int srp_get, (CHAR **, CHAR **, int *, int *));_PROTOTYP(static int srp_encode, (int, CHAR *, CHAR *, unsigned int));_PROTOTYP(static int srp_decode, (int, CHAR *, CHAR *, unsigned int));_PROTOTYP(static int srp_selcipher, (char *));_PROTOTYP(static int srp_selhash, (char *));#endif /* FTP_SRP */#ifdef FTP_GSSAPI_PROTOTYP(static void user_gss_error,(OM_uint32, OM_uint32,char *));#endif /* FTP_GSSAPI *//*  D O F T P A R G  --  Do an FTP command-line argument.  */#ifdef FTP_SECURITY#ifndef NOICP#define FT_NOGSS   1#define FT_NOK4    2#define FT_NOSRP   3#define FT_NOSSL   4#define FT_NOTLS   5#define FT_CERTFI  6#define FT_OKCERT  7#define FT_DEBUG   8#define FT_KEY     9#define FT_SECURE 10#define FT_VERIFY 11static struct keytab ftpztab[] = {    { "!gss",    FT_NOGSS,  0 },    { "!krb4",   FT_NOK4,   0 },    { "!srp",    FT_NOSRP,  0 },    { "!ssl",    FT_NOSSL,  0 },    { "!tls",    FT_NOTLS,  0 },    { "cert",    FT_CERTFI, CM_ARG },    { "certsok", FT_OKCERT, 0 },    { "debug",   FT_DEBUG,  0 },    { "key",     FT_KEY,    CM_ARG },    { "nogss",   FT_NOGSS,  0 },    { "nokrb4",  FT_NOK4,   0 },    { "nosrp",   FT_NOSRP,  0 },    { "nossl",   FT_NOSSL,  0 },    { "notls",   FT_NOTLS,  0 },#ifdef COMMENT    { "secure",  FT_SECURE, 0 },#endif /* COMMENT */    { "verify",  FT_VERIFY, CM_ARG },    { "", 0, 0 }};static int nftpztab = sizeof(ftpztab) / sizeof(struct keytab) - 1;/*  The following cipher and hash tables should be replaced with  dynamicly created versions based upon the linked library.*/#define SRP_BLOWFISH_ECB    1#define SRP_BLOWFISH_CBC    2#define SRP_BLOWFISH_CFB64  3#define SRP_BLOWFISH_OFB64  4#define SRP_CAST5_ECB       5#define SRP_CAST5_CBC       6#define SRP_CAST5_CFB64     7#define SRP_CAST5_OFB64     8#define SRP_DES_ECB         9#define SRP_DES_CBC        10#define SRP_DES_CFB64      11#define SRP_DES_OFB64      12#define SRP_DES3_ECB       13#define SRP_DES3_CBC       14#define SRP_DES3_CFB64     15#define SRP_DES3_OFB64     16static struct keytab ciphertab[] = {    { "blowfish_ecb",   SRP_BLOWFISH_ECB,   0 },    { "blowfish_cbc",   SRP_BLOWFISH_CBC,   0 },    { "blowfish_cfb64", SRP_BLOWFISH_CFB64, 0 },    { "blowfish_ofb64", SRP_BLOWFISH_OFB64, 0 },    { "cast5_ecb",      SRP_CAST5_ECB,      0 },    { "cast5_cbc",      SRP_CAST5_CBC,      0 },    { "cast5_cfb64",    SRP_CAST5_CFB64,    0 },    { "cast5_ofb64",    SRP_CAST5_OFB64,    0 },    { "des_ecb",        SRP_DES_ECB,        0 },    { "des_cbc",        SRP_DES_CBC,        0 },    { "des_cfb64",      SRP_DES_CFB64,      0 },    { "des_ofb64",      SRP_DES_OFB64,      0 },    { "des3_ecb",       SRP_DES3_ECB,       0 },    { "des3_cbc",       SRP_DES3_CBC,       0 },    { "des3_cfb64",     SRP_DES3_CFB64,     0 },    { "des3_ofb64",     SRP_DES3_OFB64,     0 },    { "none",           0, 0 },    { "", 0, 0 }};static int nciphertab = sizeof(ciphertab) / sizeof(struct keytab) - 1;#define SRP_MD5  1#define SRP_SHA  2static struct keytab hashtab[] = {    { "md5",              SRP_MD5,        0 },    { "none",             0,              0 },    { "sha",              SRP_SHA,        0 },    { "", 0, 0 }};static int nhashtab = sizeof(hashtab) / sizeof(struct keytab) - 1;#endif /* NOICP */#endif /* FTP_SECURITY */static char *strval(s1,s2) char * s1, * s2; {    if (!s1) s1 = "";    if (!s2) s2 = "";    return(*s1 ? s1 : (*s2 ? s2 : "(none)"));}#ifndef NOCSETSstatic char * rfnptr = NULL;static int rfnlen = 0;static char rfnbuf[RFNBUFSIZ];          /* Remote filename translate buffer */static char * xgnbp = NULL;static intstrgetc() {                             /* Helper function for xgnbyte() */    int c;    if (!xgnbp)      return(-1);    if (!*xgnbp)      return(-1);    c = (unsigned) *xgnbp++;    return(((unsigned) c) & 0xff);}static int                              /* Helper function for xpnbyte() */#ifdef CK_ANSICstrputc(char c)#elsestrputc(c) char c;#endif /* CK_ANSIC */{    rfnlen = rfnptr - rfnbuf;    if (rfnlen >= (RFNBUFSIZ - 1))      return(-1);    *rfnptr++ = c;    *rfnptr = NUL;    return(0);}static int#ifdef CK_ANSICxprintc(char c)#elsexprintc(c) char c;#endif /* CK_ANSIC */{    printf("%c",c);    return(0);}static VOIDbytswap(c0,c1) int * c0, * c1; {    int t;    t = *c0;    *c0 = *c1;    *c1 = t;}#endif /* NOCSETS */#ifdef CKLOGDIALchar ftplogbuf[CXLOGBUFL] = { NUL, NUL }; /* Connection Log */int ftplogactive = 0;long ftplogprev = 0L;VOIDftplogend() {    extern int dialog;    extern char diafil[];    long d1, d2, t1, t2;    char buf[32], * p;    debug(F111,"ftp cx log active",ckitoa(dialog),ftplogactive);    debug(F110,"ftp cx log buf",ftplogbuf,0);    if (!ftplogactive || !ftplogbuf[0]) /* No active record */      return;    ftplogactive = 0;                   /* Record is not active */    d1 = mjd((char *)ftplogbuf);        /* Get start date of this session */    ckstrncpy(buf,ckdate(),31);         /* Get current date */    d2 = mjd(buf);                      /* Convert them to mjds */    p = ftplogbuf;                      /* Get start time */    p[11] = NUL;    p[14] = NUL;                        /* Convert to seconds */    t1 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);    p[11] = ':';    p[14] = ':';    p = buf;                            /* Get end time */    p[11] = NUL;    p[14] = NUL;    t2 = atol(p+9) * 3600L + atol(p+12) * 60L + atol(p+15);    t2 = ((d2 - d1) * 86400L) + (t2 - t1); /* Compute elapsed time */    if (t2 > -1L) {        ftplogprev = t2;        p = hhmmss(t2);        strncat(ftplogbuf,"E=",CXLOGBUFL); /* Append to log record */        strncat(ftplogbuf,p,CXLOGBUFL);    } else      ftplogprev = 0L;    debug(F101,"ftp cx log dialog","",dialog);    if (dialog) {                       /* If logging */        int x;        x = diaopn(diafil,1,1);         /* Open log in append mode */        if (x > 0) {            debug(F101,"ftp cx log open","",x);            x = zsoutl(ZDIFIL,ftplogbuf); /* Write the record */            debug(F101,"ftp cx log write","",x);            x = zclose(ZDIFIL);         /* Close the log */            debug(F101,"ftp cx log close","",x);        }    }}VOIDdologftp() {    ftplogend();                        /* Previous session not closed out? */    ftplogprev = 0L;    ftplogactive = 1;                   /* Record is active */    ckmakxmsg(ftplogbuf,CXLOGBUFL,              ckdate()," ",strval(ftp_logname,NULL)," ",ckgetpid(),              " T=FTP N=", strval(ftp_host,NULL)," H=",myhost," ",NULL,NULL);    debug(F110,"ftp cx log begin",ftplogbuf,0);}#endif /* CKLOGDIAL */static char * dummy[2] = { NULL, NULL };static struct keytab modetab[] = {    { "active",  0, 0 },    { "passive", 1, 0 }};#ifndef NOCMDLint                                     /* Called from ckuusy.c */#ifdef CK_ANSICdoftparg(char c)#elsedoftparg(c) char c;#endif /* CK_ANSIC *//* doftparg */ {    int x, z;    char *xp;    extern char **xargv, *xarg0;    extern int xargc, stayflg, haveftpuid;    extern char uidbuf[];    xp = *xargv+1;                      /* Pointer for bundled args */    while (c) {        if (ckstrchr("MuDPkcHzm",c)) {  /* Options that take arguments */            if (*(xp+1)) {                fatal("?Invalid argument bundling");            }            xargv++, xargc--;            if ((xargc < 1) || (**xargv == '-')) {                fatal("?Required argument missing");            }        }        switch (c) {                    /* Big switch on arg */          case 'h':                     /* help */           printf("C-Kermit's FTP client command-line personality.  Usage:\n");            printf("  %s [ options ] host [ port ] [-pg files ]\n\n",xarg0);            printf("Options:\n");            printf("  -h           = help (this message)\n");            printf("  -m mode      = \"passive\" (default) or \"active\"\n");            printf("  -u name      = username for autologin (or -M)\n");            printf("  -P password  = password for autologin (RISKY)\n");            printf("  -A           = autologin anonymously\n");            printf("  -D directory = cd after autologin\n");            printf("  -b           = force binary mode\n");            printf("  -a           = force text (\"ascii\") mode (or -T)\n");            printf("  -d           = debug (double to add timestamps)\n");            printf("  -n           = no autologin\n");            printf("  -v           = verbose (default)\n");            printf("  -q           = quiet\n");            printf("  -S           = Stay (issue command prompt when done)\n");            printf("  -Y           = do not execute Kermit init file\n");            printf("  -p files     = files to put after autologin (or -s)\n");            printf("  -g files     = files to get after autologin\n");            printf("  -R           = recursive (for use with -p)\n");#ifdef FTP_SECURITY            printf("\nSecurity options:\n");            printf("  -k realm     = Kerberos 4 realm\n");            printf("  -f           = Kerboros 5 credentials forwarding\n");            printf("  -x           = autoencryption mode\n");            printf("  -c cipher    = SRP cipher type\n");            printf("  -H hash      = SRP encryption hash\n");            printf("  -z option    = Security options\n");#endif /* FTP_SECURITY */            printf("\n-p or -g, if given, should be last.  Example:\n");            printf("  ftp -A kermit.columbia.edu -D kermit -ag TESTFILE\n");            doexit(GOOD_EXIT,-1);            break;          case 'R':                     /* Recursive */            recursive = 1;            break;          case 'd':                     /* Debug */#ifdef DEBUG            if (deblog) {                extern int debtim;                debtim = 1;            } else {                deblog = debopn("debug.log",0);                debok = 1;            }#endif /* DEBUG */            /* fall thru on purpose */          case 't':                     /* Trace */            ftp_deb++;            break;          case 'n':                     /* No autologin */            ftp_log = 0;            break;          case 'i':                     /* No prompt */          case 'v':                     /* Verbose */            break;                      /* (ignored) */          case 'q':                     /* Quiet */            quiet = 1;            break;          case 'S':                     /* Stay */            stayflg = 1;            break;          case 'M':          case 'u':                     /* My User Name */            if ((int)strlen(*xargv) > 63) {                fatal("username too long");            }            ckstrncpy(uidbuf,*xargv,UIDBUFLEN);            haveftpuid = 1;            break;          case 'A':            ckstrncpy(uidbuf,"anonymous",UIDBUFLEN);            haveftpuid = 1;            break;          case 'T':                     /* Text */          case 'a':                     /* "ascii" */          case 'b':                     /* Binary */            binary = (c == 'b') ? FTT_BIN : FTT_ASC;            xfermode = XMODE_M;            filepeek = 0;            patterns = 0;            break;          case 'g':                     /* Get */          case 'p':                     /* Put */          case 's': {                   /* Send (= Put) */              int havefiles, rc;              if (ftp_action) {                  fatal("Only one FTP action at a time please");              }              if (*(xp+1)) {                  fatal("invalid argument bundling after -s");              }              nfils = 0;                /* Initialize file counter */              havefiles = 0;            /* Assume nothing to send  */              cmlist = 

⌨️ 快捷键说明

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