Graphviz  2.41.20171026.1811
main.c
Go to the documentation of this file.
1 /* $Id$ $Revision$ */
2 /* vim:set shiftwidth=4 ts=8: */
3 
4 /*************************************************************************
5  * Copyright (c) 2011 AT&T Intellectual Property
6  * All rights reserved. This program and the accompanying materials
7  * are made available under the terms of the Eclipse Public License v1.0
8  * which accompanies this distribution, and is available at
9  * http://www.eclipse.org/legal/epl-v10.html
10  *
11  * Contributors: See CVS logs. Details at http://www.graphviz.org/
12  *************************************************************************/
13 
14 #include <stdio.h>
15 #include <graphviz/cgraph.h>
16 
17 static void my_ins(Agraph_t * g, Agobj_t * obj, void *context)
18 {
19  Agnode_t *n;
20 
21  if (AGTYPE(obj) == AGNODE) {
22  n = (Agnode_t *) obj;
23  fprintf(stderr, "%s initialized with label %s\n", agnameof(n),
24  agget(n, "label"));
25  }
26 }
27 
28 static Agcbdisc_t mydisc = { {0, 0, 0}, {my_ins, 0, 0}, {0, 0, 0} };
29 
30 main(int argc, char **argv)
31 {
32  Agraph_t *g, *prev;
33  int dostat;
34 
35  if (argc > 1)
36  dostat = atoi(argv[1]);
37  else
38  dostat = 0;
39 
40  prev = agopen("some_name", Agdirected, NIL(Agdisc_t *));
41  agcallbacks(prev, FALSE);
42  agpushdisc(prev, &mydisc, NIL(void *));
43  /*agwrite(prev,stdout); */
44  fprintf(stderr, "ready to go, computer fans\n");
45  agcallbacks(prev, TRUE);
46  agclose(prev);
47  return 1;
48 }
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
Definition: graph.c:44
CGRAPH_API void agpushdisc(Agraph_t *g, Agcbdisc_t *disc, void *state)
Definition: obj.c:202
CGRAPH_API int agcallbacks(Agraph_t *g, int flag)
Definition: pend.c:286
#define AGTYPE(obj)
Definition: cgraph.h:113
char * agget(void *obj, char *name)
Definition: attr.c:428
CGRAPH_API Agdesc_t Agdirected
Definition: cgraph.h:418
#define NIL(t)
Definition: dthdr.h:13
CGRAPH_API int agclose(Agraph_t *g)
Definition: graph.c:93
CGRAPH_API char * agnameof(void *)
Definition: id.c:143
#define AGNODE
Definition: cgraph.h:101
#define FALSE
Definition: cgraph.h:35
int main(int argc, char **argv)
Definition: dot.c:95
#define TRUE
Definition: cgraph.h:38