[libsoup] [SoupURI] add a bit of ftp URI support



commit 3d1662144df8e98619c98481d59f695598ec5f96
Author: Dan Winship <danw gnome org>
Date:   Fri Dec 18 12:34:47 2009 +0100

    [SoupURI] add a bit of ftp URI support

 libsoup/soup-uri.c |   14 +++++++++++++-
 libsoup/soup-uri.h |    5 +++++
 2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri.c
index 8cb49fd..ffc4f1d 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri.c
@@ -96,6 +96,8 @@ static char *uri_decoded_copy (const char *str, int length);
 static char *uri_normalized_copy (const char *str, int length, const char *unescape_extra, gboolean fixup);
 
 gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
+gpointer _SOUP_URI_SCHEME_FTP;
+gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA;
 
 static inline const char *
 soup_uri_get_scheme (const char *scheme, int len)
@@ -122,6 +124,8 @@ soup_scheme_default_port (const char *scheme)
 		return 80;
 	else if (scheme == SOUP_URI_SCHEME_HTTPS)
 		return 443;
+	else if (scheme == SOUP_URI_SCHEME_FTP)
+		return 21;
 	else
 		return 0;
 }
@@ -358,6 +362,13 @@ soup_uri_new_with_base (SoupURI *base, const char *uri_string)
 		}
 	}
 
+	if (uri->scheme == SOUP_URI_SCHEME_FTP) {
+		if (!uri->host) {
+			soup_uri_free (uri);
+			return NULL;
+		}
+	}
+
 	if (!uri->port)
 		uri->port = soup_scheme_default_port (uri->scheme);
 	if (!uri->path)
@@ -745,7 +756,8 @@ gboolean
 soup_uri_uses_default_port (SoupURI *uri)
 {
 	g_return_val_if_fail (uri->scheme == SOUP_URI_SCHEME_HTTP ||
-			      uri->scheme == SOUP_URI_SCHEME_HTTPS, FALSE);
+			      uri->scheme == SOUP_URI_SCHEME_HTTPS ||
+			      uri->scheme == SOUP_URI_SCHEME_FTP, FALSE);
 
 	return uri->port == soup_scheme_default_port (uri->scheme);
 }
diff --git a/libsoup/soup-uri.h b/libsoup/soup-uri.h
index 21e465d..67a0580 100644
--- a/libsoup/soup-uri.h
+++ b/libsoup/soup-uri.h
@@ -33,7 +33,12 @@ GType     soup_uri_get_type          (void);
 
 #define SOUP_URI_SCHEME_HTTP  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "http")
 #define SOUP_URI_SCHEME_HTTPS _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "https")
+#define SOUP_URI_SCHEME_FTP   _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "ftp")
+#define SOUP_URI_SCHEME_FILE  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTP, "file")
+#define SOUP_URI_SCHEME_DATA  _SOUP_ATOMIC_INTERN_STRING (_SOUP_URI_SCHEME_HTTPS, "data")
 extern gpointer _SOUP_URI_SCHEME_HTTP, _SOUP_URI_SCHEME_HTTPS;
+extern gpointer _SOUP_URI_SCHEME_FTP;
+extern gpointer _SOUP_URI_SCHEME_FILE, _SOUP_URI_SCHEME_DATA;
 
 SoupURI  *soup_uri_new_with_base         (SoupURI    *base,
 					  const char *uri_string);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]