summaryrefslogtreecommitdiffhomepage
path: root/plugins/fcgi/fcgi.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/fcgi/fcgi.h')
-rw-r--r--plugins/fcgi/fcgi.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/fcgi/fcgi.h b/plugins/fcgi/fcgi.h
index 7edfe91..164fecb 100644
--- a/plugins/fcgi/fcgi.h
+++ b/plugins/fcgi/fcgi.h
@@ -2,8 +2,60 @@
#include "../../plugin_interface.h"
+#include <set>
+#include <cstdint>
+
+// TODO: multithreading
+class FCGI_ID
+{
+ std::set<uint16_t >m_unused;
+ uint16_t m_current_max{};
+
+public:
+ FCGI_ID(){}
+
+ // starting at 1
+ uint16_t getID(){
+ if (m_unused.empty()) {
+ m_current_max++;
+ return m_current_max;
+ } else {
+ uint16_t result{*m_unused.begin()};
+ m_unused.erase(m_unused.begin());
+ return result;
+ }
+ }
+
+ void putID(uint16_t id){
+ m_unused.insert(id);
+ }
+};
+
+// automatically reserves ID, and releases it via RAII
+class FCGI_ID_Guard
+{
+ FCGI_ID& m_fcgi_id;
+ uint16_t m_id;
+
+public:
+ FCGI_ID_Guard(FCGI_ID& fcgi_id): m_fcgi_id(fcgi_id), m_id(fcgi_id.getID())
+ {
+ }
+
+ ~FCGI_ID_Guard()
+ {
+ m_fcgi_id.putID(m_id);
+ }
+
+ uint16_t getID() const { return m_id; }
+};
+
+struct FCGIContext;
+
class fcgi_plugin: public webserver_plugin_interface
{
+ FCGI_ID m_fcgi_id;
+
public:
fcgi_plugin();
~fcgi_plugin();
@@ -15,6 +67,7 @@ public:
std::function<void(const std::string& key, const std::string& value)>& SetResponseHeader // to be added to result string
);
+ std::string fcgiQuery(FCGIContext& context);
};
extern "C" BOOST_SYMBOL_EXPORT fcgi_plugin webserver_plugin;