Module: sip-router
Branch: master
Commit: 486ace87c474881dd371fc98d24c960c1832f96d
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=486ace8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat Jun 25 21:07:31 2011 +0200
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)
---
route_struct.c | 14 ++++++++++++++
route_struct.h | 2 ++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/route_struct.c b/route_struct.c
index 371acaa..d2dee05 100644
--- a/route_struct.c
+++ b/route_struct.c
@@ -596,3 +596,17 @@ void print_actions(struct action* a)
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;
+}
diff --git a/route_struct.h b/route_struct.h
index ea46a22..985f863 100644
--- a/route_struct.h
+++ b/route_struct.h
@@ -223,5 +223,7 @@ void print_expr(struct expr* exp);
/** joins to cfg file positions into a new one. */
void cfg_pos_join(struct cfg_pos* res,
struct cfg_pos* pos1, struct cfg_pos* pos2);
+
+struct action *get_action_from_param(void **param, int param_no);
#endif