Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / yagle / genius / gen_verif_utils.c
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI Alliance */
4 /* */
5 /* Produit : GENIUS v1.00 */
6 /* Fichier : gen_verif_utils.c */
7 /* */
8 /* Auteur(s) : Francois DONNET le : 10/06/1999 */
9 /* */
10 /* (c) copyright 1999 Laboratoire MASI equipe CAO & VLSI */
11 /* Tous droits reserves */
12 /* Support : e-mail alliance-support@asim.lip6.fr */
13 /* */
14 /* */
15 /****************************************************************************/
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include MUT_H
20 #include MLO_H
21 #include API_H
22 #include AVT_H
23 #include "gen_verif_utils.h"
24
25
26
27 /***************************************************************************/
28 /* put ident at the end of the list, this element must be unique */
29 /* comparison is supposed to be on string */
30 /* if an elem has the same key, an error is dumped */
31 /***************************************************************************/
32 extern chain_list *put_inlist(ident,list)
33 tree_list *ident;
34 chain_list *list;
35 {
36 chain_list *p;
37 char *name;
38 if (!ident) {
39 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 252);
40 // fprintf(stderr,"put_inlist: NULL pointer\n");
41 EXIT(1);
42 }
43 name=getname(ident);
44
45 for (p=list;p;p=p->NEXT) {
46 if (!p->DATA) {
47 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 253);
48 // fprintf(stderr,"put_inlist: NULL pointer\n");
49 EXIT(1);
50 }
51 if (getname(p->DATA)==name) {
52 avt_errmsg(GNS_ERRMSG, "163", AVT_ERROR, FILE_NAME(ident),LINE(ident), name, LINE((tree_list*)p->DATA), FILE_NAME((tree_list*)p->DATA));
53 /*fprintf(stderr,"%s:%d: '%s' used several times, primary use line %d in file %s\n",
54 FILE_NAME(ident),LINE(ident), name, LINE((tree_list*)p->DATA), FILE_NAME((tree_list*)p->DATA));*/
55 Inc_Error();
56 return list;
57 }
58 if (!p->NEXT) {p->NEXT=addchain(NULL,ident);return list;}
59 }
60 return addchain(NULL,ident);
61 }
62
63
64 /***************************************************************************/
65 /* return the element of list wich DATA field equals DATA field of ident */
66 /* comparison is supposed to be on string */
67 /* if not found NULL is returned and an error is dumped */
68 /***************************************************************************/
69 extern tree_list *fetch_inlist(ident,list)
70 tree_list *ident;
71 chain_list *list;
72 {
73 chain_list *p;
74 char *name;
75 if (!ident) {
76 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 254);
77 // fprintf(stderr,"fetch_inlist: NULL pointer\n");
78 EXIT(1);
79 }
80 name=getname(ident);
81
82 for (p=list;p;p=p->NEXT) {
83 if (!p->DATA) {
84 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 254);
85 // fprintf(stderr,"fetch_inlist: NULL pointer\n");
86 EXIT(1);
87 }
88 if (strcasecmp(getname(p->DATA),name)==0) {
89 return p->DATA; }
90 }
91
92 avt_errmsg(GNS_ERRMSG, "164", AVT_ERROR, FILE_NAME(ident),LINE(ident), name);
93 // fprintf(stderr,"%s:%d: '%s' not defined\n",FILE_NAME(ident),LINE(ident), name);
94 Inc_Error();
95 return NULL;
96 }
97
98
99 /***************************************************************************/
100 /* put ident with a value at the TOP of the list, this element must unique */
101 /* comparison is supposed to be on string */
102 /* if an elem has the same key, an error is dumped */
103 /***************************************************************************/
104 extern ptype_list *put_value(ident,value,list)
105 int value;
106 tree_list *ident;
107 ptype_list *list;
108 {
109 ptype_list *p;
110 char *name;
111 if (!ident) {
112 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 255);
113 // fprintf(stderr,"put_value: NULL pointer\n");
114 EXIT(1);
115 }
116 name=getname(ident);
117
118 for (p=list;p;p=p->NEXT) {
119 if (!p->DATA) {
120 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 256);
121 // fprintf(stderr,"put_value: NULL pointer\n");
122 EXIT(1);
123 }
124 if (getname(p->DATA)==name) {
125 fprintf(stderr,"%s:%d: '%s' used several times, primary use line %d in file %s\n",
126 FILE_NAME(ident),LINE(ident), name, LINE((tree_list*)p->DATA), FILE_NAME((tree_list*)p->DATA));
127 Inc_Error();
128 return list;
129 }
130 if (!p->NEXT) {return addptype(list,value,ident);}
131 }
132 return addptype(NULL,value,ident);
133 }
134
135
136 /***************************************************************************/
137 /* return the value of the element of list wich DATA field equals DATA */
138 /* field of ident */
139 /* comparison is supposed to be on string */
140 /* if not found NULL is returned and an error is dumped */
141 /***************************************************************************/
142 extern int fetch_value(ident,list)
143 tree_list *ident;
144 ptype_list *list;
145 {
146 ptype_list *p;
147 char *name;
148 if (!ident) {
149 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 257);
150 // fprintf(stderr,"fetch_value: NULL pointer\n");
151 EXIT(1);
152 }
153 name=getname(ident);
154
155 for (p=list;p;p=p->NEXT) {
156 if (!p->DATA) {
157 avt_errmsg(GNS_ERRMSG, "004", AVT_FATAL, 258);
158 // fprintf(stderr,"fetch_value: NULL pointer\n");
159 EXIT(1);
160 }
161 if (getname(p->DATA)==name) {
162 return p->TYPE;}
163 }
164
165 avt_errmsg(GNS_ERRMSG, "164", AVT_ERROR, FILE_NAME(ident),LINE(ident), name);
166 //fprintf(stderr,"%s:%d: '%s' not defined (v2)\n",FILE_NAME(ident),LINE(ident), name);
167 Inc_Error();
168 return -1;
169 }
170
171
172