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