xrootd
XrdFrcCID.hh
Go to the documentation of this file.
1 #ifndef __FRCCID_H__
2 #define __FRCCID_H__
3 /******************************************************************************/
4 /* */
5 /* X r d F r c C I D . h h */
6 /* */
7 /* (c) 2010 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 <stdlib.h>
34 #include <string.h>
35 
36 #include "XrdSys/XrdSysPthread.hh"
37 
38 class XrdOucEnv;
39 class XrdOucStream;
40 
41 class XrdFrcCID
42 {
43 public:
44  int Add(const char *iName, const char *cName, time_t addT, pid_t Pid);
45 
46  int Get(const char *iName, char *buff, int blen);
47 
48  int Get(const char *iName, const char *vName, XrdOucEnv *evP);
49 
50  int Init(const char *qPath);
51 
52  void Ref(const char *iName);
53 
54  XrdFrcCID() : Dflt(0), First(0), cidFN(0), cidFN2(0) {}
56 
57 private:
58 
59 struct cidEnt
61  char *iName;
62  char *cName;
63  time_t addT;
64  pid_t Pid;
65  int useCnt;
66  short iNLen;
67  short cNLen;
68 
69  cidEnt(cidEnt *epnt,const char *iname,const char *cname,
70  time_t addt, pid_t idp)
71  : Next(epnt), iName(strdup(*iname ? iname : "anon")),
72  cName(strdup(cname)), addT(addt), Pid(idp), useCnt(0),
73  iNLen(strlen(iName)), cNLen(strlen(cName)) {}
74  ~cidEnt() {if (iName) free(iName); if (cName) free(cName);}
75 
76  };
77 
78 class cidMon {public:
81  private:
83  };
84 
85 cidEnt *Find(const char *iName);
86 int Init(XrdOucStream &cidFile);
87 int Update();
88 
91 char *cidFN;
92 char *cidFN2;
93 };
94 
95 namespace XrdFrc
96 {
97 extern XrdFrcCID CID;
98 }
99 #endif
XrdFrcCID()
Definition: XrdFrcCID.hh:54
static XrdSysMutex cidMutex
Definition: XrdFrcCID.hh:82
cidEnt * Next
Definition: XrdFrcCID.hh:60
pid_t Pid
Definition: XrdFrcCID.hh:64
Definition: XrdOucStream.hh:46
cidMon()
Definition: XrdFrcCID.hh:79
Definition: XrdFrcCID.hh:95
short iNLen
Definition: XrdFrcCID.hh:66
char * iName
Definition: XrdFrcCID.hh:61
Definition: XrdSysPthread.hh:165
cidEnt * Dflt
Definition: XrdFrcCID.hh:89
int Update()
int Get(const char *iName, char *buff, int blen)
~cidEnt()
Definition: XrdFrcCID.hh:74
Definition: XrdOucEnv.hh:41
cidEnt * First
Definition: XrdFrcCID.hh:90
char * cidFN
Definition: XrdFrcCID.hh:91
int useCnt
Definition: XrdFrcCID.hh:65
~XrdFrcCID()
Definition: XrdFrcCID.hh:55
void Lock()
Definition: XrdSysPthread.hh:222
int Init(const char *qPath)
Definition: XrdFrcCID.hh:78
cidEnt * Find(const char *iName)
char * cidFN2
Definition: XrdFrcCID.hh:92
int Add(const char *iName, const char *cName, time_t addT, pid_t Pid)
time_t addT
Definition: XrdFrcCID.hh:63
XrdFrcCID CID
char * cName
Definition: XrdFrcCID.hh:62
Definition: XrdFrcCID.hh:59
Definition: XrdFrcCID.hh:41
void UnLock()
Definition: XrdSysPthread.hh:224
void Ref(const char *iName)
short cNLen
Definition: XrdFrcCID.hh:67
cidEnt(cidEnt *epnt, const char *iname, const char *cname, time_t addt, pid_t idp)
Definition: XrdFrcCID.hh:69
~cidMon()
Definition: XrdFrcCID.hh:80