Browse code

- added contional lumps support functions: insert_cond_lump_after ( anchor, COND_TYPE, lump_type) insert_cond_lump_before

Andrei Pelinescu-Onciul authored on 01/04/2003 15:54:16
Showing 2 changed files
... ...
@@ -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 156
 										int type)
157 157
 {
158 158
 	struct lump* tmp;
159
-
159
+	
160 160
 	tmp=pkg_malloc(sizeof(struct lump));
161 161
 	if (tmp==0){
162 162
 		ser_error=E_OUT_OF_MEM;
... ...
@@ -182,7 +183,7 @@ struct lump* insert_subst_lump_before(	struct lump* before,
182 182
 										int type)
183 183
 {
184 184
 	struct lump* tmp;
185
-
185
+	
186 186
 	tmp=pkg_malloc(sizeof(struct lump));
187 187
 	if (tmp==0){
188 188
 		ser_error=E_OUT_OF_MEM;
... ...
@@ -201,6 +202,57 @@ struct lump* insert_subst_lump_before(	struct lump* before,
201 201
 
202 202
 
203 203
 
204
+/* inserts a  cond lump immediately after hdr 
205
+ * returns pointer on success, 0 on error */
206
+struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
207
+										int type)
208
+{
209
+	struct lump* tmp;
210
+	
211
+	tmp=pkg_malloc(sizeof(struct lump));
212
+	if (tmp==0){
213
+		ser_error=E_OUT_OF_MEM;
214
+		LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
215
+		return 0;
216
+	}
217
+	memset(tmp,0,sizeof(struct lump));
218
+	tmp->after=after->after;
219
+	tmp->type=type;
220
+	tmp->op=LUMP_ADD_OPT;
221
+	tmp->u.cond=c;
222
+	tmp->len=0;
223
+	after->after=tmp;
224
+	return tmp;
225
+}
226
+
227
+
228
+
229
+/* inserts a  conditional lump immediately before "before" 
230
+ * returns pointer on success, 0 on error */
231
+struct lump* insert_cond_lump_before(	struct lump* before, 
232
+										enum lump_conditions c,
233
+										int type)
234
+{
235
+	struct lump* tmp;
236
+	
237
+	tmp=pkg_malloc(sizeof(struct lump));
238
+	if (tmp==0){
239
+		ser_error=E_OUT_OF_MEM;
240
+		LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
241
+		return 0;
242
+	}
243
+	memset(tmp,0,sizeof(struct lump));
244
+	tmp->before=before->before;
245
+	tmp->type=type;
246
+	tmp->op=LUMP_ADD_OPT;
247
+	tmp->u.cond=c;
248
+	tmp->len=0;
249
+	before->before=tmp;
250
+	return tmp;
251
+}
252
+
253
+
254
+
204 255
 /* removes an already existing header/data lump */
205 256
 struct lump* del_lump(struct lump** list, int offset, int len, int type)
206 257
 {
... ...
@@ -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);