Submitted By:            Douglas R. Reno <renodr at linuxfromscratch dot org>
Date:                    2024-07-12
Initial Package Version: 1.14.52
Upstream Status:         Applied
Origin:                  Upstream (commit 5d4bb55095d3d6ef793c1908a88504183e28644c)
Description:             Fixes building libgsf with libxml2-2.13 by guarding
                         the usage of xmlNanoHTTPOpen and xmlNanoHTTPClose,
                         which were deprecated in libxml2-2.13.

diff -Naurp libgsf-1.14.52.orig/configure.ac libgsf-1.14.52/configure.ac
--- libgsf-1.14.52.orig/configure.ac	2023-11-02 17:57:21.000000000 -0500
+++ libgsf-1.14.52/configure.ac	2024-07-12 16:12:07.035273411 -0500
@@ -314,6 +314,7 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#inclu
 		AC_MSG_RESULT(yes)],
 	       [AC_MSG_RESULT(no)])
 AC_CHECK_FUNCS(g_date_time_new_from_iso8601 g_date_time_format_iso8601)
+AC_CHECK_FUNCS(xmlNanoHTTPOpen xmlNanoHTTPClose)
 CFLAGS=$SAVE_CFLAGS
 LIBS=$SAVE_LIBS
 
diff -Naurp libgsf-1.14.52.orig/gsf/gsf-input-http.c libgsf-1.14.52/gsf/gsf-input-http.c
--- libgsf-1.14.52.orig/gsf/gsf-input-http.c	2023-03-01 19:51:15.000000000 -0600
+++ libgsf-1.14.52/gsf/gsf-input-http.c	2024-07-12 16:15:34.112458816 -0500
@@ -20,10 +20,14 @@
  */
 
 #include <gsf-config.h>
+
 #include <gsf/gsf-input-http.h>
 #include <gsf/gsf.h>
 
+#ifdef HAVE_XMLNANOHTTPOPEN
+// It's going away, so make it conditional
 #include <libxml/nanohttp.h>
+#endif
 
 struct _GsfInputHTTP {
         GsfInput input;
@@ -74,7 +78,9 @@ gsf_input_http_finalize (GObject *obj_in
 	input->content_type = NULL;
 
         if (input->ctx) {
+#ifdef HAVE_XMLNANOHTTPCLOSE
                 xmlNanoHTTPClose ((gpointer) input->ctx);
+#endif
                 input->ctx = NULL;
         }
 
@@ -215,6 +221,7 @@ gsf_input_http_get_content_type (GsfInpu
         return content_type;
 }
 
+#ifdef HAVE_XMLNANOHTTPOPEN
 static GsfInput *
 make_local_copy (gpointer *ctx)
 {
@@ -254,6 +261,7 @@ make_local_copy (gpointer *ctx)
 
 	return copy;
 }
+#endif
 
 /**
  * gsf_input_http_new:
@@ -265,6 +273,7 @@ make_local_copy (gpointer *ctx)
 GsfInput *
 gsf_input_http_new (gchar const * url, GError **error G_GNUC_UNUSED)
 {
+#ifdef HAVE_XML_NANOHTTPOPEN
         GObject *obj;
 	GsfInput *input;
         gpointer ctx;
@@ -293,6 +302,10 @@ gsf_input_http_new (gchar const * url, G
         GSF_INPUT_HTTP (obj)->ctx = ctx;
 
         return GSF_INPUT (obj);
+#else
+        g_return_val_if_fail(url != NULL, NULL);
+        return NULL;
+#endif
 }
 
 static GsfInput *
@@ -304,6 +317,7 @@ gsf_input_http_dup (GsfInput *src, GErro
 static guint8 const *
 gsf_input_http_read (GsfInput *input, size_t num_bytes, guint8 *buffer)
 {
+#ifdef HAVE_XMLNANOHTTPOPEN
         int nread;
         size_t total_read;
         gpointer ctx = GSF_INPUT_HTTP (input)->ctx;
@@ -324,6 +338,12 @@ gsf_input_http_read (GsfInput *input, si
                         return NULL;
         }
         return buffer;
+#else
+        (void)input;
+        (void)num_bytes;
+        (void)buffer;
+        return NULL;
+#endif
 }
 
 static gboolean
