1 /*------------------------------------------------------------\
2 |                                                             |
3 | This file is part of the Alliance CAD System Copyright      |
4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie|
5 |                                                             |
6 | Home page      : http://www-asim.lip6.fr/alliance/          |
7 | E-mail         : mailto:alliance-users@asim.lip6.fr       |
8 |                                                             |
9 | This progam is  free software; you can redistribute it      |
10 | and/or modify it under the  terms of the GNU Library General|
11 | Public License as published by the Free Software Foundation |
12 | either version 2 of the License, or (at your option) any    |
13 | later version.                                              |
14 |                                                             |
15 | Alliance VLSI  CAD System  is distributed  in the hope that |
16 | it  will be useful, but WITHOUT  ANY WARRANTY;              |
17 | without even the  implied warranty of MERCHANTABILITY or    |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General       |
19 | Public License for more details.                            |
20 |                                                             |
21 | You should have received a copy  of the GNU General Public  |
22 | License along with the GNU C Library; see the file COPYING. |
23 | If not, write to the Free Software Foundation, Inc.,        |
24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.                     |
25 |                                                             |
26 \------------------------------------------------------------*/
27 /*------------------------------------------------------------\
28 |                                                             |
29 | Tool    :                     Bdd                           |
30 |                                                             |
31 | File    :                  bdduser.c                        |
32 |                                                             |
33 | Date    :                   03.12.96                        |
34 |                                                             |
35 | Author  :               Jacomme Ludovic                     |
36 |                                                             |
37 \------------------------------------------------------------*/
38 /*------------------------------------------------------------\
39 |                                                             |
40 |                         Include Files                       |
41 |                                                             |
42 \------------------------------------------------------------*/
43 
44 # include "mut.h"
45 # include "aut.h"
46 # include "abl.h"
47 # include "bdd.h"
48 
49 # include <stdio.h>
50 # include "bdduser.h"
51 # include "bdderror.h"
52 
53 /*------------------------------------------------------------\
54 |                                                             |
55 |                           Constants                         |
56 |                                                             |
57 \------------------------------------------------------------*/
58 /*------------------------------------------------------------\
59 |                                                             |
60 |                            Types                            |
61 |                                                             |
62 \------------------------------------------------------------*/
63 /*------------------------------------------------------------\
64 |                                                             |
65 |                          Variables                          |
66 |                                                             |
67 \------------------------------------------------------------*/
68 /*------------------------------------------------------------\
69 |                                                             |
70 |                          Functions                          |
71 |                                                             |
72 \------------------------------------------------------------*/
73 /*------------------------------------------------------------\
74 |                                                             |
75 |                           Add Functions                     |
76 |                                                             |
77 \------------------------------------------------------------*/
78 /*------------------------------------------------------------\
79 |                                                             |
80 |                         Bdd Add  User Function              |
81 |                                                             |
82 \------------------------------------------------------------*/
83 
addbdduserfunc(BddSystem,Type,Func,Data)84 bdduserfunc *addbdduserfunc( BddSystem, Type, Func, Data )
85 
86   bddsystem *BddSystem;
87   long       Type;
88   void     (*Func)();
89   void      *Data;
90 {
91   bdduserfunc *BddUserFunc;
92 
93   setbddlocalsystem( BddSystem );
94 
95   BddUserFunc               = allocbdduserfunc();
96   BddUserFunc->NEXT         = BddLocalSystem->USER_FUNC;
97   BddLocalSystem->USER_FUNC = BddUserFunc;
98 
99   BddUserFunc->FUNC = Func;
100   BddUserFunc->DATA = Data;
101   BddUserFunc->TYPE = Type;
102 
103   return( BddUserFunc );
104 }
105 
106 /*------------------------------------------------------------\
107 |                                                             |
108 |                           Del Functions                     |
109 |                                                             |
110 \------------------------------------------------------------*/
111 /*------------------------------------------------------------\
112 |                                                             |
113 |                         Bdd Del User Function               |
114 |                                                             |
115 \------------------------------------------------------------*/
116 
delbdduserfunc(BddSystem,BddUserFunc)117 int delbdduserfunc( BddSystem, BddUserFunc )
118 
119   bddsystem   *BddSystem;
120   bdduserfunc *BddUserFunc;
121 {
122   bdduserfunc  *ScanUserFunc;
123   bdduserfunc **PrevUserFunc;
124 
125   setbddlocalsystem( BddSystem );
126 
127   PrevUserFunc = &BddLocalSystem->USER_FUNC;
128 
129   for ( ScanUserFunc  = BddLocalSystem->USER_FUNC;
130         ScanUserFunc != (bdduserfunc *)0;
131         ScanUserFunc  = ScanUserFunc->NEXT )
132   {
133     if ( ScanUserFunc == BddUserFunc )
134     {
135       *PrevUserFunc = ScanUserFunc->NEXT;
136       freebdduserfunc( ScanUserFunc );
137 
138       return( 1 );
139     }
140 
141     PrevUserFunc = &ScanUserFunc->NEXT;
142   }
143 
144   return( 0 );
145 }
146 
147 /*------------------------------------------------------------\
148 |                                                             |
149 |                          Exec Functions                     |
150 |                                                             |
151 \------------------------------------------------------------*/
152 /*------------------------------------------------------------\
153 |                                                             |
154 |                         Bdd Exec User Function              |
155 |                                                             |
156 \------------------------------------------------------------*/
157 
execbdduserfunc(BddSystem,Type)158 void execbdduserfunc( BddSystem, Type )
159 
160   bddsystem *BddSystem;
161   long       Type;
162 {
163   bdduserfunc *ScanUserFunc;
164 
165   setbddlocalsystem( BddSystem );
166 
167   for ( ScanUserFunc  = BddLocalSystem->USER_FUNC;
168         ScanUserFunc != (bdduserfunc *)0;
169         ScanUserFunc  = ScanUserFunc->NEXT )
170   {
171     if ( ScanUserFunc->TYPE == Type )
172     {
173       (*ScanUserFunc->FUNC)( ScanUserFunc->DATA );
174     }
175   }
176 }
177 
178 /*------------------------------------------------------------\
179 |                                                             |
180 |                       Destroy Functions                     |
181 |                                                             |
182 \------------------------------------------------------------*/
183 /*------------------------------------------------------------\
184 |                                                             |
185 |                   Bdd Destroy User Function                 |
186 |                                                             |
187 \------------------------------------------------------------*/
188 
destroybdduserfunc(BddSystem)189 void destroybdduserfunc( BddSystem )
190 
191   bddsystem *BddSystem;
192 {
193   bdduserfunc *ScanUserFunc;
194   bdduserfunc *DelUserFunc;
195 
196   setbddlocalsystem( BddSystem );
197 
198   ScanUserFunc = BddLocalSystem->USER_FUNC;
199   BddLocalSystem->USER_FUNC = (bdduserfunc *)0;
200 
201   while ( ScanUserFunc != (bdduserfunc *)0 )
202   {
203     DelUserFunc  = ScanUserFunc;
204     ScanUserFunc = ScanUserFunc->NEXT;
205 
206     freebdduserfunc( DelUserFunc );
207   }
208 }
209