ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

67 lines
1.4 KiB

  1. #ifndef CPPCMS_SCGI_H
  2. #define CPPCMS_SCGI_H
  3. #include "config.h"
  4. #include <cgicc/CgiInput.h>
  5. #include <ostream>
  6. #include <streambuf>
  7. #include <map>
  8. #include <unistd.h>
  9. #include "cppcms_error.h"
  10. #include "cgi_api.h"
  11. namespace cppcms {
  12. using namespace std;
  13. #if !defined(CPPCMS_EMBEDDED) || defined(CPPCMS_EMBEDDED_THREAD)
  14. namespace scgi {
  15. class scgi_outbuffer : public streambuf
  16. {
  17. int fd;
  18. public:
  19. scgi_outbuffer(int descriptor) : fd(descriptor) {};
  20. virtual int overflow ( int c = EOF );
  21. virtual streamsize xsputn(char const *s,streamsize n);
  22. virtual ~scgi_outbuffer();
  23. };
  24. };
  25. class scgi_session : public cgicc::CgiInput,
  26. public cgi_session,
  27. public cgicc_connection
  28. {
  29. int socket;
  30. scgi::scgi_outbuffer buf;
  31. map<string,string> envmap;
  32. cgicc::Cgicc *cgi_ptr;
  33. std::ostream out_stream;
  34. public:
  35. scgi_session(int s) :
  36. socket(s), buf(s), cgi_ptr(NULL), out_stream(&buf)
  37. {};
  38. virtual size_t read(char *data, size_t length);
  39. virtual std::string getenv(const char *var);
  40. virtual cgicc_connection &get_connection();
  41. virtual bool prepare();
  42. virtual string env(char const *variable);
  43. virtual cgicc::Cgicc &cgi();
  44. virtual ostream &cout();
  45. virtual ~scgi_session();
  46. };
  47. class scgi_api : public cgi_api {
  48. int fd;
  49. public:
  50. scgi_api(string socket,int backlog=1);
  51. virtual int get_socket();
  52. virtual cgi_session *accept_session();
  53. virtual ~scgi_api();
  54. };
  55. #endif
  56. };
  57. #endif