|
||||
File indexing completed on 2025-01-17 09:55:22
0001 // 0002 // Provides support for FastCGI via C++ iostreams. 0003 // 0004 // $Id: fcgio.h,v 1.15 2002/02/25 13:16:11 robs Exp $ 0005 // 0006 // This work is based on routines written by George Feinberg. They 0007 // have been mostly re-written and extensively changed by 0008 // Michael Richards. 0009 // 0010 // Rewritten again with bug fixes and numerous enhancements by 0011 // Michael Shell. 0012 // 0013 // And rewritten again by Rob Saccoccio. 0014 // 0015 // Special Thanks to Dietmar Kuehl for his help and the numerous custom 0016 // streambuf examples on his web site. 0017 // 0018 // Copyright (c) 2000 Tux the Linux Penguin 0019 // Copyright (c) 2001 Rob Saccoccio and Chelsea Networks 0020 // 0021 // You are free to use this software without charge or royalty 0022 // as long as this notice is not removed or altered, and recognition 0023 // is given to the author(s) 0024 // 0025 // This code is offered as-is without any warranty either expressed or 0026 // implied; without even the implied warranty of MERCHANTABILITY or 0027 // FITNESS FOR A PARTICULAR PURPOSE. If it breaks, you get to keep 0028 // both halves. 0029 0030 #ifndef FCGIO_H 0031 #define FCGIO_H 0032 0033 #include <iostream> 0034 0035 #include "fcgiapp.h" 0036 0037 #ifndef DLLAPI 0038 #if defined (_WIN32) && defined (_MSC_VER) 0039 #define DLLAPI __declspec(dllimport) 0040 #else 0041 #define DLLAPI 0042 #endif 0043 #endif 0044 0045 #if ! HAVE_STREAMBUF_CHAR_TYPE 0046 typedef char char_type; 0047 #endif 0048 0049 /* 0050 * fcgi_streambuf 0051 */ 0052 class DLLAPI fcgi_streambuf : public std::streambuf 0053 { 0054 public: 0055 0056 // Note that if no buf is assigned (the default), iostream methods 0057 // such as peek(), unget() and putback() will fail. If a buf is 0058 // assigned, I/O is a bit less efficient and output streams will 0059 // have to be flushed (or the streambuf destroyed) before the next 0060 // call to "accept". 0061 fcgi_streambuf(FCGX_Stream * fcgx, char * buf, int len); 0062 0063 fcgi_streambuf(char_type * buf, std::streamsize len); 0064 0065 fcgi_streambuf(FCGX_Stream * fcgx = 0); 0066 0067 ~fcgi_streambuf(void); 0068 0069 int attach(FCGX_Stream * fcgx); 0070 0071 protected: 0072 0073 // Consume the put area (if buffered) and c (if c is not EOF). 0074 virtual int overflow(int); 0075 0076 // Flush the put area (if buffered) and the FCGX buffer to the client. 0077 virtual int sync(); 0078 0079 // Remove and return the current character. 0080 virtual int uflow(); 0081 0082 // Fill the get area (if buffered) and return the current character. 0083 virtual int underflow(); 0084 0085 // Use a buffer. The only reasons that a buffer would be useful is 0086 // to support the use of the unget()/putback() or seek() methods. Using 0087 // a buffer will result in less efficient I/O. Note: the underlying 0088 // FastCGI library (FCGX) maintains its own input and output buffers. 0089 virtual std::streambuf * setbuf(char_type * buf, std::streamsize len); 0090 0091 virtual std::streamsize xsgetn(char_type * s, std::streamsize n); 0092 virtual std::streamsize xsputn(const char_type * s, std::streamsize n); 0093 0094 private: 0095 0096 FCGX_Stream * fcgx; 0097 0098 // buf is just handy to have around 0099 char_type * buf; 0100 0101 // this isn't kept by the base class 0102 std::streamsize bufsize; 0103 0104 void init(FCGX_Stream * fcgx, char_type * buf, std::streamsize bufsize); 0105 0106 void reset(void); 0107 }; 0108 0109 /* 0110 * fcgi_istream - deprecated 0111 */ 0112 class DLLAPI fcgi_istream : public std::istream 0113 { 0114 public: 0115 0116 // deprecated 0117 fcgi_istream(FCGX_Stream * fcgx = 0); 0118 0119 // deprecated 0120 ~fcgi_istream(void) {} 0121 0122 // deprecated 0123 virtual void attach(FCGX_Stream * fcgx); 0124 0125 private: 0126 0127 fcgi_streambuf fcgi_strmbuf; 0128 }; 0129 0130 /* 0131 * fcgi_ostream - deprecated 0132 */ 0133 class DLLAPI fcgi_ostream : public std::ostream 0134 { 0135 public: 0136 0137 // deprecated 0138 fcgi_ostream(FCGX_Stream * fcgx = 0); 0139 0140 // deprecated 0141 ~fcgi_ostream(void) {} 0142 0143 // deprecated 0144 virtual void attach(FCGX_Stream *fcgx); 0145 0146 private: 0147 0148 fcgi_streambuf fcgi_strmbuf; 0149 }; 0150 0151 #endif /* FCGIO_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |