CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/EventFilter/StorageManager/interface/CurlInterface.h

Go to the documentation of this file.
00001 // $Id: CurlInterface.h,v 1.4 2011/11/16 14:32:22 mommsen Exp $
00003 
00004 #ifndef EventFilter_StorageManager_CurlInterface_h
00005 #define EventFilter_StorageManager_CurlInterface_h
00006 
00007 #include "boost/shared_ptr.hpp"
00008 
00009 #include <curl/curl.h>
00010 #include <openssl/crypto.h>
00011 #include <pthread.h>
00012 #include <string>
00013 #include <vector>
00014 
00015 
00016 namespace stor {
00017 
00026   class CurlInterface
00027   {
00028 
00029   public:
00030 
00031     typedef std::vector<char> Content;
00032 
00033     ~CurlInterface();
00034 
00038     static boost::shared_ptr<CurlInterface> getInterface();
00039 
00047     CURLcode getContent(const std::string& url, const std::string& user, Content& content);
00048 
00055     CURLcode postBinaryMessage(const std::string& url, void* buf, size_t size, Content& content);
00056 
00057     
00058   private:
00059 
00060     CurlInterface();
00061 
00062     CURLcode do_curl(CURL*, const std::string& url, Content& content);
00063     static size_t writeToString(char* data, size_t size, size_t nmemb, Content* buffer);
00064     static void sslLockingFunction(int mode, int n, const char* file, int line);
00065     static unsigned long sslIdFunction();
00066     
00067     static boost::shared_ptr<CurlInterface> interface_;
00068     static pthread_mutex_t* mutexes_;
00069   };
00070 
00071   typedef boost::shared_ptr<CurlInterface> CurlInterfacePtr;
00072 
00073 } // namespace stor
00074 
00075 #endif // EventFilter_StorageManager_CurlInterface_h
00076 
00077