Skip to main content

The following Lua example enables and and sets values for variables.

1local mod = {};
2require("msys.core");
3
4function mod:mm7_pre_submit(msg)
5  msys.core.ec_message_context_set(msg, msys.core.ECMESS_CTX_MESS, "MM7_Reply_Charging", 1);
6  msys.core.ec_message_context_set(msg, msys.core.ECMESS_CTX_MESS, "MM7_Reply_Charging_Size",
7    1024);
8  msys.core.ec_message_context_set(msg, msys.core.ECMESS_CTX_MESS, "MM7_Reply_Deadline",
9    "2011-05-30T09:30:10-06:00");
10  msys.core.ec_message_context_set(msg, msys.core.ECMESS_CTX_MESS, "MM7_Delivery_Report", 1);
11  msys.core.ec_message_context_set(msg, msys.core.ECMESS_CTX_MESS, "MM7_Read_Reply", 1);
12end
13
14msys.registerModule("mm7_pre_submit_hook_test", mod);

The following C hook does the same as the Lua implementation above:

1#include "module.h"
2#include "modules/mobility/mms/hooks/mm7_message_hooks.h"
3#include "modules/mobility/mms/mm7.h"
4
5static void sample_mm7_submit_req_hook (void  *gself, ec_message * m)
6{
7  ec_message_context_set(m, ECMESS_CTX_MESS, "MM7_Reply_Charging", "1");
8  ec_message_context_set(m, ECMESS_CTX_MESS, "MM7_Reply_Charging_Size", "1024");
9  ec_message_context_set(m, ECMESS_CTX_MESS, "MM7_Reply_Deadline",
10    "2011-05-30T09:30:10-06:00");
11  ec_message_context_set(m, ECMESS_CTX_MESS, "MM7_Delivery_Report", "1");
12  ec_message_context_set(m, ECMESS_CTX_MESS, "MM7_Read_Reply", "1");
13}
14
15static int init (generic_module_infrastructure *gself) {
16  /* register the hook during module initialization */
17  register_mm7_pre_submit_hook_first (sample_mm7_submit_req_hook, gself);
18  return 0;
19}
20
21EC_MODULE_EXPORT
22generic_module_infrastructure mm7_hook_test = {
23  {
24    EC_MODULE_INIT(EC_MODULE_TYPE_GENERIC, 0),
25    "mm7_hook_test.c",
26    "Sample MM7 Hook",
27    NULL,
28    NULL,
29    NULL,
30    init,
31    NULL,
32    NULL,
33    NULL,
34    NULL,
35    NULL
36  }
37};
Was this page helpful?