diff --git a/Makefile-libglnx.am b/Makefile-libglnx.am index c05a5a4249f88fddde1f684ef5ab421de680fc05..712e931c0554802a296c607e62b376e89b13f400 100644 --- a/Makefile-libglnx.am +++ b/Makefile-libglnx.am @@ -20,6 +20,8 @@ EXTRA_DIST += $(libglnx_srcpath)/README.md $(libglnx_srcpath)/COPYING libglnx_la_SOURCES = \ $(libglnx_srcpath)/glnx-backport-autocleanups.h \ $(libglnx_srcpath)/glnx-backport-autoptr.h \ + $(libglnx_srcpath)/glnx-backports.h \ + $(libglnx_srcpath)/glnx-backports.c \ $(libglnx_srcpath)/glnx-local-alloc.h \ $(libglnx_srcpath)/glnx-local-alloc.c \ $(libglnx_srcpath)/glnx-errors.h \ diff --git a/glnx-backports.c b/glnx-backports.c new file mode 100644 index 0000000000000000000000000000000000000000..075c21ac22f800ff001f0c446643e2692c5f119a --- /dev/null +++ b/glnx-backports.c @@ -0,0 +1,41 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2015 Colin Walters <walters@verbum.org> + * + * This program 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 licence 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. + */ + +#include "config.h" + +#include "glnx-backports.h" + +#if !GLIB_CHECK_VERSION(2, 44, 0) +gboolean +glnx_strv_contains (const gchar * const *strv, + const gchar *str) +{ + g_return_val_if_fail (strv != NULL, FALSE); + g_return_val_if_fail (str != NULL, FALSE); + + for (; *strv != NULL; strv++) + { + if (g_str_equal (str, *strv)) + return TRUE; + } + + return FALSE; +} +#endif diff --git a/glnx-backports.h b/glnx-backports.h new file mode 100644 index 0000000000000000000000000000000000000000..825ef0f895326fea003a1285456a2c8a99f3d731 --- /dev/null +++ b/glnx-backports.h @@ -0,0 +1,36 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- + * + * Copyright (C) 2015 Colin Walters <walters@verbum.org> + * + * 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. + */ + +#pragma once + +#include <gio/gio.h> + +G_BEGIN_DECLS + +#if !GLIB_CHECK_VERSION(2, 44, 0) +#define g_strv_contains glnx_strv_contains +gboolean glnx_strv_contains (const gchar * const *strv, + const gchar *str); +#endif /* !GLIB_CHECK_VERSION(2, 44, 0) */ + +G_END_DECLS diff --git a/libglnx.h b/libglnx.h index ef52c245751f5da224b4defe8783047ee10c56c0..9bd41c45decdf1754adfce96b825fb3c0f1f2fc1 100644 --- a/libglnx.h +++ b/libglnx.h @@ -26,6 +26,7 @@ G_BEGIN_DECLS #include <glnx-local-alloc.h> #include <glnx-backport-autocleanups.h> +#include <glnx-backports.h> #include <glnx-lockfile.h> #include <glnx-errors.h> #include <glnx-dirfd.h>