]> git.mxchange.org Git - flightgear.git/commitdiff
Expose the ability to run built in (command manager) commands via the
authorcurt <curt>
Sat, 4 Jan 2003 19:04:07 +0000 (19:04 +0000)
committercurt <curt>
Sat, 4 Jan 2003 19:04:07 +0000 (19:04 +0000)
"telnet" interface.

src/Network/props.cxx

index de1c870e05215f736431b9fdbd8df4e23c72c784..253aac701c636b843c914f18153bb3d633217450 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <simgear/compiler.h>
 #include <simgear/debug/logstream.hxx>
+#include <simgear/misc/commands.hxx>
 #include <simgear/misc/strutils.hxx>
 #include <simgear/misc/props.hxx>
 #include <simgear/misc/props_io.hxx>
 
 #include "props.hxx"
 
+#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(strstream);
 SG_USING_STD(ends);
+#endif
 
 /**
  * Props connection class.
@@ -325,6 +328,31 @@ PropsChannel::foundTerminator()
                }
            }
        }
+       else if ( command == "run" )
+       {
+           if ( tokens.size() == 2 )
+           {
+               string tmp;     
+                SGPropertyNode args;
+                if ( !globals->get_commands()
+                         ->execute(tokens[1].c_str(), &args) )
+                {
+                    SG_LOG( SG_GENERAL, SG_ALERT,
+                            "Command " << tokens[1] << " failed.");
+                    if ( mode == PROMPT ) {
+                        tmp += "*failed*";
+                        push( tmp.c_str() );
+                        push( getTerminator() );
+                    }
+                } else {
+                    if ( mode == PROMPT ) {
+                        tmp += "<completed>";
+                        push( tmp.c_str() );
+                        push( getTerminator() );
+                    }
+                }
+           }
+       }
        else if (command == "quit")
        {
            close();
@@ -353,6 +381,7 @@ ls [<dir>]         list directory\r\n\
 prompt             switch to interactive mode (default)\r\n\
 pwd                display your current path\r\n\
 quit               terminate connection\r\n\
+run <command>      run built in command\r\n\
 set <var> <val>    set <var> to a new <val>\r\n\
 show <var>         synonym for get\r\n";
            push( msg );