[libsoup/wip/soup-uri-removal: 20/21] Privitize most URI functions and document the public ones




commit 6e497d6405fa043926cd324f16630d33c8c65255
Author: Patrick Griffis <pgriffis igalia com>
Date:   Sun Oct 25 13:30:09 2020 -0500

    Privitize most URI functions and document the public ones

 docs/reference/libsoup-3.0-docs.xml           |  2 +-
 docs/reference/libsoup-3.0-sections.txt       |  9 +++++
 libsoup/auth/soup-auth-negotiate.c            |  2 +-
 libsoup/include/soup-installed.h              |  2 +-
 libsoup/meson.build                           |  4 +-
 libsoup/server/soup-server.h                  |  2 +-
 libsoup/soup-uri-utils-private.h              | 36 +++++++++++++++++
 libsoup/{soup-uri.c => soup-uri-utils.c}      | 18 ++++++++-
 libsoup/soup-uri-utils.h                      | 35 +++++++++++++++++
 libsoup/soup-uri.h                            | 56 ---------------------------
 libsoup/soup.h                                |  3 +-
 libsoup/websocket/soup-websocket-connection.c |  2 +-
 12 files changed, 106 insertions(+), 65 deletions(-)
---
diff --git a/docs/reference/libsoup-3.0-docs.xml b/docs/reference/libsoup-3.0-docs.xml
index b52a4920..2567b281 100644
--- a/docs/reference/libsoup-3.0-docs.xml
+++ b/docs/reference/libsoup-3.0-docs.xml
@@ -38,7 +38,6 @@
     <xi:include href="xml/soup-multipart-input-stream.xml"/>
     <xi:include href="xml/soup-session.xml"/>
     <xi:include href="xml/soup-status.xml"/>
-    <xi:include href="xml/soup-uri.xml"/>
   </chapter>
 
   <chapter>
@@ -93,6 +92,7 @@
     <title>Utility API</title>
     <xi:include href="xml/soup-date-utils.xml"/>
     <xi:include href="xml/soup-tld.xml"/>
+    <xi:include href="xml/soup-uri-utils.xml"/>
     <xi:include href="xml/soup-version.xml"/>
   </chapter>
 
diff --git a/docs/reference/libsoup-3.0-sections.txt b/docs/reference/libsoup-3.0-sections.txt
index 37fdc0a3..eff7f6b6 100644
--- a/docs/reference/libsoup-3.0-sections.txt
+++ b/docs/reference/libsoup-3.0-sections.txt
@@ -573,6 +573,15 @@ soup_date_time_to_string
 soup_date_time_is_past
 </SECTION>
 
+<SECTION>
+<FILE>soup-uri-utils</FILE>
+soup_uri_equal
+soup_uri_copy_with_query_from_form
+soup_uri_copy_with_query_from_fields
+soup_uri_get_port_with_default
+SOUP_HTTP_URI_FLAGS
+</SECTION>
+
 <SECTION>
 <FILE>soup-form</FILE>
 <TITLE>SoupForm</TITLE>
diff --git a/libsoup/auth/soup-auth-negotiate.c b/libsoup/auth/soup-auth-negotiate.c
index 916337f2..84cbb0f1 100644
--- a/libsoup/auth/soup-auth-negotiate.c
+++ b/libsoup/auth/soup-auth-negotiate.c
@@ -21,7 +21,7 @@
 #include "soup-message.h"
 #include "soup-message-private.h"
 #include "soup-misc.h"
-#include "soup-uri.h"
+#include "soup-uri-utils-private.h"
 
 /**
  * soup_auth_negotiate_supported:
diff --git a/libsoup/include/soup-installed.h b/libsoup/include/soup-installed.h
index 1abe966e..aa522c41 100644
--- a/libsoup/include/soup-installed.h
+++ b/libsoup/include/soup-installed.h
@@ -48,7 +48,7 @@ extern "C" {
 #include <libsoup/soup-session-feature.h>
 #include <libsoup/soup-status.h>
 #include <libsoup/soup-tld.h>
-#include <libsoup/soup-uri.h>
+#include <libsoup/soup-uri-utils.h>
 #include <libsoup/soup-version.h>
 #include <libsoup/soup-websocket.h>
 #include <libsoup/soup-websocket-connection.h>
diff --git a/libsoup/meson.build b/libsoup/meson.build
index 3a700870..49304398 100644
--- a/libsoup/meson.build
+++ b/libsoup/meson.build
@@ -84,7 +84,7 @@ soup_sources = [
   'soup-socket-properties.c',
   'soup-status.c',
   'soup-tld.c',
-  'soup-uri.c',
+  'soup-uri-utils.c',
   'soup-version.c',
 ]
 
@@ -146,7 +146,7 @@ soup_introspection_headers = [
   'soup-status.h',
   'soup-tld.h',
   'soup-types.h',
-  'soup-uri.h',
+  'soup-uri-utils.h',
 ]
 
 soup_installed_headers = soup_introspection_headers
diff --git a/libsoup/server/soup-server.h b/libsoup/server/soup-server.h
index b5225207..8a8d53d0 100644
--- a/libsoup/server/soup-server.h
+++ b/libsoup/server/soup-server.h
@@ -6,7 +6,7 @@
 #pragma once
 
 #include "soup-types.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup-websocket-connection.h"
 
 G_BEGIN_DECLS
diff --git a/libsoup/soup-uri-utils-private.h b/libsoup/soup-uri-utils-private.h
new file mode 100644
index 00000000..526ba0ee
--- /dev/null
+++ b/libsoup/soup-uri-utils-private.h
@@ -0,0 +1,36 @@
+/* 
+ * Copyright 1999-2002 Ximian, Inc.
+ * Copyright 2020 Igalia, S.L.
+ */
+
+
+#pragma once
+
+#include "soup-uri-utils.h"
+
+G_BEGIN_DECLS
+
+gboolean     soup_uri_is_http               (GUri       *uri,
+                                             char      **aliases);
+
+gboolean     soup_uri_is_https              (GUri       *uri,
+                                             char      **aliases);
+
+gboolean     soup_uri_uses_default_port     (GUri       *uri);
+
+GUri        *soup_uri_copy_with_credentials (GUri       *uri,
+                                             const char *username,
+                                             const char *password);
+
+char        *soup_uri_get_path_and_query    (GUri       *uri);
+
+GUri        *soup_uri_copy_host             (GUri       *uri);
+
+gboolean     soup_uri_valid_for_http        (GUri       *uri,
+                                             GError    **error);
+
+guint        soup_uri_host_hash             (gconstpointer key);
+
+gboolean     soup_uri_host_equal            (gconstpointer v1, gconstpointer v2);
+
+G_END_DECLS
diff --git a/libsoup/soup-uri.c b/libsoup/soup-uri-utils.c
similarity index 96%
rename from libsoup/soup-uri.c
rename to libsoup/soup-uri-utils.c
index 502ad461..e5a88d75 100644
--- a/libsoup/soup-uri.c
+++ b/libsoup/soup-uri-utils.c
@@ -12,10 +12,17 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup.h"
 #include "soup-misc.h"
 
+/**
+ * SECTION:soup-uri-utils
+ * @section_id: SoupURIUtils
+ * @title: URI Utilities
+ * @short_description: Functions to help working with #GUri and HTTP
+ */
+
 static inline int
 soup_scheme_default_port (const char *scheme)
 {
@@ -52,6 +59,15 @@ path_equal (const char *one, const char *two)
        return !strcmp (one, two);
 }
 
+/**
+ * soup_uri_get_port_with_default:
+ * @uri: A #GUri
+ *
+ * If @uri has a port of `-1` this will return the default
+ * port for the sheme it uses if known.
+ *
+ * Returns: The port to use with the @uri or `-1` if unknown.
+ */
 int
 soup_uri_get_port_with_default (GUri *uri)
 {
diff --git a/libsoup/soup-uri-utils.h b/libsoup/soup-uri-utils.h
new file mode 100644
index 00000000..8bc6bd2a
--- /dev/null
+++ b/libsoup/soup-uri-utils.h
@@ -0,0 +1,35 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* 
+ * Copyright 1999-2002 Ximian, Inc.
+ */
+
+
+#pragma once
+
+#include "soup-types.h"
+
+G_BEGIN_DECLS
+
+SOUP_AVAILABLE_IN_ALL
+gboolean soup_uri_equal (GUri *uri1, GUri *uri2);
+
+SOUP_AVAILABLE_IN_ALL
+GUri       *soup_uri_copy_with_query_from_form   (GUri       *uri,
+                                                  GHashTable *form);
+
+SOUP_AVAILABLE_IN_ALL
+GUri       *soup_uri_copy_with_query_from_fields (GUri       *uri,
+                                                  const char *first_field,
+                                                  ...) G_GNUC_NULL_TERMINATED;
+
+SOUP_AVAILABLE_IN_ALL
+int          soup_uri_get_port_with_default      (GUri       *uri);
+
+/**
+ * SOUP_HTTP_URI_FLAGS:
+ * The set of #GUriFlags libsoup expects all #GUri to use.
+ */
+#define SOUP_HTTP_URI_FLAGS (G_URI_FLAGS_HAS_PASSWORD | G_URI_FLAGS_ENCODED_PATH | G_URI_FLAGS_ENCODED_QUERY 
| G_URI_FLAGS_ENCODED_FRAGMENT | G_URI_FLAGS_SCHEME_NORMALIZE)
+
+G_END_DECLS
diff --git a/libsoup/soup.h b/libsoup/soup.h
index bd95488e..716e7272 100644
--- a/libsoup/soup.h
+++ b/libsoup/soup.h
@@ -51,7 +51,8 @@ extern "C" {
 #include "soup-socket.h"
 #include "soup-status.h"
 #include "soup-tld.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
+#include "soup-uri-utils-private.h"
 #include "soup-version.h"
 #include "websocket/soup-websocket.h"
 #include "websocket/soup-websocket-connection.h"
diff --git a/libsoup/websocket/soup-websocket-connection.c b/libsoup/websocket/soup-websocket-connection.c
index 6c85c8f9..6bfbeddd 100644
--- a/libsoup/websocket/soup-websocket-connection.c
+++ b/libsoup/websocket/soup-websocket-connection.c
@@ -25,7 +25,7 @@
 #include "soup-websocket-connection.h"
 #include "soup-enum-types.h"
 #include "soup-io-stream.h"
-#include "soup-uri.h"
+#include "soup-uri-utils.h"
 #include "soup-websocket-extension.h"
 
 /*


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