/* * This file is a part of Winix * and is distributed under the 2-Clause BSD licence. * Author: Tomasz Sowa */ /* * Copyright (c) 2008-2014, Tomasz Sowa * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ #include "request.h" #include "log.h" #include "plugin.h" #include "misc.h" namespace Winix { Request::Request() { id = 0; config = 0; } void Request::SetConfig(Config * pconfig) { config = pconfig; } void Request::ClearOutputStreams() { size_t len = 16; if( config ) len = config->ezc_out_streams_size; if( len < 1 || len > 64 ) len = 16; if( out_streams.size() != len ) out_streams.resize(len); if( use_html_filter.size() != len ) use_html_filter.resize(len); for(size_t i=0 ; isecond; } const std::wstring & Request::PostVar(const std::wstring & var) { PostTab::iterator p = post_tab.find(var); if( p == post_tab.end() ) return str_empty; return p->second; } bool Request::PostVar(const wchar_t * var, std::wstring & result) { PostTab::iterator p = post_tab.find(var); if( p == post_tab.end() ) { result.clear(); return false; } result = p->second; return true; } bool Request::PostVar(const std::wstring & var, std::wstring & result) { PostTab::iterator p = post_tab.find(var); if( p == post_tab.end() ) { result.clear(); return false; } result = p->second; return true; } std::wstring * Request::PostVarp(const wchar_t * var) { PostTab::iterator p = post_tab.find(var); if( p == post_tab.end() ) return 0; return &p->second; } std::wstring * Request::PostVarp(const std::wstring & var) { PostTab::iterator p = post_tab.find(var); if( p == post_tab.end() ) return 0; return &p->second; } bool Request::AllPostVarEmpty() { PostTab::iterator i; for(i=post_tab.begin() ; i!=post_tab.end() ; ++i) if( !i->second.empty() ) return false; return true; } bool Request::IsParam(const wchar_t * param_name) { ParamTab::iterator i; for(i=param_tab.begin() ; i!=param_tab.end() ; ++i) { if( i->name == param_name ) return true; } return false; } bool Request::IsParam(const std::wstring & param_name) { ParamTab::iterator i; for(i=param_tab.begin() ; i!=param_tab.end() ; ++i) { if( i->name == param_name ) return true; } return false; } const std::wstring & Request::ParamValue(const wchar_t * param_name) { ParamTab::iterator i; for(i=param_tab.begin() ; i!=param_tab.end() ; ++i) { if( i->name == param_name ) return i->value; } return str_empty; } const std::wstring & Request::ParamValue(const std::wstring & param_name) { return ParamValue(param_name.c_str()); } } // namespace Winix