Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gv2gxl.c File Reference

DOT-GXL convert subroutines. More...

#include <common/types.h>
#include <common/utils.h>
#include "convert.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <util/agxbuf.h>
#include <util/alloc.h>
#include <util/gv_ctype.h>
#include <util/startswith.h>
Include dependency graph for gv2gxl.c:

Go to the source code of this file.

Data Structures

struct  Local_Agnodeinfo_t
 
struct  namev_t
 
struct  idv_t
 
struct  gxlstate_t
 

Macros

#define EMPTY(s)   ((s == 0) || (*s == '\0'))
 
#define SLEN(s)   (sizeof(s)-1)
 
#define GXL_ATTR   "_gxl_"
 
#define GXL_ROLE   "_gxl_role"
 
#define GXL_HYPER   "_gxl_hypergraph"
 
#define GXL_ID   "_gxl_id"
 
#define GXL_FROM   "_gxl_fromorder"
 
#define GXL_TO   "_gxl_toorder"
 
#define GXL_TYPE   "_gxl_type"
 
#define GXL_COMP   "_gxl_composite_"
 
#define GXL_LOC   "_gxl_locator_"
 
#define GXL_COMP_LEN   (SLEN(GXL_COMP))
 
#define EDGEOP   "--" /* cannot use '>'; illegal in ID in GXL */
 
#define writeval(n)   (((Local_Agnodeinfo_t*)((n)->base.data))->written)
 

Functions

static void * make_nitem (void *p, Dtdisc_t *disc)
 
static void free_iditem (void *idv)
 
static void writeBody (gxlstate_t *, Agraph_t *g, FILE *gxlFile)
 
static void iterateBody (gxlstate_t *stp, Agraph_t *g)
 
static void tabover (FILE *gxlFile)
 
static bool legalGXLName (const char *id)
 
static int put (void *stream, const char *s)
 
static int xml_puts (FILE *stream, const char *s)
 
static int xml_url_puts (FILE *f, const char *s)
 
static bool isGxlGrammar (const char *name)
 
static bool isLocatorType (const char *name)
 
static bool idexists (Dt_t *ids, char *id)
 
static char * addid (Dt_t *ids, const char *id)
 
static char * createGraphId (Dt_t *ids)
 
static char * createNodeId (Dt_t *ids)
 
static char * mapLookup (Dt_t *nm, char *name)
 
static char * nodeID (gxlstate_t *stp, Agnode_t *n)
 
static char * createEdgeId (gxlstate_t *stp, Agedge_t *e)
 
static void addToMap (Dt_t *map, char *name, char *uniqueName)
 
static void graphAttrs (FILE *gxlFile, Agraph_t *g)
 
static void edgeAttrs (FILE *gxlFile, Agedge_t *e)
 
static void printHref (FILE *gxlFile, void *n)
 
static void writeDict (FILE *gxlFile, const char *name, Dict_t *dict, bool isGraph)
 
static void writeDicts (Agraph_t *g, FILE *gxlFile)
 
static void writeHdr (gxlstate_t *stp, Agraph_t *g, FILE *gxlFile, bool top)
 
static void writeTrl (Agraph_t *g, FILE *gxlFile, bool top)
 
static void writeSubgs (gxlstate_t *stp, Agraph_t *g, FILE *gxlFile)
 
static void writeEdgeName (Agedge_t *e, FILE *gxlFile)
 
static void writeNondefaultAttr (void *obj, FILE *gxlFile, Dict_t *defdict)
 
static bool attrs_written (gxlstate_t *stp, void *obj)
 
static void writeNode (gxlstate_t *stp, Agnode_t *n, FILE *gxlFile, Dict_t *d)
 
static void writePort (Agedge_t *e, FILE *gxlFile, char *name)
 
static bool writeEdgeTest (Agraph_t *g, Agedge_t *e)
 
static void writeEdge (gxlstate_t *stp, Agedge_t *e, FILE *gxlFile, Dict_t *d)
 
static void iterateHdr (gxlstate_t *stp, Agraph_t *g)
 
static void iterate_subgs (gxlstate_t *stp, Agraph_t *g)
 
static gxlstate_t initState (Agraph_t *g)
 
static void freeState (gxlstate_t stp)
 
void gv_to_gxl (Agraph_t *g, FILE *gxlFile)
 

Variables

static int Level
 
static Agsym_tTailport
 
static Agsym_tHeadport
 
static Dtdisc_t nameDisc
 
static Dtdisc_t idDisc
 

Macro Definition Documentation

◆ EDGEOP

#define EDGEOP   "--" /* cannot use '>'; illegal in ID in GXL */

Definition at line 221 of file gv2gxl.c.

◆ EMPTY

#define EMPTY (   s)    ((s == 0) || (*s == '\0'))

Definition at line 27 of file gv2gxl.c.

◆ GXL_ATTR

#define GXL_ATTR   "_gxl_"

Definition at line 30 of file gv2gxl.c.

◆ GXL_COMP

#define GXL_COMP   "_gxl_composite_"

Definition at line 37 of file gv2gxl.c.

◆ GXL_COMP_LEN

#define GXL_COMP_LEN   (SLEN(GXL_COMP))

Definition at line 40 of file gv2gxl.c.

◆ GXL_FROM

#define GXL_FROM   "_gxl_fromorder"

Definition at line 34 of file gv2gxl.c.

◆ GXL_HYPER

#define GXL_HYPER   "_gxl_hypergraph"

Definition at line 32 of file gv2gxl.c.

◆ GXL_ID

#define GXL_ID   "_gxl_id"

Definition at line 33 of file gv2gxl.c.

◆ GXL_LOC

#define GXL_LOC   "_gxl_locator_"

Definition at line 38 of file gv2gxl.c.

◆ GXL_ROLE

#define GXL_ROLE   "_gxl_role"

Definition at line 31 of file gv2gxl.c.

◆ GXL_TO

#define GXL_TO   "_gxl_toorder"

Definition at line 35 of file gv2gxl.c.

◆ GXL_TYPE

#define GXL_TYPE   "_gxl_type"

Definition at line 36 of file gv2gxl.c.

◆ SLEN

#define SLEN (   s)    (sizeof(s)-1)

Definition at line 28 of file gv2gxl.c.

◆ writeval

#define writeval (   n)    (((Local_Agnodeinfo_t*)((n)->base.data))->written)

Definition at line 672 of file gv2gxl.c.

Function Documentation

◆ addid()

static char * addid ( Dt_t ids,
const char *  id 
)
static

Definition at line 164 of file gv2gxl.c.

References dtinsert, gv_alloc(), gv_strdup(), and idv_t::name.

Referenced by createEdgeId(), createGraphId(), createNodeId(), iterateBody(), iterateHdr(), and writeHdr().

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

◆ addToMap()

static void addToMap ( Dt_t map,
char *  name,
char *  uniqueName 
)
static

Definition at line 243 of file gv2gxl.c.

References dtinsert, namev_t::name, NULL, and namev_t::unique_name.

Referenced by iterateBody(), iterateHdr(), and writeHdr().

Here is the caller graph for this function:

◆ attrs_written()

static bool attrs_written ( gxlstate_t stp,
void *  obj 
)
static

Definition at line 573 of file gv2gxl.c.

References AGATTRWF, and gxlstate_t::attrsNotWritten.

Referenced by writeEdge(), and writeNode().

Here is the caller graph for this function:

◆ createEdgeId()

static char * createEdgeId ( gxlstate_t stp,
Agedge_t e 
)
static

Definition at line 223 of file gv2gxl.c.

References addid(), AGHEAD, AGTAIL, agxbfree(), agxbprint(), agxbuse(), EDGEOP, idexists(), gxlstate_t::idList, and nodeID().

Referenced by writeEdge().

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

◆ createGraphId()

static char * createGraphId ( Dt_t ids)
static

Definition at line 172 of file gv2gxl.c.

References addid(), agxbfree(), agxbprint(), agxbuse(), and idexists().

Referenced by iterateHdr().

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

◆ createNodeId()

static char * createNodeId ( Dt_t ids)
static

Definition at line 187 of file gv2gxl.c.

References addid(), agxbfree(), agxbprint(), agxbuse(), and idexists().

Referenced by iterateBody(), and writeHdr().

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

◆ edgeAttrs()

static void edgeAttrs ( FILE *  gxlFile,
Agedge_t e 
)
static

Definition at line 267 of file gv2gxl.c.

References agget(), EMPTY, GXL_FROM, GXL_ID, GXL_TO, and xml_puts().

Referenced by writeEdge().

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

◆ free_iditem()

static void free_iditem ( void *  idv)
static

Definition at line 80 of file gv2gxl.c.

References free(), and idv_t::name.

Here is the call graph for this function:

◆ freeState()

static void freeState ( gxlstate_t  stp)
static

Definition at line 754 of file gv2gxl.c.

References dtclose(), gxlstate_t::graphMap, gxlstate_t::idList, gxlstate_t::nodeMap, and gxlstate_t::synNodeMap.

Referenced by gv_to_gxl().

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

◆ graphAttrs()

static void graphAttrs ( FILE *  gxlFile,
Agraph_t g 
)
static

Definition at line 251 of file gv2gxl.c.

References agget(), EMPTY, GXL_HYPER, GXL_ROLE, and xml_puts().

Referenced by writeHdr().

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

◆ gv_to_gxl()

void gv_to_gxl ( Agraph_t g,
FILE *  gxlFile 
)

Definition at line 761 of file gv2gxl.c.

References aginit(), AGNODE, freeState(), initState(), iterateBody(), iterateHdr(), Level, writeBody(), writeHdr(), and writeTrl().

Referenced by main().

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

◆ idexists()

static bool idexists ( Dt_t ids,
char *  id 
)
static

Definition at line 157 of file gv2gxl.c.

References dtmatch, and NULL.

Referenced by createEdgeId(), createGraphId(), createNodeId(), iterateBody(), iterateHdr(), and writeHdr().

Here is the caller graph for this function:

◆ initState()

static gxlstate_t initState ( Agraph_t g)
static

Definition at line 742 of file gv2gxl.c.

References agisdirected(), gxlstate_t::attrsNotWritten, gxlstate_t::directed, dtopen(), Dtoset, gxlstate_t::graphMap, idDisc, gxlstate_t::idList, nameDisc, gxlstate_t::nodeMap, gxlstate_t::root, and gxlstate_t::synNodeMap.

Referenced by gv_to_gxl().

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

◆ isGxlGrammar()

static bool isGxlGrammar ( const char *  name)
static

Definition at line 149 of file gv2gxl.c.

References GXL_ATTR, and startswith().

Referenced by writeDict(), and writeNondefaultAttr().

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

◆ isLocatorType()

static bool isLocatorType ( const char *  name)
static

Definition at line 153 of file gv2gxl.c.

References GXL_LOC, and startswith().

Referenced by writeDict(), and writeNondefaultAttr().

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

◆ iterate_subgs()

static void iterate_subgs ( gxlstate_t stp,
Agraph_t g 
)
static

Definition at line 706 of file gv2gxl.c.

References agfstsubg(), agnxtsubg(), iterateBody(), and iterateHdr().

Referenced by iterateBody().

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

◆ iterateBody()

static void iterateBody ( gxlstate_t stp,
Agraph_t g 
)
static

Definition at line 715 of file gv2gxl.c.

References addid(), addToMap(), agfstnode(), agfstout(), agget(), agnameof(), agnxtnode(), agnxtout(), createNodeId(), EMPTY, GXL_ID, idexists(), gxlstate_t::idList, iterate_subgs(), legalGXLName(), mapLookup(), gxlstate_t::nodeMap, and writeEdgeTest().

Referenced by gv_to_gxl(), and iterate_subgs().

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

◆ iterateHdr()

static void iterateHdr ( gxlstate_t stp,
Agraph_t g 
)
static

Definition at line 692 of file gv2gxl.c.

References addid(), addToMap(), agget(), agnameof(), createGraphId(), EMPTY, gxlstate_t::graphMap, GXL_ID, idexists(), gxlstate_t::idList, and legalGXLName().

Referenced by gv_to_gxl(), and iterate_subgs().

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

◆ legalGXLName()

static bool legalGXLName ( const char *  id)
static

Definition at line 120 of file gv2gxl.c.

References gv_isalnum(), and gv_isalpha().

Referenced by iterateBody(), iterateHdr(), and writeHdr().

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

◆ make_nitem()

static void * make_nitem ( void *  p,
Dtdisc_t disc 
)
static

Definition at line 56 of file gv2gxl.c.

References disc, gv_alloc(), namev_t::name, and namev_t::unique_name.

Here is the call graph for this function:

◆ mapLookup()

static char * mapLookup ( Dt_t nm,
char *  name 
)
static

Definition at line 202 of file gv2gxl.c.

References dtmatch, NULL, and namev_t::unique_name.

Referenced by iterateBody(), nodeID(), and writeHdr().

Here is the caller graph for this function:

◆ nodeID()

static char * nodeID ( gxlstate_t stp,
Agnode_t n 
)
static

Definition at line 213 of file gv2gxl.c.

References agnameof(), mapLookup(), and gxlstate_t::nodeMap.

Referenced by createEdgeId(), writeEdge(), and writeNode().

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

◆ printHref()

static void printHref ( FILE *  gxlFile,
void *  n 
)
static

Definition at line 290 of file gv2gxl.c.

References agget(), EMPTY, GXL_TYPE, tabover(), and xml_url_puts().

Referenced by writeEdge(), writeHdr(), and writeNode().

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 133 of file gv2gxl.c.

Referenced by xml_puts(), and xml_url_puts().

Here is the caller graph for this function:

◆ tabover()

static void tabover ( FILE *  gxlFile)
static

Definition at line 108 of file gv2gxl.c.

References Level.

Referenced by printHref(), writeDict(), writeEdge(), writeEdgeName(), writeHdr(), writeNode(), writeNondefaultAttr(), writePort(), and writeTrl().

Here is the caller graph for this function:

◆ writeBody()

static void writeBody ( gxlstate_t stp,
Agraph_t g,
FILE *  gxlFile 
)
static

Definition at line 674 of file gv2gxl.c.

References agdatadict(), agfstnode(), agfstout(), AGID, agidnode(), agnxtnode(), agnxtout(), Agdatadict_s::dict, Agdatadict_s::e, Agdatadict_s::n, gxlstate_t::root, writeEdge(), writeEdgeTest(), writeNode(), writeSubgs(), and writeval.

Referenced by gv_to_gxl(), and writeSubgs().

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

◆ writeDict()

static void writeDict ( FILE *  gxlFile,
const char *  name,
Dict_t dict,
bool  isGraph 
)
static

Definition at line 305 of file gv2gxl.c.

References Agsym_s::defval, dtfirst, dtnext, dtsearch, dtview(), EMPTY, GXL_COMP, GXL_COMP_LEN, GXL_LOC, isGxlGrammar(), isLocatorType(), NULL, startswith(), tabover(), view, xml_puts(), and xml_url_puts().

Referenced by writeDicts().

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

◆ writeDicts()

static void writeDicts ( Agraph_t g,
FILE *  gxlFile 
)
static

Definition at line 387 of file gv2gxl.c.

References agdatadict(), Agdatadict_s::dict, Agdatadict_s::e, Agdatadict_s::g, Agdatadict_s::n, and writeDict().

Referenced by writeHdr().

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

◆ writeEdge()

static void writeEdge ( gxlstate_t stp,
Agedge_t e,
FILE *  gxlFile,
Dict_t d 
)
static

Definition at line 633 of file gv2gxl.c.

References agget(), AGHEAD, AGTAIL, attrs_written(), createEdgeId(), gxlstate_t::directed, edgeAttrs(), EMPTY, GXL_ID, Level, nodeID(), printHref(), tabover(), writeEdgeName(), writeNondefaultAttr(), and writePort().

Referenced by writeBody().

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

◆ writeEdgeName()

static void writeEdgeName ( Agedge_t e,
FILE *  gxlFile 
)
static

Definition at line 483 of file gv2gxl.c.

References agnameof(), EMPTY, tabover(), and xml_puts().

Referenced by writeEdge(), and writeNondefaultAttr().

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

◆ writeEdgeTest()

static bool writeEdgeTest ( Agraph_t g,
Agedge_t e 
)
static

Definition at line 623 of file gv2gxl.c.

References agfstsubg(), agnxtsubg(), and agsubedge().

Referenced by iterateBody(), and writeBody().

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

◆ writeHdr()

static void writeHdr ( gxlstate_t stp,
Agraph_t g,
FILE *  gxlFile,
bool  top 
)
static

Definition at line 397 of file gv2gxl.c.

References addid(), addToMap(), agattr(), AGATTRWF, AGEDGE, agisstrict(), agnameof(), agparent(), agxbfree(), agxbprint(), agxbuse(), gxlstate_t::attrsNotWritten, createNodeId(), Agraph_s::desc, Agdesc_s::directed, graphAttrs(), gxlstate_t::graphMap, Headport, idexists(), gxlstate_t::idList, legalGXLName(), Level, mapLookup(), NULL, printHref(), gxlstate_t::synNodeMap, tabover(), Tailport, top(), writeDicts(), and xml_puts().

Referenced by gv_to_gxl(), and writeSubgs().

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

◆ writeNode()

static void writeNode ( gxlstate_t stp,
Agnode_t n,
FILE *  gxlFile,
Dict_t d 
)
static

Definition at line 578 of file gv2gxl.c.

References agnameof(), attrs_written(), Level, nodeID(), printHref(), tabover(), writeNondefaultAttr(), and xml_puts().

Referenced by writeBody().

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

◆ writeNondefaultAttr()

static void writeNondefaultAttr ( void *  obj,
FILE *  gxlFile,
Dict_t defdict 
)
static

Definition at line 499 of file gv2gxl.c.

References agattrrec(), AGATTRWF, aghtmlstr(), AGINEDGE, AGOUTEDGE, AGTYPE, dtfirst, dtnext, GXL_COMP, GXL_COMP_LEN, GXL_LOC, Headport, Agsym_s::id, isGxlGrammar(), isLocatorType(), startswith(), tabover(), Tailport, writeEdgeName(), xml_puts(), and xml_url_puts().

Referenced by writeEdge(), and writeNode().

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

◆ writePort()

static void writePort ( Agedge_t e,
FILE *  gxlFile,
char *  name 
)
static

Definition at line 606 of file gv2gxl.c.

References agget(), tabover(), and xml_puts().

Referenced by writeEdge().

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

◆ writeSubgs()

static void writeSubgs ( gxlstate_t stp,
Agraph_t g,
FILE *  gxlFile 
)
static

Definition at line 474 of file gv2gxl.c.

References agfstsubg(), agnxtsubg(), writeBody(), writeHdr(), and writeTrl().

Referenced by writeBody().

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

◆ writeTrl()

static void writeTrl ( Agraph_t g,
FILE *  gxlFile,
bool  top 
)
static

Definition at line 462 of file gv2gxl.c.

References agparent(), Level, tabover(), and top().

Referenced by gv_to_gxl(), and writeSubgs().

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

◆ xml_puts()

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

Definition at line 138 of file gv2gxl.c.

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

Referenced by edgeAttrs(), graphAttrs(), writeDict(), writeEdgeName(), writeHdr(), writeNode(), writeNondefaultAttr(), and writePort().

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

◆ xml_url_puts()

static int xml_url_puts ( FILE *  f,
const char *  s 
)
static

Definition at line 144 of file gv2gxl.c.

References flags, put(), and xml_escape().

Referenced by printHref(), writeDict(), and writeNondefaultAttr().

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

Variable Documentation

◆ Headport

Agsym_t * Headport
static

Definition at line 48 of file gv2gxl.c.

Referenced by writeHdr(), and writeNondefaultAttr().

◆ idDisc

Dtdisc_t idDisc
static
Initial value:
= {
offsetof(idv_t, name),
-1,
offsetof(idv_t, link),
}
node NULL
Definition grammar.y:163
static void free_iditem(void *idv)
Definition gv2gxl.c:80
Definition gv2gxl.c:75

Definition at line 86 of file gv2gxl.c.

Referenced by initState().

◆ Level

int Level
static

Definition at line 47 of file gv2gxl.c.

Referenced by gv_to_gxl(), tabover(), writeEdge(), writeHdr(), writeNode(), and writeTrl().

◆ nameDisc

Dtdisc_t nameDisc
static
Initial value:
= {
offsetof(namev_t, name),
-1,
offsetof(namev_t, link),
}
void free(void *)
static void * make_nitem(void *p, Dtdisc_t *disc)
Definition gv2gxl.c:56

Definition at line 66 of file gv2gxl.c.

Referenced by initState().

◆ Tailport

Agsym_t* Tailport
static

Definition at line 48 of file gv2gxl.c.

Referenced by writeHdr(), and writeNondefaultAttr().