From 27bc1995e7a9cf6103abad0397b3c42cfcfa867e Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 22 Jul 2014 12:03:55 +0200 Subject: [PATCH] Fixed indenting in conn_http.cpp; added proper support for debug levels to HTTP proxy. --- src/connectors/conn_http.cpp | 67 +++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/src/connectors/conn_http.cpp b/src/connectors/conn_http.cpp index 134b75ae..14bbea3e 100644 --- a/src/connectors/conn_http.cpp +++ b/src/connectors/conn_http.cpp @@ -487,62 +487,57 @@ namespace Connector_HTTP { int fdIn = conn.getSocket(); int fdOut = conn.getSocket(); - //taken from CheckProtocols (controller_connectors.cpp) + //taken from CheckProtocols (controller_connectors.cpp) char * argarr[20]; for (int i=0; i<20; i++){argarr[i] = 0;} - int id = -1; - - for (unsigned int i=0; i < ServConf["config"]["protocols"].size(); ++i){ - if ( ServConf["config"]["protocols"][i]["connector"].asStringRef() == connector ) { - id = i; - break; //pick the first protocol in the list that matches the connector - } - } - if (id == -1) { - DEBUG_MSG(DLVL_ERROR, "No connector found for: %s", connector.c_str()); - return -1; - } + int id = -1; - DEBUG_MSG(DLVL_HIGH, "Connector found: %s", connector.c_str()); + for (unsigned int i=0; i < ServConf["config"]["protocols"].size(); ++i){ + if ( ServConf["config"]["protocols"][i]["connector"].asStringRef() == connector ) { + id = i; + break; //pick the first protocol in the list that matches the connector + } + } + if (id == -1) { + DEBUG_MSG(DLVL_ERROR, "No connector found for: %s", connector.c_str()); + return -1; + } + + DEBUG_MSG(DLVL_HIGH, "Connector found: %s", connector.c_str()); //build arguments for starting output process - + std::string temphost=conn.getHost(); std::string tempstream=H.GetVar("stream"); - // buildPipedArguments( , (char **)&argarr, Connector_HTTP::capabilities, temphost, tempstream); - int argnum = 0; - + std::string debuglevel = JSON::Value((long long)Util::Config::printDebugLevel).asString(); + std::string tmparg; tmparg = Util::getMyPath() + std::string("MistOut") + ServConf["config"]["protocols"][id]["connector"].asStringRef(); struct stat buf; if (::stat(tmparg.c_str(), &buf) != 0){ tmparg = Util::getMyPath() + std::string("MistConn") + ServConf["config"]["protocols"][id]["connector"].asStringRef(); } - + + int argnum = 0; argarr[argnum++] = (char*)tmparg.c_str(); JSON::Value & p = ServConf["config"]["protocols"][id]; JSON::Value & pipedCapa = capabilities[p["connector"].asStringRef()]; - /// \todo why is the if(pipedCapa) line not working (nothing is added to argarr)?? - if (pipedCapa.isMember("required")){builPipedPart(p, argarr, argnum, pipedCapa["required"]);} - if (pipedCapa.isMember("optional")){builPipedPart(p, argarr, argnum, pipedCapa["optional"]);} - argarr[argnum++] = (char*)"-i"; argarr[argnum++] = (char*)(temphost.c_str()); argarr[argnum++] = (char*)"-s"; argarr[argnum++] = (char*)(tempstream.c_str()); - - //for (unsigned int i=0; i<20; i++){ - //std::cerr << "argv["<