bool CFrmSettings::createLayout() { rdr_t rdr; //first attach attributes to graph int _pos = graphData.indexOf(tr("{")); graphData.replace(_pos, 1, "{" + WIDGET(QTextEdit, teAttributes)->toPlainText()); /* Reset line number and file name; * If known, might want to use real name */ agsetfile((char*)"<gvedit>"); QByteArray bytes = graphData.toUtf8(); rdr.data = bytes.constData(); rdr.len = strlen(rdr.data); rdr.cur = 0; graph = agmemread(rdr.data); if (!graph) return false; if (agerrors()) { agclose(graph); graph = NULL; return false; } Agraph_t *G = this->graph; QString layout; layout=WIDGET(QComboBox, cbLayout)->currentText(); gvLayout(gvc, G, (char *)layout.toUtf8().constData()); /* library function */ return true; }
/* nextFile: * Set next available file. * If Files is NULL, we just read from stdin. */ static void nextFile(ingraph_state * sp) { void *rv = NULL; char *fname; if (sp->u.Files == NULL) { if (sp->ctr++ == 0) { rv = sp->fns->dflt; } } else { while ((fname = sp->u.Files[sp->ctr++])) { if (*fname == '-') { rv = sp->fns->dflt; break; } else if ((rv = sp->fns->openf(fname)) != 0) break; else { fprintf(stderr, "Can't open %s\n", sp->u.Files[sp->ctr - 1]); sp->errors++; } } } if (rv) agsetfile(fileName(sp)); sp->fp = rv; }
graph_t *gvNextInputGraph(GVC_t *gvc) { graph_t *g = NULL; static char *fn; static FILE *fp; static int fidx, gidx; GVG_t *gvg; while (!g) { if (!fp) { if (!(fn = gvc->input_filenames[0])) { if (fidx++ == 0) fp = stdin; } else { while ((fn = gvc->input_filenames[fidx++]) && !(fp = fopen(fn, "r"))) { agerr(AGERR, "%s: can't open %s\n", gvc->common.cmdname, fn); graphviz_errors++; } } } if (fp == NULL) break; agsetfile(fn ? fn : "<stdin>"); #ifdef EXPERIMENTAL_MYFGETS g = agread_usergets(fp, myfgets); #else g = agread(fp); #endif if (g) { gvg = zmalloc(sizeof(GVG_t)); if (!gvc->gvgs) gvc->gvgs = gvg; else gvc->gvg->next = gvg; gvc->gvg = gvg; gvg->gvc = gvc; gvg->g = g; gvg->input_filename = fn; gvg->graph_index = gidx++; break; } fp = NULL; gidx = 0; } return g; }
graph_t *gvNextInputGraph(GVC_t *gvc) { graph_t *g = NULL; static char *fn; static FILE *fp; static FILE *oldfp; static int fidx, gidx; while (!g) { if (!fp) { if (!(fn = gvc->input_filenames[0])) { if (fidx++ == 0) fp = stdin; } else { while ((fn = gvc->input_filenames[fidx++]) && !(fp = fopen(fn, "r"))) { agerr(AGERR, "%s: can't open %s\n", gvc->common.cmdname, fn); graphviz_errors++; } } } if (fp == NULL) break; if (oldfp != fp) { agsetfile(fn ? fn : "<stdin>"); oldfp = fp; } #ifdef EXPERIMENTAL_MYFGETS g = agread_usergets(fp, myfgets); #else g = agread(fp,NIL(Agdisc_t*)); #endif if (g) { gvg_init(gvc, g, fn, gidx++); break; } if (fp != stdin) fclose (fp); fp = NULL; gidx = 0; } return g; }
FILE * next_input_file(void) { static int ctr = 0; FILE *rv = NULL; if (Files[0] == NULL) { if (ctr++ == 0) rv = stdin; } else { rv = NULL; while (Files[ctr]) { if ((rv = fopen(Files[ctr++],"r"))) break; else { agerr(AGERR, "%s: can't open %s\n",CmdName,Files[ctr-1]); graphviz_errors++; } } } if (rv) agsetfile (Files[0]?Files[ctr-1]:"<stdin>"); return rv; }