cout instead of FCGX_FPrintF (c++)
Waldemar Biernacki <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
Tim Wood encourage me (thank you Tim!) to present my solution of the task.
Here it is.
I please (all of you) to comment it as I realize the solution has many holes:
Waldemar Biernacki
=================================================
#include <stdlib.h>
#include <iostream>
#include <string>
#include "fcgi_config.h"
#include "fcgiapp.h"
using namespace std;
extern char **environ;
FCGX_Stream *in, *out, *err;
FCGX_Stream & operator<<( FCGX_Stream &o, const char * s ) {
FCGX_FPrintF ( out, s );
return o;
}
FCGX_Stream & operator<<( FCGX_Stream &o, string s ) {
FCGX_FPrintF ( out, s.c_str() );
return o;
}
FCGX_Stream & operator<<( FCGX_Stream &o, int s ) {
FCGX_FPrintF ( out, "%d", s );
return o;
}
int main () {
FCGX_ParamArray envp;
int count = 0;
while ( FCGX_Accept ( &in, &out, &err, &envp ) >= 0 ) {
*out << "Content-type: text/html\r\n\r\n"
<< "<br> Request: "<< ++count <<" <br>";
string some_string = "Now we are testing strings... \n";
*out << "<br> " << some_string << "\n"
<< "<br>... Finish!";
}
return 0;
}
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/