Graphviz 14.1.3~dev.20260124.0732
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 Agraph_t *gs[2];
47 static int count;
48 agxbuf buf = {0};
49
50 gs[0] = srcGraph;
51 gs[1] = 0;
52 opts.ingraphs = gs;
53 opts.out = outfn;
54 opts.err = outfn;
55 opts.flags = GV_USE_OUTGRAPH;
56
57 assert(argc <= INT_MAX);
58 rv = gvpr((int)argc, argv, &opts);
59
60 if (rv) { /* error */
61 fprintf(stderr, "Error in gvpr\n");
62 } else if (opts.n_outgraphs)
63 {
65 agxbprint(&buf, "<%d>", ++count);
66 if (opts.outgraphs[0] != view->g[view->activeGraph])
67 add_graph_to_viewport(opts.outgraphs[0], agxbuse(&buf));
68 if (opts.n_outgraphs > 1)
69 fprintf(stderr, "Warning: multiple output graphs-discarded\n");
70 for (size_t i = 1; i < opts.n_outgraphs; i++) {
71 agclose(opts.outgraphs[i]);
72 }
73 } else
74 {
75 updateRecord (srcGraph);
77 }
78 agxbfree(&buf);
79 return rv;
80}
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
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