equal
deleted
inserted
replaced
1029 uint t_index, tstream_i; |
1029 uint t_index, tstream_i; |
1030 |
1030 |
1031 bool longtoken = false; |
1031 bool longtoken = false; |
1032 bool foundtoken = false; |
1032 bool foundtoken = false; |
1033 |
1033 |
1034 if (*cmdstr == '\0') return; // don't execute empty commands |
|
1035 |
|
1036 for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) { |
1034 for (cmdptr = cmdstr; *cmdptr != '\0'; cmdptr++) { |
1037 if (!IsValidAsciiChar(*cmdptr)) { |
1035 if (!IsValidAsciiChar(*cmdptr)) { |
1038 IConsoleError("command contains malformed characters, aborting"); |
1036 IConsoleError("command contains malformed characters, aborting"); |
1039 IConsolePrintF(_icolour_err, "ERROR: command was: '%s'", cmdstr); |
1037 IConsolePrintF(_icolour_err, "ERROR: command was: '%s'", cmdstr); |
1040 return; |
1038 return; |
1048 memset(&tokenstream, 0, sizeof(tokenstream)); |
1046 memset(&tokenstream, 0, sizeof(tokenstream)); |
1049 |
1047 |
1050 /* 1. Split up commandline into tokens, seperated by spaces, commands |
1048 /* 1. Split up commandline into tokens, seperated by spaces, commands |
1051 * enclosed in "" are taken as one token. We can only go as far as the amount |
1049 * enclosed in "" are taken as one token. We can only go as far as the amount |
1052 * of characters in our stream or the max amount of tokens we can handle */ |
1050 * of characters in our stream or the max amount of tokens we can handle */ |
1053 tokens[0] = tokenstream; |
|
1054 for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) { |
1051 for (cmdptr = cmdstr, t_index = 0, tstream_i = 0; *cmdptr != '\0'; cmdptr++) { |
1055 if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break; |
1052 if (t_index >= lengthof(tokens) || tstream_i >= lengthof(tokenstream)) break; |
1056 |
1053 |
1057 switch (*cmdptr) { |
1054 switch (*cmdptr) { |
1058 case ' ': /* Token seperator */ |
1055 case ' ': /* Token seperator */ |
1085 uint i; |
1082 uint i; |
1086 for (i = 0; tokens[i] != NULL; i++) |
1083 for (i = 0; tokens[i] != NULL; i++) |
1087 IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]); |
1084 IConsolePrintF(_icolour_dbg, "condbg: token %d is: '%s'", i, tokens[i]); |
1088 } |
1085 } |
1089 |
1086 |
|
1087 if (tokens[0] == '\0') return; // don't execute empty commands |
1090 /* 2. Determine type of command (cmd, alias or variable) and execute |
1088 /* 2. Determine type of command (cmd, alias or variable) and execute |
1091 * First try commands, then aliases, and finally variables. Execute |
1089 * First try commands, then aliases, and finally variables. Execute |
1092 * the found action taking into account its hooking code |
1090 * the found action taking into account its hooking code |
1093 */ |
1091 */ |
1094 cmd = IConsoleCmdGet(tokens[0]); |
1092 cmd = IConsoleCmdGet(tokens[0]); |