]> git.mxchange.org Git - flightgear.git/blobdiff - src/Network/httpd.cxx
Updated adf property names.
[flightgear.git] / src / Network / httpd.cxx
index 7a567a61a53d3884e1b5a6dfd20e005a53e636e6..97ab9b5d4b768d158a644110a0ca96d6206362df 100644 (file)
@@ -1,4 +1,4 @@
-// httpd.hxx -- FGFS http property manager interface / external script
+// httpd.cxx -- FGFS http property manager interface / external script
 //              and control class
 //
 // Written by Curtis Olson, started June 2001.
@@ -97,10 +97,9 @@ void HttpdChannel::foundTerminator (void) {
         string request;
         string tmp;
 
-        unsigned int pos = rest.find( " " );
+        string::size_type pos = rest.find( " " );
         if ( pos != string::npos ) {
             request = rest.substr( 0, pos );
-            request = urlDecode(request);
         } else {
             request = "/";
         }
@@ -112,6 +111,7 @@ void HttpdChannel::foundTerminator (void) {
             string args = request.substr( pos + 1 );
             request = request.substr( 0, pos );
             printf("'%s' '%s'\n", request.c_str(), args.c_str());
+            request = urlDecode(request);
 
             // parse args looking for "value="
             bool done = false;
@@ -127,19 +127,21 @@ void HttpdChannel::foundTerminator (void) {
                 }
 
                 printf("  arg = %s\n", arg.c_str() );
-                unsigned int apos = arg.find("=");
+                string::size_type apos = arg.find("=");
                 if ( apos != string::npos ) {
                     string a = arg.substr( 0, apos );
                     string b = arg.substr( apos + 1 );
                     printf("    a = %s  b = %s\n", a.c_str(), b.c_str() );
                     if ( a == "value" ) {
-                        fgSetString( request, b );
+                        fgSetString( request.c_str(), urlDecode(b).c_str() );
                     } 
                 }
             }
-        }
+        } else {
+            request = urlDecode(request);
+       }
 
-        node = globals->get_props()->getNode(request);
+        node = globals->get_props()->getNode(request.c_str());
 
         string response = "";
         response += "<HTML LANG=\"en\">";
@@ -177,7 +179,7 @@ void HttpdChannel::foundTerminator (void) {
             for (int i = 0; i < node->nChildren(); i++) {
                 SGPropertyNode *child = node->getChild(i);
                 string name = child->getName();
-                if ( node->getChild(name, 1) ) {
+                if ( node->getChild(name.c_str(), 1) ) {
                     char buf[16];
                     sprintf(buf, "[%d]", child->getIndex());
                     name += buf;
@@ -195,7 +197,7 @@ void HttpdChannel::foundTerminator (void) {
                     line += "</A></B>";
                     line += "/<BR>";
                 } else {
-                    string value = node->getStringValue ( name, "" );
+                    string value = node->getStringValue ( name.c_str(), "" );
                     line += "<B>";
                     line += name;
                     line += "</B> <A HREF=\"";
@@ -225,8 +227,7 @@ void HttpdChannel::foundTerminator (void) {
             response += value;
             response += "\" maxlength=2047>";
             response += "<input type=submit value=\"update\" name=\"submit\">";
-            response += "<FORM>";
-            response += "<BR>";
+            response += "</FORM>";
         }
         response += "</BODY>";
         response += getTerminator();
@@ -257,7 +258,7 @@ void HttpdChannel::foundTerminator (void) {
 }
 
 
-// encode everything but "a-zA-Z0-9_.-/"
+// encode everything but "a-zA-Z0-9_.-/" (see RFC2396)
 string HttpdChannel::urlEncode(string s) {
     string r = "";