Graphviz 14.1.3~dev.20260207.0611
Loading...
Searching...
No Matches
gvprpipe.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include "config.h"
12
13#include "smyrnadefs.h"
14#include "gvprpipe.h"
15#include <common/const.h>
16#include <limits.h>
17#include <stdio.h>
18#include <stdlib.h>
19#include <assert.h>
20#include <glade/glade.h>
21#include <gtk/gtk.h>
22#include "draw.h"
23#include "gui/gui.h"
24#include "gui/topviewsettings.h"
25#include <util/agxbuf.h>
26#include <viewport.h>
27
28#include <gvpr/gvpr.h>
29
30static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
31{
32 (void)sp;
33 (void)dp;
34
35 append_textview((GtkTextView *)
36 glade_xml_get_widget(xml, "gvprtextoutput"), buf,
37 nbyte);
38 append_textview((GtkTextView *)
39 glade_xml_get_widget(xml, "mainconsole"), buf, nbyte);
40 return (ssize_t)nbyte;
41}
42
43int run_gvpr(Agraph_t * srcGraph, size_t argc, char *argv[]) {
44 int rv = 1;
45 gvpropts opts = {0};
46 static int count;
47 agxbuf buf = {0};
48
49 opts.ingraphs = (Agraph_t *[]){srcGraph, NULL};
50 opts.out = outfn;
51 opts.err = outfn;
52 opts.flags = GV_USE_OUTGRAPH;
53
54 assert(argc <= INT_MAX);
55 rv = gvpr((int)argc, argv, &opts);
56
57 if (rv) { /* error */
58 fprintf(stderr, "Error in gvpr\n");
59 } else if (opts.n_outgraphs)
60 {
62 agxbprint(&buf, "<%d>", ++count);
63 if (opts.outgraphs[0] != view->g[view->activeGraph])
64 add_graph_to_viewport(opts.outgraphs[0], agxbuse(&buf));
65 if (opts.n_outgraphs > 1)
66 fprintf(stderr, "Warning: multiple output graphs-discarded\n");
67 for (size_t i = 1; i < opts.n_outgraphs; i++) {
68 agclose(opts.outgraphs[i]);
69 }
70 } else
71 {
72 updateRecord (srcGraph);
74 }
75 agxbfree(&buf);
76 return rv;
77}
Dynamically expanding string buffers.
static void agxbfree(agxbuf *xb)
free any malloced resources
Definition agxbuf.h:97
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
Definition agxbuf.h:252
static WUR char * agxbuse(agxbuf *xb)
Definition agxbuf.h:325
node NULL
Definition grammar.y:181
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Definition graph.c:97
GladeXML * xml
Definition gui.c:24
void append_textview(GtkTextView *textv, const char *s, size_t bytes)
Definition gui.c:106
static opts_t opts
Definition gvgen.c:415
int gvpr(int argc, char *argv[], gvpropts *uopts)
Definition gvpr.c:1060
graph pattern scanning and processing language API, main function gvpr
#define GV_USE_OUTGRAPH
Definition gvpr.h:49
static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
Definition gvprpipe.c:30
int run_gvpr(Agraph_t *srcGraph, size_t argc, char *argv[])
Definition gvprpipe.c:43
ViewInfo * view
Definition viewport.c:40
graph or subgraph
Definition cgraph.h:424
Agraph_t ** g
Definition smyrnadefs.h:288
int activeGraph
Definition smyrnadefs.h:292
void update_graph_from_settings(Agraph_t *g)
void updateRecord(Agraph_t *g)
Definition viewport.c:357
void refreshViewport(void)
Definition viewport.c:394
int add_graph_to_viewport(Agraph_t *graph, char *id)
Definition viewport.c:414