version 1.114, 2005/12/09 20:45:45
|
version 1.118, 2006/01/30 16:17:08
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; Symantec Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
| |
#ifdef PEGASUS_OS_HPUX | #ifdef PEGASUS_OS_HPUX |
# include <dl.h> | # include <dl.h> |
|
|
|
#if defined(PEGASUS_HPUX_USE_DLOPEN) |
# include <dlfcn.h> | # include <dlfcn.h> |
|
#endif |
|
|
#elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) | #elif defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
# include <dll.h> | # include <dll.h> |
#elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) | #elif defined(PEGASUS_PLATFORM_OS400_ISERIES_IBM) |
|
|
Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2, | Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
"Attempting to load library %s", fileName); | "Attempting to load library %s", fileName); |
| |
#if defined(PEGASUS_OS_TRU64) |
#if defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_HPUX_USE_DLOPEN) |
|
void* handle; |
|
if (bindVerbose) |
|
{ |
|
handle = shl_load(fileName, |
|
BIND_IMMEDIATE | DYNAMIC_PATH | BIND_VERBOSE, 0L); |
|
} |
|
else |
|
{ |
|
handle = shl_load(fileName, BIND_IMMEDIATE | DYNAMIC_PATH, 0L); |
|
} |
|
Tracer::trace(TRC_OS_ABSTRACTION, Tracer::LEVEL2, |
|
"After loading lib %s, error code is %d", fileName, |
|
(handle == (void *)0)?errno:0); |
|
|
|
PEG_METHOD_EXIT(); |
|
return DynamicLibraryHandle(handle); |
|
#elif defined(PEGASUS_OS_TRU64) |
PEG_METHOD_EXIT(); | PEG_METHOD_EXIT(); |
return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW)); | return DynamicLibraryHandle(dlopen(fileName, RTLD_NOW)); |
#elif defined(PEGASUS_OS_ZOS) | #elif defined(PEGASUS_OS_ZOS) |
|
|
| |
void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle) | void System::unloadDynamicLibrary(DynamicLibraryHandle libraryHandle) |
{ | { |
|
|
|
#if defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_HPUX_USE_DLOPEN) |
|
// Note: shl_unload will unload the library even if it has been loaded |
|
// multiple times. No reference count is kept. |
|
int ignored = shl_unload(reinterpret_cast<shl_t>(libraryHandle)); |
|
// ATTN: Should this method indicate success/failure? |
|
#elif defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_OS_SOLARIS) || defined(PEGASUS_OS_DARWIN) |
|
dlclose(libraryHandle); |
|
#endif |
|
|
#ifdef PEGASUS_OS_OS400 | #ifdef PEGASUS_OS_OS400 |
OS400_UnloadDynamicLibrary((int)libraryHandle); | OS400_UnloadDynamicLibrary((int)libraryHandle); |
#elif defined(PEGASUS_OS_ZOS) |
#endif |
dllfree(reinterpret_cast<dllhandle *> (libraryHandle)); |
|
#else |
#ifdef PEGASUS_OS_AIX |
dlclose(libraryHandle); | dlclose(libraryHandle); |
#endif | #endif |
|
|
|
#ifdef PEGASUS_OS_ZOS |
|
dllfree(reinterpret_cast<dllhandle *> (libraryHandle)); |
|
#endif |
} | } |
| |
String System::dynamicLoadError() { | String System::dynamicLoadError() { |
// ATTN: Is this safe in a multi-threaded process? Should this string | // ATTN: Is this safe in a multi-threaded process? Should this string |
// be returned from loadDynamicLibrary? | // be returned from loadDynamicLibrary? |
#ifdef PEGASUS_OS_ZOS |
#if defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_HPUX_USE_DLOPEN) |
|
// If shl_load() returns NULL, errno is set to indicate the error |
|
return strerror(errno); |
|
#elif defined(PEGASUS_OS_ZOS) |
return String(); | return String(); |
#elif defined(PEGASUS_OS_OS400) | #elif defined(PEGASUS_OS_OS400) |
return String(OS400_DynamicLoadError()); | return String(OS400_DynamicLoadError()); |
|
|
DynamicLibraryHandle libraryHandle, | DynamicLibraryHandle libraryHandle, |
const char* symbolName) | const char* symbolName) |
{ | { |
|
#if defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_HPUX_USE_DLOPEN) |
|
char* p = (char*)symbolName; |
|
void* proc = 0; |
| |
#ifdef PEGASUS_OS_ZOS |
if (shl_findsym((shl_t*)&libraryHandle, symbolName, TYPE_UNDEFINED, |
|
&proc) == 0) |
|
{ |
|
return DynamicSymbolHandle(proc); |
|
} |
|
|
|
if (shl_findsym((shl_t*)libraryHandle, |
|
(String("_") + symbolName).getCString(), |
|
TYPE_UNDEFINED, |
|
&proc) == 0) |
|
{ |
|
return DynamicSymbolHandle(proc); |
|
} |
|
|
|
return 0; |
|
|
|
#elif defined(PEGASUS_OS_ZOS) |
return DynamicSymbolHandle(dllqueryfn((dllhandle *)libraryHandle, | return DynamicSymbolHandle(dllqueryfn((dllhandle *)libraryHandle, |
(char*)symbolName)); | (char*)symbolName)); |
| |
|
|
| |
String System::getFullyQualifiedHostName () | String System::getFullyQualifiedHostName () |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_OS_AIX) || defined(PEGASUS_OS_LINUX) || defined(PEGASUS_OS_OS400) |
#if defined(PEGASUS_OS_ZOS) |
char hostName[PEGASUS_MAXHOSTNAMELEN + 1]; |
|
struct hostent *he; |
|
String fqName; |
|
|
|
if (gethostname(hostName, sizeof(hostName)) != 0) |
|
{ |
|
return String::EMPTY; |
|
} |
|
hostName[sizeof(hostName)-1] = 0; |
|
|
|
if ((he = gethostbyname (hostName))) |
|
{ |
|
strncpy(hostName, he->h_name, sizeof(hostName)-1); |
|
} |
|
|
|
#if defined(PEGASUS_OS_OS400) |
|
EtoA(hostName); |
|
#endif |
|
|
|
fqName.assign (hostName); |
|
|
|
return fqName; |
|
#elif defined(PEGASUS_OS_ZOS) |
|
char hostName[PEGASUS_MAXHOSTNAMELEN + 1]; | char hostName[PEGASUS_MAXHOSTNAMELEN + 1]; |
String fqName; | String fqName; |
struct addrinfo *resolv; | struct addrinfo *resolv; |
|
|
| |
return fqName; | return fqName; |
#else | #else |
// |
char hostName[PEGASUS_MAXHOSTNAMELEN + 1]; |
// ATTN: Implement this method to return the fully qualified host name |
|
// |
if (gethostname(hostName, sizeof(hostName)) != 0) |
|
{ |
return String::EMPTY; | return String::EMPTY; |
|
} |
|
hostName[sizeof(hostName)-1] = 0; |
|
|
|
struct hostent *hostEntry; |
|
|
|
# if defined(PEGASUS_OS_LINUX) |
|
char hostEntryBuffer[8192]; |
|
struct hostent hostEntryStruct; |
|
int hostEntryErrno; |
|
|
|
gethostbyname_r( |
|
hostName, |
|
&hostEntryStruct, |
|
hostEntryBuffer, |
|
sizeof(hostEntryBuffer), |
|
&hostEntry, |
|
&hostEntryErrno); |
|
# elif defined(PEGASUS_OS_SOLARIS) |
|
char hostEntryBuffer[8192]; |
|
struct hostent hostEntryStruct; |
|
int hostEntryErrno; |
|
|
|
hostEntry = gethostbyname_r( |
|
hostName, |
|
&hostEntryStruct, |
|
hostEntryBuffer, |
|
sizeof(hostEntryBuffer), |
|
&hostEntryErrno); |
|
# else |
|
hostEntry = gethostbyname(hostName); |
|
# endif |
|
|
|
if (hostEntry) |
|
{ |
|
strncpy(hostName, hostEntry->h_name, sizeof(hostName)-1); |
|
} |
|
|
|
# if defined(PEGASUS_OS_OS400) |
|
EtoA(hostName); |
|
# endif |
|
|
|
return String(hostName); |
#endif | #endif |
} | } |
| |