Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / beh / beh / beh_rmvbefig.c
1
2 /* ###--------------------------------------------------------------### */
3 /* */
4 /* file : beh_rmvbefig.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_rmvbefig */
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_rmvbefig (listbefig, befigname, mode)
29
30 befig_list *listbefig; /* list of befig containing the object */
31 char *befigname; /* name 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 struct befig *ptbefig;
38 ptype_list *ptptype;
39
40 if (listbefig != NULL)
41 {
42
43 /* ###------------------------------------------------------### */
44 /* Search the object to be deleted */
45 /* ###------------------------------------------------------### */
46
47 headfig.NEXT = listbefig;
48 headfig.NAME = NULL ;
49 headfig.BEREG = NULL ;
50 headfig.BEMSG = NULL ;
51 headfig.BERIN = NULL ;
52 headfig.BEAUX = NULL ;
53 headfig.BEBUX = NULL ;
54 headfig.BEDLY = NULL ;
55 headfig.BEPOR = NULL ;
56 headfig.USER = NULL ;
57 ptbefig = &headfig;
58 while ((ptbefig != NULL) && (ptbefig->NAME != befigname))
59 {
60 ptlastfig = ptbefig;
61 ptbefig = ptbefig->NEXT;
62 }
63
64 if (ptbefig != NULL)
65 {
66
67 /* ###------------------------------------------------------### */
68 /* If the object doesn't exist return the list without */
69 /* modification. */
70 /* If the object has been found check the mode and, if asked */
71 /* delete pointed objects recursively. */
72 /* ###------------------------------------------------------### */
73
74 if (mode == 'N')
75 {
76 if ((ptbefig->BEREG != NULL) || (ptbefig->BEMSG != NULL) ||
77 (ptbefig->BERIN != NULL) || (ptbefig->BEOUT != NULL) ||
78 (ptbefig->BEBUS != NULL) || (ptbefig->BEAUX != NULL) ||
79 (ptbefig->BEBUX != NULL) || (ptbefig->BEDLY != NULL) ||
80 (ptbefig->BEPOR != NULL) || (ptbefig->USER != NULL))
81
82 beh_warning(304,befigname,NULL);
83 // (stderr,"BEH_warning : befig `%s` not empty\n", befigname);
84 }
85 else
86 {
87 beh_frebereg (ptbefig->BEREG);
88 beh_frebemsg (ptbefig->BEMSG);
89 beh_freberin (ptbefig->BERIN);
90 beh_frebeout (ptbefig->BEOUT);
91 beh_frebebus (ptbefig->BEBUS);
92 beh_frebeaux (ptbefig->BEAUX);
93 beh_frebeaux (ptbefig->BEDLY);
94 beh_frebebux (ptbefig->BEBUX);
95 beh_frebepor (ptbefig->BEPOR);
96 if ((ptptype = getptype (ptbefig->USER,BEH_GENERIC)) != NULL)
97 beh_frebegen (ptptype->DATA);
98 }
99
100 ptlastfig->NEXT = ptbefig->NEXT;
101 mbkfree (ptbefig);
102 }
103
104 listbefig = headfig.NEXT;
105 }
106
107 return(listbefig);
108 }