Browse code

core: function to return action struct from param

- moved the function from xlog module to core to be used by other
modules
- get_action_from_param(param, param_no) can return the pointer to
action structure when the pointer to pointer param and param no is
provided (like in the fixup of module functions)

Daniel-Constantin Mierla authored on 25/06/2011 19:07:31
Showing 2 changed files
... ...
@@ -596,3 +596,17 @@ void print_actions(struct action* a)
596 596
 		a = a->next;
597 597
 	}
598 598
 }
599
+
600
+/**
601
+ * get the pointer to action structure from parameter
602
+ */
603
+struct action *get_action_from_param(void **param, int param_no)
604
+{
605
+	struct action *ac, ac2;
606
+	action_u_t *au, au2;
607
+	/* param points to au->u.string, get pointer to au */
608
+	au = (void*) ((char *)param - ((char *)&au2.u.string-(char *)&au2));
609
+	au = au - 1 - param_no;
610
+	ac = (void*) ((char *)au - ((char *)&ac2.val-(char *)&ac2));
611
+	return ac;
612
+}
... ...
@@ -223,5 +223,7 @@ void print_expr(struct expr* exp);
223 223
 /** joins to cfg file positions into a new one. */
224 224
 void cfg_pos_join(struct cfg_pos* res,
225 225
 							struct cfg_pos* pos1, struct cfg_pos* pos2);
226
+
227
+struct action *get_action_from_param(void **param, int param_no);
226 228
 #endif
227 229