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

📄 ckufio.c

📁 KERMIT工具 这在办公室下载不了,很多人都没有载不到.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* C K U F I O  --  Kermit file system support for UNIX, Aegis, and Plan 9 */#define CK_NONBLOCK                     /* See zoutdump() */#ifdef aegischar *ckzv = "Aegis File support, 8.0.200, 4 Mar 2004";#else#ifdef Plan9char *ckzv = "Plan 9 File support, 8.0.200, 4 Mar 2004";#elsechar *ckzv = "UNIX File support, 8.0.200, 4 Mar 2004";#endif /* Plan9 */#endif /* aegis *//*  Author: Frank da Cruz <fdc@columbia.edu>,  Columbia University Academic Information Systems, New York City,  and others noted in the comments below.  Note: CUCCA = Previous name of  Columbia University Academic Information Systems.  Copyright (C) 1985, 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.*//*  NOTE TO CONTRIBUTORS: This file, and all the other C-Kermit files, must be  compatible with C preprocessors that support only #ifdef, #else, #endif,  #define, and #undef.  Please do not use #if, logical operators, or other  preprocessor features in any of the portable C-Kermit modules.  You can,  of course, use these constructions in platform-specific modules where you  know they are supported.*//* Include Files */#ifdef MINIX2#define _MINIX#endif /* MINIX2 */#include "ckcsym.h"#include "ckcdeb.h"#include "ckcasc.h"#ifndef NOCSETS#include "ckcxla.h"#endif /* NOCSETS */#ifdef COMMENT/* This causes trouble in C-Kermit 8.0.  I don't remember the original *//* reason for this being here but it must have been needed at the time... */#ifdef OSF13#ifdef CK_ANSIC#ifdef _NO_PROTO#undef _NO_PROTO#endif /* _NO_PROTO */#endif /* CK_ANSIC */#endif /* OSF13 */#endif /* COMMENT */#include <errno.h>#include <signal.h>#ifdef MINIX2#undef MINIX#undef CKSYSLOG#include <limits.h>#include <time.h>#define NOFILEH#endif /* MINIX2 */#ifdef MINIX#include <limits.h>#include <sys/types.h>#include <time.h>#else#ifdef POSIX#include <limits.h>#else#ifdef SVR3#include <limits.h>#endif /* SVR3 */#endif /* POSIX */#endif /* MINIX *//*  Directory Separator macros, to allow this module to work with both UNIX and  OS/2: Because of ambiguity with the command line editor escape \ character,  the directory separator is currently left as / for OS/2 too, because the  OS/2 kernel also accepts / as directory separator.  But this is subject to  change in future versions to conform to the normal OS/2 style.*/#ifndef DIRSEP#define DIRSEP       '/'#endif /* DIRSEP */#ifndef ISDIRSEP#define ISDIRSEP(c)  ((c)=='/')#endif /* ISDIRSEP */#ifdef SDIRENT#define DIRENT#endif /* SDIRENT */#ifdef XNDIR#include <sys/ndir.h>#else /* !XNDIR */#ifdef NDIR#include <ndir.h>#else /* !NDIR, !XNDIR */#ifdef RTU#include "/usr/lib/ndir.h"#else /* !RTU, !NDIR, !XNDIR */#ifdef DIRENT#ifdef SDIRENT#include <sys/dirent.h>#else#include <dirent.h>#endif /* SDIRENT */#else#include <sys/dir.h>#endif /* DIRENT */#endif /* RTU */#endif /* NDIR */#endif /* XNDIR */#ifdef UNIX                             /* Pointer arg to wait() allowed */#define CK_CHILD                        /* Assume this is safe in all UNIX */#endif /* UNIX */extern int binary, recursive, stathack;#ifdef CK_CTRLZextern int eofmethod;#endif /* CK_CTRLZ */#include <pwd.h>                        /* Password file for shell name */#ifdef CK_SRP#include <t_pwd.h>                      /* SRP Password file */#endif /* CK_SRP */#ifdef HPUX10_TRUSTED#include <hpsecurity.h>#include <prot.h>#endif /* HPUX10_TRUSTED */#ifdef COMMENT/* Moved to ckcdeb.h */#ifdef POSIX#define UTIMEH#else#ifdef HPUX9#define UTIMEH#endif /* HPUX9 */#endif /* POSIX */#endif /* COMMENT */#ifdef SYSUTIMEH                        /* <sys/utime.h> if requested,  */#include <sys/utime.h>                  /* for extra fields required by */#else                                   /* 88Open spec. */#ifdef UTIMEH                           /* or <utime.h> if requested */#include <utime.h>                      /* (SVR4, POSIX) */#ifndef BSD44#ifndef V7/* Not sure why this is here.  What it implies is that the code bracketed   by SYSUTIMEH is valid on all platforms on which we support time    functionality.  But we know that is not true because the BSD44 and V7   platforms do not support sys/utime.h and the data structures which   are defined in them.  Now this worked before because prior to today's   changes the UTIMEH definition for BSD44 and V7 did not take place   until after SYSUTIMEH was defined.  It also would not have been a    problem if the ordering of all the time blocks was consistent.  All but   one of the blocks were BSD44, V7, SYSUTIMEH, <OTHER>.  That one case   is where this problem was triggered.*/#define SYSUTIMEH                       /* Use this for both cases. */#endif /* V7 */#endif /* BSD44 */#endif /* UTIMEH */#endif /* SYSUTIMEH */#ifndef NOTIMESTAMP#ifdef POSIX#ifndef AS400#define TIMESTAMP#endif /* AS400 */#endif /* POSIX */#ifdef BSD44                            /* BSD 4.4 */#ifndef TIMESTAMP#define TIMESTAMP                       /* Can do file dates */#endif /* TIMESTAMP */#include <sys/time.h>#include <sys/timeb.h>#else  /* Not BSD44 */#ifdef BSD4                             /* BSD 4.3 and below */#define TIMESTAMP                       /* Can do file dates */#include <time.h>                       /* Need this */#include <sys/timeb.h>                  /* Need this if really BSD */#else  /* Not BSD 4.3 and below */#ifdef SVORPOSIX                        /* System V or POSIX */#ifndef TIMESTAMP#define TIMESTAMP#endif /* TIMESTAMP */#include <time.h>/* void tzset(); (the "void" type upsets some compilers) */#ifndef IRIX60#ifndef ultrix#ifndef CONVEX9/* ConvexOS 9.0, supposedly POSIX, has extern char *timezone(int,int) */#ifndef Plan9extern long timezone;#endif /* Plan9 */#endif /* CONVEX9 */#endif /* ultrix */#endif /* IRIX60 */#endif /* SVORPOSIX */#endif /* BSD4 */#endif /* BSD44 */#ifdef COHERENT#include <time.h>#endif /* COHERENT *//* Is `y' a leap year? */#define leap(y) (((y) % 4 == 0 && (y) % 100 != 0) || (y) % 400 == 0)/* Number of leap years from 1970 to `y' (not including `y' itself). */#define nleap(y) (((y) - 1969) / 4 - ((y) - 1901) / 100 + ((y) - 1601) / 400)#endif /* NOTIMESTAMP */#ifdef CIE#include <stat.h>                       /* File status */#else#include <sys/stat.h>#endif /* CIE *//* Macro to alleviate isdir() calls internal to this module */static struct stat STATBUF;#define xisdir(a) ((stat(a,&STATBUF)==-1)?0:(S_ISDIR(STATBUF.st_mode)?1:0))extern char uidbuf[];extern int xferlog;extern char * xferfile;int iklogopen = 0;static time_t timenow;#define IKSDMSGLEN CKMAXPATH+512static char iksdmsg[IKSDMSGLEN];extern int local;extern int server, en_mkd, en_cwd, en_del;/*  Functions (n is one of the predefined file numbers from ckcker.h):   zopeni(n,name)   -- Opens an existing file for input.   zopeno(n,name,attr,fcb) -- Opens a new file for output.   zclose(n)        -- Closes a file.   zchin(n,&c)      -- Gets the next character from an input file.   zsinl(n,&s,x)    -- Read a line from file n, max len x, into address s.   zsout(n,s)       -- Write a null-terminated string to output file, buffered.   zsoutl(n,s)      -- Like zsout, but appends a line terminator.   zsoutx(n,s,x)    -- Write x characters to output file, unbuffered.   zchout(n,c)      -- Add a character to an output file, unbuffered.   zchki(name)      -- Check if named file exists and is readable, return size.   zchko(name)      -- Check if named file can be created.   zchkspa(name,n)  -- Check if n bytes available to create new file, name.   znewn(name,s)    -- Make a new unique file name based on the given name.   zdelet(name)     -- Delete the named file.   zxpand(string)   -- Expands the given wildcard string into a list of files.   znext(string)    -- Returns the next file from the list in "string".   zxrewind()       -- Rewind zxpand list.   zxcmd(n,cmd)     -- Execute the command in a lower fork on file number n.   zclosf()         -- Close input file associated with zxcmd()'s lower fork.   zrtol(n1,n2)     -- Convert remote filename into local form.   zltor(n1,n2)     -- Convert local filename into remote form.   zchdir(dirnam)   -- Change working directory.   zhome()          -- Return pointer to home directory name string.   zkself()         -- Kill self, log out own job.   zsattr(struct zattr *) -- Return attributes for file which is being sent.   zstime(f, struct zattr *, x) - Set file creation date from attribute packet.   zrename(old, new) -- Rename a file.   zcopy(source,destination) -- Copy a file.   zmkdir(path)       -- Create the directory path if possible   zfnqfp(fname,len,fullpath) - Determine full path for file name.   zgetfs(name)     -- return file size regardless of accessibility   zchkpid(pid)     -- tell if PID is valid and active*//* Kermit-specific includes *//*  Definitions here supersede those from system include files.  ckcdeb.h is included above.*/#include "ckcker.h"                     /* Kermit definitions */#include "ckucmd.h"                     /* For keyword tables */#include "ckuver.h"                     /* Version herald */char *ckzsys = HERALD;/*  File access checking ...  There are two calls to access() in this module.  If this program is installed setuid or setgid on a Berkeley-based UNIX  system that does NOT incorporate the saved-original-effective-uid/gid  feature, then, when we have swapped the effective and original uid/gid,  access() fails because it uses what it thinks are the REAL ids, but we have  swapped them.  This occurs on systems where ANYBSD is defined, NOSETREU  is NOT defined, and SAVEDUID is NOT defined.  So, in theory, we should take  care of this situation like so:    ifdef ANYBSD    ifndef NOSETREU    ifndef SAVEDUID    define SW_ACC_ID    endif    endif    endif  But we can't test such a general scheme everywhere, so let's only do this  when we know we have to...*/#ifdef NEXT                             /* NeXTSTEP 1.0-3.0 */#define SW_ACC_ID#endif /* NEXT *//* Support for tilde-expansion in file and directory names */#ifdef POSIX#define NAMEENV "LOGNAME"#else#ifdef BSD4#define NAMEENV "USER"#else#ifdef ATTSV#define NAMEENV "LOGNAME"#endif /* ATTSV */#endif /* BSD4 */#endif /* POSIX *//* Berkeley Unix Version 4.x *//* 4.1bsd support from Charles E Brooks, EDN-VAX */#ifdef BSD4#ifdef MAXNAMLEN#define BSD42#endif /* MAXNAMLEN */#endif /* BSD4 *//* Definitions of some system commands */char *DELCMD = "rm -f ";                /* For file deletion */char *CPYCMD = "cp ";                   /* For file copy */char *RENCMD = "mv ";                   /* For file rename */char *PWDCMD = "pwd ";                  /* For saying where I am */#ifdef COMMENT#ifdef HPUX10char *DIRCMD = "/usr/bin/ls -l ";       /* For directory listing */char *DIRCM2 = "/usr/bin/ls -l ";       /* For directory listing, no args */#elsechar *DIRCMD = "/bin/ls -l ";           /* For directory listing */char *DIRCM2 = "/bin/ls -l ";           /* For directory listing, no args */#endif /* HPUX10 */#elsechar *DIRCMD = "ls -l ";                /* For directory listing */char *DIRCM2 = "ls -l ";                /* For directory listing, no args */#endif /* COMMENT */char *TYPCMD = "cat ";                  /* For typing a file */#ifdef HPUXchar *MAILCMD = "mailx";                /* For sending mail */#else#ifdef DGUX540char *MAILCMD = "mailx";#else#ifdef UNIX#ifdef CK_MAILCMDchar *MAILCMD = CK_MAILCMD;		/* CFLAGS override */#elsechar *MAILCMD = "Mail";			/* Default */#endif /* CK_MAILCMD */#elsechar *MAILCMD = "";#endif /* UNIX */#endif /* HPUX */#endif /* DGUX40 */#ifdef UNIX#ifdef ANYBSD                           /* BSD uses lpr to spool */#ifdef DGUX540                          /* And DG/UX */char * PRINTCMD = "lp";#elsechar * PRINTCMD = "lpr";#endif /* DGUX540 */#else                                   /* Sys V uses lp */#ifdef TRS16                            /* except for Tandy-16/6000... */char * PRINTCMD = "lpr";#elsechar * PRINTCMD = "lp";#endif /* TRS16 */#endif /* ANYBSD */#else  /* Not UNIX */#define PRINTCMD ""#endif /* UNIX */#ifdef FT18                             /* Fortune For:Pro 1.8 */#undef BSD4#endif /* FT18 */#ifdef BSD4char *SPACMD = "pwd ; df .";            /* Space in current directory */#else#ifdef FT18char *SPACMD = "pwd ; du ; df .";#elsechar *SPACMD = "df ";#endif /* FT18 */#endif /* BSD4 */char *SPACM2 = "df ";                   /* For space in specified directory */#ifdef FT18#define BSD4#endif /* FT18 */#ifdef BSD4char *WHOCMD = "finger ";#elsechar *WHOCMD = "who ";#endif /* BSD4 *//* More system-dependent includes, which depend on symbols defined *//* in the Kermit-specific includes.  Oh what a tangled web we weave... */#ifdef COHERENT                         /* <sys/file.h> */#define NOFILEH#endif /* COHERENT */#ifdef MINIX#define NOFILEH#endif /* MINIX */#ifdef aegis#define NOFILEH#endif /* aegis */#ifdef unos#define NOFILEH#endif /* unos */

⌨️ 快捷键说明

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