language-extensions/R/test/src/linux/Utilities_linux.cpp
//-------------------------------------------------------------------------------------------------
// Name: Utilities::CrossPlatGetFunctionFromLibHandle
//
// Description:
//  Get the function pointer for the given function name from the given library handle
//
// Returns:
//  On success, returns handle to the function. Otherwise, throws a runtime_error exception.
//
:CrossPlatGetFunctionFromLibHandle
Description:
Get the function pointer for the given function name from the given library handle

On success, returns handle to the function. Otherwise, throws a runtime_error exception.
: CrossPlatGetFunctionFromLibHandle Description : Get the function pointer for the given function name from the given library handle On success returns handle to the function . Otherwise throws a runtime_error exception .
void* Utilities::CrossPlatGetFunctionFromLibHandle(void *libHandle, const std::string &fnName)
{
	void *pFuncPtr = nullptr;
	if (libHandle != nullptr)
	{
		pFuncPtr = static_cast<void*>(dlsym(libHandle, fnName.c_str()));
		if (pFuncPtr == nullptr)
		{
			char *error = dlerror();
			CrossPlatCloseLibrary(libHandle);
			string errorString("CrossPlatGetFunctionFromLibHandle failed finding function '"
				+ fnName + "' with error:" + string(error));
			cout << errorString << endl;
			throw runtime_error(errorString);
		}
	}
	else
	{
		cout << "Received null library handle" << endl;
	}
	return pFuncPtr;
}
void * Utilities :: CrossPlatGetFunctionFromLibHandle ( void * libHandle , const std :: string & fnName ) { void * pFuncPtr = nullptr ; if ( libHandle != nullptr ) { pFuncPtr = static_cast < void * > ( dlsym ( libHandle , fnName . c_str ( ) ) ) ; if ( pFuncPtr == nullptr ) { char * error = dlerror ( ) ; CrossPlatCloseLibrary ( libHandle ) ; string errorString ( " " + fnName + " " + string ( error ) ) ; cout << errorString << endl ; throw runtime_error ( errorString ) ; } } else { cout << " " << endl ; } return pFuncPtr ; }
Name: Utilities::CrossPlatGetFunctionFromLibHandle
Description:
Get the function pointer for the given function name from the given library handle
Name : Utilities :: CrossPlatGetFunctionFromLibHandle Description : Get the function pointer for the given function name from the given library handle
// this will be the pointer to the function to be returned //