Many useful functions of the command interpreter need to know what is the thread from which they are called, i.e. what is the corresponding flow_data structure. For instance the functions convert_int and convert_float, that are used to parse numerical arguments of commands, need that, because they can use local variables, i.e. variables that are specific to a thread (cf. 10.2). In a function corresponding to a command a pointer the flow_data structure is contained in argv[-1]. For instance
int MyCom_cmd(int argc, char *argv[]) { flow_data *flow_interp; flow_interp = (flow_data *) argv[-1]; . . . }
If a command is emulated inside a function it is better to send it a pointer to the current flow_data structure. For instance if we want to emulate a command corresponding to the function com_cmd, which needs two arguments, we proceed like this :
char *k[4]; /* will contain the arguments */ k[0] = (char *) flow_interp /* the pointer to the flow_data structure */ /* Then we fill k with the other arguments, the first being the name of the emulated command */ . . . /* Then we call the command */ com_cmd(3, k + 1); . . .