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

[PATCH] GNOME VFS support for dia (2)



I just made another gnome-vfs patch, made against CVS as of Dec 2nd.
This one cleans things up a bit and adds gnome-vfs support to the
following plug-ins:
                                                                                                    
dxf, pstricks, xfig, hpgl, metapost, png and cgm
                                                                                                    
The following plug-ins have also been modified but need a little work:
                                                                                                    
wpg, shape, svg
                                                                                                    
The following plug-ins have not yet been modified:
                                                                                                    
ps, xslt and pixbuf
                                                                                                    
Again, I am trying to lay the infrastructure for allowing dia to tie
into the GNOME VFS model nicely.  I am interesed in getting command line
stuff working (ie: dia file:///tmp/Diagram1.dia) but other techinques
(double-clicking on VFS entities in nautilus, file open dialogs, DnD,
etc. would be easy to add).
                                                                                                    
Of course, I am trying to do this all without affecting non-GNOME dia
builds.  I think the techniques I am using are pretty non-intrusive to
source code readability.

You should find the patch attached to this message.

-- 
Mike

:wq
diff -u --recursive dia-vanilla/app/app_procs.c dia/app/app_procs.c
--- dia-vanilla/app/app_procs.c	2003-11-17 15:41:24.000000000 -0600
+++ dia/app/app_procs.c	2003-11-26 21:54:10.000000000 -0600
@@ -39,6 +39,7 @@
 
 #ifdef GNOME
 #include <gnome.h>
+#include <libgnomevfs/gnome-vfs.h>
 #else
 #ifdef HAVE_POPT_H
 #include <popt.h>
@@ -221,6 +222,9 @@
   DDisplay *ddisp = NULL;
   Diagram *diagram = NULL;
   gboolean made_conversions = FALSE;
+#ifdef GNOME
+  GnomeVFSURI * vfsURI;
+#endif
 
   if (export_file_format) {
     char *export_file_name = NULL;
@@ -243,7 +247,16 @@
   } else if (out_file_name) {
     made_conversions |= do_convert(in_file_name, out_file_name, NULL);
   } else {
+#ifdef GNOME
+    if (!gnome_vfs_init()) {
+      message_error(_("Error initializing GNOME VFS.\n"));
+      return made_conversions;
+    }
+    vfsURI = gnome_vfs_uri_new (in_file_name);
+    if (gnome_vfs_uri_exists(vfsURI)) {
+#else
     if (g_file_test(in_file_name, G_FILE_TEST_EXISTS)) {
+#endif
       diagram = diagram_load (in_file_name, NULL);
     } else
       diagram = new_diagram (in_file_name);
diff -u --recursive dia-vanilla/app/diapsft2renderer.c dia/app/diapsft2renderer.c
--- dia-vanilla/app/diapsft2renderer.c	2003-08-25 10:18:36.000000000 -0500
+++ dia/app/diapsft2renderer.c	2003-12-01 09:20:46.000000000 -0600
@@ -97,7 +97,7 @@
 			 void *user_data)
 {
   OutlineInfo *outline_info = (OutlineInfo*)user_data;
-  fprintf(outline_info->OUT, "%d %d moveto\n",
+  diaFprintf(outline_info->OUT, "%d %d moveto\n",
 	  to->x ,
 	  to->y );
   return 0;
@@ -107,7 +107,7 @@
 			 void *user_data)
 {
   OutlineInfo *outline_info = (OutlineInfo*)user_data;
-  fprintf(outline_info->OUT, "%d %d lineto\n",
+  diaFprintf(outline_info->OUT, "%d %d lineto\n",
 	  to->x ,
 	  to->y );
   return 0;
@@ -118,7 +118,7 @@
 			  void *user_data)
 {
   OutlineInfo *outline_info = (OutlineInfo*)user_data;
-  fprintf(outline_info->OUT, "%d %d %d %d conicto\n",
+  diaFprintf(outline_info->OUT, "%d %d %d %d conicto\n",
 	  control->x  ,
 	  control->y  ,
 	  to->x   ,
@@ -132,7 +132,7 @@
 			  void *user_data)
 {
   OutlineInfo *outline_info = (OutlineInfo*)user_data;
-  fprintf(outline_info->OUT,
+  diaFprintf(outline_info->OUT,
 	  "%d %d %d %d %d %d curveto\n",
 	  control1->x , 
 	  control1->y ,
@@ -147,11 +147,11 @@
 void postscript_contour_headers(FILE *OUT, int dpi_x, int dpi_y)
 {
   /* /dpi_x needed for /conicto */
-  fprintf(OUT,
+  diaFprintf(OUT,
 	  "/dpi_x %d def\n"
 	  "/dpi_y %d def\n", dpi_x, dpi_y);
   /* Outline support */
-  fprintf(OUT,
+  diaFprintf(OUT,
 	  "/conicto {\n"
 	  "    /to_y exch def\n"
 	  "    /to_x exch def\n"
@@ -215,12 +215,12 @@
     int glyph_idx;
 
     if (font == NULL) {
-      fprintf(stderr, "No font found\n");
+      diaFprintf(stderr, "No font found\n");
       continue;
     } 
     ft_face = pango_ft2_font_get_face(font);
     if (ft_face == NULL) {
-      fprintf(stderr, "Failed to get face for font %s\n",
+      diaFprintf(stderr, "Failed to get face for font %s\n",
 	      pango_font_description_to_string(pango_font_describe(font)));
       continue;
     }
@@ -295,19 +295,19 @@
   outline_info.dpi = dpi_x;
   outline_info.OUT = renderer->file;
 
-  fprintf(renderer->file, 
+  diaFprintf(renderer->file, 
 	  "gsave %f %f translate %f %f scale\n",
 	  pos_x, pos_y, 2.54/72.0, -2.54/72.0);
-  fprintf(renderer->file, "start_ol\n");
+  diaFprintf(renderer->file, "start_ol\n");
 
   if ((error=FT_Load_Glyph(face, glyph_index, load_flags))) {
-    fprintf(stderr, "Can't load glyph: %d\n", error);
+    diaFprintf(stderr, "Can't load glyph: %d\n", error);
     return;
   }
   FT_Get_Glyph (face->glyph, &glyph);
   FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
                         &outlinefunc, &outline_info);
-  fprintf(renderer->file, "end_ol grestore \n");
+  diaFprintf(renderer->file, "end_ol grestore \n");
   
   FT_Done_Glyph (glyph);
 }
diff -u --recursive dia-vanilla/app/diapsrenderer.c dia/app/diapsrenderer.c
--- dia-vanilla/app/diapsrenderer.c	2003-10-14 16:51:08.000000000 -0500
+++ dia/app/diapsrenderer.c	2003-12-01 09:21:18.000000000 -0600
@@ -38,7 +38,7 @@
 {
   if (!color_equals(color, &(renderer->lcolor))) {
     renderer->lcolor = *color;
-    fprintf(renderer->file, "%f %f %f srgb\n",
+    diaFprintf(renderer->file, "%f %f %f srgb\n",
             (double) color->red,
             (double) color->green,
             (double) color->blue);    
@@ -56,12 +56,12 @@
   time_now  = time(NULL);
 
   if (renderer->is_eps)
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
             "%%!PS-Adobe-2.0 EPSF-2.0\n");
   else
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
             "%%!PS-Adobe-2.0\n");
-  fprintf(renderer->file,
+  diaFprintf(renderer->file,
           "%%%%Title: %s\n"
           "%%%%Creator: Dia v%s\n"
           "%%%%CreationDate: %s"
@@ -74,7 +74,7 @@
           renderer->is_portrait ? "Portrait" : "Landscape");
 
   if (renderer->is_eps)
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
             "%%%%Magnification: 1.0000\n"
 	  "%%%%BoundingBox: 0 0 %d %d\n",
             (int) ceil(  (renderer->extent.right - renderer->extent.left) 
@@ -83,13 +83,13 @@
                        * renderer->scale) );
 
   else
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	  "%%%%DocumentPaperSizes: %s\n",
             renderer->paper ? renderer->paper : "(NULL)");
 
-  fprintf(renderer->file,
+  diaFprintf(renderer->file,
           "%%%%BeginSetup\n");
-  fprintf(renderer->file,
+  diaFprintf(renderer->file,
           "%%%%EndSetup\n"
           "%%%%EndComments\n");
 
@@ -106,7 +106,7 @@
   DiaPsRenderer *renderer = DIA_PS_RENDERER(self);
 
   if (renderer->is_eps)
-    fprintf(renderer->file, "showpage\n");
+    diaFprintf(renderer->file, "showpage\n");
 }
 
 static void
@@ -118,7 +118,7 @@
    * due to different resolution output. */
   /* .01 cm becomes <5 dots on 1200 DPI */
   if (linewidth == 0.0) linewidth=.01;
-  fprintf(renderer->file, "%f slw\n", (double) linewidth);
+  diaFprintf(renderer->file, "%f slw\n", (double) linewidth);
 }
 
 static void
@@ -141,7 +141,7 @@
     ps_mode = 0;
   }
 
-  fprintf(renderer->file, "%d slc\n", ps_mode);
+  diaFprintf(renderer->file, "%d slc\n", ps_mode);
 }
 
 static void
@@ -164,7 +164,7 @@
     ps_mode = 0;
   }
 
-  fprintf(renderer->file, "%d slj\n", ps_mode);
+  diaFprintf(renderer->file, "%d slj\n", ps_mode);
 }
 
 static void
@@ -177,14 +177,14 @@
   
   switch(mode) {
   case LINESTYLE_SOLID:
-    fprintf(renderer->file, "[] 0 sd\n");
+    diaFprintf(renderer->file, "[] 0 sd\n");
     break;
   case LINESTYLE_DASHED:
-    fprintf(renderer->file, "[%f] 0 sd\n", renderer->dash_length);
+    diaFprintf(renderer->file, "[%f] 0 sd\n", renderer->dash_length);
     break;
   case LINESTYLE_DASH_DOT:
     hole_width = (renderer->dash_length - renderer->dot_length) / 2.0;
-    fprintf(renderer->file, "[%f %f %f %f] 0 sd\n",
+    diaFprintf(renderer->file, "[%f %f %f %f] 0 sd\n",
 	    renderer->dash_length,
 	    hole_width,
 	    renderer->dot_length,
@@ -192,7 +192,7 @@
     break;
   case LINESTYLE_DASH_DOT_DOT:
     hole_width = (renderer->dash_length - 2.0*renderer->dot_length) / 3.0;
-    fprintf(renderer->file, "[%f %f %f %f %f %f] 0 sd\n",
+    diaFprintf(renderer->file, "[%f %f %f %f %f %f] 0 sd\n",
 	    renderer->dash_length,
 	    hole_width,
 	    renderer->dot_length,
@@ -201,7 +201,7 @@
 	    hole_width );
     break;
   case LINESTYLE_DOTTED:
-    fprintf(renderer->file, "[%f] 0 sd\n", renderer->dot_length);
+    diaFprintf(renderer->file, "[%f] 0 sd\n", renderer->dot_length);
     break;
   }
 }
@@ -239,7 +239,7 @@
 {
   DiaPsRenderer *renderer = DIA_PS_RENDERER(self);
 
-  fprintf(renderer->file, "/%s-latin1 ff %f scf sf\n",
+  diaFprintf(renderer->file, "/%s-latin1 ff %f scf sf\n",
           dia_font_get_psfontname(font), (double)height*0.7);
 }
 
@@ -252,7 +252,7 @@
 
   lazy_setcolor(renderer,line_color);
 
-  fprintf(renderer->file, "n %f %f m %f %f l s\n",
+  diaFprintf(renderer->file, "n %f %f m %f %f l s\n",
 	  start->x, start->y, end->x, end->y);
 }
 
@@ -266,15 +266,15 @@
 
   lazy_setcolor(renderer,line_color);
   
-  fprintf(renderer->file, "n %f %f m ",
+  diaFprintf(renderer->file, "n %f %f m ",
 	  points[0].x, points[0].y);
 
   for (i=1;i<num_points;i++) {
-    fprintf(renderer->file, "%f %f l ",
+    diaFprintf(renderer->file, "%f %f l ",
 	  points[i].x, points[i].y);
   }
 
-  fprintf(renderer->file, "s\n");
+  diaFprintf(renderer->file, "s\n");
 }
 
 static void
@@ -287,15 +287,15 @@
   
   lazy_setcolor(renderer,line_color);
   
-  fprintf(renderer->file, "n %f %f m ",
+  diaFprintf(renderer->file, "n %f %f m ",
 	  points[0].x, points[0].y);
 
   for (i=1;i<num_points;i++) {
-    fprintf(renderer->file, "%f %f l ",
+    diaFprintf(renderer->file, "%f %f l ",
 	  points[i].x, points[i].y);
   }
 
-  fprintf(renderer->file, "cp s\n");
+  diaFprintf(renderer->file, "cp s\n");
 }
 
 static void
@@ -308,15 +308,15 @@
 
   lazy_setcolor(renderer,fill_color);
   
-  fprintf(renderer->file, "n %f %f m ",
+  diaFprintf(renderer->file, "n %f %f m ",
 	  points[0].x, points[0].y);
 
   for (i=1;i<num_points;i++) {
-    fprintf(renderer->file, "%f %f l ",
+    diaFprintf(renderer->file, "%f %f l ",
 	  points[i].x, points[i].y);
   }
 
-  fprintf(renderer->file, "f\n");
+  diaFprintf(renderer->file, "f\n");
 }
 
 static void
@@ -328,7 +328,7 @@
 
   lazy_setcolor(renderer,color);
   
-  fprintf(renderer->file, "n %f %f m %f %f l %f %f l %f %f l cp s\n",
+  diaFprintf(renderer->file, "n %f %f m %f %f l %f %f l %f %f l cp s\n",
 	  (double) ul_corner->x, (double) ul_corner->y,
 	  (double) ul_corner->x, (double) lr_corner->y,
 	  (double) lr_corner->x, (double) lr_corner->y,
@@ -344,7 +344,7 @@
 
   lazy_setcolor(renderer,color);
 
-  fprintf(renderer->file, "n %f %f m %f %f l %f %f l %f %f l f\n",
+  diaFprintf(renderer->file, "n %f %f m %f %f l %f %f l %f %f l f\n",
 	  (double) ul_corner->x, (double) ul_corner->y,
 	  (double) ul_corner->x, (double) lr_corner->y,
 	  (double) lr_corner->x, (double) lr_corner->y,
@@ -362,7 +362,7 @@
 
   lazy_setcolor(renderer,color);
 
-  fprintf(renderer->file, "n %f %f %f %f %f %f ellipse s\n",
+  diaFprintf(renderer->file, "n %f %f %f %f %f %f ellipse s\n",
 	  (double) center->x, (double) center->y,
 	  (double) width/2.0, (double) height/2.0,
 	  (double) 360.0 - angle2, (double) 360.0 - angle1 );
@@ -379,7 +379,7 @@
 
   lazy_setcolor(renderer,color);
 
-  fprintf(renderer->file, "n %f %f m %f %f %f %f %f %f ellipse f\n",
+  diaFprintf(renderer->file, "n %f %f m %f %f %f %f %f %f ellipse f\n",
 	  (double) center->x, (double) center->y,
 	  (double) center->x, (double) center->y,
 	  (double) width/2.0, (double) height/2.0,
@@ -396,7 +396,7 @@
 
   lazy_setcolor(renderer,color);
 
-  fprintf(renderer->file, "n %f %f %f %f 0 360 ellipse cp s\n",
+  diaFprintf(renderer->file, "n %f %f %f %f 0 360 ellipse cp s\n",
 	  (double) center->x, (double) center->y,
 	  (double) width/2.0, (double) height/2.0 );
 }
@@ -411,7 +411,7 @@
 
   lazy_setcolor(renderer,color);
 
-  fprintf(renderer->file, "n %f %f %f %f 0 360 ellipse f\n",
+  diaFprintf(renderer->file, "n %f %f %f %f 0 360 ellipse f\n",
 	  (double) center->x, (double) center->y,
 	  (double) width/2.0, (double) height/2.0 );
 }
@@ -430,7 +430,7 @@
   if (points[0].type != BEZ_MOVE_TO)
     g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-  fprintf(renderer->file, "n %f %f m",
+  diaFprintf(renderer->file, "n %f %f m",
 	  (double) points[0].p1.x, (double) points[0].p1.y);
   
   for (i = 1; i < numpoints; i++)
@@ -439,18 +439,18 @@
       g_warning("only first BezPoint can be a BEZ_MOVE_TO");
       break;
     case BEZ_LINE_TO:
-      fprintf(renderer->file, " %f %f l",
+      diaFprintf(renderer->file, " %f %f l",
 	      (double) points[i].p1.x, (double) points[i].p1.y);
       break;
     case BEZ_CURVE_TO:
-      fprintf(renderer->file, " %f %f %f %f %f %f c",
+      diaFprintf(renderer->file, " %f %f %f %f %f %f c",
 	      (double) points[i].p1.x, (double) points[i].p1.y,
 	      (double) points[i].p2.x, (double) points[i].p2.y,
 	      (double) points[i].p3.x, (double) points[i].p3.y );
       break;
     }
 
-  fprintf(renderer->file, " s\n");
+  diaFprintf(renderer->file, " s\n");
 }
 
 static void
@@ -467,7 +467,7 @@
   if (points[0].type != BEZ_MOVE_TO)
     g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-  fprintf(renderer->file, "n %f %f m",
+  diaFprintf(renderer->file, "n %f %f m",
 	  (double) points[0].p1.x, (double) points[0].p1.y);
   
   for (i = 1; i < numpoints; i++)
@@ -476,18 +476,18 @@
       g_warning("only first BezPoint can be a BEZ_MOVE_TO");
       break;
     case BEZ_LINE_TO:
-      fprintf(renderer->file, " %f %f l",
+      diaFprintf(renderer->file, " %f %f l",
 	      (double) points[i].p1.x, (double) points[i].p1.y);
       break;
     case BEZ_CURVE_TO:
-      fprintf(renderer->file, " %f %f %f %f %f %f c",
+      diaFprintf(renderer->file, " %f %f %f %f %f %f c",
 	      (double) points[i].p1.x, (double) points[i].p1.y,
 	      (double) points[i].p2.x, (double) points[i].p2.y,
 	      (double) points[i].p3.x, (double) points[i].p3.y );
       break;
     }
 
-  fprintf(renderer->file, " f\n");
+  diaFprintf(renderer->file, " f\n");
 }
 
 static void
@@ -531,25 +531,25 @@
       str++;
     }
   }
-  fprintf(renderer->file, "(%s) ", buffer);
+  diaFprintf(renderer->file, "(%s) ", buffer);
   g_free(buffer);
   g_free(localestr);
 
   switch (alignment) {
   case ALIGN_LEFT:
-    fprintf(renderer->file, "%f %f m", pos->x, pos->y);
+    diaFprintf(renderer->file, "%f %f m", pos->x, pos->y);
     break;
   case ALIGN_CENTER:
-    fprintf(renderer->file, "dup sw 2 div %f ex sub %f m",
+    diaFprintf(renderer->file, "dup sw 2 div %f ex sub %f m",
 	    pos->x, pos->y);
     break;
   case ALIGN_RIGHT:
-    fprintf(renderer->file, "dup sw %f ex sub %f m",
+    diaFprintf(renderer->file, "dup sw %f ex sub %f m",
 	    pos->x, pos->y);
     break;
   }
   
-  fprintf(renderer->file, " gs 1 -1 sc sh gr\n");
+  diaFprintf(renderer->file, " gs 1 -1 sc sh gr\n");
 }
 
 static void
@@ -575,44 +575,44 @@
 
   ratio = height/width;
 
-  fprintf(renderer->file, "gs\n");
+  diaFprintf(renderer->file, "gs\n");
 
   /* color output only */
-  fprintf(renderer->file, "/pix %i string def\n", img_width * 3);
-  fprintf(renderer->file, "%i %i 8\n", img_width, img_height);
-  fprintf(renderer->file, "%f %f tr\n", point->x, point->y);
-  fprintf(renderer->file, "%f %f sc\n", width, height);
-  fprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
-
-  fprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
-  fprintf(renderer->file, "false 3 colorimage\n");
-  fprintf(renderer->file, "\n");
+  diaFprintf(renderer->file, "/pix %i string def\n", img_width * 3);
+  diaFprintf(renderer->file, "%i %i 8\n", img_width, img_height);
+  diaFprintf(renderer->file, "%f %f tr\n", point->x, point->y);
+  diaFprintf(renderer->file, "%f %f sc\n", width, height);
+  diaFprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
+
+  diaFprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
+  diaFprintf(renderer->file, "false 3 colorimage\n");
+  diaFprintf(renderer->file, "\n");
 
   if (mask_data) {
     for (y = 0; y < img_height; y++) {
       for (x = 0; x < img_width; x++) {
 	int i = y*img_rowstride+x*3;
 	int m = y*img_width+x;
-        fprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i])/255));
-        fprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i+1])/255));
-        fprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i+2])/255));
+        diaFprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i])/255));
+        diaFprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i+1])/255));
+        diaFprintf(renderer->file, "%02x", 255-(mask_data[m]*(255-rgb_data[i+2])/255));
       }
-      fprintf(renderer->file, "\n");
+      diaFprintf(renderer->file, "\n");
     }
   } else {
     guint8 *ptr = rgb_data;
     for (y = 0; y < img_height; y++) {
       for (x = 0; x < img_width; x++) {
 	int i = y*img_rowstride+x*3;
-        fprintf(renderer->file, "%02x", (int)(rgb_data[i]));
-        fprintf(renderer->file, "%02x", (int)(rgb_data[i+1]));
-        fprintf(renderer->file, "%02x", (int)(rgb_data[i+2]));
+        diaFprintf(renderer->file, "%02x", (int)(rgb_data[i]));
+        diaFprintf(renderer->file, "%02x", (int)(rgb_data[i+1]));
+        diaFprintf(renderer->file, "%02x", (int)(rgb_data[i+2]));
       }
-      fprintf(renderer->file, "\n");
+      diaFprintf(renderer->file, "\n");
     }
   }
-  fprintf(renderer->file, "gr\n");
-  fprintf(renderer->file, "\n");
+  diaFprintf(renderer->file, "gr\n");
+  diaFprintf(renderer->file, "\n");
    
   g_free(rgb_data);
   g_free(mask_data);
@@ -623,8 +623,8 @@
 {
   g_assert(renderer->file != NULL);
 
-  fprintf(renderer->file, "%%%%BeginProlog\n");
-  fprintf(renderer->file,
+  diaFprintf(renderer->file, "%%%%BeginProlog\n");
+  diaFprintf(renderer->file,
 	  "[ /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
 	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
 	  "/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
@@ -652,7 +652,7 @@
 	  "/eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave\n"
 	  "/uacute /ucircumflex /udieresis /yacute /thorn /ydieresis] /isolatin1encoding exch def\n");
 
-  fprintf(renderer->file,
+  diaFprintf(renderer->file,
 	  "/cp {closepath} bind def\n"
 	  "/c {curveto} bind def\n"
 	  "/f {fill} bind def\n"
@@ -726,12 +726,12 @@
   /* Don't reencode the Symbol font, as it doesn't work in latin1 encoding.
    * Instead, just define Symbol-latin1 to be the same as Symbol. */
   if (!strcmp(fontname, "Symbol"))
-    fprintf(file,
+    diaFprintf(file,
 	    "/%s-latin1\n"
 	    "    /%s findfont\n"
 	    "definefont pop\n", fontname, fontname);
   else
-    fprintf(file,
+    diaFprintf(file,
 	    "/%s-latin1\n"
 	    "    /%s findfont\n"
 	    "    dup length dict begin\n"
@@ -785,15 +785,15 @@
 end_prolog (DiaPsRenderer *renderer)
 {
   if (renderer->is_eps) {
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
             "%f %f scale\n", renderer->scale, -renderer->scale);
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
             "%f %f translate\n", -renderer->extent.left, -renderer->extent.bottom);
   } else {
     /* done by BoundingBox above */
   }
 
-  fprintf(renderer->file,
+  diaFprintf(renderer->file,
 	  "%%%%EndProlog\n\n\n");
 }
 
@@ -854,7 +854,7 @@
   DiaPsRenderer *renderer = DIA_PS_RENDERER (object);
 
   g_free(renderer->title);
-  /*  fclose(renderer->file);*/
+  /*  diaClose(renderer->file);*/
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
diff -u --recursive dia-vanilla/app/export_png.c dia/app/export_png.c
--- dia-vanilla/app/export_png.c	2003-11-17 15:41:24.000000000 -0600
+++ dia/app/export_png.c	2003-12-01 09:10:40.000000000 -0600
@@ -59,6 +59,11 @@
 static GtkWidget *export_png_okay_button, *export_png_cancel_button;
 static real export_png_aspect_ratio;
 
+void *png_write(png_structp png, png_bytep buf, png_size_t size)
+{
+	diaFwrite(buf, size, sizeof(char), png->io_ptr);
+}
+
 /* The heart of the png exporter.
    Deals with a bit of dialog handling and all the rendering and writing.
    The dialog is not used when dia is non-interactive (export mode)
@@ -111,7 +116,7 @@
   la_renderer = DIA_LIBART_RENDERER (renderer);
   dia_renderer_set_size(renderer, NULL, imagewidth, band);
 
-  fp = fopen(cbdata->filename, "wb");
+  fp = diaOpen(cbdata->filename, "wb");
   if (fp == NULL) {
     message_error(_("Can't open output file %s: %s\n"), cbdata->filename, strerror(errno));
     goto error;
@@ -120,7 +125,7 @@
   png = png_create_write_struct(PNG_LIBPNG_VER_STRING,
 				NULL, NULL, NULL);
   if (!png) {
-    fclose(fp);
+    diaClose(fp);
     message_error(_("Could not create PNG write structure"));
     goto error;
   }
@@ -128,7 +133,7 @@
   /* allocate/initialise the image information data */
   info = png_create_info_struct(png);
   if (!info) {
-    fclose(fp);
+    diaClose(fp);
     png_destroy_write_struct(&png, (png_infopp)NULL);
     message_error(_("Could not create PNG header info structure"));
     goto error;
@@ -136,7 +141,7 @@
 
   /* set error handling ... */
   if (setjmp(png->jmpbuf)) {
-    fclose(fp);
+    diaClose(fp);
     png_destroy_write_struct(&png, (png_infopp)NULL);
     message_error(_("Error occurred while writing PNG"));
     goto error;
@@ -152,7 +157,8 @@
   }
   band = MIN(imageheight, BAND_HEIGHT);
 
-  png_init_io(png, fp);
+  // png_init_io(png, fp);
+  png_set_write_fn(png, fp, png_write, NULL);
 
   /* header fields */
   png_set_IHDR(png, info, imagewidth, imageheight, 8,
@@ -193,7 +199,7 @@
   g_free(row_ptr);
   png_write_end(png, info);
   png_destroy_write_struct(&png, (png_infopp)NULL);
-  fclose(fp);
+  diaClose(fp);
 
  error:
   g_object_unref(renderer);
diff -u --recursive dia-vanilla/app/load_save.c dia/app/load_save.c
--- dia-vanilla/app/load_save.c	2003-11-24 12:43:05.000000000 -0600
+++ dia/app/load_save.c	2003-12-01 10:01:56.000000000 -0600
@@ -20,6 +20,13 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#ifdef GNOME
+#include <libgnomevfs/gnome-vfs.h>
+#include <gsf/gsf.h>
+#include <gsf/gsf-libxml.h>
+#include <gsf/gsf-input-gzip.h>
+#include <gsf-gnome/gsf-input-gnomevfs.h>
+#endif
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -303,7 +310,6 @@
 diagram_data_load(const char *filename, DiagramData *data, void* user_data)
 {
   GHashTable *objects_hash;
-  int fd;
   GList *list;
   xmlDocPtr doc;
   xmlNodePtr diagramdata;
@@ -313,28 +319,37 @@
   Layer *layer;
   xmlNsPtr namespace;
   gchar firstchar;
+/*
+#ifdef GNOME
+  GnomeVFSHandle * vfsHandle;
+  GnomeVFSResult vfsResult;
+  GnomeVFSFileSize vfsBytesRead;
+#else
+  int fd;
+#endif
+*/
+  diaFile *fd;
 
   if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
     message_error(_("You must specify a file, not a directory.\n"));
     return FALSE;
   }
 
-  fd = open(filename, O_RDONLY);
+  fd = diaOpen(filename, "r");
 
-  if (fd==-1) {
+  if (!fd) {
     message_error(_("Couldn't open: '%s' for reading.\n"), filename);
     return FALSE;
   }
 
-  if (read(fd, &firstchar, 1)) {
+  if (diaRead(fd, &firstchar, 1))
     data->is_compressed = (firstchar != '<');
-  } else {
+  else
     /* Couldn't read a single char?  Set to default. */
     data->is_compressed = prefs.new_diagram.compress_save;
-  }
   
   /* Note that this closing and opening means we can't read from a pipe */
-  close(fd);
+  diaClose(fd);
 
   doc = xmlDiaParseFile(filename);
 
@@ -842,6 +857,9 @@
   int ret;
    
   /* build the temporary and backup file names */
+#ifdef GNOME /* is there a gsf/gnomevfs-happy mkstemp? */
+  tmpname = g_strdup("/tmp/__diaXXXXXX");
+#else /* platforms like Win32 do not have a /tmp */
   dirname = g_strdup(filename);
   p = strrchr((char *)dirname,G_DIR_SEPARATOR);
   if (p) {
@@ -851,6 +869,7 @@
     dirname = g_strdup("." G_DIR_SEPARATOR_S);
   }
   tmpname = g_strconcat(dirname,"__diaXXXXXX",NULL);
+#endif
   bakname = g_strconcat(filename,"~",NULL);
 
   /* open a temporary name, and fix the modes to match what fopen() would have
@@ -875,18 +894,25 @@
     /* Save failed; we clean our stuff up, without touching the file named
        "filename" if it existed. */
     unlink(tmpname);
-    g_free(tmpname);
+#ifndef GNOME
     g_free(dirname);
+#endif
+    g_free(tmpname);
     g_free(bakname);
     return FALSE;
   }
   /* save succeeded. We kill the old backup file, move the old file into 
      backup, and the temp file into the new saved file. */
+#ifdef GNOME
+  gnome_vfs_move(filename,bakname,TRUE);
+  ret = gnome_vfs_move(tmpname,filename,FALSE) != GNOME_VFS_OK;
+#else
   unlink(bakname);
   rename(filename,bakname);
   ret = rename(tmpname,filename);
-  g_free(tmpname);
   g_free(dirname);
+#endif
+  g_free(tmpname);
   g_free(bakname);
   return (ret?FALSE:TRUE);
 }
diff -u --recursive dia-vanilla/app/render_eps.c dia/app/render_eps.c
--- dia-vanilla/app/render_eps.c	2003-10-21 13:13:40.000000000 -0500
+++ dia/app/render_eps.c	2003-12-01 09:20:04.000000000 -0600
@@ -98,7 +98,7 @@
 {
   FILE *outfile;
 
-  outfile = fopen(filename, "w");
+  outfile = diaOpen(filename, "w");
   if (outfile == NULL) {
     message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
     g_object_unref(renderer);
@@ -115,7 +115,7 @@
     data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
   }
   g_object_unref (renderer);
-  fclose(outfile);
+  diaClose(outfile);
 }
 
 DiaRenderer *
diff -u --recursive dia-vanilla/configure.in dia/configure.in
--- dia-vanilla/configure.in	2003-12-01 09:42:13.000000000 -0600
+++ dia/configure.in	2003-12-01 09:41:22.000000000 -0600
@@ -104,7 +104,7 @@
 AC_ARG_ENABLE(gnome,[  --enable-gnome          enable gnome code],
               GNOME=$enableval, GNOME=no)
 if test "$GNOME" = "yes" ; then
-    GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0"
+    GTK_MODULES="$GTK_MODULES libgnome-2.0 libgnomeui-2.0 libgsf-1 libgsf-gnome-1"
     AC_DEFINE(GNOME,1,[Define if building with GNOME support])
     AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [GNOME icon directory])
     have_gnome=true
diff -u --recursive dia-vanilla/CVS/Entries dia/CVS/Entries
--- dia-vanilla/CVS/Entries	2003-12-02 10:13:25.829689000 -0600
+++ dia/CVS/Entries	2003-12-02 09:07:06.000000000 -0600
@@ -38,6 +38,6 @@
 D/samples////
 D/shapes////
 D/sheets////
-/config.h.win32/1.26/Mon Dec  1 15:42:13 2003//
-/configure.in/1.213/Mon Dec  1 15:42:13 2003//
-/ChangeLog/1.1411/Tue Dec  2 16:13:25 2003//
+/config.h.win32/1.26/Mon Dec  1 15:41:20 2003//
+/configure.in/1.213/Result of merge//
+/ChangeLog/1.1411/Tue Dec  2 15:07:06 2003//
diff -u --recursive dia-vanilla/lib/dia_xml.c dia/lib/dia_xml.c
--- dia-vanilla/lib/dia_xml.c	2003-09-18 05:28:39.000000000 -0500
+++ dia/lib/dia_xml.c	2003-11-29 22:14:46.000000000 -0600
@@ -33,6 +33,14 @@
 #include <unistd.h>
 #endif
 
+#ifdef GNOME
+#include <libgnomevfs/gnome-vfs.h>
+#include <gsf/gsf.h>
+#include <gsf/gsf-libxml.h>
+#include <gsf/gsf-input-gzip.h>
+#include <gsf-gnome/gsf-input-gnomevfs.h>
+#endif
+
 #include <zlib.h>
 
 #include "intl.h"
@@ -41,6 +49,7 @@
 #include "dia_xml.h"
 #include "geometry.h"		/* For isinf() on Solaris */
 #include "message.h"
+#include "filter.h"
 
 #ifdef G_OS_WIN32
 #include <io.h> /* write, close */
@@ -68,7 +77,7 @@
      it untouched to libxml2.
   */
 
-  gzFile zf = gzopen(filename,"rb");  
+  diaFile *zf = diaOpen(filename,"rb");  
   gchar *buf;
   gchar *p,*pmax;
   int len;
@@ -85,12 +94,12 @@
     return NULL;
   }
   p = buf = g_malloc0(BUFLEN);  
-  len = gzread(zf,buf,BUFLEN);
+  len = diaRead(zf,buf,BUFLEN);
   pmax = p + len;
 
   /* first, we expect the magic <?xml string */
   if ((0 != strncmp(p,magic_xml,5)) || (len < 5)) {
-    gzclose(zf);
+    diaClose(zf);
     return filename; /* let libxml figure out what this is. */
   }
   /* now, we're sure we have some asciish XML file. */
@@ -98,17 +107,17 @@
   while (((*p == 0x20)||(*p == 0x09)||(*p == 0x0d)||(*p == 0x0a))
          && (p<pmax)) p++;
   if (p>=pmax) { /* whoops ? */
-    gzclose(zf);
+    diaClose(zf);
     return filename;
   }
   if (0 != strncmp(p,"version=\"",9)) {
-    gzclose(zf); /* chicken out. */
+    diaClose(zf); /* chicken out. */
     return filename;
   }
   p += 9;
   /* The header is rather well formed. */
   if (p>=pmax) { /* whoops ? */
-    gzclose(zf);
+    diaClose(zf);
     return filename;
   }
   while ((*p != '"') && (p < pmax)) p++;
@@ -116,11 +125,11 @@
   while (((*p == 0x20)||(*p == 0x09)||(*p == 0x0d)||(*p == 0x0a))
          && (p<pmax)) p++;
   if (p>=pmax) { /* whoops ? */
-    gzclose(zf);
+    diaClose(zf);
     return filename;
   }
   if (0 == strncmp(p,"encoding=\"",10)) {
-    gzclose(zf); /* this file has an encoding string. Good. */
+    diaClose(zf); /* this file has an encoding string. Good. */
     return filename;
   }
   /* now let's read the whole file, to see if there are offending bits.
@@ -132,22 +141,22 @@
     for (i = 0; i < len; i++)
       if (buf[i] & 0x80 || buf[i] == '&')
         well_formed_utf8 = FALSE;
-    len = gzread(zf,buf,BUFLEN);
+    len = diaRead(zf,buf,BUFLEN);
   } while (len > 0 && well_formed_utf8);
   if (well_formed_utf8) {
-    gzclose(zf); /* this file is utf-8 compatible  */
+    diaClose(zf); /* this file is utf-8 compatible  */
     return filename;
   } else {
-    gzclose(zf); /* poor man's fseek */
-    zf = gzopen(filename,"rb"); 
-    len = gzread(zf,buf,BUFLEN);
+    diaClose(zf); /* poor man's fseek */
+    zf = diaOpen(filename,"rb"); 
+    len = diaRead(zf,buf,BUFLEN);
   }
 
   if (0 != strcmp(default_enc,"UTF-8")) {
     message_warning(_("The file %s has no encoding specification;\n"
                       "assuming it is encoded in %s"),filename,default_enc);
   } else {
-    gzclose(zf); /* we apply the standard here. */
+    diaClose(zf); /* we apply the standard here. */
     return filename;
   }
 
@@ -164,11 +173,11 @@
   write(uf,p,pmax - p);
 
   while (1) {
-    len = gzread(zf,buf,BUFLEN);
+    len = diaRead(zf,buf,BUFLEN);
     if (len <= 0) break;
     write(uf,buf,len);
   }
-  gzclose(zf);
+  diaClose(zf);
   close(uf);
   return res; /* caller frees the name and unlinks the file. */
 }
@@ -202,7 +211,40 @@
 
 xmlDocPtr
 xmlDoParseFile(const char *filename) {
+#ifdef GNOME
+  GError *err; 
+  GsfInputGnomeVFS * vfsInputPtr;
+  xmlParserCtxt * docCtxt;
+
+  gsf_init();
+  vfsInputPtr = gsf_input_gnomevfs_new(filename, &err);
+  if (vfsInputPtr == NULL){
+    message_error(_("Error loading diagram %s.\n%s."),filename, err->message);
+    return FALSE;
+  }
+/* FIXME: compression does not yet work
+  if (data->is_compressed){
+    GsfInputGZip * gzipInputPtr;
+    gzipInputPtr = gsf_input_gzip_new(GSF_INPUT(vfsInputPtr), &err);
+    if (gzipInputPtr == NULL){
+      message_error(_("Error loading diagram %s.\n%s."),filename, err->message);      return FALSE;
+    }
+    docCtxt = gsf_xml_parser_context(GSF_INPUT(gzipInputPtr));
+  } else {
+*/
+    docCtxt = gsf_xml_parser_context(GSF_INPUT(vfsInputPtr));
+/* FIXME: compression does not yet work
+  }
+*/
+  if (docCtxt == NULL){
+    message_error(_("Error loading diagram %s.\nError initializing parser."),filename);
+    return FALSE;
+  }
+  xmlParseDocument(docCtxt);
+  return docCtxt->myDoc;
+#else
   return xmlParseFile(filename);
+#endif
 }
 
 AttributeNode
diff -u --recursive dia-vanilla/lib/filter.c dia/lib/filter.c
--- dia-vanilla/lib/filter.c	2003-10-11 01:50:57.000000000 -0500
+++ dia/lib/filter.c	2003-12-02 09:53:06.000000000 -0600
@@ -216,3 +216,123 @@
 {
   return g_list_first (callback_filters);
 }
+
+diaFile * diaOpen(const char *path, const char *mode)
+{
+#ifdef GNOME
+	const char *ptr;
+	GnomeVFSHandle * vfsHandle;
+	GnomeVFSResult vfsResult;
+	GnomeVFSURI *vfsURI;
+	GnomeVFSOpenMode vfsMode = GNOME_VFS_OPEN_NONE;
+
+	for (ptr = mode; *ptr; ptr++)
+		switch (*ptr) {
+			case 'r':
+				vfsMode |= GNOME_VFS_OPEN_READ;
+				break;
+			case 'w':
+				vfsMode |= GNOME_VFS_OPEN_WRITE;
+				break;
+		}
+
+	if (!gnome_vfs_init())
+		return NULL;
+
+	vfsURI = gnome_vfs_uri_new (path);
+	if (vfsMode & GNOME_VFS_OPEN_WRITE && !gnome_vfs_uri_exists(vfsURI))
+		vfsResult = gnome_vfs_create_uri(&vfsHandle, vfsURI, vfsMode, 1, 0644); /* FIXME: use umask */
+	else
+		vfsResult = gnome_vfs_open_uri(&vfsHandle, vfsURI, vfsMode);
+	if (vfsResult != GNOME_VFS_OK)
+		return NULL;
+	return vfsHandle;
+#else
+	return gzopen(path, mode);
+#endif
+}
+
+int diaRead(diaFile * file, void * buf, unsigned int len)
+{
+#ifdef GNOME
+	GnomeVFSResult vfsResult;
+	GnomeVFSFileSize vfsBytesRead;
+
+	vfsResult = gnome_vfs_read(file, buf, len, &vfsBytesRead);
+	if (vfsResult != GNOME_VFS_OK)
+		return 0;
+	return vfsBytesRead;
+#else
+	return gzread(file, buf, len);
+#endif
+}
+
+char* diaFgets(char * buf, int len, diaFile * file)
+{
+#ifdef GNOME
+	/* FIXME: a little ugly? */
+	int bytesRead = 0;
+	char c[2];
+
+	c[1] = 0x00;
+	buf[0] = 0x00;
+	while (diaRead(file, c, 1) && len--) {
+		bytesRead = 1;
+		strncat(buf, c, 1);
+		if (*c == '\n')
+			break;
+	}
+	return bytesRead ? buf : NULL;
+#else
+	return gzgets(file, buf, len);
+#endif
+}
+
+size_t diaFwrite(void *ptr, size_t size, size_t nmemb, diaFile * stream)
+{
+#ifdef GNOME
+	GnomeVFSResult vfsResult;
+	GnomeVFSFileSize vfsBytesWritten;
+
+	vfsResult = gnome_vfs_write(stream, ptr, size * nmemb, &vfsBytesWritten);
+	if (vfsResult != GNOME_VFS_OK)
+		return 0;
+	return vfsBytesWritten;
+#else
+	return gzwrite(stream, ptr, size * nmemb);
+#endif
+}
+
+int diaFprintf(diaFile * file, const char * format, ...)
+{
+	va_list args;
+	char *buf;
+	int writeCount;
+
+	va_start(args, format);
+	writeCount = vasprintf(&buf, format, args);
+	va_end(args);
+#ifdef GNOME
+	return diaFwrite(buf, sizeof(char), writeCount, file);
+#else
+	return gzputs(file, buf);
+#endif
+}
+
+int diaPutc(int c, FILE *stream)
+{
+#ifdef GNOME
+	return diaFwrite(&c, sizeof(char), 1, stream);
+#else
+	return gzputc(stream, c);
+#endif
+}
+
+int diaClose(diaFile * file)
+{
+#ifdef GNOME
+	return gnome_vfs_close(file);
+#else
+	return gzclose(file);
+#endif
+}
diff -u --recursive dia-vanilla/lib/filter.h dia/lib/filter.h
--- dia-vanilla/lib/filter.h	2003-10-11 01:50:57.000000000 -0500
+++ dia/lib/filter.h	2003-11-30 20:45:17.000000000 -0600
@@ -21,9 +21,17 @@
 #ifndef FILTER_H
 #define FILTER_H
 
+#ifdef GNOME
+#define _GNU_SOURCE /* for vasprintf */
+#include <libgnomevfs/gnome-vfs.h>
+#else
+#include <zlib.h>
+#endif
+
 #include "diatypes.h"
 #include <glib.h>
 #include <diagramdata.h>
+#include <stdarg.h>
 
 typedef void (* DiaExportFunc) (DiagramData *dia, const gchar *filename,
 				const gchar *diafilename, void* user_data);
@@ -98,4 +106,17 @@
 /* returns all registered callbacks */
 GList *filter_get_callbacks(void);
 
+#ifdef GNOME
+typedef GnomeVFSHandle diaFile;
+#else
+typedef gzFile diaFile;
+#endif
+
+diaFile * diaOpen(const char *path, const char *mode);
+int diaRead(diaFile * file, void * buf, unsigned int len);
+char *diaFgets(char * buf, int len, diaFile * file);
+size_t diaFwrite(void *ptr, size_t size, size_t nmemb, diaFile * stream);
+int diaFprintf(diaFile * file, const char * format, ...);
+int diaClose(diaFile * file);
+
 #endif
diff -u --recursive dia-vanilla/plug-ins/cgm/cgm.c dia/plug-ins/cgm/cgm.c
--- dia-vanilla/plug-ins/cgm/cgm.c	2003-05-01 16:28:15.000000000 -0500
+++ dia/plug-ins/cgm/cgm.c	2003-12-02 10:04:14.929689000 -0600
@@ -65,8 +65,8 @@
 static void
 write_uint16(FILE *fp, guint16 n)
 {
-    putc( (n & 0xff00) >> 8, fp);
-    putc( n & 0xff, fp);
+    diaPutc( (n & 0xff00) >> 8, fp);
+    diaPutc( n & 0xff, fp);
 }
 
 static void
@@ -78,10 +78,10 @@
 static void
 write_uint32(FILE *fp, guint32 n)
 {
-    putc((n >> 24) & 0xff, fp);
-    putc((n >> 16) & 0xff, fp); 
-    putc((n >> 8) & 0xff, fp); 
-    putc(n & 0xff, fp); 
+    diaPutc((n >> 24) & 0xff, fp);
+    diaPutc((n >> 16) & 0xff, fp); 
+    diaPutc((n >> 8) & 0xff, fp); 
+    diaPutc(n & 0xff, fp); 
 }
 
 static void
@@ -93,9 +93,9 @@
 static void
 write_colour(FILE *fp, Color *c)
 {
-    putc((int)(c->red   * 255), fp);
-    putc((int)(c->green * 255), fp);
-    putc((int)(c->blue  * 255), fp);
+    diaPutc((int)(c->red   * 255), fp);
+    diaPutc((int)(c->green * 255), fp);
+    diaPutc((int)(c->blue  * 255), fp);
 }
 
 #define REALSIZE 4
@@ -425,7 +425,7 @@
     {
         write_elhead(renderer->file, 5, 4, 3); /* line colour */
         write_colour(renderer->file, &lnew->color);
-        putc(0, renderer->file);
+        diaPutc(0, renderer->file);
         lold->color = lnew->color;
     }
 }
@@ -506,7 +506,7 @@
         {
             write_elhead(renderer->file, 5, 29, 3); /* line colour */
             write_colour(renderer->file, &fnew->color);
-            putc(0, renderer->file);
+            diaPutc(0, renderer->file);
             fold->color = fnew->color;
         }
     }
@@ -537,7 +537,7 @@
         {
             write_elhead(renderer->file, 5, 23, 3);   /* fill colour */
             write_colour(renderer->file, &fnew->fill_color);
-            putc(0, renderer->file);
+            diaPutc(0, renderer->file);
             fold->fill_color = fnew->fill_color;
         }
     }
@@ -586,7 +586,7 @@
     {
         write_elhead(renderer->file, 5, 14, 3);   /* text colour */
         write_colour(renderer->file, &tnew->color);
-        putc(0, renderer->file);
+        diaPutc(0, renderer->file);
         told->color = tnew->color;
     }
 }
@@ -607,7 +607,7 @@
     /* end metafile */
     write_elhead(renderer->file, 0, 2, 0);
 
-    fclose(renderer->file);
+    diaClose(renderer->file);
 }
 
 static void
@@ -1067,10 +1067,10 @@
     write_real(renderer->file, x);
     write_real(renderer->file, y);
     write_int16(renderer->file, (len == chunk)); /* last chunk? */
-    putc(chunk, renderer->file);
-    fwrite(text, sizeof(char), chunk, renderer->file);
+    diaPutc(chunk, renderer->file);
+    diaFwrite(text, sizeof(char), chunk, renderer->file);
     if (!IS_ODD(chunk))
-	putc(0, renderer->file);
+	diaPutc(0, renderer->file);
 
     len -= chunk;
     text += chunk;
@@ -1079,10 +1079,10 @@
 	chunk = MIN(maxappendchunk, len);
 	write_elhead(renderer->file, 4, 6, 2 + 1 + chunk);
 	write_int16(renderer->file, (len == chunk));
-	putc(chunk, renderer->file);
-	fwrite(text, sizeof(char), chunk, renderer->file);
+	diaPutc(chunk, renderer->file);
+	diaFwrite(text, sizeof(char), chunk, renderer->file);
 	if (!IS_ODD(chunk))
-	    putc(0, renderer->file);
+	    diaPutc(0, renderer->file);
 
 	len -= chunk;
 	text += chunk;
@@ -1133,7 +1133,7 @@
 	write_int16(renderer->file, 8); /* colour precision */
 	write_int16(renderer->file, 1); /* packed encoding */
 
-	fwrite(ptr, sizeof(guint8), chunk, renderer->file);
+	diaFwrite(ptr, sizeof(guint8), chunk, renderer->file);
 
 	lines -= clines;
 	ptr += chunk;
@@ -1151,7 +1151,7 @@
     Rectangle *extent;
     gint len;
 
-    file = fopen(filename, "wb");
+    file = diaOpen(filename, "wb");
 
     if (file == NULL) {
 	message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -1165,10 +1165,10 @@
     /* write BEGMF */
     len = strlen(dia_version_string);
     write_elhead(file, 0, 1, len + 1);
-    putc(len, file);
-    fwrite(dia_version_string, sizeof(char), len, file);
+    diaPutc(len, file);
+    diaFwrite(dia_version_string, sizeof(char), len, file);
     if (!IS_ODD(len))
-	putc(0, file);
+	diaPutc(0, file);
 
     /* write metafile version */
     write_elhead(file, 1, 1, 2);
@@ -1178,10 +1178,10 @@
     /* write metafile description -- use original dia filename */
     len = strlen(diafilename);
     write_elhead(file, 1, 2, len + 1);
-    putc(len, file);
-    fwrite(diafilename, sizeof(char), len, file);
+    diaPutc(len, file);
+    diaFwrite(diafilename, sizeof(char), len, file);
     if (!IS_ODD(len))
-	putc(0, file);
+	diaPutc(0, file);
 #endif
 
     /* set integer precision */
@@ -1205,17 +1205,17 @@
     /* write font list */
     init_fonts();
     write_elhead(file, 1, 13, fontlistlen);
-    fwrite(fontlist, sizeof(char), fontlistlen, file);
+    diaFwrite(fontlist, sizeof(char), fontlistlen, file);
     if (IS_ODD(fontlistlen))
-	putc(0, file);
+	diaPutc(0, file);
  
     /* begin picture */
     len = strlen(diafilename);
     write_elhead(file, 0, 3, len + 1);
-    putc(len, file);
-    fwrite(diafilename, sizeof(char), len, file);
+    diaPutc(len, file);
+    diaFwrite(diafilename, sizeof(char), len, file);
     if (!IS_ODD(len))
-	putc(0, file);
+	diaPutc(0, file);
 
     /* write the colour mode string */
     write_elhead(file, 2, 2, 2);
@@ -1247,7 +1247,7 @@
     /* write back colour */
     write_elhead(file, 2, 7, 3);
     write_colour(file, &data->bg_color);
-    putc(0, file);
+    diaPutc(0, file);
 
     /* begin the picture body */
     write_elhead(file, 0, 4, 0);
diff -u --recursive dia-vanilla/plug-ins/dxf/dxf-export.c dia/plug-ins/dxf/dxf-export.c
--- dia-vanilla/plug-ins/dxf/dxf-export.c	2003-05-01 16:28:17.000000000 -0500
+++ dia/plug-ins/dxf/dxf-export.c	2003-11-30 19:23:05.000000000 -0600
@@ -276,8 +276,8 @@
 {
     DxfRenderer *renderer = DXF_RENDERER(self);
 
-    fprintf(renderer->file, "0\nENDSEC\n0\nEOF\n");
-    fclose(renderer->file);
+    diaFprintf(renderer->file, "0\nENDSEC\n0\nEOF\n");
+    diaClose(renderer->file);
 }
 
 static void
@@ -352,14 +352,14 @@
 {
     DxfRenderer *renderer = DXF_RENDERER(self);
 
-    fprintf(renderer->file, "  0\nLINE\n");
-    fprintf(renderer->file, "  8\n%s\n", renderer->layername);
-    fprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
-    fprintf(renderer->file, " 10\n%f\n", start->x);
-    fprintf(renderer->file, " 20\n%f\n", (-1)*start->y);
-    fprintf(renderer->file, " 11\n%f\n", end->x);
-    fprintf(renderer->file, " 21\n%f\n", (-1)*end->y);
-    fprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
+    diaFprintf(renderer->file, "  0\nLINE\n");
+    diaFprintf(renderer->file, "  8\n%s\n", renderer->layername);
+    diaFprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
+    diaFprintf(renderer->file, " 10\n%f\n", start->x);
+    diaFprintf(renderer->file, " 20\n%f\n", (-1)*start->y);
+    diaFprintf(renderer->file, " 11\n%f\n", end->x);
+    diaFprintf(renderer->file, " 21\n%f\n", (-1)*end->y);
+    diaFprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
 }
 
 static void 
@@ -388,16 +388,16 @@
     DxfRenderer *renderer = DXF_RENDERER(self);
 
     if(height != 0.0){
-        fprintf(renderer->file, "  0\nELLIPSE\n");
-        fprintf(renderer->file, "  8\n%s\n", renderer->layername);
-        fprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
-        fprintf(renderer->file, " 10\n%f\n", center->x);
-        fprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
-        fprintf(renderer->file, " 11\n%f\n", width/2); /* Endpoint major axis relative to center X*/            
-        fprintf(renderer->file, " 40\n%f\n", width/height); /*Ratio major/minor axis*/
-        fprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
-        fprintf(renderer->file, " 41\n%f\n", (angle1/360 ) * 2 * M_PI); /*Start Parameter full ellipse */
-        fprintf(renderer->file, " 42\n%f\n", (angle2/360 ) * 2 * M_PI); /* End Parameter full ellipse */		
+        diaFprintf(renderer->file, "  0\nELLIPSE\n");
+        diaFprintf(renderer->file, "  8\n%s\n", renderer->layername);
+        diaFprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
+        diaFprintf(renderer->file, " 10\n%f\n", center->x);
+        diaFprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
+        diaFprintf(renderer->file, " 11\n%f\n", width/2); /* Endpoint major axis relative to center X*/            
+        diaFprintf(renderer->file, " 40\n%f\n", width/height); /*Ratio major/minor axis*/
+        diaFprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
+        diaFprintf(renderer->file, " 41\n%f\n", (angle1/360 ) * 2 * M_PI); /*Start Parameter full ellipse */
+        diaFprintf(renderer->file, " 42\n%f\n", (angle2/360 ) * 2 * M_PI); /* End Parameter full ellipse */		
     }          
 }
 
@@ -421,25 +421,25 @@
 
     /* draw a circle instead of an ellipse, if it's one */
     if(width == height){
-        fprintf(renderer->file, "  0\nCIRCLE\n");
-        fprintf(renderer->file, "  8\n%s\n", renderer->layername);
-        fprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
-        fprintf(renderer->file, " 10\n%f\n", center->x);
-        fprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
-        fprintf(renderer->file, " 40\n%f\n", height/2);
-        fprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
+        diaFprintf(renderer->file, "  0\nCIRCLE\n");
+        diaFprintf(renderer->file, "  8\n%s\n", renderer->layername);
+        diaFprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
+        diaFprintf(renderer->file, " 10\n%f\n", center->x);
+        diaFprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
+        diaFprintf(renderer->file, " 40\n%f\n", height/2);
+        diaFprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
     }
     else if(height != 0.0){
-        fprintf(renderer->file, "  0\nELLIPSE\n");
-        fprintf(renderer->file, "  8\n%s\n", renderer->layername);
-        fprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
-        fprintf(renderer->file, " 10\n%f\n", center->x);
-        fprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
-        fprintf(renderer->file, " 11\n%f\n", width/2); /* Endpoint major axis relative to center X*/            
-        fprintf(renderer->file, " 40\n%f\n", height/width); /*Ratio major/minor axis*/
-        fprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
-        fprintf(renderer->file, " 41\n%f\n", 0.0); /*Start Parameter full ellipse */
-        fprintf(renderer->file, " 42\n%f\n", 2.0*3.14); /* End Parameter full ellipse */		
+        diaFprintf(renderer->file, "  0\nELLIPSE\n");
+        diaFprintf(renderer->file, "  8\n%s\n", renderer->layername);
+        diaFprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
+        diaFprintf(renderer->file, " 10\n%f\n", center->x);
+        diaFprintf(renderer->file, " 20\n%f\n", (-1)*center->y);
+        diaFprintf(renderer->file, " 11\n%f\n", width/2); /* Endpoint major axis relative to center X*/            
+        diaFprintf(renderer->file, " 40\n%f\n", height/width); /*Ratio major/minor axis*/
+        diaFprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
+        diaFprintf(renderer->file, " 41\n%f\n", 0.0); /*Start Parameter full ellipse */
+        diaFprintf(renderer->file, " 42\n%f\n", 2.0*3.14); /* End Parameter full ellipse */		
     }
 }
 
@@ -461,25 +461,25 @@
 {
     DxfRenderer *renderer = DXF_RENDERER(self);
 
-    fprintf(renderer->file, "  0\nTEXT\n");
-    fprintf(renderer->file, "  8\n%s\n", renderer->layername);
-    fprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
-    fprintf(renderer->file, " 10\n%f\n", pos->x);
-    fprintf(renderer->file, " 20\n%f\n", (-1)*pos->y);
-    fprintf(renderer->file, " 40\n%f\n", renderer->tcurrent.font_height); /* Text height */
-    fprintf(renderer->file, " 50\n%f\n", 0.0); /* Text rotation */
+    diaFprintf(renderer->file, "  0\nTEXT\n");
+    diaFprintf(renderer->file, "  8\n%s\n", renderer->layername);
+    diaFprintf(renderer->file, "  6\n%s\n", renderer->lcurrent.style);
+    diaFprintf(renderer->file, " 10\n%f\n", pos->x);
+    diaFprintf(renderer->file, " 20\n%f\n", (-1)*pos->y);
+    diaFprintf(renderer->file, " 40\n%f\n", renderer->tcurrent.font_height); /* Text height */
+    diaFprintf(renderer->file, " 50\n%f\n", 0.0); /* Text rotation */
     switch(alignment) {
     case ALIGN_LEFT :
-	fprintf(renderer->file, " 72\n%d\n", 0);
+	diaFprintf(renderer->file, " 72\n%d\n", 0);
     case ALIGN_RIGHT :
-   	fprintf(renderer->file, " 72\n%d\n", 2);
+   	diaFprintf(renderer->file, " 72\n%d\n", 2);
     case ALIGN_CENTER :
-   	fprintf(renderer->file, " 72\n%d\n", 1);	    	    
+   	diaFprintf(renderer->file, " 72\n%d\n", 1);	    	    
     }    
-    fprintf(renderer->file, "  7\n%s\n", "0"); /* Text style */
-    fprintf(renderer->file, "  1\n%s\n", text);
-    fprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
-    fprintf(renderer->file, " 62\n%d\n", 1);
+    diaFprintf(renderer->file, "  7\n%s\n", "0"); /* Text style */
+    diaFprintf(renderer->file, "  1\n%s\n", text);
+    diaFprintf(renderer->file, " 39\n%d\n", (int)(10*renderer->lcurrent.width)); /* Thickness */
+    diaFprintf(renderer->file, " 62\n%d\n", 1);
 }
 
 static void
@@ -499,7 +499,7 @@
     int i;
     Layer *layer;
 
-    file = fopen(filename, "w");
+    file = diaOpen(filename, "w");
 
     if (file == NULL) {
 	message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -511,21 +511,21 @@
     renderer->file = file;
     
     /* write layer description */
-    fprintf(file,"O\nSECTION\n2\nTABLES\n");
+    diaFprintf(file,"O\nSECTION\n2\nTABLES\n");
     for (i=0; i<data->layers->len; i++) {
       layer = (Layer *) g_ptr_array_index(data->layers, i);
-      fprintf(file,"0\nLAYER\n2\n%s\n",layer->name);
+      diaFprintf(file,"0\nLAYER\n2\n%s\n",layer->name);
       if(layer->visible){
-		fprintf(file,"62\n%d\n",i+1);
+		diaFprintf(file,"62\n%d\n",i+1);
       }
       else {
-      	fprintf(file,"62\n%d\n",(-1)*(i+1));
+      	diaFprintf(file,"62\n%d\n",(-1)*(i+1));
       }
   	}
-    fprintf(file, "0\nENDTAB\n0\nENDSEC\n");    
+    diaFprintf(file, "0\nENDTAB\n0\nENDSEC\n");    
     
     /* write graphics */
-    fprintf(file,"0\nSECTION\n2\nENTITIES\n");
+    diaFprintf(file,"0\nSECTION\n2\nENTITIES\n");
     
     init_attributes(renderer);
 
diff -u --recursive dia-vanilla/plug-ins/dxf/dxf-import.c dia/plug-ins/dxf/dxf-import.c
--- dia-vanilla/plug-ins/dxf/dxf-import.c	2002-12-05 17:47:50.000000000 -0600
+++ dia/plug-ins/dxf/dxf-import.c	2003-11-30 13:04:55.000000000 -0600
@@ -1299,7 +1299,7 @@
     DxfData *data;
     int codedxf;
     
-    filedxf = fopen(filename,"r");
+    filedxf = diaOpen(filename,"r");
     if(filedxf == NULL){
         message_error(_("Couldn't open: '%s' for reading.\n"), filename);
         return FALSE;
@@ -1356,12 +1356,16 @@
     int i;
     char *c;
     
-    if(fgets(data->code, DXF_LINE_LENGTH, filedxf) == NULL){
+printf("here we go\n");
+    if(diaFgets(data->code, DXF_LINE_LENGTH, filedxf) == NULL){
         return FALSE;
     }
-    if(fgets(data->value, DXF_LINE_LENGTH, filedxf) == NULL){
+printf("%s\n", data->code);
+    if(diaFgets(data->value, DXF_LINE_LENGTH, filedxf) == NULL){
         return FALSE;
     }
+printf("%s\n", data->value);
+printf("done\n");
     c=data->value;
     for(i=0; i < DXF_LINE_LENGTH; i++){		
         if((c[i] == '\n')||(c[i] == '\r')){
diff -u --recursive dia-vanilla/plug-ins/hpgl/hpgl.c dia/plug-ins/hpgl/hpgl.c
--- dia-vanilla/plug-ins/hpgl/hpgl.c	2003-05-01 16:28:17.000000000 -0500
+++ dia/plug-ins/hpgl/hpgl.c	2003-11-30 20:28:19.000000000 -0600
@@ -150,7 +150,7 @@
     }
 
     if (renderer->last_pen != nPen)
-        fprintf(renderer->file, "SP%d;\n", nPen+1);
+        diaFprintf(renderer->file, "SP%d;\n", nPen+1);
     renderer->last_pen = nPen;
 }
 
@@ -185,7 +185,7 @@
     HpglRenderer *renderer = HPGL_RENDERER (object);
 
     DIAG_NOTE(g_message("end_render"));
-    fclose(renderer->file);
+    diaClose(renderer->file);
 }
 
 static void
@@ -246,22 +246,22 @@
     /* line type */
     switch (mode) {
     case LINESTYLE_SOLID:
-      fprintf(renderer->file, "LT;\n");
+      diaFprintf(renderer->file, "LT;\n");
       break;
     case LINESTYLE_DASHED:
       if (renderer->dash_length > 0.5) /* ??? unit of dash_lenght ? */
-          fprintf(renderer->file, "LT2;\n"); /* short */
+          diaFprintf(renderer->file, "LT2;\n"); /* short */
       else
-          fprintf(renderer->file, "LT3;\n"); /* long */
+          diaFprintf(renderer->file, "LT3;\n"); /* long */
       break;
     case LINESTYLE_DASH_DOT:
-      fprintf(renderer->file, "LT4;\n");
+      diaFprintf(renderer->file, "LT4;\n");
       break;
     case LINESTYLE_DASH_DOT_DOT:
-      fprintf(renderer->file, "LT5;\n"); /* ??? Mittellinie? */
+      diaFprintf(renderer->file, "LT5;\n"); /* ??? Mittellinie? */
       break;
     case LINESTYLE_DOTTED:
-      fprintf(renderer->file, "LT1;\n");
+      diaFprintf(renderer->file, "LT1;\n");
       break;
     default:
 	message_error("HpglRenderer : Unsupported fill mode specified!\n");
@@ -319,7 +319,7 @@
     DIAG_NOTE(g_message("draw_line %f,%f -> %f, %f", 
               start->x, start->y, end->x, end->y));
     hpgl_select_pen(renderer, line_colour, 0.0);
-    fprintf (renderer->file, 
+    diaFprintf (renderer->file, 
              "PU%d,%d;PD%d,%d;\n",
              hpgl_scale(renderer, start->x), hpgl_scale(renderer, -start->y),
              hpgl_scale(renderer, end->x), hpgl_scale(renderer, -end->y));
@@ -339,16 +339,16 @@
     g_return_if_fail(1 < num_points);
 
     hpgl_select_pen(renderer, line_colour, 0.0);
-    fprintf (renderer->file, "PU%d,%d;PD;PA",
+    diaFprintf (renderer->file, "PU%d,%d;PD;PA",
              hpgl_scale(renderer, points[0].x),
              hpgl_scale(renderer, -points[0].y));
     /* absolute movement */
     for (i = 1; i < num_points-1; i++)
-        fprintf(renderer->file, "%d,%d,",
+        diaFprintf(renderer->file, "%d,%d,",
                 hpgl_scale(renderer, points[i].x),
                 hpgl_scale(renderer, -points[i].y));
     i = num_points - 1;
-    fprintf(renderer->file, "%d,%d;\n",
+    diaFprintf(renderer->file, "%d,%d;\n",
             hpgl_scale(renderer, points[i].x),
             hpgl_scale(renderer, -points[i].y));
 }
@@ -389,7 +389,7 @@
     DIAG_NOTE(g_message("draw_rect %f,%f -> %f,%f", 
               ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y));
     hpgl_select_pen(renderer, colour, 0.0);
-    fprintf (renderer->file, "PU%d,%d;PD;EA%d,%d;\n",
+    diaFprintf (renderer->file, "PU%d,%d;PD;EA%d,%d;\n",
              hpgl_scale(renderer, ul_corner->x),
              hpgl_scale(renderer, -ul_corner->y),
              hpgl_scale(renderer, lr_corner->x),
@@ -407,7 +407,7 @@
               ul_corner->x, ul_corner->y, lr_corner->x, lr_corner->y));
 #if 0
     hpgl_select_pen(renderer, colour, 0.0);
-    fprintf (renderer->file, "PU%d,%d;PD;RA%d,%d;\n",
+    diaFprintf (renderer->file, "PU%d,%d;PD;RA%d,%d;\n",
              hpgl_scale(renderer, ul_corner->x),
              hpgl_scale(renderer, -ul_corner->y),
              hpgl_scale(renderer, lr_corner->x),
@@ -435,11 +435,11 @@
     /* move to start point */
     start.x = center->x + (width / 2.0)  * cos((M_PI / 180.0) * angle1);  
     start.y = - center->y + (height / 2.0) * sin((M_PI / 180.0) * angle1);
-    fprintf (renderer->file, "PU%d,%d;PD;",
+    diaFprintf (renderer->file, "PU%d,%d;PD;",
              hpgl_scale(renderer, start.x),
              hpgl_scale(renderer, start.y));
     /* Arc Absolute - around center */
-    fprintf (renderer->file, "AA%d,%d,%d;",
+    diaFprintf (renderer->file, "AA%d,%d,%d;",
              hpgl_scale(renderer, center->x),
              hpgl_scale(renderer, - center->y),
              (int)floor(360.0 - angle1 + angle2));
@@ -459,11 +459,11 @@
     g_assert (width == height);
 
     /* move to center */
-    fprintf (renderer->file, "PU%d,%d;PD;",
+    diaFprintf (renderer->file, "PU%d,%d;PD;",
              hpgl_scale(renderer, center->x),
              hpgl_scale(renderer, -center->y));
     /* Edge Wedge */
-    fprintf (renderer->file, "EW%d,%d,%d;",
+    diaFprintf (renderer->file, "EW%d,%d,%d;",
              hpgl_scale(renderer, width),
              (int)angle1, (int)(angle2-angle1));
 }
@@ -539,7 +539,7 @@
     {
       hpgl_select_pen(renderer, colour, 0.0);
 
-      fprintf (renderer->file, "PU%d,%d;CI%d;\n",
+      diaFprintf (renderer->file, "PU%d,%d;CI%d;\n",
                hpgl_scale(renderer, center->x),
                hpgl_scale(renderer, -center->y),
                hpgl_scale(renderer, width / 2.0));
@@ -582,18 +582,18 @@
               pos->x, pos->y, text));
 
     /* set position */
-    fprintf(renderer->file, "PU%d,%d;",
+    diaFprintf(renderer->file, "PU%d,%d;",
             hpgl_scale(renderer, pos->x), hpgl_scale(renderer, -pos->y));
 
     switch (alignment) {
     case ALIGN_LEFT:
-        fprintf (renderer->file, "LO1;\n");
+        diaFprintf (renderer->file, "LO1;\n");
 	break;
     case ALIGN_CENTER:
-        fprintf (renderer->file, "LO4;\n");
+        diaFprintf (renderer->file, "LO4;\n");
 	break;
     case ALIGN_RIGHT:
-        fprintf (renderer->file, "LO7;\n");
+        diaFprintf (renderer->file, "LO7;\n");
 	break;
     }
     hpgl_select_pen(renderer,colour,0.0);
@@ -606,18 +606,18 @@
      */
     height = (127.999 * renderer->font_height * renderer->scale) / renderer->size.y; 
     width  = 0.75 * height; /* FIXME: */
-    fprintf(renderer->file, "SR%.3f,%.3f;", width, height);
+    diaFprintf(renderer->file, "SR%.3f,%.3f;", width, height);
 #else
     /*
      * SI - character size absolute
      *    size needed in centimeters
      */
-    fprintf(renderer->file, "SI%.3f,%.3f;", 
+    diaFprintf(renderer->file, "SI%.3f,%.3f;", 
             renderer->font_height * renderer->scale * 0.75 * 0.0025,
             renderer->font_height * renderer->scale * 0.0025);
 
 #endif
-    fprintf(renderer->file, "DT\003;" /* Terminator */
+    diaFprintf(renderer->file, "DT\003;" /* Terminator */
             "LB%s\003;\n", text);
 }
 
@@ -726,7 +726,7 @@
     Rectangle *extent;
     real width, height;
 
-    file = fopen(filename, "w"); /* "wb" for binary! */
+    file = diaOpen(filename, "w"); /* "wb" for binary! */
 
     if (file == NULL) {
 	message_error(_("Can't open output file %s: %s\n"), file, strerror(errno));
@@ -756,7 +756,7 @@
     renderer->size.y = height * renderer->scale;
 #if 0
     /* OR: set page size and scale */
-    fprintf(renderer->file, "PS0;SC%d,%d,%d,%d;\n",
+    diaFprintf(renderer->file, "PS0;SC%d,%d,%d,%d;\n",
             hpgl_scale(renderer, extent->left),
             hpgl_scale(renderer, extent->right),
             hpgl_scale(renderer, extent->bottom),
diff -u --recursive dia-vanilla/plug-ins/metapost/render_metapost.c dia/plug-ins/metapost/render_metapost.c
--- dia-vanilla/plug-ins/metapost/render_metapost.c	2003-07-11 10:21:51.000000000 -0500
+++ dia/plug-ins/metapost/render_metapost.c	2003-11-30 20:31:12.000000000 -0600
@@ -208,21 +208,21 @@
 static void
 end_draw_op(MetapostRenderer *renderer)
 {
-    fprintf(renderer->file, "\n    withpen pencircle scaled %5.4fx", 
+    diaFprintf(renderer->file, "\n    withpen pencircle scaled %5.4fx", 
             (double)renderer->line_width);
-    fprintf(renderer->file, "\n    withcolor (%5.4f, %5.4f, %5.4f)", 
+    diaFprintf(renderer->file, "\n    withcolor (%5.4f, %5.4f, %5.4f)", 
             (double)renderer->color.red,
             (double)renderer->color.green,
             (double)renderer->color.blue);
     draw_with_linestyle(renderer);
-    fprintf(renderer->file, ";\n");
+    diaFprintf(renderer->file, ";\n");
 }
 	    
 static void 
 set_line_color(MetapostRenderer *renderer,Color *color)
 {
     renderer->color = *color;
-    fprintf(renderer->file, "%% set_line_color %f, %f, %f\n", 
+    diaFprintf(renderer->file, "%% set_line_color %f, %f, %f\n", 
             (double)color->red, (double)color->green, (double)color->blue);
 }
 
@@ -243,16 +243,16 @@
 {
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
   
-    fprintf(renderer->file,"endfig;\n");
-    fprintf(renderer->file,"end;\n");
-    fclose(renderer->file);
+    diaFprintf(renderer->file,"endfig;\n");
+    diaFprintf(renderer->file,"end;\n");
+    diaClose(renderer->file);
 }
 
 static void
 set_linewidth(DiaRenderer *self, real linewidth)
 {  /* 0 == hairline **/
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
-    fprintf(renderer->file, "%% set_linewidth %f\n", linewidth);
+    diaFprintf(renderer->file, "%% set_linewidth %f\n", linewidth);
     renderer->line_width = linewidth;
 }
 
@@ -266,17 +266,17 @@
   
     switch(mode) {
     case LINECAPS_BUTT:
-	fprintf(renderer->file, "linecap:=butt;\n");
+	diaFprintf(renderer->file, "linecap:=butt;\n");
 	break;
     case LINECAPS_ROUND:
-	fprintf(renderer->file, "linecap:=rounded;\n");
+	diaFprintf(renderer->file, "linecap:=rounded;\n");
 	break;
     case LINECAPS_PROJECTING:
 	/* is this right? */
-	fprintf(renderer->file, "linecap:=squared;\n");
+	diaFprintf(renderer->file, "linecap:=squared;\n");
 	break;
     default:
-	fprintf(renderer->file, "linecap:=squared;\n");
+	diaFprintf(renderer->file, "linecap:=squared;\n");
     }
 
     renderer->saved_line_cap = mode;
@@ -292,13 +292,13 @@
 
     switch(mode) {
     case LINEJOIN_MITER:
-	fprintf(renderer->file, "linejoin:=mitered;\n");
+	diaFprintf(renderer->file, "linejoin:=mitered;\n");
 	break;
     case LINEJOIN_ROUND:
-	fprintf(renderer->file, "linejoin:=rounded;\n");
+	diaFprintf(renderer->file, "linejoin:=rounded;\n");
 	break;
     case LINEJOIN_BEVEL:
-	fprintf(renderer->file, "linejoin:=beveled;\n");
+	diaFprintf(renderer->file, "linejoin:=beveled;\n");
 	break;
     default:
 	/* noop; required at least for msvc */;
@@ -323,13 +323,13 @@
     case LINESTYLE_SOLID:
 	break;
     case LINESTYLE_DASHED:
-	fprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx)", 
+	diaFprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx)", 
 		renderer->dash_length,
 		renderer->dash_length);
 	break;
     case LINESTYLE_DASH_DOT:
 	hole_width = (renderer->dash_length - renderer->dot_length) / 2.0;
-	fprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx on %fx off %fx)",
+	diaFprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx on %fx off %fx)",
 		renderer->dash_length,
 		hole_width,
 		renderer->dot_length,
@@ -337,7 +337,7 @@
 	break;
     case LINESTYLE_DASH_DOT_DOT:
 	hole_width = (renderer->dash_length - 2.0*renderer->dot_length) / 3.0;
-	fprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx on %fx off %fx on %fx off %fx)",
+	diaFprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx on %fx off %fx on %fx off %fx)",
 		renderer->dash_length,
 		hole_width,
 		renderer->dot_length,
@@ -346,7 +346,7 @@
 		hole_width );
 	break;
     case LINESTYLE_DOTTED:
-	fprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx)", 
+	diaFprintf(renderer->file, "\n    dashed dashpattern (on %fx off %fx)", 
 		renderer->dash_length,
 		renderer->dash_length);
 	break;
@@ -388,7 +388,7 @@
      * TODO: implement size, figure out how to specify tex document font 
      */
 #if 0
-    fprintf(renderer->file, "defaultfont:=\"%s\";\n", font_get_psfontname(font));
+    diaFprintf(renderer->file, "defaultfont:=\"%s\";\n", font_get_psfontname(font));
 #endif
 }
 
@@ -401,7 +401,7 @@
 
     set_line_color(renderer,line_color);
 
-    fprintf(renderer->file, "  draw (%fx,%fy)--(%fx,%fy)",
+    diaFprintf(renderer->file, "  draw (%fx,%fy)--(%fx,%fy)",
 	    start->x, start->y, end->x, end->y);
     end_draw_op(renderer);
 }
@@ -416,12 +416,12 @@
     
     set_line_color(renderer,line_color);
   
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  draw (%fx,%fy)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "--(%fx,%fy)",
+	diaFprintf(renderer->file, "--(%fx,%fy)",
 		points[i].x, points[i].y);
     }
     end_draw_op(renderer);
@@ -437,15 +437,15 @@
 
     set_line_color(renderer,line_color);
   
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  draw (%fx,%fy)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "--(%fx,%fy)",
+	diaFprintf(renderer->file, "--(%fx,%fy)",
 		points[i].x, points[i].y);
     }
-    fprintf(renderer->file,"--cycle");
+    diaFprintf(renderer->file,"--cycle");
     end_draw_op(renderer);
 }
 
@@ -459,18 +459,18 @@
 
     set_line_color(renderer,line_color);
     
-    fprintf(renderer->file, "%% fill_polygon\n");
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, "%% fill_polygon\n");
+    diaFprintf(renderer->file, 
 	    "  path p;\n"
 	    "  p = (%fx,%fy)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "--(%fx,%fy)",
+	diaFprintf(renderer->file, "--(%fx,%fy)",
 		points[i].x, points[i].y);
     }
-    fprintf(renderer->file,"--cycle;\n");
-    fprintf(renderer->file,"  fill p ");
+    diaFprintf(renderer->file,"--cycle;\n");
+    diaFprintf(renderer->file,"  fill p ");
     end_draw_op(renderer);
 }
 
@@ -483,7 +483,7 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  draw (%fx,%fy)--(%fx,%fy)--(%fx,%fy)--(%fx,%fy)--cycle",
 	    (double) ul_corner->x, (double) ul_corner->y,
 	    (double) ul_corner->x, (double) lr_corner->y,
@@ -499,14 +499,14 @@
 {
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
 
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  path p;\n"
 	    "  p = (%fx,%fy)--(%fx,%fy)--(%fx,%fy)--(%fx,%fy)--cycle;\n",
 	    (double) ul_corner->x, (double) ul_corner->y,
 	    (double) ul_corner->x, (double) lr_corner->y,
 	    (double) lr_corner->x, (double) lr_corner->y,
 	    (double) lr_corner->x, (double) ul_corner->y );
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	    "  fill p withcolor (%f,%f,%f);\n",
 	    (double) color->red, (double) color->green, (double) color->blue);
 }
@@ -526,13 +526,13 @@
     radius1=(double) width/2.0;
     radius2=(double) height/2.0;
 
-    fprintf(renderer->file,"%%metapost_arc\n");
-    fprintf(renderer->file, "%% %s = %f", "center->x", center->x);
-    fprintf(renderer->file, "%% %s = %f", "center->y", center->y);
-    fprintf(renderer->file, "%% %s = %f", "width", width);
-    fprintf(renderer->file, "%% %s = %f", "height", height);
-    fprintf(renderer->file, "%% %s = %f", "angle1", angle1);
-    fprintf(renderer->file, "%% %s = %f", "angle2", angle2);
+    diaFprintf(renderer->file,"%%metapost_arc\n");
+    diaFprintf(renderer->file, "%% %s = %f", "center->x", center->x);
+    diaFprintf(renderer->file, "%% %s = %f", "center->y", center->y);
+    diaFprintf(renderer->file, "%% %s = %f", "width", width);
+    diaFprintf(renderer->file, "%% %s = %f", "height", height);
+    diaFprintf(renderer->file, "%% %s = %f", "angle1", angle1);
+    diaFprintf(renderer->file, "%% %s = %f", "angle2", angle2);
     
     
     angle1 = angle1*M_PI/180;
@@ -543,7 +543,7 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	    "  draw (%fx,%fy)..(%fx,%fy)..(%fx,%fy)",
 	    cx + radius1*cos(angle1), cy - radius2*sin(angle1),
 	    cx + radius1*cos(angle3), cy - radius2*sin(angle3),
@@ -585,7 +585,7 @@
 
     set_line_color(renderer,color);
     
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  draw (%fx,%fy)..(%fx,%fy)..(%fx,%fy)..(%fx,%fy)..cycle",
 	    (double) center->x+width/2.0, (double) center->y,
 	    (double) center->x,           (double) center->y+height/2.0,
@@ -602,7 +602,7 @@
 {
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
 
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "  path p;\n"
 	    "  p = (%fx,%fy)..(%fx,%fy)..(%fx,%fy)..(%fx,%fy)..cycle;\n",
 	    (double) center->x+width/2.0, (double) center->y,
@@ -610,7 +610,7 @@
 	    (double) center->x-width/2.0, (double) center->y,
 	    (double) center->x,           (double) center->y-height/2.0);
 
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	    "  fill p withcolor (%f,%f,%f);\n",
 	    (double) color->red, (double) color->green, (double) color->blue);
 }
@@ -631,7 +631,7 @@
     if (points[0].type != BEZ_MOVE_TO)
 	g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-    fprintf(renderer->file, "  draw (%fx,%fy)",
+    diaFprintf(renderer->file, "  draw (%fx,%fy)",
 	    (double) points[0].p1.x, (double) points[0].p1.y);
   
     for (i = 1; i < numpoints; i++)
@@ -640,11 +640,11 @@
 	    g_warning("only first BezPoint can be a BEZ_MOVE_TO");
 	    break;
 	case BEZ_LINE_TO:
-	    fprintf(renderer->file, "--(%fx,%fy)",
+	    diaFprintf(renderer->file, "--(%fx,%fy)",
 		    (double) points[i].p1.x, (double) points[i].p1.y);
 	    break;
 	case BEZ_CURVE_TO:
-	    fprintf(renderer->file, "..controls (%fx,%fy) and (%fx,%fy)\n    ..(%fx,%fy)",
+	    diaFprintf(renderer->file, "..controls (%fx,%fy) and (%fx,%fy)\n    ..(%fx,%fy)",
 		    (double) points[i].p1.x, (double) points[i].p1.y,
 		    (double) points[i].p2.x, (double) points[i].p2.y,
 		    (double) points[i].p3.x, (double) points[i].p3.y);
@@ -667,8 +667,8 @@
     if (points[0].type != BEZ_MOVE_TO)
 	g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-    fprintf(renderer->file, "  path p;\n");
-    fprintf(renderer->file, "  p = (%fx,%fy)",
+    diaFprintf(renderer->file, "  path p;\n");
+    diaFprintf(renderer->file, "  p = (%fx,%fy)",
 	    (double) points[0].p1.x, (double) points[0].p1.y);
   
     for (i = 1; i < numpoints; i++)
@@ -677,19 +677,19 @@
 	    g_warning("only first BezPoint can be a BEZ_MOVE_TO");
 	    break;
 	case BEZ_LINE_TO:
-	    fprintf(renderer->file, "--(%fx,%fy)",
+	    diaFprintf(renderer->file, "--(%fx,%fy)",
 		    (double) points[i].p1.x, (double) points[i].p1.y);
 	    break;
 	case BEZ_CURVE_TO:
-	    fprintf(renderer->file, "..controls (%fx,%fy) and (%fx,%fy)\n    ..(%fx,%fy)",
+	    diaFprintf(renderer->file, "..controls (%fx,%fy) and (%fx,%fy)\n    ..(%fx,%fy)",
 		    (double) points[i].p1.x, (double) points[i].p1.y,
 		    (double) points[i].p2.x, (double) points[i].p2.y,
 		    (double) points[i].p3.x, (double) points[i].p3.y);
 	    break;
 	}
-    fprintf(renderer->file, "\n    ..cycle;\n");
+    diaFprintf(renderer->file, "\n    ..cycle;\n");
 
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	    "  fill p withcolor (%f,%f,%f);\n",
 	    (double) color->red, (double) color->green, (double) color->blue);
 }
@@ -706,16 +706,16 @@
 
     switch (alignment) {
     case ALIGN_LEFT:
-	fprintf(renderer->file,"  label.rt");
+	diaFprintf(renderer->file,"  label.rt");
 	break;
     case ALIGN_CENTER:
-	fprintf(renderer->file,"  label");
+	diaFprintf(renderer->file,"  label");
 	break;
     case ALIGN_RIGHT:
-	fprintf(renderer->file,"  label.lft");
+	diaFprintf(renderer->file,"  label.lft");
 	break;
     }
-    fprintf(renderer->file,
+    diaFprintf(renderer->file,
 	    "(btex %s etex,(%fx,%fy));\n",
 	    text, pos->x, pos->y);
 }
@@ -736,7 +736,7 @@
 
     MetapostRenderer *renderer = METAPOST_RENDERER (self);
 
-    fprintf(renderer->file, "  %% draw_image: %s\n", dia_image_filename(image));
+    diaFprintf(renderer->file, "  %% draw_image: %s\n", dia_image_filename(image));
     
 
     img_width = dia_image_width(image);
@@ -749,37 +749,37 @@
     rgb_data = dia_image_rgb_data(image);
     mask_data = dia_image_mask_data(image);
 
-    fprintf(renderer->file, "  pickup pensquare scaled %fx scaled %f;\n",
+    diaFprintf(renderer->file, "  pickup pensquare scaled %fx scaled %f;\n",
             (double) xstep,
             (double) (ystep/xstep));
 
 
     if (mask_data) {
-        fprintf(renderer->file, "  %% have mask\n");
+        diaFprintf(renderer->file, "  %% have mask\n");
         for (y = 0, iy = point->y; y < img_height; y++, iy += ystep) {
             for (x = 0, ix = point->x; x < img_width; x++, ix += xstep) {
                 int i = y*img_rowstride+x*3;
                 int m = y*img_width+x;
-                fprintf(renderer->file, "  draw (%fx, %fy) withcolor (%5.4f, %5.4f, %5.4f);\n",
+                diaFprintf(renderer->file, "  draw (%fx, %fy) withcolor (%5.4f, %5.4f, %5.4f);\n",
                         ix, iy,
                         (255-(mask_data[m]*(255-rgb_data[i])/255)/255.0),
                         (255-(mask_data[m]*(255-rgb_data[i+1])/255))/255.0,
                         (255-(mask_data[m]*(255-rgb_data[i+2])/255))/255.0);
             }
-            fprintf(renderer->file, "\n");
+            diaFprintf(renderer->file, "\n");
         }
     } else {
         guint8 *ptr = rgb_data;
         for (y = 0, iy = point->y; y < img_height; y++, iy += ystep) {
             for (x = 0, ix = point->x; x < img_width; x++, ix += xstep) {
                 int i = y*img_rowstride+x*3;
-                fprintf(renderer->file, "  draw (%fx, %fy) withcolor (%5.4f, %5.4f, %5.4f);\n",
+                diaFprintf(renderer->file, "  draw (%fx, %fy) withcolor (%5.4f, %5.4f, %5.4f);\n",
                         ix, iy,
                         (double)(rgb_data[i])/255.0,
                         (double)(rgb_data[i+1])/255.0,
                         (double)(rgb_data[i+2])/255.0);
             }
-            fprintf(renderer->file, "\n");
+            diaFprintf(renderer->file, "\n");
         }
     }
     
@@ -801,7 +801,7 @@
 
     Color initial_color;
  
-    file = fopen(filename, "wb");
+    file = diaOpen(filename, "wb");
 
     if (file==NULL) {
 	message_error(_("Can't open output file %s: %s\n"), file, strerror(errno));
@@ -823,7 +823,7 @@
   
     name = g_get_user_name();
   
-    fprintf(file,
+    diaFprintf(file,
 	    "%% Metapost TeX macro\n"
 	    "%% Title: %s\n"
 	    "%% Creator: Dia v%s\n"
@@ -836,13 +836,13 @@
 	    ctime(&time_now),
 	    name);
  
-    fprintf(renderer->file,"  %% picture(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file,"  %% picture(%f,%f)(%f,%f)\n",
 	    extent->left * data->paper.scaling,
 	    -extent->bottom * data->paper.scaling,
 	    extent->right * data->paper.scaling,
 	    -extent->top * data->paper.scaling
 	    );
-    fprintf(renderer->file,"  x = %fcm; y = %fcm;\n\n",
+    diaFprintf(renderer->file,"  x = %fcm; y = %fcm;\n\n",
 	    data->paper.scaling,
 	    -data->paper.scaling);
 
diff -u --recursive dia-vanilla/plug-ins/pstricks/render_pstricks.c dia/plug-ins/pstricks/render_pstricks.c
--- dia-vanilla/plug-ins/pstricks/render_pstricks.c	2003-10-14 16:51:10.000000000 -0500
+++ dia/plug-ins/pstricks/render_pstricks.c	2003-11-30 20:32:11.000000000 -0600
@@ -210,17 +210,17 @@
 static void 
 set_line_color(PstricksRenderer *renderer,Color *color)
 {
-    fprintf(renderer->file, "\\newrgbcolor{dialinecolor}{%f %f %f}\n",
+    diaFprintf(renderer->file, "\\newrgbcolor{dialinecolor}{%f %f %f}\n",
 	    (double) color->red, (double) color->green, (double) color->blue);
-    fprintf(renderer->file,"\\psset{linecolor=dialinecolor}\n");
+    diaFprintf(renderer->file,"\\psset{linecolor=dialinecolor}\n");
 }
 
 static void 
 set_fill_color(PstricksRenderer *renderer,Color *color)
 {
-    fprintf(renderer->file, "\\newrgbcolor{diafillcolor}{%f %f %f}\n",
+    diaFprintf(renderer->file, "\\newrgbcolor{diafillcolor}{%f %f %f}\n",
 	    (double) color->red, (double) color->green, (double) color->blue);
-    fprintf(renderer->file,"\\psset{fillcolor=diafillcolor}\n");
+    diaFprintf(renderer->file,"\\psset{fillcolor=diafillcolor}\n");
 }
 
 static void
@@ -233,8 +233,8 @@
 {
     PstricksRenderer *renderer = PSTRICKS_RENDERER(self);
   
-    fprintf(renderer->file,"}\\endpspicture");
-    fclose(renderer->file);
+    diaFprintf(renderer->file,"}\\endpspicture");
+    diaClose(renderer->file);
 }
 
 static void
@@ -242,7 +242,7 @@
 {  /* 0 == hairline **/
     PstricksRenderer *renderer = PSTRICKS_RENDERER(self);
 
-    fprintf(renderer->file, "\\psset{linewidth=%f}\n", (double) linewidth);
+    diaFprintf(renderer->file, "\\psset{linewidth=%f}\n", (double) linewidth);
 }
 
 static void
@@ -265,7 +265,7 @@
 	ps_mode = 0;
     }
 
-    fprintf(renderer->file, "\\setlinecaps{%d}\n", ps_mode);
+    diaFprintf(renderer->file, "\\setlinecaps{%d}\n", ps_mode);
 }
 
 static void
@@ -288,7 +288,7 @@
 	ps_mode = 0;
     }
 
-    fprintf(renderer->file, "\\setlinejoinmode{%d}\n", ps_mode);
+    diaFprintf(renderer->file, "\\setlinejoinmode{%d}\n", ps_mode);
 }
 
 static void
@@ -301,16 +301,16 @@
   
     switch(mode) {
     case LINESTYLE_SOLID:
-	fprintf(renderer->file, "\\psset{linestyle=solid}\n");
+	diaFprintf(renderer->file, "\\psset{linestyle=solid}\n");
 	break;
     case LINESTYLE_DASHED:
-	fprintf(renderer->file, "\\psset{linestyle=dashed,dash=%f %f}\n", 
+	diaFprintf(renderer->file, "\\psset{linestyle=dashed,dash=%f %f}\n", 
 		renderer->dash_length,
 		renderer->dash_length);
 	break;
     case LINESTYLE_DASH_DOT:
 	hole_width = (renderer->dash_length - renderer->dot_length) / 2.0;
-	fprintf(renderer->file, "\\linestyleddashdotted{%f %f %f %f}\n",
+	diaFprintf(renderer->file, "\\linestyleddashdotted{%f %f %f %f}\n",
 		renderer->dash_length,
 		hole_width,
 		renderer->dot_length,
@@ -318,7 +318,7 @@
 	break;
     case LINESTYLE_DASH_DOT_DOT:
 	hole_width = (renderer->dash_length - 2.0*renderer->dot_length) / 3.0;
-	fprintf(renderer->file, "\\linestyleddashdotdotted{%f %f %f %f %f %f}\n",
+	diaFprintf(renderer->file, "\\linestyleddashdotdotted{%f %f %f %f %f %f}\n",
 		renderer->dash_length,
 		hole_width,
 		renderer->dot_length,
@@ -327,7 +327,7 @@
 		hole_width );
 	break;
     case LINESTYLE_DOTTED:
-	fprintf(renderer->file, "\\psset{linestyle=dotted,dotsep=%f}\n", renderer->dot_length);
+	diaFprintf(renderer->file, "\\psset{linestyle=dotted,dotsep=%f}\n", renderer->dot_length);
 	break;
     }
 }
@@ -364,7 +364,7 @@
 {
     PstricksRenderer *renderer = PSTRICKS_RENDERER(self);
 
-    fprintf(renderer->file, "\\setfont{%s}{%f}\n",
+    diaFprintf(renderer->file, "\\setfont{%s}{%f}\n",
             dia_font_get_psfontname(font), (double)height);
 }
 
@@ -377,7 +377,7 @@
 
     set_line_color(renderer,line_color);
 
-    fprintf(renderer->file, "\\psline(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file, "\\psline(%f,%f)(%f,%f)\n",
 	    start->x, start->y, end->x, end->y);
 }
 
@@ -390,15 +390,15 @@
     int i;
   
     set_line_color(renderer,line_color);  
-    fprintf(renderer->file, "\\psline(%f,%f)",
+    diaFprintf(renderer->file, "\\psline(%f,%f)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "(%f,%f)",
+	diaFprintf(renderer->file, "(%f,%f)",
 		points[i].x, points[i].y);
     }
 
-    fprintf(renderer->file, "\n");
+    diaFprintf(renderer->file, "\n");
 }
 
 static void
@@ -411,14 +411,14 @@
 
     set_line_color(renderer,line_color);
   
-    fprintf(renderer->file, "\\pspolygon(%f,%f)",
+    diaFprintf(renderer->file, "\\pspolygon(%f,%f)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "(%f,%f)",
+	diaFprintf(renderer->file, "(%f,%f)",
 		points[i].x, points[i].y);
     }
-    fprintf(renderer->file,"\n");
+    diaFprintf(renderer->file,"\n");
 }
 
 static void
@@ -431,14 +431,14 @@
   
     set_line_color(renderer,line_color);
   
-    fprintf(renderer->file, "\\pspolygon*(%f,%f)",
+    diaFprintf(renderer->file, "\\pspolygon*(%f,%f)",
 	    points[0].x, points[0].y);
 
     for (i=1;i<num_points;i++) {
-	fprintf(renderer->file, "(%f,%f)",
+	diaFprintf(renderer->file, "(%f,%f)",
 		points[i].x, points[i].y);
     }
-    fprintf(renderer->file,"\n");
+    diaFprintf(renderer->file,"\n");
 }
 
 static void
@@ -450,7 +450,7 @@
 
     set_line_color(renderer,color);
   
-    fprintf(renderer->file, "\\pspolygon(%f,%f)(%f,%f)(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file, "\\pspolygon(%f,%f)(%f,%f)(%f,%f)(%f,%f)\n",
 	    (double) ul_corner->x, (double) ul_corner->y,
 	    (double) ul_corner->x, (double) lr_corner->y,
 	    (double) lr_corner->x, (double) lr_corner->y,
@@ -467,7 +467,7 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file, 
+    diaFprintf(renderer->file, 
 	    "\\pspolygon*(%f,%f)(%f,%f)(%f,%f)(%f,%f)\n",
 	    (double) ul_corner->x, (double) ul_corner->y,
 	    (double) ul_corner->x, (double) lr_corner->y,
@@ -488,17 +488,17 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file,"\\psclip{\\pswedge[linestyle=none,fillstyle=none](%f,%f){%f}{%f}{%f}}\n",
+    diaFprintf(renderer->file,"\\psclip{\\pswedge[linestyle=none,fillstyle=none](%f,%f){%f}{%f}{%f}}\n",
 	    (double) center->x, (double) center->y,
 	    sqrt(radius1*radius1+radius2*radius2),
 	    (double) 360.0 - angle2, (double) 360.0 - angle1);
   
-    fprintf(renderer->file,"\\psellipse%s(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file,"\\psellipse%s(%f,%f)(%f,%f)\n",
 	    (filled?"*":""),
 	    (double) center->x, (double) center->y,
 	    radius1,radius2);
 
-    fprintf(renderer->file,"\\endpsclip\n");
+    diaFprintf(renderer->file,"\\endpsclip\n");
 }
 
 static void
@@ -535,7 +535,7 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file, "\\psellipse(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file, "\\psellipse(%f,%f)(%f,%f)\n",
 	    (double) center->x, (double) center->y,
 	    (double) width/2.0, (double) height/2.0 );
 }
@@ -550,7 +550,7 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file, "\\psellipse*(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file, "\\psellipse*(%f,%f)(%f,%f)\n",
 	    (double) center->x, (double) center->y,
 	    (double) width/2.0, (double) height/2.0 );
 }
@@ -568,12 +568,12 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file, "\\pscustom{\n");
+    diaFprintf(renderer->file, "\\pscustom{\n");
 
     if (points[0].type != BEZ_MOVE_TO)
 	g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-    fprintf(renderer->file, "\\newpath\n\\moveto(%f,%f)\n",
+    diaFprintf(renderer->file, "\\newpath\n\\moveto(%f,%f)\n",
 	    (double) points[0].p1.x, (double) points[0].p1.y);
   
     for (i = 1; i < numpoints; i++)
@@ -582,18 +582,18 @@
 	    g_warning("only first BezPoint can be a BEZ_MOVE_TO");
 	    break;
 	case BEZ_LINE_TO:
-	    fprintf(renderer->file, "\\lineto(%f,%f)\n",
+	    diaFprintf(renderer->file, "\\lineto(%f,%f)\n",
 		    (double) points[i].p1.x, (double) points[i].p1.y);
 	    break;
 	case BEZ_CURVE_TO:
-	    fprintf(renderer->file, "\\curveto(%f,%f)(%f,%f)(%f,%f)\n",
+	    diaFprintf(renderer->file, "\\curveto(%f,%f)(%f,%f)(%f,%f)\n",
 		    (double) points[i].p1.x, (double) points[i].p1.y,
 		    (double) points[i].p2.x, (double) points[i].p2.y,
 		    (double) points[i].p3.x, (double) points[i].p3.y );
 	    break;
 	}
 
-    fprintf(renderer->file, "\\stroke}\n");
+    diaFprintf(renderer->file, "\\stroke}\n");
 }
 
 
@@ -609,12 +609,12 @@
 
     set_fill_color(renderer,color);
 
-    fprintf(renderer->file, "\\pscustom{\n");
+    diaFprintf(renderer->file, "\\pscustom{\n");
 
     if (points[0].type != BEZ_MOVE_TO)
 	g_warning("first BezPoint must be a BEZ_MOVE_TO");
 
-    fprintf(renderer->file, "\\newpath\n\\moveto(%f,%f)\n",
+    diaFprintf(renderer->file, "\\newpath\n\\moveto(%f,%f)\n",
 	    (double) points[0].p1.x, (double) points[0].p1.y);
   
     for (i = 1; i < numpoints; i++)
@@ -623,18 +623,18 @@
 	    g_warning("only first BezPoint can be a BEZ_MOVE_TO");
 	    break;
 	case BEZ_LINE_TO:
-	    fprintf(renderer->file, "\\lineto(%f,%f)\n",
+	    diaFprintf(renderer->file, "\\lineto(%f,%f)\n",
 		    (double) points[i].p1.x, (double) points[i].p1.y);
 	    break;
 	case BEZ_CURVE_TO:
-	    fprintf(renderer->file, "\\curveto(%f,%f)(%f,%f)(%f,%f)\n",
+	    diaFprintf(renderer->file, "\\curveto(%f,%f)(%f,%f)(%f,%f)\n",
 		    (double) points[i].p1.x, (double) points[i].p1.y,
 		    (double) points[i].p2.x, (double) points[i].p2.y,
 		    (double) points[i].p3.x, (double) points[i].p3.y );
 	    break;
 	}
 
-    fprintf(renderer->file, "\\fill[fillstyle=solid,fillcolor=diafillcolor,linecolor=diafillcolor]}\n");
+    diaFprintf(renderer->file, "\\fill[fillstyle=solid,fillcolor=diafillcolor,linecolor=diafillcolor]}\n");
 }
 
 /* Do I really want to do this?  What if the text is intended as 
@@ -689,18 +689,18 @@
 
     set_line_color(renderer,color);
 
-    fprintf(renderer->file,"\\rput");
+    diaFprintf(renderer->file,"\\rput");
     switch (alignment) {
     case ALIGN_LEFT:
-	fprintf(renderer->file,"[l]");
+	diaFprintf(renderer->file,"[l]");
 	break;
     case ALIGN_CENTER:
 	break;
     case ALIGN_RIGHT:
-	fprintf(renderer->file,"[r]");
+	diaFprintf(renderer->file,"[r]");
 	break;
     }
-    fprintf(renderer->file,"(%f,%f){\\scalebox{1 -1}{%s}}\n",pos->x, pos->y, text);
+    diaFprintf(renderer->file,"(%f,%f){\\scalebox{1 -1}{%s}}\n",pos->x, pos->y, text);
     /*    g_free(escaped);*/
 }
 
@@ -725,42 +725,42 @@
   
     ratio = height/width;
 
-    fprintf(renderer->file, "\\pscustom{\\code{gsave\n");
+    diaFprintf(renderer->file, "\\pscustom{\\code{gsave\n");
     if (1) { /* Color output */
-	fprintf(renderer->file, "/pix %i string def\n", img_width * 3);
-	fprintf(renderer->file, "/grays %i string def\n", img_width);
-	fprintf(renderer->file, "/npixls 0 def\n");
-	fprintf(renderer->file, "/rgbindx 0 def\n");
-	fprintf(renderer->file, "%f %f scale\n", POINTS_in_INCH, POINTS_in_INCH);
-	fprintf(renderer->file, "%f %f translate\n", point->x, point->y);
-	fprintf(renderer->file, "%f %f scale\n", width, height);
-	fprintf(renderer->file, "%i %i 8\n", img_width, img_height);
-	fprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
-	fprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
-	fprintf(renderer->file, "false 3 colorimage\n");
-	/*    fprintf(renderer->file, "\n"); */
+	diaFprintf(renderer->file, "/pix %i string def\n", img_width * 3);
+	diaFprintf(renderer->file, "/grays %i string def\n", img_width);
+	diaFprintf(renderer->file, "/npixls 0 def\n");
+	diaFprintf(renderer->file, "/rgbindx 0 def\n");
+	diaFprintf(renderer->file, "%f %f scale\n", POINTS_in_INCH, POINTS_in_INCH);
+	diaFprintf(renderer->file, "%f %f translate\n", point->x, point->y);
+	diaFprintf(renderer->file, "%f %f scale\n", width, height);
+	diaFprintf(renderer->file, "%i %i 8\n", img_width, img_height);
+	diaFprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
+	diaFprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
+	diaFprintf(renderer->file, "false 3 colorimage\n");
+	/*    diaFprintf(renderer->file, "\n"); */
 	ptr = rgb_data;
 	for (y = 0; y < img_width; y++) {
 	    for (x = 0; x < img_height; x++) {
-		fprintf(renderer->file, "%02x", (int)(*ptr++));
-		fprintf(renderer->file, "%02x", (int)(*ptr++));
-		fprintf(renderer->file, "%02x", (int)(*ptr++));
+		diaFprintf(renderer->file, "%02x", (int)(*ptr++));
+		diaFprintf(renderer->file, "%02x", (int)(*ptr++));
+		diaFprintf(renderer->file, "%02x", (int)(*ptr++));
 	    }
-	    fprintf(renderer->file, "\n");
+	    diaFprintf(renderer->file, "\n");
 	}
     } else { /* Grayscale */
-	fprintf(renderer->file, "/pix %i string def\n", img_width);
-	fprintf(renderer->file, "/grays %i string def\n", img_width);
-	fprintf(renderer->file, "/npixls 0 def\n");
-	fprintf(renderer->file, "/rgbindx 0 def\n");
-	fprintf(renderer->file, "%f %f scale\n", POINTS_in_INCH, POINTS_in_INCH);
-	fprintf(renderer->file, "%f %f translate\n", point->x, point->y);
-	fprintf(renderer->file, "%f %f scale\n", width, height);
-	fprintf(renderer->file, "%i %i 8\n", img_width, img_height);
-	fprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
-	fprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
-	fprintf(renderer->file, "image\n");
-	fprintf(renderer->file, "\n");
+	diaFprintf(renderer->file, "/pix %i string def\n", img_width);
+	diaFprintf(renderer->file, "/grays %i string def\n", img_width);
+	diaFprintf(renderer->file, "/npixls 0 def\n");
+	diaFprintf(renderer->file, "/rgbindx 0 def\n");
+	diaFprintf(renderer->file, "%f %f scale\n", POINTS_in_INCH, POINTS_in_INCH);
+	diaFprintf(renderer->file, "%f %f translate\n", point->x, point->y);
+	diaFprintf(renderer->file, "%f %f scale\n", width, height);
+	diaFprintf(renderer->file, "%i %i 8\n", img_width, img_height);
+	diaFprintf(renderer->file, "[%i 0 0 %i 0 0]\n", img_width, img_height);
+	diaFprintf(renderer->file, "{currentfile pix readhexstring pop}\n");
+	diaFprintf(renderer->file, "image\n");
+	diaFprintf(renderer->file, "\n");
 	ptr = rgb_data;
 	for (y = 0; y < img_height; y++) {
 	    for (x = 0; x < img_width; x++) {
@@ -768,14 +768,14 @@
 		v += (int)(*ptr++);
 		v += (int)(*ptr++);
 		v /= 3;
-		fprintf(renderer->file, "%02x", v);
+		diaFprintf(renderer->file, "%02x", v);
 	    }
-	    fprintf(renderer->file, "\n");
+	    diaFprintf(renderer->file, "\n");
 	}
     }
-    /*  fprintf(renderer->file, "%f %f scale\n", 1.0, 1.0/ratio);*/
-    fprintf(renderer->file, "grestore\n");
-    fprintf(renderer->file, "}}\n");
+    /*  diaFprintf(renderer->file, "%f %f scale\n", 1.0, 1.0/ratio);*/
+    diaFprintf(renderer->file, "grestore\n");
+    diaFprintf(renderer->file, "}}\n");
 
     g_free (rgb_data);
 }
@@ -794,7 +794,7 @@
 
     Color initial_color;
  
-    file = fopen(filename, "wb");
+    file = diaOpen(filename, "wb");
 
     if (file==NULL) {
 	message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -816,7 +816,7 @@
   
     name = g_get_user_name();
   
-    fprintf(file,
+    diaFprintf(file,
 	"%% PSTricks TeX macro\n"
 	"%% Title: %s\n"
 	"%% Creator: Dia v%s\n"
@@ -841,13 +841,13 @@
 	ctime(&time_now),
 	name);
 
-    fprintf(renderer->file,"\\pspicture(%f,%f)(%f,%f)\n",
+    diaFprintf(renderer->file,"\\pspicture(%f,%f)(%f,%f)\n",
 	    extent->left * data->paper.scaling,
 	    -extent->bottom * data->paper.scaling,
 	    extent->right * data->paper.scaling,
 	    -extent->top * data->paper.scaling
 	    );
-    fprintf(renderer->file,"\\scalebox{%f %f}{\n",
+    diaFprintf(renderer->file,"\\scalebox{%f %f}{\n",
 	    data->paper.scaling,
 	    -data->paper.scaling);
 
diff -u --recursive dia-vanilla/plug-ins/wpg/wpg.c dia/plug-ins/wpg/wpg.c
--- dia-vanilla/plug-ins/wpg/wpg.c	2003-05-01 16:29:46.000000000 -0500
+++ dia/plug-ins/wpg/wpg.c	2003-11-30 20:41:33.000000000 -0600
@@ -116,10 +116,10 @@
 
 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
 /* shortcut if testing of indirection isn't needed anymore */
-#define fwrite_le(a,b,c,d) fwrite(a,b,c,d)
+#define diaFwrite_le(a,b,c,d) diaFwrite(a,b,c,d)
 #else
 static size_t
-fwrite_le(void* buf, size_t size, size_t count, FILE* f)
+diaFwrite_le(void* buf, size_t size, size_t count, FILE* f)
 {
   size_t n = 0;
   guint i;
@@ -205,7 +205,7 @@
     rh.Dummy = 0xFF;
     rh.Size  = (guint16)Size;
     fwrite(&rh, sizeof(guint8), 2, renderer->file);
-    fwrite_le(&(rh.Size), sizeof(guint16), 1, renderer->file);
+    diaFwrite_le(&(rh.Size), sizeof(guint16), 1, renderer->file);
   }
   else
   {
@@ -218,7 +218,7 @@
      * is written in parts ...
      */
     fwrite(&rh, sizeof(guint8), 2, renderer->file);
-    fwrite_le(&rh.Size, sizeof(guint32), 1, renderer->file);
+    diaFwrite_le(&rh.Size, sizeof(guint32), 1, renderer->file);
   }
 }
 
@@ -230,7 +230,7 @@
   WriteRecHead(renderer, WPG_LINEATTR, sizeof(WPGLineAttr));
   renderer->LineAttr.Color = LookupColor(renderer, colour);
   fwrite(&renderer->LineAttr, sizeof(guint8), 2, renderer->file);
-  fwrite_le(&renderer->LineAttr.Width, sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&renderer->LineAttr.Width, sizeof(guint16), 1, renderer->file);
 }
 
 static void
@@ -286,7 +286,7 @@
 #else
   g_assert(6 == sizeof(WPGStartData));
   fwrite(&renderer->Box, sizeof(guint8), 2, renderer->file);
-  fwrite_le(&renderer->Box.Width, sizeof(guint16), 2, renderer->file);
+  diaFwrite_le(&renderer->Box.Width, sizeof(guint16), 2, renderer->file);
 #endif
   /* initialize a well known colormap, see LookupColor */
   pPal = g_new(gint8, CC_LEN*CC_LEN*CC_LEN*3);
@@ -302,9 +302,9 @@
 
   WriteRecHead(renderer, WPG_COLORMAP, CC_LEN*CC_LEN*CC_LEN*3 + 2*sizeof(guint16));
   i = WPG_NUM_DEF_COLORS; /* start color */
-  fwrite_le(&i, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(&i, sizeof(gint16), 1, renderer->file);
   i = CC_LEN*CC_LEN*CC_LEN;
-  fwrite_le(&i, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(&i, sizeof(gint16), 1, renderer->file);
   fwrite(pPal, 1, CC_LEN*CC_LEN*CC_LEN*3, renderer->file);
 
   /* FIXME: following 3 lines needed to make filling work !? */
@@ -323,7 +323,7 @@
   DIAG_NOTE(g_message( "end_render"));
 
   WriteRecHead(renderer, WPG_END, 0); /* no data following */
-  fclose(renderer->file);
+  diaClose(renderer->file);
 }
 
 static void
@@ -481,7 +481,7 @@
   pData[2] = SCX(end->x);
   pData[3] = SCY(-end->y);
 
-  fwrite_le(pData, sizeof(gint16), 4, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 4, renderer->file);
 }
 
 static void
@@ -505,7 +505,7 @@
 
   /* number of points */
   pData[0] = num_points;
-  fwrite_le(pData, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 1, renderer->file);
 
   /* point data */
   for (i = 0; i < num_points; i++)
@@ -514,7 +514,7 @@
     pData[2*i+1] = SCY(-points[i].y);
   }
 
-  fwrite_le(pData, sizeof(gint16), num_points*2, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), num_points*2, renderer->file);
 
   g_free(pData);
 }
@@ -538,7 +538,7 @@
 
   /* number of vertices */
   pData[0] = num_points;
-  fwrite_le(pData, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 1, renderer->file);
 
   /* point data */
   for (i = 0; i < num_points; i++)
@@ -547,7 +547,7 @@
     pData[2*i+1] = SCY(-points[i].y);
   }
 
-  fwrite_le(pData, sizeof(gint16), num_points*2, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), num_points*2, renderer->file);
 
   g_free(pData);
 }
@@ -586,7 +586,7 @@
   pData[2] = SC(lr_corner->x - ul_corner->x); /* width */
   pData[3] = SC(lr_corner->y - ul_corner->y); /* height */
 
-  fwrite_le(pData, sizeof(gint16), 4, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 4, renderer->file);
 
   g_free(pData);
 }
@@ -633,7 +633,7 @@
   WriteRecHead(renderer, WPG_ELLIPSE, sizeof(WPGEllipse));
 
   g_assert(16 == sizeof(WPGEllipse));
-  fwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
+  diaFwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
 }
 
 static void
@@ -664,7 +664,7 @@
   WriteRecHead(renderer, WPG_ELLIPSE, sizeof(WPGEllipse));
 
   g_assert(16 == sizeof(WPGEllipse));
-  fwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
+  diaFwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
   WriteFillAttr(renderer, colour, FALSE);
 }
 
@@ -694,7 +694,7 @@
   WriteRecHead(renderer, WPG_ELLIPSE, sizeof(WPGEllipse));
 
   g_assert(16 == sizeof(WPGEllipse));
-  fwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
+  diaFwrite_le(&ell, sizeof(guint16), sizeof(WPGEllipse) / sizeof(guint16), renderer->file);
 }
 
 static void
@@ -739,10 +739,10 @@
   pData[0] = SCX(points[0].p1.x);
   pData[1] = SCY(-points[0].p1.y);
 #endif
-  fwrite_le(pData, sizeof(gint16), 2, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 2, renderer->file);
 
   pData[0] = numpoints * 2;
-  fwrite_le(pData, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), 1, renderer->file);
 
   /* WPG's Poly Curve is not quite the same as DIA's Bezier.
    * There is only one Control Point per Point and I can't 
@@ -791,7 +791,7 @@
     }
   }
 
-  fwrite_le(pData, sizeof(gint16), numpoints*4, renderer->file);
+  diaFwrite_le(pData, sizeof(gint16), numpoints*4, renderer->file);
   g_free(pData);
 }
 
@@ -837,23 +837,23 @@
   fwrite(&renderer->TextStyle, sizeof(WPGTextStyle), 1, renderer->file);
 #else
   g_assert(22 == sizeof(WPGTextStyle));
-  fwrite_le(&renderer->TextStyle.Width, sizeof(guint16), 1, renderer->file);
-  fwrite_le(&renderer->TextStyle.Height, sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&renderer->TextStyle.Width, sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&renderer->TextStyle.Height, sizeof(guint16), 1, renderer->file);
   fwrite(&renderer->TextStyle.Reserved, 1, sizeof(renderer->TextStyle.Reserved), renderer->file);
-  fwrite_le(&renderer->TextStyle.Font, sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&renderer->TextStyle.Font, sizeof(guint16), 1, renderer->file);
   fwrite(&renderer->TextStyle.Reserved2, sizeof(guint8), 1, renderer->file);
   fwrite(&renderer->TextStyle.XAlign, 1, 1, renderer->file);
   fwrite(&renderer->TextStyle.YAlign, 1, 1, renderer->file);
   fwrite(&renderer->TextStyle.Color, 1, 1, renderer->file);
-  fwrite_le(&renderer->TextStyle.Angle, sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&renderer->TextStyle.Angle, sizeof(guint16), 1, renderer->file);
 #endif
   pt.x = SCX(pos->x);
   pt.y = SCY(-pos->y);
 
   WriteRecHead(renderer, WPG_TEXT, 3*sizeof(gint16) + len);
-  fwrite_le(&len, sizeof(gint16), 1, renderer->file);
-  fwrite_le(&pt.x,  sizeof(guint16), 1, renderer->file);
-  fwrite_le(&pt.y,  sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&len, sizeof(gint16), 1, renderer->file);
+  diaFwrite_le(&pt.x,  sizeof(guint16), 1, renderer->file);
+  diaFwrite_le(&pt.y,  sizeof(guint16), 1, renderer->file);
   fwrite(text, 1, len, renderer->file);
 }
 
@@ -946,14 +946,14 @@
   {
     FILE* f;
     int i, j;
-    f = fopen("c:\\temp\\wpg_bmp.raw", "wb");
+    f = diaOpen("c:\\temp\\wpg_bmp.raw", "wb");
     j = p - pOut;
     for (i = 0; i < j; i+=2)
     {
       for (x = 0; x < (pOut[i] & 0x7F); x++) 
         fwrite(&pOut[i+1], 1, 1, f);
     }
-    fclose(f);
+    diaClose(f);
   }
 #endif
   g_free(pDiaImg);
@@ -1059,7 +1059,7 @@
   Rectangle *extent;
   real width, height;
 
-  file = fopen(filename, "wb"); /* "wb" for binary! */
+  file = diaOpen(filename, "wb"); /* "wb" for binary! */
 
   if (file == NULL) {
     message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -1163,7 +1163,7 @@
   gboolean bRet;
   WPGHead8 rh;
 
-  f = fopen(filename, "rb");
+  f = diaOpen(filename, "rb");
 
   if (NULL == f) {
     message_error(_("Couldn't open: '%s' for reading.\n"), filename);
@@ -1300,7 +1300,7 @@
     g_object_unref (ren);
   } /* bRet */
 
-  if (f) fclose(f);
+  if (f) diaClose(f);
   return bRet;
 }
 
diff -u --recursive dia-vanilla/plug-ins/xfig/xfig-export.c dia/plug-ins/xfig/xfig-export.c
--- dia-vanilla/plug-ins/xfig/xfig-export.c	2003-07-31 06:22:08.000000000 -0500
+++ dia/plug-ins/xfig/xfig-export.c	2003-11-30 20:33:08.000000000 -0600
@@ -307,7 +307,7 @@
     return;
   }
   renderer->user_colors[renderer->max_user_color] = *color;
-  fprintf(renderer->file, "0 %d #%02x%02x%02x\n", 
+  diaFprintf(renderer->file, "0 %d #%02x%02x%02x\n", 
           renderer->max_user_color + FIG_MAX_DEFAULT_COLORS,
           (int)(color->red*255), (int)(color->green*255), (int)(color->blue*255));
   renderer->max_user_color++;
@@ -446,7 +446,7 @@
   case ARROW_BLANKED_CONCAVE:
     type = 2; style = 0; break;
   }
-  fprintf(renderer->file, "  %d %d %f %f %f\n",
+  diaFprintf(renderer->file, "  %d %d %f %f %f\n",
 	  type, style, figAltCoord(renderer, line_width), 
 	  figCoord(renderer, arrow->width),
 	  figCoord(renderer, arrow->length));	  
@@ -550,12 +550,12 @@
     return;
   }
 
-  fprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 2\n",
+  diaFprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 2\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
 	  figCapsStyle(renderer));
-  fprintf(renderer->file, "\t%d %d %d %d\n",
+  diaFprintf(renderer->file, "\t%d %d %d %d\n",
 	  (int)figCoord(renderer, start->x), (int)figCoord(renderer, start->y), 
 	  (int)figCoord(renderer, end->x), (int)figCoord(renderer, end->y));
 }
@@ -575,7 +575,7 @@
     return;
   }
 
-  fprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 %d %d 2\n",
+  diaFprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 %d %d 2\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
@@ -588,7 +588,7 @@
   if (start_arrow != NULL) {
     figArrow(renderer, start_arrow, line_width);
   }
-  fprintf(renderer->file, "\t%d %d %d %d\n",
+  diaFprintf(renderer->file, "\t%d %d %d %d\n",
 	  (int)figCoord(renderer, start->x), (int)figCoord(renderer, start->y), 
 	  (int)figCoord(renderer, end->x), (int)figCoord(renderer, end->y));
 }
@@ -606,17 +606,17 @@
     return;
   }
 
-  fprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 %d\n",
+  diaFprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer),
 	  figCapsStyle(renderer), num_points);
-  fprintf(renderer->file, "\t");
+  diaFprintf(renderer->file, "\t");
   for (i = 0; i < num_points; i++) {
-    fprintf(renderer->file, "%d %d ",
+    diaFprintf(renderer->file, "%d %d ",
 	    (int)figCoord(renderer, points[i].x), (int)figCoord(renderer, points[i].y));
   }
-  fprintf(renderer->file, "\n");
+  diaFprintf(renderer->file, "\n");
 }
 
 static void 
@@ -635,7 +635,7 @@
     return;
   }
 
-  fprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 %d %d %d\n",
+  diaFprintf(renderer->file, "2 1 %d %d %d 0 %d 0 -1 %f %d %d 0 %d %d %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer),
@@ -648,12 +648,12 @@
   if (start_arrow != NULL) {
     figArrow(renderer, start_arrow, line_width);
   }
-  fprintf(renderer->file, "\t");
+  diaFprintf(renderer->file, "\t");
   for (i = 0; i < num_points; i++) {
-    fprintf(renderer->file, "%d %d ",
+    diaFprintf(renderer->file, "%d %d ",
 	    (int)figCoord(renderer, points[i].x), (int)figCoord(renderer, points[i].y));
   }
-  fprintf(renderer->file, "\n");
+  diaFprintf(renderer->file, "\n");
 }
 
 static void 
@@ -669,17 +669,17 @@
     return;
   }
 
-  fprintf(renderer->file, "2 3 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 %d\n",
+  diaFprintf(renderer->file, "2 3 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer),
 	  figCapsStyle(renderer), num_points+1);
-  fprintf(renderer->file, "\t");
+  diaFprintf(renderer->file, "\t");
   for (i = 0; i < num_points; i++) {
-    fprintf(renderer->file, "%d %d ",
+    diaFprintf(renderer->file, "%d %d ",
 	    (int)figCoord(renderer, points[i].x), (int)figCoord(renderer, points[i].y));
   }
-  fprintf(renderer->file, "%d %d\n",
+  diaFprintf(renderer->file, "%d %d\n",
 	  (int)figCoord(renderer, points[0].x), (int)figCoord(renderer, points[0].y));
 }
 
@@ -696,18 +696,18 @@
     return;
   }
 
-  fprintf(renderer->file, "2 3 %d 0 %d %d %d 0 20 %f %d %d 0 0 0 %d\n",
+  diaFprintf(renderer->file, "2 3 %d 0 %d %d %d 0 20 %f %d %d 0 0 0 %d\n",
 	  figLineStyle(renderer), 
 	  figColor(renderer, color), figColor(renderer, color),
 	  figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer),
 	  figCapsStyle(renderer), num_points+1);
-  fprintf(renderer->file, "\t");
+  diaFprintf(renderer->file, "\t");
   for (i = 0; i < num_points; i++) {
-    fprintf(renderer->file, "%d %d ",
+    diaFprintf(renderer->file, "%d %d ",
 	    (int)figCoord(renderer, points[i].x), (int)figCoord(renderer, points[i].y));
   }
-  fprintf(renderer->file, "%d %d\n",
+  diaFprintf(renderer->file, "%d %d\n",
 	  (int)figCoord(renderer, points[0].x), (int)figCoord(renderer, points[0].y));
 }
 
@@ -723,12 +723,12 @@
     return;
   }
 
-  fprintf(renderer->file, "2 3 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 5\n",
+  diaFprintf(renderer->file, "2 3 %d %d %d 0 %d 0 -1 %f %d %d 0 0 0 5\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
 	  figCapsStyle(renderer));
-  fprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
 	  (int)figCoord(renderer, ul_corner->x), (int)figCoord(renderer, ul_corner->y), 
 	  (int)figCoord(renderer, lr_corner->x), (int)figCoord(renderer, ul_corner->y), 
 	  (int)figCoord(renderer, lr_corner->x), (int)figCoord(renderer, lr_corner->y), 
@@ -748,13 +748,13 @@
     return;
   }
 
-  fprintf(renderer->file, "2 3 %d %d %d %d %d -1 20 %f %d %d 0 0 0 5\n",
+  diaFprintf(renderer->file, "2 3 %d %d %d %d %d -1 20 %f %d %d 0 0 0 5\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figColor(renderer, color),
 	  figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
 	  figCapsStyle(renderer));
-  fprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
 	  (int)figCoord(renderer, ul_corner->x), (int)figCoord(renderer, ul_corner->y), 
 	  (int)figCoord(renderer, lr_corner->x), (int)figCoord(renderer, ul_corner->y), 
 	  (int)figCoord(renderer, lr_corner->x), (int)figCoord(renderer, lr_corner->y), 
@@ -789,7 +789,7 @@
   last.x += (width/2.0)*cos(angle2);
   last.y -= (height/2.0)*sin(angle2);
 
-  fprintf(renderer->file, "5 1 %d %d %d %d %d 0 -1 %f %d 1 0 0 %f %f %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "5 1 %d %d %d %d %d 0 -1 %f %d 1 0 0 %f %f %d %d %d %d %d %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figColor(renderer, color),
 	  figDepth(renderer),
@@ -846,7 +846,7 @@
   center.x = 0.0;
   center.y = 0.0;
 
-  fprintf(renderer->file, "5 1 %d %d %d %d %d 0 -1 %f %d 1 %d %d %f %f %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "5 1 %d %d %d %d %d 0 -1 %f %d 1 %d %d %f %f %d %d %d %d %d %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figColor(renderer, color),
 	  figDepth(renderer),
@@ -895,7 +895,7 @@
   last.x += (width/2.0)*cos(angle2);
   last.y -= (height/2.0)*sin(angle2);
 
-  fprintf(renderer->file, "5 1 %d %d %d %d %d 20 0 %f %d 1 0 0 %f %f %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "5 1 %d %d %d %d %d 20 0 %f %d 1 0 0 %f %f %d %d %d %d %d %d\n",
 	  figLineStyle(renderer), figLineWidth(renderer), 
 	  figColor(renderer, color), figColor(renderer, color),
 	  figDepth(renderer),
@@ -922,7 +922,7 @@
     return;
   }
 
-  fprintf(renderer->file, "1 1 %d %d %d -1 %d 0 -1 %f 1 0.0 %d %d %d %d 0 0 0 0\n",
+  diaFprintf(renderer->file, "1 1 %d %d %d -1 %d 0 -1 %f 1 0.0 %d %d %d %d 0 0 0 0\n",
 	  figLineStyle(renderer), 
 	  figLineWidth(renderer), 
 	  figColor(renderer, color),
@@ -946,7 +946,7 @@
     return;
   }
 
-  fprintf(renderer->file, "1 1 %d %d %d %d %d 0 20 %f 1 0.0 %d %d %d %d 0 0 0 0\n",
+  diaFprintf(renderer->file, "1 1 %d %d %d %d %d 0 20 %f 1 0.0 %d %d %d %d 0 0 0 0\n",
 	  figLineStyle(renderer), 
 	  figLineWidth(renderer), 
 	  figColor(renderer, color),
@@ -1023,7 +1023,7 @@
   }
 
   figtext = figText(renderer, text);
-  fprintf(renderer->file, "4 %d %d %d 0 %d %f 0.0 4 0.0 0.0 %d %d %s\\001\n",
+  diaFprintf(renderer->file, "4 %d %d %d 0 %d %f 0.0 4 0.0 0.0 %d %d %s\\001\n",
 	  figAlignment(renderer, alignment),
 	  figColor(renderer, color), 
 	  figDepth(renderer),
@@ -1046,12 +1046,12 @@
   if (renderer->color_pass)
     return;
 
-  fprintf(renderer->file, "2 5 %d 0 -1 0 %d 0 -1 %f %d %d 0 0 0 5\n",
+  diaFprintf(renderer->file, "2 5 %d 0 -1 0 %d 0 -1 %f %d %d 0 0 0 5\n",
 	  figLineStyle(renderer), figDepth(renderer),
 	  figDashLength(renderer), figJoinStyle(renderer), 
 	  figCapsStyle(renderer));
-  fprintf(renderer->file, "\t0 %s\n", dia_image_filename(image));
-  fprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
+  diaFprintf(renderer->file, "\t0 %s\n", dia_image_filename(image));
+  diaFprintf(renderer->file, "\t%d %d %d %d %d %d %d %d %d %d\n",
 	  (int)figCoord(renderer, point->x), (int)figCoord(renderer, point->y), 
 	  (int)figCoord(renderer, point->x+width), (int)figCoord(renderer, point->y), 
 	  (int)figCoord(renderer, point->x+width), (int)figCoord(renderer, point->y+height), 
@@ -1066,10 +1066,10 @@
   XfigRenderer *renderer = XFIG_RENDERER(self);
 
   if (!renderer->color_pass)
-    fprintf(renderer->file, "6 0 0 0 0\n");
+    diaFprintf(renderer->file, "6 0 0 0 0\n");
   object->ops->draw(object, DIA_RENDERER(renderer));
   if (!renderer->color_pass)
-    fprintf(renderer->file, "-6\n");
+    diaFprintf(renderer->file, "-6\n");
 }
 
 static void
@@ -1081,7 +1081,7 @@
   int i;
   Layer *layer;
 
-  file = fopen(filename, "w");
+  file = diaOpen(filename, "w");
 
   if (file == NULL) {
     message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -1092,15 +1092,15 @@
 
   renderer->file = file;
 
-  fprintf(file, "#FIG 3.2\n");
-  fprintf(file, (data->paper.is_portrait?"Portrait\n":"Landscape\n"));
-  fprintf(file, "Center\n");
-  fprintf(file, "Metric\n");
-  fprintf(file, "%s\n", data->paper.name);
-  fprintf(file, "%f\n", data->paper.scaling*100.0);
-  fprintf(file, "Single\n"); /* Could we do layers this way? */
-  fprintf(file, "-2\n");
-  fprintf(file, "1200 2\n");
+  diaFprintf(file, "#FIG 3.2\n");
+  diaFprintf(file, (data->paper.is_portrait?"Portrait\n":"Landscape\n"));
+  diaFprintf(file, "Center\n");
+  diaFprintf(file, "Metric\n");
+  diaFprintf(file, "%s\n", data->paper.name);
+  diaFprintf(file, "%f\n", data->paper.scaling*100.0);
+  diaFprintf(file, "Single\n"); /* Could we do layers this way? */
+  diaFprintf(file, "-2\n");
+  diaFprintf(file, "1200 2\n");
 
   renderer->color_pass = TRUE;
 
@@ -1128,7 +1128,7 @@
 
   g_object_unref(renderer);
 
-  fclose(file);
+  diaClose(file);
 }
 
 static const gchar *extensions[] = { "fig", NULL };
diff -u --recursive dia-vanilla/plug-ins/xslt/xslt.c dia/plug-ins/xslt/xslt.c
--- dia-vanilla/plug-ins/xslt/xslt.c	2003-07-20 13:35:53.000000000 -0500
+++ dia/plug-ins/xslt/xslt.c	2003-11-30 20:56:48.000000000 -0600
@@ -72,14 +72,14 @@
 
 	params[1] = g_strconcat("'", g_dirname(filename), G_DIR_SEPARATOR_S, "'", NULL);
 	
-	file = fopen(diafilename, "r");
+	file = diaOpen(diafilename, "r");
 
 	if (file == NULL) {
 	    message_error(_("Couldn't open: '%s' for reading.\n"), diafilename);
 	    return;
 	}
 
-	out = fopen(filename, "w+");
+	out = diaOpen(filename, "w+");
 	
 	if (out == NULL) {
 	  message_error(_("Can't open output file %s: %s\n"), filename, strerror(errno));
@@ -129,8 +129,8 @@
       /* printf("Saved to file (%i) using stylesheet: %s\n",
          err, stylefname); */
 		
-	fclose(out);
-	fclose(file);
+	diaClose(out);
+	diaClose(file);
 
 	xsltFreeStylesheet(codestyle);
 	xsltFreeStylesheet(style);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK