Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / beh / beh / beh_delbebus.c
1
2 /* ###--------------------------------------------------------------### */
3 /* */
4 /* file : beh_delbebus.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_delbebus */
19 /* description : delete a BEBUS 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_frebiabl, beh_frebinode */
23 /* ###--------------------------------------------------------------### */
24
25 bebus_list *beh_delbebus (listbebus, ptbebus, mode)
26
27 bebus_list *listbebus; /* list of bebus containing the object */
28 bebus_list *ptbebus; /* pointer of the BEBUS to be deleted */
29 char mode; /* recursive delete or not (Y or N) */
30
31 {
32 struct bebus headbus;
33 struct bebus *ptlastbus;
34
35 if ((listbebus != NULL) && (ptbebus != NULL))
36 {
37
38 /* ###------------------------------------------------------### */
39 /* Search the object to be deleted */
40 /* ###------------------------------------------------------### */
41
42 headbus.NEXT = listbebus;
43 ptlastbus = &headbus;
44 while ((ptlastbus != NULL) && (ptlastbus->NEXT != ptbebus))
45 ptlastbus = ptlastbus->NEXT;
46
47 if (ptlastbus != NULL)
48 {
49
50 /* ###------------------------------------------------------### */
51 /* If the object doesn't exist return the list without */
52 /* modification. */
53 /* If the object has been found check the mode and, if asked */
54 /* delete pointed objects recursively. */
55 /* ###------------------------------------------------------### */
56
57 if (mode == 'N')
58 {
59 if ((ptbebus->BIABL != NULL) || (ptbebus->BINODE != NULL))
60 beh_warning(301,ptbebus->NAME,NULL);
61 //(stderr,"BEH_warning : bebus `%s` not empty\n", ptbebus->NAME);
62 }
63 else
64 {
65 beh_frebiabl (ptbebus->BIABL);
66 beh_frebinode (ptbebus->BINODE);
67 }
68
69 ptlastbus->NEXT = ptbebus->NEXT;
70 mbkfree (ptbebus);
71 }
72
73 listbebus = headbus.NEXT;
74 }
75
76 return(listbebus);
77 }