[syslog-ng] [PATCH (3.4) 2/2] value-pairs: Export value_pairs_foreach_sorted()

Gergely Nagy algernon at balabit.hu
Fri Feb 10 17:35:22 CET 2012


Export value_pairs_foreach_sorted(), so that if any module wants to
use a custom sort function, they can do that.

Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 lib/value-pairs.c |   19 ++++++++++++++-----
 lib/value-pairs.h |    8 ++++++--
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/lib/value-pairs.c b/lib/value-pairs.c
index c5649ea..671d4f4 100644
--- a/lib/value-pairs.c
+++ b/lib/value-pairs.c
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2011 BalaBit IT Ltd, Budapest, Hungary
- * Copyright (c) 2011 Gergely Nagy <algernon at balabit.hu>
+ * Copyright (c) 2011-2012 BalaBit IT Ltd, Budapest, Hungary
+ * Copyright (c) 2011-2012 Gergely Nagy <algernon at balabit.hu>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -280,13 +280,14 @@ vp_merge_set(ValuePairs *vp, LogMessage *msg, gint32 seq_num, ValuePairSpec *set
 }
 
 void
-value_pairs_foreach (ValuePairs *vp, VPForeachFunc func,
-		     LogMessage *msg, gint32 seq_num, gpointer user_data)
+value_pairs_foreach_sorted (ValuePairs *vp, VPForeachFunc func,
+                            GCompareDataFunc compare_func,
+                            LogMessage *msg, gint32 seq_num, gpointer user_data)
 {
   gpointer args[] = { vp, func, msg, GINT_TO_POINTER (seq_num), user_data, NULL };
   GTree *scope_set;
 
-  scope_set = g_tree_new_full((GCompareDataFunc)g_strcmp0, NULL,
+  scope_set = g_tree_new_full((GCompareDataFunc)compare_func, NULL,
                               (GDestroyNotify)g_free,
                               (GDestroyNotify)g_free);
   args[5] = scope_set;
@@ -320,6 +321,14 @@ value_pairs_foreach (ValuePairs *vp, VPForeachFunc func,
   g_tree_destroy(scope_set);
 }
 
+void
+value_pairs_foreach(ValuePairs *vp, VPForeachFunc func,
+                    LogMessage *msg, gint32 seq_num,
+                    gpointer user_data)
+{
+  value_pairs_foreach_sorted(vp, func, (GCompareDataFunc)g_strcmp0,
+                             msg, seq_num, user_data);
+}
 
 static void
 value_pairs_init_set(ValuePairSpec *set)
diff --git a/lib/value-pairs.h b/lib/value-pairs.h
index 9b77266..1de97ca 100644
--- a/lib/value-pairs.h
+++ b/lib/value-pairs.h
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2011 BalaBit IT Ltd, Budapest, Hungary
- * Copyright (c) 2011 Gergely Nagy <algernon at balabit.hu>
+ * Copyright (c) 2011-2012 BalaBit IT Ltd, Budapest, Hungary
+ * Copyright (c) 2011-2012 Gergely Nagy <algernon at balabit.hu>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -37,6 +37,10 @@ void value_pairs_add_pair(ValuePairs *vp, GlobalConfig *cfg, const gchar *key, c
 
 void value_pairs_add_transforms(ValuePairs *vp, gpointer *vpts);
 
+void value_pairs_foreach_sorted(ValuePairs *vp, VPForeachFunc func,
+                                GCompareDataFunc compare_func,
+                                LogMessage *msg, gint32 seq_num,
+                                gpointer user_data);
 void value_pairs_foreach(ValuePairs *vp, VPForeachFunc func,
                          LogMessage *msg, gint32 seq_num,
                          gpointer user_data);
-- 
1.7.9




More information about the syslog-ng mailing list