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
62 for (i =
Level; i > 0; i--)
69 return gv_isalnum(c) || c ==
'.' || c ==
'-' || !isascii(c);
116 int cnt = 0, dotcnt = 0;
117 bool needs_quotes =
false;
118 bool part_of_escape =
false;
120 bool backslash_pending =
false;
121 static const char *tokenlist[]
122 = {
"node",
"edge",
"strict",
"graph",
"digraph",
"subgraph",
133 maybe_num =
gv_isdigit(uc) || uc ==
'.' || uc ==
'-';
135 if (uc ==
'\"' && !part_of_escape) {
138 }
else if (!part_of_escape &&
is_escape(&
s[-1])) {
140 part_of_escape =
true;
141 }
else if (maybe_num) {
148 else if (uc ==
'.') {
158 part_of_escape =
false;
160 else if (!(
gv_isalnum(uc) || uc ==
'_' || !isascii(uc))) {
162 part_of_escape =
false;
164 part_of_escape =
false;
178 backslash_pending =
false;
187 backslash_pending =
true;
194 if (needs_quotes || (
cnt == 1 && (*arg ==
'.' || *arg ==
'-')))
200 if (!strcasecmp(*
tok, arg))
210 sprintf(buf,
"<%s>", arg);
230 static size_t len = 0;
233 req =
MAX(2 * strlen(
str) + 2, BUFSIZ);
235 char *r = realloc(rv, req);
342 char *name, *sep, *kind, *strict;
370 if (root || hasName) {
410 const char *
const name =
agnameof(g);
425 for (i = 0; i < n; i++)
426 if (sdata->
str[i] && pdata->
str[i]
427 && strcmp(sdata->
str[i], pdata->
str[i]))
511 for (sym =
dtfirst(defdict); sym; sym =
dtnext(defdict, sym)) {
549 char buf[
sizeof(
"__SUSPECT") + 20];
550 snprintf(buf,
sizeof(buf),
"_%" PRIu64
"_SUSPECT",
AGID(n));
572 return ioput(g, ofile,
";\n");
605 char *
s = strchr(val,
':');
646 return ioput(g, ofile,
";\n");
697 s =
agget(g,
"linelength");
699 unsigned long len = strtoul(
s,
NULL, 10);
709 return AGDISC(g, io)->flush(ofile);
718 ix0 =
subgdfs(subg, ix0, wr_info);
static void * gv_calloc(size_t nmemb, size_t size)
CDT_API int dtsize(Dt_t *)
CDT_API Dt_t * dtview(Dt_t *, Dt_t *)
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 * 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)
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 *)
char * agstrcanon(char *arg, char *buf)
int agstrfree(Agraph_t *, const char *, bool is_html)
char * agstrdup(Agraph_t *, const char *)
returns a pointer to a reference-counted copy of the argument string, creating one if necessary
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
Agclos_t * clos
shared resources
uint64_t * node_last_written
uint64_t * preorder_number
uint64_t * edge_last_written
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 int write_canonstr(Agraph_t *g, iochan_t *ofile, char *str, bool known)
static bool not_default_attrs(Agraph_t *g, Agnode_t *n)
static uint64_t subgdfs(Agraph_t *g, uint64_t ix, write_info_t *wr_info)
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 void set_attrwf(Agraph_t *g, bool toplevel, bool value)
static int write_nodename(Agnode_t *n, iochan_t *ofile)
static bool is_escape(const char *str)
static void after_write(write_info_t)
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(Agraph_t *subg, Agedge_t *e, iochan_t *ofile, Dict_t *d, write_info_t *wr_info)
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_body(Agraph_t *g, iochan_t *ofile, write_info_t *wr_info)
static bool is_id_char(char c)
static bool write_node_test(Agraph_t *g, Agnode_t *n, write_info_t *wr_info)
static Agsym_t * Tailport
static int write_subgs(Agraph_t *g, iochan_t *ofile, write_info_t *wr_info)
static char * getoutputbuffer(const char *str)
static int write_nondefault_attrs(void *obj, iochan_t *ofile, Dict_t *defdict)
static bool write_edge_test(Agraph_t *g, Agedge_t *e, write_info_t *wr_info)
static char * agcanonhtmlstr(const char *arg, char *buf)
static int write_node(Agraph_t *subg, Agnode_t *n, iochan_t *ofile, Dict_t *d, write_info_t *wr_info)
static int Max_outputline
static write_info_t before_write(Agraph_t *)
static int write_hdr(Agraph_t *g, iochan_t *ofile, bool top)