... | ... |
@@ -28,6 +28,7 @@ |
28 | 28 |
* -------- |
29 | 29 |
* 2003-01-19 support for duplication lump lists added (jiri) |
30 | 30 |
* 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei) |
31 |
+ * 2003-04-01 added conditional lump suport functions (andrei) |
|
31 | 32 |
*/ |
32 | 33 |
|
33 | 34 |
|
... | ... |
@@ -156,7 +157,7 @@ struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst, |
156 | 157 |
int type) |
157 | 158 |
{ |
158 | 159 |
struct lump* tmp; |
159 |
- |
|
160 |
+ |
|
160 | 161 |
tmp=pkg_malloc(sizeof(struct lump)); |
161 | 162 |
if (tmp==0){ |
162 | 163 |
ser_error=E_OUT_OF_MEM; |
... | ... |
@@ -182,7 +183,7 @@ struct lump* insert_subst_lump_before( struct lump* before, |
182 | 183 |
int type) |
183 | 184 |
{ |
184 | 185 |
struct lump* tmp; |
185 |
- |
|
186 |
+ |
|
186 | 187 |
tmp=pkg_malloc(sizeof(struct lump)); |
187 | 188 |
if (tmp==0){ |
188 | 189 |
ser_error=E_OUT_OF_MEM; |
... | ... |
@@ -201,6 +202,57 @@ struct lump* insert_subst_lump_before( struct lump* before, |
201 | 202 |
|
202 | 203 |
|
203 | 204 |
|
205 |
+/* inserts a cond lump immediately after hdr |
|
206 |
+ * returns pointer on success, 0 on error */ |
|
207 |
+struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c, |
|
208 |
+ int type) |
|
209 |
+{ |
|
210 |
+ struct lump* tmp; |
|
211 |
+ |
|
212 |
+ tmp=pkg_malloc(sizeof(struct lump)); |
|
213 |
+ if (tmp==0){ |
|
214 |
+ ser_error=E_OUT_OF_MEM; |
|
215 |
+ LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n"); |
|
216 |
+ return 0; |
|
217 |
+ } |
|
218 |
+ memset(tmp,0,sizeof(struct lump)); |
|
219 |
+ tmp->after=after->after; |
|
220 |
+ tmp->type=type; |
|
221 |
+ tmp->op=LUMP_ADD_OPT; |
|
222 |
+ tmp->u.cond=c; |
|
223 |
+ tmp->len=0; |
|
224 |
+ after->after=tmp; |
|
225 |
+ return tmp; |
|
226 |
+} |
|
227 |
+ |
|
228 |
+ |
|
229 |
+ |
|
230 |
+/* inserts a conditional lump immediately before "before" |
|
231 |
+ * returns pointer on success, 0 on error */ |
|
232 |
+struct lump* insert_cond_lump_before( struct lump* before, |
|
233 |
+ enum lump_conditions c, |
|
234 |
+ int type) |
|
235 |
+{ |
|
236 |
+ struct lump* tmp; |
|
237 |
+ |
|
238 |
+ tmp=pkg_malloc(sizeof(struct lump)); |
|
239 |
+ if (tmp==0){ |
|
240 |
+ ser_error=E_OUT_OF_MEM; |
|
241 |
+ LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n"); |
|
242 |
+ return 0; |
|
243 |
+ } |
|
244 |
+ memset(tmp,0,sizeof(struct lump)); |
|
245 |
+ tmp->before=before->before; |
|
246 |
+ tmp->type=type; |
|
247 |
+ tmp->op=LUMP_ADD_OPT; |
|
248 |
+ tmp->u.cond=c; |
|
249 |
+ tmp->len=0; |
|
250 |
+ before->before=tmp; |
|
251 |
+ return tmp; |
|
252 |
+} |
|
253 |
+ |
|
254 |
+ |
|
255 |
+ |
|
204 | 256 |
/* removes an already existing header/data lump */ |
205 | 257 |
struct lump* del_lump(struct lump** list, int offset, int len, int type) |
206 | 258 |
{ |
... | ... |
@@ -127,6 +127,11 @@ struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, |
127 | 127 |
struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, |
128 | 128 |
int type); |
129 | 129 |
|
130 |
+/* conditional lumps */ |
|
131 |
+struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, |
|
132 |
+ int type); |
|
133 |
+struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, |
|
134 |
+ int type); |
|
130 | 135 |
|
131 | 136 |
/* removes an already existing header */ |
132 | 137 |
struct lump* del_lump(struct lump** list, int offset, int len, int type); |