libfetch-2.12:
Make function naming consistent before external code depend on it. Update man page.
This commit is contained in:
parent
adb4aa9e4c
commit
d332b7e9e2
8 changed files with 113 additions and 53 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.
|
||||
.Pp
|
||||
.Fn fetchMakeURL
|
||||
and
|
||||
.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 ,
|
||||
.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 ,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 *);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue