Author Topic: Modules and register_hook_callback  (Read 2165 times)

0 Members and 1 Guest are viewing this topic.

iostres

  • Entrant
  • Posts: 4
Modules and register_hook_callback
« on: September 23, 2011, 09:17:40 AM »
Hi all,

can someone please explain values for register_hook_callback calls in module development?

BR,
iostres
« Last Edit: September 23, 2011, 09:21:42 AM by iostres »

cparm

  • Observer
  • Posts: 12
Re: Modules and register_hook_callback
« Reply #1 on: September 30, 2011, 08:32:36 PM »
hi, here is a very simple example

Code: [Select]
void print_nb_value_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
    int *value_ptr = (int*)arg1;
    int value = *value_ptr;
    printf("the value is %i\n", value);
   
}

void print_Hello_hook(void* arg1, void* arg2, void* arg3, void* arg4)
{
    printf("Hello, World!\n");
   
}

int entry_point ()
{

   
    register_hook_callback("print_nb_value", &print_nb_value_hook);
   
    register_hook_callback("print_Hello", &print_Hello_hook);



    execute_hook("print_Hello", NULL, NULL, NULL, NULL);
   
    int i_want_2_print_this_value_through_my_callback = 2;
    execute_hook("print_nb_value", &i_want_2_print_this_value_through_my_callback, NULL, NULL, NULL);

   
    return 0;
}

execute entry_point() will give this result:

Quote
Hello, World!
the value is 2

i hope this will help  :)
« Last Edit: November 10, 2011, 09:48:39 AM by cparm »