From 77a7a6cb4e77bc3249be134feb6d2552eb8f9703 Mon Sep 17 00:00:00 2001 From: short <> Date: Wed, 24 Sep 2003 01:57:17 +0000 Subject: [PATCH] Compatibility with glib-2.0.x - missing g_str_has_suffix(). --- Makefile.am | 3 ++- configure.in | 2 ++ g_str_has_suffix.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ modules/http-method.c | 4 ++++ 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 g_str_has_suffix.c diff --git a/Makefile.am b/Makefile.am index 665b41b..afc6b66 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,7 +13,8 @@ EXTRA_DIST = \ debian/gnome-vfs-httpcaptive.conffiles \ debian/gnome-vfs-httpcaptive.docs \ debian/gnome-vfs-httpcaptive.files \ - debian/rules + debian/rules \ + g_str_has_suffix.c # Needed for dpkg-buildpackage(1): EXTRA_DIST+=debian/changelog diff --git a/configure.in b/configure.in index 64cd955..f4818d4 100644 --- a/configure.in +++ b/configure.in @@ -538,6 +538,8 @@ dnl End of IPv6 checks dnl ============================================================================== dnl Output files +AC_REPLACE_FUNCS(g_str_has_suffix) + AC_OUTPUT([ Makefile gnome-vfs-httpcaptive.spec diff --git a/g_str_has_suffix.c b/g_str_has_suffix.c new file mode 100644 index 0000000..802a7a2 --- /dev/null +++ b/g_str_has_suffix.c @@ -0,0 +1,61 @@ +/* GLIB - Library of useful routines for C programming + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * Modified by the GLib Team and others 1997-2000. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + + +#include +#include +#include + + +/** + * g_str_has_suffix: + * @str: a nul-terminated string. + * @suffix: the nul-terminated suffix to look for. + * + * Looks whether the string @str ends with @suffix. + * + * Return value: %TRUE if @str end with @suffix, %FALSE otherwise. + * + * Since: 2.2 + **/ +gboolean +g_str_has_suffix (const gchar *str, + const gchar *suffix) +{ + int str_len; + int suffix_len; + + g_return_val_if_fail (str != NULL, FALSE); + g_return_val_if_fail (suffix != NULL, FALSE); + + str_len = strlen (str); + suffix_len = strlen (suffix); + + if (str_len < suffix_len) + return FALSE; + + return strcmp (str + str_len - suffix_len, suffix) == 0; +} diff --git a/modules/http-method.c b/modules/http-method.c index c9de671..9431510 100644 --- a/modules/http-method.c +++ b/modules/http-method.c @@ -64,6 +64,10 @@ #include #include +#ifndef HAVE_G_STR_HAS_SUFFIX +gboolean g_str_has_suffix(const gchar *str, const gchar *suffix); +#endif + #ifdef DEBUG_HTTP_ENABLE void http_debug_printf (char *fmt, ...) -- 1.8.3.1