diff options
Diffstat (limited to 'net/libfetch')
-rw-r--r-- | net/libfetch/Makefile | 4 | ||||
-rw-r--r-- | net/libfetch/files/fetch.3 | 8 | ||||
-rw-r--r-- | net/libfetch/files/fetch.c | 38 | ||||
-rw-r--r-- | net/libfetch/files/fetch.cat3 | 18 | ||||
-rw-r--r-- | net/libfetch/files/fetch.h | 3 |
5 files changed, 59 insertions, 12 deletions
diff --git a/net/libfetch/Makefile b/net/libfetch/Makefile index 13a8122157d..ca0b4d5de71 100644 --- a/net/libfetch/Makefile +++ b/net/libfetch/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.15 2008/04/25 16:25:25 joerg Exp $ +# $NetBSD: Makefile,v 1.16 2008/04/25 19:59:30 joerg Exp $ # -DISTNAME= libfetch-2.12 +DISTNAME= libfetch-2.13 CATEGORIES= net MASTER_SITES= # empty DISTFILES= # empty diff --git a/net/libfetch/files/fetch.3 b/net/libfetch/files/fetch.3 index 5122f839fad..fa5976fb10a 100644 --- a/net/libfetch/files/fetch.3 +++ b/net/libfetch/files/fetch.3 @@ -24,7 +24,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $ -.\" $NetBSD: fetch.3,v 1.6 2008/04/25 16:25:25 joerg Exp $ +.\" $NetBSD: fetch.3,v 1.7 2008/04/25 19:59:30 joerg Exp $ .\" .Dd April 25, 2008 .Dt FETCH 3 @@ -63,6 +63,7 @@ .Nm fetchFreeURLList , .Nm fetchUnquotePath , .Nm fetchUnquoteFilename , +.Nm fetchStringifyURL , .Nm fetch .Nd file transfer functions .Sh LIBRARY @@ -136,6 +137,8 @@ .Fn fetchUnquotePath "struct url *u" .Ft char * .Fn fetchUnquoteFilename "struct url *u" +.Ft char * +.Fn fetchStringifyURL "const struct url *u" .Sh DESCRIPTION These functions implement a high-level library for retrieving and uploading files using Uniform Resource Locators (URLs). @@ -272,12 +275,15 @@ The list should be initialised by calling and the entries be freed by calling .Fn fetchFreeURLList . .Pp +.Fn fetchStringifyURL +returns the URL as string. .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 fetchStringifyURL , .Fn fetchUnquotePath and .Fn fetchUnquoteFilename diff --git a/net/libfetch/files/fetch.c b/net/libfetch/files/fetch.c index 218156cf18d..d322054bef6 100644 --- a/net/libfetch/files/fetch.c +++ b/net/libfetch/files/fetch.c @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.10 2008/04/25 16:25:25 joerg Exp $ */ +/* $NetBSD: fetch.c,v 1.11 2008/04/25 19:59:30 joerg Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org> @@ -590,3 +590,39 @@ fetchUnquoteFilename(struct url *url) free(unquoted); return filename; } + +char * +fetchStringifyURL(const struct url *url) +{ + size_t total; + char *doc; + + /* scheme :// user : pwd @ host :port doc */ + total = strlen(url->scheme) + 3 + strlen(url->user) + 1 + + strlen(url->pwd) + 1 + strlen(url->host) + 6 + strlen(url->doc) + 1; + if ((doc = malloc(total)) == NULL) + return NULL; + if (url->port != 0) + snprintf(doc, total, "%s%s%s%s%s%s%s:%d%s", + url->scheme, + url->scheme[0] != '\0' ? "://" : "", + url->user, + url->pwd[0] != '\0' ? ":" : "", + url->pwd, + url->user[0] != '\0' || url->pwd[0] != '\0' ? "@" : "", + url->host, + (int)url->port, + url->doc); + else { + snprintf(doc, total, "%s%s%s%s%s%s%s%s", + url->scheme, + url->scheme[0] != '\0' ? "://" : "", + url->user, + url->pwd[0] != '\0' ? ":" : "", + url->pwd, + url->user[0] != '\0' || url->pwd[0] != '\0' ? "@" : "", + url->host, + url->doc); + } + return doc; +} diff --git a/net/libfetch/files/fetch.cat3 b/net/libfetch/files/fetch.cat3 index df7815836f9..7031a66409d 100644 --- a/net/libfetch/files/fetch.cat3 +++ b/net/libfetch/files/fetch.cat3 @@ -7,8 +7,8 @@ NNAAMMEE ffeettcchhPPuuttFFiillee, ffeettcchhSSttaattFFiillee, ffeettcchhLLiissttFFiillee, ffeettcchhXXGGeettHHTTTTPP, ffeettcchhGGeettHHTTTTPP, ffeettcchhPPuuttHHTTTTPP, ffeettcchhSSttaattHHTTTTPP, ffeettcchhLLiissttHHTTTTPP, ffeettcchhXXGGeettFFTTPP, ffeettcchhGGeettFFTTPP, ffeettcchhPPuuttFFTTPP, ffeettcchhSSttaattFFTTPP, ffeettcchhLLiissttFFTTPP ffeettcchhIInniittUURRLLLLiisstt, - ffeettcchhFFrreeeeUURRLLLLiisstt, ffeettcchhUUnnqquuootteePPaatthh, ffeettcchhUUnnqquuootteeFFiilleennaammee, ffeettcchh -- file - transfer functions + ffeettcchhFFrreeeeUURRLLLLiisstt, ffeettcchhUUnnqquuootteePPaatthh, ffeettcchhUUnnqquuootteeFFiilleennaammee, + ffeettcchhSSttrriinnggiiffyyUURRLL, ffeettcchh -- file transfer functions LLIIBBRRAARRYY library ``libfetch'' @@ -117,6 +117,9 @@ SSYYNNOOPPSSIISS _c_h_a_r _* ffeettcchhUUnnqquuootteeFFiilleennaammee(_s_t_r_u_c_t _u_r_l _*_u); + _c_h_a_r _* + ffeettcchhSSttrriinnggiiffyyUURRLL(_c_o_n_s_t _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). @@ -201,12 +204,13 @@ DDEESSCCRRIIPPTTIIOONN 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. + ffeettcchhSSttrriinnggiiffyyUURRLL() returns the URL as string. 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. + returned by ffeettcchhUUnnqquuootteePPaatthh(). ffeettcchhSSttrriinnggiiffyyUURRLL(), 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 diff --git a/net/libfetch/files/fetch.h b/net/libfetch/files/fetch.h index 3fb8af01eb3..9a7b80cf262 100644 --- a/net/libfetch/files/fetch.h +++ b/net/libfetch/files/fetch.h @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.h,v 1.10 2008/04/25 16:25:25 joerg Exp $ */ +/* $NetBSD: fetch.h,v 1.11 2008/04/25 19:59:30 joerg Exp $ */ /*- * Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav * All rights reserved. @@ -146,6 +146,7 @@ struct url *fetchMakeURL(const char *, const char *, int, const char *, const char *, const char *); struct url *fetchParseURL(const char *); struct url *fetchCopyURL(const struct url *); +char *fetchStringifyURL(const struct url *); void fetchFreeURL(struct url *); /* URL listening */ |