📄 ckcplm.txt
字号:
Checks the file number n. Returns: -1: File number n is out of range 0: n is in range, but file is not open 1: n in range and file is open int iswild(filspec) char *filespec; Checks if the file specification is "wild", i.e. contains metacharacters or other notations intended to match multiple filenames. Returns: 0: not wild 1: wild. int isdir(string) char *string; Checks if the string is the name of an existing directory. The idea is to check whether the string can be "cd'd" to, so in some cases (e.g. DOS) it might also indicate any file structured device, such as a disk drive (like A:). Other nonzero returns indicate system-dependent information; e.g. in VMS isdir("[.FOO]") returns 1 but isdir("FOO.DIR;1") returns 2 to indicate the directory-file name is in a format that needs conversion before it can be combined with a filename. Returns: 0: not a directory (including any kind of error) 1: it is an existing directory char * zfcdat(name) char *name; Returns modification (preferably, otherwise creation) date/time of file whose name is given in the argument string. Return value is a pointer to a string of the form yyyymmdd hh:mm:ss, for example 19931231 23:59:59, which represents the local time (no timezone or daylight savings time finagling required). Returns the null string ("") on failure. The text pointed to by the string pointer might be in a static buffer, and so should be copied to a safe place by the caller before any subsequent calls to this function. struct zfnfp * zfnqfp(fn, buflen, buf) char * fn; int buflen; char * buf; Given the filename fn, the corresponding fully qualified, absolute filename is placed into the buffer buf, whose length is buflen. On failure returns a NULL pointer. On success returns a pointer to a struct zfnfp containing pointers to the full pathname and to just the filename, and an int giving the length of the full pathname. All references to this function in mainline code must be protected by #ifdef ZFNQFP..#endif, because it is not present in all of the ck*fio.c modules. So if you implement this function in a version that did not have it before, be sure to add #define ZFNQFP in the appropriate spot in ckcdeb.h or in the build-procedure CFLAGS. int zcmpfn(s1,s2) char * s2, * s2; Compares two filenames to see if they refer to the same. Internally, the arguments can be converted to fully qualified pathnames, e.g. with zfnqfp(), realpath(), or somesuch. In Unix or other systems where symbolic links exist, the link should be resolved before making the comparison or looking at the inodes. Returns: 0: Files are not identical. 1: Files are identical. int zfseek(pos) long pos; Positions the input pointer on the current input file to the given position. The pos argument is 0-based, the offset (distance in bytes) from beginning of the file. Needed for RESEND, PSEND, and other recovery operations. This function is not necessarily possible on all systems, e.g. record-oriented systems. It should only be used on binary files (i.e. files we are sending in binary mode) and stream-oriented file systems. Returns: -1: on failure. 0: On success. int zchdir(dirnam) char *dirnam; Changes current or default directory to the one given in dirnam. Returns: 0: On failure. 1: on success. long zchki(fn) char *fn; Check to see if file with name fn is a regular, readable, existing file, suitable for Kermit to send -- not a directory, not a symbolic link, etc. Returns: -3: if file exists but is not accessible (e.g. read-protected); -2: if file exists but is not of a readable type (e.g. a directory); -1: on error (e.g. file does not exist, or fn is garbage); >=0: (length of file) if file exists and is readable. Also see isdir(), zgetfs(). int zchkpid(pid) unsigned long pid; Returns: 1: If the given process ID (e.g. pid in UNIX) is valid and active 0: otherwise. long zgetfs(fn) char *fn; Gets the size of the given file, regardless of accessibility. Used for directory listings. Unlike zchki(), should return the size of any kind of file, even a directory. zgetfs() also should serve as a mini "get file info" function that can be used until we design a better one, by also setting some global variables: int zgfs_link = 1/0 = file is (not) a symbolic link. int zgfs_dir = 1/0 = file is (not) a directory. char linkname[] = if zgfs_link != 0, name of file link points to. Returns: -1: on error (e.g. file does not exist, or fn is garbage); >=0: (length of file) if file exists and is readable. int zchko(fn) char *fn; Checks to see if a file of the given name can be created. Returns: -1: if file cannot be created, or on any kind of error. 0: if file can be created. int zchkspa(fn,len) char *f; long len; Checks to see if there is sufficient space to store the file named fn, which is len bytes long. If you can't write a function to do this, then just make a dummy that always returns 1; higher level code will recover from disk-full errors. The receiving Kermit uses this function to refuse an incoming file based on its size, via the attribute mechanism. Returns: -1: on error. 0: if there is not enough space. 1: if there is enough space. int zchin(n,c) int n; int *c; Gets a character from file number n, return it in c (call with &c). Returns: -1: on failure, including EOF. 0: on success with character in c. int zchout(n,c) int n; char c; Writes the character c to file number n. Returns: -1: on error. 0: on success. int zclose(n) int n; Closes file number n. Returns: -1: on error. 1: on success. int zdelet(fn) char *name; Attempts to delete (remove, erase) the named file. Returns: -1: on error. 1: if file was deleted successfully. char * zgperm(char * f) Returns a pointer to the system-dependent numeric permissions/protection string for file f, or NULL upon failure. Used if CK_PERMS is defined. char * ziperm(char * f) Returns a pointer to the system-dependent symbolic permissions/protection string for file f, or NULL upon failure. Used if CK_PERMS is defined. Example: In UNIX zgperm(f) might return "100770", but ziperm() might return "-rwxrwx---". In VMS, zgperm() would return a hexadecimal string, but ziperm() would return something like "(RWED,RWED,RE,)". char * zgtdir() Returns a pointer to the name of the current directory, folder, etc, or a NULL pointer if the current directory cannot be determined. If possible, the directory specification should be (a) fully specified, e.g. as a complete pathname, and (b) be suitable for appending a filename. Thus, for example, Unix directory names should end with '/'. VMS directory names should look like DEV:[NAME] (rather than, say, NAME.DIR;1). char * zhome() Returns a pointer to a string containing the user's home directory, or NULL upon error. Should be formatted like zgtdir() (q.v.). int zinfill() Fill buffer from input file. This function is used by the macro zminchar(), which is defined in ckcker.h. zminchar() manages its own buffer, and calls zinfill() to fill it whenever it becomes empty. It is used only for sending files, and reads characters only from file number ZIFILE. zinfill() returns -1 upon end of file, -2 upon fatal error, and -3 upon timeout (e.g. when reading from a pipe); otherwise it returns the first character from the buffer it just read. int zkself() Kills the current job, session, process, etc, logs out, disappears. Used by the Kermit server when it receives a BYE command. On failure, returns -1. On success, does not return at all! This function should not be called until all other steps have been taken to close files, etc. VOID zstrip(fn,&fn2) char *fn1, **fn2; Strips device and directory, etc, from file specification fn, leaving only the filename (including "extension" or "filetype" -- the part after the dot). For example DUA0:[PROGRAMS]OOFA.C;3 becomes OOFA.C, or /usr/fdc/oofa.c becomes oofa.c. Returns a pointer to result in fn2. int zsetperm(char * file, unsigned int code) Set permissions of file to given system-dependent code. 0: On failure. 1: on success. int zsetroot(char * dir) Sets the root for the user's file access, like Unix chroot(), but does not require privilege. In Unix, this must be implemented entirely by Kermit's own file access routines. Returns: 1: Success -1: Invalid argument -2: -3: Internal error -4: Access to given directory denied -5: New root not within old root int zinroot(char * file) If no root is set (zsetroot()), returns 1. Otherwise, if given file is in the root, returns 1. Otherwise, returns 0. VOID zltor(fn,fn2) char *fn1, *fn2; Local-To-Remote filename translation. OBSOLETE: replaced by nzltor() (q.v.). Translates the local filename fn into a format suitable for transmission to an arbitrary type of computer, and copies the result into the buffer pointed to by fn2. Translation may involve (a) stripping the device and/or directory/path name, (b) converting lowercase to uppercase, (c) removing spaces and strange characters, or converting them to some innocuous alphabetic character like X, (d) discarding or converting extra periods (there should not be more than one). Does its best. Returns no value. name2 is a pointer to a buffer, furnished by the caller, into which zltor() writes the resulting name. No length checking is done. #ifdef NZLTOR VOID nzltor(fn,fn2,convert,pathnames,max) char *fn1,*fn2; int convert,pathnames,max; Replaces zltor(). This new version handles pathnames and checks length. fn1 and fn2 are as in zltor(). This version is called unconditionally for each file, rather than only when filename conversion is enabled. Pathnames can have the following values: PATH_OFF: Pathname, if any, is to be stripped PATH_REL: The relative pathname is to be included PATH_ABS: The full pathname is to be included After handling pathnames, conversion is done to the result as in the zltor() description if convert != 0; if relative or absolute pathnames are included, they are converted to UNIX format, i.e. with slash (/) as the directory separator. The max parameter specifies the maximum size o
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -