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-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <dirent.h> 00034 #include <sys/types.h> 00035 00036 #include "Xrd/XrdJob.hh" 00037 #include "Xrd/XrdScheduler.hh" 00038 #include "XrdSys/XrdSysError.hh" 00039 #include "XrdOuc/XrdOucTList.hh" 00040 00041 /******************************************************************************/ 00042 /* X r d O l b P r e p A r g s */ 00043 /******************************************************************************/ 00044 00045 class XrdXrootdPrepArgs 00046 { 00047 public: 00048 friend class XrdXrootdPrepare; 00049 00050 char *reqid; 00051 char *user; 00052 char *notify; 00053 int prty; 00054 char mode[4]; 00055 XrdOucTList *paths; 00056 00057 XrdXrootdPrepArgs(int sfree=1, int pfree=1) 00058 {reqid = user = notify = 0; paths = 0; *mode = '\0'; 00059 dirP = 0; prty = reqlen = usrlen = 0; 00060 freestore = sfree; freepaths = pfree; 00061 } 00062 ~XrdXrootdPrepArgs() 00063 {XrdOucTList *tp; 00064 if (freestore) 00065 {if (reqid) free(reqid); 00066 if (notify) free(notify); 00067 } 00068 if (freepaths) while((tp=paths)) {paths=paths->next; delete tp;} 00069 if (dirP) closedir(dirP); 00070 } 00071 private: 00072 DIR *dirP; 00073 int reqlen; 00074 int usrlen; 00075 int freestore; 00076 int freepaths; 00077 }; 00078 00079 /******************************************************************************/ 00080 /* C l a s s X r d O l b P r e p a r e */ 00081 /******************************************************************************/ 00082 00083 class XrdXrootdPrepare : public XrdJob 00084 { 00085 public: 00086 00087 static int Close(int fd) {return close(fd);} 00088 00089 void DoIt() {Scrub(); 00090 SchedP->Schedule((XrdJob *)this, scrubtime+time(0)); 00091 } 00092 00093 static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen); 00094 00095 static void Log(XrdXrootdPrepArgs &pargs); 00096 00097 static void Logdel(char *reqid); 00098 00099 static int Open(const char *reqid, int &fsz); 00100 00101 static void Scrub(); 00102 00103 static int setParms(int stime, int skeep); 00104 00105 static int setParms(char *ldir); 00106 00107 XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp); 00108 ~XrdXrootdPrepare() {} // Never gets deleted 00109 00110 private: 00111 00112 static const char *TraceID; 00113 static XrdScheduler *SchedP; // System scheduler 00114 static XrdSysError *eDest; // Error message handler 00115 00116 static int scrubtime; 00117 static int scrubkeep; 00118 static char *LogDir; 00119 static int LogDirLen; 00120 }; 00121 #endif