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

📄 ckufio.c

📁 linux终端仿真程序
💻 C
📖 第 1 页 / 共 5 页
字号:
#ifdef OS2#ifdef NTchar *ckzv = "Win32 File support, 6.0.115 19 Nov 96";#else /* NT */char *ckzv = "OS/2 File support, 6.0.115 19 Nov 96";#endif /* NT */#else#ifdef aegischar *ckzv = "Aegis File support, 6.0.115 6 Sep 96";#else#ifdef Plan9char *ckzv = "Plan 9 File support, 6.0.115 6 Sep 96";#elsechar *ckzv = "UNIX File support, 6.0.115 6 Sep 96";#endif /* Plan9 */#endif /* aegis */#endif /* OS2 *//* C K U F I O  --  Kermit file system support for UNIX, OS/2, and Aegis *//*  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 system-specific modules when you they  are supported.*//*  Author: Frank da Cruz (fdc@columbia.edu),  Columbia University Academic Information Systems, New York City,  and others noted below.  Copyright (C) 1985, 1996, Trustees of Columbia University in the City of New  York.  All rights reserved.*//* Include Files */#include "ckcsym.h"#include "ckcdeb.h"#include "ckcasc.h"#ifdef OS2#include "ckuusr.h"#include <stdio.h>_PROTOTYP( int os2settitle, (char *, int) );extern int priority;#ifdef NT#define timezone _timezone#define write _write#define fileno _fileno#ifndef SEM_INDEFINITE_WAIT#define SEM_INDEFINITE_WAIT INFINITE#endif /* SEM_INDEFINITE_WAIT */#endif /* NT */#endif /* OS2 */#include <signal.h>#ifdef MINIX#include <limits.h>#else#ifdef POSIX#include <limits.h>#else#ifdef SVR3#include <limits.h>#endif /* SVR3 */#endif /* POSIX */#endif /* MINIX *//* Directory structure header file */#ifdef OS2/*  C-Kermit's OS/2 support originally by Chris Adie <C.Adie@uk.ac.edinburgh>  Edinburgh University Computing Service, Scotland, for C-Kermit 4F.  Adapted  to C-Kermit 5A and integrated into the UNIX support module by Kai Uwe Rommel  <rommel@informatik.tu-muenchen.de>, Muenchen, Germany, December 1991.*//*  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.*/#define DIRSEP       '/'/* #define DIRSEP       '\\' */#define ISDIRSEP(c)  ((c)=='/'||(c)=='\\')#else /* not OS2 */#define DIRSEP       '/'#define ISDIRSEP(c)  ((c)=='/')#endif /* OS2 */#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#ifdef OS2#define OPENDIR#define DIRENT#include "ckodir.h"#else/* !RTU, !NDIR, !XNDIR, !DIRENT, !OS2, i.e. all others */#include <sys/dir.h>#endif /* OS2 */#endif /* DIRENT */#endif /* RTU */#endif /* NDIR */#endif /* XNDIR */#ifdef OS2				/* OS/2 file system interface */#define BSD4				/* is like Berkeley UNIX */#define NOFILEH				/* with no <file.h> */#include <sys/utime.h>#include <stdlib.h>#include <process.h>#include <share.h>extern int binary;			/* We need to know this for open() */extern int fncact;			/* Need this for zchkspa()         */extern int tlevel, cmdlvl ;		/* Need this for external commands */#ifdef __IBMC__extern FILE *popen(char *, char *);extern int pclose(FILE *);#else#ifndef __EMX__#define popen    _popen#define pclose   _pclose#define fopen(n, m)  _fsopen(n, m, SH_DENYWR)#endif /* __EMX__ */#endif /* __IBMC__ */#ifdef NT#include <io.h>#endif /* NT */#else /* OS2 */#include <pwd.h>			/* Password file for shell name */#endif /* OS2 */#ifdef POSIX#define UTIMEH#endif /* POSIX */#ifndef OS2#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) */#define SYSUTIMEH			/* Use this for both cases. */#endif /* UTIMEH */#endif /* SYSUTIMEH */#endif /* OS2 */#ifdef POSIX#define TIMESTAMP#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 *//* 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)#ifdef CIE#include <stat.h>			/* File status */#else#include <sys/stat.h>#ifdef OS2#include <sys/types.h>/* Because standard stat has trouble with trailing /'s we have to wrap it */#ifdef NTint os2stat(char *, struct _stat *);#else /* NT */int os2stat(char *, struct stat *);#endif /* NT */#ifdef __IBMC__#ifdef system#undef system#endif#ifdef stat#undef stat#define __IBMC__STAT#endif#endif#define stat(path, buf) os2stat(path, buf)#endif /* OS2 */#endif /* CIE *//*  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".   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.*//* 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 sys-dependent 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"#endif /* POSIX */#ifdef BSD4#define NAMEENV "USER"#endif /* BSD4 */#ifdef ATTSV#define NAMEENV "LOGNAME"#endif /* ATTSV *//* 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 */#ifdef OS2char *CPYCMD = "copy ";         /* For file copy */char *DELCMD = "del ";			/* For file deletion */char *RENCMD = "rename ";       /* For file rename */char *PWDCMD = "chdir ";		/* For saying where I am */char *TYPCMD = "type ";			/* For typing a file */char *DIRCMD = "dir ";			/* For directory listing */char *DIRCM2 = "dir ";			/* For directory listing, no args */#ifdef NTchar *WHOCMD = "@echo  Kermit 95 Server"; /* Who's there? */#else /* NT */char *WHOCMD = "@echo  K/2 Server"; /* Who's there? */#endif /* NT */char *SPACMD = "dir | find \"bytes free\""; /* For space on disk */char *SPACM2 = "dir | find \"bytes free\""; /* For space on disk */#else /* Not OS2, ergo UNIX (or Aegis) */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 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 */#endif /* OS2 */#ifdef DTILDE				/* For tilde expansion */_PROTOTYP( char * tilde_expand, (char *) );#endif /* DTILDE *//* 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 */#ifndef NOFILEH#include <sys/file.h>#endif /* NOFILEH */#ifndef is68k				/* Whether to include <fcntl.h> */#ifndef BSD41				/* All but a couple UNIXes have it. */#ifndef FT18#ifndef COHERENT#include <fcntl.h>#endif /* COHERENT */#endif /* FT18  */#endif /* BSD41 */#endif /* not is68k */#ifdef COHERENT#ifdef _I386#include <fcntl.h>#else#include <sys/fcntl.h>#endif /* _I386 */#endif /* COHERENT *//*  Change argument to "(const char *)" if this causes trouble.  Or... if it causes trouble, then maybe it was already declared   in a header file after all, so you can remove this prototype.*/#ifndef NDGPWNAM /* If not defined No Declare getpwnam... */#ifndef _POSIX_SOURCE#ifndef NEXT#ifndef SVR4/* POSIX <pwd.h> already gave prototypes for these. */#ifdef IRIX40_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef IRIX51_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef M_UNIX_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef HPUX9_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef HPUX10_PROTOTYP( struct passwd * getpwnam, (const char *) );#else#ifdef DCGPWNAM_PROTOTYP( struct passwd * getpwnam, (const char *) );#else_PROTOTYP( struct passwd * getpwnam, (char *) );#endif /* DCGPWNAM */#endif /* HPUX10 */#endif /* HPUX9 */#endif /* M_UNIX */#endif /* IRIX51 */#endif /* IRIX40 */#ifndef SUNOS4#ifndef HPUX9#ifndef HPUX10#ifndef _SCO_DS_PROTOTYP( struct passwd * getpwuid, (PWID_T) );#endif /* _SCO_DS */#endif /* HPUX10 */#endif /* HPUX9 */#endif /* SUNOS4 */_PROTOTYP( struct passwd * getpwent, (void) );#endif /* SVR4 */#endif /* NEXT */#endif /* _POSIX_SOURCE */

⌨️ 快捷键说明

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