+/**
+ * collectd - src/sn_stage.c
+ * Copyright (C) 2008 Florian octo Forster
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; only version 2 of the License is applicable.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors:
+ * Florian octo Forster <octo at verplant.org>
+ **/
+
+#ifndef _ISOC99_SOURCE
+# define _ISOC99_SOURCE
+#endif
+#ifndef _POSIX_C_SOURCE
+# define _POSIX_C_SOURCE 200112L
+#endif
+
#include <stdlib.h>
#include <string.h>
#include <assert.h>
free (s);
} /* void sn_stage_destroy */
+int sn_stage_sort (sn_stage_t *s, int *values)
+{
+ sn_comparator_t *c;
+ int i;
+
+ for (i = 0; i < s->comparators_num; i++)
+ {
+ c = s->comparators + i;
+ if (values[c->min] > values[c->max])
+ {
+ int temp;
+
+ temp = values[c->min];
+ values[c->min] = values[c->max];
+ values[c->max] = temp;
+ }
+ }
+
+ return (0);
+} /* int sn_stage_sort */
+
int sn_stage_comparator_add (sn_stage_t *s, const sn_comparator_t *c)
{
sn_comparator_t *temp;
int j;
int k;
-
for (i = 0; i < s->comparators_num; i++)
{
lines[i] = -1;