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-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <dirent.h>
34 #include <sys/types.h>
35 
36 #include "Xrd/XrdJob.hh"
37 #include "Xrd/XrdScheduler.hh"
38 #include "XrdSys/XrdSysError.hh"
39 #include "XrdOuc/XrdOucTList.hh"
40 
41 /******************************************************************************/
42 /* X r d O l b P r e p A r g s */
43 /******************************************************************************/
44 
46 {
47 public:
48 friend class XrdXrootdPrepare;
49 
50 char *reqid;
51 char *user;
52 char *notify;
53 int prty;
54 char mode[4];
56 
57  XrdXrootdPrepArgs(int sfree=1, int pfree=1)
58  {reqid = user = notify = 0; paths = 0; *mode = '\0';
59  dirP = 0; prty = reqlen = usrlen = 0;
60  freestore = sfree; freepaths = pfree;
61  }
63  {XrdOucTList *tp;
64  if (freestore)
65  {if (reqid) free(reqid);
66  if (notify) free(notify);
67  }
68  if (freepaths) while((tp=paths)) {paths=paths->next; delete tp;}
69  if (dirP) closedir(dirP);
70  }
71 private:
72 DIR *dirP;
73 int reqlen;
74 int usrlen;
75 int freestore;
76 int freepaths;
77 };
78 
79 /******************************************************************************/
80 /* C l a s s X r d O l b P r e p a r e */
81 /******************************************************************************/
82 
83 class XrdXrootdPrepare : public XrdJob
84 {
85 public:
86 
87 static int Close(int fd) {return close(fd);}
88 
89  void DoIt() {Scrub();
90  SchedP->Schedule((XrdJob *)this, scrubtime+time(0));
91  }
92 
93 static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen);
94 
95 static void Log(XrdXrootdPrepArgs &pargs);
96 
97 static void Logdel(char *reqid);
98 
99 static int Open(const char *reqid, int &fsz);
100 
101 static void Scrub();
102 
103 static int setParms(int stime, int skeep);
104 
105 static int setParms(char *ldir);
106 
107  XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp, bool nomsg);
108  ~XrdXrootdPrepare() {} // Never gets deleted
109 
110 private:
111 
112 static const char *TraceID;
113 static XrdScheduler *SchedP; // System scheduler
114 static XrdSysError *eDest; // Error message handler
115 
116 static int scrubtime;
117 static int scrubkeep;
118 static char *LogDir;
119 static int LogDirLen;
120 };
121 #endif
int closedir(DIR *dirp)
#define close(a)
Definition: XrdPosix.hh:43
Definition: XrdJob.hh:43
XrdOucTList * next
Definition: XrdOucTList.hh:45
void Schedule(XrdJob *jp)
XrdXrootdPrepArgs(int sfree=1, int pfree=1)
XrdOucTList * paths
static int List(XrdXrootdPrepArgs &pargs, char *resp, int resplen)
static void Log(XrdXrootdPrepArgs &pargs)
static void Logdel(char *reqid)
static void Scrub()
static int Close(int fd)
static int setParms(int stime, int skeep)
XrdXrootdPrepare(XrdSysError *lp, XrdScheduler *sp, bool nomsg)
static int Open(const char *reqid, int &fsz)