30#define EMPTY(s) (((s) == 0) || (s)[0] == '\0')
31#define MAX(a,b) ((a)>(b)?(a):(b))
32#define CHKRV(v) {if ((v) == EOF) return EOF;}
42#define MAX_OUTPUTLINE 128
43#define MIN_OUTPUTLINE 60
52 for (i =
Level; i > 0; i--)
59 return gv_isalnum(c) || c ==
'.' || c ==
'-' || !isascii(c);
106 int cnt = 0, dotcnt = 0;
107 bool needs_quotes =
false;
108 bool part_of_escape =
false;
110 bool backslash_pending =
false;
111 static const char *tokenlist[]
112 = {
"node",
"edge",
"strict",
"graph",
"digraph",
"subgraph",
123 maybe_num =
gv_isdigit(uc) || uc ==
'.' || uc ==
'-';
125 if (uc ==
'\"' && !part_of_escape) {
128 }
else if (!part_of_escape &&
is_escape(&
s[-1])) {
130 part_of_escape =
true;
131 }
else if (maybe_num) {
138 else if (uc ==
'.') {
148 part_of_escape =
false;
150 else if (!(
gv_isalnum(uc) || uc ==
'_' || !isascii(uc))) {
152 part_of_escape =
false;
154 part_of_escape =
false;
168 backslash_pending =
false;
177 backslash_pending =
true;
184 if (needs_quotes || (
cnt == 1 && (*arg ==
'.' || *arg ==
'-')))
190 if (!strcasecmp(*
tok, arg))
200 sprintf(buf,
"<%s>", arg);
220 static size_t len = 0;
223 req =
MAX(2 * strlen(
str) + 2, BUFSIZ);
225 char *r = realloc(rv, req);
346 char *name, *sep, *kind, *strict;
374 if (root || hasName) {
414 const char *
const name =
agnameof(g);
429 for (i = 0; i < n; i++)
430 if (sdata->
str[i] && pdata->
str[i]
431 && strcmp(sdata->
str[i], pdata->
str[i]))
444 Agraphs_t *subgs =
g_seq2(g);
446 for (
size_t i = 0; i < Agraphs_size(subgs); ++i) {
447 Agraph_t *subg = Agraphs_get(subgs, i);
543 for (sym =
dtfirst(defdict); sym; sym =
dtnext(defdict, sym)) {
581 char buf[
sizeof(
"__SUSPECT") + 20];
582 snprintf(buf,
sizeof(buf),
"_%" PRIu64
"_SUSPECT",
AGID(n));
602 return ioput(g, ofile,
";\n");
635 char *
s = strchr(val,
':');
650 Agraphs_t *subgs =
g_seq2(g);
653 for (
size_t i = 0; i < Agraphs_size(subgs); ++i) {
654 Agraph_t *subg = Agraphs_get(subgs, i);
682 return ioput(g, ofile,
";\n");
734 s =
agget(g,
"linelength");
736 unsigned long len = strtoul(
s,
NULL, 10);
745 return AGDISC(g, io)->flush(ofile);
CDT_API int dtsize(Dt_t *)
CDT_API Dt_t * dtview(Dt_t *, Dt_t *)
static Agraphs_t * g_seq2(Agraph_t *g)
static double len(glCompPoint p)
static int cnt(Dict_t *d, Dtlink_t **set)
Agattr_t * agattrrec(void *obj)
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
char * agget(void *obj, char *name)
Agdatadict_t * agdatadict(Agraph_t *g, bool cflag)
char * agxget(void *obj, Agsym_t *sym)
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
int agisdirected(Agraph_t *g)
int agisstrict(Agraph_t *g)
int agwrite(Agraph_t *g, void *ofile)
Return 0 on success, EOF on failure.
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
#define AGID(obj)
returns the unique integer ID associated with the object
uint64_t IDTYPE
unique per main graph ID
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Agraph_t * agroot(void *obj)
int aghtmlstr(const char *)
int agstrfree(Agraph_t *, const char *)
char * agstrcanon(char *arg, char *buf)
char * agstrdup(Agraph_t *, const char *)
returns a pointer to a reference-counted copy of the argument string, creating one if necessary
char * agcanon(char *str, int html)
char * agcanonStr(char *str)
Agraph_t * agparent(Agraph_t *g)
Agraph_t * agfstsubg(Agraph_t *g)
Agraph_t * agnxtsubg(Agraph_t *subg)
replacements for ctype.h functions
static bool gv_isalnum(int c)
static bool gv_isdigit(int c)
textitem scanner parser str
static Agedge_t * top(edge_stack_t *sp)
platform abstraction for case-insensitive string functions
string attribute container
char ** str
the attribute string values indexed by Agsym_s.id
struct Agdatadict_s::@64 dict
static tok_t tok(const char *input, const char *separators)
begin tokenization of a new string
static bool is_anonymous(Agraph_t *g)
static Agsym_t * Headport
static bool write_node_test(Agraph_t *g, Agnode_t *n, uint64_t pred_id)
static bool write_edge_test(Agraph_t *g, Agedge_t *e)
static bool not_default_attrs(Agraph_t *g, Agnode_t *n)
static bool has_no_predecessor_below(Agraph_t *g, Agnode_t *n, uint64_t val)
static int ioput(Agraph_t *g, iochan_t *ofile, char *str)
static char * _agstrcanon(char *arg, char *buf)
static int attrs_written(void *obj)
static int write_dicts(Agraph_t *g, iochan_t *ofile, bool top)
static int write_port(Agedge_t *e, iochan_t *ofile, Agsym_t *port)
static int write_dict(Agraph_t *g, iochan_t *ofile, char *name, Dict_t *dict, bool top)
static int write_canonstr(Agraph_t *g, iochan_t *ofile, char *str)
static bool node_in_subg(Agraph_t *g, Agnode_t *n)
static void set_attrwf(Agraph_t *g, bool toplevel, bool value)
static int write_edge(Agedge_t *e, iochan_t *ofile, Dict_t *d)
static int write_nodename(Agnode_t *n, iochan_t *ofile)
static bool is_escape(const char *str)
static int write_trl(Agraph_t *g, iochan_t *ofile)
static bool has_no_edges(Agraph_t *g, Agnode_t *n)
static bool irrelevant_subgraph(Agraph_t *g)
static int write_edge_name(Agedge_t *e, iochan_t *ofile, bool terminate)
static int indent(Agraph_t *g, iochan_t *ofile)
static int _write_canonstr(Agraph_t *g, iochan_t *ofile, char *str, bool chk)
static int write_subgs(Agraph_t *g, iochan_t *ofile)
static bool is_id_char(char c)
static Agsym_t * Tailport
static char * getoutputbuffer(const char *str)
static int write_nondefault_attrs(void *obj, iochan_t *ofile, Dict_t *defdict)
static int write_body(Agraph_t *g, iochan_t *ofile)
static char * agcanonhtmlstr(const char *arg, char *buf)
static int write_node(Agnode_t *n, iochan_t *ofile, Dict_t *d)
static int Max_outputline
static int write_hdr(Agraph_t *g, iochan_t *ofile, bool top)