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

implements agwrite, agcanon, agstrcanon, and agcanonStr More...

#include <assert.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <ctype.h>
#include <cgraph/cghdr.h>
#include <inttypes.h>
#include <util/gv_ctype.h>
#include <util/strcasecmp.h>
Include dependency graph for write.c:

Go to the source code of this file.

Macros

#define EMPTY(s)   (((s) == 0) || (s)[0] == '\0')
 
#define MAX(a, b)   ((a)>(b)?(a):(b))
 
#define CHKRV(v)   {if ((v) == EOF) return EOF;}
 
#define MAX_OUTPUTLINE   128
 
#define MIN_OUTPUTLINE   60
 

Typedefs

typedef void iochan_t
 

Functions

static int ioput (Agraph_t *g, iochan_t *ofile, char *str)
 
static int write_body (Agraph_t *g, iochan_t *ofile)
 
static int indent (Agraph_t *g, iochan_t *ofile)
 
static bool is_id_char (char c)
 
static bool is_escape (const char *str)
 
static char * _agstrcanon (char *arg, char *buf)
 
static char * agcanonhtmlstr (const char *arg, char *buf)
 
char * agstrcanon (char *arg, char *buf)
 
static char * getoutputbuffer (const char *str)
 
char * agcanonStr (char *str)
 
char * agcanon (char *str, int html)
 
static int _write_canonstr (Agraph_t *g, iochan_t *ofile, char *str, bool chk)
 
static int write_canonstr (Agraph_t *g, iochan_t *ofile, char *str)
 
static int write_dict (Agraph_t *g, iochan_t *ofile, char *name, Dict_t *dict, bool top)
 
static int write_dicts (Agraph_t *g, iochan_t *ofile, bool top)
 
static int write_hdr (Agraph_t *g, iochan_t *ofile, bool top)
 
static int write_trl (Agraph_t *g, iochan_t *ofile)
 
static bool is_anonymous (Agraph_t *g)
 
static bool irrelevant_subgraph (Agraph_t *g)
 
static bool node_in_subg (Agraph_t *g, Agnode_t *n)
 
static bool has_no_edges (Agraph_t *g, Agnode_t *n)
 
static bool has_no_predecessor_below (Agraph_t *g, Agnode_t *n, uint64_t val)
 
static bool not_default_attrs (Agraph_t *g, Agnode_t *n)
 
static int write_subgs (Agraph_t *g, iochan_t *ofile)
 
static int write_edge_name (Agedge_t *e, iochan_t *ofile, bool terminate)
 
static int write_nondefault_attrs (void *obj, iochan_t *ofile, Dict_t *defdict)
 
static int write_nodename (Agnode_t *n, iochan_t *ofile)
 
static int attrs_written (void *obj)
 
static int write_node (Agnode_t *n, iochan_t *ofile, Dict_t *d)
 
static bool write_node_test (Agraph_t *g, Agnode_t *n, uint64_t pred_id)
 
static int write_port (Agedge_t *e, iochan_t *ofile, Agsym_t *port)
 
static bool write_edge_test (Agraph_t *g, Agedge_t *e)
 
static int write_edge (Agedge_t *e, iochan_t *ofile, Dict_t *d)
 
static void set_attrwf (Agraph_t *g, bool toplevel, bool value)
 
int agwrite (Agraph_t *g, void *ofile)
 Return 0 on success, EOF on failure.
 

Variables

static int Level
 
static int Max_outputline = MAX_OUTPUTLINE
 
static Agsym_tTailport
 
static Agsym_tHeadport
 

Macro Definition Documentation

◆ CHKRV

#define CHKRV (   v)    {if ((v) == EOF) return EOF;}

Definition at line 32 of file write.c.

◆ EMPTY

#define EMPTY (   s)    (((s) == 0) || (s)[0] == '\0')

Definition at line 30 of file write.c.

◆ MAX

#define MAX (   a,
 
)    ((a)>(b)?(a):(b))

Definition at line 31 of file write.c.

◆ MAX_OUTPUTLINE

#define MAX_OUTPUTLINE   128

Definition at line 42 of file write.c.

◆ MIN_OUTPUTLINE

#define MIN_OUTPUTLINE   60

Definition at line 43 of file write.c.

Typedef Documentation

◆ iochan_t

typedef void iochan_t

Definition at line 34 of file write.c.

Function Documentation

◆ _agstrcanon()

static char * _agstrcanon ( char *  arg,
char *  buf 
)
static

Definition at line 102 of file write.c.

References cnt(), EMPTY, gv_isalnum(), gv_isdigit(), is_escape(), is_id_char(), Max_outputline, NULL, and tok().

Referenced by _write_canonstr(), agcanon(), and agstrcanon().

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

◆ _write_canonstr()

static int _write_canonstr ( Agraph_t g,
iochan_t ofile,
char *  str,
bool  chk 
)
static

Definition at line 263 of file write.c.

References _agstrcanon(), agcanonStr(), getoutputbuffer(), ioput(), NULL, and str.

Referenced by write_canonstr(), and write_port().

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

◆ agcanonhtmlstr()

static char * agcanonhtmlstr ( const char *  arg,
char *  buf 
)
static

Canonicalize html strings.

Definition at line 198 of file write.c.

Referenced by agcanon(), and agstrcanon().

Here is the caller graph for this function:

◆ attrs_written()

static int attrs_written ( void *  obj)
static

Definition at line 588 of file write.c.

References AGATTRWF.

Referenced by write_edge(), and write_node().

Here is the caller graph for this function:

◆ getoutputbuffer()

static char * getoutputbuffer ( const char *  str)
static

Definition at line 217 of file write.c.

References len(), MAX, NULL, and str.

Referenced by _write_canonstr(), agcanon(), and agcanonStr().

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

◆ has_no_edges()

static bool has_no_edges ( Agraph_t g,
Agnode_t n 
)
static

Definition at line 456 of file write.c.

References agfstin(), agfstout(), and NULL.

Referenced by write_node_test().

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

◆ has_no_predecessor_below()

static bool has_no_predecessor_below ( Agraph_t g,
Agnode_t n,
uint64_t  val 
)
static

Definition at line 461 of file write.c.

References agfstin(), agnxtin(), AGSEQ, and Agedge_s::node.

Referenced by write_node_test().

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

◆ indent()

static int indent ( Agraph_t g,
iochan_t ofile 
)
static

Definition at line 49 of file write.c.

References CHKRV, ioput(), and Level.

Referenced by write_dict(), write_edge(), write_hdr(), write_node(), write_nondefault_attrs(), and write_trl().

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

◆ ioput()

static int ioput ( Agraph_t g,
iochan_t ofile,
char *  str 
)
static

Definition at line 36 of file write.c.

References AGDISC, and str.

Referenced by _write_canonstr(), indent(), write_dict(), write_edge(), write_edge_name(), write_hdr(), write_node(), write_nodename(), write_nondefault_attrs(), write_port(), and write_trl().

Here is the caller graph for this function:

◆ irrelevant_subgraph()

static bool irrelevant_subgraph ( Agraph_t g)
static

Definition at line 418 of file write.c.

References agattrrec(), agdatadict(), agparent(), agroot(), Agdatadict_s::dict, dtsize(), Agdatadict_s::e, is_anonymous(), Agdatadict_s::n, and Agattr_s::str.

Referenced by node_in_subg(), write_edge_test(), and write_subgs().

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

◆ is_anonymous()

static bool is_anonymous ( Agraph_t g)
static

is this graph unnamed?

Parameters
gGraph to inspect
Returns
True if this graph was given no explicit name

Definition at line 401 of file write.c.

References AGDISC, AGID, AgIdDisc, agnameof(), LOCALNAMEPREFIX, and NULL.

Referenced by irrelevant_subgraph().

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

◆ is_escape()

static bool is_escape ( const char *  str)
static

Definition at line 64 of file write.c.

References NULL, and str.

Referenced by _agstrcanon().

Here is the caller graph for this function:

◆ is_id_char()

static bool is_id_char ( char  c)
static

Definition at line 58 of file write.c.

References gv_isalnum().

Referenced by _agstrcanon().

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

◆ node_in_subg()

static bool node_in_subg ( Agraph_t g,
Agnode_t n 
)
static

Definition at line 442 of file write.c.

References agsubnode(), g_seq2(), and irrelevant_subgraph().

Referenced by write_node_test().

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

◆ not_default_attrs()

static bool not_default_attrs ( Agraph_t g,
Agnode_t n 
)
static

Definition at line 474 of file write.c.

References agattrrec(), Agsym_s::defval, dtfirst, dtnext, and Agsym_s::id.

Referenced by write_node_test().

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

◆ set_attrwf()

static void set_attrwf ( Agraph_t g,
bool  toplevel,
bool  value 
)
static

Definition at line 710 of file write.c.

References AGATTRWF, agfstnode(), agfstout(), agfstsubg(), agnxtnode(), agnxtout(), agnxtsubg(), and set_attrwf().

Referenced by agwrite(), and set_attrwf().

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

◆ write_body()

static int write_body ( Agraph_t g,
iochan_t ofile 
)
static

Definition at line 685 of file write.c.

References agdatadict(), agfstnode(), agfstout(), aghead, agnxtnode(), agnxtout(), AGSEQ, CHKRV, Agdatadict_s::dict, Agdatadict_s::e, Agdatadict_s::n, prev, write_edge(), write_edge_test(), write_node(), write_node_test(), and write_subgs().

Referenced by agwrite(), and write_subgs().

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

◆ write_canonstr()

static int write_canonstr ( Agraph_t g,
iochan_t ofile,
char *  str 
)
static

Definition at line 275 of file write.c.

References _write_canonstr(), agstrdup(), agstrfree(), and str.

Referenced by write_dict(), write_edge_name(), write_hdr(), write_nodename(), write_nondefault_attrs(), and write_port().

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

◆ write_dict()

static int write_dict ( Agraph_t g,
iochan_t ofile,
char *  name,
Dict_t dict,
bool  top 
)
static

Definition at line 290 of file write.c.

References CHKRV, cnt(), Agsym_s::defval, dtfirst, dtnext, dtsearch, dtview(), EMPTY, indent(), ioput(), Level, Agsym_s::name, NULL, Agsym_s::print, top(), view, and write_canonstr().

Referenced by write_dicts().

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

◆ write_dicts()

static int write_dicts ( Agraph_t g,
iochan_t ofile,
bool  top 
)
static

Definition at line 335 of file write.c.

References agdatadict(), CHKRV, Agdatadict_s::dict, Agdatadict_s::e, Agdatadict_s::g, Agdatadict_s::n, top(), and write_dict().

Referenced by write_hdr().

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

◆ write_edge()

static int write_edge ( Agedge_t e,
iochan_t ofile,
Dict_t d 
)
static

Definition at line 663 of file write.c.

References AGHEAD, agisdirected(), agraphof(), AGTAIL, attrs_written(), CHKRV, Headport, indent(), ioput(), Tailport, write_edge_name(), write_nodename(), write_nondefault_attrs(), and write_port().

Referenced by write_body().

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

◆ write_edge_name()

static int write_edge_name ( Agedge_t e,
iochan_t ofile,
bool  terminate 
)
static

Definition at line 506 of file write.c.

References agnameof(), agraphof(), CHKRV, EMPTY, ioput(), Level, and write_canonstr().

Referenced by write_edge(), and write_nondefault_attrs().

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

◆ write_edge_test()

static bool write_edge_test ( Agraph_t g,
Agedge_t e 
)
static

Definition at line 649 of file write.c.

References agsubedge(), g_seq2(), and irrelevant_subgraph().

Referenced by write_body().

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

◆ write_hdr()

static int write_hdr ( Agraph_t g,
iochan_t ofile,
bool  top 
)
static

Definition at line 345 of file write.c.

References agattr(), AGATTRWF, AGEDGE, agisstrict(), agnameof(), agparent(), CHKRV, Agraph_s::desc, Agdesc_s::directed, Headport, HEADPORT_ID, indent(), ioput(), Level, LOCALNAMEPREFIX, NULL, Tailport, TAILPORT_ID, top(), write_canonstr(), and write_dicts().

Referenced by agwrite(), and write_subgs().

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

◆ write_node()

static int write_node ( Agnode_t n,
iochan_t ofile,
Dict_t d 
)
static

Definition at line 593 of file write.c.

References agraphof(), attrs_written(), CHKRV, indent(), ioput(), write_nodename(), and write_nondefault_attrs().

Referenced by write_body().

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

◆ write_node_test()

static bool write_node_test ( Agraph_t g,
Agnode_t n,
uint64_t  pred_id 
)
static

Definition at line 609 of file write.c.

References has_no_edges(), has_no_predecessor_below(), node_in_subg(), and not_default_attrs().

Referenced by write_body().

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

◆ write_nodename()

static int write_nodename ( Agnode_t n,
iochan_t ofile 
)
static

Definition at line 571 of file write.c.

References AGID, agnameof(), agraphof(), CHKRV, ioput(), and write_canonstr().

Referenced by write_edge(), and write_node().

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

◆ write_nondefault_attrs()

static int write_nondefault_attrs ( void *  obj,
iochan_t ofile,
Dict_t defdict 
)
static

Definition at line 526 of file write.c.

References agattrrec(), AGATTRWF, AGINEDGE, AGOUTEDGE, agraphof(), AGTYPE, CHKRV, cnt(), Agsym_s::defval, dtfirst, dtnext, Headport, Agsym_s::id, indent(), ioput(), Level, Agsym_s::name, Tailport, write_canonstr(), and write_edge_name().

Referenced by write_edge(), and write_node().

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

◆ write_port()

static int write_port ( Agedge_t e,
iochan_t ofile,
Agsym_t port 
)
static

Definition at line 619 of file write.c.

References _write_canonstr(), aghtmlstr(), agraphof(), agxget(), CHKRV, ioput(), and write_canonstr().

Referenced by write_edge().

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

◆ write_subgs()

static int write_subgs ( Agraph_t g,
iochan_t ofile 
)
static

Definition at line 489 of file write.c.

References agfstsubg(), agnxtsubg(), CHKRV, irrelevant_subgraph(), write_body(), write_hdr(), write_subgs(), and write_trl().

Referenced by write_body(), and write_subgs().

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

◆ write_trl()

static int write_trl ( Agraph_t g,
iochan_t ofile 
)
static

Definition at line 388 of file write.c.

References CHKRV, indent(), ioput(), and Level.

Referenced by agwrite(), and write_subgs().

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 47 of file write.c.

Referenced by write_edge(), write_hdr(), and write_nondefault_attrs().

◆ Level

int Level
static

◆ Max_outputline

int Max_outputline = MAX_OUTPUTLINE
static

Definition at line 46 of file write.c.

Referenced by _agstrcanon(), and agwrite().

◆ Tailport

Agsym_t* Tailport
static

Definition at line 47 of file write.c.

Referenced by write_edge(), write_hdr(), and write_nondefault_attrs().