//
-// $Id: fcgio.cpp,v 1.9 2001/11/21 20:18:12 robs Exp $
+// $Id: fcgio.cpp,v 1.10 2001/11/21 20:54:24 robs Exp $
//
// Allows you communicate with FastCGI streams using C++ iostreams
//
#include "fcgio.h"
-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, char * buf, int bufsize)
+{
+ init(fcgx, buf, bufsize);
+}
+
+fcgi_streambuf::fcgi_streambuf(char * buf, int bufsize)
+{
+ init(NULL, buf, bufsize);
+}
+
fcgi_streambuf::fcgi_streambuf(FCGX_Stream * fcgx)
{
init(fcgx, NULL, 0);
{
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
+}
+
+void fcgi_streambuf::init(FCGX_Stream * fcgx, char * buf, int bufsize)
+{
+ this->fcgx = fcgx;
+ this->buf = NULL;
+ this->bufsize = 0;
+ setbuf(buf, bufsize);
}
int fcgi_streambuf::overflow(int c)
return 0;
}
-// default base class behaviour seems to be inconsistent\r
+// default base class behaviour seems to be inconsistent
int fcgi_streambuf::sync()
{
- if (overflow(EOF)) return EOF;\r
+ if (overflow(EOF)) return EOF;
if (FCGX_FFlush(this->fcgx)) return EOF;
return 0;
}
}
}
-void fcgi_streambuf::reset(void)\r
-{\r
- // it should be ok to set up both the get and put areas\r
- setg(this->buf, this->buf, this->buf);\r
- setp(this->buf, this->buf + this->bufsize);\r
-}\r
-\r
+void fcgi_streambuf::reset(void)
+{
+ // it should be ok to set up both the get and put areas
+ setg(this->buf, this->buf, this->buf);
+ setp(this->buf, this->buf + this->bufsize);
+}
+
streambuf * fcgi_streambuf::setbuf(char * buf, int len)
{
- // XXX support moving data from an old buffer\r
- if (this->bufsize) return NULL;\r
-\r
- this->buf = buf;\r
- this->bufsize = len;\r
-\r
- // the base setbuf() *has* to be called\r
+ // XXX support moving data from an old buffer
+ if (this->bufsize) return NULL;
+
+ this->buf = buf;
+ this->bufsize = len;
+
+ // the base setbuf() *has* to be called
streambuf::setbuf(buf, len);
- reset();\r
+ reset();
return this;
-}\r
-\r
-int fcgi_streambuf::attach(FCGX_Stream * strm)\r
-{ \r
- this->fcgx = strm;\r
-\r
- if (this->bufsize)\r
- {\r
- reset();\r
- }\r
-\r
- return 0;\r
+}
+
+int fcgi_streambuf::attach(FCGX_Stream * strm)
+{
+ this->fcgx = strm;
+
+ if (this->bufsize)
+ {
+ reset();
+ }
+
+ return 0;
}
int fcgi_streambuf::xsgetn(char * s, int n)
-{\r
- return (this->bufsize) \r
- ? streambuf::xsgetn(s, n) \r
+{
+ return (this->bufsize)
+ ? streambuf::xsgetn(s, n)
: FCGX_GetStr(s, n, this->fcgx);
-}\r
- \r
+}
+
int fcgi_streambuf::xsputn(const char * s, int n)
-{\r
- return (this->bufsize) \r
- ? streambuf::xsputn(s, n) \r
- : FCGX_PutStr(s, n, this->fcgx);\r
-}\r
-\r
-// deprecated\r
-fcgi_istream::fcgi_istream(FCGX_Stream * strm) :\r
+{
+ return (this->bufsize)
+ ? streambuf::xsputn(s, n)
+ : FCGX_PutStr(s, n, this->fcgx);
+}
+
+// deprecated
+fcgi_istream::fcgi_istream(FCGX_Stream * strm) :
istream(&fcgi_strmbuf)
{
fcgi_strmbuf.attach(strm);
}
-// deprecated\r
+// deprecated
void fcgi_istream::attach(FCGX_Stream * strm)
{
fcgi_strmbuf.attach(strm);
}
-// deprecated\r
+// deprecated
fcgi_ostream::fcgi_ostream(FCGX_Stream * strm) :
- ostream(&fcgi_strmbuf)\r
+ ostream(&fcgi_strmbuf)
{
fcgi_strmbuf.attach(strm);
}
-// deprecated\r
+// deprecated
void fcgi_ostream::attach(FCGX_Stream * strm)
{
fcgi_strmbuf.attach(strm);