]> granicus.if.org Git - graphviz/commitdiff
add:
authorellson <devnull@localhost>
Wed, 19 Dec 2007 20:57:07 +0000 (20:57 +0000)
committerellson <devnull@localhost>
Wed, 19 Dec 2007 20:57:07 +0000 (20:57 +0000)
    void gvdevice_printnum(GVC_t *job, double num);
    void gvdevice_printpointf(GVC_t *job, pointf p);

lib/gvc/gvcproc.h
lib/gvc/gvdevice.c

index db048bf1495a7773438d831ba6cd4121bc59f488..a6ab07bf6cc1bb498fcc70f77725ec0503a8cf6a 100644 (file)
@@ -78,6 +78,8 @@ extern "C" {
     extern void gvdevice_finalize(GVJ_t * job);
 
     extern char * gvprintnum(int *len, double num);
+    extern void gvdevice_printnum(GVJ_t * job, double num);
+    extern void gvdevice_printpointf(GVJ_t * job, pointf p);
 
 /* render */
 
index 56858a6f5fb6598c90a4b52a18e2857d57fa2b11..4b141f69825a99f7dddec03b92c7c1bd8204e7f5 100644 (file)
 #include "gvcint.h"
 #include "gvcproc.h"
 
+size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len)
+{
+    if (job->gvc->write_fn && job->output_file == stdout)   /* externally provided write dicipline */
+       return (job->gvc->write_fn)((char*)s, len);
+    if (job->flags & GVDEVICE_COMPRESSED_FORMAT) {
+#ifdef HAVE_LIBZ
+       return gzwrite((gzFile *) (job->output_file), s, len);
+#endif
+    }
+    else if (job->output_data) {
+       if (len > (job->output_data_allocated - (job->output_data_position + 1))) {
+           job->output_data_allocated = job->output_data_position + len + 1000;
+           job->output_data = realloc(job->output_data, job->output_data_allocated);
+           if (!job->output_data) {
+               fprintf(stderr, "failure realloc'ing for result string\n");
+               return 0;
+           }
+       }
+       strcpy(job->output_data + job->output_data_position, (char*)s);
+        job->output_data_position += len;
+       return len;
+    }
+    else
+       return fwrite(s, sizeof(char), len, job->output_file);
+    return 0;
+}
+
 void gvdevice_fputs(GVJ_t * job, char *s)
 {
     gvdevice_write (job, (unsigned char*)s, strlen(s));
@@ -77,32 +104,26 @@ void gvdevice_printf(GVJ_t * job, const char *format, ...)
     gvdevice_write(job, buf, len);
 }
 
-size_t gvdevice_write (GVJ_t * job, const unsigned char *s, unsigned int len)
+void gvdevice_printnum(GVJ_t * job, double num)
 {
-    if (job->gvc->write_fn && job->output_file == stdout)   /* externally provided write dicipline */
-       return (job->gvc->write_fn)((char*)s, len);
-    if (job->flags & GVDEVICE_COMPRESSED_FORMAT) {
-#ifdef HAVE_LIBZ
-       return gzwrite((gzFile *) (job->output_file), s, len);
-#endif
-    }
-    else if (job->output_data) {
-       if (len > (job->output_data_allocated - (job->output_data_position + 1))) {
-           job->output_data_allocated = job->output_data_position + len + 1000;
-           job->output_data = realloc(job->output_data, job->output_data_allocated);
-           if (!job->output_data) {
-               fprintf(stderr, "failure realloc'ing for result string\n");
-               return 0;
-           }
-       }
-       strcpy(job->output_data + job->output_data_position, (char*)s);
-        job->output_data_position += len;
-       return len;
-    }
-    else
-       return fwrite(s, sizeof(char), len, job->output_file);
-    return 0;
-}
+    char *buf;
+    int len;
+
+    buf = gvprintnum(&len, num);
+    gvdevice_write(job, buf, len);
+} 
+
+void gvdevice_printpointf(GVJ_t * job, pointf p)
+{
+    char *buf;
+    int len;
+
+    buf = gvprintnum(&len, p.x);
+    gvdevice_write(job, buf, len);
+    gvdevice_write(job, " ", 1);
+    buf = gvprintnum(&len, p.y);
+    gvdevice_write(job, buf, len);
+} 
 
 static void auto_output_filename(GVJ_t *job)
 {