| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# System.cpp File Reference

`#include <ctime>`
`#include <cstring>`
`#include <cstdlib>`
`#include <iomanip>`
`#include <iostream>`
`#include <sstream>`
`#include <typeinfo>`
`#include "GaudiKernel/System.h"`
`#include <errno.h>`
`#include <string.h>`
`#include "sys/times.h"`
`#include "unistd.h"`
`#include "libgen.h"`
`#include <cstdio>`
`#include <cxxabi.h>`

Include dependency graph for System.cpp:

Go to the source code of this file.

## Defines
#define | SYSTEM_SYSTEM_CPP
#define | __attribute__(x)
## Functions
static unsigned long | doLoad (const std::string &name, System::ImageHandle *handle)
static unsigned long | loadWithoutEnvironment (const std::string &name, System::ImageHandle *handle)
unsigned long | System::loadDynamicLib (const std::string &name, ImageHandle *handle)
| Load dynamic link library.
unsigned long | System::unloadDynamicLib (ImageHandle handle)
| unload dynamic link library
unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, EntryPoint *pFunction)
| Get a specific function defined in the DLL.
unsigned long | System::getProcedureByName (ImageHandle handle, const std::string &name, Creator *pFunction)
| Get a specific function defined in the DLL.
unsigned long | System::getLastError ()
| Get last system known error.
const std::string | System::getLastErrorString ()
| Get last system error as string.
const std::string | System::getErrorString (unsigned long error)
| Retrieve error code as string for a given error.
std::string | __typeName (char *&name)
std::string | __className (char *&name)
const std::string | System::typeinfoName (const std::type_info &)
| Get platform independent information about the class type.
const std::string | System::typeinfoName (const char *)
const std::string & | System::hostName ()
| Host name.
const std::string & | System::osName ()
| OS name.
const std::string & | System::osVersion ()
| OS version.
const std::string & | System::machineType ()
| Machine type.
const std::string & | System::accountName ()
| User login name.
long | System::numCmdLineArgs ()
| Number of arguments passed to the commandline.
long | System::argc ()
| Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
const std::vector< std::string > | System::cmdLineArgs ()
| Command line arguments including executable name as arg[0] as vector of strings.
char ** | System::argv ()
| char** command line arguments including executable name as arg[0]; You may not modify them!
const std::string | System::getEnv (const char *var)
| get a particular environment variable
const std::vector< std::string > | System::getEnv ()
| get all environment variables
int | System::backTrace (void **addresses __attribute__((unused)), const int depth __attribute__((unused)))
bool | System::backTrace (std::string &btrace, const int depth, const int offset=0)
bool | System::getStackLevel (void *addresses __attribute__((unused)), void *&addr __attribute__((unused)), std::string &fnc __attribute__((unused)), std::string &lib __attribute__((unused)))
int | System::setEnv (const std::string &name, const std::string &value, int overwrite=1)
| Set an environment variables.
## Variables
static const char * | SHLIB_SUFFIX = ".so"
static std::vector< std::string > | s_argvStrings
static std::vector< const char * > | s_argvChars
| return

## Define Documentation

#define __attribute__ | ( | x |  | ) |

Definition at line 69 of file System.cpp.

#define SYSTEM_SYSTEM_CPP

Definition at line 14 of file System.cpp.

## Function Documentation

std::string __className | ( | char *& | name | ) |

Definition at line 298 of file System.cpp.

    00298                                    {
    00299   std::string result;
    00300   int j = 0, k, i;
    00301   if ( 't' == *name ) {
    00302     goto Template;
    00303   }
    00304   for ( i = ::strtol(name, &name, 10);  i > 0; i = ::strtol(name, &name, 10) ) {
    00305     if ( j++ != 0 ) result.append("::",2);
    00306     result.append(name, i);
    00307     if ( *(name+=i) == 't' ) {
    00308       result.append("::",2);
    00309     Template:
    00310       result.append(name, (i=::strtol(++name, &name, 10)));
    00311       result.append("<");
    00312       for (k = 0, i=::strtol(name+i, &name, 10); k < i; k++ ) {
    00313         result += __typeName( ++name );
    00314         if ( k+1 < i ) result += ",";
    00315       }
    00316       result.append(">");
    00317     }
    00318   }
    00319   return result;
    00320 }

std::string __typeName | ( | char *& | name | ) |

Definition at line 322 of file System.cpp.

    00322                                    {
    00323   if ( *name == 'Q' ) {              // Handle name spaces
    00324     if ( *(++name) == '_' )          // >= 10 nested name spaces
    00325       ::strtol(++name, &name, 10);   // type Q_##_...
    00326     return __className(++name);
    00327   }
    00328   else if ( 't' == *name )  {
    00329     return __className(name);
    00330   }
    00331   else  {
    00332     std::string result;
    00333     char* ptr;
    00334     int i = ::strtol(name, &ptr, 10);
    00335     if ( i <= 0 )  {
    00336       name = ptr;
    00337       while ( *name != 0 && *name != 'Z' )  {
    00338         if ( *name == 'U' )  {
    00339           result += "unsigned ";
    00340           name++;
    00341         }
    00342         switch( *name++ )  {
    00343         case 'c': result += "char"; break;
    00344         case 's': result += "short"; break;
    00345         case 'i': result += "int"; break;
    00346         case 'l': result += "long"; break;
    00347         case 'f': result += "float"; break;
    00348         case 'd': result += "double"; break;
    00349         default:  result += *(name-1);
    00350         }
    00351       }
    00352       return result;
    00353     }
    00354     else {
    00355       return __className(name);
    00356     }
    00357   }
    00358 }

static unsigned long doLoad | ( | const std::string & | name,
|  | System::ImageHandle * | handle |
| ) |  |  | `[static]`

Definition at line 75 of file System.cpp.

    00075                                                                                {
    00076 #ifdef _WIN32
    00077   void* mh = ::LoadLibrary( name.length() == 0 ? System::exeName().c_str() : name.c_str());
    00078   *handle = mh;
    00079 #else
    00080   const char* path = name.c_str();
    00081 #if defined(linux) || defined(__APPLE__)
    00082   void *mh = ::dlopen(name.length() == 0 ? 0 : path, RTLD_LAZY | RTLD_GLOBAL);
    00083   *handle = mh;
    00084 #elif __hpux
    00085   shl_t mh = ::shl_load(name.length() == 0 ? 0 : path, BIND_IMMEDIATE | BIND_VERBOSE, 0);
    00086   HMODULE* mod = new HMODULE;
    00087   if ( 0 != mh ) {
    00088     if ( 0 != ::shl_gethandle_r(mh, &mod->dsc) ) {
    00089       std::cout << "System::loadDynamicLib>" << ::strerror(getLastError()) << std::endl;
    00090     }
    00091     else {
    00092       typedef void* (*___all)();
    00093       ___all _alloc = (___all)malloc;
    00094       mod->numSym = ::shl_getsymbols(mod->dsc.handle, TYPE_PROCEDURE, EXPORT_SYMBOLS, malloc, &mod->sym);
    00095       *handle = mod;
    00096     }
    00097   }
    00098 #endif
    00099 #endif
    00100   if ( 0 == *handle )   {
    00101     return System::getLastError();
    00102   }
    00103   return 1;
    00104 }

static unsigned long loadWithoutEnvironment | ( | const std::string & | name,
|  | System::ImageHandle * | handle |
| ) |  |  | `[static]`

Definition at line 106 of file System.cpp.

    00106                                                                                                  {
    00107
    00108   std::string dllName = name;
    00109   long len = strlen(SHLIB_SUFFIX);
    00110
    00111   // Add the suffix at the end of the library name only if necessary
    00112   // FIXME: cure the logic
    00113   if ((dllName.length() != 0) &&
    00114       ::strncasecmp(dllName.data()+dllName.length()-len, SHLIB_SUFFIX, len) != 0) {
    00115     dllName += SHLIB_SUFFIX;
    00116   }
    00117
    00118   // Load the library
    00119   return doLoad(dllName, handle);
    00120 }

## Variable Documentation

return

Definition at line 176 of file System.cpp.

std::vector<const char*> s_argvChars`[static]`

Definition at line 73 of file System.cpp.

std::vector<std::string> s_argvStrings`[static]`

Definition at line 72 of file System.cpp.

const char* SHLIB_SUFFIX = ".so"`[static]`

Definition at line 37 of file System.cpp.