commit 6c98a74: [Minor] Add older glib compat
Vsevolod Stakhov
vsevolod at highsecure.ru
Wed Mar 27 14:21:04 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-03-27 12:32:55 +0000
URL: https://github.com/rspamd/rspamd/commit/6c98a7447d79fda38e0eb8313d45c6cc23cfc3c9
[Minor] Add older glib compat
---
src/libutil/util.c | 23 +++++++++++++++++++++++
src/libutil/util.h | 3 +++
2 files changed, 26 insertions(+)
diff --git a/src/libutil/util.c b/src/libutil/util.c
index d5ec57845..df10bf912 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1487,6 +1487,29 @@ g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data)
}
#endif
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 32))
+const gchar *
+g_environ_getenv (gchar **envp, const gchar *variable)
+{
+ gsize len;
+ gint i;
+
+ if (envp == NULL) {
+ return NULL;
+ }
+
+ len = strlen (variable);
+
+ for (i = 0; envp[i]; i++) {
+ if (strncmp (envp[i], variable, len) == 0 && envp[i][len] == '=') {
+ return envp[i] + len + 1;
+ }
+ }
+
+ return NULL;
+}
+#endif
+
gint
rspamd_fallocate (gint fd, off_t offset, off_t len)
{
diff --git a/src/libutil/util.h b/src/libutil/util.h
index e9c1fa1db..9d12285d4 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -195,6 +195,9 @@ void g_ptr_array_insert (GPtrArray *array, gint index_, gpointer data);
GPtrArray* g_ptr_array_new_full (guint reserved_size,
GDestroyNotify element_free_func);
#endif
+#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 32))
+const gchar *g_environ_getenv (gchar **envp, const gchar *variable);
+#endif
/*
* Convert milliseconds to timeval fields
More information about the Commits
mailing list