I have this program that I want other processes to be able to call functions on (through unix sockets). The message protocol is very simple, the function name, a function signature, and a buffer (char *) that holds the parameters.
When a module in my program wants to allow a function to be accessible, it registers the name and signature with the library. The problem I'm facing is with physically calling the function once the request comes in. I have looked at RPC and java RMI-like libraries, but those require that I generate stubs to wrap calls. The system I am working on is very dynamic and I also have to interface with other peoples code that I can't modify.
So basically, a function might look like:
int somefunc(int someparam, double another)
{
return 1234;
}
now I register with the library:
// func ptr name signature
REG_FUNCTION(somefunc, "somefunc", "i:id");
When the request comes in, I do some error checking, once valid I want to call the function. So I have the variables:
void * funcptr = (the requested function);
char * sig = (the function signature);
char * params = (a buffer of function parameters);
//note that the params buffer can hold data types of arbitrary lengths
How can I call the function with the parameters in C?
Thanks!