Voodooprojects

Chameleon => DevTalk => Topic started by: iostres on September 23, 2011, 09:17:40 AM

Title: Modules and register_hook_callback
Post by: iostres 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
Title: Re: Modules and register_hook_callback
Post by: cparm 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  :)