94#define ID(n) (((Local_Agnodeinfo_t*)(n->base.data))->id)
107 if (*ep)
return false;
133static void emitInt(
char *name,
int value,
int ix) {
135 fprintf (
outFile,
"%s %d\n", name, value);
138static void emitReal(
char *name,
double value,
int ix) {
140 fprintf (
outFile,
"%s %g\n", name, value);
145 fprintf (
outFile,
"point [ x %g y %g ]\n", x, y);
163 *xp = strtod (
s, &endp);
164 if (
s == endp)
return NULL;
167 *yp = strtod (
s, &endp);
168 if (
s == endp)
return NULL;
173arrowEnd (
char* s0,
char* pfx,
int* fp,
double* xp,
double* yp)
177 if (strncmp(
s,pfx,2))
return s;
181 fprintf (stderr,
"Illegal spline end: %s\n", s0);
189 double sx, sy, ex, ey;
210static inline int put(
void *stream,
const char *
s) {
211 return fputs(
s, stream);
215static inline int xml_puts(FILE *stream,
const char *
s) {
220static void emitAttr(
char *name,
char *value,
int ix) {
223 fprintf (
outFile,
"%s %s\n", name, value);
225 fprintf(
outFile,
"%s \"", name);
241 int doLabelGraphics = 0;
247 memset(&attrs,0,
sizeof(attrs));
267 if (
streq(
"\\N", v)) {
287 attrs.
w = 72.0*atof (v);
295 attrs.
h = 72.0*atof (v);
302 if (sscanf (v,
"%lf,%lf", &x, &y) == 2) {
360 fprintf (
outFile,
" graphics [\n");
398 if (doLabelGraphics) {
399 fprintf (
outFile,
" LabelGraphics [\n");
420 fprintf(
outFile,
" node [\n id %" PRIu64
"\n name \"%s\"\n",
id,
438 int doLabelGraphics = 0;
443 memset(&attrs,0,
sizeof(attrs));
536 fprintf (
outFile,
" graphics [\n");
577 if (doLabelGraphics) {
578 fprintf (
outFile,
" LabelGraphics [\n");
594 fprintf(
outFile,
" edge [\n id %" PRIu64
"\n", (uint64_t)
AGSEQ(e));
616 fprintf (
outFile,
"graph [\n version 2\n");
618 fprintf (
outFile,
" directed 1\n");
620 fprintf (
outFile,
" directed 0\n");
639 -o<file> : output to <file> (stdout)\n\
640 -y : output yWorks.com GML variant\n\
642If no files are specified, stdin is used\n";
654 sp = strrchr(
cmd,
'/');
668 while ((c = getopt(argc, argv,
":o:y")) != -1) {
679 fprintf(stderr,
"%s: option -%c missing parameter\n",
CmdName, optopt);
686 fprintf(stderr,
"%s: option -%c unrecognized\n",
CmdName,
abstract graph C library, Cgraph API
static NORETURN void graphviz_exit(int status)
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
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)
int agisdirected(Agraph_t *g)
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
char * agnameof(void *)
returns a string descriptor for the object.
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
static void emitNode(Agraph_t *G, Agnode_t *n)
static void emitSpline(char *s, int ix)
static char * readPoint(char *s, double *xp, double *yp)
static void emitEdgeAttrs(Agraph_t *G, Agedge_t *ep, int ix)
static void emitInt(char *name, int value, int ix)
static void emitGraphAttrs(Agraph_t *G)
static void emitReal(char *name, double value, int ix)
static char * arrowEnd(char *s0, char *pfx, int *fp, double *xp, double *yp)
static int xml_puts(FILE *stream, const char *s)
static void initargs(int argc, char **argv)
static void emitNodeAttrs(Agraph_t *G, Agnode_t *np, int ix)
static int put(void *stream, const char *s)
static char * skipWS(char *s)
static void emitEdge(Agraph_t *G, Agedge_t *e)
static bool yworks
use yWorks.com variant of GML?
static void emitAttr(char *name, char *value, int ix)
static void indent(int ix)
static void gv_to_gml(Agraph_t *G)
static int parseStyle(char *s)
Simple implementation for parsing style attribute.
static bool isNumber(char *s)
Return true if input string is number.
static char * cmdName(char *cmd)
static void emitPoint(double x, double y, int ix)
replacements for ctype.h functions
static bool gv_isspace(int c)
static const char * usage
Agraph_t * nextGraph(ingraph_state *sp)
ingraph_state * newIngraph(ingraph_state *sp, char **files)
supports user-supplied data
static FILE * openFile(const char *argv0, const char *name, const char *mode)
static int label(Agnode_t *n, int nodecnt, int *edgecnt)
static bool streq(const char *a, const char *b)
are a and b equal?
implementation of Agrec_t
a non-owning string reference
state for an in-progress string tokenization
Non-owning string references.
static bool strview_str_eq(strview_t a, const char *b)
compare a string reference to a string for equality
static strview_t tok_get(const tok_t *t)
get the current token
static tok_t tok(const char *input, const char *separators)
begin tokenization of a new string
static bool tok_end(const tok_t *t)
is this tokenizer exhausted?
static void tok_next(tok_t *t)
advance to the next token in the string being scanned
graphs, nodes and edges info: Agraphinfo_t, Agnodeinfo_t and Agedgeinfo_t
int xml_escape(const char *s, xml_flags_t flags, int(*cb)(void *state, const char *s), void *state)