int agwrite(Agraph_t * g, FILE * fp) { printdict_t *p; char *t0, *t1; /* write the graph header */ t0 = (AG_IS_STRICT(g)) ? "strict " : ""; t1 = (AG_IS_DIRECTED(g)) ? "digraph" : "graph"; if (strncmp(g->name, "_anonymous", 10)) fprintf(fp, "%s%s %s {\n", t0, t1, agcanonical(g->name)); else fprintf(fp, "%s%s {\n", t0, t1); /* write the top level attribute defs */ write_dict(g->univ->globattr, fp); write_dict(g->univ->nodeattr, fp); write_dict(g->univ->edgeattr, fp); /* write the graph contents */ p = new_printdict_t(g); write_subg(g, fp, (Agraph_t *) 0, 0, p); fprintf(fp, "}\n"); free_printdict_t(p); return ferror(fp); }
int agwrite(Agraph_t * g, FILE * fp) { printdict_t *p; if (AG.fwrite == NULL) { AG.fwrite = fwrite; /* init to system version of fwrite() */ } if (AG.ferror == NULL) { #ifdef ferror #undef ferror /* if ferror is a macro, then use our wrapper function, but * undef the macro first so it doesn't subst in "AG.ferror" */ AG.ferror = agferror; /* init to ferror macro wrapper function */ #else AG.ferror = ferror; /* init to system version of ferror() */ #endif } /* write the graph header */ agputs((AG_IS_STRICT(g)) ? "strict " : "", fp); agputs((AG_IS_DIRECTED(g)) ? "digraph" : "graph", fp); if (strncmp(g->name, "_anonymous", 10)) { agputc(' ', fp); agputs(agcanonical(g->name), fp); } agputs(" {\n", fp); /* write the top level attribute defs */ write_dict(g->univ->globattr, fp); write_dict(g->univ->nodeattr, fp); write_dict(g->univ->edgeattr, fp); /* write the graph contents */ p = new_printdict_t(g); write_subg(g, fp, (Agraph_t *) 0, 0, p); agputs("}\n", fp); free_printdict_t(p); return AG.ferror(fp); }