//
// Provides support for FastCGI via C++ iostreams.\r
//\r
-// $Id: fcgio.h,v 1.7 2001/11/20 03:24:18 robs Exp $
+// $Id: fcgio.h,v 1.8 2001/11/21 20:18:13 robs Exp $
//
// This work is based on routines written by George Feinberg. They
// have been mostly re-written and extensively changed by
{
public:
- DLLAPI fcgi_streambuf(FCGX_Stream * strm = NULL);
+ // Note that if no buf is assigned (the default), iostream methods\r
+ // such as peek(), unget() and putback() will fail. If a buf is\r
+ // assigned, I/O is a bit less effecient and output streams will\r
+ // have to be flushed (or the streambuf destroyed) before the next \r
+ // call to "accept".\r
+ DLLAPI fcgi_streambuf(FCGX_Stream * fcgx, char * buf, int len);\r
+ \r
+ DLLAPI fcgi_streambuf(char * buf, int len);\r
+ \r
+ DLLAPI fcgi_streambuf(FCGX_Stream * fcgx = NULL);\r
DLLAPI ~fcgi_streambuf(void);
- DLLAPI int attach(FCGX_Stream * strm);
+ DLLAPI int attach(FCGX_Stream * fcgx);
// Consume the put area (if buffered) and c (if c is not EOF).
DLLAPI virtual int overflow(int);
// this isn't kept by the base class\r
int bufsize;
\r
+ void init(FCGX_Stream * fcgx, char * buf, int bufsize);\r
+\r
void reset(void);\r
};
public:
// deprecated
- DLLAPI fcgi_istream(FCGX_Stream * strm = NULL);
+ DLLAPI fcgi_istream(FCGX_Stream * fcgx = NULL);
// deprecated
DLLAPI ~fcgi_istream(void) {}
// deprecated
- DLLAPI virtual void attach(FCGX_Stream * strm);
+ DLLAPI virtual void attach(FCGX_Stream * fcgx);
private:
public:
// deprecated
- DLLAPI fcgi_ostream(FCGX_Stream * strm = NULL);
+ DLLAPI fcgi_ostream(FCGX_Stream * fcgx = NULL);
// deprecated
DLLAPI ~fcgi_ostream(void) {}
// deprecated
- DLLAPI virtual void attach(FCGX_Stream *str);
+ DLLAPI virtual void attach(FCGX_Stream *fcgx);
private:
//
-// $Id: fcgio.cpp,v 1.8 2001/11/20 13:11:12 robs Exp $
+// $Id: fcgio.cpp,v 1.9 2001/11/21 20:18:12 robs Exp $
//
// Allows you communicate with FastCGI streams using C++ iostreams
//
#include "fcgio.h"
-fcgi_streambuf::fcgi_streambuf(FCGX_Stream * strm)
+fcgi_streambuf::fcgi_streambuf(FCGX_Stream * fcgx, char * buf, int bufsize)\r
+{\r
+ init(fcgx, buf, bufsize);\r
+}\r
+ \r
+fcgi_streambuf::fcgi_streambuf(char * buf, int bufsize)\r
+{\r
+ init(NULL, buf, bufsize);\r
+}\r
+ \r
+fcgi_streambuf::fcgi_streambuf(FCGX_Stream * fcgx)
{
- this->fcgx = strm;\r
- this->buf = NULL;
- this->bufsize = 0;\r
- setbuf(NULL, 0);
+ init(fcgx, NULL, 0);
}
fcgi_streambuf::~fcgi_streambuf(void)
{
overflow(EOF);
// FCGX_Finish()/FCGX_Accept() will flush and close
-}
+}\r
+\r
+void fcgi_streambuf::init(FCGX_Stream * fcgx, char * buf, int bufsize)\r
+{\r
+ this->fcgx = fcgx;\r
+ this->buf = NULL;\r
+ this->bufsize = NULL;\r
+ setbuf(buf, bufsize); \r
+}
int fcgi_streambuf::overflow(int c)
{
void fcgi_streambuf::reset(void)\r
{\r
// it should be ok to set up both the get and put areas\r
- char * end = this->buf + this->bufsize;\r
- setg(this->buf, this->buf, end);\r
- setp(this->buf, end);\r
+ setg(this->buf, this->buf, this->buf);\r
+ setp(this->buf, this->buf + this->bufsize);\r
}\r
\r
streambuf * fcgi_streambuf::setbuf(char * buf, int len)