Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
gvprmain.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
12/*
13 * gvpr: graph pattern recognizer
14 *
15 * Written by Emden Gansner
16 */
17
18
19#include "config.h"
20#include <limits.h>
21#include <stddef.h>
22#include <stdio.h>
23
24#include <cgraph/cgraph.h>
25#include <cgraph/exit.h>
26#include <gvpr/gvpr.h>
27
28#ifdef DEBUG
29static ssize_t outfn (void* sp, const char *buf, size_t nbyte, void* dp)
30{
31 if (nbyte > (size_t)INT_MAX) {
32 return -1;
33 }
34 return printf("<stdout>%.*s", (int)nbyte, buf);
35}
36
37static ssize_t errfn (void* sp, const char *buf, size_t nbyte, void* dp)
38{
39 if (nbyte > (size_t)INT_MAX) {
40 return -1;
41 }
42 return fprintf(stderr, "<stderr>%.*s", (int)nbyte, buf);
43}
44
45static int iofread(void *chan, char *buf, int bufsize)
46{
47 return (int)fread(buf, 1, (size_t)bufsize, chan);
48}
49
50static int ioputstr(void *chan, const char *str)
51{
52 return fputs(str, chan);
53}
54
55static int ioflush(void *chan)
56{
57 return fflush(chan);
58}
59
61
62static Agdisc_t gprDisc = { &AgIdDisc, &gprIoDisc };
63
64int
65main (int argc, char* argv[])
66{
67 Agraph_t* gs[2];
68 Agraph_t* g = agread(stdin, &gprDisc);
69 int rv;
71
72 gs[0] = g;
73 gs[1] = 0;
74 opts.ingraphs = gs;
75 opts.out = outfn;
76 opts.err = errfn;
77 opts.flags = GV_USE_OUTGRAPH;
78 opts.bindings = 0;
79
80 rv = gvpr (argc, argv, &opts);
81
82 fprintf(stderr, "rv %d\n", rv);
83
84 rv = gvpr (argc, argv, &opts);
85
86 graphviz_exit(rv);
87}
88
89#else
90int
91main (int argc, char* argv[])
92{
94 opts.ingraphs = 0;
95 opts.out = 0;
96 opts.err = 0;
97 opts.flags = GV_USE_EXIT;
98 opts.bindings = 0;
99
100 graphviz_exit(gvpr(argc, argv, &opts));
101}
102
103#endif
104
static Agiodisc_t gprIoDisc
Definition actions.c:46
abstract graph C library, Cgraph API
static Agdisc_t gprDisc
Definition compile.c:84
static NORETURN void graphviz_exit(int status)
Definition exit.h:23
Agiddisc_t AgIdDisc
Definition id.c:100
Agraph_t * agread(void *chan, Agdisc_t *disc)
constructs a new graph
Definition grammar.c:2274
static opts_t opts
Definition gvgen.c:394
int gvpr(int argc, char *argv[], gvpropts *uopts)
Definition gvpr.c:1055
graph pattern scanning and processing language API, main function gvpr
#define GV_USE_OUTGRAPH
Definition gvpr.h:49
#define GV_USE_EXIT
Definition gvpr.h:47
static ssize_t outfn(void *sp, const char *buf, size_t nbyte, void *dp)
Definition gvprpipe.c:28
agxbuf * str
Definition htmlparse.c:97
static int iofread(void *chan, char *buf, int bufsize)
Definition io.c:20
static int ioflush(void *chan)
Definition io.c:34
static int ioputstr(void *chan, const char *str)
Definition io.c:29
user's discipline
Definition cgraph.h:337
IO services.
Definition cgraph.h:327
graph or subgraph
Definition cgraph.h:425
int main()