[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gEDA-dev: [PATCH] libgeda: Add f_print_stream function



On Thursday 27 July 2006 13:09, Peter Brett wrote:
> On Tuesday 25 July 2006 16:59, Peter TB Brett wrote:
> > The first patch is to add the ability to libgeda to print to a stream.
> >
> > Backwards compatibility is preserved: most of the code from the old
> > f_print() has been moved into a new function called f_print_stream(), and
> > f_print() now only contains the logic to open a new file pointer and pass
> > it to f_print_stream().
>
> First patch was broken in a subtly wrong way: revised patch attached.

Where as _that_ one was broken in a blatantly wrong way.  3rd attempt.

Peter

-- 
Quake II build tools maintainer             http://tinyurl.com/fkldd

v2sw6YShw7$ln5pr6ck3ma8u6/8Lw3+2m0l7Ci6e4+8t4Eb8Aen5+6g6Pa2Xs5MSr5p4
  hackerkey.com
diff --git a/geda/gaf/libgeda/include/prototype.h b/geda/gaf/libgeda/include/prototype.h
index d34e31b..fb331ee 100644
--- a/geda/gaf/libgeda/include/prototype.h
+++ b/geda/gaf/libgeda/include/prototype.h
@@ -26,6 +26,7 @@ int f_print_header(TOPLEVEL *w_current, 
 void f_print_footer(FILE *fp);
 void f_print_objects(TOPLEVEL *w_current, FILE *fp, OBJECT *head, int start_x, int start_y, float scale, int unicode_count, gunichar *unicode_table);
 int f_print(TOPLEVEL *w_current, const char *filename);
+int f_print_stream(TOPLEVEL *w_current, FILE *fp);
 void f_print_set_type(TOPLEVEL *w_current, int type);
 int f_print_initialize_glyph_table(void);
 
diff --git a/geda/gaf/libgeda/src/f_print.c b/geda/gaf/libgeda/src/f_print.c
index 42f67a2..af818d9 100644
--- a/geda/gaf/libgeda/src/f_print.c
+++ b/geda/gaf/libgeda/src/f_print.c
@@ -352,7 +352,9 @@ void f_print_objects(TOPLEVEL *w_current
   return;
 }
 
-/*! \brief Print the current TOPLEVEL object to a postscript document.
+/*! \brief Print the current TOPLEVEL object to a file as a postscript
+ *  document.  
+ *
  *  \par Function Description
  *
  *  \param [in] w_current  The TOPLEVEL object to print.
@@ -362,6 +364,33 @@ void f_print_objects(TOPLEVEL *w_current
 int f_print(TOPLEVEL *w_current, const char *filename)
 {
   FILE *fp;
+  int result;
+
+  /* dots are breaking my filename selection hack hack !!!! */
+  fp = fopen(filename, "w");
+
+  /* check to see if it worked */ 
+  if (fp == NULL) {
+    s_log_message("Could not open [%s] for printing\n", filename);
+    return(-1);
+  }
+
+  result = f_print_stream(w_current, fp);
+  fclose (fp);
+  return result;
+}
+
+/*! \brief Print the current TOPLEVEL object to a stream as a
+ *  postscript document.  
+ *  \par Function Description
+ *
+ *  \param [in] w_current  The TOPLEVEL object to print.
+ *  \param [in] fp         An open FILE pointer
+ *  \return 0 on success, -1 on failure.
+ */
+
+int f_print_stream(TOPLEVEL *w_current, FILE *fp)
+{
   int origin_x, origin_y, bottom, right;
   int margin_x, margin_y;
   int dx,dy;
@@ -379,16 +408,6 @@ int f_print(TOPLEVEL *w_current, const c
 			 w_current->page_current->object_head, 
 			 0, unicode_table);
 
-
-  /* dots are breaking my filename selection hack hack !!!! */
-  fp = fopen(filename, "w");
-
-  /* check to see if it worked */ 
-  if (fp == NULL) {
-    s_log_message("Could not open [%s] for printing\n", filename);
-    return(-1);
-  }
-
   /*	printf("%d %d\n", w_current->paper_width, w_current->paper_height);*/
 
   world_get_complex_bounds(w_current, 
@@ -539,7 +558,6 @@ #endif  
 
   f_print_footer(fp);
 
-  fclose(fp);
   return(0);
 }
 


_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev