summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorjoerg <joerg@pkgsrc.org>2008-04-25 16:25:25 +0000
committerjoerg <joerg@pkgsrc.org>2008-04-25 16:25:25 +0000
commitd332b7e9e29e8a45f5bf0a677aa82c7dc707df4a (patch)
tree348d329de805a94a8aa32dc28db4e1279b987819 /net
parentadb4aa9e4cec17f37ea84ab5291edf3cd5d7365a (diff)
downloadpkgsrc-d332b7e9e29e8a45f5bf0a677aa82c7dc707df4a.tar.gz
libfetch-2.12:
Make function naming consistent before external code depend on it. Update man page.
Diffstat (limited to 'net')
-rw-r--r--net/libfetch/Makefile4
-rw-r--r--net/libfetch/files/common.c6
-rw-r--r--net/libfetch/files/fetch.362
-rw-r--r--net/libfetch/files/fetch.c8
-rw-r--r--net/libfetch/files/fetch.cat360
-rw-r--r--net/libfetch/files/fetch.h10
-rw-r--r--net/libfetch/files/file.c10
-rw-r--r--net/libfetch/files/ftp.c4
8 files changed, 112 insertions, 52 deletions
diff --git a/net/libfetch/Makefile b/net/libfetch/Makefile
index 3a9a148056c..13a8122157d 100644
--- a/net/libfetch/Makefile
+++ b/net/libfetch/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.14 2008/04/24 10:21:33 joerg Exp $
+# $NetBSD: Makefile,v 1.15 2008/04/25 16:25:25 joerg Exp $
#
-DISTNAME= libfetch-2.11
+DISTNAME= libfetch-2.12
CATEGORIES= net
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/net/libfetch/files/common.c b/net/libfetch/files/common.c
index d7ecc96a4e3..4cef72da61e 100644
--- a/net/libfetch/files/common.c
+++ b/net/libfetch/files/common.c
@@ -1,4 +1,4 @@
-/* $NetBSD: common.c,v 1.11 2008/04/24 10:21:33 joerg Exp $ */
+/* $NetBSD: common.c,v 1.12 2008/04/25 16:25:25 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
@@ -705,14 +705,14 @@ fetch_add_entry(struct url_list *ue, struct url *base, const char *name,
}
void
-fetch_init_url_list(struct url_list *ue)
+fetchInitURLList(struct url_list *ue)
{
ue->length = ue->alloc_size = 0;
ue->urls = NULL;
}
void
-fetch_free_url_list(struct url_list *ue)
+fetchFreeURLList(struct url_list *ue)
{
size_t i;
diff --git a/net/libfetch/files/fetch.3 b/net/libfetch/files/fetch.3
index 49800161836..5122f839fad 100644
--- a/net/libfetch/files/fetch.3
+++ b/net/libfetch/files/fetch.3
@@ -24,14 +24,15 @@
.\" SUCH DAMAGE.
.\"
.\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $
-.\" $NetBSD: fetch.3,v 1.5 2008/04/19 14:49:23 joerg Exp $
+.\" $NetBSD: fetch.3,v 1.6 2008/04/25 16:25:25 joerg Exp $
.\"
-.Dd April 19, 2008
+.Dd April 25, 2008
.Dt FETCH 3
.Os
.Sh NAME
.Nm fetchMakeURL ,
.Nm fetchParseURL ,
+.Nm fetchCopyURL ,
.Nm fetchFreeURL ,
.Nm fetchXGetURL ,
.Nm fetchGetURL ,
@@ -58,6 +59,11 @@
.Nm fetchPutFTP ,
.Nm fetchStatFTP ,
.Nm fetchListFTP
+.Nm fetchInitURLList ,
+.Nm fetchFreeURLList ,
+.Nm fetchUnquotePath ,
+.Nm fetchUnquoteFilename ,
+.Nm fetch
.Nd file transfer functions
.Sh LIBRARY
.Lb libfetch
@@ -68,6 +74,8 @@
.Fn fetchMakeURL "const char *scheme" "const char *host" "int port" "const char *doc" "const char *user" "const char *pwd"
.Ft struct url *
.Fn fetchParseURL "const char *URL"
+.Ft struct url *
+.Fn fetchCopyURL "const struct url *u"
.Ft void
.Fn fetchFreeURL "struct url *u"
.Ft fetchIO *
@@ -120,6 +128,14 @@
.Fn fetchStatFTP "struct url *u" "struct url_stat *us" "const char *flags"
.Ft int
.Fn fetchListFTP "struct url_list *list" "struct url *u" "const char *flags"
+.Ft void
+.Fn fetchInitURLList "struct url_list *ul"
+.Ft void
+.Fn fetchFreeURLList "struct url_list *ul"
+.Ft char *
+.Fn fetchUnquotePath "struct url *u"
+.Ft char *
+.Fn fetchUnquoteFilename "struct url *u"
.Sh DESCRIPTION
These functions implement a high-level library for retrieving and
uploading files using Uniform Resource Locators (URLs).
@@ -133,20 +149,26 @@ A regular expression which produces this syntax is:
<scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
.Ed
.Pp
-If the URL does not seem to begin with a scheme name, the following
-syntax is assumed:
-.Bd -literal
- ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
-.Ed
+If the URL does not seem to begin with a scheme name, it is assumed to be a local path.
+Only absolute path names are accepted.
.Pp
Note that some components of the URL are not necessarily relevant to
all URL schemes.
For instance, the file scheme only needs the <scheme> and <document>
components.
+.Fn fetchParseURL
+quotes any unsafe character in the URL automatically.
+This is not done by
+.Fn fetchMakeURL .
+.Fn fetchCopyURL
+copies an existing
+.Vt url
+structure.
.Pp
-.Fn fetchMakeURL
-and
+.Fn fetchMakeURL ,
.Fn fetchParseURL
+and
+.Fn fetchCopyURL
return a pointer to a
.Vt url
structure, which is defined as follows in
@@ -170,8 +192,9 @@ struct url {
.Ed
.Pp
The pointer returned by
-.Fn fetchMakeURL
-or
+.Fn fetchMakeURL ,
+.Fn fetchCopyURL
+and
.Fn fetchParseURL
should be freed using
.Fn fetchFreeURL .
@@ -245,9 +268,22 @@ struct url_list {
.Ed
.Pp
The list should be initialised by calling
-.Fn fetch_init_url_list
+.Fn fetchInitURLList
and the entries be freed by calling
-.Fn fetch_free_url_list .
+.Fn fetchFreeURLList .
+.Pp
+.Fn fetchUnquotePath
+returns the path name part of the URL with any quoting undone.
+Query arguments and fragment identifiers are not included.
+.Fn fetchUnquoteFilename
+returns the last component of the path name as returned by
+.Fn fetchUnquotePath .
+.Fn fetchUnquotePath
+and
+.Fn fetchUnquoteFilename
+return a string that should be deallocated with
+.Fn free
+after use.
.Pp
.Fn fetchXGet ,
.Fn fetchGet ,
diff --git a/net/libfetch/files/fetch.c b/net/libfetch/files/fetch.c
index 4ba9f0d0a19..218156cf18d 100644
--- a/net/libfetch/files/fetch.c
+++ b/net/libfetch/files/fetch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fetch.c,v 1.9 2008/04/24 10:24:04 joerg Exp $ */
+/* $NetBSD: fetch.c,v 1.10 2008/04/25 16:25:25 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
@@ -545,7 +545,7 @@ xdigit2digit(char digit)
* Skips optional parts like query or fragment identifier.
*/
char *
-fetch_unquote_doc(struct url *url)
+fetchUnquotePath(struct url *url)
{
char *unquoted;
const char *iter;
@@ -576,12 +576,12 @@ fetch_unquote_doc(struct url *url)
* Extract the file name component of a URL.
*/
char *
-fetch_extract_filename(struct url *url)
+fetchUnquoteFilename(struct url *url)
{
char *unquoted, *filename;
const char *last_slash;
- if ((unquoted = fetch_unquote_doc(url)) == NULL)
+ if ((unquoted = fetchUnquotePath(url)) == NULL)
return NULL;
if ((last_slash = strrchr(unquoted, '/')) == NULL)
diff --git a/net/libfetch/files/fetch.cat3 b/net/libfetch/files/fetch.cat3
index 48fd3d92c2b..df7815836f9 100644
--- a/net/libfetch/files/fetch.cat3
+++ b/net/libfetch/files/fetch.cat3
@@ -1,12 +1,14 @@
FETCH(3) NetBSD Library Functions Manual FETCH(3)
NNAAMMEE
- ffeettcchhMMaakkeeUURRLL, ffeettcchhPPaarrsseeUURRLL, ffeettcchhFFrreeeeUURRLL, ffeettcchhXXGGeettUURRLL, ffeettcchhGGeettUURRLL,
- ffeettcchhPPuuttUURRLL, ffeettcchhSSttaattUURRLL, ffeettcchhLLiissttUURRLL, ffeettcchhXXGGeett, ffeettcchhGGeett, ffeettcchhPPuutt,
- ffeettcchhSSttaatt, ffeettcchhLLiisstt, ffeettcchhXXGGeettFFiillee, ffeettcchhGGeettFFiillee, ffeettcchhPPuuttFFiillee,
- ffeettcchhSSttaattFFiillee, ffeettcchhLLiissttFFiillee, ffeettcchhXXGGeettHHTTTTPP, ffeettcchhGGeettHHTTTTPP, ffeettcchhPPuuttHHTTTTPP,
- ffeettcchhSSttaattHHTTTTPP, ffeettcchhLLiissttHHTTTTPP, ffeettcchhXXGGeettFFTTPP, ffeettcchhGGeettFFTTPP, ffeettcchhPPuuttFFTTPP,
- ffeettcchhSSttaattFFTTPP, ffeettcchhLLiissttFFTTPP -- file transfer functions
+ ffeettcchhMMaakkeeUURRLL, ffeettcchhPPaarrsseeUURRLL, ffeettcchhCCooppyyUURRLL, ffeettcchhFFrreeeeUURRLL, ffeettcchhXXGGeettUURRLL,
+ ffeettcchhGGeettUURRLL, ffeettcchhPPuuttUURRLL, ffeettcchhSSttaattUURRLL, ffeettcchhLLiissttUURRLL, ffeettcchhXXGGeett,
+ ffeettcchhGGeett, ffeettcchhPPuutt, ffeettcchhSSttaatt, ffeettcchhLLiisstt, ffeettcchhXXGGeettFFiillee, ffeettcchhGGeettFFiillee,
+ ffeettcchhPPuuttFFiillee, ffeettcchhSSttaattFFiillee, ffeettcchhLLiissttFFiillee, ffeettcchhXXGGeettHHTTTTPP, ffeettcchhGGeettHHTTTTPP,
+ ffeettcchhPPuuttHHTTTTPP, ffeettcchhSSttaattHHTTTTPP, ffeettcchhLLiissttHHTTTTPP, ffeettcchhXXGGeettFFTTPP, ffeettcchhGGeettFFTTPP,
+ ffeettcchhPPuuttFFTTPP, ffeettcchhSSttaattFFTTPP, ffeettcchhLLiissttFFTTPP ffeettcchhIInniittUURRLLLLiisstt,
+ ffeettcchhFFrreeeeUURRLLLLiisstt, ffeettcchhUUnnqquuootteePPaatthh, ffeettcchhUUnnqquuootteeFFiilleennaammee, ffeettcchh -- file
+ transfer functions
LLIIBBRRAARRYY
library ``libfetch''
@@ -22,6 +24,9 @@ SSYYNNOOPPSSIISS
_s_t_r_u_c_t _u_r_l _*
ffeettcchhPPaarrsseeUURRLL(_c_o_n_s_t _c_h_a_r _*_U_R_L);
+ _s_t_r_u_c_t _u_r_l _*
+ ffeettcchhCCooppyyUURRLL(_c_o_n_s_t _s_t_r_u_c_t _u_r_l _*_u);
+
_v_o_i_d
ffeettcchhFFrreeeeUURRLL(_s_t_r_u_c_t _u_r_l _*_u);
@@ -100,6 +105,18 @@ SSYYNNOOPPSSIISS
_i_n_t
ffeettcchhLLiissttFFTTPP(_s_t_r_u_c_t _u_r_l___l_i_s_t _*_l_i_s_t, _s_t_r_u_c_t _u_r_l _*_u, _c_o_n_s_t _c_h_a_r _*_f_l_a_g_s);
+ _v_o_i_d
+ ffeettcchhIInniittUURRLLLLiisstt(_s_t_r_u_c_t _u_r_l___l_i_s_t _*_u_l);
+
+ _v_o_i_d
+ ffeettcchhFFrreeeeUURRLLLLiisstt(_s_t_r_u_c_t _u_r_l___l_i_s_t _*_u_l);
+
+ _c_h_a_r _*
+ ffeettcchhUUnnqquuootteePPaatthh(_s_t_r_u_c_t _u_r_l _*_u);
+
+ _c_h_a_r _*
+ ffeettcchhUUnnqquuootteeFFiilleennaammee(_s_t_r_u_c_t _u_r_l _*_u);
+
DDEESSCCRRIIPPTTIIOONN
These functions implement a high-level library for retrieving and upload-
ing files using Uniform Resource Locators (URLs).
@@ -111,17 +128,17 @@ DDEESSCCRRIIPPTTIIOONN
<scheme>:(//(<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
- If the URL does not seem to begin with a scheme name, the following syn-
- tax is assumed:
-
- ((<user>(:<pwd>)?@)?<host>(:<port>)?)?/(<document>)?
+ If the URL does not seem to begin with a scheme name, it is assumed to be
+ a local path. Only absolute path names are accepted.
Note that some components of the URL are not necessarily relevant to all
URL schemes. For instance, the file scheme only needs the <scheme> and
- <document> components.
+ <document> components. ffeettcchhPPaarrsseeUURRLL() quotes any unsafe character in
+ the URL automatically. This is not done by ffeettcchhMMaakkeeUURRLL().
+ ffeettcchhCCooppyyUURRLL() copies an existing _u_r_l structure.
- ffeettcchhMMaakkeeUURRLL() and ffeettcchhPPaarrsseeUURRLL() return a pointer to a _u_r_l structure,
- which is defined as follows in <_f_e_t_c_h_._h>:
+ ffeettcchhMMaakkeeUURRLL(), ffeettcchhPPaarrsseeUURRLL() and ffeettcchhCCooppyyUURRLL() return a pointer to a
+ _u_r_l structure, which is defined as follows in <_f_e_t_c_h_._h>:
#define URL_SCHEMELEN 16
#define URL_USERLEN 256
@@ -139,8 +156,8 @@ DDEESSCCRRIIPPTTIIOONN
size_t length;
};
- The pointer returned by ffeettcchhMMaakkeeUURRLL() or ffeettcchhPPaarrsseeUURRLL() should be freed
- using ffeettcchhFFrreeeeUURRLL().
+ The pointer returned by ffeettcchhMMaakkeeUURRLL(), ffeettcchhCCooppyyUURRLL() and
+ ffeettcchhPPaarrsseeUURRLL() should be freed using ffeettcchhFFrreeeeUURRLL().
ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), and ffeettcchhPPuuttUURRLL() constitute the recom-
mended interface to the ffeettcchh library. They examine the URL passed to
@@ -181,8 +198,15 @@ DDEESSCCRRIIPPTTIIOONN
struct url *urls;
};
- The list should be initialised by calling ffeettcchh__iinniitt__uurrll__lliisstt() and the
- entries be freed by calling ffeettcchh__ffrreeee__uurrll__lliisstt().
+ The list should be initialised by calling ffeettcchhIInniittUURRLLLLiisstt() and the
+ entries be freed by calling ffeettcchhFFrreeeeUURRLLLLiisstt().
+
+ ffeettcchhUUnnqquuootteePPaatthh() returns the path name part of the URL with any quoting
+ undone. Query arguments and fragment identifiers are not included.
+ ffeettcchhUUnnqquuootteeFFiilleennaammee() returns the last component of the path name as
+ returned by ffeettcchhUUnnqquuootteePPaatthh(). ffeettcchhUUnnqquuootteePPaatthh() and
+ ffeettcchhUUnnqquuootteeFFiilleennaammee() return a string that should be deallocated with
+ ffrreeee() after use.
ffeettcchhXXGGeett(), ffeettcchhGGeett(), ffeettcchhPPuutt() and ffeettcchhSSttaatt() are similar to
ffeettcchhXXGGeettUURRLL(), ffeettcchhGGeettUURRLL(), ffeettcchhPPuuttUURRLL() and ffeettcchhSSttaattUURRLL(), except
@@ -465,4 +489,4 @@ BBUUGGSS
Some parts of the code are not fully reentrant.
-NetBSD 4.0 April 19, 2008 NetBSD 4.0
+NetBSD 4.0 April 25, 2008 NetBSD 4.0
diff --git a/net/libfetch/files/fetch.h b/net/libfetch/files/fetch.h
index 7917746b932..3fb8af01eb3 100644
--- a/net/libfetch/files/fetch.h
+++ b/net/libfetch/files/fetch.h
@@ -1,4 +1,4 @@
-/* $NetBSD: fetch.h,v 1.9 2008/04/24 10:21:33 joerg Exp $ */
+/* $NetBSD: fetch.h,v 1.10 2008/04/25 16:25:25 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved.
@@ -149,10 +149,10 @@ struct url *fetchCopyURL(const struct url *);
void fetchFreeURL(struct url *);
/* URL listening */
-void fetch_init_url_list(struct url_list *);
-void fetch_free_url_list(struct url_list *);
-char *fetch_unquote_doc(struct url *);
-char *fetch_extract_filename(struct url *);
+void fetchInitURLList(struct url_list *);
+void fetchFreeURLList(struct url_list *);
+char *fetchUnquotePath(struct url *);
+char *fetchUnquoteFilename(struct url *);
/* Authentication */
typedef int (*auth_t)(struct url *);
diff --git a/net/libfetch/files/file.c b/net/libfetch/files/file.c
index 7b730d4bea0..19aa5493e66 100644
--- a/net/libfetch/files/file.c
+++ b/net/libfetch/files/file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: file.c,v 1.10 2008/04/24 10:24:04 joerg Exp $ */
+/* $NetBSD: file.c,v 1.11 2008/04/25 16:25:25 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
@@ -74,7 +74,7 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
fetchIO *f;
int fd, *cookie;
- if ((path = fetch_unquote_doc(u)) == NULL) {
+ if ((path = fetchUnquotePath(u)) == NULL) {
fetch_syserr();
return NULL;
}
@@ -126,7 +126,7 @@ fetchPutFile(struct url *u, const char *flags)
fetchIO *f;
int fd, *cookie;
- if ((path = fetch_unquote_doc(u)) == NULL) {
+ if ((path = fetchUnquotePath(u)) == NULL) {
fetch_syserr();
return NULL;
}
@@ -188,7 +188,7 @@ fetchStatFile(struct url *u, struct url_stat *us, const char *flags)
char *path;
int fd, rv;
- if ((path = fetch_unquote_doc(u)) == NULL) {
+ if ((path = fetchUnquotePath(u)) == NULL) {
fetch_syserr();
return -1;
}
@@ -214,7 +214,7 @@ fetchListFile(struct url_list *ue, struct url *u, const char *pattern, const cha
struct dirent *de;
DIR *dir;
- if ((path = fetch_unquote_doc(u)) == NULL) {
+ if ((path = fetchUnquotePath(u)) == NULL) {
fetch_syserr();
return -1;
}
diff --git a/net/libfetch/files/ftp.c b/net/libfetch/files/ftp.c
index fc731197a24..7e324dfc99a 100644
--- a/net/libfetch/files/ftp.c
+++ b/net/libfetch/files/ftp.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ftp.c,v 1.21 2008/04/24 10:21:33 joerg Exp $ */
+/* $NetBSD: ftp.c,v 1.22 2008/04/25 16:25:25 joerg Exp $ */
/*-
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
@@ -1126,7 +1126,7 @@ ftp_request(struct url *url, const char *op, const char *op_arg,
if (conn == NULL)
return (NULL);
- if ((path = fetch_unquote_doc(url)) == NULL) {
+ if ((path = fetchUnquotePath(url)) == NULL) {
fetch_syserr();
return NULL;
}