📄 ckcplm.txt
字号:
f = pointer to name of existing file. yy = pointer to a Kermit file attribute structure in which yy->date.val is a date of the form yyyymmdd hh:mm:ss, e.g. 19900208 13:00:00, which is to be used for setting or comparing the date. Other attributes in the struct can also be set, such as the protection/permission (See Appendix I), when it makes sense (e.g. "yy->lprotect.val" can be set if the remote system ID matches the local one). x = is a function code: 0 means to set the file's creation date as given. 1 means compare the date from the yy struct with the file's date. Returns: -1 on any kind of error. 0 if x is 0 and the file date was set successfully. 0 if x is 1 and date from attribute structure > file creation date. 1 if x is 1 and date from attribute structure <= file creation date.VOIDzstrip(name,name2) char *name, **name2; Strips pathname from filename "name". Constructs the resulting string in a static buffer in its own space and returns a pointer to it in name2. Also strips device name, file version numbers, and other "non-name" material.(zxcmd - arguments are new, writing to a command is new)intzxcmd(n,s) char *s; Runs a system command so its output can be accessed as if it were file n. The command is run in ordinary, unprivileged user mode. If n is ZSTDIO or ZCTERM, returns -1. If n is ZIFILE or ZRFILE, then Kermit reads from the command, otherwise Kermit writes to the command. Returns 0 on error, 1 on success.intzxpand(fn) char *fn; OBSOLETE! Replaced by nzxpand(), q.v.intzxrewind() Returns the number of files returned by the most recent zxpand call, and resets the list to the beginning so the next znext() call returns the first file. Returns -1 if zxpand has not yet been called. If this function is available, ZXREWIND should be defined; otherwise it should not be referenced.intxsystem(cmd) char *cmd; Executes the system command without redirecting any of its i/o, similar (well, identical) to system() in Unix. But before passing the command to the system, xsystem() ensures that all privileges are turned off, so that the system command will execute in ordinary unprivileged user mode.B.1.2 IKSD FunctionsThese must be implemented in any C-Kermit version that is to be installed asan Internet Kermit Service Daemon (IKSD). IKSD is expected to be started bythe Internet Daemon (e.g. inetd) with its standard i/o redirected to theincoming connection.int ckxanon; Nonzero if anonymous logins allowed.extern int inserver; Nonzero if started in IKSD mode.extern int isguest; Nonzero if IKSD and user logged in anonymously.extern char * homdir; Pointer to user's home directory.extern char * anonroot; Pointer to file-system root for anonymous users.Existing functions must make "if (inserver && isguest)" checks for actionsthat would not be legal for guests: zdelete(), zrmdir(), zprint(), zmail(),etc.intzvuser(name) char * name; Verifies that user "name" exists and is allowed to log in. If the name is "ftp" or "anonymous" and ckxanon != 0, a guest login is set up. Returns 0 if user not allowed to log in, nonzero if user may log in.zvpass(string) char * string; Verifies password of the user from the most recent zvuser() call. Returns nonzero if password is valid for user, 0 if it isn't. Makes any appropriate system log entries (IKSD logins, failed login attempts, etc). If password is valid, logs the user in as herself (if real user), or sets up restricted anonymous access if user is guest (e.g. changes file-system root to anonroot and sets isguest = 1).voidzsyslog() Begins any desired system logging of an IKSD session.voidzvlogout() Terminates an IKSD session. In most cases this is simply a wrapper for exit() or doexit(), with some system logging added.B.1.3 Security/Privilege Functions (all)These functions are used by C-Kermit to adapt itself to operating systemswhere the program can be made to run in a "privileged" mode. C-Kermitshould NOT read and write files or start subprocesses as a privileged program.This would present a serious threat to system security. The security packagehas been installed to prevent such security breaches by turning off theprogram's special privileges at all times except when they are needed.In UNIX, the only need Kermit has for privileged status is access to the UUCPlockfile directory, in order to read, create, and destroy lockfiles, and toopen communication devices that are normally protected against the user.Therefore, privileges should only be enabled for these operations and disabledat all other times. This relieves the programmer of the responsibility ofputting expensive and unreliable access checks around every file access andsubprocess creation.Strictly speaking, these functions are not required in all C-Kermitimplementations, because their use (so far, at least) is internal to the group3 modules. However, they should be included in all C-Kermit implementationsfor operating systems that support the notion of a privileged program (UNIX,RSTS/E, what else?).intpriv_ini() Determine whether the program is running in privileged status. If so, turn off the privileges, in such a way that they can be turned on again when needed. Called from sysinit() at program startup time. Returns: 0 on success nonzero on failure, in which case the program should halt immediately.intpriv_on() If the program is not privileged, this function does nothing. If the program is privileged, this function returns it to privileged status. priv_ini() must have been called first. Returns: 0 on success nonzero on failureintpriv_off() Turns privileges off (if they are on) in such a way that they can be turned back on again. Returns: 0 on success nonzero on failureintpriv_can() Turns privileges off in such a way that they cannot be turned back on. Returns: 0 on success nonzero on failureintpriv_chk() Attempts to turns privileges off in such a way that they can be turned on again later. Then checks to make sure that they were really turned off. If they were not really turned off, then they are cancelled permanently. Returns: 0 on success nonzero on failureB.2. Console-Related Functions.These relate to the program's "console", or controlling terminal, i.e. theterminal that the user is logged in on and types commands at, or on a PC orworkstation, the actual keyboard and screen.intconbin(esc) char esc; Puts the console into "binary" mode, so that Kermit's command parser can control echoing and other treatment of characters that the user types. esc is the character that will be used to get Kermit's attention during packet mode; puts this in a global place. Sets the ckxech variable. Returns: -1 on error. 0 on success.intconcb(esc) char esc; Put console in "cbreak" (single-character wakeup) mode. That is, ensure that each console character is available to the program immediately when the user types it. Otherwise just like conbin(). Returns: -1 on error. 0 on success.intconchk() Returns a number, 0 or greater, the number of characters waiting to be read from the console, i.e. the number of characters that the user has typed that have not been read yet.longcongspd(); Returns the speed ("baud rate") of the controlling terminal, if known, otherwise -1L.intcongks(timo) int timo; Get Keyboard Scancode. Reads a keyboard scan code from the physical console keyboard. If the timo parameter is greater than zero, then times out and returns -2 if no character appears within the given number of seconds. Upon any other kind of error, returns -1. Upon success returns a scan code, which may be any positive integer. For situations where scan codes cannot be read (for example, when an ASCII terminal is used as the job's controlling terminal), this function is identical to coninc(), i.e. it returns an 8-bit character value. congks() is for use with workstations whose keyboards have Alternate, Command, Option, and similar modifier keys, and Function keys that generate codes greater than 255.intcongm() Console get modes. Gets the current console terminal modes and saves them so that conres() can restore them later. Returns 1 if it got the modes OK, 0 if it did nothing (e.g. because Kermit is not connected with any terminal), -1 on error.intconinc(timo) int timo; Console Input Character. Reads a character from the console. If the timo parameter is greater than zero, then coninc() times out and returns -2 if no character appears within the given number of seconds. Upon any other kind of error, returns -1. Upon success, returns the character itself, with a value in the range 0-255 decimal.VOIDconint(f,s) SIGTYP (*f)(), (*s)(); Sets the console to generate an interrupt if the user types a keyboard interrupt character, and to transfer control the signal-handling function f. For systems with job control, s is the address of the function that suspends the job. Sets the global variable "backgrd" to zero if Kermit is running in the foreground, and to nonzero if Kermit is running in the background. See ckcdeb.h for the definition of SIGTYP. No return value.VOIDconnoi() Console no interrupts. Disable keyboard interrupts on the console. No return value.intconoc(c) char c; Write character c to the console terminal. Returns: 0 on failure, 1 on success.intconol(s) char *s; Write string s to the console. Returns -1 on error, 0 or greater on success.intconola(s) char *s[]; { Write an array of strings to the console. Returns -1 on error, 0 or greater on success.intconoll(s) char *s; Write string s to the console, followed by the necessary line termination characters to put the console cursor at the beginning of the next line. Returns -1 on error, 0 or greater on success.intconres() Restore the console terminal to the modes obtained by congm(). Returns: -1 on error, 0 on success.intconxo(x,s) int x; char *s; Write x characters from string s to the console. Returns 0 or greater on success, -1 on error.char *conkbg(); Returns a pointer to the designator of the console keyboard type. For example, on a PC, this function would return "88", "101", etc. Upon failure, returns a pointer to the empty string.B.3 - Communication Device FunctionsThe communication device is the device used for terminal emulation and filetransfer. It may or may not be the same device as the console, and it mayor may not be a terminal device (it could also be a network device). Forbrevity, the communication device is referred to here as the "tty". When thecommunication device is the same as the console device, Kermit is said to bein remote mode. When the two devices are different, Kermit is in local mode.intttchk() Returns the number of characters that have arrived at the communication device but have not yet been read by ttinc(), ttinl(), and friends. If communication input is buffered (and it should be), this is the sum of the number of unread characters in Kermit's buffer PLUS the number of unread characters in the operating system's internal buffer. The call must be nondestructive and nonblocking, and as inexpensive as possible. Returns: 0 or greater on success, 0 in case of internal error, -1 or less when it determines the connection has been broken, or there is no connection. That is, a negative return from ttchk() should reliably indicate that there is no usable connection. Furthermore, ttchk
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -