xref: /freebsd/lib/libfetch/fetch.3 (revision 6c81eb523e10c41a04a98cd08889e5915847d697)
14ca1ab94SDag-Erling Smørgrav.\" Copyright (c) 1998 Dag-Erling Co�dan Sm�rgrav
24ca1ab94SDag-Erling Smørgrav.\" All rights reserved.
34ca1ab94SDag-Erling Smørgrav.\"
44ca1ab94SDag-Erling Smørgrav.\" Redistribution and use in source and binary forms, with or without
54ca1ab94SDag-Erling Smørgrav.\" modification, are permitted provided that the following conditions
64ca1ab94SDag-Erling Smørgrav.\" are met:
74ca1ab94SDag-Erling Smørgrav.\" 1. Redistributions of source code must retain the above copyright
84ca1ab94SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer.
94ca1ab94SDag-Erling Smørgrav.\" 2. Redistributions in binary form must reproduce the above copyright
104ca1ab94SDag-Erling Smørgrav.\"    notice, this list of conditions and the following disclaimer in the
114ca1ab94SDag-Erling Smørgrav.\"    documentation and/or other materials provided with the distribution.
124ca1ab94SDag-Erling Smørgrav.\"
134ca1ab94SDag-Erling Smørgrav.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
144ca1ab94SDag-Erling Smørgrav.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
154ca1ab94SDag-Erling Smørgrav.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
164ca1ab94SDag-Erling Smørgrav.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
174ca1ab94SDag-Erling Smørgrav.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
184ca1ab94SDag-Erling Smørgrav.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
194ca1ab94SDag-Erling Smørgrav.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
204ca1ab94SDag-Erling Smørgrav.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
214ca1ab94SDag-Erling Smørgrav.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
224ca1ab94SDag-Erling Smørgrav.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
234ca1ab94SDag-Erling Smørgrav.\" SUCH DAMAGE.
244ca1ab94SDag-Erling Smørgrav.\"
257f3dea24SPeter Wemm.\" $FreeBSD$
264ca1ab94SDag-Erling Smørgrav.\"
274ca1ab94SDag-Erling Smørgrav.Dd July 1, 1998
284ca1ab94SDag-Erling Smørgrav.Dt FETCH 3
294ca1ab94SDag-Erling Smørgrav.Os
304ca1ab94SDag-Erling Smørgrav.Sh NAME
319a964d6aSDag-Erling Smørgrav.Nm fetchMakeURL ,
3260245e42SDag-Erling Smørgrav.Nm fetchParseURL ,
3360245e42SDag-Erling Smørgrav.Nm fetchFreeURL ,
341a5faa10SDag-Erling Smørgrav.Nm fetchXGetURL ,
354ca1ab94SDag-Erling Smørgrav.Nm fetchGetURL ,
364ca1ab94SDag-Erling Smørgrav.Nm fetchPutURL ,
37d8acd8dcSDag-Erling Smørgrav.Nm fetchStatURL ,
38ce71b736SDag-Erling Smørgrav.Nm fetchListURL ,
391a5faa10SDag-Erling Smørgrav.Nm fetchXGet ,
40db5f8cebSDag-Erling Smørgrav.Nm fetchGet ,
41db5f8cebSDag-Erling Smørgrav.Nm fetchPut ,
42d8acd8dcSDag-Erling Smørgrav.Nm fetchStat ,
43ce71b736SDag-Erling Smørgrav.Nm fetchList ,
441a5faa10SDag-Erling Smørgrav.Nm fetchXGetFile ,
454ca1ab94SDag-Erling Smørgrav.Nm fetchGetFile ,
464ca1ab94SDag-Erling Smørgrav.Nm fetchPutFile ,
47d8acd8dcSDag-Erling Smørgrav.Nm fetchStatFile ,
48ce71b736SDag-Erling Smørgrav.Nm fetchListFile ,
491a5faa10SDag-Erling Smørgrav.Nm fetchXGetHTTP ,
504ca1ab94SDag-Erling Smørgrav.Nm fetchGetHTTP ,
514ca1ab94SDag-Erling Smørgrav.Nm fetchPutHTTP ,
52d8acd8dcSDag-Erling Smørgrav.Nm fetchStatHTTP ,
53ce71b736SDag-Erling Smørgrav.Nm fetchListHTTP ,
541a5faa10SDag-Erling Smørgrav.Nm fetchXGetFTP ,
554ca1ab94SDag-Erling Smørgrav.Nm fetchGetFTP ,
5615efcd39SAlexey Zelkin.Nm fetchPutFTP ,
5715efcd39SAlexey Zelkin.Nm fetchStatFTP ,
5815efcd39SAlexey Zelkin.Nm fetchListFTP
5915efcd39SAlexey Zelkin.Nd file transfer functions
6015efcd39SAlexey Zelkin.Sh LIBRARY
6115efcd39SAlexey Zelkin.Lb libfetch
624ca1ab94SDag-Erling Smørgrav.Sh SYNOPSIS
630fba3a00SDag-Erling Smørgrav.Fd #include <sys/param.h>
640fba3a00SDag-Erling Smørgrav.Fd #include <stdio.h>
654ca1ab94SDag-Erling Smørgrav.Fd #include <fetch.h>
6660245e42SDag-Erling Smørgrav.Ft struct url *
679a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL "char *scheme" "char *host" "int port" "char *doc" "char *user" "char *pwd"
689a964d6aSDag-Erling Smørgrav.Ft struct url *
6960245e42SDag-Erling Smørgrav.Fn fetchParseURL "char *URL"
7060245e42SDag-Erling Smørgrav.Ft void
7160245e42SDag-Erling Smørgrav.Fn fetchFreeURL "struct url *URL"
72db5f8cebSDag-Erling Smørgrav.Ft FILE *
731a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL "char *URL" "struct url_stat *us" "char *flags"
741a5faa10SDag-Erling Smørgrav.Ft FILE *
75db5f8cebSDag-Erling Smørgrav.Fn fetchGetURL "char *URL" "char *flags"
76db5f8cebSDag-Erling Smørgrav.Ft FILE *
77db5f8cebSDag-Erling Smørgrav.Fn fetchPutURL "char *URL" "char *flags"
78d8acd8dcSDag-Erling Smørgrav.Ft int
79d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL "char *URL" "struct url_stat *us" "char *flags"
80ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
81ce71b736SDag-Erling Smørgrav.Fn fetchListURL "char *URL" "char *flags"
824ca1ab94SDag-Erling Smørgrav.Ft FILE *
831a5faa10SDag-Erling Smørgrav.Fn fetchXGet "struct url *URL" "struct url_stat *us" "char *flags"
841a5faa10SDag-Erling Smørgrav.Ft FILE *
85d8acd8dcSDag-Erling Smørgrav.Fn fetchGet "struct url *URL" "char *flags"
86db5f8cebSDag-Erling Smørgrav.Ft FILE *
87d8acd8dcSDag-Erling Smørgrav.Fn fetchPut "struct url *URL" "char *flags"
88d8acd8dcSDag-Erling Smørgrav.Ft int
89d8acd8dcSDag-Erling Smørgrav.Fn fetchStat "struct url *URL" "struct url_stat *us" "char *flags"
90ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
91ce71b736SDag-Erling Smørgrav.Fn fetchList "struct url *" "char *flags"
92db5f8cebSDag-Erling Smørgrav.Ft FILE *
931a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile "struct url *u" "struct url_stat *us" "char *flags"
941a5faa10SDag-Erling Smørgrav.Ft FILE *
95d8acd8dcSDag-Erling Smørgrav.Fn fetchGetFile "struct url *u" "char *flags"
964ca1ab94SDag-Erling Smørgrav.Ft FILE *
97d8acd8dcSDag-Erling Smørgrav.Fn fetchPutFile "struct url *u" "char *flags"
98d8acd8dcSDag-Erling Smørgrav.Ft int
99d8acd8dcSDag-Erling Smørgrav.Fn fetchStatFile "struct url *URL" "struct url_stat *us" "char *flags"
100ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
101ce71b736SDag-Erling Smørgrav.Fn fetchListFile "struct url *" "char *flags"
1024ca1ab94SDag-Erling Smørgrav.Ft FILE *
1031a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP "struct url *u" "struct url_stat *us" "char *flags"
1041a5faa10SDag-Erling Smørgrav.Ft FILE *
105d8acd8dcSDag-Erling Smørgrav.Fn fetchGetHTTP "struct url *u" "char *flags"
1064ca1ab94SDag-Erling Smørgrav.Ft FILE *
107d8acd8dcSDag-Erling Smørgrav.Fn fetchPutHTTP "struct url *u" "char *flags"
108d8acd8dcSDag-Erling Smørgrav.Ft int
109d8acd8dcSDag-Erling Smørgrav.Fn fetchStatHTTP "struct url *URL" "struct url_stat *us" "char *flags"
110ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
111ce71b736SDag-Erling Smørgrav.Fn fetchListHTTP "struct url *" "char *flags"
1124ca1ab94SDag-Erling Smørgrav.Ft FILE *
1131a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP "struct url *u" "struct url_stat *us" "char *flags"
1141a5faa10SDag-Erling Smørgrav.Ft FILE *
115d8acd8dcSDag-Erling Smørgrav.Fn fetchGetFTP "struct url *u" "char *flags"
1164ca1ab94SDag-Erling Smørgrav.Ft FILE *
117d8acd8dcSDag-Erling Smørgrav.Fn fetchPutFTP "struct url *u" "char *flags"
118d8acd8dcSDag-Erling Smørgrav.Ft int
119d8acd8dcSDag-Erling Smørgrav.Fn fetchStatFTP "struct url *URL" "struct url_stat *us" "char *flags"
120ce71b736SDag-Erling Smørgrav.Ft struct url_ent *
121ce71b736SDag-Erling Smørgrav.Fn fetchListFTP "struct url *" "char *flags"
1224ca1ab94SDag-Erling Smørgrav.Sh DESCRIPTION
123d8acd8dcSDag-Erling Smørgrav.Pp
1244ca1ab94SDag-Erling SmørgravThese functions implement a high-level library for retrieving and
1254ca1ab94SDag-Erling Smørgravuploading files using Uniform Resource Locators (URLs).
1264ca1ab94SDag-Erling Smørgrav.Pp
12760245e42SDag-Erling Smørgrav.Fn fetchParseURL
12860245e42SDag-Erling Smørgravtakes a URL in the form of a null-terminated string and splits it into
12960245e42SDag-Erling Smørgravits components function according to the Common Internet Scheme Syntax
1309364c532SDag-Erling Smørgravdetailed in RFC1738.
1319364c532SDag-Erling SmørgravA regular expression which produces this syntax is:
13260245e42SDag-Erling Smørgrav.Bd -literal
13360245e42SDag-Erling Smørgrav    <scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
13460245e42SDag-Erling Smørgrav.Ed
13560245e42SDag-Erling Smørgrav.Pp
1361df2031cSDag-Erling SmørgravIf the URL does not seem to begin with a scheme name, the following
1371df2031cSDag-Erling Smørgravsyntax is assumed:
1381df2031cSDag-Erling Smørgrav.Bd -literal
1391df2031cSDag-Erling Smørgrav    ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
1401df2031cSDag-Erling Smørgrav.Ed
1411df2031cSDag-Erling Smørgrav.Pp
14260245e42SDag-Erling SmørgravNote that some components of the URL are not necessarily relevant to
14360245e42SDag-Erling Smørgravall URL schemes.
1441df2031cSDag-Erling SmørgravFor instance, the file scheme only needs the <scheme> and <document>
1451df2031cSDag-Erling Smørgravcomponents.
14660245e42SDag-Erling Smørgrav.Pp
1479a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL
1489a964d6aSDag-Erling Smørgravand
14940ac2845SDag-Erling Smørgrav.Fn fetchParseURL
1509a964d6aSDag-Erling Smørgravreturn a pointer to a
15140ac2845SDag-Erling Smørgrav.Fa url
15240ac2845SDag-Erling Smørgravstructure, which is defined as follows in
15340ac2845SDag-Erling Smørgrav.Aq Pa fetch.h :
15440ac2845SDag-Erling Smørgrav.Bd -literal
15540ac2845SDag-Erling Smørgrav#define URL_SCHEMELEN 16
15640ac2845SDag-Erling Smørgrav#define URL_USERLEN 256
15740ac2845SDag-Erling Smørgrav#define URL_PWDLEN 256
15840ac2845SDag-Erling Smørgrav
15940ac2845SDag-Erling Smørgravstruct url {
16040ac2845SDag-Erling Smørgrav    char	 scheme[URL_SCHEMELEN+1];
16140ac2845SDag-Erling Smørgrav    char	 user[URL_USERLEN+1];
16240ac2845SDag-Erling Smørgrav    char	 pwd[URL_PWDLEN+1];
16340ac2845SDag-Erling Smørgrav    char	 host[MAXHOSTNAMELEN+1];
16440ac2845SDag-Erling Smørgrav    int		 port;
16540ac2845SDag-Erling Smørgrav    char	*doc;
16640ac2845SDag-Erling Smørgrav    off_t	 offset;
16740ac2845SDag-Erling Smørgrav    size_t	 length;
16840ac2845SDag-Erling Smørgrav};
16940ac2845SDag-Erling Smørgrav.Ed
17040ac2845SDag-Erling Smørgrav.Pp
17160245e42SDag-Erling SmørgravThe pointer returned by
1729a964d6aSDag-Erling Smørgrav.Fn fetchMakeURL
1739a964d6aSDag-Erling Smørgravor
17460245e42SDag-Erling Smørgrav.Fn fetchParseURL
17560245e42SDag-Erling Smørgravshould be freed using
17660245e42SDag-Erling Smørgrav.Fn fetchFreeURL .
17760245e42SDag-Erling Smørgrav.Pp
1781a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL ,
1791a5faa10SDag-Erling Smørgrav.Fn fetchGetURL ,
180db5f8cebSDag-Erling Smørgravand
181db5f8cebSDag-Erling Smørgrav.Fn fetchPutURL
182db5f8cebSDag-Erling Smørgravconstitute the recommended interface to the
183db5f8cebSDag-Erling Smørgrav.Nm fetch
184c6ff3a1bSSheldon Hearnlibrary.
185c6ff3a1bSSheldon HearnThey examine the URL passed to them to determine the transfer
186db5f8cebSDag-Erling Smørgravmethod, and call the appropriate lower-level functions to perform the
187c6ff3a1bSSheldon Hearnactual transfer.
1881a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL
1891a5faa10SDag-Erling Smørgravalso returns the remote document's metadata in the
1901a5faa10SDag-Erling Smørgrav.Fa url_stat
1911a5faa10SDag-Erling Smørgravstructure pointed to by the
1921a5faa10SDag-Erling Smørgrav.Fa us
1931a5faa10SDag-Erling Smørgravargument.
1941a5faa10SDag-Erling Smørgrav.Pp
195c6ff3a1bSSheldon HearnThe
196db5f8cebSDag-Erling Smørgrav.Fa flags
197c6ff3a1bSSheldon Hearnargument is a string of characters which specify transfer options.
198c6ff3a1bSSheldon HearnThe
199db5f8cebSDag-Erling Smørgravmeaning of the individual flags is scheme-dependent, and is detailed
200db5f8cebSDag-Erling Smørgravin the appropriate section below.
201db5f8cebSDag-Erling Smørgrav.Pp
202d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL
203d8acd8dcSDag-Erling Smørgravattempts to obtain the requested document's metadata and fill in the
204c6ff3a1bSSheldon Hearnstructure pointed to by it's second argument.
205c6ff3a1bSSheldon HearnThe
206d8acd8dcSDag-Erling Smørgrav.Fa url_stat
207d8acd8dcSDag-Erling Smørgravstructure is defined as follows in
208d8acd8dcSDag-Erling Smørgrav.Aq Pa fetch.h :
209d8acd8dcSDag-Erling Smørgrav.Bd -literal
210d8acd8dcSDag-Erling Smørgravstruct url_stat {
211d8acd8dcSDag-Erling Smørgrav    off_t	 size;
2125aea254fSDag-Erling Smørgrav    time_t	 atime;
2135aea254fSDag-Erling Smørgrav    time_t	 mtime;
214d8acd8dcSDag-Erling Smørgrav};
215d8acd8dcSDag-Erling Smørgrav.Ed
216d8acd8dcSDag-Erling Smørgrav.Pp
21740ac2845SDag-Erling SmørgravIf the size could not be obtained from the server, the
21840ac2845SDag-Erling Smørgrav.Fa size
21940ac2845SDag-Erling Smørgravfield is set to -1.
22040ac2845SDag-Erling SmørgravIf the modification time could not be obtained from the server, the
22140ac2845SDag-Erling Smørgrav.Fa mtime
22240ac2845SDag-Erling Smørgravfield is set to the epoch.
22340ac2845SDag-Erling SmørgravIf the access time could not be obtained from the server, the
22440ac2845SDag-Erling Smørgrav.Fa atime
22540ac2845SDag-Erling Smørgravfield is set to the modification time.
22640ac2845SDag-Erling Smørgrav.Pp
227ce71b736SDag-Erling Smørgrav.Fn fetchListURL
228ce71b736SDag-Erling Smørgravattempts to list the contents of the directory pointed to by the URL
229c6ff3a1bSSheldon Hearnprovided.
230c6ff3a1bSSheldon HearnIf successful, it returns a malloced array of
231ce71b736SDag-Erling Smørgrav.Fa url_ent
232c6ff3a1bSSheldon Hearnstructures.
233c6ff3a1bSSheldon HearnThe
234ce71b736SDag-Erling Smørgrav.Fa url_ent
235ce71b736SDag-Erling Smørgravstructure is defined as follows in
236ce71b736SDag-Erling Smørgrav.Aq Pa fetch.h :
237ce71b736SDag-Erling Smørgrav.Bd -literal
238ce71b736SDag-Erling Smørgravstruct url_ent {
239ce71b736SDag-Erling Smørgrav    char         name[MAXPATHLEN];
240ce71b736SDag-Erling Smørgrav    struct url_stat stat;
241ce71b736SDag-Erling Smørgrav};
242ce71b736SDag-Erling Smørgrav.Ed
243ce71b736SDag-Erling Smørgrav.Pp
244ce71b736SDag-Erling SmørgravThe list is terminated by an entry with an empty name.
245ce71b736SDag-Erling Smørgrav.Pp
246ce71b736SDag-Erling SmørgravThe pointer returned by
247ce71b736SDag-Erling Smørgrav.Fn fetchListURL
248ce71b736SDag-Erling Smørgravshould be freed using
249ce71b736SDag-Erling Smørgrav.Fn free .
250ce71b736SDag-Erling Smørgrav.Pp
2511a5faa10SDag-Erling Smørgrav.Fn fetchXGet ,
252d8acd8dcSDag-Erling Smørgrav.Fn fetchGet ,
253db5f8cebSDag-Erling Smørgrav.Fn fetchPut
2544ca1ab94SDag-Erling Smørgravand
255d8acd8dcSDag-Erling Smørgrav.Fn fetchStat
256d8acd8dcSDag-Erling Smørgravare similar to
2571a5faa10SDag-Erling Smørgrav.Fn fetchXGetURL ,
258d8acd8dcSDag-Erling Smørgrav.Fn fetchGetURL ,
259d8acd8dcSDag-Erling Smørgrav.Fn fetchPutURL
260d8acd8dcSDag-Erling Smørgravand
261d8acd8dcSDag-Erling Smørgrav.Fn fetchStatURL ,
262db5f8cebSDag-Erling Smørgravexcept that they expect a pre-parsed URL in the form of a pointer to
263d8acd8dcSDag-Erling Smørgrava
264d8acd8dcSDag-Erling Smørgrav.Fa struct url
265d8acd8dcSDag-Erling Smørgravrather than a string.
2664ca1ab94SDag-Erling Smørgrav.Pp
2674ca1ab94SDag-Erling SmørgravAll of the
2681a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX ,
2694ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX
2704ca1ab94SDag-Erling Smørgravand
2714ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX
2724ca1ab94SDag-Erling Smørgravfunctions return a pointer to a stream which can be used to read or
273c6ff3a1bSSheldon Hearnwrite data from or to the requested document, respectively.
274c6ff3a1bSSheldon HearnNote that
2754ca1ab94SDag-Erling Smørgravalthough the implementation details of the individual access methods
2764ca1ab94SDag-Erling Smørgravvary, it can generally be assumed that a stream returned by one of the
2771a5faa10SDag-Erling Smørgrav.Fn fetchXGetXXX
2781a5faa10SDag-Erling Smørgravor
2794ca1ab94SDag-Erling Smørgrav.Fn fetchGetXXX
2804ca1ab94SDag-Erling Smørgravfunctions is read-only, and that a stream returned by one of the
2814ca1ab94SDag-Erling Smørgrav.Fn fetchPutXXX
2824ca1ab94SDag-Erling Smørgravfunctions is write-only.
2834ca1ab94SDag-Erling Smørgrav.Sh FILE SCHEME
2841a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile ,
2854ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile
2864ca1ab94SDag-Erling Smørgravand
2874ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
2884ca1ab94SDag-Erling Smørgravprovide access to documents which are files in a locally mounted file
289c6ff3a1bSSheldon Hearnsystem.
290c6ff3a1bSSheldon HearnOnly the <document> component of the URL is used.
2914ca1ab94SDag-Erling Smørgrav.Pp
2921a5faa10SDag-Erling Smørgrav.Fn fetchXGetFile
2931a5faa10SDag-Erling Smørgravand
2944ca1ab94SDag-Erling Smørgrav.Fn fetchGetFile
2951a5faa10SDag-Erling Smørgravdo not accept any flags.
2964ca1ab94SDag-Erling Smørgrav.Pp
2974ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
2984ca1ab94SDag-Erling Smørgravaccepts the
2994ca1ab94SDag-Erling Smørgrav.Fa a
300c6ff3a1bSSheldon Hearn(append to file) flag.
301c6ff3a1bSSheldon HearnIf that flag is specified, the data written to
3024ca1ab94SDag-Erling Smørgravthe stream returned by
3034ca1ab94SDag-Erling Smørgrav.Fn fetchPutFile
3044ca1ab94SDag-Erling Smørgravwill be appended to the previous contents of the file, instead of
3054ca1ab94SDag-Erling Smørgravreplacing them.
3064ca1ab94SDag-Erling Smørgrav.Sh FTP SCHEME
3071a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP ,
3084ca1ab94SDag-Erling Smørgrav.Fn fetchGetFTP
3094ca1ab94SDag-Erling Smørgravand
3104ca1ab94SDag-Erling Smørgrav.Fn fetchPutFTP
3114ca1ab94SDag-Erling Smørgravimplement the FTP protocol as described in RFC959.
3124ca1ab94SDag-Erling Smørgrav.Pp
3134ca1ab94SDag-Erling SmørgravIf the
3144ca1ab94SDag-Erling Smørgrav.Fa p
3154ca1ab94SDag-Erling Smørgrav(passive) flag is specified, a passive (rather than active) connection
3164ca1ab94SDag-Erling Smørgravwill be attempted.
3174ca1ab94SDag-Erling Smørgrav.Pp
318f5f109a0SDag-Erling SmørgravIf the
319f5f109a0SDag-Erling Smørgrav.Fa h
320f5f109a0SDag-Erling Smørgrav(high) flag is specified, data sockets will be allocated in the high
321f5f109a0SDag-Erling Smørgravport range (see
322f5f109a0SDag-Erling Smørgrav.Xr ip 4 ).
323f5f109a0SDag-Erling Smørgrav.Pp
324f5f109a0SDag-Erling SmørgravIf the
325f5f109a0SDag-Erling Smørgrav.Fa d
326f5f109a0SDag-Erling Smørgrav(direct) flag is specified,
3271a5faa10SDag-Erling Smørgrav.Fn fetchXGetFTP ,
328f5f109a0SDag-Erling Smørgrav.Fn fetchGetFTP
329f5f109a0SDag-Erling Smørgravand
330f5f109a0SDag-Erling Smørgrav.Fn fetchPutFTP
331f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined.
332f5f109a0SDag-Erling Smørgrav.Pp
3334ca1ab94SDag-Erling SmørgravIf no user name or password is given, the
3344ca1ab94SDag-Erling Smørgrav.Nm fetch
3354ca1ab94SDag-Erling Smørgravlibrary will attempt an anonymous login, with user name "ftp" and
3364ca1ab94SDag-Erling Smørgravpassword "ftp".
3374ca1ab94SDag-Erling Smørgrav.Sh HTTP SCHEME
3384ca1ab94SDag-Erling SmørgravThe
3391a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP ,
3404ca1ab94SDag-Erling Smørgrav.Fn fetchGetHTTP
3414ca1ab94SDag-Erling Smørgravand
3424ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP
343c6ff3a1bSSheldon Hearnfunctions implement the HTTP/1.1 protocol.
344c6ff3a1bSSheldon HearnWith a little luck, there's
3454ca1ab94SDag-Erling Smørgraveven a chance that they comply with RFC2068.
3464ca1ab94SDag-Erling Smørgrav.Pp
347f5f109a0SDag-Erling SmørgravIf the
348f5f109a0SDag-Erling Smørgrav.Fa d
349f5f109a0SDag-Erling Smørgrav(direct) flag is specified,
3501a5faa10SDag-Erling Smørgrav.Fn fetchXGetHTTP ,
351f5f109a0SDag-Erling Smørgrav.Fn fetchGetHTTP
352f5f109a0SDag-Erling Smørgravand
353f5f109a0SDag-Erling Smørgrav.Fn fetchPutHTTP
354f5f109a0SDag-Erling Smørgravwill use a direct connection even if a proxy server is defined.
355f5f109a0SDag-Erling Smørgrav.Pp
3564ca1ab94SDag-Erling SmørgravSince there seems to be no good way of implementing the HTTP PUT
3574ca1ab94SDag-Erling Smørgravmethod in a manner consistent with the rest of the
3584ca1ab94SDag-Erling Smørgrav.Nm fetch
3594ca1ab94SDag-Erling Smørgravlibrary,
3604ca1ab94SDag-Erling Smørgrav.Fn fetchPutHTTP
3614ca1ab94SDag-Erling Smørgravis currently unimplemented.
3624ca1ab94SDag-Erling Smørgrav.Sh RETURN VALUES
3634ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL
3644ca1ab94SDag-Erling Smørgravreturns a pointer to a
365d8acd8dcSDag-Erling Smørgrav.Fa struct url
366c6ff3a1bSSheldon Hearncontaining the individual components of the URL.
367c6ff3a1bSSheldon HearnIf it is
3684ca1ab94SDag-Erling Smørgravunable to allocate memory, or the URL is syntactically incorrect,
3694ca1ab94SDag-Erling Smørgrav.Fn fetchParseURL
3704ca1ab94SDag-Erling Smørgravreturns a NULL pointer.
3714ca1ab94SDag-Erling Smørgrav.Pp
372d8acd8dcSDag-Erling SmørgravThe
373d8acd8dcSDag-Erling Smørgrav.Fn fetchStat
374d8acd8dcSDag-Erling Smørgravfunctions return 0 on success and -1 on failure.
375d8acd8dcSDag-Erling Smørgrav.Pp
3764ca1ab94SDag-Erling SmørgravAll other functions return a stream pointer which may be used to
377d8acd8dcSDag-Erling Smørgravaccess the requested document, or NULL if an error occurred.
378d8acd8dcSDag-Erling Smørgrav.Pp
379ba101983SDag-Erling SmørgravThe following error codes are defined in
380ba101983SDag-Erling Smørgrav.Aq Pa fetch.h :
38115efcd39SAlexey Zelkin.Bl -tag -width 18n
382d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_ABORT
383d8acd8dcSDag-Erling SmørgravOperation aborted
384d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_AUTH
385d8acd8dcSDag-Erling SmørgravAuthentication failed
386d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_DOWN
387d8acd8dcSDag-Erling SmørgravService unavailable
388d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_EXISTS
389d8acd8dcSDag-Erling SmørgravFile exists
390d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_FULL
391d8acd8dcSDag-Erling SmørgravFile system full
392d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_INFO
393d8acd8dcSDag-Erling SmørgravInformational response
394d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MEMORY
395d8acd8dcSDag-Erling SmørgravInsufficient memory
396d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_MOVED
397d8acd8dcSDag-Erling SmørgravFile has moved
398d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_NETWORK
399d8acd8dcSDag-Erling SmørgravNetwork error
400d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_OK
401d8acd8dcSDag-Erling SmørgravNo error
402d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_PROTO
403d8acd8dcSDag-Erling SmørgravProtocol error
404d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_RESOLV
405d8acd8dcSDag-Erling SmørgravResolver error
406d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_SERVER
407d8acd8dcSDag-Erling SmørgravServer error
408d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TEMP
409d8acd8dcSDag-Erling SmørgravTemporary error
410d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_TIMEOUT
411d8acd8dcSDag-Erling SmørgravOperation timed out
412d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNAVAIL
413d8acd8dcSDag-Erling SmørgravFile is not available
414d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_UNKNOWN
415d8acd8dcSDag-Erling SmørgravUnknown error
416d8acd8dcSDag-Erling Smørgrav.It Bq Er FETCH_URL
417d8acd8dcSDag-Erling SmørgravInvalid URL
418d8acd8dcSDag-Erling Smørgrav.El
419d8acd8dcSDag-Erling Smørgrav.Pp
420d8acd8dcSDag-Erling SmørgravThe accompanying error message includes a protocol-specific error code
421d8acd8dcSDag-Erling Smørgravand message, e.g. "File is not available (404 Not Found)"
4224ca1ab94SDag-Erling Smørgrav.Sh ENVIRONMENT
42391c51046SDag-Erling Smørgrav.Bl -tag -width FTP_PASSIVE_MODE
42491c51046SDag-Erling Smørgrav.It Ev FTP_PASSIVE_MODE
4256c81eb52SDag-Erling SmørgravIf set to anything but
4266c81eb52SDag-Erling Smørgrav.Ql no ,
4276c81eb52SDag-Erling Smørgravforces the FTP code to use passive mode.
42891c51046SDag-Erling Smørgrav.It Ev FTP_PASSWORD
42991c51046SDag-Erling SmørgravDefault FTP password if the remote server requests one and none was
43091c51046SDag-Erling Smørgravprovided in the URL.
431bc2a5e68SDag-Erling Smørgrav.It Ev FTP_PROXY
4321df2031cSDag-Erling SmørgravURL of the proxy to use for FTP requests.
4331df2031cSDag-Erling SmørgravThe document part is ignored.
4341df2031cSDag-Erling SmørgravFTP and HTTP proxies are supported; if no scheme is specified, FTP is
4351df2031cSDag-Erling Smørgravassumed.
4361df2031cSDag-Erling SmørgravIf the proxy is an FTP proxy,
437e0a9ca38SDag-Erling Smørgrav.Nm libfetch
438e0a9ca38SDag-Erling Smørgravwill send
439e0a9ca38SDag-Erling Smørgrav.Ql user@host
440e0a9ca38SDag-Erling Smørgravas user name to the proxy, where
441e0a9ca38SDag-Erling Smørgrav.Ql user
442e0a9ca38SDag-Erling Smørgravis the real user name, and
443e0a9ca38SDag-Erling Smørgrav.Ql host
444e0a9ca38SDag-Erling Smørgravis the name of the FTP server.
44589d755e1SDag-Erling Smørgrav.Pp
4462e83f638SDag-Erling SmørgravIf this variable is set to an empty string, no proxy will be used for
4472e83f638SDag-Erling SmørgravFTP requests, even if the
4482e83f638SDag-Erling Smørgrav.Ev HTTP_PROXY
4492e83f638SDag-Erling Smørgravvariable is set.
45098f5573fSDag-Erling Smørgrav.It Ev HTTP_AUTH
45189d755e1SDag-Erling SmørgravSpecifies HTTP authorization parameters as a colon-separated list of
45289d755e1SDag-Erling Smørgravitems.
45398f5573fSDag-Erling SmørgravThe first and second item are the authorization scheme and realm
45498f5573fSDag-Erling Smørgravrespectively; further items are scheme-dependent.
45598f5573fSDag-Erling SmørgravCurrently, only basic authorization is supported.
45689d755e1SDag-Erling Smørgrav.Pp
45798f5573fSDag-Erling SmørgravBasic authorization requires two parameters: the user name and
45898f5573fSDag-Erling Smørgravpassword, in that order.
45989d755e1SDag-Erling Smørgrav.Pp
46089d755e1SDag-Erling SmørgravThis variable is only used if the server requires authorization and
46189d755e1SDag-Erling Smørgravno user name or password was specified in the URL.
462bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY
4631df2031cSDag-Erling SmørgravURL of the proxy to use for HTTP requests.
4641df2031cSDag-Erling SmørgravThe document part is ignored.
4651df2031cSDag-Erling SmørgravOnly HTTP proxies are supported for HTTP requests.
466bc2a5e68SDag-Erling SmørgravIf no port number is specified, the default is 3128.
46789d755e1SDag-Erling Smørgrav.Pp
4681df2031cSDag-Erling SmørgravNote that this proxy will also be used for FTP documents, unless the
469e0a9ca38SDag-Erling Smørgrav.Ev FTP_PROXY
470e0a9ca38SDag-Erling Smørgravvariable is set.
471bc2a5e68SDag-Erling Smørgrav.It Ev HTTP_PROXY_AUTH
47298f5573fSDag-Erling SmørgravSpecifies authorization parameters for the HTTP proxy in the same
473e0a9ca38SDag-Erling Smørgravformat as the
474e0a9ca38SDag-Erling Smørgrav.Ev HTTP_AUTH
475e0a9ca38SDag-Erling Smørgravvariable.
47689d755e1SDag-Erling Smørgrav.Pp
4771df2031cSDag-Erling SmørgravThis variable is used if and only if connected to an HTTP proxy, and
4781df2031cSDag-Erling Smørgravis ignored if a user and/or a password were specified in the proxy
4791df2031cSDag-Erling SmørgravURL.
480bc2a5e68SDag-Erling Smørgrav.El
4814ca1ab94SDag-Erling Smørgrav.Sh SEE ALSO
4824ca1ab94SDag-Erling Smørgrav.Xr fetch 1 ,
483f5f109a0SDag-Erling Smørgrav.Xr ftpio 3 ,
484f5f109a0SDag-Erling Smørgrav.Xr ip 4 .
4854ca1ab94SDag-Erling Smørgrav.Rs
4860f5fcaa3SSheldon Hearn.%A T. Berners-Lee
4870f5fcaa3SSheldon Hearn.%A L. Masinter
4880f5fcaa3SSheldon Hearn.%A M. McCahill
4894ca1ab94SDag-Erling Smørgrav.%D December 1994
4904ca1ab94SDag-Erling Smørgrav.%T Uniform Resource Locators (URL)
4914ca1ab94SDag-Erling Smørgrav.%O RFC1738
4924ca1ab94SDag-Erling Smørgrav.Re
4934ca1ab94SDag-Erling Smørgrav.Rs
4940f5fcaa3SSheldon Hearn.%A R. Fielding
4950f5fcaa3SSheldon Hearn.%A J. Gettys
4960f5fcaa3SSheldon Hearn.%A J. Mogul
4970f5fcaa3SSheldon Hearn.%A H. Frystyk
4980f5fcaa3SSheldon Hearn.%A T. Berners-Lee
4994ca1ab94SDag-Erling Smørgrav.%D Januray 1997
5004ca1ab94SDag-Erling Smørgrav.%B Hypertext Transfer Protocol -- HTTP/1.1
5014ca1ab94SDag-Erling Smørgrav.%O RFC2068
5024ca1ab94SDag-Erling Smørgrav.Re
5034ca1ab94SDag-Erling Smørgrav.Rs
5040f5fcaa3SSheldon Hearn.%A J. Postel
5050f5fcaa3SSheldon Hearn.%A J. K. Reynolds
5064ca1ab94SDag-Erling Smørgrav.%D October 1985
5074ca1ab94SDag-Erling Smørgrav.%B File Transfer Protocol
5084ca1ab94SDag-Erling Smørgrav.%O RFC959
5094ca1ab94SDag-Erling Smørgrav.Re
5104ca1ab94SDag-Erling Smørgrav.Sh HISTORY
5114ca1ab94SDag-Erling SmørgravThe
5124ca1ab94SDag-Erling Smørgrav.Nm fetch
5134ca1ab94SDag-Erling Smørgravlibrary first appeared in
5144ca1ab94SDag-Erling Smørgrav.Fx 3.0 .
5154ca1ab94SDag-Erling Smørgrav.Sh AUTHORS
516725ab628SRuslan Ermilov.An -nosplit
5174ca1ab94SDag-Erling SmørgravThe
5184ca1ab94SDag-Erling Smørgrav.Nm fetch
5194ca1ab94SDag-Erling Smørgravlibrary was mostly written by
520b82f5db0SRuslan Ermilov.An Dag-Erling Co\(:idan Sm\(/orgrav Aq des@FreeBSD.org
5214ca1ab94SDag-Erling Smørgravwith numerous suggestions from
522d8acd8dcSDag-Erling Smørgrav.An Jordan K. Hubbard Aq jkh@FreeBSD.org ,
523d8acd8dcSDag-Erling Smørgrav.An Eugene Skepner Aq eu@qub.com
524b5c508fbSRuslan Ermilovand other
525b5c508fbSRuslan Ermilov.Fx
526b5c508fbSRuslan Ermilovdevelopers.
527d8acd8dcSDag-Erling SmørgravIt replaces the older
5284ca1ab94SDag-Erling Smørgrav.Nm ftpio
529d8acd8dcSDag-Erling Smørgravlibrary written by
530d8acd8dcSDag-Erling Smørgrav.An Poul-Henning Kamp Aq pkh@FreeBSD.org
531d8acd8dcSDag-Erling Smørgravand
5324ca1ab94SDag-Erling Smørgrav.An Jordan K. Hubbard Aq jkh@FreeBSD.org .
5334ca1ab94SDag-Erling Smørgrav.Pp
5344ca1ab94SDag-Erling SmørgravThis manual page was written by
535725ab628SRuslan Ermilov.An Dag-Erling Co\(:idan Sm\(/orgrav Aq des@FreeBSD.org .
5364ca1ab94SDag-Erling Smørgrav.Sh BUGS
537c6ff3a1bSSheldon HearnSome parts of the library are not yet implemented.
538c6ff3a1bSSheldon HearnThe most notable
539d8acd8dcSDag-Erling Smørgravexamples of this are
540d8acd8dcSDag-Erling Smørgrav.Fn fetchPutHTTP ,
541ce71b736SDag-Erling Smørgrav.Fn fetchListHTTP ,
54215efcd39SAlexey Zelkin.Fn fetchListFTP
543d8acd8dcSDag-Erling Smørgravand FTP proxy support.
544d8acd8dcSDag-Erling Smørgrav.Pp
545db5f8cebSDag-Erling SmørgravThere's no way to select a proxy at run-time other than setting the
546db5f8cebSDag-Erling Smørgrav.Ev HTTP_PROXY
547db5f8cebSDag-Erling Smørgravor
548db5f8cebSDag-Erling Smørgrav.Ev FTP_PROXY
549c6ff3a1bSSheldon Hearnenvironment variables as appropriate.
55098f5573fSDag-Erling Smørgrav.Pp
551842a95ccSDag-Erling Smørgrav.Nm libfetch
55298f5573fSDag-Erling Smørgravdoes not understand or obey 305 (Use Proxy) replies.
55398f5573fSDag-Erling Smørgrav.Pp
554842a95ccSDag-Erling SmørgravError numbers are unique only within a certain context; the error
555842a95ccSDag-Erling Smørgravcodes used for FTP and HTTP overlap, as do those used for resolver and
556c6ff3a1bSSheldon Hearnsystem errors.
557c6ff3a1bSSheldon HearnFor instance, error code 202 means "Command not
558842a95ccSDag-Erling Smørgravimplemented, superfluous at this site" in an FTP context and
559842a95ccSDag-Erling Smørgrav"Accepted" in an HTTP context.
560842a95ccSDag-Erling Smørgrav.Pp
561f5f109a0SDag-Erling Smørgrav.Fn fetchStatFTP
562f5f109a0SDag-Erling Smørgravdoes not check that the result of an MDTM command is a valid date.
563f5f109a0SDag-Erling Smørgrav.Pp
5641a5faa10SDag-Erling SmørgravThe man page is incomplete, poorly written and produces badly
5651a5faa10SDag-Erling Smørgravformatted text.
566db5f8cebSDag-Erling Smørgrav.Pp
567ba101983SDag-Erling SmørgravThe error reporting mechanism is unsatisfactory.
568ba101983SDag-Erling Smørgrav.Pp
569ba101983SDag-Erling SmørgravSome parts of the code are not fully reentrant.
570