XrdSecProtocolsslProc.hh

Go to the documentation of this file.
00001 //         $Id: XrdSecProtocolsslProc.hh 38011 2011-02-08 18:35:57Z ganis $
00002 
00003 #ifndef __SECPROTOCOLSSL_PROC__
00004 #define __SECPROTOCOLSSL_PROC__
00005 
00006 #include "XrdOuc/XrdOucString.hh"
00007 #include "XrdOuc/XrdOucHash.hh"
00008 
00009 #include <sys/types.h>
00010 #include <sys/stat.h>
00011 #include <unistd.h>
00012 #include <fcntl.h>
00013 #include <dirent.h>
00014 
00015 class XrdSecProtocolsslProcFile
00016 {
00017 private:
00018   int fd;
00019   XrdOucString fname;
00020   bool procsync;
00021   time_t lastwrite;
00022 
00023 public:
00024   bool Open();
00025   bool Close() { if (fd>=0) close(fd);return true;}
00026   bool Write(long long val, int writedelay=0);
00027   bool Write(double val, int writedelay=0);
00028   bool Write(const char* str, int writedelay=0);
00029   bool WriteKeyVal(const char* key, unsigned long long value, int writedelay, bool truncate=0);
00030   long long Read();
00031   bool Read(XrdOucString &str);
00032   
00033 
00034   XrdSecProtocolsslProcFile(const char* name, bool syncit=false){fname = name;fd=0;procsync = syncit;lastwrite=0;};
00035   virtual ~XrdSecProtocolsslProcFile() {Close();};
00036 };
00037 
00038 class XrdSecProtocolsslProc
00039 {
00040 private:
00041   bool procsync;
00042   XrdOucString procdirectory;
00043   XrdOucHash<XrdSecProtocolsslProcFile> files;
00044 
00045 public:
00046   
00047   XrdSecProtocolsslProcFile* Handle(const char* name);
00048 
00049   XrdSecProtocolsslProc(const char* procdir, bool syncit) { 
00050     procdirectory = procdir; 
00051     procdirectory += "/ssl/";
00052     while((procdirectory.find("//")!=STR_NPOS)) { procdirectory.replace("//","/");}
00053     procsync = syncit;
00054   };
00055 
00056   bool Open() {
00057     XrdOucString doit="mkdir -p ";
00058     doit+=procdirectory;
00059     int rc = system(doit.c_str());
00060     if (rc == -1)
00061       return false;
00062 
00063     DIR* pd=opendir(procdirectory.c_str());
00064     if (!pd) {
00065       return false;
00066     } else {
00067       closedir(pd);
00068       return true;
00069     }
00070   }
00071 
00072   virtual ~XrdSecProtocolsslProc() {};
00073 };
00074 #endif
00075 

Generated on Tue Jul 5 14:47:01 2011 for ROOT_528-00b_version by  doxygen 1.5.1