Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / yagle / yag_utillo.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : YAGLE v3.50 */
6 /* Fichier : yag_utilbeh.c */
7 /* */
8 /* (c) copyright 1993 Laboratoire MASI equipe CAO & VLSI */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
11 /* */
12 /* Auteur(s) : Anthony LESTER le : 8/05/1994 */
13 /* */
14 /* Modifie par : le : ../../.... */
15 /* Modifie par : le : ../../.... */
16 /* Modifie par : le : ../../.... */
17 /* */
18 /****************************************************************************/
19
20 #include "yag_headers.h"
21
22 static ht *loconvecht;
23 static ht *losigvecht;
24
25 void yagInitLoconVect()
26 {
27 loconvecht = addht(100);
28 }
29
30 void yagCloseLoconVect()
31 {
32 delht(loconvecht);
33 }
34
35 void yagInitLosigVect()
36 {
37 losigvecht = addht(100);
38 }
39
40 void yagCloseLosigVect()
41 {
42 delht(losigvecht);
43 }
44
45 locon_list *
46 yagAddLoconVect(ptlofig, name, ptlosig, dir, vec, pnode, user)
47 lofig_list *ptlofig;
48 char *name;
49 losig_list *ptlosig;
50 char dir;
51 int vec;
52 num_list *pnode;
53 ptype_list *user;
54 {
55 locon_list *listpos, *prevpos;
56 locon_list *newlocon;
57 char *stem;
58 char *nextname;
59 int index;
60
61 stem = vectorradical(name);
62 if (stem == name) {
63 newlocon = addlocon(ptlofig, name, ptlosig, dir);
64 }
65 else {
66 if ((listpos = (locon_list *)gethtitem(loconvecht, stem)) == (locon_list *)EMPTYHT) {
67 newlocon = addlocon(ptlofig, name, ptlosig, dir);
68 addhtitem(loconvecht, stem, (long)ptlofig->LOCON);
69 }
70 else {
71 index = vectorindex(name);
72 if ((vectorindex(listpos->NAME) < index && vec == YAG_VECDOWNTO)
73 || (vectorindex(listpos->NAME) > index && vec == YAG_VECTO)) {
74 if (listpos == ptlofig->LOCON) {
75 newlocon = addlocon(ptlofig, name, ptlosig, dir);
76 }
77 else {
78 for (prevpos = ptlofig->LOCON; prevpos->NEXT != listpos; prevpos = prevpos->NEXT);
79 newlocon = addlocon(ptlofig, name, ptlosig, dir);
80 ptlofig->LOCON = ptlofig->LOCON->NEXT;
81 prevpos->NEXT = newlocon;
82 newlocon->NEXT = listpos;
83 }
84 sethtitem(loconvecht, stem, (long)newlocon);
85 }
86 else {
87 for (prevpos = listpos; prevpos->NEXT != NULL; prevpos = prevpos->NEXT) {
88 nextname = prevpos->NEXT->NAME;
89 if ((vectorindex(nextname) < index && vec == YAG_VECDOWNTO)
90 || (vectorindex(nextname) > index && vec == YAG_VECTO)
91 || vectorradical(nextname) != stem) break;
92 }
93 newlocon = addlocon(ptlofig, name, ptlosig, dir);
94 ptlofig->LOCON = ptlofig->LOCON->NEXT;
95 newlocon->NEXT = prevpos->NEXT;
96 prevpos->NEXT = newlocon;
97 }
98 }
99 }
100 newlocon->PNODE = pnode;
101 newlocon->USER = user;
102 return newlocon;
103 }
104
105 void
106 yagAddGivenLoconVect(ptlofig, ptlocon, vec)
107 lofig_list *ptlofig;
108 locon_list *ptlocon;
109 int vec;
110 {
111 locon_list *listpos, *prevpos;
112 char *stem;
113 char *nextname;
114 int index;
115
116 stem = vectorradical(ptlocon->NAME);
117 if (stem == ptlocon->NAME) {
118 ptlocon->NEXT = ptlofig->LOCON;
119 ptlofig->LOCON = ptlocon;
120 }
121 else {
122 if ((listpos = (locon_list *)gethtitem(loconvecht, stem)) == (locon_list *)EMPTYHT) {
123 ptlocon->NEXT = ptlofig->LOCON;
124 ptlofig->LOCON = ptlocon;
125 addhtitem(loconvecht, stem, (long)ptlocon);
126 }
127 else {
128 index = vectorindex(ptlocon->NAME);
129 if ((vectorindex(listpos->NAME) < index && vec == YAG_VECDOWNTO)
130 || (vectorindex(listpos->NAME) > index && vec == YAG_VECTO)) {
131 if (listpos == ptlofig->LOCON) {
132 ptlocon->NEXT = ptlofig->LOCON;
133 ptlofig->LOCON = ptlocon;
134 }
135 else {
136 for (prevpos = ptlofig->LOCON; prevpos->NEXT != listpos; prevpos = prevpos->NEXT);
137 prevpos->NEXT = ptlocon;
138 ptlocon->NEXT = listpos;
139 }
140 sethtitem(loconvecht, stem, (long)ptlocon);
141 }
142 else {
143 for (prevpos = listpos; prevpos->NEXT != NULL; prevpos = prevpos->NEXT) {
144 nextname = prevpos->NEXT->NAME;
145 if ((vectorindex(nextname) < index && vec == YAG_VECDOWNTO)
146 || (vectorindex(nextname) > index && vec == YAG_VECTO)
147 || vectorradical(nextname) != stem) break;
148 }
149 ptlocon->NEXT = prevpos->NEXT;
150 prevpos->NEXT = ptlocon;
151 }
152 }
153 }
154 }
155
156 losig_list *
157 yagAddLosigVect(ptlofig, sigindex, ptnamechain, type)
158 lofig_list *ptlofig;
159 long sigindex;
160 chain_list *ptnamechain;
161 char type;
162 {
163 losig_list *listpos, *prevpos;
164 losig_list *newlosig;
165 char *name;
166 char *stem;
167 char *nextname;
168 int index;
169
170 newlosig = addlosig(ptlofig, sigindex, ptnamechain, type);
171 name = getsigname(newlosig);
172 stem = vectorradical(name);
173
174 if (stem == name) {
175 return newlosig;
176 }
177 else {
178 if ((listpos = (losig_list *)gethtitem(losigvecht, stem)) == (losig_list *)EMPTYHT) {
179 addhtitem(losigvecht, stem, (long)newlosig);
180 }
181 else {
182 index = vectorindex(name);
183 if (vectorindex(getsigname(listpos)) > index) {
184 if (listpos != ptlofig->LOSIG->NEXT) {
185 for (prevpos = ptlofig->LOSIG; prevpos->NEXT != listpos; prevpos = prevpos->NEXT);
186 ptlofig->LOSIG = ptlofig->LOSIG->NEXT;
187 prevpos->NEXT = newlosig;
188 newlosig->NEXT = listpos;
189 }
190 sethtitem(losigvecht, stem, (long)newlosig);
191 }
192 else {
193 for (prevpos = listpos; prevpos->NEXT != NULL; prevpos = prevpos->NEXT) {
194 nextname = getsigname(prevpos->NEXT);
195 if (vectorindex(nextname) > index || vectorradical(nextname) != stem) break;
196 }
197 ptlofig->LOSIG = ptlofig->LOSIG->NEXT;
198 newlosig->NEXT = prevpos->NEXT;
199 prevpos->NEXT = newlosig;
200 }
201 }
202 }
203 return newlosig;
204 }