]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/props.cxx
Patches from Erik Hofman for SGI compatibility:
[flightgear.git] / src / Network / props.cxx
index 8752da41b927eb48ec5d9c2cd96ec6813d22443f..de1c870e05215f736431b9fdbd8df4e23c72c784 100644 (file)
 
 #include "props.hxx"
 
-#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
 SG_USING_STD(strstream);
 SG_USING_STD(ends);
-#endif
 
 /**
  * Props connection class.
@@ -203,15 +201,7 @@ PropsChannel::foundTerminator()
            for (int i = 0; i < dir->nChildren(); i++)
            {
                SGPropertyNode * child = dir->getChild(i);
-               string name = child->getName();
-               string line = name;
-
-               if (dir->getChild( name.c_str(), 1 ))
-               {
-                   char buf[16];
-                   sprintf(buf, "[%d]", child->getIndex());
-                   line += buf;
-               }
+               string line = child->getDisplayName(true);
 
                if ( child->nChildren() > 0 )
                {
@@ -221,10 +211,9 @@ PropsChannel::foundTerminator()
                {
                    if (mode == PROMPT)
                    {
-                       string value = dir->getStringValue( name.c_str(), "" );
+                       string value = child->getStringValue();
                        line += " =\t'" + value + "'\t(";
-                       line += getValueTypeString(
-                                       dir->getNode( name.c_str() ) );
+                       line += getValueTypeString( child );
                        line += ")";
                    }
                }
@@ -393,12 +382,25 @@ FGProps::FGProps( const vector<string>& tokens )
     // tokens:
     //   props,port#
     //   props,medium,direction,hz,hostname,port#,style
-    if (tokens.size() == 2)
+    if (tokens.size() == 2) {
        port = atoi( tokens[1].c_str() );
-    else if (tokens.size() == 7)
+        set_hz( 5 );                // default to processing requests @ 5Hz
+    } else if (tokens.size() == 7) {
+        char* endptr;
+        errno = 0;
+        int hz = strtol( tokens[3].c_str(), &endptr, 10 );
+        if (errno != 0) {
+           SG_LOG( SG_IO, SG_ALERT, "I/O poll frequency out of range" );
+           set_hz( 5 );           // default to processing requests @ 5Hz
+        } else {
+            SG_LOG( SG_IO, SG_INFO, "Setting I/O poll frequency to "
+                    << hz << " Hz");
+            set_hz( hz );
+        }
        port = atoi( tokens[5].c_str() );
-    else
+    } else {
        throw FGProtocolConfigError( "FGProps: incorrect number of configuration arguments" );
+    }
 }
 
 /**
@@ -426,7 +428,6 @@ FGProps::open()
     netChannel::listen( 5 );
     SG_LOG( SG_IO, SG_INFO, "Props server started on port " << port );
 
-    set_hz( 5 );                // default to processing requests @ 5Hz
     set_enabled( true );
     return true;
 }