src/sn_{network,stage}.[ch]: Implement sn_{network,stage}_show_fh.
authorFlorian Forster <octo@leeloo.octo.it>
Mon, 24 Jan 2011 07:28:35 +0000 (08:28 +0100)
committerFlorian Forster <octo@leeloo.octo.it>
Mon, 24 Jan 2011 07:28:35 +0000 (08:28 +0100)
src/sn_network.c
src/sn_network.h
src/sn_stage.c
src/sn_stage.h

index 29c2c03..7fee9b5 100644 (file)
@@ -423,14 +423,19 @@ int sn_network_get_comparator_num (const sn_network_t *n) /* {{{ */
   return (num);
 } /* }}} int sn_network_get_comparator_num */
 
   return (num);
 } /* }}} int sn_network_get_comparator_num */
 
-int sn_network_show (sn_network_t *n) /* {{{ */
+int sn_network_show_fh (sn_network_t *n, FILE *fh) /* {{{ */
 {
   int i;
 
   for (i = 0; i < n->stages_num; i++)
 {
   int i;
 
   for (i = 0; i < n->stages_num; i++)
-    sn_stage_show (n->stages[i]);
+    sn_stage_show_fh (n->stages[i], fh);
 
   return (0);
 
   return (0);
+} /* }}} int sn_network_show_fh */
+
+int sn_network_show (sn_network_t *n) /* {{{ */
+{
+  return (sn_network_show_fh (n, stdout));
 } /* }}} int sn_network_show */
 
 int sn_network_invert (sn_network_t *n) /* {{{ */
 } /* }}} int sn_network_show */
 
 int sn_network_invert (sn_network_t *n) /* {{{ */
index f94a237..14a36c5 100644 (file)
@@ -196,6 +196,7 @@ int sn_network_brute_force_check (sn_network_t *n);
  * \return Zero on success, non-zero on failure.
  */
 int sn_network_show (sn_network_t *n);
  * \return Zero on success, non-zero on failure.
  */
 int sn_network_show (sn_network_t *n);
+int sn_network_show_fh (sn_network_t *n, FILE *fh);
 
 /**
  * Inverts a comparator network by switching the direction of all comparators.
 
 /**
  * Inverts a comparator network by switching the direction of all comparators.
index 1584469..3e9b728 100644 (file)
@@ -202,7 +202,7 @@ int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_t *c0
   return (0);
 } /* int sn_stage_comparator_check_conflict */
 
   return (0);
 } /* int sn_stage_comparator_check_conflict */
 
-int sn_stage_show (sn_stage_t *s)
+int sn_stage_show_fh (sn_stage_t *s, FILE *fh) /* {{{ */
 {
   int lines[s->comparators_num];
   int right[s->comparators_num];
 {
   int lines[s->comparators_num];
   int right[s->comparators_num];
@@ -234,7 +234,7 @@ int sn_stage_show (sn_stage_t *s)
 
   for (i = 0; i < lines_used; i++)
   {
 
   for (i = 0; i < lines_used; i++)
   {
-    printf ("%3i: ", s->depth);
+    fprintf (fh, "%3i: ", s->depth);
 
     for (j = 0; j <= right[i]; j++)
     {
 
     for (j = 0; j <= right[i]; j++)
     {
@@ -264,31 +264,36 @@ int sn_stage_show (sn_stage_t *s)
       if (on_elem == 0)
       {
        if (line_after == 0)
       if (on_elem == 0)
       {
        if (line_after == 0)
-         printf ("     ");
+         fprintf (fh, "     ");
        else
        else
-         printf ("-----");
+         fprintf (fh, "-----");
       }
       else if (on_elem == -1)
       {
        if (line_after == 0)
       }
       else if (on_elem == -1)
       {
        if (line_after == 0)
-         printf ("-!   ");
+         fprintf (fh, "-!   ");
        else
        else
-         printf (" !---");
+         fprintf (fh, " !---");
       }
       else
       {
        if (line_after == 0)
       }
       else
       {
        if (line_after == 0)
-         printf ("->   ");
+         fprintf (fh, "->   ");
        else
        else
-         printf (" <---");
+         fprintf (fh, " <---");
       }
     } /* for (columns) */
 
       }
     } /* for (columns) */
 
-    printf ("\n");
+    fprintf (fh, "\n");
   } /* for (lines) */
 
   return (0);
   } /* for (lines) */
 
   return (0);
-} /* int sn_stage_show */
+} /* }}} int sn_stage_show_fh */
+
+int sn_stage_show (sn_stage_t *s) /* {{{ */
+{
+  return (sn_stage_show_fh (s, stdout));
+} /* }}} int sn_stage_show */
 
 int sn_stage_invert (sn_stage_t *s)
 {
 
 int sn_stage_invert (sn_stage_t *s)
 {
index 2f5f729..8697eda 100644 (file)
@@ -144,6 +144,7 @@ int sn_stage_comparator_check_conflict (sn_stage_t *s, const sn_comparator_t *c)
  * \see sn_network_show
  */
 int sn_stage_show (sn_stage_t *s);
  * \see sn_network_show
  */
 int sn_stage_show (sn_stage_t *s);
+int sn_stage_show_fh (sn_stage_t *s, FILE *fh);
 
 /**
  * Inverts a stage by switching the direction of all comparators.
 
 /**
  * Inverts a stage by switching the direction of all comparators.