yhook: rename unused checkOutput() -> getOutType() and use it

Origin commit data
------------------
Commit: 3d78e7d657
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-02-21 (Sun, 21 Feb 2016)

Origin message was:
------------------
- yhook: rename unused checkOutput() -> getOutType() and use it
This commit is contained in:
vanhofen
2016-02-21 21:41:24 +01:00
parent 00774d8fde
commit 290240f5a0
2 changed files with 10 additions and 14 deletions

View File

@@ -73,7 +73,7 @@ THandleStatus CyhookHandler::Hooks_SendResponse() {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
THandleStatus CyhookHandler::Hooks_PrepareResponse() { THandleStatus CyhookHandler::Hooks_PrepareResponse() {
log_level_printf(4, "PrepareResponse Hook-List Start\n"); log_level_printf(4, "PrepareResponse Hook-List Start\n");
outType = checkOutput(); outType = getOutType();
THandleStatus _status = HANDLED_NONE; THandleStatus _status = HANDLED_NONE;
THookList::iterator i = HookList.begin(); THookList::iterator i = HookList.begin();
for (; i != HookList.end(); ++i) { for (; i != HookList.end(); ++i) {
@@ -392,28 +392,24 @@ void CyhookHandler::printf(const char *fmt, ...) {
Write(outbuf); Write(outbuf);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
TOutType CyhookHandler::checkOutput() { TOutType CyhookHandler::getOutType() {
// get outType TOutType _outType = plain;
outType = plain; // plain
if(!(ParamList.empty())) { if(!(ParamList.empty())) {
if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "json") if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "json")
|| (ParamList.find("json") != ParamList.end() && !(ParamList["json"].empty())) ) || (ParamList.find("json") != ParamList.end() && !(ParamList["json"].empty())) )
outType = json; _outType = json;
else if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "xml") else if ((ParamList.find("format") != ParamList.end() && ParamList["format"] == "xml")
|| (ParamList.find("xml") != ParamList.end() && !(ParamList["xml"].empty())) ) || (ParamList.find("xml") != ParamList.end() && !(ParamList["xml"].empty())) )
outType = xml; _outType = xml;
} }
return outType; return _outType;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
TOutType CyhookHandler::outStart(bool single) { TOutType CyhookHandler::outStart(bool single) {
outSingle = single; // for compatibility // for compatibility
outSingle = single;
// get outType // get outType
outType = plain; // plain outType = getOutType();
if (ParamList["format"] == "json")
outType = json;
else if (ParamList["format"] == "xml" || !(ParamList["xml"].empty()) )
outType = xml;
// set response header // set response header
if (outType == xml) if (outType == xml)
SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); SetHeader(HTTP_OK, "text/xml; charset=UTF-8");

View File

@@ -202,7 +202,7 @@ public:
int _outIndent; int _outIndent;
TOutType outType; // Outputtpe = plain (default)|xml|json TOutType outType; // Outputtpe = plain (default)|xml|json
TOutType outStart(bool single = false); TOutType outStart(bool single = false);
TOutType checkOutput(); TOutType getOutType();
std::string outIndent(); std::string outIndent();
std::string outPair(std::string _key, std::string _content, bool _next); std::string outPair(std::string _key, std::string _content, bool _next);
std::string outArray(std::string _key, std::string _content); std::string outArray(std::string _key, std::string _content);