00001 #ifndef __FRCCID_H__
00002 #define __FRCCID_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include <stdlib.h>
00034 #include <string.h>
00035
00036 #include "XrdSys/XrdSysPthread.hh"
00037
00038 class XrdOucEnv;
00039 class XrdOucStream;
00040
00041 class XrdFrcCID
00042 {
00043 public:
00044 int Add(const char *iName, const char *cName, time_t addT, pid_t Pid);
00045
00046 int Get(const char *iName, char *buff, int blen);
00047
00048 int Get(const char *iName, const char *vName, XrdOucEnv *evP);
00049
00050 int Init(const char *qPath);
00051
00052 void Ref(const char *iName);
00053
00054 XrdFrcCID() : Dflt(0), First(0), cidFN(0), cidFN2(0) {}
00055 ~XrdFrcCID() {}
00056
00057 private:
00058
00059 struct cidEnt
00060 {cidEnt *Next;
00061 char *iName;
00062 char *cName;
00063 time_t addT;
00064 pid_t Pid;
00065 int useCnt;
00066 short iNLen;
00067 short cNLen;
00068
00069 cidEnt(cidEnt *epnt,const char *iname,const char *cname,
00070 time_t addt, pid_t idp)
00071 : Next(epnt), iName(strdup(*iname ? iname : "anon")),
00072 cName(strdup(cname)), addT(addt), Pid(idp), useCnt(0),
00073 iNLen(strlen(iName)), cNLen(strlen(cName)) {}
00074 ~cidEnt() {if (iName) free(iName); if (cName) free(cName);}
00075
00076 };
00077
00078 class cidMon {public:
00079 cidMon() {cidMutex.Lock();}
00080 ~cidMon() {cidMutex.UnLock();}
00081 private:
00082 static XrdSysMutex cidMutex;
00083 };
00084
00085 cidEnt *Find(const char *iName);
00086 int Init(XrdOucStream &cidFile);
00087 int Update();
00088
00089 cidEnt *Dflt;
00090 cidEnt *First;
00091 char *cidFN;
00092 char *cidFN2;
00093 };
00094
00095 namespace XrdFrc
00096 {
00097 extern XrdFrcCID CID;
00098 }
00099 #endif