The approach I would recommend is to look at another C code that uses the dispatch table and see how it is structured. The specific examples that I know from my head (maybe not the best examples of training, as they are just the random free software that I worked on) are MIT Kerberos and Heimdal, both of which use sending tables all over the world and Apache web server and how it handles dynamically loaded modules. None of them inherit, but inheritance is relatively simple to add: you see if the method you are trying to call is NULL, and if so, you check the parent distribution table for this method.
The short version of how to handle the distribution table in C as a whole is that you define a data structure, akin to C ++ vtable, which contains pointers to functions and a way to determine which pointer to use. Something like:
typedef void (*dispatch_func)(void *); struct dispatch { const char *command; dispatch_func callback; };
is a super-generic version that matches string label names for functions that take a single anonymous pointer as an argument. Your actual mailing table will be an array of such as this (modified example taken from tinyleaf in the INN source):
const struct dispatch commands[] = { { "help", command_help }, { "ihave", command_ihave }, { "quit", command_quit } };
Obviously, the more you know about functions, the more specific you can make a prototype, and you can embed other selection criteria (for example, the number of arguments) in the dispatch table. (The actual INN source has minimum and maximum argument values, passes the argument structure, not just void *, and includes a description of the command in the dispatch table.)
The basic code for finding a distribution table is pretty simple. Assuming you have an array of these distribution structure entries in vtable and the table length in length , something like:
for (i = 0; i < length; i++) if (strcmp(command, vtable[i].command) == 0) { (*vtable[i].callback)(data); return; }
To implement inheritance, you will need a parent pointer, and if you fall from the end of the loop, you will go to the parent element and repeat the logic. (Obviously, this can be a useful place for a recursive function.)