Graphviz 13.0.0~dev.20241220.2304
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 "smyrnadefs.h"
12#include "gvprpipe.h"
13#include <common/const.h>
14#include <limits.h>
15#include <stdio.h>
16#include <stdlib.h>
17#include <assert.h>
18#include <glade/glade.h>
19#include <gtk/gtk.h>
20#include "draw.h"
21#include "gui.h"
22#include "topviewsettings.h"
23#include <util/agxbuf.h>
24#include <viewport.h>
25
26#include <gvpr/gvpr.h>
27
28static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
29{
30 (void)sp;
31 (void)dp;
32
33 append_textview((GtkTextView *)
34 glade_xml_get_widget(xml, "gvprtextoutput"), buf,
35 nbyte);
36 append_textview((GtkTextView *)
37 glade_xml_get_widget(xml, "mainconsole"), buf, nbyte);
38 return (ssize_t)nbyte;
39}
40
41int run_gvpr(Agraph_t * srcGraph, size_t argc, char *argv[]) {
42 int rv = 1;
44 Agraph_t *gs[2];
45 static int count;
46 agxbuf buf = {0};
47
48 gs[0] = srcGraph;
49 gs[1] = 0;
50 memset (&opts, 0, sizeof(opts));
51 opts.ingraphs = gs;
52 opts.out = outfn;
53 opts.err = outfn;
54 opts.flags = GV_USE_OUTGRAPH;
55
56 assert(argc <= INT_MAX);
57 rv = gvpr((int)argc, argv, &opts);
58
59 if (rv) { /* error */
60 fprintf(stderr, "Error in gvpr\n");
61 } else if (opts.n_outgraphs)
62 {
64 agxbprint(&buf, "<%d>", ++count);
65 if (opts.outgraphs[0] != view->g[view->activeGraph])
66 add_graph_to_viewport(opts.outgraphs[0], agxbuse(&buf));
67 if (opts.n_outgraphs > 1)
68 fprintf(stderr, "Warning: multiple output graphs-discarded\n");
69 for (size_t i = 1; i < opts.n_outgraphs; i++) {
70 agclose(opts.outgraphs[i]);
71 }
72 } else
73 {
74 updateRecord (srcGraph);
76 }
77 agxbfree(&buf);
78 return rv;
79}
static void agxbfree(agxbuf *xb)
free any malloced resources
Definition agxbuf.h:78
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
Definition agxbuf.h:234
static WUR char * agxbuse(agxbuf *xb)
Definition agxbuf.h:307
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Definition graph.c:102
GladeXML * xml
Definition gui.c:22
void append_textview(GtkTextView *textv, const char *s, size_t bytes)
Definition gui.c:104
static opts_t opts
Definition gvgen.c:394
int gvpr(int argc, char *argv[], gvpropts *uopts)
Definition gvpr.c:1041
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:28
int run_gvpr(Agraph_t *srcGraph, size_t argc, char *argv[])
Definition gvprpipe.c:41
ViewInfo * view
Definition viewport.c:37
graph or subgraph
Definition cgraph.h:425
Agraph_t ** g
Definition smyrnadefs.h:296
int activeGraph
Definition smyrnadefs.h:300
void update_graph_from_settings(Agraph_t *g)
void updateRecord(Agraph_t *g)
Definition viewport.c:374
void refreshViewport(void)
Definition viewport.c:411
int add_graph_to_viewport(Agraph_t *graph, char *id)
Definition viewport.c:431