On Jun 29, 2010 at 08:31, Ovidiu Sas osas@voipembedded.com wrote:
Hello Andrei,
Thanks for getting back to me on this one.
Here's a pseudocode example. Let's assume that we have module a and module b. We have an rpc call into module a to print out some info. Module b has some relevant info that we would like to print out during the rpc call into module a.
inside module a we have: static void module_a_print_info(rpc_t *rpc, void *c) { /*declare a variable to pass rpc stuf up to module b */ rpc_cb_ctx_t *rpc_cb;
/* print stuff related to module a */ rpc->printf(c, "module a stuff ...."); /*let's print stuf from mudule b now via a callback */ rpc_cb->rpc = rpc; rpc_cb->c = c; run_callback_into_module_b( ...., (void *)rpc_cb);
}
inside module b, we have the callback: void module_b_callback_function(...., struct module_b_generic_callback_param *param) /* extract rpc and c via the generic module_b_generic_callback_param */ rpc_cb_ctx_t* rpc_cb = (rpc_cb_ctx_t*)(param); rpc_t *rpc = rpc_cb->rpc; void *c = rpc_cb->c;
rpc->printf(c, "module b stuff ....");
}
Hope that the above pseudocode explains what I want to achieve. There is no impact on the core, all I want is to declare the rpc_cb_ctx_t structure into the rpc.h in order to make it available in an atomic way to both module a and b.
Ok, so you really need a common type used to pack the rpc functions and context, defined somewhere in a file included by both of the modules.
It's fine if you add it to rpc.h, but then please add some comments stating that is only a convenient way of packing an rpc callback (rpc_function_t) parameters and it's not used/needed by the rpc api/interface (to avoid confusion in the future).
The real modules are:
- module a: modules_k/dialog (dialog.c:internal_rpc_print_dlg)
- module b: modules_k/qos (qos_handlers.c:qos_dialog_rpc_context_CB)
Andrei [...]