Quote:(04-19-2018, 04:17 PM)0xAeschylus Wrote: [To see links please register here]
Great code! Easily editable and works great. But what about if the functions needed arguments based on user input?
There's 2 ways of attacking that:
Option 1 is to pass the c-string of the command to every function called, and then have a va_list on each of the prototypes, allowing each function to read the rest of the arglist (or parse it ahead of time).
Option 2 is to parse out the arglist based on the command inside that if statement and let every function have a different number of args. To do this, simply remove the void from the proto in the struct, and then C won't enforce the argument list checks and you can pass as many or as few as you need.
I'd advise option 2, then add a "group" field to make it easier