1996-06-17 12:26:06 +00:00
|
|
|
.\" Copyright (c) 1996 Jordan Hubbard (jkh@FreeBSD.org)
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. 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.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``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 AUTHOR 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.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1996-06-17 12:26:06 +00:00
|
|
|
.\"
|
|
|
|
.Dd June 17, 1996
|
1999-08-15 09:51:25 +00:00
|
|
|
.Dt FTPIO 3
|
1996-06-17 12:26:06 +00:00
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm ftpLogin ,
|
|
|
|
.Nm ftpChdir ,
|
|
|
|
.Nm ftpErrno ,
|
|
|
|
.Nm ftpGetModtime ,
|
|
|
|
.Nm ftpGetSize ,
|
|
|
|
.Nm ftpGet ,
|
|
|
|
.Nm ftpPut ,
|
|
|
|
.Nm ftpBinary ,
|
|
|
|
.Nm ftpPassive ,
|
1996-07-04 00:55:21 +00:00
|
|
|
.Nm ftpVerbose ,
|
1996-06-17 12:26:06 +00:00
|
|
|
.Nm ftpGetURL ,
|
2000-07-05 19:34:43 +00:00
|
|
|
.Nm ftpPutURL ,
|
|
|
|
.Nm ftpLoginAf ,
|
|
|
|
.Nm ftpGetURLAf ,
|
|
|
|
.Nm ftpPutURLAf
|
2001-04-18 15:54:10 +00:00
|
|
|
.Nd FTPIO user library
|
1996-06-17 12:26:06 +00:00
|
|
|
.Sh SYNOPSIS
|
|
|
|
.Fd #include <ftpio.h>
|
|
|
|
.Ft FILE *
|
1996-11-14 06:59:41 +00:00
|
|
|
.Fn ftpLogin "char *host" "char *user" "char *passwd" "int ftp_port" "int verbose" "int *retcode"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft int
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpChdir "FILE *stream" "char *dirname"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft int
|
1996-06-20 15:49:54 +00:00
|
|
|
.Fn ftpErrno "FILE *stream"
|
1996-08-21 01:12:11 +00:00
|
|
|
.Ft const char *
|
|
|
|
.Fn ftpErrString "int errno"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft time_t
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpGetModtime "FILE *stream" "char *file"
|
1997-04-19 15:57:20 +00:00
|
|
|
.Ft off_t
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpGetSize "FILE *stream" "char *file"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft FILE *
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpGet "FILE *stream" "char *file" "off_t *seekto"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft FILE *
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpPut "FILE *stream" "char *file"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft int
|
1996-06-24 02:22:15 +00:00
|
|
|
.Fn ftpAscii "FILE *stream"
|
|
|
|
.Ft int
|
|
|
|
.Fn ftpBinary "FILE *stream"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft int
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpPassive "FILE *stream" "int status"
|
1996-07-04 00:55:21 +00:00
|
|
|
.Ft void
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpVerbose "FILE *stream" "int status"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft FILE *
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpGetURL "char *url" "char *user" "char *passwd" "int *retcode"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Ft FILE *
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fn ftpPutURL "char *url" "char *user" "char *passwd" "int *retcode"
|
2001-02-05 23:58:59 +00:00
|
|
|
.Ft FILE *
|
2000-07-05 19:34:43 +00:00
|
|
|
.Fn ftpLoginAf "char *host" "int af" "char *user" "char *passwd" "int ftp_port" "int verbose" "int *retcode"
|
|
|
|
.Ft FILE *
|
|
|
|
.Fn ftpGetURLAf "char *url" "int af" "char *user" "char *passwd" "int *retcode"
|
|
|
|
.Ft FILE *
|
|
|
|
.Fn ftpPutURLAf "char *url" "int af" "char *user" "char *passwd" "int *retcode"
|
1996-06-17 12:26:06 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
These functions implement a high-level library for managing FTP connections.
|
|
|
|
.Pp
|
|
|
|
.Fn ftpLogin
|
|
|
|
attempts to log in using the supplied
|
|
|
|
.Fa user ,
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fa passwd ,
|
1996-06-17 12:26:06 +00:00
|
|
|
.Fa ftp_port
|
1996-08-03 11:58:54 +00:00
|
|
|
(if passed as 0,
|
1996-06-17 12:26:06 +00:00
|
|
|
.Fa ftp_port
|
1996-08-03 11:58:54 +00:00
|
|
|
defaults to the standard ftp port of 21) and
|
|
|
|
.Fa verbose
|
|
|
|
fields. If it is successful, a
|
1996-06-17 15:28:08 +00:00
|
|
|
standard stream descriptor is returned which should be passed to
|
2000-03-02 09:14:21 +00:00
|
|
|
subsequent FTP operations.
|
|
|
|
On failure, NULL is returned and
|
1996-11-14 06:59:41 +00:00
|
|
|
.Fa retcode
|
|
|
|
will have the error code returned by the foreign server.
|
1996-06-17 12:26:06 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpChdir
|
1996-10-05 22:27:30 +00:00
|
|
|
attempts to issue a server CD command to the directory named in
|
2001-02-01 16:38:02 +00:00
|
|
|
.Fa dir .
|
1996-06-17 20:36:57 +00:00
|
|
|
On success, zero is returned. On failure, the error code from the server.
|
1996-06-17 12:26:06 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpErrno
|
|
|
|
returns the server failure code for the last operation (useful for seeing
|
|
|
|
more about what happened if you're familiar with FTP error codes).
|
1996-08-21 01:12:11 +00:00
|
|
|
.Fn ftpErrString
|
|
|
|
returns a human readable version of the supplied server failure code.
|
1996-06-17 12:26:06 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpGet
|
|
|
|
attempts to retreive the file named by the
|
|
|
|
.Fa file
|
|
|
|
argument (which is assumed to be relative to the FTP server's current directory,
|
|
|
|
see
|
|
|
|
.Fn ftpChdir )
|
1996-06-20 15:49:54 +00:00
|
|
|
and returns a new FILE* pointer for the file or NULL on failure. If
|
1996-06-17 15:28:08 +00:00
|
|
|
.Fa seekto
|
|
|
|
is non-NULL, the contents of the integer it points to will be used
|
|
|
|
as a restart point for the file, that is to say that the stream
|
|
|
|
returned will point
|
|
|
|
.Fa *seekto
|
|
|
|
bytes into the file gotten (this is handy for restarting failed
|
1996-08-21 01:23:33 +00:00
|
|
|
transfers efficiently). If the seek operation fails, the value
|
1996-06-17 15:28:08 +00:00
|
|
|
of
|
|
|
|
.Fa *seekto
|
|
|
|
will be zero'd.
|
1996-06-17 12:26:06 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpGetModtime
|
|
|
|
returns the last modification time of the file named by the
|
|
|
|
.Fa file
|
|
|
|
argument. If the file could not be opened or stat'd, 0 is returned.
|
|
|
|
.Pp
|
|
|
|
.Fn ftpGetSize
|
|
|
|
returns the size in bytes of the file named by the
|
|
|
|
.Fa file
|
|
|
|
argument. If the file could not be opened or stat'd, -1 is returned.
|
|
|
|
.Pp
|
|
|
|
.Fn ftpPut
|
|
|
|
attempts to create a new file named by the
|
|
|
|
.Fa file
|
|
|
|
argument (which is assumed to be relative to the FTP server's current directory,
|
|
|
|
see
|
|
|
|
.Fn ftpChdir )
|
|
|
|
and returns a new
|
|
|
|
.Fa stream
|
|
|
|
pointer for the file or NULL on failure.
|
|
|
|
.Pp
|
1996-06-24 02:22:15 +00:00
|
|
|
.Fn ftpAscii
|
1999-09-20 09:15:23 +00:00
|
|
|
sets ASCII mode for the current server connection named by
|
1996-06-24 02:22:15 +00:00
|
|
|
.Fa stream .
|
|
|
|
.Pp
|
1996-06-17 12:26:06 +00:00
|
|
|
.Fn ftpBinary
|
|
|
|
sets binary mode for the current server connection named by
|
1996-06-24 02:22:15 +00:00
|
|
|
.Fa stream .
|
1996-06-17 12:26:06 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpPassive
|
|
|
|
sets passive mode (for firewalls) for the current server connection named by
|
|
|
|
.Fa stream
|
|
|
|
to boolean value
|
|
|
|
.Fa status .
|
|
|
|
.Pp
|
1996-07-04 00:55:21 +00:00
|
|
|
.Fn ftpVerbose
|
|
|
|
sets the verbosity mode for the current server connection named by
|
|
|
|
.Fa stream
|
|
|
|
to boolean value
|
|
|
|
.Fa status .
|
|
|
|
.Pp
|
1996-06-17 12:26:06 +00:00
|
|
|
.Fn ftpGetURL
|
|
|
|
attempts to retreive the file named by the supplied
|
|
|
|
.Fa URL
|
|
|
|
and can be considered equivalent to the combined
|
|
|
|
.Fn ftpLogin ,
|
|
|
|
.Fn ftpChdir
|
|
|
|
and
|
|
|
|
.Fn ftpGet
|
|
|
|
operations except that no server
|
|
|
|
.Fa stream
|
|
|
|
is ever returned - the connection to the server closes when
|
|
|
|
the file has been completely read. Use the lower-level routines
|
|
|
|
if multiple gets are required as it will be far more efficient.
|
|
|
|
.Pp
|
|
|
|
.Fn ftpPutURL
|
|
|
|
attempts to create the file named by the supplied
|
|
|
|
.Fa URL
|
|
|
|
and can be considered equivalent to the combined
|
|
|
|
.Fn ftpLogin ,
|
|
|
|
.Fn ftpChdir
|
|
|
|
and
|
|
|
|
.Fn ftpPut
|
1996-06-17 15:28:08 +00:00
|
|
|
operations except that no server stream is ever returned - the connection
|
|
|
|
to the server closes when the file has been completely written. Use the
|
|
|
|
lower-level routines if multiple puts are required as it will be far more
|
|
|
|
efficient.
|
2000-07-05 19:34:43 +00:00
|
|
|
.Pp
|
|
|
|
.Fn ftpLoginAf ,
|
|
|
|
.Fn ftpGetURLAf ,
|
|
|
|
.Fn ftpPutURLAf
|
|
|
|
are same as
|
|
|
|
.Fn ftpLogin ,
|
|
|
|
.Fn ftpGetURL ,
|
|
|
|
.Fn ftpPutURL
|
|
|
|
except that they are able to specify address family
|
|
|
|
.Fa af .
|
1998-02-10 07:01:51 +00:00
|
|
|
.Sh ENVIRONMENT
|
2000-12-29 14:08:20 +00:00
|
|
|
.Bl -tag -width FTP_PASSIVE_MODE -offset 3n
|
1998-02-10 07:01:51 +00:00
|
|
|
.It Ev FTP_TIMEOUT
|
|
|
|
Maximum time, in seconds, to wait for a response
|
|
|
|
from the peer before aborting an
|
|
|
|
.Tn FTP
|
|
|
|
connection.
|
|
|
|
.It Ev FTP_PASSIVE_MODE
|
2000-08-17 23:46:13 +00:00
|
|
|
If defined, forces the use of passive mode, unless equal
|
|
|
|
to ``NO'' or ``no'' in which case active mode is forced.
|
|
|
|
If defined, the setting of this variable always overrides any calls to
|
|
|
|
.Fn ftpPassive .
|
1998-02-10 07:01:51 +00:00
|
|
|
.El
|
1996-06-17 12:26:06 +00:00
|
|
|
.Sh BUGS
|
|
|
|
I'm sure you can get this thing's internal state machine confused if
|
|
|
|
you really work at it, but so far it's proven itself pretty robust in
|
|
|
|
all my tests.
|
|
|
|
.Sh HISTORY
|
|
|
|
Started life as Poul-Henning Kamp's ftp driver for the system installation
|
|
|
|
utility, later significantly mutated into a more general form as an
|
1996-08-21 01:12:11 +00:00
|
|
|
extension of stdio by Jordan Hubbard. Also incorporates some ideas and
|
|
|
|
extensions from Jean-Marc Zucconi.
|
1996-06-17 12:28:50 +00:00
|
|
|
.Sh AUTHORS
|
1998-03-19 07:34:22 +00:00
|
|
|
.An Jordan Hubbard ,
|
|
|
|
.An Poul-Henning Kamp
|
|
|
|
and
|
|
|
|
.An Jean-Marc Zucconi
|