#ifndef _KM3NET_DB__CLIENT_H_ #define _KM3NET_DB__CLIENT_H_ #include "KM3NeTDBClient.h" #include "KM3NeTDBServer.h" #include "KM3NeTDBResultSet.h" #include #include #include #include #include #include #include #include #include #include #include #include #define PERSISTENT_CONN_CHAR '_' using namespace KM3NeT; using namespace KM3NeT::DB; class _Client : public Client { private: std::string _Usr; std::string _Pwd; std::string _ConnCookie; Server _Srv; const SSL_METHOD *_method; SSL_CTX *_ctx; SSL *_ssl; int _sockfd; struct hostent *_host; struct sockaddr_in _dest_addr; X509 *_cert; char _read_buf[65536]; int _bytes; int _consumedbytes; bool _chunked; int _thischunksize; std::shared_ptr pResultSet; void _ZeroAll(); void _ReleaseAll(); void _InitSSL(); void _SSLConnect(); void _SSLDisconnect(); void _Init(); public: void Close(); inline const std::string& User() const override { return _Usr; } inline const Server &ServerEndPoint() const override { return _Srv; } _Client(const Server &srv, const char *usr, const char *pwd); _Client(const Server &srv, const char *persistentcookie); _Client(); private: inline std::string _GetEnv(const char *env) { char *e = std::getenv(env); return std::string(e ? e : ""); } int ReadBytes(); int _ProcessHTTPHeaders(std::vector &headers, int &scan); int _ProcessHTTPHeaders(std::vector &headers); std::shared_ptr _DetX(std::ostringstream &oss, int run, const char *t0set, const char *calibset); std::shared_ptr _DetX(std::ostringstream &oss, int run); std::shared_ptr _DetX(std::ostringstream &oss, int run, int version); std::shared_ptr _DetX(std::ostringstream &oss, const char *tcal, const char *pcal, const char *rcal); std::shared_ptr _DetX(std::ostringstream &oss, const char *tcal, const char *pcal, const char *rcal, const char *acal, const char *ccal, const char *scal, int version); std::shared_ptr APIv2Access(const char mode, const char *apiversion, const char *entrypoint, const std::vector &selectors); public: std::shared_ptr DetX(int detector, int run, const char *t0set, const char *calibset = 0); std::shared_ptr DetX(const char *detector, int run, const char *t0set, const char *calibset = 0); std::shared_ptr DetX(int detector, int run); std::shared_ptr DetX(const char *detector, int run); std::shared_ptr DetX(int detector, const char *tcal, const char *pcal, const char *rcal); std::shared_ptr DetX(const char *detector, const char *tcal, const char *pcal, const char *rcal); std::shared_ptr DetX(int detector, const char *tcal, const char *pcal, const char *rcal, const char *acal, const char *ccal, const char *scal, int version); std::shared_ptr DetX(const char *detector, const char *tcal, const char *pcal, const char *rcal, const char *acal, const char *ccal, const char *scal, int version); std::shared_ptr DetX(int detector, int run, int version); std::shared_ptr DetX(const char *detector, int run, int version); ResultSet &StreamDS(); ResultSet &StreamDS(const char *streamname, const std::vector &selectors); void _ResultSetClose(); int _GetBytes(char *&data); std::shared_ptr APIv2Help(const char *apiversion, const char *entrypoint); std::shared_ptr APIv2Select(const char *apiversion, const char *entrypoint, const std::vector &selectors); }; #endif