]> granicus.if.org Git - graphviz/commitdiff
remove unused lib/common files
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Mar 2021 16:50:29 +0000 (08:50 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Tue, 16 Mar 2021 04:49:50 +0000 (21:49 -0700)
lib/common/diagen.c [deleted file]
lib/common/mifgen.c [deleted file]
lib/common/mpgen.c [deleted file]
lib/common/picgen.c [deleted file]
lib/common/vtxgen.c [deleted file]

diff --git a/lib/common/diagen.c b/lib/common/diagen.c
deleted file mode 100644 (file)
index 3f5016a..0000000
+++ /dev/null
@@ -1,1010 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-#include "config.h"
-
-#include <common/render.h>
-
-#include <stdarg.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_LIBZ
-#include <zlib.h>
-#endif
-
-/* DIA font modifiers */
-#define REGULAR 0
-#define BOLD   1
-#define ITALIC 2
-
-/* DIA patterns */
-#define P_SOLID        0
-#define P_NONE  15
-#define P_DOTTED 4             /* i wasn't sure about this */
-#define P_DASHED 11            /* or this */
-
-/* DIA bold line constant */
-#define WIDTH_NORMAL 1
-#define WIDTH_BOLD 3
-
-#define DIA_RESOLUTION 1.0
-#define SCALE (DIA_RESOLUTION/15.0)
-
-#define                NODE            1
-#define                EDGE            2
-#define                CLST            3
-
-
-/* FIXME - these are not used currently - probably something missing */
-#if 0
-/* DIA dash array */
-static char *sdarray = "5,2";
-/* DIA dot array */
-static char *sdotarray = "1,5";
-static int GraphURL, ClusterURL, NodeURL, EdgeURL;
-static char *op[] = { "graph", "node", "edge", "graph" };
-#endif
-
-/* static      int             N_pages; */
-/* static      point   Pages; */
-static double Scale;
-static pointf Offset;
-static int Rot;
-static box PB;
-static int onetime = TRUE;
-
-static node_t *Curnode;
-static edge_t *Curedge;
-static graph_t *Curgraph, *Rootgraph;
-
-typedef struct context_t {
-    char *pencolor, *fillcolor, *fontfam, fontopt, font_was_set;
-    char pen, fill, penwidth, style_was_set;
-    double fontsz;
-} context_t;
-
-#define MAXNEST 4
-static context_t cstk[MAXNEST];
-static int SP;
-
-#ifdef HAVE_LIBZ
-static gzFile Zfile;
-#endif
-
-static int dia_fputs(char *s)
-{
-    int len;
-
-    len = strlen(s);
-
-#ifdef HAVE_LIBZ
-    return gzwrite(Zfile, s, (unsigned) len);
-#else
-    return 0;
-#endif
-}
-
-
-/* dia_printf:
- * Note that this function is unsafe due to the fixed buffer size.
- * It should only be used when the caller is sure the input will not
- * overflow the buffer. In particular, it should be avoided for
- * input coming from users.
- */
-static int dia_printf(const char *format, ...)
-{
-    char buf[BUFSIZ];
-    va_list argp;
-    int len;
-
-    va_start(argp, format);
-    (void) vsnprintf(buf, sizeof(buf), format, argp);
-    va_end(argp);
-    len = strlen(buf);
-
-    /* some *sprintf (e.g C99 std)
-       don't return the number of
-       bytes actually written */
-
-#ifdef HAVE_LIBZ
-    return gzwrite(Zfile, buf, (unsigned) len);
-#else
-    return 0;
-#endif
-}
-
-#define SVG_COLORS_P 0
-
-static int dia_comparestr(const void *s1, const void *s2)
-{
-        return strcmp(*(char **) s1, *(char **) s2);
-}
-
-static char *dia_resolve_color(char *name)
-{
-/* color names from http://www.w3.org/TR/SVG/types.html */
-/* NB.  List must be LANG_C sorted */
-    static char *svg_known_colors[] = {
-        "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure",
-        "beige", "bisque", "black", "blanchedalmond", "blue",
-        "blueviolet", "brown", "burlywood",
-        "cadetblue", "chartreuse", "chocolate", "coral",
-        "cornflowerblue", "cornsilk", "crimson", "cyan",
-        "darkblue", "darkcyan", "darkgoldenrod", "darkgray",
-        "darkgreen", "darkgrey", "darkkhaki", "darkmagenta",
-        "darkolivegreen", "darkorange", "darkorchid", "darkred",
-        "darksalmon", "darkseagreen", "darkslateblue", "darkslategray",
-        "darkslategrey", "darkturquoise", "darkviolet", "deeppink",
-        "deepskyblue", "dimgray", "dimgrey", "dodgerblue",
-        "firebrick", "floralwhite", "forestgreen", "fuchsia",
-        "gainsboro", "ghostwhite", "gold", "goldenrod", "gray",
-        "green", "greenyellow", "grey",
-        "honeydew", "hotpink", "indianred",
-        "indigo", "ivory", "khaki",
-        "lavender", "lavenderblush", "lawngreen", "lemonchiffon",
-        "lightblue", "lightcoral", "lightcyan", "lightgoldenrodyellow",
-        "lightgray", "lightgreen", "lightgrey", "lightpink",
-        "lightsalmon", "lightseagreen", "lightskyblue",
-        "lightslategray", "lightslategrey", "lightsteelblue",
-        "lightyellow", "lime", "limegreen", "linen",
-        "magenta", "maroon", "mediumaquamarine", "mediumblue",
-        "mediumorchid", "mediumpurple", "mediumseagreen",
-        "mediumslateblue", "mediumspringgreen", "mediumturquoise",
-        "mediumvioletred", "midnightblue", "mintcream",
-        "mistyrose", "moccasin",
-        "navajowhite", "navy", "oldlace",
-        "olive", "olivedrab", "orange", "orangered", "orchid",
-        "palegoldenrod", "palegreen", "paleturquoise",
-        "palevioletred", "papayawhip", "peachpuff", "peru", "pink",
-        "plum", "powderblue", "purple",
-        "red", "rosybrown", "royalblue",
-        "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell",
-        "sienna", "silver", "skyblue", "slateblue", "slategray",
-        "slategrey", "snow", "springgreen", "steelblue",
-        "tan", "teal", "thistle", "tomato", "turquoise",
-        "violet",
-        "wheat", "white", "whitesmoke",
-        "yellow", "yellowgreen",
-    };
-
-    static char buf[SMALLBUF];
-    char *tok;
-    gvcolor_t color;
-
-    tok = canontoken(name);
-    if (!SVG_COLORS_P || (bsearch(&tok, svg_known_colors,
-                              sizeof(svg_known_colors) / sizeof(char *),
-                              sizeof(char *), dia_comparestr) == NULL)) {
-        /* if tok was not found in known_colors */
-        if (streq(tok, "transparent")) {
-            tok = "none";
-        } else {
-            colorxlate(name, &color, RGBA_BYTE);
-            snprintf(buf, sizeof(buf), "#%02x%02x%02x",
-                     color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]);
-            tok = buf;
-        }
-    }
-    return tok;
-}
-
-
-static void dia_reset(void)
-{
-    onetime = TRUE;
-}
-
-
-static void init_dia(void)
-{
-    SP = 0;
-    cstk[0].pencolor = DEFAULT_COLOR;  /* DIA pencolor */
-    cstk[0].fillcolor = "";    /* DIA fillcolor */
-    cstk[0].fontfam = DEFAULT_FONTNAME;        /* font family name */
-    cstk[0].fontsz = DEFAULT_FONTSIZE; /* font size */
-    cstk[0].fontopt = REGULAR; /* modifier: REGULAR, BOLD or ITALIC */
-    cstk[0].pen = P_SOLID;     /* pen pattern style, default is solid */
-    cstk[0].fill = P_NONE;
-    cstk[0].penwidth = WIDTH_NORMAL;
-}
-
-static pointf diapt(point p)
-{
-    pointf rv;
-
-    if (Rot == 0) {
-       rv.x = PB.LL.x + p.x * Scale + Offset.x;
-       rv.y = PB.UR.y - 1 - p.y * Scale - Offset.y;
-    } else {
-       rv.x = PB.UR.x - 1 - p.y * Scale - Offset.x;
-       rv.y = PB.UR.y - 1 - p.x * Scale - Offset.y;
-    }
-    return rv;
-}
-
-static pointf diaptf(pointf p)
-{
-    pointf rv;
-
-    if (Rot == 0) {
-       rv.x = PB.LL.x + p.x * Scale + Offset.x;
-       rv.y = PB.UR.y - 1 - p.y * Scale - Offset.y;
-    } else {
-       rv.x = PB.UR.x - 1 - p.y * Scale - Offset.x;
-       rv.y = PB.UR.y - 1 - p.x * Scale - Offset.y;
-    }
-    return rv;
-}
-
-static void dia_grstyle(context_t * cp)
-{
-    if (strcmp(cp->pencolor, DEFAULT_COLOR)) {
-       dia_fputs("      <dia:attribute name=\"border_color\">\n");
-       dia_printf("        <dia:color val=\"%s\"/>\n",
-                  dia_resolve_color(cp->pencolor));
-       dia_fputs("      </dia:attribute>\n");
-    }
-    if (cp->penwidth != WIDTH_NORMAL) {
-       dia_fputs("      <dia:attribute name=\"line_width\">\n");
-       dia_printf("        <dia:real val=\"%g\"/>\n",
-                  Scale * (cp->penwidth));
-       dia_fputs("      </dia:attribute>\n");
-    }
-    if (cp->pen == P_DASHED) {
-       dia_fputs("      <dia:attribute name=\"line_style\">\n");
-       dia_printf("        <dia:real val=\"%d\"/>\n", 1);
-       dia_fputs("      </dia:attribute>\n");
-#if 0
-    } else if (cp->pen == P_DOTTED) {
-       dia_printf("stroke-dasharray:%s;", sdotarray);
-#endif
-    }
-}
-
-static void dia_grstylefill(context_t * cp, int filled)
-{
-    if (filled) {
-       dia_fputs("      <dia:attribute name=\"inner_color\">\n");
-       dia_printf("        <dia:color val=\"%s\"/>\n",
-                  dia_resolve_color(cp->fillcolor));
-       dia_fputs("      </dia:attribute>\n");
-    } else {
-       dia_fputs("      <dia:attribute name=\"show_background\">\n");
-       dia_printf("        <dia:boolean val=\"%s\"/>\n", "true");
-       dia_fputs("      </dia:attribute>\n");
-    }
-}
-
-static void dia_comment(char *str)
-{
-    dia_fputs("<!-- ");
-    dia_fputs(xml_string(str));
-    dia_fputs(" -->\n");
-}
-
-static void
-dia_begin_job(FILE * ofp, graph_t * g, const char **lib, char *info[], point pages)
-{
-#if HAVE_LIBZ
-    int fd;
-
-    fd = dup(fileno(Output_file));     /* open dup so can gzclose 
-                                          independent of FILE close */
-    Zfile = gzdopen(fd, "wb");
-    if (!Zfile) {
-       agerr(AGERR, "Error opening compressed output file\n");
-       exit(1);
-    }
-#else
-    agerr(AGERR,
-         "No support for compressed output. Not compiled with zlib.\n");
-    exit(1);
-#endif
-
-/*     Pages = pages; */
-/*     N_pages = pages.x * pages.y; */
-    dia_printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
-
-}
-
-static void dia_end_job(void)
-{
-}
-
-static void dia_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
-{
-    Rootgraph = g;
-    PB.LL.x = PB.LL.y = 0;
-    PB.UR.x = (bb.UR.x - bb.LL.x + 2 * GD_drawing(g)->margin.x) * SCALE;
-    PB.UR.y = (bb.UR.y - bb.LL.y + 2 * GD_drawing(g)->margin.y) * SCALE;
-    Offset.x = GD_drawing(g)->margin.x * SCALE;
-    Offset.y = GD_drawing(g)->margin.y * SCALE;
-    if (onetime) {
-       init_dia();
-       onetime = FALSE;
-    }
-    dia_fputs
-       ("<dia:diagram xmlns:dia=\"http://www.lysator.liu.se/~alla/dia/\">\n");
-    dia_fputs("  <dia:diagramdata>\n");
-    dia_fputs("    <dia:attribute name=\"background\">\n");
-    dia_fputs("      <dia:color val=\"#ffffff\"/>\n");
-    dia_fputs("    </dia:attribute>\n");
-    dia_fputs("    <dia:attribute name=\"paper\">\n");
-    dia_fputs("      <dia:composite type=\"paper\">\n");
-    dia_fputs("        <dia:attribute name=\"name\">\n");
-    dia_fputs("          <dia:string>#A4#</dia:string>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"tmargin\">\n");
-    dia_fputs("          <dia:real val=\"2.8222\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"bmargin\">\n");
-    dia_fputs("          <dia:real val=\"2.8222\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"lmargin\">\n");
-    dia_fputs("          <dia:real val=\"2.8222\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"rmargin\">\n");
-    dia_fputs("          <dia:real val=\"2.8222\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"is_portrait\">\n");
-    dia_fputs("          <dia:boolean val=\"true\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"scaling\">\n");
-    dia_fputs("          <dia:real val=\"1\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"fitto\">\n");
-    dia_fputs("          <dia:boolean val=\"false\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("      </dia:composite>\n");
-    dia_fputs("    </dia:attribute>\n");
-    dia_fputs("    <dia:attribute name=\"grid\">\n");
-    dia_fputs("      <dia:composite type=\"grid\">\n");
-    dia_fputs("        <dia:attribute name=\"width_x\">\n");
-    dia_fputs("          <dia:real val=\"1\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"width_y\">\n");
-    dia_fputs("          <dia:real val=\"1\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"visible_x\">\n");
-    dia_fputs("          <dia:int val=\"1\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("        <dia:attribute name=\"visible_y\">\n");
-    dia_fputs("          <dia:int val=\"1\"/>\n");
-    dia_fputs("        </dia:attribute>\n");
-    dia_fputs("      </dia:composite>\n");
-    dia_fputs("    </dia:attribute>\n");
-    dia_fputs("    <dia:attribute name=\"guides\">\n");
-    dia_fputs("      <dia:composite type=\"guides\">\n");
-    dia_fputs("        <dia:attribute name=\"hguides\"/>\n");
-    dia_fputs("        <dia:attribute name=\"vguides\"/>\n");
-    dia_fputs("      </dia:composite>\n");
-    dia_fputs("    </dia:attribute>\n");
-    dia_fputs("  </dia:diagramdata>\n");
-}
-
-static void dia_end_graph(void)
-{
-    dia_printf("</dia:diagram>\n");
-#ifdef HAVE_LIBZ
-    gzclose(Zfile);
-#endif
-}
-
-static void
-dia_begin_page(graph_t * g, point page, double scale, int rot,
-              point offset)
-{
-    /* int          page_number; */
-    /* point        sz; */
-
-    Scale = scale * SCALE;
-    Rot = rot;
-    /* page_number =  page.x + page.y * Pages.x + 1; */
-    /* sz = sub_points(PB.UR,PB.LL); */
-
-    dia_printf("  <dia:layer name=\"Background\" visible=\"true\">\n");
-}
-
-static void dia_end_page(void)
-{
-    dia_fputs("  </dia:layer>\n");
-}
-
-static void dia_begin_cluster(graph_t * g)
-{
-    dia_printf("<dia:group>\n");
-    Curgraph = g;
-}
-
-static void dia_end_cluster(void)
-{
-    dia_printf("</dia:group>\n");
-}
-
-static void dia_begin_node(node_t * n)
-{
-    dia_printf("<dia:group>\n");
-    Curnode = n;
-}
-
-static void dia_end_node(void)
-{
-    dia_printf("</dia:group>\n");
-}
-
-static void dia_begin_edge(edge_t * e)
-{
-    Curedge = e;
-}
-
-static void dia_end_edge(void)
-{
-    Curedge = NULL;
-}
-
-static void dia_begin_context(void)
-{
-    assert(SP + 1 < MAXNEST);
-    cstk[SP + 1] = cstk[SP];
-    SP++;
-}
-
-static void dia_end_context(void)
-{
-    int psp = SP - 1;
-    assert(SP > 0);
-    /*free(cstk[psp].fontfam); */
-    SP = psp;
-}
-
-static void dia_set_font(char *name, double size)
-{
-    char *p;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    cp->font_was_set = TRUE;
-    cp->fontsz = size;
-    p = strdup(name);
-    cp->fontfam = p;
-}
-
-static void dia_set_pencolor(char *name)
-{
-    cstk[SP].pencolor = name;
-}
-
-static void dia_set_fillcolor(char *name)
-{
-    cstk[SP].fillcolor = name;
-}
-
-static void dia_set_style(char **s)
-{
-    char *line, *p;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    while ((p = line = *s++)) {
-       if (streq(line, "solid"))
-           cp->pen = P_SOLID;
-       else if (streq(line, "dashed"))
-           cp->pen = P_DASHED;
-       else if (streq(line, "dotted"))
-           cp->pen = P_DOTTED;
-       else if (streq(line, "invis"))
-           cp->pen = P_NONE;
-       else if (streq(line, "bold"))
-           cp->penwidth = WIDTH_BOLD;
-       else if (streq(line, "setlinewidth")) {
-           while (*p)
-               p++;
-           p++;
-           cp->penwidth = atol(p);
-       } else if (streq(line, "filled"))
-           cp->fill = P_SOLID;
-       else if (streq(line, "unfilled"))
-           cp->fill = P_NONE;
-       else {
-           agerr(AGWARN,
-                 "dia_set_style: unsupported style %s - ignoring\n",
-                 line);
-       }
-       cp->style_was_set = TRUE;
-    }
-    /* if (cp->style_was_set) dia_style(cp); */
-}
-
-static void dia_textpara(point p, textpara_t * para)
-{
-    int anchor;
-    pointf mp;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    switch (para->just) {
-    case 'l':
-       anchor = 0;
-       break;
-    case 'r':
-       anchor = 2;
-       break;
-    default:
-    case 'n':
-       anchor = 1;
-       break;
-    }
-
-    mp = diapt(p);
-    dia_printf
-       ("    <dia:object type=\"Standard - Text\" version=\"0\" id=\"%s\">\n",
-        "0");
-    dia_fputs("      <dia:attribute name=\"text\">\n");
-    dia_fputs("        <dia:composite type=\"text\">\n");
-    dia_fputs("          <dia:attribute name=\"string\">\n");
-    dia_fputs("            <dia:string>#");
-    dia_fputs(xml_string(para->str));
-    dia_fputs("#</dia:string>\n");
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("          <dia:attribute name=\"font\">\n");
-    dia_printf("            <dia:font name=\"%s\"/>\n", cp->fontfam);
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("          <dia:attribute name=\"height\">\n");
-    dia_printf("            <dia:real val=\"%g\"/>\n",
-              Scale * (cp->fontsz));
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("          <dia:attribute name=\"pos\">\n");
-    dia_printf("            <dia:point val=\"%g,%g\"/>\n", mp.x, mp.y);
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("          <dia:attribute name=\"color\">\n");
-    dia_printf("            <dia:color val=\"%s\"/>\n",
-              dia_resolve_color(cp->pencolor));
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("          <dia:attribute name=\"alignment\">\n");
-    dia_printf("            <dia:enum val=\"%d\"/>\n", anchor);
-    dia_fputs("          </dia:attribute>\n");
-    dia_fputs("        </dia:composite>\n");
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_pos\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", mp.x, mp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_bb\">\n");
-    dia_printf("        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              mp.x - (Scale * (para->width) / 2.), mp.y - 0.4,
-              mp.x + (Scale * (para->width) / 2.), mp.y + 0.4);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("    </dia:object>\n");
-}
-
-static void dia_ellipse(point p, int rx, int ry, int filled)
-{
-    pointf cp, rp;
-    int nodeId;
-
-    switch (Obj) {
-    case NODE:
-       nodeId = AGID(Curnode);
-       break;
-    default:
-       nodeId = -1;
-       break;
-    }
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-    cp = diapt(p);
-
-    if (Rot) {
-       int t;
-       t = rx;
-       rx = ry;
-       ry = t;
-    }
-    rp.x = Scale * rx;
-    rp.y = Scale * ry;
-
-    dia_printf
-       ("    <dia:object type=\"Standard - Ellipse\" version=\"0\" id=\"%d\">\n",
-        nodeId);
-    dia_fputs("      <dia:attribute name=\"elem_corner\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", cp.x - rp.x,
-              cp.y - rp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"elem_width\">\n");
-    dia_printf("        <dia:real val=\"%g\"/>\n", rp.x + rp.x);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"elem_height\">\n");
-    dia_printf("        <dia:real val=\"%g\"/>\n", rp.y + rp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_pos\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", cp.x - rp.x,
-              cp.y - rp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_bb\">\n");
-    dia_printf("        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              cp.x - rp.x - .11, cp.y - rp.y - .11, cp.x + rp.x + .11,
-              cp.y + rp.y + .11);
-    dia_fputs("      </dia:attribute>\n");
-    dia_grstyle(&cstk[SP]);
-    dia_grstylefill(&cstk[SP], filled);
-    dia_fputs("    </dia:object>\n");
-}
-
-
-int ellipse_connection(pointf cp, pointf p)
-{
-    int conn = 0;
-
-    if (cp.x == p.x) {
-       if (cp.y > p.y)
-           conn = 1;
-       else
-           conn = 6;
-    } else if (cp.y == p.y) {
-       if (cp.x > p.x)
-           conn = 3;
-       else
-           conn = 4;
-    } else if (cp.x < p.x) {
-       if (cp.y < p.y)
-           conn = 7;
-       else
-           conn = 2;
-    } else if (cp.x > p.x) {
-       if (cp.y < p.y)
-           conn = 5;
-       else
-           conn = 0;
-    }
-
-    return conn;
-}
-
-
-int box_connection(node_t * n, pointf p)
-{
-    int i = 0, j, sides, conn = 0, peripheries, z;
-    double xsize, ysize, mindist2 = 0.0, dist2;
-    polygon_t *poly;
-    pointf P, *vertices;
-    static pointf *A;
-    static int A_size;
-
-    poly = (polygon_t *) ND_shape_info(n);
-    vertices = poly->vertices;
-    sides = poly->sides;
-    peripheries = poly->peripheries;
-
-    if (A_size < sides) {
-       A_size = sides + 5;
-       A = ALLOC(A_size, A, pointf);
-    }
-
-    xsize = (ND_lw(n) + ND_rw(n)) / POINTS(ND_width(n));
-    ysize = (ND_ht(n)) / POINTS(ND_height(n));
-
-    for (j = 0; j < peripheries; j++) {
-       for (i = 0; i < sides; i++) {
-           P = vertices[i + j * sides];
-           A[i].x = P.x * xsize;
-           A[i].y = P.y * ysize;
-           if (sides > 2) {
-               A[i].x += ND_coord(n).x;
-               A[i].y += ND_coord(n).y;
-           }
-       }
-    }
-
-    z = 0;
-    while (z < i) {
-       dist2 = DIST2(p, diaptf(A[z]));
-       if (z == 0) {
-           mindist2 = dist2;
-           conn = 0;
-       }
-       if (dist2 < mindist2) {
-           mindist2 = dist2;
-           conn = 2 * z;
-       }
-       z++;
-    }
-
-    z = 0;
-    while (z < i) {
-       P.x = (diaptf(A[z]).x + diaptf(A[z + 1]).x) / 2;
-       P.y = (diaptf(A[z]).y + diaptf(A[z + 1]).y) / 2;
-       dist2 = DIST2(p, P);
-       if (dist2 < mindist2) {
-           mindist2 = dist2;
-           conn = 2 * z + 1;
-       }
-       z++;
-    }
-
-    return conn;
-}
-
-
-static void
-dia_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled)
-{
-    int i, conn_h, conn_t;
-    pointf p, firstp = { 0, 0 }, llp = { 0, 0}, urp = { 0, 0};
-    node_t *head, *tail;
-    char *shape_t;
-    pointf cp_h, cp_t;
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-
-    dia_printf
-       ("    <dia:object type=\"Standard - BezierLine\" version=\"0\" id=\"%s\">\n",
-        "00");
-    dia_fputs("       <dia:attribute name=\"bez_points\">\n");
-    for (i = 0; i < n; i++) {
-       p = diapt(A[i]);
-       if (!i)
-           llp = urp = firstp = p;
-       if (p.x < llp.x || p.y < llp.y)
-           llp = p;
-       if (p.x > urp.x || p.y > urp.y)
-           urp = p;
-       dia_printf("        <dia:point val=\"%g,%g\"/>\n", p.x, p.y);
-    }
-    dia_fputs("      </dia:attribute>\n");
-    dia_grstyle(&cstk[SP]);
-    dia_fputs("      <dia:attribute name=\"obj_pos\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", firstp.x, firstp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_bb\">\n");
-    dia_printf("        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              llp.x - .11, llp.y - .11, urp.x + .11, urp.y + .11);
-    dia_fputs("      </dia:attribute>\n");
-
-    if (Curedge) {
-        conn_h = conn_t = -1;
-
-        head = aghead(Curedge);
-        tail = agtail(Curedge);
-
-        shape_t = ND_shape(tail)->name;
-
-        /* arrowheads */
-        if (arrow_at_start) {
-           dia_fputs("      <dia:attribute name=\"start_arrow\">\n");
-           dia_fputs("          <dia:enum val=\"3\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-           dia_fputs("      <dia:attribute name=\"start_arrow_length\">\n");
-           dia_fputs("         <dia:real val=\"0.8\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-           dia_fputs
-               ("               <dia:attribute name=\"start_arrow_width\">\n");
-           dia_fputs("                 <dia:real val=\"0.8\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-        }
-        if (arrow_at_end) {
-           dia_fputs("      <dia:attribute name=\"end_arrow\">\n");
-           dia_fputs("          <dia:enum val=\"3\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-           dia_fputs("      <dia:attribute name=\"end_arrow_length\">\n");
-           dia_fputs("         <dia:real val=\"0.8\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-           dia_fputs
-               ("               <dia:attribute name=\"end_arrow_width\">\n");
-           dia_fputs("                 <dia:real val=\"0.8\"/>\n");
-           dia_fputs("      </dia:attribute>\n");
-        }
-    
-        dia_fputs("      <dia:attribute name=\"conn_endpoints\">\n");
-        dia_printf("        <dia:point val=\"%g,%g\"/>\n",
-               diapt(A[0]).x, diapt(A[0]).y);
-        dia_printf("        <dia:point val=\"%g,%g\"/>\n",
-               diapt(A[n - 1]).x, diapt(A[n - 1]).y);
-        dia_fputs("      </dia:attribute>\n");
-        dia_fputs("      <dia:connections>\n");
-    
-/* FIXME !!! - What is this crap!   It should just user the arrow vector. */
-        if ((strcmp(shape_t, "ellipse") == 0)
-           || (strcmp(shape_t, "circle") == 0)
-           || (strcmp(shape_t, "doublecircle") == 0)) {
-           cp_h = diaptf(ND_coord(head));
-           if (agisdirected(Rootgraph))
-
-               conn_h = ellipse_connection(cp_h, diapt(A[n - 1]));
-           else
-               conn_h = ellipse_connection(cp_h, diapt(A[0]));
-        } else if (strcmp(shape_t, "record") == 0) { 
-        } else {
-           if (agisdirected(Rootgraph))
-               conn_h = box_connection(head, diapt(A[n - 1]));
-           else
-               conn_h = box_connection(head, diapt(A[0]));
-        }
-    
-        if ((strcmp(shape_t, "ellipse") == 0)
-           || (strcmp(shape_t, "circle") == 0)
-           || (strcmp(shape_t, "doublecircle") == 0)) {
-           cp_t = diaptf(ND_coord(tail));
-           if (agisdirected(Rootgraph))
-               conn_t = ellipse_connection(cp_t, diapt(A[0]));
-           else
-               conn_t = ellipse_connection(cp_t, diapt(A[n - 1]));
-        } else if (strcmp(shape_t, "record") == 0) {
-        } else {
-           if (agisdirected(Rootgraph))
-               conn_t = box_connection(tail, diapt(A[0]));
-           else
-               conn_t = box_connection(tail, diapt(A[n - 1]));
-        }
-
-        if (arrow_at_start) {
-           dia_printf
-               ("        <dia:connection handle=\"0\" to=\"%d\" connection=\"%d\"/>\n",
-                AGID(head), conn_h);
-           dia_printf
-               ("        <dia:connection handle=\"%d\" to=\"%d\" connection=\"%d\"/>\n",
-                (n - 1), AGID(tail), conn_t);
-        } else {
-           dia_printf
-               ("        <dia:connection handle=\"0\" to=\"%d\" connection=\"%d\"/>\n",
-                AGID(tail), conn_t);
-           dia_printf
-               ("        <dia:connection handle=\"%d\" to=\"%d\" connection=\"%d\"/>\n",
-                (n - 1), AGID(head), conn_h);
-        }
-    
-        dia_fputs("      </dia:connections>\n");
-    }
-    dia_fputs("    </dia:object>\n");
-}
-
-
-
-static void dia_polygon(point * A, int n, int filled)
-{
-    int i;
-    pointf p, firstp = { 0, 0 }, llp = {
-    0, 0}, urp = {
-    0, 0};
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-
-    switch (Obj) {
-    case NODE:
-       dia_printf
-           ("    <dia:object type=\"Standard - Polygon\" version=\"0\" id=\"%d\">\n",
-            AGID(Curnode));
-       break;
-    case EDGE:
-       return;
-       break;
-    case CLST:
-       dia_printf
-           ("    <dia:object type=\"Standard - Polygon\" version=\"0\" id=\"%s\">\n",
-            agnameof(Curgraph));
-       break;
-    default:
-       dia_printf
-           ("    <dia:object type=\"Standard - Polygon\" version=\"0\" id=\"%s\">\n",
-            "polygon");
-       break;
-    }
-    dia_fputs("       <dia:attribute name=\"poly_points\">\n");
-    for (i = 0; i < n; i++) {
-       p = diapt(A[i]);
-       if (!i)
-           llp = urp = firstp = p;
-       if (p.x < llp.x || p.y < llp.y)
-           llp = p;
-       if (p.x > urp.x || p.y > urp.y)
-           urp = p;
-       dia_printf("        <dia:point val=\"%g,%g\"/>\n", p.x, p.y);
-    }
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_pos\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", firstp.x, firstp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_bb\">\n");
-    dia_printf("        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              llp.x - .11, llp.y - .11, urp.x + .11, urp.y + .11);
-    dia_fputs("      </dia:attribute>\n");
-    dia_grstyle(&cstk[SP]);
-    dia_grstylefill(&cstk[SP], filled);
-    dia_fputs("    </dia:object>\n");
-}
-
-static void dia_polyline(point * A, int n)
-{
-    int i;
-    pointf p, firstp = { 0, 0 }, llp = {
-    0, 0}, urp = {
-    0, 0};
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-    dia_printf
-       ("    <dia:object type=\"Standard - PolyLine\" version=\"0\" id=\"%s\">\n",
-        "0");
-    dia_fputs("      <dia:attribute name=\"poly_points\">\n");
-    for (i = 0; i < n; i++) {
-       p = diapt(A[i]);
-       if (!i)
-           llp = urp = firstp = p;
-       if (p.x < llp.x || p.y < llp.y)
-           llp = p;
-       if (p.x > urp.x || p.y > urp.y)
-           urp = p;
-       dia_printf("<dia:point val=\"%g,%g\"/>\n", p.x, p.y);
-    }
-    dia_fputs("      </dia:attribute>\n");
-    dia_grstyle(&cstk[SP]);
-    dia_fputs("      <dia:attribute name=\"obj_pos\">\n");
-    dia_printf("        <dia:point val=\"%g,%g\"/>\n", firstp.x, firstp.y);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("      <dia:attribute name=\"obj_bb\">\n");
-    dia_printf("        <dia:rectangle val=\"%g,%g;%g,%g\"/>\n",
-              llp.x - .11, llp.y - .11, urp.x + .11, urp.y + .11);
-    dia_fputs("      </dia:attribute>\n");
-    dia_fputs("    </dia:object>\n");
-}
-
-static void dia_usershape(usershape_t *us, boxf b, point *A, int n, boolean filled)
-{
-    char *imagefile;
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-
-#if 0
-/* FIXME */
-    imagefile = agget(Curnode, "shapefile");
-#else
-    imagefile = NULL;
-#endif
-
-    if (! imagefile) {
-       dia_polygon(A, n, filled);
-       return;
-    }
-}
-
-codegen_t DIA_CodeGen = {
-    dia_reset,
-    dia_begin_job, dia_end_job,
-    dia_begin_graph, dia_end_graph,
-    dia_begin_page, dia_end_page,
-    0, /* dia_begin_layer */ 0,        /* dia_end_layer */
-    dia_begin_cluster, dia_end_cluster,
-    0, /* dia_begin_nodes */ 0,        /* dia_end_nodes */
-    0, /* dia_begin_edges */ 0,        /* dia_end_edges */
-    dia_begin_node, dia_end_node,
-    dia_begin_edge, dia_end_edge,
-    dia_begin_context, dia_end_context,
-    0, /* dia_begin_anchor */ 0,       /* dia_end_anchor */
-    dia_set_font, dia_textpara,
-    dia_set_pencolor, dia_set_fillcolor, dia_set_style,
-    dia_ellipse, dia_polygon,
-    dia_bezier, dia_polyline,
-    1,                         /* bezier_has_arrows */
-    dia_comment,
-    dia_usershape
-};
diff --git a/lib/common/mifgen.c b/lib/common/mifgen.c
deleted file mode 100644 (file)
index 84c7e12..0000000
+++ /dev/null
@@ -1,571 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include <common/render.h>
-#include <cgraph/strcasecmp.h>
-
-#define        NONE    0
-#define        NODE    1
-#define        EDGE    2
-#define        CLST    3
-
-/* MIF font modifiers */
-#define REGULAR 0
-#define BOLD   1
-#define ITALIC 2
-
-/* MIF patterns */
-#define P_SOLID        0
-#define P_NONE  15
-#define P_DOTTED 4             /* i wasn't sure about this */
-#define P_DASHED 11            /* or this */
-
-/* MIF bold line constant */
-#define WIDTH_NORMAL 1
-#define WIDTH_BOLD 3
-
-static int N_pages;
-/* static      point   Pages; */
-static double Scale;
-static int Rot;
-static box PB;
-static int onetime = TRUE;
-
-typedef struct context_t {
-    char color_ix, *fontfam, fontopt, font_was_set;
-    char pen, fill, penwidth, style_was_set;
-    double fontsz;
-} context_t;
-
-#define MAXNEST 4
-static context_t cstk[MAXNEST];
-static int SP;
-
-static char *FillStr = "<Fill 3>";
-static char *NoFillStr = "<Fill 15>";
-
-static void mif_reset(void)
-{
-    onetime = TRUE;
-}
-
-
-static void init_mif(void)
-{
-    SP = 0;
-    cstk[0].color_ix = 0;      /* MIF color index 0-7 */
-    cstk[0].fontfam = "Times"; /* font family name */
-    cstk[0].fontopt = REGULAR; /* modifier: REGULAR, BOLD or ITALIC */
-    cstk[0].pen = P_SOLID;     /* pen pattern style, default is solid */
-    cstk[0].fill = P_NONE;
-    cstk[0].penwidth = WIDTH_NORMAL;
-}
-
-static pointf mifpt(pointf p)
-{
-    pointf tmp, rv;
-    tmp.x = p.x * Scale;
-    tmp.y = Scale * p.y;
-    if (Rot == 0) {
-       rv.x = tmp.x;
-       rv.y = PB.UR.y - PB.LL.y - tmp.y;
-    } else {
-       rv.x = PB.UR.x - PB.LL.x - tmp.y;
-       rv.y = tmp.x;
-    }
-    return rv;
-}
-
-static void mifptarray(point * A, int n)
-{
-    int i;
-    pointf p;
-
-    fprintf(Output_file, " <NumPoints %d>\n", n);
-    for (i = 0; i < n; i++) {
-       p.x = A[i].x;
-       p.y = A[i].y;
-       p = mifpt(p);
-       fprintf(Output_file, " <Point %.2f %.2f>\n", p.x, p.y);
-    }
-}
-
-static void mif_font(context_t * cp)
-{
-    char *fw, *fa;
-
-    fw = fa = "Regular";
-    switch (cp->fontopt) {
-    case BOLD:
-       fw = "Bold";
-       break;
-    case ITALIC:
-       fa = "Italic";
-       break;
-    }
-    fprintf(Output_file,
-           "<Font <FFamily `%s'> <FSize %.1f pt> <FWeight %s> <FAngle %s>>\n",
-           cp->fontfam, Scale * cp->fontsz, fw, fa);
-}
-
-static void mif_color(int i)
-{
-    static char *mifcolor[] = {
-       "black", "white", "red", "green", "blue", "cyan",
-       "magenta", "yellow", "comment",
-       "aquamarine", "plum", "peru", "pink", "mediumpurple", "grey",
-       "lightgrey", "lightskyblue", "lightcoral", "yellowgreen",
-       (char *) 0
-    };
-    if (i <= 8)
-       fprintf(Output_file, "<Separation %d>\n", i);
-    if (i > 8)
-       fprintf(Output_file, "<ObColor `%s'>\n", mifcolor[i]);
-}
-
-static void mif_style(context_t * cp)
-{
-    fprintf(Output_file, "<Pen %d> <Fill %d> <PenWidth %d>\n",
-           cp->pen, cp->fill, cp->penwidth);
-}
-
-static void mif_comment(char *str)
-{
-    fprintf(Output_file, "# %s\n", str);
-}
-
-static void
-mif_begin_job(FILE * ofp, graph_t * g, const char **lib, char *info[], point pages)
-{
-    /* Pages = pages; */
-    N_pages = pages.x * pages.y;
-    fprintf(Output_file,
-           "<MIFFile 3.00> # Generated by %s version %s (%s)\n", info[0],
-           info[1], info[2]);
-    fprintf(Output_file, "# Title: %s\n", agnameof(g));
-    fprintf(Output_file, "# Pages: %d\n", N_pages);
-    fprintf(Output_file, "<Units Upt>\n");
-    fprintf(Output_file, "<ColorCatalog \n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Black'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  100.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsBlack>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `White'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsWhite>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Red'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  100.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  100.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsRed>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Green'>\n");
-    fprintf(Output_file, "  <ColorCyan  100.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  100.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsGreen>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Blue'>\n");
-    fprintf(Output_file, "  <ColorCyan  100.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  100.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsBlue>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Cyan'>\n");
-    fprintf(Output_file, "  <ColorCyan  100.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsCyan>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Magenta'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  100.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsMagenta>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `Yellow'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  100.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsYellow>\n");
-    fprintf(Output_file, "  <ColorAttribute ColorIsReserved>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `aquamarine'>\n");
-    fprintf(Output_file, "  <ColorCyan  100.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  18.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `plum'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  100.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  33.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `peru'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  24.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  100.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  32.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `pink'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  50.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `mediumpurple'>\n");
-    fprintf(Output_file, "  <ColorCyan  40.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  100.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `grey'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  50.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `lightgrey'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  25.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `lightskyblue'>\n");
-    fprintf(Output_file, "  <ColorCyan  38.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  33.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  0.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `lightcoral'>\n");
-    fprintf(Output_file, "  <ColorCyan  0.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  50.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  60.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, " <Color \n");
-    fprintf(Output_file, "  <ColorTag `yellowgreen'>\n");
-    fprintf(Output_file, "  <ColorCyan  31.000000>\n");
-    fprintf(Output_file, "  <ColorMagenta  0.000000>\n");
-    fprintf(Output_file, "  <ColorYellow  100.000000>\n");
-    fprintf(Output_file, "  <ColorBlack  0.000000>\n");
-    fprintf(Output_file, " > # end of Color\n");
-    fprintf(Output_file, "> # end of ColorCatalog\n");
-}
-
-static void mif_end_job(void)
-{
-    fprintf(Output_file, "# end of MIFFile\n");
-}
-
-static void mif_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
-{
-    PB = bb;
-    if (onetime) {
-       fprintf(Output_file, "<BRect %d %d %d %d>\n",
-               PB.LL.x, PB.UR.y, PB.UR.x - PB.LL.x, PB.UR.y - PB.LL.y);
-       init_mif();
-       onetime = FALSE;
-    }
-}
-
-static void
-mif_begin_page(graph_t * g, point page, double scale, int rot,
-              point offset)
-{
-    /* int          page_number; */
-    /* point        sz; */
-
-    Scale = scale;
-    Rot = rot;
-    /* page_number =  page.x + page.y * Pages.x + 1; */
-    /* sz = sub_points(PB.UR,PB.LL); */
-    fprintf(Output_file,
-           " <ArrowStyle <TipAngle 15> <BaseAngle 90> <Length %.1f> <HeadType Filled>>\n",
-           14 * Scale);
-}
-
-static void mif_begin_context(void)
-{
-    assert(SP + 1 < MAXNEST);
-    cstk[SP + 1] = cstk[SP];
-    SP++;
-}
-
-static void mif_end_context(void)
-{
-    int c, psp = SP - 1;
-    assert(SP > 0);
-    if (cstk[SP].color_ix != (c = cstk[psp].color_ix))
-       mif_color(c);
-    if (cstk[SP].font_was_set)
-       mif_font(&(cstk[psp]));
-    if (cstk[SP].style_was_set)
-       mif_style(&(cstk[psp]));
-    /*free(cstk[psp].fontfam); */
-    SP = psp;
-}
-
-static void mif_set_font(char *name, double size)
-{
-    char *p, *q;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    cp->font_was_set = TRUE;
-    cp->fontsz = size;
-    p = strdup(name);
-    if ((q = strchr(p, '-'))) {
-       *q++ = 0;
-       if (strcasecmp(q, "italic") == 0)
-           cp->fontopt = ITALIC;
-       else if (strcasecmp(q, "bold") == 0)
-           cp->fontopt = BOLD;
-    }
-    cp->fontfam = p;
-    mif_font(&cstk[SP]);
-}
-
-static void mif_set_color(char *name)
-{
-    int i;
-    char *tok;
-
-    static char *mifcolor[] = {
-       "black", "white", "red", "green", "blue", "cyan",
-       "magenta", "yellow", "comment",
-       "aquamarine", "plum", "peru", "pink", "mediumpurple", "grey",
-       "lightgrey", "lightskyblue", "lightcoral", "yellowgreen",
-       (char *) 0
-    };
-
-    tok = canontoken(name);
-    for (i = 0; mifcolor[i]; i++) {
-       if (strcasecmp(mifcolor[i], tok) == 0) {
-           cstk[SP].color_ix = i;
-           mif_color(i);
-           return;
-       }
-    }
-    agerr(AGERR, "color %s not supported in MIF\n", name);
-}
-
-static void mif_set_style(char **s)
-{
-    char *line;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    while ((line = *s++)) {
-       if (streq(line, "solid"))
-           cp->pen = P_SOLID;
-       else if (streq(line, "dashed"))
-           cp->pen = P_DASHED;
-       else if (streq(line, "dotted"))
-           cp->pen = P_DOTTED;
-       else if (streq(line, "invis"))
-           cp->pen = P_NONE;
-       else if (streq(line, "bold"))
-           cp->penwidth = WIDTH_BOLD;
-       else if (streq(line, "filled"))
-           cp->fill = P_SOLID;
-       else if (streq(line, "unfilled"))
-           cp->fill = P_NONE;
-       else {
-           agerr(AGERR,
-                 "mif_set_style: unsupported style %s - ignoring\n",
-                 line);
-       }
-       cp->style_was_set = TRUE;
-    }
-    if (cp->style_was_set)
-       mif_style(cp);
-}
-
-static char *mif_string(char *s)
-{
-    static char *buf = NULL;
-    static int bufsize = 0;
-    int pos = 0;
-    char *p, esc;
-
-    if (!buf) {
-       bufsize = 64;
-       buf = N_GNEW(bufsize, char);
-    }
-
-    p = buf;
-    while (*s) {
-       if (pos > (bufsize - 8)) {
-           bufsize *= 2;
-           buf = grealloc(buf, bufsize);
-           p = buf + pos;
-       }
-       esc = 0;
-       switch (*s) {
-       case '\t':
-           esc = 't';
-           break;
-       case '>':
-       case '\'':
-       case '`':
-       case '\\':
-           esc = *s;
-           break;
-       }
-       if (esc) {
-           *p++ = '\\';
-           *p++ = esc;
-           pos += 2;
-       } else {
-           *p++ = *s;
-           pos++;
-       }
-       s++;
-    }
-    *p = '\0';
-    return buf;
-}
-
-static void mif_textpara(point p, textpara_t * para)
-{
-    pointf mp;
-    char *anchor;
-
-    mp.x = p.x;
-    mp.y = p.y - cstk[SP].fontsz / 2 + 2;
-    switch (para->just) {
-    case 'l':
-       anchor = "Left";
-       break;
-    case 'r':
-       anchor = "Right";
-       break;
-    default:
-    case 'n':
-       anchor = "Center";
-       break;
-    }
-    mp = mifpt(mp);
-    fprintf(Output_file,
-           "<TextLine <Angle %d> <TLOrigin %.2f %.2f> <TLAlignment %s>",
-           Rot, mp.x, mp.y, anchor);
-    fprintf(Output_file, " <String `%s'>>\n", mif_string(para->str));
-}
-
-static void mif_bezier(point * A, int n, int arrow_at_start,
-                      int arrow_at_end, int filled)
-{
-    fprintf(Output_file,
-           "<PolyLine <Fill 15> <Smoothed Yes> <HeadCap Square>\n");
-    mifptarray(A, n);
-    fprintf(Output_file, ">\n");
-}
-
-static void mif_polygon(point * A, int n, int filled)
-{
-    fprintf(Output_file, "<Polygon %s\n", (filled ? FillStr : NoFillStr));
-    mifptarray(A, n);
-    fprintf(Output_file, ">\n");
-}
-
-static void mif_ellipse(point p, int rx, int ry, int filled)
-{
-    pointf tl, mp;
-    tl.x = p.x - rx;
-    tl.y = p.y + ry;
-    if (Rot) {
-       int t;
-       t = rx;
-       rx = ry;
-       ry = t;
-    }
-    mp = mifpt(tl);
-    fprintf(Output_file, "<Ellipse %s <BRect %.2f %.2f %.1f %.1f>>\n",
-           filled ? FillStr : NoFillStr,
-           mp.x, mp.y, Scale * (rx + rx), Scale * (ry + ry));
-}
-
-static void mif_polyline(point * A, int n)
-{
-    fprintf(Output_file, "<PolyLine <HeadCap Square>\n");
-    mifptarray(A, n);
-    fprintf(Output_file, ">\n");
-}
-
-static void mif_usershape(usershape_t *us, boxf b, point *A, int n, boolean filled)
-{
-    static boolean onetime = TRUE;
-    if (onetime) {
-       agerr(AGERR, "custom shapes not available with this driver\n");
-       onetime = FALSE;
-    }
-}
-
-codegen_t MIF_CodeGen = {
-    mif_reset,
-    mif_begin_job, mif_end_job,
-    mif_begin_graph, 0,                /* mif_end_graph */
-    mif_begin_page, 0,         /* mif_end_page */
-    0, /* mif_begin_layer */ 0,        /* mif_end_layer */
-    0, /* mif_begin_cluster */ 0, /* mif_end_cluster */
-    0, /* mif_begin_nodes */ 0,        /* mif_end_nodes */
-    0, /* mif_begin_edges */ 0,        /* mif_end_edges */
-    0, /* mif_begin_node */  0,        /* mif_end_node */
-    0, /* mif_begin_edge */  0,        /* mif_end_edge */
-    mif_begin_context, mif_end_context,
-    0, /* mif_begin_anchor */ 0,       /* mif_end_anchor */
-    mif_set_font, mif_textpara,
-    mif_set_color, mif_set_color, mif_set_style,
-    mif_ellipse, mif_polygon,
-    mif_bezier, mif_polyline,
-    0,                         /* bezier_has_arrows */
-    mif_comment,
-    mif_usershape
-};
diff --git a/lib/common/mpgen.c b/lib/common/mpgen.c
deleted file mode 100644 (file)
index 55680de..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-/* mpgen.c 1999-Feb-23 Jim Hefferon jim@joshua.smcvt.edu 
- *  Adapted from psgen.c.  See 1st_read.mp.
- */
-#include <common/render.h>
-#ifndef _WIN32
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-
-
-#define        NONE    0
-#define        NODE    1
-#define        EDGE    2
-#define        CLST    3
-
-/* static      point   Pages; */
-/* static      box             PB; */
-static int onetime = TRUE;
-
-static const char      **U_lib;
-
-typedef struct grcontext_t {
-    char *color, *font;
-    double size;
-} grcontext_t;
-
-#define STACKSIZE 32           /* essentially infinite? */
-static grcontext_t S[STACKSIZE];
-static int SP = 0;
-
-static void mp_reset(void)
-{
-    onetime = TRUE;
-}
-
-/* mp_cat_libfile:
- * Write library files onto the given file pointer.
- * arglib is an NULL-terminated array of char*
- * Each non-trivial entry should be the name of a file to be included.
- * stdlib is an NULL-terminated array of char*
- * Each of these is a line of a standard library to be included.
- * If any item in arglib is the empty string, the stdlib is not used.
- * The stdlib is printed first, if used, followed by the user libraries.
- * We check that for web-safe file usage.
- */
-static void mp_cat_libfile(FILE * ofp, const char **arglib, const char **stdlib)
-{
-    FILE *fp;
-    const char **s, *bp, *p, *path;
-    int i;
-    boolean use_stdlib = TRUE;
-
-    /* check for empty string to turn off stdlib */
-    if (arglib) {
-       for (i = 0; use_stdlib && ((p = arglib[i])); i++) {
-           if (*p == '\0')
-               use_stdlib = FALSE;
-       }
-    }
-    if (use_stdlib)
-       for (s = stdlib; *s; s++) {
-           fputs(*s, ofp);
-           fputc('\n', ofp);
-       }
-    if (arglib) {
-       for (i = 0; (p = arglib[i]) != 0; i++) {
-           if (*p == '\0')
-               continue;       /* ignore empty string */
-           path = safefile(p); /* make sure filename is okay */
-           if (!path) {
-               agerr(AGWARN, "can't find library file %s\n", p);
-           }
-           else if ((fp = fopen(path, "r"))) {
-               while ((bp = Fgets(fp)))
-                   fputs(bp, ofp);
-               fputc('\n', ofp); /* append a newline just in case */
-               fclose (fp);
-           } else
-               agerr(AGWARN, "can't open library file %s\n", path);
-       }
-    }
-}
-
-static void
-mp_begin_job(FILE * ofp, graph_t * g, const char **lib, char *info[], point pages)
-{
-    /* pages and libraries not here (yet?) */
-    /* Pages = pages; */
-    U_lib = lib;
-    /* N_pages = pages.x * pages.y; */
-    /* Cur_page = 0; */
-
-    fprintf(Output_file, "%%--- graphviz MetaPost input\n");
-    fprintf(Output_file, "%% Created by program: %s version %s (%s)\n",
-           info[0], info[1], info[2]);
-    fprintf(Output_file, "%% Title: %s\n", agnameof(g));
-    fprintf(Output_file,
-           "%%  Put this between beginfig and endfig.  See 1st_read.mp.\n");
-    fprintf(Output_file, "%% \n");
-}
-
-static void mp_end_job(void)
-{
-    fprintf(Output_file, "%%  End of graphviz MetaPost input\n");
-    fprintf(Output_file, "%%  \n");
-}
-
-static void mp_comment(char *str)
-{
-    fprintf(Output_file, "%% %s\n", str);
-}
-
-static void mp_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
-{
-    /* PB = bb; */
-    static const char *mp_lib[] = {0};
-    if (onetime) {
-       fprintf(Output_file, "%% BoundingBox: %d %d %d %d\n",
-               bb.LL.x, bb.LL.y, bb.UR.x + 1, bb.UR.y + 1);
-               mp_cat_libfile(Output_file,U_lib,mp_lib);
-       onetime = FALSE;
-    }
-}
-
-static void
-mp_begin_page(graph_t * g, point page, double scale, int rot, point offset)
-{
-    assert(SP == 0);
-    S[SP].font = "";
-    S[SP].color = "black";
-    S[SP].size = 0.0;
-}
-
-static void mp_begin_context(void)
-{
-    if (SP == STACKSIZE - 1)
-       agerr(AGWARN, "mpgen stack overflow\n");
-    else {
-       SP++;
-       S[SP] = S[SP - 1];
-    }
-}
-
-static void mp_end_context(void)
-{
-    if (SP == 0)
-       agerr(AGWARN, "mpgen stack underflow\n");
-    else
-       SP--;
-}
-
-static void mp_set_font(char *name, double size)
-{
-    if (strcmp(S[SP].font, name) || (size != S[SP].size)) {
-       fprintf(Output_file, "%% GV set font: %.2f /%s ignored\n", size,
-               name);
-       S[SP].font = name;
-       S[SP].size = size;
-    }
-}
-
-static void mp_set_color(char *name)
-{
-    static char *op[] = { "graph", "node", "edge", "sethsb" };
-    gvcolor_t color;
-
-    if (strcmp(name, S[SP].color)) {
-       colorxlate(name, &color, HSVA_DOUBLE);
-       fprintf(Output_file, "%% GV set color: %.3f %.3f %.3f %scolor\n",
-               color.u.HSVA[0], color.u.HSVA[1], color.u.HSVA[2], op[Obj]);
-    }
-    S[SP].color = name;
-}
-
-static void mp_set_style(char **s)
-{
-    char *line, *p;
-
-    while ((p = line = *s++)) {
-       while (*p)
-           p++;
-       p++;
-       while (*p) {
-           fprintf(Output_file, "%% GV set style: %s \n", p);
-           while (*p)
-               p++;
-           p++;
-       }
-       fprintf(Output_file, "%% GV set style:: %s\n", line);
-    }
-}
-
-static char *mp_string(char *s)
-{
-    static char *buf = NULL;
-    static int bufsize = 0;
-    int pos = 0;
-    char *p;
-
-    if (!buf) {
-       bufsize = 64;
-       buf = N_GNEW(bufsize, char);
-    }
-
-    p = buf;
-    while (*s) {
-       if (pos > (bufsize - 8)) {
-           bufsize *= 2;
-           buf = grealloc(buf, bufsize);
-           p = buf + pos;
-       }
-       if ((*s == LPAREN) || (*s == RPAREN)) {
-           *p++ = '\\';
-           pos++;
-       }
-       *p++ = *s++;
-       pos++;
-    }
-    *p = '\0';
-    return buf;
-}
-
-static void mp_textpara(point p, textpara_t * para)
-{
-    fprintf(Output_file, "label(btex %s etex,(%dbp,%dbp)) withcolor %s;\n",
-           mp_string(para->str), p.x, p.y, S[SP].color);
-}
-
-static void
-mp_bezier(point * A, int n, int arrow_at_start, int arrow_at_end, int filled)
-{
-    int j;
-    if (arrow_at_start || arrow_at_end)
-       agerr(AGERR, "mp_bezier illegal arrow args\n");
-    fprintf(Output_file, "draw (%dbp,%dbp) ", A[0].x, A[0].y);
-    for (j = 1; j < n; j += 3)
-       fprintf(Output_file,
-               "\n  ..controls (%dbp,%dbp) and (%dbp,%dbp).. (%dbp,%dbp)",
-               A[j].x, A[j].y, A[j + 1].x, A[j + 1].y, A[j + 2].x,
-               A[j + 2].y);
-    fprintf(Output_file, " withcolor %s;\n", S[SP].color);
-}
-
-static void mp_polygon(point * A, int n, int filled)
-{
-    int j;
-    if (filled) {
-       fprintf(Output_file, "  fill (%dbp,%dbp)", A[0].x, A[0].y);
-       for (j = 1; j < n; j++)
-           fprintf(Output_file, "\n  --(%dbp,%dbp)", A[j].x, A[j].y);
-       fprintf(Output_file, "\n  --cycle withcolor %s;\n", S[SP].color);
-    }
-    fprintf(Output_file, "draw (%dbp,%dbp)  ", A[0].x, A[0].y);
-    for (j = 1; j < n; j++)
-       fprintf(Output_file, "\n  --(%dbp,%dbp)", A[j].x, A[j].y);
-    fprintf(Output_file, "\n  --cycle withcolor %s;\n", S[SP].color);
-}
-
-static void mp_ellipse(point p, int rx, int ry, int filled)
-{
-    if (filled)
-       fprintf(Output_file,
-               "  fill fullcircle xscaled %dbp yscaled %dbp shifted (%dbp,%dbp) withcolor %s;\n",
-               2 * rx, 2 * ry, p.x, p.y, S[SP].color);
-    fprintf(Output_file,
-           "draw fullcircle xscaled %dbp yscaled %dbp shifted (%dbp,%dbp);\n",
-           2 * rx, 2 * ry, p.x, p.y);
-}
-
-static void mp_polyline(point * A, int n)
-{
-    int j;
-
-    fprintf(Output_file, "draw (%dbp,%dbp) ", A[0].x, A[0].y);
-    for (j = 1; j < n; j++)
-       fprintf(Output_file, "\n  --(%dbp,%dbp)", A[j].x, A[j].y);
-    fprintf(Output_file, " withcolor %s;\n", S[SP].color);
-}
-
-static void mp_usershape(usershape_t *us, boxf b, point *A, int n, boolean filled)
-{
-    int j;
-    fprintf(Output_file, "%%GV USER SHAPE [ ");
-    for (j = 0; j < n; j++)
-       fprintf(Output_file, "%d %d ", A[j].x, A[j].y);
-    fprintf(Output_file, "%d %d ", A[0].x, A[0].y);
-    fprintf(Output_file, "]  %d %s %s ignored\n", n,
-           (filled ? "true" : "false"), us->name);
-}
-
-codegen_t MP_CodeGen = {
-    mp_reset,
-    mp_begin_job, mp_end_job,
-    mp_begin_graph, 0,         /* mp_end_graph */
-    mp_begin_page, 0,          /* mp_end_page */
-    0, /* mp_begin_layer */ 0, /* mp_end_layer */
-    0, /* mp_begin_cluster */ 0,       /* mp_end_cluster */
-    0, /* mp_begin_nodes */ 0, /* mp_end_nodes */
-    0, /* mp_begin_edges */ 0, /* mp_end_edges */
-    0, /* mp_begin_node */  0, /* mp_end_node */
-    0, /* mp_begin_edge */  0, /* mp_end_edge */
-    mp_begin_context, mp_end_context,
-    0, /* mp_begin_anchor */ 0,        /* mp_end_anchor */
-    mp_set_font, mp_textpara,
-    mp_set_color, mp_set_color, mp_set_style,
-    mp_ellipse, mp_polygon,
-    mp_bezier, mp_polyline,
-    0,                         /* bezier_has_arrows */
-    mp_comment,
-    mp_usershape
-};
diff --git a/lib/common/picgen.c b/lib/common/picgen.c
deleted file mode 100644 (file)
index 638b29b..0000000
+++ /dev/null
@@ -1,609 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-#include <common/render.h>
-
-#define PIC_COORDS_PER_LINE (16)       /* to avoid stdio BUF overflow */
-
-static box BB;
-static int BezierSubdivision = 10;
-static int Rot;
-static int onetime = TRUE;
-static double Scale;
-static double Fontscale;
-
-/* static char **U_lib,*User,*Vers; */
-static const char *EscComment = ".\\\" ";      /* troff comment */
-
-typedef struct grcontext_t {
-    char *color, *font;
-    double size;
-} grcontext_t;
-
-#define STACKSIZE 8
-static grcontext_t S[STACKSIZE];
-static int SP = 0;
-
-static char picgen_msghdr[] = "dot picgen: ";
-static void unsupported(char *s)
-{
-    agerr(AGWARN, "%s%s unsupported\n", picgen_msghdr, s);
-}
-static void warn(char *s)
-{
-    agerr(AGWARN, "%s%s\n", picgen_msghdr, s);
-}
-
-/* There are a couple of ways to generate output: 
-    1. generate for whatever size is given by the bounding box
-       - the drawing at its "natural" size might not fit on a physical page
-         ~ dot size specification can be used to scale the drawing
-         ~ and it's not difficult for user to scale the pic output to fit (multiply 4 (3 distinct) numbers on 3 lines by a scale factor)
-       - some troff implementations may clip large graphs
-         ~ handle by scaling to manageable size
-       - give explicit width and height as parameters to .PS
-       - pic scale variable is reset to 1.0
-       - fonts are printed as size specified by caller, modified by user scaling
-    2. scale to fit on a physical page
-       - requires an assumption of page size (GNU pic assumes 8.5x11.0 inches)
-         ~ any assumption is bound to be wrong more often than right
-       - requires separate scaling of font point sizes since pic's scale variable doesn't affect text
-         ~ possible, as above
-       - likewise for line thickness
-       - GNU pic does this (except for fonts) if .PS is used without explicit width or height; DWB pic does not
-         ~ pic variants likely to cause trouble
-  The first approach is used here.
-*/
-
-static pointf cvt2ptf(point p)
-{
-    pointf r;
-
-    r.x = PS2INCH(p.x);
-    r.y = PS2INCH(p.y);
-    return r;
-}
-
-
-/* troff font mapping */
-typedef struct {
-    char trname[3], *psname;
-} fontinfo;
-
-static fontinfo fonttab[] = {
-    {"AB", "AvantGarde-Demi"},
-    {"AI", "AvantGarde-BookOblique"},
-    {"AR", "AvantGarde-Book"},
-    {"AX", "AvantGarde-DemiOblique"},
-    {"B ", "Times-Bold"},
-    {"BI", "Times-BoldItalic"},
-    {"CB", "Courier-Bold"},
-    {"CO", "Courier"},
-    {"CX", "Courier-BoldOblique"},
-    {"H ", "Helvetica"},
-    {"HB", "Helvetica-Bold"},
-    {"HI", "Helvetica-Oblique"},
-    {"HX", "Helvetica-BoldOblique"},
-    {"Hb", "Helvetica-Narrow-Bold"},
-    {"Hi", "Helvetica-Narrow-Oblique"},
-    {"Hr", "Helvetica-Narrow"},
-    {"Hx", "Helvetica-Narrow-BoldOblique"},
-    {"I ", "Times-Italic"},
-    {"KB", "Bookman-Demi"},
-    {"KI", "Bookman-LightItalic"},
-    {"KR", "Bookman-Light"},
-    {"KX", "Bookman-DemiItalic"},
-    {"NB", "NewCenturySchlbk-Bold"},
-    {"NI", "NewCenturySchlbk-Italic"},
-    {"NR", "NewCenturySchlbk-Roman"},
-    {"NX", "NewCenturySchlbk-BoldItalic"},
-    {"PA", "Palatino-Roman"},
-    {"PB", "Palatino-Bold"},
-    {"PI", "Palatino-Italic"},
-    {"PX", "Palatino-BoldItalic"},
-    {"R ", "Times-Roman"},
-    {"S ", "Symbol"},
-    {"ZD", "ZapfDingbats"},
-    {"\000\000", (char *) 0}
-};
-
-static char *picfontname(char *psname)
-{
-    char *rv;
-    fontinfo *p;
-
-    for (p = fonttab; p->psname; p++)
-       if (streq(p->psname, psname))
-           break;
-    if (p->psname)
-       rv = p->trname;
-    else {
-       agerr(AGERR, "%s%s is not a troff font\n", picgen_msghdr, psname);
-       /* try base font names, e.g. Helvetica-Outline-Oblique -> Helvetica-Outline -> Helvetica */
-       if ((rv = strrchr(psname, '-'))) {
-           *rv = '\0';         /* psname is not specified as const ... */
-           rv = picfontname(psname);
-       } else
-           rv = "R";
-    }
-    return rv;
-}
-
-static char *pic_fcoord(char *buf, pointf pf)
-{
-    sprintf(buf, "(%.5f,%.5f)", Scale * pf.x, Scale * pf.y);
-    return buf;
-}
-
-static char *pic_coord(char *buf, point p)
-{
-    return pic_fcoord(buf, cvt2ptf(p));
-}
-
-static void pic_reset(void)
-{
-    onetime = TRUE;
-}
-
-static void pic_begin_job(FILE * ofp, graph_t * g, const char **lib, char *info[], point pages)
-{
-    /* U_lib = lib; */
-    if (onetime && (pages.x * pages.y > 1)) {
-       unsupported("pagination");
-       onetime = FALSE;
-    }
-    fprintf(Output_file, "%s Creator: %s version %s (%s)\n",
-           EscComment, info[0], info[1], info[2]);
-    fprintf(Output_file, "%s Title: %s\n", EscComment, agnameof(g));
-}
-
-static void pic_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
-{
-    BB = bb;
-
-    fprintf(Output_file,
-           "%s save point size and font\n.nr .S \\n(.s\n.nr DF \\n(.f\n",
-           EscComment);
-}
-
-static void pic_end_graph(void)
-{
-    fprintf(Output_file,
-           "%s restore point size and font\n.ps \\n(.S\n.ft \\n(DF\n",
-           EscComment);
-}
-
-static void pic_begin_page(graph_t * g, point page, double scale, int rot,
-                          point offset)
-{
-    double height, width;
-
-    if (onetime && rot && (rot != 90)) {
-       unsupported("rotation");
-       onetime = FALSE;
-    }
-    Rot = rot;
-    height = PS2INCH((double) (BB.UR.y) - (double) (BB.LL.y));
-    width = PS2INCH((double) (BB.UR.x) - (double) (BB.LL.x));
-    Scale = scale;
-    if (Rot == 90) {
-       double temp = width;
-       width = height;
-       height = temp;
-    }
-    fprintf(Output_file, ".PS %.5f %.5f\n", width, height);
-    EscComment = "#";          /* pic comment */
-    fprintf(Output_file,
-           "%s to change drawing size, multiply the width and height on the .PS line above and the number on the two lines below (rounded to the nearest integer) by a scale factor\n",
-           EscComment);
-    if (width > 0.0) {
-       Fontscale = log10(width);
-       Fontscale += 3.0 - (int) Fontscale;     /* between 3.0 and 4.0 */
-    } else
-       Fontscale = 3.0;
-    Fontscale = pow(10.0, Fontscale);  /* a power of 10 times width, between 1000 and 10000 */
-    fprintf(Output_file, ".nr SF %.0f\nscalethickness = %.0f\n", Fontscale,
-           Fontscale);
-    fprintf(Output_file,
-           "%s don't change anything below this line in this drawing\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s non-fatal run-time pic version determination, version 2\n",
-           EscComment);
-    fprintf(Output_file,
-           "boxrad=2.0 %s will be reset to 0.0 by gpic only\n",
-           EscComment);
-    fprintf(Output_file, "scale=1.0 %s required for comparisons\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s boxrad is now 0.0 in gpic, else it remains 2.0\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s dashwid is 0.1 in 10th Edition, 0.05 in DWB 2 and in gpic\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s fillval is 0.3 in 10th Edition (fill 0 means black), 0.5 in gpic (fill 0 means white), undefined in DWB 2\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s fill has no meaning in DWB 2, gpic can use fill or filled, 10th Edition uses fill only\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s DWB 2 doesn't use fill and doesn't define fillval\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s reset works in gpic and 10th edition, but isn't defined in DWB 2\n",
-           EscComment);
-    fprintf(Output_file, "%s DWB 2 compatibility definitions\n",
-           EscComment);
-    fprintf(Output_file,
-           "if boxrad > 1.0 && dashwid < 0.075 then X\n\tfillval = 1;\n\tdefine fill Y Y;\n\tdefine solid Y Y;\n\tdefine reset Y scale=1.0 Y;\nX\n");
-    fprintf(Output_file, "reset %s set to known state\n", EscComment);
-    fprintf(Output_file, "%s GNU pic vs. 10th Edition d\\(e'tente\n",
-           EscComment);
-    fprintf(Output_file,
-           "if fillval > 0.4 then X\n\tdefine setfillval Y fillval = 1 - Y;\n\tdefine bold Y thickness 2 Y;\n");
-    fprintf(Output_file,
-           "\t%s if you use gpic and it barfs on encountering \"solid\",\n",
-           EscComment);
-    fprintf(Output_file,
-           "\t%s\tinstall a more recent version of gpic or switch to DWB or 10th Edition pic;\n",
-           EscComment);
-    fprintf(Output_file,
-           "\t%s\tsorry, the groff folks changed gpic; send any complaint to them;\n",
-           EscComment);
-    fprintf(Output_file,
-           "X else Z\n\tdefine setfillval Y fillval = Y;\n\tdefine bold Y Y;\n\tdefine filled Y fill Y;\nZ\n");
-    fprintf(Output_file,
-           "%s arrowhead has no meaning in DWB 2, arrowhead = 7 makes filled arrowheads in gpic and in 10th Edition\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s arrowhead is undefined in DWB 2, initially 1 in gpic, 2 in 10th Edition\n",
-           EscComment);
-    fprintf(Output_file, "arrowhead = 7 %s not used by graphviz\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s GNU pic supports a boxrad variable to draw boxes with rounded corners; DWB and 10th Ed. do not\n",
-           EscComment);
-    fprintf(Output_file, "boxrad = 0 %s no rounded corners in graphviz\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s GNU pic supports a linethick variable to set line thickness; DWB and 10th Ed. do not\n",
-           EscComment);
-    fprintf(Output_file, "linethick = 0; oldlinethick = linethick\n");
-    fprintf(Output_file,
-           "%s .PS w/o args causes GNU pic to scale drawing to fit 8.5x11 paper; DWB does not\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s maxpsht and maxpswid have no meaning in DWB 2.0, set page boundaries in gpic and in 10th Edition\n",
-           EscComment);
-    fprintf(Output_file,
-           "%s maxpsht and maxpswid are predefined to 11.0 and 8.5 in gpic\n",
-           EscComment);
-    fprintf(Output_file, "maxpsht = %f\nmaxpswid = %f\n", height, width);
-    fprintf(Output_file, "Dot: [\n");
-    fprintf(Output_file,
-           "define attrs0 %% %%; define unfilled %% %%; define rounded %% %%; define diagonals %% %%\n");
-}
-
-static void pic_end_page(void)
-{
-    fprintf(Output_file, "]\n.PE\n");
-    EscComment = ".\\\" ";     /* troff comment */
-    assert(SP == 0);
-}
-
-static void pic_begin_node(node_t * n)
-{
-    fprintf(Output_file, "%s\t%s\n", EscComment, agnameof(n));
-}
-
-static void pic_begin_edge(edge_t * e)
-{
-    fprintf(Output_file, "%s\t%s -> %s\n", EscComment,
-           agnameof(agtail(e)), agnameof(aghead(e)));
-}
-
-static void pic_begin_context(void)
-{
-    fprintf(Output_file, "{\n");
-    if (SP == STACKSIZE - 1)
-       warn("stk ovfl");
-    else {
-       SP++;
-       S[SP] = S[SP - 1];
-       fprintf(Output_file, "define attrs%d %% %%\n", SP);     /* ensure plain (no attributes) style at start of context */
-    }
-}
-
-static void pic_end_context(void)
-{
-    if (SP == 0)
-       warn("stk undfl");
-    else {
-       SP--;
-       fprintf(Output_file, "}\n");    /* end context group */
-       /* restore correct font and size for context */
-       if (S[SP + 1].font
-           && (!(S[SP].font) || strcmp(S[SP + 1].font, S[SP].font)))
-           fprintf(Output_file, ".ft %s\n", picfontname(S[SP].font));
-       if (S[SP + 1].size != S[SP].size) {
-           int sz;
-
-           if ((sz = (int) (S[SP].size * Scale)) < 1)
-               sz = 1;
-           fprintf(Output_file, ".ps %d*\\n(SFu/%.0fu\n", sz, Fontscale);
-       }
-       fprintf(Output_file, "linethick = oldlinethick\n");
-    }
-}
-
-static void pic_set_font(char *name, double size)
-{
-    if (name && (!(S[SP].font) || strcmp(S[SP].font, name))) {
-       S[SP].font = name;
-       fprintf(Output_file, ".ft %s\n", picfontname(name));
-    }
-    if (size != S[SP].size) {
-       int sz;
-
-       S[SP].size = size;
-       if ((sz = (int) (size * Scale)) < 1)
-           sz = 1;
-       fprintf(Output_file, ".ps %d*\\n(SFu/%.0fu\n", sz, Fontscale);
-    }
-}
-
-static char *pic_string(char *s)
-{
-    static char *buf = NULL;
-    static int bufsize = 0;
-    int pos = 0;
-    char *p;
-
-    if (!buf) {
-       bufsize = 64;
-       buf = N_GNEW(bufsize, char);
-    }
-
-    p = buf;
-    while (*s) {
-       if (pos > (bufsize - 8)) {
-           bufsize *= 2;
-           buf = grealloc(buf, bufsize);
-           p = buf + pos;
-       }
-       if (*s == '\015') {     /* GACK, PTUI! Fire up the teletype, boys;
-                                  somebody's sending an old-fashioned mechanical
-                                  "carriage return" control character. */
-           s++;
-           continue;
-       }
-       if (*s == '\\') {
-           strcpy(p, "\\(rs"); /* e.g. man 5 groff_char from mkssoftware.com */
-           p += 4;
-           pos += 4;
-           s++;
-           continue;
-       }
-       *p++ = *s++;
-       pos++;
-    }
-    *p = '\0';
-    return buf;
-}
-
-static void pic_textpara(point p, textpara_t * para)
-{
-    pointf pf;
-    short flag = 0;
-    double fontsz = S[SP].size;
-
-    switch (para->just) {
-    case 'l':
-       p.x = p.x;
-       break;
-    case 'r':
-       p.x = p.x - para->width;
-       break;
-    default:
-    case 'n':
-       p.x = p.x - para->width / 2;
-       break;
-    }
-    pf = cvt2ptf(p);
-    /* Why on earth would we do this. But it works. SCN 2/26/2002 */
-    /* adjust text baseline for quirks of the renderer */
-    pf.y += fontsz / (3.0 * POINTS_PER_INCH);
-    pf.x += para->width / (2.0 * POINTS_PER_INCH);
-    if (!(S[SP].size)) {       /* size was never set in this or hierarchically higher context */
-       pic_set_font(S[SP].font, fontsz);       /* primarily to output font and/or size directives */
-       for (flag = SP; ((S[flag].size = fontsz), flag); flag--)        /* set size in contexts */
-           ;                   /* flag is zero again at loop termination */
-    }
-    if (fontsz != S[SP].size) {        /* size already set in context,
-                                  but different from request; start new context */
-       flag = 1;
-       pic_begin_context();
-       pic_set_font(S[SP - 1].font, fontsz);
-    }
-    fprintf(Output_file, "\"%s\" at (%.5f,%.5f);\n",
-           pic_string(para->str), Scale * pf.x, Scale * pf.y);
-    if (flag)
-       pic_end_context();
-}
-
-static void pic_set_color(char *name)
-{
-    gvcolor_t color;
-
-    S[SP].color = name;
-    colorxlate(name, &color, HSVA_DOUBLE);
-    /* just v used to set grayscale value */
-    fprintf(Output_file, "setfillval %f\n", color.u.HSVA[2]);
-}
-
-static void pic_set_style(char **s)
-{
-    const char *line, *p;
-    char skip = 0;
-    char buf[BUFSIZ];
-
-    buf[0] = '\0';
-    fprintf(Output_file, "define attrs%d %%", SP);
-    while ((p = line = *s++)) {
-       while (*p)
-           p++;
-       p++;
-       while (*p) {
-           if (!strcmp(line, "setlinewidth")) {        /* a hack to handle the user-defined (PS) style spec in proc3d.dot */
-               long n = atol(p);
-
-               snprintf(buf, sizeof(buf),
-                       "oldlinethick = linethick;linethick = %ld * scalethickness / %.0f\n",
-                       n, Fontscale / Scale);
-               skip = 1;
-           } else
-               fprintf(Output_file, " %s", p);
-           while (*p)
-               p++;
-           p++;
-       }
-       if (!skip)
-           fprintf(Output_file, " %s", line);
-       skip = 0;
-    }
-    fprintf(Output_file, " %%\n");
-    fprintf(Output_file, "%s", buf);
-}
-
-static void pic_ellipse(point p, int rx, int ry, int filled)
-{
-    pointf pf;
-
-    pf = cvt2ptf(p);
-    fprintf(Output_file,
-           "ellipse attrs%d %swid %.5f ht %.5f at (%.5f,%.5f);\n", SP,
-           filled ? "fill " : "", Scale * PS2INCH(2 * rx),
-           Scale * PS2INCH(2 * ry), Scale * pf.x, Scale * pf.y);
-}
-
-static void point_list_out(point * A, int n, int close)
-{
-    int j;
-    char buf[SMALLBUF];
-
-    for (j = 0; j < n; j++)
-       fprintf(Output_file, "P%d: %s\n", j, pic_coord(buf, A[j]));
-    for (j = 0; j + 1 < n; j++)
-       fprintf(Output_file, "move to P%d; line attrs%d to P%d\n", j, SP,
-               j + 1);
-    if (close)
-       fprintf(Output_file, "move to P%d; line attrs%d to P0\n", n - 1,
-               SP);
-}
-
-static void pic_polygon(point * A, int n, int filled)
-{
-    /* test for special case: rectangle oriented with page */
-    if ((n == 4) && (((A[0].x == A[1].x) && (A[0].y == A[3].y)
-                     && (A[1].y == A[2].y) && (A[2].x == A[3].x))
-                    || ((A[0].y == A[1].y) && (A[0].x == A[3].x)
-                        && (A[1].x == A[2].x) && (A[2].y == A[3].y))
-       )) {
-       pointf pf1, pf2;
-
-       pf1 = cvt2ptf(A[0]);    /* opposite */
-       pf2 = cvt2ptf(A[2]);    /* corners  */
-       if (filled) {
-           gvcolor_t color;
-
-           colorxlate(S[SP].color, &color, HSVA_DOUBLE);
-           fprintf(Output_file, "setfillval %f\n", color.u.HSVA[2]);
-       }
-       fprintf(Output_file, "box attrs%d %swid %.5f ht %.5f at (%.5f,%.5f);\n", SP, filled ? "fill " : "", Scale * fabs(pf1.x - pf2.x), Scale * fabs(pf1.y - pf2.y),   /* width, height */
-               Scale * (pf1.x + pf2.x) / 2.0, Scale * (pf1.y + pf2.y) / 2.0);  /* center coordinates */
-       return;
-    }
-    if (onetime && filled) {
-       unsupported("shape fill");
-       onetime = FALSE;
-    }
-    point_list_out(A, n, TRUE);
-}
-
-static void pic_polyline(point * A, int n)
-{
-    point_list_out(A, n, FALSE);
-}
-
-static void pic_usershape(usershape_t *us, boxf b, point *A, int n, boolean filled)
-{
-/* FIXME */
-    /* it's not at all clear what xxx_user_shape is supposed to do; in most xxxgen.c files it emits a message */
-    /* this defines the shape as a macro and then invokes the macro */
-    fprintf(Output_file, "define %s {\n", us->name);
-    fprintf(Output_file, "}\n%s\n", us->name);
-}
-
-static void pic_bezier(point * A, int n, int arrow_at_start,
-                      int arrow_at_end, int filled)
-{
-    pointf V[4], p;
-    int i, j, m, step;
-    char buf[SMALLBUF];
-
-    if (arrow_at_start || arrow_at_end)
-       warn("not supposed to be making arrows here!");
-    V[3] = cvt2ptf(A[0]);      /* initial cond */
-    for (i = m = 0; i + 3 < n; i += 3) {
-       V[0] = V[3];
-       for (j = 1; j <= 3; j++)
-           V[j] = cvt2ptf(A[i + j]);
-       p = Bezier(V, 3, 0.0, NULL, NULL);
-       if (!i)
-           fprintf(Output_file, "P0: %s\n", pic_fcoord(buf, p));
-       for (step = 1; step <= BezierSubdivision; step++) {
-           p = Bezier(V, 3, (double) step / BezierSubdivision, NULL,
-                      NULL);
-           ++m;
-           fprintf(Output_file, "P%d: %s\n", m, pic_fcoord(buf, p));
-       }
-    }
-    for (i = 0; i + 2 <= m; i += 2)    /* DWB 2 pic suffers from severe roundoff errors if too many steps are plotted at once */
-       fprintf(Output_file, "move to P%d; line attrs%d to P%d then to P%d\n", i, SP, i + 1, i + 2);    /* use line, as splines can't be dotted or dashed */
-}
-
-static void pic_comment(char *str)
-{
-    fprintf(Output_file, "'\\\" %s\n", str);
-}
-
-codegen_t PIC_CodeGen = {
-    pic_reset,
-    pic_begin_job, 0,          /* pic_end_job */
-    pic_begin_graph, pic_end_graph,
-    pic_begin_page, pic_end_page,
-    0, /* pic_begin_layer */ 0,        /* pic_end_layer */
-    0, /* pic_begin_cluster */ 0,      /* pic_end_cluster */
-    0, /* pic_begin_nodes */ 0,        /* pic_end_nodes */
-    0, /* pic_begin_edges */ 0,        /* pic_end_edges */
-    pic_begin_node, 0,         /* pic_end_node */
-    pic_begin_edge, 0,         /* pic_end_edge */
-    pic_begin_context, pic_end_context,
-    0, /* pic_begin_anchor */ 0,       /* pic_end_anchor */
-    pic_set_font, pic_textpara,
-    pic_set_color, pic_set_color, pic_set_style,
-    pic_ellipse, pic_polygon,
-    pic_bezier, pic_polyline,
-    0,                         /* bezier_has_arrows */
-    pic_comment,
-    pic_usershape
-};
diff --git a/lib/common/vtxgen.c b/lib/common/vtxgen.c
deleted file mode 100644 (file)
index 2dc8cf2..0000000
+++ /dev/null
@@ -1,644 +0,0 @@
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property 
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: Details at https://graphviz.org
- *************************************************************************/
-
-
-/*
- * vtxgen.c generates graph diagrams in the format for
- *  Confluents's Visual Thought
- */
-
-/*
- * If this time code is a pain to port, then just comment out the
- * next line.  It only provides an optional information field
- * in the (header...) block 
- */
-#define SUPPORT_WRITEDATE
-
-#include <common/render.h>
-#ifdef SUPPORT_WRITEDATE
-#include <time.h>
-#endif
-#include <cgraph/strcasecmp.h>
-
-
-/* VTX font modifiers */
-#define REGULAR 0
-#define BOLD   1
-#define ITALIC 2
-#define UNDERSORE 4
-#define STRIKE 8
-
-/* VTX patterns */
-#define P_NONE  0
-#define P_SOLID        1
-#define P_DOTTED 2
-#define P_DASHED 3
-
-/* VTX bold line constant */
-#define WIDTH_NORMAL 1
-#define WIDTH_BOLD 3
-
-/* VTX shape mappings */
-typedef struct shapemap_s {
-    char *shape;
-    char *vtxshape;
-} shapemap_t;
-
-static shapemap_t shapemap[] = {
-    {"box", "\"Rectangle\""},
-    {"ellipse", "\"Ellipse\""},
-    {"circle", "\"Ellipse\""},
-    {"triangle", "\"Triangle\""},
-    {"diamond", "\"Diamond\""},
-    {"trapezium", "\"Trapezoid\""},
-    {"parallelogram", "\"Parallelogram\""},
-    {"hexagon", "\"Hexagon\""},
-    {NULL, "\"Ellipse\""}      /* default */
-};
-
-
-static point Pages;
-static double Scale;
-static int Rot;
-/* static      box             PB; */
-static int onetime = TRUE;
-
-typedef struct context_t {
-    int color_r, color_g, color_b;
-    char *fontfam, fontopt, font_was_set;
-    char pen, fill, penwidth, style_was_set;
-    double fontsz;
-} context_t;
-
-#define MAXNEST 4
-static context_t cstk[MAXNEST];
-static int SP;
-
-static void vtx_reset(void)
-{
-    onetime = TRUE;
-}
-
-
-static void init_vtx(void)
-{
-    SP = 0;
-    cstk[0].color_r = cstk[0].color_g = cstk[0].color_b = 0;
-    cstk[0].fontfam = "Times"; /* font family name */
-    cstk[0].fontopt = REGULAR; /* modifier: REGULAR, BOLD or ITALIC */
-    cstk[0].pen = P_SOLID;     /* pen pattern style, default is solid */
-    cstk[0].fill = P_NONE;
-    cstk[0].penwidth = WIDTH_NORMAL;
-}
-
-static pointf vtx_pt(pointf p)
-{
-    pointf rv;
-
-    if (Rot == 0) {
-       rv.x = p.x;
-       rv.y = p.y;
-    } else {
-       rv.x = p.y;
-       rv.y = p.x;
-    }
-    return rv;
-}
-
-static void vtx_ptarray(point * A, int n)
-{
-    int i;
-    pointf p;
-
-    fprintf(Output_file, "    (points\n");
-    for (i = 0; i < n; i++) {
-       p.x = (double) A[i].x;
-       p.y = (double) A[i].y;
-       p = vtx_pt(p);
-       fprintf(Output_file, "      (%g %g)\n", p.x, p.y);
-    }
-    fprintf(Output_file, "    )\n");
-}
-
-static void vtx_bzptarray(point * A, int start, int end)
-{
-    pointf p;
-    int qx = 0, qy = 0;
-    int i, j, incr = (start > end) ? -1 : 1;
-
-    fprintf(Output_file, "    (points\n");
-    for (i = start, j = 1; i != end; i += incr, j++) {
-       switch (j % 3) {
-       case 0:
-           p.x = (double) A[i].x;
-           p.y = (double) A[i].y;
-           p = vtx_pt(p);
-           fprintf(Output_file, "      (%g %g)\n", p.x, p.y);
-           break;
-       case 1:
-#if 1
-           qx = A[i].x;
-           qy = A[i].y;
-#else
-           p.x = (double) A[i].x;
-           p.y = (double) A[i].y;
-           p = vtx_pt(p);
-           fprintf(Output_file, "      (%g %g)\n", p.x, p.y);
-#endif
-           break;
-       case 2:
-#if 1
-           /* undo EK's strange coding of straight segments */
-           if (A[i].x == qx && A[i].y == qy) {
-               if ((A[i - 2].x == qx && A[i - 2].y == qy)
-                   || (A[i + 1].x == qx && A[i + 1].y == qy)) {
-                   p.x = (A[i + 1].x + A[i - 2].x) / 2.0;
-                   p.y = (A[i + 1].y + A[i - 2].y) / 2.0;
-               } else {
-                   p.x = (double) qx;
-                   p.y = (double) qy;
-               }
-           } else {
-               p.x = (A[i].x + qx) / 2.0;
-               p.y = (A[i].y + qy) / 2.0;
-           }
-#else
-           p.x = (double) A[i].x;
-           p.y = (double) A[i].y;
-#endif
-           p = vtx_pt(p);
-           fprintf(Output_file, "      (%g %g)\n", p.x, p.y);
-           break;
-       }
-    }
-    fprintf(Output_file, "    )\n");
-}
-
-static void vtx_font(context_t * cp)
-{
-/* FIX
-       char    *fw,*fa;
-
-       fw = fa = "Regular";
-       switch (cp->fontopt) {
-               case BOLD: fw = "Bold"; break;
-               case ITALIC: fa = "Italic"; break;
-       }
-*/
-}
-
-static void vtx_comment(char *str)
-{
-    fprintf(Output_file, "; %s\n", str);
-}
-
-static void
-vtx_begin_job(FILE * ofp, graph_t * g, const char **lib, char *info[], point pages)
-{
-    char *date = "";
-#ifdef SUPPORT_WRITEDATE
-    time_t when;
-    struct tm *tm;
-    size_t date_length = 200;
-
-    time(&when);
-    tm = localtime(&when);
-    date = N_GNEW(date_length, char);
-    strftime(date, date_length, "%a %b %e %H:%M:%S %Z %Y", tm);
-#endif
-
-    Pages = pages;
-    /* N_pages = pages.x * pages.y; */
-
-    fprintf(Output_file, "; Visual Thought 1.0\n"
-           "\n"
-           "(header\n"
-           "  (program \"%s\")\n"
-           "  (version \"%s\")\n"
-           "  (buildDate \"%s\")\n"
-           "  (writeDate \"%s\")\n"
-           "  (documentPath \"\")\n"
-           ")\n" "\n", info[0], info[1], info[2], date);
-
-    free(date);
-}
-
-static void vtx_begin_graph(GVC_t * gvc, graph_t * g, box bb, point pb)
-{
-    /* PB = bb; */
-    if (onetime) {
-       init_vtx();
-       onetime = FALSE;
-    }
-}
-
-static void
-vtx_begin_page(graph_t * g, point page, double scale, int rot,
-              point offset)
-{
-    int page_number;
-    /* point        sz; */
-
-    Scale = scale;
-    Rot = rot;
-    page_number = page.x + page.y * Pages.x + 1;
-    /* sz = sub_points(PB.UR,PB.LL); */
-
-    fprintf(Output_file, "(document\n"
-           "  (palette F)\n"
-           "  (layout\n"
-           "    (page \"Letter\")\n"
-           "    (units \"Inches\")\n"
-           "    (orientation \"portrait\")\n"
-           "    (numberOfPages %d %d)\n"
-           "    (scale %g)\n"
-           "    (margins 18 18 18 18)\n"
-           "  )\n"
-           ")\n"
-           "\n"
-           "(views\n"
-           "  (view\n"
-           "    (location 269 49)\n"
-           "    (size 632 723)\n"
-           "    (zoom %g)\n"
-           "    (documentLocation 0 119)\n"
-           "    (gridSnap T)\n"
-           "    (gridVisibility F)\n"
-           "    (gridSpacing 9)\n"
-           "    (pageBreaks T)\n"
-           "    (toolVisibility T)\n"
-           "    (rulerVisibility T)\n"
-           "  )\n"
-           ")\n"
-           "\n", page_number, Pages.x * Pages.y, scale * 100, scale);
-}
-
-static void vtx_begin_nodes(void)
-{
-    fprintf(Output_file, "(shapes\n");
-}
-
-static void vtx_end_nodes(void)
-{
-    fprintf(Output_file, ")\n" "\n");
-}
-
-static void vtx_begin_edges(void)
-{
-    fprintf(Output_file, "(connections\n");
-}
-
-static void vtx_end_edges(void)
-{
-    fprintf(Output_file, ")\n" "\n" "(groups\n" ")\n");
-}
-
-static void vtx_begin_node(node_t * n)
-{
-    shapemap_t *p;
-
-    for (p = shapemap; p->shape; p++) {
-       if (streq(ND_shape(n)->name, p->shape)) {
-           break;
-       }
-    }
-    fprintf(Output_file, "  (shape\n"
-           "    (id %ld)\n"
-           "    (layer %ld)\n"
-           "    (type %s)\n", AGID(n) + 1, AGID(n), p->vtxshape);
-}
-
-static void vtx_end_node(void)
-{
-    fprintf(Output_file, "  )\n");
-}
-
-static void vtx_begin_edge(edge_t * e)
-{
-    fprintf(Output_file, "  (connection\n"
-           "    (id %ld)\n"
-           "    (layer %ld)\n"
-           "    (rotation 0)\n"
-           "    (textRotation 0)\n"
-           "    (locked F)\n"
-           "    (start %ld)\n"
-           "    (end %ld)\n",
-           AGID(e) + 1, AGID(e), AGID(agtail(e)) + 1, AGID(aghead(e)) + 1);
-}
-
-static void vtx_end_edge(void)
-{
-    fprintf(Output_file, "  )\n");
-}
-
-static void vtx_begin_context(void)
-{
-    assert(SP + 1 < MAXNEST);
-    cstk[SP + 1] = cstk[SP];
-    SP++;
-}
-
-static void vtx_end_context(void)
-{
-    int psp = SP - 1;
-
-    assert(SP > 0);
-    SP = psp;
-}
-
-static void vtx_set_font(char *name, double size)
-{
-    char *p, *q;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    cp->font_was_set = TRUE;
-    cp->fontsz = size;
-    p = strdup(name);
-    if ((q = strchr(p, '-'))) {
-       *q++ = 0;
-       if (strcasecmp(q, "italic") == 0)
-           cp->fontopt = ITALIC;
-       else if (strcasecmp(q, "bold") == 0)
-           cp->fontopt = BOLD;
-    }
-    cp->fontfam = p;
-    vtx_font(&cstk[SP]);
-}
-
-static void vtx_style(void)
-{
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    fprintf(Output_file, "    (style\n"
-           "      (filled %s)\n"
-           "      (fillColor %d %d %d)\n"
-           "      (stroked T)\n"
-           "      (strokeColor %d %d %d)\n"
-           "      (lineWidth %d)\n"
-           "      (shadowed F)\n"
-           "      (shadowColor 39321 39321 39321)\n"
-           "    )\n",
-           cp->fill ? "T" : "F",
-           cp->color_r, cp->color_g, cp->color_b,
-           cp->color_r, cp->color_g, cp->color_b, cp->penwidth);
-}
-
-static void vtx_node_style(void)
-{
-    fprintf(Output_file, "    (rotation 0)\n" "    (locked F)\n");
-    vtx_style();
-    fprintf(Output_file, "    (flipHorizontal F)\n"
-           "    (flipVertical F)\n");
-}
-
-static void vtx_set_color(char *name)
-{
-    gvcolor_t color;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    colorxlate(name, &color, RGBA_WORD);
-    cp->color_r = color.u.rrggbbaa[0];
-    cp->color_g = color.u.rrggbbaa[1];
-    cp->color_b = color.u.rrggbbaa[2];
-}
-
-static void vtx_set_style(char **s)
-{
-    char *line;
-    context_t *cp;
-
-    cp = &(cstk[SP]);
-    while ((line = *s++)) {
-       if (streq(line, "solid"))
-           cp->pen = P_SOLID;
-       else if (streq(line, "dashed"))
-           cp->pen = P_DASHED;
-       else if (streq(line, "dotted"))
-           cp->pen = P_DOTTED;
-       else if (streq(line, "invis"))
-           cp->pen = P_NONE;
-       else if (streq(line, "bold"))
-           cp->penwidth = WIDTH_BOLD;
-       else if (streq(line, "filled"))
-           cp->fill = P_SOLID;
-       else if (streq(line, "unfilled"))
-           cp->fill = P_NONE;
-       else {
-           agerr(AGERR,
-                 "vtx_set_style: unsupported style %s - ignoring\n",
-                 line);
-       }
-       cp->style_was_set = TRUE;
-    }
-}
-
-static char *vtx_string(char *s)
-{
-    static char *buf = NULL;
-    static int bufsize = 0;
-    int pos = 0;
-    char *p, esc;
-
-    if (!buf) {
-       bufsize = 64;
-       buf = N_GNEW(bufsize, char);
-    }
-
-    p = buf;
-    while (*s) {
-       if (pos > (bufsize - 8)) {
-           bufsize *= 2;
-           buf = grealloc(buf, bufsize);
-           p = buf + pos;
-       }
-       esc = 0;
-       switch (*s) {
-       case '\t':
-           esc = 't';
-           break;
-       case '{':
-       case '}':
-       case '\\':
-           esc = *s;
-           break;
-       }
-       if (esc) {
-           *p++ = '\\';
-           *p++ = esc;
-           pos += 2;
-       } else {
-           *p++ = *s;
-           pos++;
-       }
-       s++;
-    }
-    *p = '\0';
-    return buf;
-}
-
-static void vtx_textpara(point p, textpara_t * para)
-{
-    pointf mp;
-    double fontsz = Scale * cstk[SP].fontsz;
-
-    if (cstk[SP].pen == P_NONE) {
-       /* its invisible, don't draw */
-       return;
-    }
-
-    mp.x = (double) p.x;
-    mp.y = (double) (p.y - fontsz / 2 + 2);
-    mp = vtx_pt(mp);
-    if (Obj == EDGE) {
-       fprintf(Output_file, "    (showText T)\n"
-               "    (textDistancePercentage 0.5)\n"
-               "    (textWidth 72)\n"
-               "    (textOffset 0)\n"
-               "    (rtfText{\\rtf1\\ansi\\deff0\n"
-               "{\\fonttbl{\\f0\\fnil helvetica medium;}}\n"
-               "{\\colortbl\\red0\\green0\\blue0;}\n"
-               "\\cf0\\plain\\pard {\\fs%d %s}})\n",
-               (int) ((fontsz * 2) - 8), vtx_string(para->str));
-    } else {
-       fprintf(Output_file, "    (showText T)\n"
-               "    (textVerticalAlignment \"left\")\n"
-               "    (rtfText{\\rtf1\\ansi\\deff0\n"
-               "{\\fonttbl{\\f0\\fnil helvetica medium;}}\n"
-               "{\\colortbl\\red0\\green0\\blue0;}\n"
-               "\\cf0\\plain\\pard {\\fs%d %s}})\n",
-               (int) ((fontsz * 2) - 8), vtx_string(para->str));
-    }
-}
-
-static void vtx_bezier(point * A, int n, int arrow_at_start,
-                      int arrow_at_end, int filled)
-{
-    if (arrow_at_start) {
-       vtx_bzptarray(A, n - 2, 0);
-       fprintf(Output_file, "    (curved T)\n");
-       vtx_style();
-       fprintf(Output_file, "    (drawStartArrowhead %s)\n"
-               "    (drawEndArrowhead %s)\n"
-               "    (startArrowhead \"StandardArrow\")\n"
-               "    (endArrowhead \"StandardArrow\")\n",
-               arrow_at_end ? "T" : "F", arrow_at_start ? "T" : "F");
-    } else {
-       vtx_bzptarray(A, 1, n - 1);
-       fprintf(Output_file, "    (curved T)\n");
-       vtx_style();
-       fprintf(Output_file, "    (drawStartArrowhead %s)\n"
-               "    (drawEndArrowhead %s)\n"
-               "    (startArrowhead \"StandardArrow\")\n"
-               "    (endArrowhead \"StandardArrow\")\n",
-               arrow_at_start ? "T" : "F", arrow_at_end ? "T" : "F");
-    }
-}
-
-static void vtx_polygon(point * A, int n, int filled)
-{
-    int i;
-    pointf mp, max, min;
-
-    mp.x = 0;
-    mp.y = 0;
-    max.x = min.x = (double) A[0].x;
-    max.y = min.y = (double) A[0].y;
-    for (i = 0; i < n; i++) {
-       mp.x += (double) A[i].x;
-       mp.y += (double) A[i].y;
-       max.x = MAX(max.x, (double) A[i].x);
-       max.y = MAX(max.y, (double) A[i].y);
-       min.x = MIN(min.x, (double) A[i].x);
-       min.y = MIN(min.y, (double) A[i].y);
-    }
-    mp.x /= n;
-    mp.y /= n;
-    mp = vtx_pt(mp);
-    max = vtx_pt(max);
-    min = vtx_pt(min);
-    fprintf(Output_file, "    (location %g %g)\n"
-           "    (size %g %g)\n",
-           mp.x, mp.y, max.x - min.x, max.y - min.y);
-    vtx_node_style();
-}
-
-static void vtx_ellipse(point p, int rx, int ry, int filled)
-{
-    pointf mp;
-
-    mp.x = (double) p.x;
-    mp.y = (double) p.y;
-    mp = vtx_pt(mp);
-    fprintf(Output_file, "    (location %g %g)\n"
-           "    (size %g %g)\n",
-           mp.x, mp.y, (double) (rx + rx), (double) (ry + ry));
-    vtx_node_style();
-}
-
-static void vtx_polyline(point * A, int n)
-{
-    vtx_ptarray(A, n);
-    fprintf(Output_file, "    (curved F)\n");
-    vtx_style();
-}
-
-static void vtx_usershape(usershape_t *us, boxf b, point *A, int n, boolean filled)
-{
-/* FIXME */
-    int i;
-    pointf mp, max, min;
-
-    mp.x = 0;
-    mp.y = 0;
-    max.x = min.x = (double) A[0].x;
-    max.y = min.y = (double) A[0].y;
-    for (i = 0; i < n; i++) {
-       mp.x += (double) A[i].x;
-       mp.y += (double) A[i].y;
-       max.x = MAX(max.x, (double) A[i].x);
-       max.y = MAX(max.y, (double) A[i].y);
-       min.x = MIN(min.x, (double) A[i].x);
-       min.y = MIN(min.y, (double) A[i].y);
-    }
-    mp.x /= n;
-    mp.y /= n;
-    mp = vtx_pt(mp);
-    max = vtx_pt(max);
-    min = vtx_pt(min);
-    fprintf(Output_file, "    (location %g %g)\n"
-           "    (size %g %g)\n",
-           mp.x, mp.y, max.x - min.x, max.y - min.y);
-    vtx_node_style();
-}
-
-codegen_t VTX_CodeGen = {
-    vtx_reset,
-    vtx_begin_job, 0,          /* vtx_end_job */
-    vtx_begin_graph, 0,                /* vtx_end_graph */
-    vtx_begin_page, 0,         /* vtx_end_page */
-    0, /* vtx_begin_layer */ 0,        /* vtx_end_layer */
-    0, /* vtx_begin_cluster */ 0,      /* vtx_end_cluster */
-    vtx_begin_nodes, vtx_end_nodes,
-    vtx_begin_edges, vtx_end_edges,
-    vtx_begin_node, vtx_end_node,
-    vtx_begin_edge, vtx_end_edge,
-    vtx_begin_context, vtx_end_context,
-    0, /* vtx_begin_anchor */ 0,       /* vtx_end_anchor */
-    vtx_set_font, vtx_textpara,
-    vtx_set_color, vtx_set_color, vtx_set_style,
-    vtx_ellipse, vtx_polygon,
-    vtx_bezier, vtx_polyline,
-    1,                         /* bezier_has_arrows */
-    vtx_comment,
-    vtx_usershape
-};