1 /* ###--------------------------------------------------------------------### */
2 /* # # */
3 /* # file : velo.c # */
4 /* | date : Jun 03 1997 | */
5 /* | version : 1.00 | */
6 /* | author : Denis Hommais | */
7 /* | | */
8 /* # contents : basical functions to used VEL structures # */
9 /* # # */
10 /* ###--------------------------------------------------------------------### */
11 /*
12 * $Log: vel_o.c,v $
13 * Revision 1.2 2006/03/29 17:10:39 xtof
14 * * gcc4 compatible : no cast like (Foo*)bar=foo; use bar=(Bar*)foo;
15 *
16 * * ALLIANCE_CFLAGS not added anymore to CFLAGS or CXXFLAGS
17 * by alliance.m4 -> must be added explicitely in each
18 * Makefile.am
19 *
20 * * remove configure.in (generated by autostuff)
21 *
22 * Revision 1.1.1.1 2002/04/26 09:51:07 ludo
23 * Mise a plat de mbkvhdlg
24 *
25 * Revision 1.1.1.1 2002/04/11 08:54:53 fred
26 * Importing mbkvhdlg into the new Alliance CVS tree
27 *
28 * Revision 1.1.1.1 2002/02/28 12:58:31 disydent
29 * Creation of Disydent CVS Tree
30 *
31 * Revision 1.1.1.1 2001/11/19 16:55:27 pwet
32 * Changing the CVS tree structure of disydent
33 *
34 * Revision 1.1.1.1 2001/07/24 13:31:42 pwet
35 * cvs tree of part of disydent
36 *
37 * Revision 1.1.1.1 2001/07/19 14:32:19 pwet
38 * New cvs tree
39 *
40 * Revision 1.1 1997/12/10 16:40:22 denys
41 * Initial revision
42 *
43 * Revision 1.2 1997/09/23 09:43:48 denys
44 * *** empty log message ***
45 *
46 * Revision 1.2 1997/09/23 09:43:48 denys
47 * *** empty log message ***
48 *
49 */
50
51 #ident "$Id: vel_o.c,v 1.2 2006/03/29 17:10:39 xtof Exp $"
52
53
54 #include <stdio.h>
55 #include <string.h>
56 #include <unistd.h>
57 #include <mut.h>
58 #include <mlo.h>
59 #include <mlu.h>
60 #include "vel_velo.h"
61
62 /* ###--------------------------------------------------------------------### */
63 /* # Function addvelosig # */
64 /* ###--------------------------------------------------------------------### */
65
addvelosig(ptype_list * tsig,char * name,long left,long right,char type)66 velosig *addvelosig (ptype_list *tsig, char *name,
67 long left, long right, char type)
68 {
69 velosig *s;
70
71 name = namealloc(name);
72 s = (velosig *)mbkalloc(sizeof(velosig));
73 s->NEXT=(velosig *)tsig->DATA;
74 s->NAME=name;
75 s->LEFT=left;
76 s->RIGHT=right;
77 s->VSIG=NULL;
78 s->NAMECHAIN=NULL;
79 s->USER=NULL;
80 s->TYPE=type;
81 s->SUPER=NULL;
82 tsig->DATA=s;
83 return s;
84 }
85
86 /* ###--------------------------------------------------------------------### */
87 /* # Function addvelocon # */
88 /* ###--------------------------------------------------------------------### */
89
addvelocon(ptype_list * tcon,char * name,long left,long right)90 velocon *addvelocon (ptype_list *tcon, char *name, long left, long right)
91 {
92 velocon *c;
93
94 name = namealloc(name);
95 c=(velocon *)mbkalloc(sizeof(velocon));
96 c->NEXT=(velocon *)tcon->DATA;
97 c->NAME=name;
98 c->LEFT=left;
99 c->RIGHT=right;
100 c->VSIG=NULL;
101 c->ROOT=NULL;
102 c->USER=NULL;
103 tcon->DATA=c;
104 return c;
105 }
106
107 /* ###--------------------------------------------------------------------### */
108 /* # Function dupvelosig # */
109 /* ###--------------------------------------------------------------------### */
110
dupvelosig(ptype_list * p,velosig * s)111 velosig *dupvelosig(ptype_list *p, velosig *s)
112 {
113 velosig *d;
114
115 d=(velosig *)mbkalloc(sizeof(velosig));
116 memcpy(d,s,sizeof(velosig));
117 d->NEXT=(velosig *)p->DATA;
118 p->DATA=d;
119
120 return d;
121 }
122
123 /* ###--------------------------------------------------------------------### */
124 /* # Function getvelosig # */
125 /* ###--------------------------------------------------------------------### */
126
getvelosig(ptype_list * p,char * name,long left,long right)127 velosig *getvelosig(ptype_list *p, char *name, long left, long right)
128 {
129 velosig *s;
130
131 for (s=(velosig *)p->DATA; s; s=s->NEXT) {
132 if (s->NAME == name && ( s->LEFT == left && s->RIGHT == right))
133 return s;
134 }
135 return NULL;
136 }
137
138 /* ###--------------------------------------------------------------------### */
139 /* # Function delvelocon # */
140 /* ###--------------------------------------------------------------------### */
141
delvelocon(ptype_list * p,velocon * d)142 int delvelocon(ptype_list *p, velocon *d)
143 {
144 velocon *c, *s=NULL;
145
146 for (c=(velocon *)p->DATA; c; c=c->NEXT) {
147 if (c==d)
148 break;
149 s=c;
150 }
151 if (!c)
152 return 0;
153 if (c==p->DATA)
154 p->DATA=c->NEXT;
155 else
156 s->NEXT=c->NEXT;
157 mbkfree(c);
158
159 return 1;
160 }
161
162 /* ###--------------------------------------------------------------------### */
163 /* # Function delvelosig # */
164 /* ###--------------------------------------------------------------------### */
165
delvelosig(ptype_list * p,velosig * d)166 int delvelosig(ptype_list *p, velosig *d)
167 {
168 velosig *c=NULL, *s=NULL;
169
170 for (c=(velosig *)p->DATA; c; c=c->NEXT) {
171 if (c==d)
172 break;
173 s=c;
174 }
175 if (!c)
176 return 0;
177 if (c==p->DATA)
178 p->DATA=c->NEXT;
179 else
180 s->NEXT=c->NEXT;
181 mbkfree(c);
182
183 return 1;
184 }
185