Browse Source

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 14 years ago
parent
commit
486ace87c4
2 changed files with 16 additions and 0 deletions
  1. 14 0
      route_struct.c
  2. 2 0
      route_struct.h

+ 14 - 0
route_struct.c

@@ -596,3 +596,17 @@ void print_actions(struct action* a)
 		a = a->next;
 		a = a->next;
 	}
 	}
 }
 }
+
+/**
+ * get the pointer to action structure from parameter
+ */
+struct action *get_action_from_param(void **param, int param_no)
+{
+	struct action *ac, ac2;
+	action_u_t *au, au2;
+	/* param points to au->u.string, get pointer to au */
+	au = (void*) ((char *)param - ((char *)&au2.u.string-(char *)&au2));
+	au = au - 1 - param_no;
+	ac = (void*) ((char *)au - ((char *)&ac2.val-(char *)&ac2));
+	return ac;
+}

+ 2 - 0
route_struct.h

@@ -223,5 +223,7 @@ void print_expr(struct expr* exp);
 /** joins to cfg file positions into a new one. */
 /** joins to cfg file positions into a new one. */
 void cfg_pos_join(struct cfg_pos* res,
 void cfg_pos_join(struct cfg_pos* res,
 							struct cfg_pos* pos1, struct cfg_pos* pos2);
 							struct cfg_pos* pos1, struct cfg_pos* pos2);
+
+struct action *get_action_from_param(void **param, int param_no);
 #endif
 #endif