Loading...
Searching...
No Matches
XrdOucEnv Class Reference

`#include <XrdOucEnv.hh>`

Collaboration diagram for XrdOucEnv:

## Public Member Functions

| XrdOucEnv (const char *vardata=0, int vardlen=0, const XrdSecEntity *secent=0)
| ~XrdOucEnv ()
char * | Delimit (char *value)
char * | Env (int &envlen)
char * | EnvTidy (int &envlen)
char * | Get (const char *varname)
long | GetInt (const char *varname)
void * | GetPtr (const char *varname)
void | Put (const char *varname, const char *value)
void | PutInt (const char *varname, long value)
void | PutPtr (const char *varname, void *value)
const XrdSecEntity * | secEnv () const

## Static Public Member Functions

static int | Export (const char *Var, const char *Val)
static int | Export (const char *Var, int Val)
static bool | Import (const char *var, char *&val)
static bool | Import (const char *var, long &val)

## Detailed Description

Definition at line 41 of file XrdOucEnv.hh.

## Constructor & Destructor Documentation

## XrdOucEnv()

XrdOucEnv::XrdOucEnv | ( | const char * | vardata = 0,
|  | int | vardlen = 0,
|  | const XrdSecEntity * | secent = 0 )

Definition at line 42 of file XrdOucEnv.cc.

: env_Hash(8,13), secEntity(secent)
{
char *vdp, varsave, *varname, *varvalu;
if (!vardata) {global_env = 0; global_len = 0; return;}
// Get the length of the global information (don't rely on its being correct)
//
if (!varlen) varlen = strlen(vardata);
// We want our env copy to start with a single ampersand
//
while(*vardata == '&' && varlen) {vardata++; varlen--;}
if (!varlen) {global_env = 0; global_len = 0; return;}
global_env = (char *)malloc(varlen+2);
*global_env = '&'; vdp = global_env+1;
memcpy((void *)vdp, (const void *)vardata, (size_t)varlen);
*(vdp+varlen) = '\0'; global_len = varlen+1;
// scan through the string looking for '&'
//
while(*vdp)
{while(*vdp == '&') vdp++;
varname = vdp;
while(*vdp && *vdp != '=' && *vdp != '&') vdp++; // &....=
if (!*vdp) break;
if (*vdp == '&') continue;
*vdp = '\0';
varvalu = ++vdp;
while(*vdp && *vdp != '&') vdp++; // &....=....&
varsave = *vdp; *vdp = '\0';
if (*varname && *varvalu)
env_Hash.Rep(varname, strdup(varvalu), 0, Hash_dofree);
*vdp = varsave; *(varvalu-1) = '=';
}
return;
}
Hash_dofree
@ Hash_dofree
Definition XrdOucHash.hh:56

References Hash_dofree.

## ~XrdOucEnv()

XrdOucEnv::~XrdOucEnv | ( |  | ) |

inline

Definition at line 115 of file XrdOucEnv.hh.

{if (global_env) free((void *)global_env);}

## Member Function Documentation

## Delimit()

char * XrdOucEnv::Delimit | ( | char * | value | ) |

Definition at line 90 of file XrdOucEnv.cc.

{
while(*value) if (*value == ',') {*value = '\0'; return ++value;}
else value++;
return (char *)0;
}

## Env()

char * XrdOucEnv::Env | ( | int & | envlen | ) |

inline

Definition at line 48 of file XrdOucEnv.hh.

{envlen = global_len; return global_env;}

Referenced by XrdHttpExtReq::XrdHttpExtReq(), XrdPssUrlInfo::XrdPssUrlInfo(), EnvTidy(), XrdSsiFileResource::Init(), XrdCmsRedirLocal::Locate(), XrdPssFile::Open(), XrdOssSys::Stage_QT(), and XrdOssCsi::tagOpenEnv().

Here is the caller graph for this function:

## EnvTidy()

char * XrdOucEnv::EnvTidy | ( | int & | envlen | ) |

Definition at line 142 of file XrdOucEnv.cc.

{
char *tidyEnv;
int tries = 1;
// Check if there is no env
//
if ((envlen = global_len) == 0 || global_env == 0) return 0;
// Check if we have produced a tidy version. If noo build one and try again.
//
do{if ((tidyEnv = Get(TIDY_ENVVAR)))
{if (*tidyEnv == 0) break;
envlen = strlen(tidyEnv);
return tidyEnv;
}
EnvBuildTidy();
} while(tries--);
// Return standard env
//
return Env(envlen);
}
TIDY_ENVVAR
#define TIDY_ENVVAR
Definition XrdOucEnv.cc:101
XrdOucEnv::Env
char * Env(int &envlen)
Definition XrdOucEnv.hh:48
XrdOucEnv::Get
char * Get(const char *varname)
Definition XrdOucEnv.hh:69

References Env(), Get(), and TIDY_ENVVAR.

Referenced by XrdCmsFinderRMT::Forward(), and XrdCmsFinderRMT::Locate().

Here is the call graph for this function:
Here is the caller graph for this function:

## Export() [1/2]

int XrdOucEnv::Export | ( | const char * | Var,
|  | const char * | Val )

static

Definition at line 170 of file XrdOucEnv.cc.

{
int vLen = strlen(Var);
char *eBuff;
// If this is a null value then substitute a null string
//
if (!Val) Val = "";
// Allocate memory. Note that this memory will appear to be lost.
//
eBuff = (char *)malloc(vLen+strlen(Val)+2); // +2 for '=' and '\0'
// Set up envar
//
strcpy(eBuff, Var);
*(eBuff+vLen) = '=';
strcpy(eBuff+vLen+1, Val);
return putenv(eBuff);
}

Referenced by XrdOucPsx::ClientConfig(), XrdPfc::Cache::Config(), XrdOfs::Config_Display(), XrdOucLogging::configLog(), XrdCephOss::Configure(), XrdCmsClientConfig::Configure(), XrdConfig::Configure(), XrdFrmConfig::Configure(), XrdOfs::Configure(), XrdSecServer::Configure(), XrdXrootdProtocol::Configure(), XrdCmsConfig::Configure1(), XrdXrootdMonitor::Defaults(), Export(), XrdOfsEvr::Init(), XrdOfsTPC::Init(), XrdOssSpace::Init(), XrdOucN2NLoader::Load(), main(), XrdOucSiteName::Set(), XrdCmsSecurity::setSystemID(), XrdOfsTPC::Start(), and XrdXrootdloadFileSystem().

Here is the caller graph for this function:

## Export() [2/2]

int XrdOucEnv::Export | ( | const char * | Var,
|  | int | Val )

static

Definition at line 193 of file XrdOucEnv.cc.

{
char buff[32];
sprintf(buff, "%d", Val);
return Export(Var, buff);
}
XrdOucEnv::Export
static int Export(const char *Var, const char *Val)
Definition XrdOucEnv.cc:170

References Export().

Here is the call graph for this function:

## Get()

char * XrdOucEnv::Get | ( | const char * | varname | ) |

inline

Definition at line 69 of file XrdOucEnv.hh.

{return env_Hash.Find(varname);}

Referenced by XrdOssStats::FileSystem::FileSystem(), Macaroons::Authz::Access(), XrdAccSciTokens::Access(), XrdOssSys::Alloc_Cache(), XrdOfsTPC::Authorize(), XrdPfc::Cache::Config(), XrdOssSys::Configure(), XrdXrootdProtocol::Configure(), XrdOucUtils::doIf(), EnvTidy(), fillCephNbStripes(), fillCephObjectSize(), fillCephPool(), fillCephStripeUnit(), fillCephUserId(), XrdSecPManager::Get(), XrdSecProtocolgsi::getCredentials(), XrdSecProtocolkrb5::getCredentials(), XrdSecProtocolsss::getCredentials(), XrdOfsTPC::getTTL(), XrdSsiFileResource::Init(), XrdOfsConfigPI::Load(), XrdSecProtocolsss::Load_Client(), XrdCmsFinderRMT::Locate(), XrdOssFile::Open(), XrdPssFile::Open(), XrdBwmFile::open(), XrdThrottleManager::PrepLoadShed(), XrdPosixConfig::SetConfig(), XrdCmsFinderRMT::Space(), XrdOssSys::Stage_RT(), XrdOssSys::Stat(), XrdOssSys::StatLS(), XrdOssCsi::tagOpenEnv(), XrdOfsTPC::Validate(), XrdOssStatInfoInit(), and XrdSecgsiAuthzInit().

Here is the caller graph for this function:

## GetInt()

long XrdOucEnv::GetInt | ( | const char * | varname | ) |

Definition at line 235 of file XrdOucEnv.cc.

{
char *cP;
// Retrieve a char* value from the Hash table and convert it into a long.
// Return -999999999 if the varname does not exist
//
if ((cP = env_Hash.Find(varname)) == NULL) return -999999999;
return atol(cP);
}

Referenced by XrdSsiSfsConfig::Configure(), XrdXrootdProtocol::Configure(), and XrdThrottle::FileSystem::XrdSfsGetFileSystem_Internal.

Here is the caller graph for this function:

## GetPtr()

void * XrdOucEnv::GetPtr | ( | const char * | varname | ) |

Definition at line 263 of file XrdOucEnv.cc.

{
void *Valp;
char *cP, *Value = (char *)&Valp;
int cLen, n, i = 0, Odd = 0;
// Retrieve the variable from the hash
//
if ((cP = env_Hash.Find(varname)) == NULL) return (void *)0;
// Verify that the string is not too long or too short
//
if ((cLen = strlen(cP)) != (int)sizeof(void *)*2) return (void *)0;
// Now convert the hex string back to its pointer value
//
while(cLen--)
{ if (*cP >= '0' && *cP <= '9') n = *cP-48;
else if (*cP >= 'a' && *cP <= 'f') n = *cP-87;
else if (*cP >= 'A' && *cP <= 'F') n = *cP-55;
else return (void *)0;
if (Odd) Value[i++] |= n;
else Value[i ] = n << 4;
cP++; Odd = ~Odd;
}
// All done, return the actual pointer value
//
return Valp;
}

Referenced by XrdOssStats::FileSystem::FileSystem(), TPC::TPCHandler::TPCHandler(), XrdCmsFinderRMT::Configure(), XrdConfig::Configure(), XrdPfcFSctl::Configure(), XrdSsiSfsConfig::Configure(), XrdXrootdProtocol::Configure(), XrdPosixConfig::EnvInfo(), XrdOucStream::Exec(), XrdOssCsi::Init(), XrdHttpGetExtHandler(), XrdOfsgetPrepare(), and XrdOucGetCache().

Here is the caller graph for this function:

## Import() [1/2]

bool XrdOucEnv::Import | ( | const char * | var,
|  | char *& | val )

static

Definition at line 204 of file XrdOucEnv.cc.

{
char *value = getenv( var );
if( !value || !*value )
return false;
val = value;
return true;
}

Referenced by XrdVomsMapfile::Configure().

Here is the caller graph for this function:

## Import() [2/2]

bool XrdOucEnv::Import | ( | const char * | var,
|  | long & | val )

static

Definition at line 217 of file XrdOucEnv.cc.

{
char *value;
if( !Import( var, value ) )
return false;
char *status;
val = strtol( value, &status, 0 );
if( *status != 0 )
return false;
return true;
}
Import
bool Import
Definition XrdSecpwdSrvAdmin.cc:178

References Import.

## Put()

void XrdOucEnv::Put | ( | const char * | varname,
|  | const char * | value )

inline

Definition at line 85 of file XrdOucEnv.hh.

{env_Hash.Rep((char *)varname, strdup(value), 0, Hash_dofree);}

References Hash_dofree.

Referenced by XrdPosixXrootd::XrdPosixXrootd(), XrdPfc::Cache::Config(), XrdOfs::Configure(), XrdPfc::Cache::ExecuteCommandUrl(), XrdOfs::fsctl(), XrdFrcCID::Get(), XrdPssFile::Open(), XrdOfsTPC::Validate(), XrdPfc::DataFsSnapshot::write_json_file(), and XrdOssGetSS().

Here is the caller graph for this function:

## PutInt()

void XrdOucEnv::PutInt | ( | const char * | varname,
|  | long | value )

Definition at line 250 of file XrdOucEnv.cc.

{
// Convert the long into a char* and the put it into the hash table
//
char stringValue[24];
sprintf(stringValue, "%ld", value);
env_Hash.Rep(varname, strdup(stringValue), 0, Hash_dofree);
}

References Hash_dofree.

Referenced by XrdConfig::Configure(), XrdOfs::FAttr(), and XrdOssAddStorageSystem2().

Here is the caller graph for this function:

## PutPtr()

void XrdOucEnv::PutPtr | ( | const char * | varname,
|  | void * | value )

Definition at line 298 of file XrdOucEnv.cc.

{
static const char hv[] = "0123456789abcdef";
char Buff[sizeof(void *)*2+1], *Value = (char *)&value;
int i, j = 0;
// Convert the pointer value to a hex string
//
if (value) for (i = 0; i <(int)sizeof(void *); i++)
{Buff[j++] = hv[(Value[i] >> 4) & 0x0f];
Buff[j++] = hv[ Value[i] & 0x0f];
}
Buff[j] = '\0';
// Replace the value in he hash
//
env_Hash.Rep(varname, strdup(Buff), 0, Hash_dofree);
}

References Hash_dofree.

Referenced by XrdOssSys::ConfigStatLib(), XrdCmsFinderTRG::Configure(), XrdConfig::Configure(), XrdOfs::Configure(), XrdOssSys::Configure(), XrdXrootdProtocol::Configure(), XrdStats::Export(), XrdOucN2NLoader::Load(), XrdOucProg::Run(), and XrdOucGetCache().

Here is the caller graph for this function:

## secEnv()

const XrdSecEntity * XrdOucEnv::secEnv | ( |  | ) | const

inline

Definition at line 107 of file XrdOucEnv.hh.

{return secEntity;}

Referenced by XrdPssUrlInfo::XrdPssUrlInfo(), XrdPssSys::Connect(), XrdPssSys::Disc(), XrdSsiFileResource::Init(), XrdCmsRedirLocal::Locate(), XrdPssFile::Open(), and XrdOssCsi::tagOpenEnv().

Here is the caller graph for this function:

The documentation for this class was generated from the following files:

- XrdOucEnv.hh
- XrdOucEnv.cc