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

📄 ckuusx.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifdef VMS    extern char * ckvmserrstr(unsigned long);#ifdef CKROOT    if (ckrooterr)      return("Off limits");#endif /* CKROOT */    return(ckvmserrstr(0L));#else  /* !VMS */#ifdef BSD44#ifdef __386BSD__#ifndef NDSYSERRLIST    extern int sys_nerr;    extern char *sys_errlist[];#endif /* NDSYSERRLIST */#else  /* !__386BSD__ */#ifndef __bsdi__#ifndef NDSYSERRLIST    extern int sys_nerr;    extern const char *const sys_errlist[];#endif /* NDSYSERRLIST */#endif /* __bsdi__ */#endif /* __386BSD__ */#ifdef CKROOT    if (ckrooterr)      return("Off limits");    else#endif /* CKROOT */    if (errno >= sys_nerr)      return("Error number out of range");    else      return((char *) sys_errlist[errno]);#else /* !BSD44 */#ifdef ATTSV#ifndef NDSYSERRLIST    extern int sys_nerr;    extern char *sys_errlist[];#endif /* NDSYSERRLIST */#ifdef CKROOT    if (ckrooterr)      return("Off limits");    else#endif /* CKROOT */    if (errno >= sys_nerr)      return("Error number out of range");    else      return((char *) sys_errlist[errno]);#else /* !ATTSV */#ifdef BSD4#ifndef NDSYSERRLIST    extern int sys_nerr;    extern char *sys_errlist[];#endif /* NDSYSERRLIST */#ifdef CKROOT    if (ckrooterr)      return("Off limits");    else#endif /* CKROOT */    if (errno >= sys_nerr)      return("Error number out of range");    else      return((char *) sys_errlist[errno]);#else#ifdef OS2#ifndef NDSYSERRLIST    extern char *sys_errlist[];#endif /* NDSYSERRLIST */#ifdef NT    extern int_sys_nerr;#endif /* NT */    char *e;#ifdef CKROOT    if (ckrooterr)      return("Off limits");#endif /* CKROOT */    e = (errno > -1#ifdef NT         && errno <= _sys_nerr#endif /* NT */         ) ?#ifdef NT         (char *) sys_errlist[errno]#else /* NT */         /* I don't know how to get a CLIB error string in OS/2 */         strerror(errno)#endif /* NT */             : "";    return(e ? e : "");#else /* OS2 */    return("");#endif /* OS2 */#endif /* BSD4 */#endif /* ATTSV */#endif /* BSD44 */#endif /* VMS */#endif /* USE_STRERROR */}#ifdef PATTERNS/*  Filename pattern recognition lists for automatic text/binary switching.  These are somewhat passe after the addition of scanfile()  (7.0).  But with the addition of FTP [M]GET, they're back in style (8.0).  Although, with FTP the lists need to be used in the reverse.  With  Kermit the list is used to imply the types of the local system.  Whereas  with FTP, the list must be used to imply the type of the remote system.  Therefore, all platforms must now support all of the lists.*/char *txtpatterns[FTPATTERNS+1] = { NULL, NULL };char *binpatterns[FTPATTERNS+1] = { NULL, NULL };/*  Default pattern lists for each platform...  NOTE: In most cases we leave ".hlp", ".ini", and ".scr" alone; although they  are traditionally text types, they are binary in Windows.  So they are  handled by the prevailing SET FILE TYPE, rather than automatically.  Similarly for ".dat", ".inf", and so on.  Also ".ps" since PostScript files  are not always text.  ".log" is omitted since logs can be text or binary,  except in VMS they are usually text, etc etc.  Later (Sep 2003): Add PostScript to binary patterns.*/static char *txtp[SYS_MAX][FTPATTERNS] = {    /* UNKNOWN */ {	NULL, NULL    },    {					/* UNIX */    "*.txt","*.c","*.h","*.r","*.w","*.cpp","*.cc","*.ksc","*.bwr","*.upd",    "*.html","*.htm","*.mss","*.tex","*.nr","[Mm]akefile", "*.hex", "*.hqx",    "*.for","*.f77","*.f","*.F","*.s","*.pas","*.java","*.el","*.lisp","*.sh",    "*.m4","*.perl","*.pl","*.pod","*.pm","*.awk","*.sno","*.spt","*.sed",    "*.ksc","*.TXT", "*read.me", "*READ.ME", ".*", "*/.*", "*.mem","*.mac",    NULL    },    {					/* WIN32 */    "*.txt","*.ksc","*.htm","*.html","*.bat","*.cmd","*.jav","*.asm", "*.hex",    "*.hqx", "*.c", "*.h", "*.cpp", "*.hpp", "*.cxx", "*.cxx", "*.w",    "*.java", "*.bwr", "*.upd", "*.mak", "read.me", "*.map", "makefile",    "*.mem","*.mac","*.cc","*.pl","*.pod","*.pm","*.m4",NULL    },    {					/* VMS */    "*.com","*.txt","*.c",  "*.for","*.pas","*.rno","*.rnh","*.mar","*.bli",    "*.hlp","*.mss","*.doc","*.bwr","*.cld","*.hex","*.bas","*.ini","*.log",    "*.mms","*.opt","*.ksc","*.perl","*.pl","*.pod","*.pm","*.sno","*.spt",    "*.mem",NULL    },    {					/* OS2 */    "*.txt","*.ksc","*.htm","*.html","*.bat","*.cmd","*.jav","*.asm", "*.hex",    "*.hqx", "*.c", "*.h", "*.cpp", "*.hpp", "*.cxx", "*.cxx", "*.w",    "*.java", "*.bwr", "*.upd", "*.mak", "read.me", "*.map", "makefile",    NULL    },    {					/* DOS */    "*.txt","*.ksc","*.htm","*.bat","*.cmd","*.jav","*.asm", "*.hex",    "*.hqx", "*.c", "*.h", "*.cpp", "*.hpp", "*.cxx", "*.cxx", "*.w",    "*.bwr", "*.upd", "*.mak", "read.me", "*.map", "makefile", NULL    },    {					/* TOPS-10 */    "*.cmd","*.hlp","*.doc","*.ini","*.txt","*.mac","*.for","*.sai","*.bli",    "*.pas","*.sno","*.spt","*.pcl","*.mss","*.rno","*.b36","*.tex","*.pub",    "*.req","*.r36","*.mem","*.bwr","*.ccl","*.ctl","*.rnh","*.ksc",NULL    },    {					/* TOPS-20 */    "*.cmd","*.hlp","*.doc","*.ini","*.txt","*.mac","*.for","*.sai","*.bli",    "*.pas","*.sno","*.spt","*.pcl","*.mss","*.rno","*.b36","*.tex","*.pub",    "*.req","*.r36","*.mem","*.bwr","*.ccl","*.ctl","*.rnh","*.ksc",NULL    },    {					/* STRATUS VOS */    "*.txt","*.ksc","*.htm","*.html","*.bat", "*.cmd","*.jav","*.asm","*.hex",    "*.hqx","*.c",  "*.h",  "*.w",   "*.java","*.bwr","*.upd","*.ttp","*.cm",    "*.pl1","*.emacs", "read.me", "*.pl", "makefile", NULL    },    {					/* DG AOS/VS */    "*.txt", "*.c", "*.h", "*.w", "*.er", "*.bwr", "*.upd", "read.me",    "*.cli", "*.ksc", NULL    },    {					/* OSK */    "*.c","*.cpp","*.h","*.a","*akefile", /* program sources */    "*.for","*.f77","*.f","*.F","*.s","*.pas","*.java","*.el","*.lisp",    "*.sh","*.perl","*.awk","*.sno","*.spt","*.sed",    "*.txt","*.w",			/* general text */    "*.ksc","*.bwr","*.upd",    "*.html","*.htm","*.mss","*.tex","*.nr","*.hex", "*.hqx",    "*.TXT", "*read.me", "*READ.ME", ".*", "*/.*",    NULL    }};/* Note: .DOC added to (some) binary patterns June 1998... Microsoft wins. */static char *binp[SYS_MAX][FTPATTERNS] = {    {					/* UNKNOWN */    NULL, NULL    },    {					/* UNIX */    "*.gz","*.Z","*.tgz","*.gif", "*.tar","*.zip","*.o","*.so","*.a","*.out",    "*.exe", "*.jpg", "*.jpeg", "*.tif","*.tiff", "*.pdf", "*.so.*", "*.class",    "*.rpm", "*.bmp", "*.bz2", "*.BMP", "*.dll", "*.doc", "*.vxd", "*.dcx",    "*.xl*", "*.lzh", "*.lhz", "*.au", "*.voc", "*.mpg", "*.mpeg","[wk]ermit",    "*.ps", NULL    },    {					/* WIN32 */    "*.exe", "*.zip", "*.obj", "*.com", "*.gif", "*.jpg", "*.wav", "*.ram",    "*.class","*.cla","*.dll", "*.drv", "*.ocx", "*.vbx", "*.lib", "*.ico",    "*.bmp", "*.tif", "*.tar", "*.gz",  "*.tgz", "*.xl*", "*.doc", "*.vxd",    "*.pdf", "*.lzh", "*.vxd", "*.snd", "*.au", "* .voc", "*.mpg", "*.mpeg",    "*.ps", NULL    },    {					/* VMS */    "*.exe","*.obj","*.bak","*.bin","*.adf","*.stb","*.mai","*.sys","*.dmp",    "*.ps", "*.dat","*.par", NULL    },    {					/* OS2 */    "*.exe", "*.zip", "*.obj", "*.com", "*.gif", "*.jpg", "*.wav", "*.ram",    "*.class", "*.cla", "*.dll", "*.drv", "*.ocx", "*.vbx", "*.lib", "*.ico",    "*.bmp", "*.tif", "*.tar", "*.gz", "*.tgz", "*.xl*", "*.doc", "*.vxd",    "*.pdf", "*.ps", "*.lzh", NULL    },    {					/* DOS */    "*.exe", "*.zip", "*.obj", "*.com", "*.gif", "*.jpg", "*.wav", "*.ram",    "*.cla", "*.dll", "*.drv", "*.ocx", "*.vbx", "*.lib", "*.ico",    "*.bmp", "*.tif", "*.tar", "*.gz", "*.tgz", "*.xl*", "*.doc", "*.vxd",    "*.pdf", "*.ps", "*.lzh", NULL    },    {					/* TOPS10 */    "*.exe","*.sav","*.bin","*.rim","*.rel","*.unv","*.lib","*.tap","*.dvi",    "*.ps", NULL    },    {					/* TOPS20 */    "*.exe","*.sav","*.bin","*.rim","*.rel","*.unv","*.lib","*.tap","*.dvi",    "*.ps", NULL    },    {					/* STRATUS VOS */    "*.exe", "*.zip", "*.obj", "*.com", "*.gif", "*.jpg", "*.wav", "*.ram",    "*.class", "*.cla", "*.dll", "*.drv", "*.ocx", "*.vbx", "*.lib", "*.ico",    "*.bmp", "*.tif", "*.tar", "*.gz", "*.tgz", "*.xl*", "*.doc", "*.vxd",    "*.pdf", "*.ps", "*.lzh", "*.pm", NULL    },    {					/* DG */    "*.ob", "*.pr", "*.dmp", "*.ps", NULL    },    { /* OSK */    "*.gz","*.Z","*.z","*.tgz","*.lhz","*.tar",	/* archivers */    "*.zip","*.ar","*.zoo","*.rpm","*.lzh",    /* object files, libraries, executables */    "*.r","*.l","*.exe", "*.dll", "*.so.*", "*.class",    /* images */    "*.gif", "*.jpg", "*.jpeg", "*.tif","*.tiff", "*.pdf", "*.ps",    "*.bmp", "*.bz2", "*.BMP","*.pcx",    NULL    }};/*  Set up default pattern lists so they can be freed and re-malloc'd.  Each pattern list must terminated by a null element.*/VOIDinitpat() {    int i;    for (i = 0; i < FTPATTERNS; i++) {        txtpatterns[i] = NULL;        binpatterns[i] = NULL;    }    for (i = 0; i < FTPATTERNS; i++) {#ifdef UNIX        makestr(&(txtpatterns[i]),txtp[SYS_UNIX][i]);#else /* UNIX */#ifdef OS2#ifdef NT        makestr(&(txtpatterns[i]),txtp[SYS_WIN32][i]);#else /* NT */        makestr(&(txtpatterns[i]),txtp[SYS_OS2][i]);#endif /* NT */#else /* OS2 */#ifdef VMS        makestr(&(txtpatterns[i]),txtp[SYS_VMS][i]);#else /* VMS */#ifdef STRATUS        makestr(&(txtpatterns[i]),txtp[SYS_VOS][i]);#else /* STRATUS */#ifdef datageneral        makestr(&(txtpatterns[i]),txtp[SYS_DG][i]);#else /* datageneral */#ifdef OSK        makestr(&(txtpatterns[i]),txtp[SYS_OSK][i]);#else /* OSK */        makestr(&(txtpatterns[i]),txtp[SYS_UNK][i]);#endif /* OSK */#endif /* datageneral */#endif /* STRATUS */#endif /* VMS */#endif /* OS2 */#endif /* UNIX */        if (!txtp[i])          break;    }    for (i = 0; i < FTPATTERNS; i++) {#ifdef UNIX        makestr(&(binpatterns[i]),binp[SYS_UNIX][i]);#else /* UNIX */#ifdef OS2#ifdef NT        makestr(&(binpatterns[i]),binp[SYS_WIN32][i]);#else /* NT */        makestr(&(binpatterns[i]),binp[SYS_OS2][i]);#endif /* NT */#else /* OS2 */#ifdef VMS        makestr(&(binpatterns[i]),binp[SYS_VMS][i]);#else /* VMS */#ifdef STRATUS        makestr(&(binpatterns[i]),binp[SYS_VOS][i]);#else /* STRATUS */#ifdef datageneral        makestr(&(binpatterns[i]),binp[SYS_DG][i]);#else /* datageneral */#ifdef OSK        makestr(&(binpatterns[i]),binp[SYS_OSK][i]);#else /* OSK */        makestr(&(binpatterns[i]),binp[SYS_UNK][i]);#endif /* OSK */#endif /* datageneral */#endif /* STRATUS */#endif /* VMS */#endif /* OS2 */#endif /* UNIX */        if (!binp[i])          break;    }}/*  m a t c h n a m e  --  Compare filename with text & binary name patterns.  Returns:    0 if name matches a text pattern but not a binary pattern.    1 if name matches a binary pattern but not a text pattern.   -1 if name matches no patterns.   -2 if name matches a binary pattern and a text pattern.*/intmatchname(filename, local, os) char * filename; int local; int os; {    int rc = -1;			/* Return code */    char * name, * p;#ifdef OS2ORUNIX    char tmpbuf[CKMAXPATH+1];#endif /* OS2ORUNIX */    name = filename ? filename : "";	/* Copy of original arg */    if (patterns && *name) {		/* If PATTERNS ON... */	int i;#ifdef OS2ORUNIX	if (ckmatch("*.~[1-9]*~",name,1,1)) { /* Name has backup suffix? */	    int k;	    k = ckstrncpy(tmpbuf,name,CKMAXPATH+1); /* Yes, copy and strip */	    for (i = k - 3; i > 4; i--) {		if (tmpbuf[i] == '~' && tmpbuf[i-1] == '.') {		    tmpbuf[i-1] = NUL;		    break;		}	    }	    name = tmpbuf;		/* And point to stripped copy */	}#endif /* OS2ORUNIX */	zstrip(name,&p);		/* Strip pathname too */	name = p;        if (local) {            if (txtpatterns[0]) {	/* Search text patterns */                for (i = 0; i < FTPATTERNS && txtpatterns[i]; i++) {                    if (ckmatch(txtpatterns[i],name,filecase,1)) {                        rc = 0;                        break;                    }                }            }            if (binpatterns[0]) {	/* And search binary patterns */                for (i = 0; i < FTPATTERNS && binpatterns[i]; i++) {                    if (ckmatch(binpatterns[i],name,filecase,1)) {                        rc = (rc > -1) ? -2 : 1;                        break;                    }                }            }	} else {            if (os >= 0 && os < SYS_MAX) {		if (txtp[os][0]) {		    for (i = 0; i < FTPATTERNS && txtp[os][i]; i++) {			if (ckmatch(txtp[os][i],name,filecase,1)) {			    rc = 0;			    break;			}		    }		}		if (binp[os][0]) {		    for (i = 0; i < FTPATTERNS && binp[os][i]; i++) {			if (ckmatch(binp[os][i],name,filecase,1)) {			    rc = (rc > -1) ? -2 : 1;			    break;			}		    }		}	    }        }    }    debug(F111,"matchname",name,rc);    return(rc);}#endif /* PATTERNS */#ifdef UNICODE#ifndef NOEVENMAX#define EVENMAX#endif /* NOEVENMAX */#endif /* UNICODE *//*  S C A N F I L E  --  Analyze a file's contents  *//*  Call with:    name:    Pointer to name of existing file.    flag:    Pointer to int in which to return additional numeric data.  Returns:    -1 on failure (to open file or to read from it).    Integer, 0..4, on success indicating file type:     0 = 7-bit text (flag = -1)     1 = UTF-8 text (flag = -1)     2 = UCS-2 text (flag =  0: big-endian; flag = 1: little-endian)     3 = 8-bit text (flag =  0: no C1 bytes; flag = 1: includes C1 bytes)     4 = binary     (flag = -1)  If UNICODE is defined:   1. If file begins with a valid BOM, it is believed.  Otherwise we      read the first 4K of the file (since it might be email with verbose      headers) and analyze it:   2. If file contains only valid UTF-8 sequences, we call it UTF-8;      otherwise:   3. If the file contains lots of alternate 0 bytes, we call it UCS-2, and      set the polarity according to whether the preponderance of them are in      even or odd positions; otherwise:   4. If EVENMAX is defined and the file contains lots of alternate bytes that      are identical, even if they aren't zero, and the number of such bytes      is at least four times the length of the maximum run of alternating      identical bytes of the opposite polarity, we call it UCS-2; otherwise:   5. If the file contained no bytes with their 8th bits on and no controls      other than CR, LF, HT, and FF, we call it ASCII; otherwise:   6. If it contains C0 control characters other than CR, LF, HT, and FF, we      call it binary; otherwise:   7. We call it 8-bit text, character set unknown (could be Latin-1 or      anything else).   Note that malformed UTF-8 is not diagnosed as UTF-8.   If UNICODE is not defined:   1. If the file contains C0 control characters other than CR, LF, HT, and      FF, we call it binary; otherwise:   2. If the file contains any 8-bit bytes, we call it 8-bit text; otherwise:   3. We call it 7-bit text.   In the non-Unicode case, UCS-2 is diagnosed as binary, but UTF-8 as   8-bit text.   There is no significant speed difference between the Unicode and

⌨️ 快捷键说明

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