Global: collectd → libsortnetwork
[sort-networks.git] / src / sn-apply.c
index 4793097..24f01d7 100644 (file)
@@ -1,6 +1,6 @@
 /**
- * collectd - src/sn-apply.c
- * Copyright (C) 2008  Florian octo Forster
+ * libsortnetwork - src/sn-apply.c
+ * Copyright (C) 2008-2010  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
  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  *
  * Authors:
- *   Florian octo Forster <octo at verplant.org>
+ *   Florian octo Forster <ff at octo.it>
  **/
 
-#define _ISOC99_SOURCE
-#define _POSIX_C_SOURCE 200112L
+#include "config.h"
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -49,7 +48,7 @@ static void exit_usage (const char *name)
       "  -i <file>     File holding the network (REQUIRED)\n"
       "\n",
       name);
-  exit (1);
+  exit (EXIT_FAILURE);
 } /* void exit_usage */
 
 int read_options (int argc, char **argv)
@@ -138,23 +137,9 @@ static int show_sort (int *values)
   for (i = 0; i < stages_num; i++)
   {
     sn_stage_t *s;
-    int j;
 
     s = SN_NETWORK_STAGE_GET (network, i);
-
-    for (j = 0; j < SN_STAGE_COMP_NUM (s); j++)
-    {
-      sn_comparator_t *c;
-
-      c = SN_STAGE_COMP_GET (s, j);
-
-      if (values[c->min] > values[c->max])
-      {
-       int temp = values[c->min];
-       values[c->min] = values[c->max];
-       values[c->max] = temp;
-      }
-    } /* for (comparators) */
+    sn_stage_sort (s, values);
 
     show_values (SN_NETWORK_INPUT_NUM (network), values);
   } /* for (stages) */
@@ -207,8 +192,8 @@ int main (int argc, char **argv)
   }
 
   if (status < 0)
-    return (1);
-  return (0);
+    exit (EXIT_FAILURE);
+  exit (EXIT_SUCCESS);
 } /* int main */
 
 /* vim: set shiftwidth=2 softtabstop=2 : */