00001 #ifndef __XROOTD_PREPARE__H 00002 #define __XROOTD_PREPARE__H 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d P r e p a r e . h h */ 00006 /* */ 00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC03-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdXrootdPrepare.hh 22437 2008-03-04 14:35:16Z rdm $ 00014 00015 #include <dirent.h> 00016 #include <sys/types.h> 00017 00018 #include "Xrd/XrdJob.hh" 00019 #include "Xrd/XrdScheduler.hh" 00020 #include "XrdSys/XrdSysError.hh" 00021 #include "XrdOuc/XrdOucTList.hh" 00022 00023 /******************************************************************************/ 00024 /* X r d O l b P r e p A r g s */ 00025 /******************************************************************************/ 00026 00027 class XrdXrootdPrepArgs 00028 { 00029 public: 00030 friend class XrdXrootdPrepare; 00031 00032 char *reqid; 00033 char *user; 00034 char *notify; 00035 int prty; 00036 char mode[4]; 00037 XrdOucTList *paths; 00038 00039 XrdXrootdPrepArgs(int sfree=1, int pfree=1) 00040 {reqid = user = notify = 0; paths = 0; *mode = '\0'; 00041 dirP = 0; prty = reqlen = usrlen = 0; 00042 freestore = sfree; freepaths = pfree; 00043 } 00044 ~XrdXrootdPrepArgs() 00045 {XrdOucTList *tp; 00046 if (freestore) 00047 {if (reqid) free(reqid); 00048 if (notify) free(notify); 00049 } 00050 if (freepaths) while((tp=paths)) {paths=paths->next; delete tp;} 00051 if (dirP) closedir(dirP); 00052 } 00053 private: 00054 DIR *dirP; 00055 int reqlen; 00056 int usrlen; 00057 int freestore; 00058 int freepaths; 00059 }; 00060 00061 /******************************************************************************/ 00062 /* C l a s s X r d O l b P r e p a r e */ 00063 /******************************************************************************/ 00064 00065 class XrdXrootdPrepare : public XrdJob 00066 { 00067 public: 00068 00069 static int Close(int fd) {return close(fd);} 00070 00071 void DoIt() {Scrub(); 00072 SchedP->Schedule((XrdJob *)this, scrubtime+time(0)); 00073 } 00074 00075 static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen); 00076 00077 static void Log(XrdXrootdPrepArgs &pargs); 00078 00079 static void Logdel(char *reqid); 00080 00081 static int Open(const char *reqid, int &fsz); 00082 00083 static void Scrub(); 00084 00085 static int setParms(int stime, int skeep); 00086 00087 static int setParms(char *ldir); 00088 00089 XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp); 00090 ~XrdXrootdPrepare() {} // Never gets deleted 00091 00092 private: 00093 00094 static const char *TraceID; 00095 static XrdScheduler *SchedP; // System scheduler 00096 static XrdSysError *eDest; // Error message handler 00097 00098 static int scrubtime; 00099 static int scrubkeep; 00100 static char *LogDir; 00101 static int LogDirLen; 00102 }; 00103 #endif