00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014
00015
00016 #ifndef XRD_CENV_H
00017 #define XRD_CENV_H
00018
00019 #include "XrdOuc/XrdOucEnv.hh"
00020 #include "XrdSys/XrdSysPthread.hh"
00021
00022 #include <string.h>
00023
00024 using namespace std;
00025
00026
00027 #define EnvGetLong(x) XrdClientEnv::Instance()->ShellGetInt(x)
00028 #define EnvGetString(x) XrdClientEnv::Instance()->ShellGet(x)
00029 #define EnvPutString(name, val) XrdClientEnv::Instance()->Put(name, val)
00030 #define EnvPutInt(name, val) XrdClientEnv::Instance()->PutInt(name, val)
00031
00032 class XrdClientEnv {
00033 private:
00034
00035 XrdOucEnv *fOucEnv;
00036 XrdSysRecMutex fMutex;
00037 static XrdClientEnv *fgInstance;
00038 XrdOucEnv *fShellEnv;
00039
00040 protected:
00041 XrdClientEnv();
00042 ~XrdClientEnv();
00043
00044
00047
00048 bool ImportStr( const char *varname );
00049 bool ImportInt( const char *varname );
00050
00051 public:
00052
00053 const char * Get(const char *varname) {
00054 const char *res;
00055 XrdSysMutexHelper m(fMutex);
00056
00057 res = fOucEnv->Get(varname);
00058 return res;
00059 }
00060
00061 long GetInt(const char *varname) {
00062 long res;
00063 XrdSysMutexHelper m(fMutex);
00064
00065 res = fOucEnv->GetInt(varname);
00066 return res;
00067 }
00068
00069
00072
00073 const char *ShellGet( const char *varname );
00074
00075
00078
00079 long ShellGetInt( const char *varname );
00080
00081
00082 void Put(const char *varname, const char *value) {
00083 XrdSysMutexHelper m(fMutex);
00084
00085 fOucEnv->Put(varname, value);
00086 }
00087
00088 void PutInt(const char *varname, long value) {
00089 XrdSysMutexHelper m(fMutex);
00090
00091 fOucEnv->PutInt(varname, value);
00092 }
00093
00094 static XrdClientEnv *Instance();
00095 };
00096
00097 #endif