Executes a generic command line for a specific agent
| 893 | |
| 894 | // Executes a generic command line for a specific agent |
| 895 | bool KernelSML::HandleCommandLine(AgentSML* pAgentSML, char const* pCommandName, Connection* pConnection, AnalyzeXML* pIncoming, soarxml::ElementXML* pResponse) |
| 896 | { |
| 897 | #ifdef _DEBUG |
| 898 | bool kDebugCommandLine = false ; |
| 899 | #else |
| 900 | bool kDebugCommandLine = false ; |
| 901 | #endif |
| 902 | |
| 903 | // Get the parameters |
| 904 | char const* pLine = pIncoming->GetArgString(sml_Names::kParamLine) ; |
| 905 | bool echoResults = pIncoming->GetArgBool(sml_Names::kParamEcho, false) ; |
| 906 | bool noFiltering = pIncoming->GetArgBool(sml_Names::kParamNoFiltering, false) ; |
| 907 | |
| 908 | // If the user chooses to enable this feature, certain commands are always echoed back. |
| 909 | // This is primarily to support two users connected to and debugging the same kernel at once. |
| 910 | if (GetEchoCommands() && m_CommandLineInterface.ShouldEchoCommand(pLine)) |
| 911 | { |
| 912 | echoResults = true ; |
| 913 | } |
| 914 | |
| 915 | bool rawOutput = false; |
| 916 | |
| 917 | // The caller can ask for simple string output (raw output) or more complex, structured XML output |
| 918 | // which can then be parsed. |
| 919 | soarxml::ElementXML const* pCommand = pIncoming->GetCommandTag() ; |
| 920 | const char* pCommandOutput = pCommand->GetAttribute(sml_Names::kCommandOutput) ; |
| 921 | |
| 922 | if (pCommandOutput) |
| 923 | { |
| 924 | rawOutput = (strcmp(pCommandOutput, sml_Names::kRawOutput) == 0) ; |
| 925 | } |
| 926 | |
| 927 | if (!pLine) |
| 928 | { |
| 929 | return InvalidArg(pConnection, pResponse, pCommandName, "Command line missing") ; |
| 930 | } |
| 931 | |
| 932 | if (kDebugCommandLine) |
| 933 | { |
| 934 | sml::PrintDebugFormat("Executing %s", pLine) ; |
| 935 | } |
| 936 | |
| 937 | // If we're echoing the results, also echo the command we're executing |
| 938 | if (echoResults && pAgentSML) |
| 939 | { |
| 940 | pAgentSML->FireEchoEvent(pConnection, pLine) ; |
| 941 | } |
| 942 | |
| 943 | if (kDebugCommandLine) |
| 944 | { |
| 945 | sml::PrintDebugFormat("Echoed line\n") ; |
| 946 | } |
| 947 | |
| 948 | // Send this command line through anyone registered filters. |
| 949 | // If there are no filters (or this command requested not to be filtered), this copies the original line into the filtered line unchanged. |
| 950 | char const* pFilteredLine = pLine ; |
| 951 | bool filteredError = false ; |
| 952 | soarxml::ElementXML* pFilteredXML = NULL ; |
nothing calls this directly
no test coverage detected