[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gEDA-dev: [PATCH] libgeda: Add f_print_stream function
Hi folks,
I'm working on adding the ability to gschem to print to a command rather
than to a file.
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().
Regards,
Peter
--
Quake II build tools: https://adidas.servegame.org/projects/buildutils/
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..3fb4b48 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,29 @@ void f_print_objects(TOPLEVEL *w_current
int f_print(TOPLEVEL *w_current, const char *filename)
{
FILE *fp;
+ /* 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);
+ }
+
+ return f_print_stream(w_current, fp);
+}
+
+/*! \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 +404,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,
_______________________________________________
geda-dev mailing list
geda-dev@moria.seul.org
http://www.seul.org/cgi-bin/mailman/listinfo/geda-dev