Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / beh / beh / beh_delbefig.c
1
2 /* ###--------------------------------------------------------------### */
3 /* */
4 /* file : beh_delbefig.c */
5 /* date : Sep 3 1993 */
6 /* version : v106 */
7 /* authors : Pirouz BAZARGAN SABET */
8 /* content : low-level function */
9 /* */
10 /* ###--------------------------------------------------------------### */
11
12 #include <stdio.h>
13 #include MUT_H
14 #include LOG_H
15 #include BEH_H
16
17 /* ###--------------------------------------------------------------### */
18 /* function : beh_delbefig */
19 /* description : delete a BEFIG structure and return the pointer of */
20 /* the next object. A warning is printed out if the */
21 /* object to be deleted is not empty when the mode is N. */
22 /* called func. : mbkfree , beh_frebereg, beh_frebemsg, */
23 /* beh_freberin, beh_frebeout, beh_frebebus, */
24 /* beh_frebeaux, beh_frebebux, beh_frebepor, */
25 /* beh_frebegen, getptype */
26 /* ###--------------------------------------------------------------### */
27
28 befig_list *beh_delbefig (listbefig, ptbefig, mode)
29
30 befig_list *listbefig; /* list of befig containing the object */
31 befig_list *ptbefig; /* pointer of the BEFIG to be deleted */
32 char mode; /* recursive delete or not (Y or N) */
33
34 {
35 struct befig headfig;
36 struct befig *ptlastfig;
37 ptype_list *ptptype;
38
39 if ((listbefig != NULL) && (ptbefig != NULL))
40 {
41
42 /* ###------------------------------------------------------### */
43 /* Search the object to be deleted */
44 /* ###------------------------------------------------------### */
45
46 headfig.NEXT = listbefig;
47 ptlastfig = &headfig;
48 while ((ptlastfig != NULL) && (ptlastfig->NEXT != ptbefig))
49 ptlastfig = ptlastfig->NEXT;
50
51 if (ptlastfig != NULL)
52 {
53
54 /* ###------------------------------------------------------### */
55 /* If the object doesn't exist return the list without */
56 /* modification. */
57 /* If the object has been found check the mode and, if asked */
58 /* delete pointed objects recursively. */
59 /* ###------------------------------------------------------### */
60
61 if (mode == 'N')
62 {
63 if ((ptbefig->BEREG != NULL) || (ptbefig->BEMSG != NULL) ||
64 (ptbefig->BERIN != NULL) || (ptbefig->BEOUT != NULL) ||
65 (ptbefig->BEBUS != NULL) || (ptbefig->BEAUX != NULL) ||
66 (ptbefig->BEBUX != NULL) || (ptbefig->BEDLY != NULL) ||
67 (ptbefig->BEPOR != NULL) || (ptbefig->USER != NULL) ||
68 (ptbefig->BEVECTREG) || (ptbefig->BEVECTOUT) ||
69 (ptbefig->BEVECTBUS) || (ptbefig->BEVECTAUX) ||
70 (ptbefig->BEVECTBUS) || (ptbefig->BEVECTPOR) )
71
72 beh_warning(304,ptbefig->NAME,NULL);
73 // (stderr,"BEH_warning : befig `%s` not empty\n", ptbefig->NAME);
74 }
75 else
76 {
77 beh_frebereg (listbefig->BEREG);
78 beh_frebevectreg (listbefig->BEVECTREG);
79 beh_frebemsg (listbefig->BEMSG);
80 beh_freberin (listbefig->BERIN);
81 beh_frebeout (listbefig->BEOUT);
82 beh_frebevectout (listbefig->BEVECTOUT);
83 beh_frebebus (listbefig->BEBUS);
84 beh_frebevectbus (listbefig->BEVECTBUS);
85 beh_frebeaux (listbefig->BEAUX);
86 beh_frebevectaux (listbefig->BEVECTAUX);
87 beh_frebeaux (listbefig->BEDLY);
88 beh_frebebux (listbefig->BEBUX);
89 beh_frebevectbux (listbefig->BEVECTBUX);
90 beh_frebepor (listbefig->BEPOR);
91 beh_frebevectpor (listbefig->BEVECTPOR);
92 if ((ptptype = getptype (ptbefig->USER,BEH_GENERIC)) != NULL)
93 beh_frebegen (ptptype->DATA);
94 }
95
96 ptlastfig->NEXT = ptbefig->NEXT;
97 if (ptbefig->CIRCUI) destroyCct(ptbefig->CIRCUI);
98 mbkfree (ptbefig);
99 }
100
101 listbefig = headfig.NEXT;
102 }
103
104 return(listbefig);
105 }