Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / beh / beh / beh_delbinod.c
1
2 /* ###--------------------------------------------------------------### */
3 /* */
4 /* file : beh_delbinod.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_delbinode */
19 /* description : delete a BINODE 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 */
23 /* ###--------------------------------------------------------------### */
24
25 binode_list *beh_delbinode (listbinode, ptbinode, mode)
26
27 binode_list *listbinode; /* list of binode containing the object */
28 binode_list *ptbinode; /* pointer of the BINODE to be deleted */
29 char mode; /* recursive delete or not (Y or N) */
30
31 {
32 struct binode headnode;
33 struct binode *ptlastnode;
34
35 if ((listbinode != NULL) && (ptbinode != NULL))
36 {
37
38 /* ###------------------------------------------------------### */
39 /* Search the object to be deleted */
40 /* ###------------------------------------------------------### */
41
42 headnode.NEXT = listbinode;
43 ptlastnode = &headnode;
44 while ((ptlastnode != NULL) && (ptlastnode->NEXT != ptbinode))
45 ptlastnode = ptlastnode->NEXT;
46
47 if (ptlastnode != 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 ((ptbinode->VALNODE != NULL) || (ptbinode->CNDNODE != NULL))
60 beh_warning(311,NULL,NULL);
61 //(stderr,"BEH_warning : binode not empty\n");
62 }
63
64 ptlastnode->NEXT = ptbinode->NEXT;
65 mbkfree (ptbinode);
66 }
67
68 listbinode = headnode.NEXT;
69 }
70
71 return(listbinode);
72 }