Exemplo n.º 1
0
/**
 * Tries to locate and load VBoxXPCOMC.so/dylib/dll, resolving all the related
 * function pointers.
 *
 * @returns 0 on success, -1 on failure.
 *
 * @remark  This should be considered moved into a separate glue library since
 *          its its going to be pretty much the same for any user of VBoxXPCOMC
 *          and it will just cause trouble to have duplicate versions of this
 *          source code all around the place.
 */
int VBoxCGlueInit(void)
{
    /*
     * If the user specifies the location, try only that.
     */
    const char *pszHome = getenv("VBOX_APP_HOME");
    if (pszHome)
        return tryLoadOne(pszHome, 0);

    /*
     * Try the configured location.
     */
    g_szVBoxErrMsg[0] = '\0';

    if (tryLoadOne(VBOX_XPCOMC_DIR, 1) == 0)
        return 0;

    /*
     * Finally try the dynamic linker search path.
     */
    if (tryLoadOne(NULL, 1) == 0)
        return 0;

    /* No luck, return failure. */
    return -1;
}
Exemplo n.º 2
0
/**
 * Tries to locate and load VBoxXPCOMC.so/dylib/dll, resolving all the related
 * function pointers.
 *
 * @returns 0 on success, -1 on failure.
 */
int
VBoxCGlueInit(unsigned int *version)
{
    int i;
    static const char *knownDirs[] = {
        "/usr/lib/virtualbox",
        "/usr/lib/virtualbox-ose",
        "/usr/lib64/virtualbox",
        "/usr/lib64/virtualbox-ose",
        "/usr/lib/VirtualBox",
        "/opt/virtualbox",
        "/opt/VirtualBox",
        "/opt/virtualbox/i386",
        "/opt/VirtualBox/i386",
        "/opt/virtualbox/amd64",
        "/opt/VirtualBox/amd64",
        "/usr/local/lib/virtualbox",
        "/usr/local/lib/VirtualBox",
        "/Applications/VirtualBox.app/Contents/MacOS"
    };
    const char *home = getenv("VBOX_APP_HOME");

    /* If the user specifies the location, try only that. */
    if (home != NULL) {
        if (tryLoadOne(home, false, false, version) < 0) {
            return -1;
        }
    }

    /* Try the additionally configured location. */
    if (VBOX_XPCOMC_DIR[0] != '\0') {
        if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0) {
            return 0;
        }
    }

    /* Try the known locations. */
    for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) {
        if (tryLoadOne(knownDirs[i], true, true, version) >= 0) {
            return 0;
        }
    }

    /* Finally try the dynamic linker search path. */
    if (tryLoadOne(NULL, false, true, version) >= 0) {
        return 0;
    }

    /* No luck, return failure. */
    return -1;
}
Exemplo n.º 3
0
/**
 * Tries to locate and load VBoxXPCOMC.so/dylib/dll, resolving all the related
 * function pointers.
 *
 * @returns 0 on success, -1 on failure.
 *
 * @remark  This should be considered moved into a separate glue library since
 *          its its going to be pretty much the same for any user of VBoxXPCOMC
 *          and it will just cause trouble to have duplicate versions of this
 *          source code all around the place.
 */
int VBoxCGlueInit(void)
{
    /*
     * If the user specifies the location, try only that.
     */
    const char *pszHome = getenv("VBOX_APP_HOME");
    if (pszHome)
        return tryLoadOne(pszHome, 0);

    /*
     * Try the known standard locations.
     */
    g_szVBoxErrMsg[0] = '\0';
#if defined(__gnu__linux__) || defined(__linux__)
    if (tryLoadOne("/opt/VirtualBox", 1) == 0)
        return 0;
    if (tryLoadOne("/usr/lib/virtualbox", 1) == 0)
        return 0;
#elif defined(__sun__)
    if (tryLoadOne("/opt/VirtualBox/amd64", 1) == 0)
        return 0;
    if (tryLoadOne("/opt/VirtualBox/i386", 1) == 0)
        return 0;
#elif defined(__APPLE__)
    if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS", 1) == 0)
        return 0;
#elif defined(__FreeBSD__)
    if (tryLoadOne("/usr/local/lib/virtualbox", 1) == 0)
        return 0;
#elif defined(__OS2__)
    if (tryLoadOne("C:/Apps/VirtualBox", 1) == 0)
        return 0;
#else
# error "port me"
#endif

    /*
     * Finally try the dynamic linker search path.
     */
    if (tryLoadOne(NULL, 1) == 0)
        return 0;

    /* No luck, return failure. */
    return -1;
}