xrootd
XrdXrootdPrepare.hh
Go to the documentation of this file.
1 #ifndef __XROOTD_PREPARE__H
2 #define __XROOTD_PREPARE__H
3 /******************************************************************************/
4 /* */
5 /* X r d X r o o t d P r e p a r e . h h */
6 /* */
7 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC03-76-SFO0515 with the Department of Energy */
11 /******************************************************************************/
12 
13 // $Id$
14 
15 #include <dirent.h>
16 #include <sys/types.h>
17 
18 #include "Xrd/XrdJob.hh"
19 #include "Xrd/XrdScheduler.hh"
20 #include "XrdSys/XrdSysError.hh"
21 #include "XrdOuc/XrdOucTList.hh"
22 
23 /******************************************************************************/
24 /* X r d O l b P r e p A r g s */
25 /******************************************************************************/
26 
28 {
29 public:
30 friend class XrdXrootdPrepare;
31 
32 char *reqid;
33 char *user;
34 char *notify;
35 int prty;
36 char mode[4];
38 
39  XrdXrootdPrepArgs(int sfree=1, int pfree=1)
40  {reqid = user = notify = 0; paths = 0; *mode = '\0';
41  dirP = 0; prty = reqlen = usrlen = 0;
42  freestore = sfree; freepaths = pfree;
43  }
45  {XrdOucTList *tp;
46  if (freestore)
47  {if (reqid) free(reqid);
48  if (notify) free(notify);
49  }
50  if (freepaths) while((tp=paths)) {paths=paths->next; delete tp;}
51  if (dirP) closedir(dirP);
52  }
53 private:
54 DIR *dirP;
55 int reqlen;
56 int usrlen;
59 };
60 
61 /******************************************************************************/
62 /* C l a s s X r d O l b P r e p a r e */
63 /******************************************************************************/
64 
65 class XrdXrootdPrepare : public XrdJob
66 {
67 public:
68 
69 static int Close(int fd) {return close(fd);}
70 
71  void DoIt() {Scrub();
72  SchedP->Schedule((XrdJob *)this, scrubtime+time(0));
73  }
74 
75 static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen);
76 
77 static void Log(XrdXrootdPrepArgs &pargs);
78 
79 static void Logdel(char *reqid);
80 
81 static int Open(const char *reqid, int &fsz);
82 
83 static void Scrub();
84 
85 static int setParms(int stime, int skeep);
86 
87 static int setParms(char *ldir);
88 
90  ~XrdXrootdPrepare() {} // Never gets deleted
91 
92 private:
93 
94 static const char *TraceID;
95 static XrdScheduler *SchedP; // System scheduler
96 static XrdSysError *eDest; // Error message handler
97 
98 static int scrubtime;
99 static int scrubkeep;
100 static char *LogDir;
101 static int LogDirLen;
102 };
103 #endif