~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to agraph/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This software may only be used by you under license from AT&T Corp.
 
3
    ("AT&T").  A copy of AT&T's Source Code Agreement is available at
 
4
    AT&T's Internet website having the URL:
 
5
    <http://www.research.att.com/sw/tools/graphviz/license/source.html>
 
6
    If you received this software without first entering into a license
 
7
    with AT&T, you have an infringing copy of this software and cannot use
 
8
    it without violating AT&T's intellectual property rights.
 
9
*/
 
10
#pragma prototyped
 
11
 
 
12
#include <stdio.h>
 
13
#include <agraph.h>
 
14
 
 
15
#ifdef DMALLOC
 
16
#include "dmalloc.h"
 
17
#endif
 
18
 
 
19
static void prstats(Agraph_t  *g, int verbose);
 
20
static void do_it(Agraph_t *g, int dostat);
 
21
 
 
22
 
 
23
static void my_ins(Agobj_t *obj, void *context)
 
24
{
 
25
        Agnode_t        *n;
 
26
 
 
27
        if (AGTYPE(obj) == AGNODE) {
 
28
                n = (Agnode_t*)obj;
 
29
                fprintf(stderr,"%s initialized with label %s\n", agnameof(n), agget(n,"label") );
 
30
        }
 
31
}
 
32
 
 
33
static Agcbdisc_t mydisc = { {0,0,0}, {my_ins,0,0}, {0,0,0} };
 
34
 
 
35
main(int argc, char **argv)
 
36
{
 
37
        Agraph_t        *g,*prev;
 
38
        int                     dostat;
 
39
 
 
40
        if (argc > 1) dostat = atoi(argv[1]);
 
41
        else dostat = 0;
 
42
 
 
43
        prev = agopen("some_name",Agdirected, NIL(Agdisc_t*));
 
44
        agcallbacks(prev,FALSE);
 
45
        agpushdisc(prev,&mydisc,NIL(void*));
 
46
        while (g = agconcat(prev,stdin,NIL(Agdisc_t*))) {
 
47
                /*do_it(g, dostat);*/
 
48
        }
 
49
        /*agwrite(prev,stdout);*/
 
50
        fprintf(stderr,"ready to go, computer fans\n");
 
51
        agcallbacks(prev,TRUE);
 
52
        agclose(prev);
 
53
        return 1;
 
54
}
 
55
 
 
56
static void prstats(Agraph_t *g, int verbose)
 
57
{
 
58
#ifdef HAVE_VMALLOC
 
59
        Vmstat_t        ss,*s;
 
60
        vmstat(g->cmn->heap,&ss);
 
61
        s = &ss;
 
62
if (verbose)
 
63
        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",
 
64
                s->n_busy, s->n_free, s->s_busy, s->s_free, s->m_busy, s->m_free,
 
65
                s->n_seg, s->extent);
 
66
else
 
67
        fprintf(stderr,"%d (%d,%d)\n",s->extent,s->s_busy,s->s_free);
 
68
#endif
 
69
}
 
70
 
 
71
static void do_it(Agraph_t *g,int dostat)
 
72
{
 
73
        if (dostat) agflatten(g,TRUE);
 
74
        agwrite(g,stdout);
 
75
        if (dostat)  prstats(g,dostat > 1);
 
76
}