Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
ftp
Description
A simple FTP client library.
Author
Requirements
None
Documentation
Errors triggered by invalid or negative replies from the FTP server are signalled by raising a compund condition of the kinds exn and ftp. The error code of a ftp condition can be accessed with the code property.
This extension provides the ftp module.
ftp:connect
[procedure] (ftp:connect HOSTNAME USERNAME PASSWORD [VERBOSE [PORT]])Connects to the server HOSTNAME using the FTP protocol and identifies this client with USERNAME with a given PASSWORD (all strings). If the optional argument VERBOSE is given and not #f, then a protocol of the communication with the server is written to the value of (current-error-port). PORT specifies the port-number and defaults to 21.
This procedure returns an object representing the FTP session.
ftp:disconnect
[procedure] (ftp:disconnect FTP)Closes the connection identified by the session object FTP.
ftp:ftp?
[procedure] (ftp:ftp? X)Returns #t if X is an FTP session object, or #f otherwise.
ftp:set-type!
[procedure] (ftp:set-type! FTP TYPE)Sets the transmission to binary or character type. TYPE should one of the symbols binary, image or ascii.
ftp:set-mode!
[procedure] (ftp:set-mode! FTP MODE)Selects active or passive mode. MODE should one of the symbols active or passive. Passive mode is the default.
ftp:change-directory
[procedure] (ftp:change-directory FTP DIR)Changes the current directory of the FTP session FTP to DIR.
ftp:open-list
[procedure] (ftp:open-list FTP [MASK [LONG]])Returns an input-port from which a directory list can be retrieved. The optional string MASK selects files to be listed (like *.scm). If the optional flag LONG is given and not #f, then the directory is requested in "long" format (if the server differentiates between short and long directory format). After the directory has been read, the port must be closed to allow further read/write operations in this FTP session.
ftp:open-input-file
[procedure] (ftp:open-input-file FTP FILENAME)Opens the file FILENAME for retrieval from the FTP server and returns an input-port from which the file can be read. After the file has been read, the port must be closed to allow further read/write operations in this FTP session.
ftp:open-output-file
[procedure] (ftp:open-output-file FTP FILENAME)Opens the file FILENAME the FTP server and returns an output-port to which the data to be stored should be written. After the file has been written, the port must be closed to allow further read/write operations in this FTP session.
ftp:abort
[procedure] (ftp:abort FTP)Aborts any transmission currently in progress for the given FTP session.
ftp:delete-file
[procedure] (ftp:delete-file FTP FILENAME)Deletes the file FILENAME on the FTP server.
ftp:rename-file
[procedure] (ftp:rename-file FTP OLD NEW)Renames the file OLD on the FTP server to NEW.
ftp:delete-directory
[procedure] (ftp:delete-directory FTP DIRNAME)Deletes the directory DIRNAME on the FTP server.
ftp:create-directory
[procedure] (ftp:create-directory FTP DIRNAME)Creates the directory DIRNAME on the FTP server.
Example
; Connect to FTP server: (define f (ftp:connect "ftp.foo.com" "joe" "secret")) ; Retrieve directory listing: (let ([p (ftp:open-list f)]) (display (read-string #f p)) (close-input-port p) ) ; Download a file: (with-output-to-file "foo.txt" (lambda () (let ([p (ftp:open-input-file f "foo.txt")]) (display (read-string #f p)) (close-input-port p) ) ) ) ; Terminate connection: (ftp:disconnect f)
Changelog
- 1.4 added regex dependency
- 1.3 Added matchable to list of dependencies in meta file
- 1.2 Ported to Chicken 4
- 1.1 Added support for passive mode.
- 1.0 Initial release
License
Copyright (c) 2003, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.