//this should be already implemented char tolower(char ch) { if(ch>='A'&&ch<='Z') return ch-('A'-'a'); return ch; } //compare strings ignoring case int stricmp(const char *a, const char *b) { int i; for(i=0;;i++) { if(tolower(a[i])!=tolower(b[i])) return i; if((!a[i]&&b[i])||(a[i]&&!b[i])) return i; } return 0; } typedef struct { char *name; int args; void (*cmd)(ePlayerNetID *p); } svcmd_t; void command1_f(ePlayerNetID *p) { std::cout << "command1 called with argument " << tok_argv(1) << std::endl; } void command2_f(ePlayerNetID *p) { std::cout << "command2 called" << std::endl; } const svcmd_t svcmds[]= { {"command1", 1, command1_f}, {"command2", 0, command2_f} }; static bool handle_cmds(const char *input, ePlayerNetID *p) { int i; if(input[0]!='/') return false; toTokenize(input+1); if(tok_argc()==0) return false; //wtf? for(i=0;i=svcmds[i].args) if(!stricmp(tok_argv(0),svcmds[i].name)) { svcmds[i].cmd(p); return true; } return false; }