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