File: main.c

package info (click to toggle)
graphviz 1.7.16-2
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 11,124 kB
  • ctags: 12,650
  • sloc: ansic: 131,002; sh: 7,483; makefile: 1,954; tcl: 1,760; yacc: 1,758; perl: 253; awk: 150; lex: 96
file content (76 lines) | stat: -rw-r--r-- 1,935 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
    This software may only be used by you under license from AT&T Corp.
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
    AT&T's Internet website having the URL:
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
    If you received this software without first entering into a license
    with AT&T, you have an infringing copy of this software and cannot use
    it without violating AT&T's intellectual property rights.
*/
#pragma prototyped

#include <stdio.h>
#include <agraph.h>

#ifdef DMALLOC
#include "dmalloc.h"
#endif

static void prstats(Agraph_t  *g, int verbose);
static void do_it(Agraph_t *g, int dostat);


static void my_ins(Agobj_t *obj, void *context)
{
	Agnode_t	*n;

	if (AGTYPE(obj) == AGNODE) {
		n = (Agnode_t*)obj;
		fprintf(stderr,"%s initialized with label %s\n", agnameof(n), agget(n,"label") );
	}
}

static Agcbdisc_t mydisc = { {0,0,0}, {my_ins,0,0}, {0,0,0} };

main(int argc, char **argv)
{
	Agraph_t	*g,*prev;
	int			dostat;

	if (argc > 1) dostat = atoi(argv[1]);
	else dostat = 0;

	prev = agopen("some_name",Agdirected, NIL(Agdisc_t*));
	agcallbacks(prev,FALSE);
	agpushdisc(prev,&mydisc,NIL(void*));
	while (g = agconcat(prev,stdin,NIL(Agdisc_t*))) {
		/*do_it(g, dostat);*/
	}
	/*agwrite(prev,stdout);*/
	fprintf(stderr,"ready to go, computer fans\n");
	agcallbacks(prev,TRUE);
	agclose(prev);
	return 1;
}

static void prstats(Agraph_t *g, int verbose)
{
#ifdef HAVE_VMALLOC
	Vmstat_t	ss,*s;
	vmstat(g->cmn->heap,&ss);
	s = &ss;
if (verbose)
	fprintf(stderr,"n_busy %d n_free %d s_busy %d s_free %d m_busy %d m_free %d n_seg %d extent %d\n",
		s->n_busy, s->n_free, s->s_busy, s->s_free, s->m_busy, s->m_free,
		s->n_seg, s->extent);
else
	fprintf(stderr,"%d (%d,%d)\n",s->extent,s->s_busy,s->s_free);
#endif
}

static void do_it(Agraph_t *g,int dostat)
{
	if (dostat) agflatten(g,TRUE);
	agwrite(g,stdout);
	if (dostat)  prstats(g,dostat > 1);
}