Commit | Line | Data |
---|---|---|
c124bb9b | 1 | // |
f684a497 | 2 | // Provides support for FastCGI via C++ iostreams.\r |
3 | //\r | |
af4a4f30 | 4 | // $Id: fcgio.h,v 1.7 2001/11/20 03:24:18 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 | |
af4a4f30 | 37 | #ifndef DLLAPI |
38 | #ifdef _WIN32 | |
39 | #define DLLAPI __declspec(dllimport) | |
40 | #else | |
41 | #define DLLAPI | |
42 | #endif | |
43 | #endif | |
44 | ||
f684a497 | 45 | /* |
46 | * fcgi_streambuf | |
47 | */ | |
98e2ddaa | 48 | class fcgi_streambuf : public streambuf |
49 | { | |
f684a497 | 50 | public: |
98e2ddaa | 51 | |
f684a497 | 52 | DLLAPI fcgi_streambuf(FCGX_Stream * strm = NULL); |
98e2ddaa | 53 | |
f684a497 | 54 | DLLAPI ~fcgi_streambuf(void); |
98e2ddaa | 55 | |
f684a497 | 56 | DLLAPI int attach(FCGX_Stream * strm); |
98e2ddaa | 57 | |
f684a497 | 58 | // Consume the put area (if buffered) and c (if c is not EOF). |
59 | DLLAPI virtual int overflow(int); | |
98e2ddaa | 60 | |
f684a497 | 61 | // Flush the put area (if buffered) and the FCGX buffer to the client.\r |
62 | // Note: sync() is protected in some implementations. | |
63 | DLLAPI virtual int sync(); | |
98e2ddaa | 64 | |
f684a497 | 65 | // Fill the get area (if buffered) and return the next character. |
66 | DLLAPI virtual int underflow(); | |
98e2ddaa | 67 | |
f684a497 | 68 | // Use a buffer. The only reasons that a buffer would be useful is\r |
69 | // to support the use of the unget()/putback() or seek() methods. Using\r | |
70 | // a buffer will result in less efficient I/O. Note: the underlying\r | |
71 | // FastCGI library (FCGX) maintains its own input and output buffers. \r | |
72 | // Note: setbuf() is protected in some implementations. | |
73 | DLLAPI virtual streambuf * setbuf(char * buf, int len); | |
98e2ddaa | 74 | |
f684a497 | 75 | DLLAPI virtual int xsgetn(char * s, int n);\r |
76 | DLLAPI virtual int xsputn(const char * s, int n);\r | |
98e2ddaa | 77 | |
f684a497 | 78 | private: |
c124bb9b | 79 | |
f684a497 | 80 | FCGX_Stream * fcgx; |
c124bb9b | 81 | |
f684a497 | 82 | // buf is just handy to have around\r |
83 | char * buf;\r | |
84 | \r | |
85 | // this isn't kept by the base class\r | |
86 | int bufsize; | |
87 | \r | |
88 | void reset(void);\r | |
c124bb9b | 89 | }; |
90 | ||
f684a497 | 91 | /* |
92 | * fcgi_istream - deprecated | |
93 | */ | |
98e2ddaa | 94 | class fcgi_istream : public istream |
95 | { | |
f684a497 | 96 | public: |
98e2ddaa | 97 | |
f684a497 | 98 | // deprecated |
99 | DLLAPI fcgi_istream(FCGX_Stream * strm = NULL); | |
100 | ||
101 | // deprecated | |
102 | DLLAPI ~fcgi_istream(void) {} | |
98e2ddaa | 103 | |
f684a497 | 104 | // deprecated |
105 | DLLAPI virtual void attach(FCGX_Stream * strm); | |
98e2ddaa | 106 | |
f684a497 | 107 | private: |
c124bb9b | 108 | |
98e2ddaa | 109 | fcgi_streambuf fcgi_strmbuf; |
c124bb9b | 110 | }; |
111 | ||
f684a497 | 112 | /* |
113 | * fcgi_ostream - deprecated | |
114 | */ | |
98e2ddaa | 115 | class fcgi_ostream : public ostream |
116 | { | |
f684a497 | 117 | public: |
118 | ||
119 | // deprecated | |
120 | DLLAPI fcgi_ostream(FCGX_Stream * strm = NULL); | |
121 | ||
122 | // deprecated | |
123 | DLLAPI ~fcgi_ostream(void) {} | |
98e2ddaa | 124 | |
f684a497 | 125 | // deprecated |
126 | DLLAPI virtual void attach(FCGX_Stream *str); | |
98e2ddaa | 127 | |
f684a497 | 128 | private: |
c124bb9b | 129 | |
98e2ddaa | 130 | fcgi_streambuf fcgi_strmbuf; |
131 | }; | |
c124bb9b | 132 | |
f684a497 | 133 | #endif /* FCGIO_H */ |