[libglnx] Add a generic glnx-backports.h
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libglnx] Add a generic glnx-backports.h
- Date: Sat, 29 Aug 2015 13:38:57 +0000 (UTC)
commit 0cf50c6735246147d0a231d45f730724de0841e8
Author: Colin Walters <walters verbum org>
Date: Sat Aug 29 09:28:35 2015 -0400
Add a generic glnx-backports.h
Where we can put general functions that come in newer glib.
Makefile-libglnx.am | 2 ++
glnx-backports.c | 41 +++++++++++++++++++++++++++++++++++++++++
glnx-backports.h | 36 ++++++++++++++++++++++++++++++++++++
libglnx.h | 1 +
4 files changed, 80 insertions(+), 0 deletions(-)
---
diff --git a/Makefile-libglnx.am b/Makefile-libglnx.am
index c05a5a4..712e931 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 0000000..075c21a
--- /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 0000000..825ef0f
--- /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 ef52c24..9bd41c4 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>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]