Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / lib / lib_global.c
1 /********************************************/
2 /* lib_global.c : */
3 /* fichier de fonctions en C appelees dans */
4 /* le fichier YACC. */
5 /********************************************/
6
7 /******************************************************************************/
8 /* INCLUDE */
9 /******************************************************************************/
10 #include "lib_global.h"
11
12
13 /******************************************************************************/
14 /* GLOBALS */
15 /******************************************************************************/
16
17 /******************************************************************************/
18 /* FONCTIONS */
19 /******************************************************************************/
20 /*----------------------------------------------------------------------------*/
21 /* LIB_TREAT_GROUP_HEAD : */
22 /* */
23 /*----------------------------------------------------------------------------*/
24 void lib_treat_group_head(char *ident, chain_list *param)
25 {
26 long ctxt;
27 chain_list *ch;
28
29 lib_push_context(lib_give_context(ident));
30 if((ctxt=lib_get_context()) != NO_ACTION_TYPE) {
31 if(ctxt == LIB_TYPE) {
32 lib_setenv();
33 lib_init();
34 if(LIB_TRACE_MODE == 'N') {
35 // avt_error("library", -1, AVT_INFO, "loading LIB '¤2%s¤.'\n", (char*)param->DATA);
36 /* fprintf(stdout,"\nLOADING LIBRARY %s LIB... ", (char*)param->DATA);
37 fflush( stdout );*/
38 }
39 }
40 else if(ctxt == CELL_TYPE) {
41 if((LIB_TRACE_MODE == 'V') || (LIB_TRACE_MODE == 'A'))
42 printf("\t ---> processing cell %s\n", (char *)(param->DATA));
43 }
44 lib_pushgroup(ident, param);
45 }
46 else {
47 for(ch = param ; ch ; ch=ch->NEXT)
48 mbkfree((char *)(ch->DATA));
49 freechain(param);
50 }
51 mbkfree((char *)ident);
52 }
53 /*----------------------------------------------------------------------------*/
54 /* LIB_TREAT_GROUP_END : */
55 /* */
56 /*----------------------------------------------------------------------------*/
57 void lib_treat_group_end(void)
58 {
59 long ctxt;
60 lofig_list *plofig;
61 lib_group *p;
62
63 if((ctxt=lib_get_context()) != NO_ACTION_TYPE) {
64 if(ctxt == LIB_TYPE) {
65 lib_tim_store_default_wire_load();
66 if((LIB_TRACE_MODE == 'V') || (LIB_TRACE_MODE == 'A'))
67 printf("\t<--- done\n");
68 /* else
69 fprintf(stdout,"DONE!\n");
70 */
71 p=LIB_CURRENT_GP;
72
73 lib_popgroup();
74 lib_del_group(p);
75 cbh_delcct();
76 if(LIB_TIME_U){
77 mbkfree((lib_scale_unit *)LIB_TIME_U);
78 LIB_TIME_U = NULL;
79 }
80 if(LIB_RES_U){
81 mbkfree((lib_scale_unit *)LIB_RES_U);
82 LIB_RES_U = NULL;
83 }
84 if(LIB_CAPA_U){
85 mbkfree((lib_scale_unit *)LIB_CAPA_U);
86 LIB_CAPA_U = NULL;
87 }
88 if(libparserpowerptype){
89 freeptype(libparserpowerptype);
90 libparserpowerptype = NULL;
91 }
92 }
93 else if(ctxt == CELL_TYPE) {
94 if((plofig=lib_func_treat_cell(LIB_CURRENT_GP)))
95 lib_tim_treat_cell(LIB_CURRENT_GP, plofig);
96 p=LIB_CURRENT_GP;
97 lib_popgroup();
98 lib_del_group(p);
99 }
100 else if(ctxt == LU_TEMPL_TYPE) {
101 lib_tim_store_template();
102 p=LIB_CURRENT_GP;
103 lib_popgroup();
104 lib_del_group(p);
105 }
106 else if(ctxt == WIRE_LOAD_TYPE) {
107 lib_tim_store_wire_load();
108 p=LIB_CURRENT_GP;
109 lib_popgroup();
110 lib_del_group(p);
111 }
112 else if(ctxt == WIRE_LOAD_TABLE_TYPE) {
113 lib_tim_store_wire_load_table();
114 p=LIB_CURRENT_GP;
115 lib_popgroup();
116 lib_del_group(p);
117 }
118 else if(ctxt == POWER_SUPPLY_TYPE) {
119 lib_tim_treat_power_supply();
120 p=LIB_CURRENT_GP;
121 lib_popgroup();
122 lib_del_group(p);
123 }
124 else
125 lib_popgroup();
126 }
127
128 lib_pop_context();
129 }
130
131 /*----------------------------------------------------------------------------*/
132 /* LIB_TREAT_S_ATTR : */
133 /* */
134 /*----------------------------------------------------------------------------*/
135 void lib_treat_s_attr(char *ident, char *attr)
136 {
137
138 if(lib_get_context() != NO_ACTION_TYPE)
139 lib_add_s_attr(ident, attr);
140 else
141 mbkfree((char *)attr);
142 mbkfree((char *)ident);
143 }
144
145 /*----------------------------------------------------------------------------*/
146 /* LIB_TREAT_C_ATTR : */
147 /* */
148 /*----------------------------------------------------------------------------*/
149 void lib_treat_c_attr(char *ident, chain_list *attr)
150 {
151 chain_list *ch;
152
153 if(lib_get_context() != NO_ACTION_TYPE)
154 lib_add_c_attr(ident, attr);
155 else {
156 for(ch=attr ; ch ; ch=ch->NEXT)
157 mbkfree((char *)(ch->DATA));
158 freechain(attr);
159 }
160 mbkfree((char *)ident);
161 }
162