|
xrootd
|
00001 #ifndef __FRCCID_H__ 00002 #define __FRCCID_H__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d F r c C I D . h h */ 00006 /* */ 00007 /* (c) 2010 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 00013 #include <stdlib.h> 00014 #include <string.h> 00015 00016 #include "XrdSys/XrdSysPthread.hh" 00017 00018 class XrdOucEnv; 00019 class XrdOucStream; 00020 00021 class XrdFrcCID 00022 { 00023 public: 00024 int Add(const char *iName, const char *cName, time_t addT, pid_t Pid); 00025 00026 int Get(const char *iName, char *buff, int blen); 00027 00028 int Get(const char *iName, const char *vName, XrdOucEnv *evP); 00029 00030 int Init(const char *qPath); 00031 00032 void Ref(const char *iName); 00033 00034 XrdFrcCID() : Dflt(0), First(0), cidFN(0), cidFN2(0) {} 00035 ~XrdFrcCID() {} 00036 00037 private: 00038 00039 struct cidEnt 00040 {cidEnt *Next; 00041 char *iName; 00042 char *cName; 00043 time_t addT; 00044 pid_t Pid; 00045 int useCnt; 00046 short iNLen; 00047 short cNLen; 00048 00049 cidEnt(cidEnt *epnt,const char *iname,const char *cname, 00050 time_t addt, pid_t idp) 00051 : Next(epnt), iName(strdup(*iname ? iname : "anon")), 00052 cName(strdup(cname)), addT(addt), Pid(idp), useCnt(0), 00053 iNLen(strlen(iName)), cNLen(strlen(cName)) {} 00054 ~cidEnt() {if (iName) free(iName); if (cName) free(cName);} 00055 00056 }; 00057 00058 class cidMon {public: 00059 cidMon() {cidMutex.Lock();} 00060 ~cidMon() {cidMutex.UnLock();} 00061 private: 00062 static XrdSysMutex cidMutex; 00063 }; 00064 00065 cidEnt *Find(const char *iName); 00066 int Init(XrdOucStream &cidFile); 00067 int Update(); 00068 00069 cidEnt *Dflt; 00070 cidEnt *First; 00071 char *cidFN; 00072 char *cidFN2; 00073 }; 00074 00075 namespace XrdFrc 00076 { 00077 extern XrdFrcCID CID; 00078 } 00079 #endif
1.7.5