Commit | Line | Data |
---|---|---|
c124bb9b | 1 | // |
f684a497 | 2 | // Provides support for FastCGI via C++ iostreams.\r |
3 | //\r | |
4 | // $Id: fcgio.h,v 1.6 2001/11/20 02:29:38 robs Exp $ | |
98e2ddaa | 5 | // |
6 | // This work is based on routines written by George Feinberg. They | |
7 | // have been mostly re-written and extensively changed by | |
c124bb9b | 8 | // Michael Richards. |
9 | // | |
98e2ddaa | 10 | // Rewritten again with bug fixes and numerous enhancements by |
f684a497 | 11 | // Michael Shell.\r |
12 | // \r | |
13 | // And rewritten again by Rob Saccoccio. | |
98e2ddaa | 14 | // |
15 | // Special Thanks to Dietmar Kuehl for his help and the numerous custom | |
16 | // streambuf examples on his web site. | |
17 | // | |
f684a497 | 18 | // Copyright (c) 2000 Tux the Linux Penguin\r |
19 | // Copyright (c) 2001 Rob Saccoccio and Chelsea Networks | |
c124bb9b | 20 | // |
21 | // You are free to use this software without charge or royalty | |
98e2ddaa | 22 | // as long as this notice is not removed or altered, and recognition |
c124bb9b | 23 | // is given to the author(s) |
24 | // | |
98e2ddaa | 25 | // This code is offered as-is without any warranty either expressed or |
26 | // implied; without even the implied warranty of MERCHANTABILITY or | |
f684a497 | 27 | // FITNESS FOR A PARTICULAR PURPOSE. If it breaks, you get to keep \r |
28 | // both halves. | |
98e2ddaa | 29 | |
c124bb9b | 30 | #ifndef FCGIO_H |
31 | #define FCGIO_H | |
98e2ddaa | 32 | |
c124bb9b | 33 | #include <iostream.h> |
02089704 | 34 | |
0a62d748 | 35 | #include "fcgiapp.h" |
02089704 | 36 | |
f684a497 | 37 | /* |
38 | * fcgi_streambuf | |
39 | */ | |
98e2ddaa | 40 | class fcgi_streambuf : public streambuf |
41 | { | |
f684a497 | 42 | public: |
98e2ddaa | 43 | |
f684a497 | 44 | DLLAPI fcgi_streambuf(FCGX_Stream * strm = NULL); |
98e2ddaa | 45 | |
f684a497 | 46 | DLLAPI ~fcgi_streambuf(void); |
98e2ddaa | 47 | |
f684a497 | 48 | DLLAPI int attach(FCGX_Stream * strm); |
98e2ddaa | 49 | |
f684a497 | 50 | // Consume the put area (if buffered) and c (if c is not EOF). |
51 | DLLAPI virtual int overflow(int); | |
98e2ddaa | 52 | |
f684a497 | 53 | // Flush the put area (if buffered) and the FCGX buffer to the client.\r |
54 | // Note: sync() is protected in some implementations. | |
55 | DLLAPI virtual int sync(); | |
98e2ddaa | 56 | |
f684a497 | 57 | // Fill the get area (if buffered) and return the next character. |
58 | DLLAPI virtual int underflow(); | |
98e2ddaa | 59 | |
f684a497 | 60 | // Use a buffer. The only reasons that a buffer would be useful is\r |
61 | // to support the use of the unget()/putback() or seek() methods. Using\r | |
62 | // a buffer will result in less efficient I/O. Note: the underlying\r | |
63 | // FastCGI library (FCGX) maintains its own input and output buffers. \r | |
64 | // Note: setbuf() is protected in some implementations. | |
65 | DLLAPI virtual streambuf * setbuf(char * buf, int len); | |
98e2ddaa | 66 | |
f684a497 | 67 | DLLAPI virtual int xsgetn(char * s, int n);\r |
68 | DLLAPI virtual int xsputn(const char * s, int n);\r | |
98e2ddaa | 69 | |
f684a497 | 70 | private: |
c124bb9b | 71 | |
f684a497 | 72 | FCGX_Stream * fcgx; |
c124bb9b | 73 | |
f684a497 | 74 | // buf is just handy to have around\r |
75 | char * buf;\r | |
76 | \r | |
77 | // this isn't kept by the base class\r | |
78 | int bufsize; | |
79 | \r | |
80 | void reset(void);\r | |
c124bb9b | 81 | }; |
82 | ||
f684a497 | 83 | /* |
84 | * fcgi_istream - deprecated | |
85 | */ | |
98e2ddaa | 86 | class fcgi_istream : public istream |
87 | { | |
f684a497 | 88 | public: |
98e2ddaa | 89 | |
f684a497 | 90 | // deprecated |
91 | DLLAPI fcgi_istream(FCGX_Stream * strm = NULL); | |
92 | ||
93 | // deprecated | |
94 | DLLAPI ~fcgi_istream(void) {} | |
98e2ddaa | 95 | |
f684a497 | 96 | // deprecated |
97 | DLLAPI virtual void attach(FCGX_Stream * strm); | |
98e2ddaa | 98 | |
f684a497 | 99 | private: |
c124bb9b | 100 | |
98e2ddaa | 101 | fcgi_streambuf fcgi_strmbuf; |
c124bb9b | 102 | }; |
103 | ||
f684a497 | 104 | /* |
105 | * fcgi_ostream - deprecated | |
106 | */ | |
98e2ddaa | 107 | class fcgi_ostream : public ostream |
108 | { | |
f684a497 | 109 | public: |
110 | ||
111 | // deprecated | |
112 | DLLAPI fcgi_ostream(FCGX_Stream * strm = NULL); | |
113 | ||
114 | // deprecated | |
115 | DLLAPI ~fcgi_ostream(void) {} | |
98e2ddaa | 116 | |
f684a497 | 117 | // deprecated |
118 | DLLAPI virtual void attach(FCGX_Stream *str); | |
98e2ddaa | 119 | |
f684a497 | 120 | private: |
c124bb9b | 121 | |
98e2ddaa | 122 | fcgi_streambuf fcgi_strmbuf; |
123 | }; | |
c124bb9b | 124 | |
f684a497 | 125 | #endif /* FCGIO_H */ |