FreeBSD/cddl/contrib/opensolaris/lib/libctf/common/ctf_lib.c
/*
 * Attempt to dlopen the decompression library and locate the symbols of
 * interest that we will need to call.  This information in cached so
 * that multiple calls to ctf_bufopen() do not need to reopen the library.
 */
Attempt to dlopen the decompression library and locate the symbols of
interest that we will need to call.  This information in cached so
that multiple calls to ctf_bufopen() do not need to reopen the library.
Attempt to dlopen the decompression library and locate the symbols of interest that we will need to call . This information in cached so that multiple calls to ctf_bufopen () do not need to reopen the library .
void *
ctf_zopen(int *errp)
{
#ifdef illumos
	ctf_dprintf("decompressing CTF data using %s\n", _libctf_zlib);
	if (zlib.z_dlp != NULL)
		return (zlib.z_dlp); 
	if (access(_libctf_zlib, R_OK) == -1)
		return (ctf_set_open_errno(errp, ECTF_ZMISSING));
	if ((zlib.z_dlp = dlopen(_libctf_zlib, RTLD_LAZY | RTLD_LOCAL)) == NULL)
		return (ctf_set_open_errno(errp, ECTF_ZINIT));
	zlib.z_uncompress = (int (*)(uchar_t *, ulong_t *, const uchar_t *, ulong_t)) dlsym(zlib.z_dlp, "uncompress");
	zlib.z_error = (const char *(*)(int)) dlsym(zlib.z_dlp, "zError");
	if (zlib.z_uncompress == NULL || zlib.z_error == NULL) {
		(void) dlclose(zlib.z_dlp);
		bzero(&zlib, sizeof (zlib));
		return (ctf_set_open_errno(errp, ECTF_ZINIT));
	}
#else
	zlib.z_uncompress = uncompress;
	zlib.z_error = zError;
	zlib.z_dlp = (void *) (uintptr_t) 1;
#endif
	return (zlib.z_dlp);
}
void * ctf_zopen ( int * errp ) { #ifdef illumos ctf_dprintf ( " \n " , _libctf_zlib ) ; if ( zlib . z_dlp != NULL ) return ( zlib . z_dlp ) ; if ( access ( _libctf_zlib , R_OK ) == -1 ) return ( ctf_set_open_errno ( errp , ECTF_ZMISSING ) ) ; if ( ( zlib . z_dlp = dlopen ( _libctf_zlib , RTLD_LAZY | RTLD_LOCAL ) ) == NULL ) return ( ctf_set_open_errno ( errp , ECTF_ZINIT ) ) ; zlib . z_uncompress = ( int ( * ) ( uchar_t * , ulong_t * , const uchar_t * , ulong_t ) ) dlsym ( zlib . z_dlp , " " ) ; zlib . z_error = ( const char * ( * ) ( int ) ) dlsym ( zlib . z_dlp , " " ) ; if ( zlib . z_uncompress == NULL || zlib . z_error == NULL ) { ( void ) dlclose ( zlib . z_dlp ) ; bzero ( & zlib , sizeof ( zlib ) ) ; return ( ctf_set_open_errno ( errp , ECTF_ZINIT ) ) ; } #else zlib . z_uncompress = uncompress ; zlib . z_error = zError ; zlib . z_dlp = ( void * ) ( uintptr_t ) 1 ; #endif return ( zlib . z_dlp ) ; }
Attempt to dlopen the decompression library and locate the symbols of
 interest that we will need to call.
Attempt to dlopen the decompression library and locate the symbols of interest that we will need to call .
/* library is already loaded */ /* Dummy return variable as 'no error' */