• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

XrdOucEnv.hh

Go to the documentation of this file.
00001 #ifndef __OUC_ENV__
00002 #define __OUC_ENV__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                          X r d O u c E n v . h h                           */
00006 /*                                                                            */
00007 /* (c) 2003 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-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012   
00013 //         $Id: XrdOucEnv.hh,v 1.6 2010/01/25 11:07:06 abh Exp $
00014 
00015 #include <stdlib.h>
00016 #ifndef WIN32
00017 #include <strings.h>
00018 #endif
00019 #include "XrdOuc/XrdOucHash.hh"
00020 
00021 class XrdSecEntity;
00022 
00023 class XrdOucEnv
00024 {
00025 public:
00026 
00027 // Env() returns the full environment string and length passed to the
00028 //       constructor.
00029 //
00030 inline char *Env(int &envlen) {envlen = global_len; return global_env;}
00031 
00032 // Export() sets an external environmental variable to the desired value
00033 //          using dynamically allocated fixed storage.
00034 //
00035 static int   Export(const char *Var, const char *Val);
00036 static int   Export(const char *Var, int         Val);
00037 
00038 // Get() returns the address of the string associated with the variable
00039 //       name. If no association exists, zero is returned.
00040 //
00041        char *Get(const char *varname) {return env_Hash.Find(varname);}
00042 
00043 // GetInt() returns a long integer value. If the variable varname is not found
00044 //           in the hash table, return -999999999.       
00045 //
00046        long  GetInt(const char *varname);
00047 
00048 // Put() associates a string value with the a variable name. If one already
00049 //       exists, it is replaced. The passed value and variable strings are
00050 //       duplicated (value here, variable by env_Hash).
00051 //
00052        void  Put(const char *varname, const char *value)
00053                 {env_Hash.Rep((char *)varname, strdup(value), 0, Hash_dofree);}
00054 
00055 // PutInt() puts a long integer value into the hash. Internally, the value gets
00056 //          converted into a char*
00057 //
00058        void  PutInt(const char *varname, long value);
00059 
00060 // Delimit() search for the first occurrence of comma (',') in value and
00061 //           replaces it with a null byte. It then returns the address of the
00062 //           remaining string. If no comma was found, it returns zero.
00063 //
00064        char *Delimit(char *value);
00065 
00066 // secEnv() returns the security environment; which may be a null pointer.
00067 //
00068 inline const XrdSecEntity *secEnv() {return secEntity;}
00069 
00070 // Use the constructor to define the initial variable settings. The passed
00071 // string is duplicated and the copy can be retrieved using Env().
00072 //
00073        XrdOucEnv(const char *vardata=0, int vardlen=0, 
00074                  const XrdSecEntity *secent=0);
00075 
00076       ~XrdOucEnv() {if (global_env) free((void *)global_env);}
00077 
00078 private:
00079 
00080 XrdOucHash<char> env_Hash;
00081 const XrdSecEntity *secEntity;
00082 char *global_env;
00083 int   global_len;
00084 };
00085 #endif

Generated on Wed Sep 1 2010 for xrootd by  doxygen 1.7.1