33#define EMPTY(s) (((s) == 0) || (s)[0] == '\0')
34#define CHKRV(v) {if ((v) == EOF) return EOF;}
44#define MAX_OUTPUTLINE 128
45#define MIN_OUTPUTLINE 60
64 for (i = wr_info.
level; i > 0; i--)
71 return gv_isalnum(c) || c ==
'.' || c ==
'-' || !isascii(c);
118 int cnt = 0, dotcnt = 0;
119 bool needs_quotes =
false;
120 bool part_of_escape =
false;
122 bool backslash_pending =
false;
123 static const char *tokenlist[]
124 = {
"node",
"edge",
"strict",
"graph",
"digraph",
"subgraph",
135 maybe_num =
gv_isdigit(uc) || uc ==
'.' || uc ==
'-';
137 if (uc ==
'\"' && !part_of_escape) {
140 }
else if (!part_of_escape &&
is_escape(&
s[-1])) {
142 part_of_escape =
true;
143 }
else if (maybe_num) {
150 else if (uc ==
'.') {
160 part_of_escape =
false;
162 else if (!(
gv_isalnum(uc) || uc ==
'_' || !isascii(uc))) {
164 part_of_escape =
false;
166 part_of_escape =
false;
180 backslash_pending =
false;
189 backslash_pending =
true;
196 if (needs_quotes || (
cnt == 1 && (*arg ==
'.' || *arg ==
'-')))
202 if (!strcasecmp(*
tok, arg))
212 sprintf(buf,
"<%s>", arg);
234 char *
const scratch =
malloc(required);
235 if (scratch ==
NULL) {
239 char *
const canonicalized =
241 const int rc =
ioput(g, ofile, canonicalized);
321 char *name, *sep, *kind, *strict;
349 if (root || hasName) {
387 const char *
const name =
agnameof(g);
402 for (i = 0; i < n; i++)
403 if (sdata->
str[i] && pdata->
str[i]
404 && strcmp(sdata->
str[i], pdata->
str[i]))
488 for (sym =
dtfirst(defdict); sym; sym =
dtnext(defdict, sym)) {
526 char buf[
sizeof(
"__SUSPECT") + 20];
527 snprintf(buf,
sizeof(buf),
"_%" PRIu64
"_SUSPECT",
AGID(n));
549 return ioput(g, ofile,
";\n");
582 char *
s = strchr(val,
':');
615 return ioput(g, ofile,
";\n");
619 for (
size_t i = 0; i < wr_info->
n_edges; ++i) {
680 s =
agget(g,
"linelength");
682 unsigned long len = strtoul(
s,
NULL, 10);
687 if (
write_hdr(g, ofile,
true, &wr_info) == EOF) {
695 if (
write_trl(g, ofile, &wr_info) == EOF) {
701 return AGDISC(g, io)->flush(ofile);
710 ix0 =
subgdfs(subg, ix0, wr_info);
Helpers for dealing with agstrcanon
static size_t agstrcanon_bytes(const char *str)
how many bytes are needed to canonicalize the given string
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_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text 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
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
Dict_t * dict
shared dict of Agsym_s to interpret Agattr_s.str
struct Agdatadict_s::@32 dict
Agclos_t * clos
shared resources
uint64_t * node_last_written
uint64_t * preorder_number
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 int write_dict(Agraph_t *g, iochan_t *ofile, char *name, Dict_t *dict, bool top, write_info_t *wr_info)
static int write_nondefault_attrs(void *obj, iochan_t *ofile, Dict_t *defdict, write_info_t *wr_info)
static char * _agstrcanon(char *arg, char *buf)
static int attrs_written(void *obj)
static int write_edges(iochan_t *ofile, Dict_t *d, write_info_t *wr_info)
static int write_edge(Agedge_t *e, iochan_t *ofile, Dict_t *d, write_info_t *wr_info)
static int write_port(Agedge_t *e, iochan_t *ofile, Agsym_t *port)
static void set_attrwf(Agraph_t *g, bool toplevel, bool value)
static int write_nodename(Agnode_t *n, iochan_t *ofile)
static int write_edge_name(Agedge_t *e, iochan_t *ofile, bool terminate, write_info_t *wr_info)
static bool is_escape(const char *str)
static void after_write(write_info_t)
static int indent(Agraph_t *g, iochan_t *ofile, const write_info_t wr_info)
static bool has_no_edges(Agraph_t *g, Agnode_t *n)
static int write_dicts(Agraph_t *g, iochan_t *ofile, bool top, write_info_t *wr_info)
static bool irrelevant_subgraph(Agraph_t *g)
static int write_trl(Agraph_t *g, iochan_t *ofile, write_info_t *wr_info)
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 int write_hdr(Agraph_t *g, iochan_t *ofile, bool top, 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 *)