コード例 #1
0
ファイル: linker-cmn.c プロジェクト: ImAWolf/ncbi-vdb
/* Whack
 */
static
rc_t CC VLinkerWhack ( VLinker *self )
{
    KRefcountWhack ( & self -> refcount, "VLinker" );

    VectorWhack ( & self -> fact, LFactoryWhack, NULL );
    VectorWhack ( & self -> special, LSpecialWhack, NULL );
    BSTreeWhack ( & self -> scope, KSymbolWhack, NULL );

    KDyldRelease ( self -> dl );
    VLinkerSever ( self -> dad );

    free ( self );

    return 0;
}
コード例 #2
0
static rc_t KNSManagerLoadLib( struct KNSManager *self )
{
    KDyld *dl;
    /* make a dynamic-library loader */
    rc_t rc = KDyldMake ( &dl );
    if ( rc == 0 )
    {
        /* load the curl-library */
        rc = KDyldLoadLib( dl, &lib_curl_handle, LPFX "curl" SHLX );
        if ( rc == 0 )
        {
            KSymAddr *sym;

            /* resolve symbols */

            /* curl_easy_init() */
            rc = KDylibSymbol( lib_curl_handle, &sym, "curl_easy_init" );
            if ( rc == 0 )
            {
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_easy_init_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_easy_cleanup() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_easy_cleanup" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_easy_cleanup_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_easy_setopt() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_easy_setopt" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_easy_setopt_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_easy_perform() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_easy_perform" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_easy_perform_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_easy_getinfo() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_easy_getinfo" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_easy_getinfo_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_slist_append() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_slist_append" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_slist_append_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_version() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_version" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_version_fkt) );
                KSymAddrRelease( sym );
            }

            /* curl_slist_free_all() */
            if ( rc == 0 )
            {
                rc = KDylibSymbol( lib_curl_handle, &sym, "curl_slist_free_all" );
                KSymAddrAsFunc( sym, ( fptr_t* ) &(self->curl_slist_free_all_fkt) );
                KSymAddrRelease( sym );
            }

            /* bail on error */
            if ( rc != 0 )
            {
                KDylibRelease ( lib_curl_handle );
                lib_curl_handle = NULL;
                self->curl_easy_init_fkt = NULL;
                self->curl_easy_cleanup_fkt = NULL;
                self->curl_easy_setopt_fkt = NULL;
                self->curl_easy_perform_fkt = NULL;
                self->curl_slist_append_fkt = NULL;
                self->curl_version_fkt = NULL;
                self->curl_easy_getinfo_fkt = NULL;
            }
        }
        KDyldRelease ( dl );
    }

    return rc;

}
コード例 #3
0
ファイル: testld.c プロジェクト: Jingyu9/sra-tools
rc_t CC KMain ( int argc, char *argv [] )
{
    Args * args;
    rc_t rc;

    rc = ArgsMakeAndHandle (&args, argc, argv, 1, MyOptions, sizeof MyOptions / sizeof (OptDef));
    if (rc)
        LOGERR (klogInt, rc, "failed to parse arguments");

    else
    {
        do
        {
            KDyld *dl;
            uint32_t num_libs;

            rc = ArgsParamCount (args, &num_libs);
            if (rc)
            {
                LOGERR ( klogInt, rc, "Failure to count parameters" );
                break;
            }

            if (num_libs == 0)
            {
                rc = MiniUsage(args);
                break;
            }

            /* create loader */
            rc = KDyldMake (&dl);
            if (rc)
            {
                LOGERR ( klogInt, rc, "failed to create dynamic loader" );
                break;
            }
            else
            {
                do
                {
                    KDlset *libs;
                    const char * path;
                    uint32_t ix;
                    uint32_t num_paths;

                    rc = ArgsOptionCount (args, OPTION_LOAD, &num_paths);
                    if (rc)
                    {
                        LOGERR (klogInt, rc, "failed to count paths");
                        break;
                    }

                    for (ix = 0; ix < num_paths; ix++)
                    {

                        rc = ArgsOptionValue (args, OPTION_LOAD, ix, (const void **)&path);
                        if (rc)
                        {
                            LOGERR (klogInt, rc, "failed to access a path option");
                            break;
                        }
                        testld_update_libpath (dl, path);
                    }
                    if (rc)
                        break;

                    /* append contents of LD_LIBRARY_PATH */
                    path = getenv ( "LD_LIBRARY_PATH" );

                    if (path)
                        testld_update_libpath (dl, path);

                    /* create libset */
                    rc = KDyldMakeSet (dl, & libs);
                    if (rc)
                    {
                        LOGERR (klogInt, rc, "failed to create dl library set");
                        break;
                    }
                    else
                    {
                        /* test it */
                        for (ix = 0; ix < num_libs; ++ ix )
                        {
                            rc = ArgsParamValue (args, ix, (const void **)&path);
                            if (rc)
                                break;

                            testld_load_library (dl, libs, path);
                        }

                        KDlsetRelease ( libs );
                    }
                } while (0);

                KDyldRelease ( dl );
            }

        } while (0);

        ArgsWhack (args);
    }
    return rc;
}