lvalue.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2008 iptelorg GmbH
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /**
  19. * @file
  20. * @brief lvalues (assignment)
  21. */
  22. /*
  23. * History:
  24. * --------
  25. * 2008-11-30 initial version (andrei)
  26. */
  27. #ifndef __lvalue_h_
  28. #define __lvalue_h_
  29. #include "rvalue.h"
  30. #include "usr_avp.h"
  31. #include "pvar.h"
  32. #include "parser/msg_parser.h"
  33. #include "action.h"
  34. union lval_u{
  35. pv_spec_t *pvs;
  36. avp_spec_t avps;
  37. };
  38. enum lval_type{
  39. LV_NONE, LV_AVP, LV_PVAR
  40. };
  41. struct lvalue{
  42. enum lval_type type;
  43. union lval_u lv;
  44. };
  45. /* lval operators */
  46. #define EQ_T 254 /* k compatibility */
  47. typedef int (*log_assign_action_f)(struct sip_msg* msg, struct lvalue *lv);
  48. void set_log_assign_action_cb(log_assign_action_f f);
  49. /** eval rve and assign the result to lv
  50. * lv=eval(rve)
  51. *
  52. * @param h - script context
  53. * @param msg - sip msg
  54. * @param lv - lvalue
  55. * @param rve - rvalue expression
  56. * @return >= 0 on success (expr. bool value), -1 on error
  57. */
  58. int lval_assign(struct run_act_ctx* h, struct sip_msg* msg,
  59. struct lvalue* lv, struct rval_expr* rve);
  60. #endif /* __lvalue_h_*/