00001 /* -*-c++-*- */ 00002 /* 00003 * $Id: FCgiIO_8h-source.html,v 1.1 2007/07/03 21:34:46 sebdiaz Exp $ 00004 * 00005 * Copyright (C) 2002 Steve McAndrewSmith 00006 * Copyright (C) 2002 Stephen F. Booth 00007 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com> 00008 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc 00009 * 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 3 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA* 00023 */ 00024 00025 #ifndef _FCGIIO_H_ 00026 #define _FCGIIO_H_ 1 00027 00028 #ifdef __GNUG__ 00029 # pragma interface 00030 #endif 00031 00043 #include <ostream> 00044 #include <string> 00045 #include <map> 00046 00047 #include "fcgio.h" 00048 00049 #include "cgicc/CgiInput.h" 00050 00051 namespace cgicc { 00052 00053 // ============================================================ 00054 // Class FCgiIO 00055 // ============================================================ 00056 00067 class CGICC_API FCgiIO : public cgicc::CgiInput, public std::ostream 00068 { 00069 public: 00070 00071 // ============================================================ 00072 00075 00081 FCgiIO(FCGX_Request& request); 00082 00087 FCgiIO(const FCgiIO& io); 00088 00094 virtual inline 00095 ~FCgiIO() 00096 {} 00098 00099 // ============================================================ 00100 00103 00111 virtual inline size_t read(char *data, size_t length) 00112 { 00113 return FCGX_GetStr(data, length, fRequest.in); 00114 } 00115 00123 virtual inline std::string getenv(const char *varName) 00124 { 00125 return fEnv[varName]; 00126 } 00128 00129 // ============================================================ 00130 00133 00137 inline std::ostream& err(void) 00138 { 00139 return fErr; 00140 } 00142 00143 protected: 00144 FCGX_Request& fRequest; 00145 fcgi_streambuf fOutBuf; 00146 fcgi_streambuf fErrBuf; 00147 std::ostream fErr; 00148 std::map<std::string, std::string> fEnv; 00149 }; 00150 00151 } // namespace cgicc 00152 00153 #endif /* ! _FCGIIO_H_ */