version 1.2, 2005/02/18 03:24:02
|
version 1.3, 2005/06/03 19:47:32
|
|
|
// ensure the module is not already loaded | // ensure the module is not already loaded |
PEGASUS_ASSERT(isLoaded() == false); | PEGASUS_ASSERT(isLoaded() == false); |
| |
vmsSaveFileName = _fileName; |
CString cstr = _fileName.getCString(); |
| |
_handle = (LIBRARY_HANDLE)1; |
_handle = dlopen(cstr, RTLD_NOW); |
return(isLoaded()); | return(isLoaded()); |
} | } |
| |
|
|
// ensure the module is loaded | // ensure the module is loaded |
PEGASUS_ASSERT(isLoaded() == true); | PEGASUS_ASSERT(isLoaded() == true); |
| |
|
dlclose(_handle); |
_handle = 0; | _handle = 0; |
| |
return(isLoaded()); | return(isLoaded()); |
|
|
return(_handle != 0); | return(_handle != 0); |
} | } |
| |
DynamicLibrary::LIBRARY_SYMBOL DynamicLibrary::getVmsSymbol(const char *symbolName, |
|
const char *fileName, |
|
const char *vmsProviderDir) |
|
{ |
|
char* Errorout; |
|
unsigned int status; |
|
CString cstr; |
|
|
|
const char *sName = symbolName; |
|
const char *fName = fileName; |
|
const char *dName = vmsProviderDir; |
|
|
|
int symbolValue = 0; |
|
unsigned int flags = 0; |
|
|
|
$DESCRIPTOR(vmsFileName, "Dummy fileName"); |
|
$DESCRIPTOR(vmsSymbolName, "Dummy symbolName"); |
|
$DESCRIPTOR(vmsDirName, "Dummy vmsProviderDir"); |
|
|
|
vmsFileName.dsc$b_dtype = DSC$K_DTYPE_T; |
|
vmsFileName.dsc$b_class = DSC$K_CLASS_S; |
|
vmsFileName.dsc$w_length = strlen(fName); |
|
vmsFileName.dsc$a_pointer = (char *)fName; |
|
|
|
vmsSymbolName.dsc$b_dtype = DSC$K_DTYPE_T; |
|
vmsSymbolName.dsc$b_class = DSC$K_CLASS_S; |
|
vmsSymbolName.dsc$w_length = strlen(sName); |
|
vmsSymbolName.dsc$a_pointer = (char *)sName; |
|
|
|
vmsDirName.dsc$b_dtype = DSC$K_DTYPE_T; |
|
vmsDirName.dsc$b_class = DSC$K_CLASS_S; |
|
vmsDirName.dsc$w_length = strlen(dName); |
|
vmsDirName.dsc$a_pointer = (char *)dName; |
|
|
|
if(isLoaded()) |
|
{ |
|
try |
|
{ |
|
status = lib$find_image_symbol (&vmsFileName, &vmsSymbolName, &symbolValue, &vmsDirName, flags); |
|
} |
|
|
|
catch (struct chf$signal_array &obj) |
|
{ |
|
// if (obj.chf$is_sig_name != LIB$_EOMWARN) |
|
// { |
|
symbolValue = 0; |
|
return (LIBRARY_SYMBOL)symbolValue; |
|
// } |
|
} |
|
|
|
catch (...) |
|
{ |
|
symbolValue = 0; |
|
return (LIBRARY_SYMBOL)symbolValue; |
|
} |
|
|
|
if (!$VMS_STATUS_SUCCESS(status)) |
|
{ |
|
symbolValue = 0; |
|
} |
|
} |
|
return (LIBRARY_SYMBOL)symbolValue; |
|
} |
|
|
|
DynamicLibrary::LIBRARY_SYMBOL DynamicLibrary::getSymbol(const String & symbolName) | DynamicLibrary::LIBRARY_SYMBOL DynamicLibrary::getSymbol(const String & symbolName) |
{ | { |
| |
LIBRARY_SYMBOL Ls; |
char* Errorout; |
|
void* Dsh; |
char* tmp = getenv("PEGASUS_SYSSHARE"); |
|
|
|
if (tmp == "") |
|
{ |
|
throw UnrecognizedConfigProperty("PEGASUS_SYSSHARE"); |
|
} |
|
|
|
String vmsProviderDir = ( tmp + vmsSaveFileName + ".exe"); |
|
| |
if(isLoaded()) | if(isLoaded()) |
{ | { |
CString cstr = symbolName.getCString(); | CString cstr = symbolName.getCString(); |
| |
Ls = getVmsSymbol((const char *)symbolName.getCString(), |
if ((Dsh = dlsym(_handle, cstr)) == 0) |
(const char *)vmsSaveFileName.getCString(), |
{ |
(const char *)vmsProviderDir.getCString()); |
Errorout = dlerror(); |
return Ls; |
} |
|
return (LIBRARY_SYMBOL)Dsh; |
} | } |
return (0); | return (0); |
} | } |