Graphviz 12.0.1~dev.20240715.2254
Loading...
Searching...
No Matches
gv2gml.c File Reference

DOT-GML converter. More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <getopt.h>
#include <cgraph/cgraph.h>
#include <cgraph/exit.h>
#include <cgraph/gv_ctype.h>
#include <cgraph/ingraphs.h>
#include <cgraph/streq.h>
#include <cgraph/strview.h>
#include <cgraph/tokenize.h>
#include <cgraph/unreachable.h>
#include <common/types.h>
#include <common/utils.h>
#include "openFile.h"
Include dependency graph for gv2gml.c:

Go to the source code of this file.

Data Structures

struct  node_attrs
 
struct  edge_attrs
 
struct  Local_Agnodeinfo_t
 

Macros

#define POS_SET   (1<<0)
 
#define W_SET   (1<<1)
 
#define H_SET   (1<<2)
 
#define INVIS   (1<<3)
 
#define FILL   (1<<4)
 
#define LINE   (1<<5)
 
#define DASH   (1<<6)
 
#define DOT   (1<<7)
 
#define BOLD   (1<<8)
 
#define ID(n)   (((Local_Agnodeinfo_t*)(n->base.data))->id)
 

Functions

static void indent (int ix)
 
static bool isNumber (char *s)
 Return true if input string is number.
 
static int parseStyle (char *s)
 Simple implementation for parsing style attribute.
 
static void emitInt (char *name, int value, int ix)
 
static void emitReal (char *name, double value, int ix)
 
static void emitPoint (double x, double y, int ix)
 
static char * skipWS (char *s)
 
static char * readPoint (char *s, double *xp, double *yp)
 
static char * arrowEnd (char *s0, char *pfx, int *fp, double *xp, double *yp)
 
static void emitSpline (char *s, int ix)
 
static int put (void *stream, const char *s)
 
static int xml_puts (FILE *stream, const char *s)
 
static void emitAttr (char *name, char *value, int ix)
 
static void emitNodeAttrs (Agraph_t *G, Agnode_t *np, int ix)
 
static void emitNode (Agraph_t *G, Agnode_t *n)
 
static void emitEdgeAttrs (Agraph_t *G, Agedge_t *ep, int ix)
 
static void emitEdge (Agraph_t *G, Agedge_t *e)
 
static void emitGraphAttrs (Agraph_t *G)
 
static void gv_to_gml (Agraph_t *G)
 
static void usage (int v)
 
static char * cmdName (char *cmd)
 
static void initargs (int argc, char **argv)
 
int main (int argc, char **argv)
 

Variables

static FILE * outFile
 
static char * CmdName
 
static char ** Files
 
static uint64_t id
 
static bool yworks
 use yWorks.com variant of GML?
 
static char * useString
 

Macro Definition Documentation

◆ BOLD

#define BOLD   (1<<8)

Definition at line 53 of file gv2gml.c.

◆ DASH

#define DASH   (1<<6)

Definition at line 51 of file gv2gml.c.

◆ DOT

#define DOT   (1<<7)

Definition at line 52 of file gv2gml.c.

◆ FILL

#define FILL   (1<<4)

Definition at line 49 of file gv2gml.c.

◆ H_SET

#define H_SET   (1<<2)

Definition at line 47 of file gv2gml.c.

◆ ID

#define ID (   n)    (((Local_Agnodeinfo_t*)(n->base.data))->id)

Definition at line 94 of file gv2gml.c.

◆ INVIS

#define INVIS   (1<<3)

Definition at line 48 of file gv2gml.c.

◆ LINE

#define LINE   (1<<5)

Definition at line 50 of file gv2gml.c.

◆ POS_SET

#define POS_SET   (1<<0)

Definition at line 45 of file gv2gml.c.

◆ W_SET

#define W_SET   (1<<1)

Definition at line 46 of file gv2gml.c.

Function Documentation

◆ arrowEnd()

static char * arrowEnd ( char *  s0,
char *  pfx,
int *  fp,
double *  xp,
double *  yp 
)
static

Definition at line 173 of file gv2gml.c.

References graphviz_exit(), NULL, readPoint(), and skipWS().

Referenced by emitSpline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cmdName()

static char * cmdName ( char *  cmd)
static

Definition at line 650 of file gv2gml.c.

References cmd.

Referenced by initargs().

Here is the caller graph for this function:

◆ emitAttr()

static void emitAttr ( char *  name,
char *  value,
int  ix 
)
static

Definition at line 220 of file gv2gml.c.

References indent(), isNumber(), outFile, and xml_puts().

Referenced by emitEdgeAttrs(), emitGraphAttrs(), and emitNodeAttrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitEdge()

static void emitEdge ( Agraph_t G,
Agedge_t e 
)
static

Definition at line 593 of file gv2gml.c.

References aghead, AGSEQ, agtail, emitEdgeAttrs(), G, ID, and outFile.

Referenced by gv_to_gml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitEdgeAttrs()

static void emitEdgeAttrs ( Agraph_t G,
Agedge_t ep,
int  ix 
)
static

Definition at line 433 of file gv2gml.c.

References AGEDGE, agnxtattr(), agxget(), edge_attrs::arrow, edge_attrs::arrowhead, edge_attrs::arrowtail, BOLD, DASH, DOT, emitAttr(), emitInt(), emitSpline(), edge_attrs::fill, edge_attrs::flags, edge_attrs::fontColor, edge_attrs::fontName, edge_attrs::fontSize, G, INVIS, label(), LINE, s::name, NULL, outFile, parseStyle(), edge_attrs::pos, streq(), edge_attrs::width, and yworks.

Referenced by emitEdge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitGraphAttrs()

static void emitGraphAttrs ( Agraph_t G)
static

Definition at line 601 of file gv2gml.c.

References agnxtattr(), AGRAPH, agxget(), emitAttr(), G, s::name, and NULL.

Referenced by gv_to_gml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitInt()

static void emitInt ( char *  name,
int  value,
int  ix 
)
static

Definition at line 133 of file gv2gml.c.

References indent(), and outFile.

Referenced by emitEdgeAttrs(), and emitNodeAttrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitNode()

static void emitNode ( Agraph_t G,
Agnode_t n 
)
static

Definition at line 418 of file gv2gml.c.

References agbindrec(), agnameof(), emitNodeAttrs(), G, ID, and outFile.

Referenced by gv_to_gml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitNodeAttrs()

static void emitNodeAttrs ( Agraph_t G,
Agnode_t np,
int  ix 
)
static

Definition at line 236 of file gv2gml.c.

References agnameof(), AGNODE, agnxtattr(), agxget(), DASH, DOT, emitAttr(), emitInt(), emitReal(), FILL, node_attrs::fill, node_attrs::flags, node_attrs::fontColor, node_attrs::fontName, node_attrs::fontSize, G, node_attrs::h, H_SET, node_attrs::image, INVIS, label(), LINE, s::name, NULL, outFile, node_attrs::outline, node_attrs::outlineStyle, parseStyle(), POS_SET, streq(), node_attrs::type, node_attrs::w, W_SET, node_attrs::width, node_attrs::x, node_attrs::y, and yworks.

Referenced by emitNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitPoint()

static void emitPoint ( double  x,
double  y,
int  ix 
)
static

Definition at line 143 of file gv2gml.c.

References indent(), and outFile.

Referenced by emitSpline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitReal()

static void emitReal ( char *  name,
double  value,
int  ix 
)
static

Definition at line 138 of file gv2gml.c.

References indent(), and outFile.

Referenced by emitNodeAttrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitSpline()

static void emitSpline ( char *  s,
int  ix 
)
static

Definition at line 188 of file gv2gml.c.

References arrowEnd(), emitPoint(), indent(), outFile, and readPoint().

Referenced by emitEdgeAttrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gv_to_gml()

static void gv_to_gml ( Agraph_t G)
static

Definition at line 612 of file gv2gml.c.

References agfstnode(), agfstout(), agisdirected(), agnxtnode(), agnxtout(), emitEdge(), emitGraphAttrs(), emitNode(), G, and outFile.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indent()

static void indent ( int  ix)
static

Definition at line 96 of file gv2gml.c.

References outFile.

Referenced by emitAttr(), emitInt(), emitPoint(), emitReal(), and emitSpline().

Here is the caller graph for this function:

◆ initargs()

static void initargs ( int  argc,
char **  argv 
)
static

Definition at line 662 of file gv2gml.c.

References CmdName, cmdName(), Files, NULL, openFile(), outFile, UNREACHABLE, usage, and yworks.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNumber()

static bool isNumber ( char *  s)
static

Definition at line 102 of file gv2gml.c.

References gv_isspace().

Referenced by emitAttr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 705 of file gv2gml.c.

References agclose(), Files, G, graphviz_exit(), gv_to_gml(), initargs(), newIngraph(), nextGraph(), outFile, and prev.

Here is the call graph for this function:

◆ parseStyle()

static int parseStyle ( char *  s)
static

Definition at line 115 of file gv2gml.c.

References BOLD, DASH, DOT, FILL, flags, INVIS, LINE, strview_str_eq(), tok(), tok_end(), tok_get(), and tok_next().

Referenced by emitEdgeAttrs(), and emitNodeAttrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ put()

static int put ( void *  stream,
const char *  s 
)
inlinestatic

Definition at line 210 of file gv2gml.c.

Referenced by xml_puts().

Here is the caller graph for this function:

◆ readPoint()

static char * readPoint ( char *  s,
double *  xp,
double *  yp 
)
static

Definition at line 158 of file gv2gml.c.

References NULL, and skipWS().

Referenced by arrowEnd(), and emitSpline().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ skipWS()

static char * skipWS ( char *  s)
static

Definition at line 149 of file gv2gml.c.

References gv_isspace().

Referenced by arrowEnd(), and readPoint().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ usage()

static void usage ( int  v)
static

Definition at line 644 of file gv2gml.c.

References CmdName, graphviz_exit(), and useString.

Here is the call graph for this function:

◆ xml_puts()

static int xml_puts ( FILE *  stream,
const char *  s 
)
inlinestatic

Definition at line 215 of file gv2gml.c.

References xml_flags_t::dash, flags, put(), and xml_escape().

Referenced by emitAttr().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ CmdName

char* CmdName
static

Definition at line 40 of file gv2gml.c.

Referenced by initargs(), and usage().

◆ Files

char** Files
static

Definition at line 41 of file gv2gml.c.

Referenced by initargs(), and main().

◆ id

◆ outFile

◆ useString

char* useString
static
Initial value:
= "Usage: %s [-y] [-?] <files>\n\
-o<file> : output to <file> (stdout)\n\
-y : output yWorks.com GML variant\n\
-? - print usage\n\
If no files are specified, stdin is used\n"

Definition at line 638 of file gv2gml.c.

Referenced by usage().

◆ yworks

bool yworks
static

Definition at line 43 of file gv2gml.c.

Referenced by emitEdgeAttrs(), emitNodeAttrs(), and initargs().