pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/libfetch libfetch-2.13:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/5597362fa802
branches:  trunk
changeset: 541785:5597362fa802
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Fri Apr 25 19:59:30 2008 +0000

description:
libfetch-2.13:
Add a function to turn struct url back into a string.

diffstat:

 net/libfetch/Makefile         |   4 ++--
 net/libfetch/files/fetch.3    |   8 +++++++-
 net/libfetch/files/fetch.c    |  38 +++++++++++++++++++++++++++++++++++++-
 net/libfetch/files/fetch.cat3 |  18 +++++++++++-------
 net/libfetch/files/fetch.h    |   3 ++-
 5 files changed, 59 insertions(+), 12 deletions(-)

diffs (167 lines):

diff -r b1a35f09b145 -r 5597362fa802 net/libfetch/Makefile
--- a/net/libfetch/Makefile     Fri Apr 25 19:58:17 2008 +0000
+++ b/net/libfetch/Makefile     Fri Apr 25 19:59:30 2008 +0000
@@ -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 -r b1a35f09b145 -r 5597362fa802 net/libfetch/files/fetch.3
--- a/net/libfetch/files/fetch.3        Fri Apr 25 19:58:17 2008 +0000
+++ b/net/libfetch/files/fetch.3        Fri Apr 25 19:59:30 2008 +0000
@@ -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 @@
 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 -r b1a35f09b145 -r 5597362fa802 net/libfetch/files/fetch.c
--- a/net/libfetch/files/fetch.c        Fri Apr 25 19:58:17 2008 +0000
+++ b/net/libfetch/files/fetch.c        Fri Apr 25 19:59:30 2008 +0000
@@ -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@localhost>
@@ -590,3 +590,39 @@
        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 -r b1a35f09b145 -r 5597362fa802 net/libfetch/files/fetch.cat3
--- a/net/libfetch/files/fetch.cat3     Fri Apr 25 19:58:17 2008 +0000
+++ b/net/libfetch/files/fetch.cat3     Fri Apr 25 19:59:30 2008 +0000
@@ -7,8 +7,8 @@
      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 @@
      _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 @@
      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 -r b1a35f09b145 -r 5597362fa802 net/libfetch/files/fetch.h
--- a/net/libfetch/files/fetch.h        Fri Apr 25 19:58:17 2008 +0000
+++ b/net/libfetch/files/fetch.h        Fri Apr 25 19:59:30 2008 +0000
@@ -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 @@
                     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 */



Home | Main Index | Thread Index | Old Index