2 // Provides support for FastCGI via C++ iostreams.
4 // $Id: fcgio.h,v 1.9 2001/11/21 21:12:04 robs Exp $
6 // This work is based on routines written by George Feinberg. They
7 // have been mostly re-written and extensively changed by
10 // Rewritten again with bug fixes and numerous enhancements by
13 // And rewritten again by Rob Saccoccio.
15 // Special Thanks to Dietmar Kuehl for his help and the numerous custom
16 // streambuf examples on his web site.
18 // Copyright (c) 2000 Tux the Linux Penguin
19 // Copyright (c) 2001 Rob Saccoccio and Chelsea Networks
21 // You are free to use this software without charge or royalty
22 // as long as this notice is not removed or altered, and recognition
23 // is given to the author(s)
25 // This code is offered as-is without any warranty either expressed or
26 // implied; without even the implied warranty of MERCHANTABILITY or
27 // FITNESS FOR A PARTICULAR PURPOSE. If it breaks, you get to keep
39 #define DLLAPI __declspec(dllimport)
48 class fcgi_streambuf : public streambuf
52 // Note that if no buf is assigned (the default), iostream methods
53 // such as peek(), unget() and putback() will fail. If a buf is
54 // assigned, I/O is a bit less effecient and output streams will
55 // have to be flushed (or the streambuf destroyed) before the next
57 DLLAPI fcgi_streambuf(FCGX_Stream * fcgx, char * buf, int len);
59 DLLAPI fcgi_streambuf(char * buf, int len);
61 DLLAPI fcgi_streambuf(FCGX_Stream * fcgx = NULL);
63 DLLAPI ~fcgi_streambuf(void);
65 DLLAPI int attach(FCGX_Stream * fcgx);
67 // Consume the put area (if buffered) and c (if c is not EOF).
68 DLLAPI virtual int overflow(int);
70 // Flush the put area (if buffered) and the FCGX buffer to the client.
71 // Note: sync() is protected in some implementations.
72 DLLAPI virtual int sync();
74 // Fill the get area (if buffered) and return the next character.
75 DLLAPI virtual int underflow();
77 // Use a buffer. The only reasons that a buffer would be useful is
78 // to support the use of the unget()/putback() or seek() methods. Using
79 // a buffer will result in less efficient I/O. Note: the underlying
80 // FastCGI library (FCGX) maintains its own input and output buffers.
81 // Note: setbuf() is protected in some implementations.
82 DLLAPI virtual streambuf * setbuf(char * buf, int len);
84 DLLAPI virtual int xsgetn(char * s, int n);
85 DLLAPI virtual int xsputn(const char * s, int n);
91 // buf is just handy to have around
94 // this isn't kept by the base class
97 void init(FCGX_Stream * fcgx, char * buf, int bufsize);
103 * fcgi_istream - deprecated
105 class fcgi_istream : public istream
110 DLLAPI fcgi_istream(FCGX_Stream * fcgx = NULL);
113 DLLAPI ~fcgi_istream(void) {}
116 DLLAPI virtual void attach(FCGX_Stream * fcgx);
120 fcgi_streambuf fcgi_strmbuf;
124 * fcgi_ostream - deprecated
126 class fcgi_ostream : public ostream
131 DLLAPI fcgi_ostream(FCGX_Stream * fcgx = NULL);
134 DLLAPI ~fcgi_ostream(void) {}
137 DLLAPI virtual void attach(FCGX_Stream *fcgx);
141 fcgi_streambuf fcgi_strmbuf;