Changeset 18871 in vbox
- Timestamp:
- Apr 11, 2009 9:38:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/cbinding/VBoxXPCOMCGlue.c
r18853 r18871 69 69 /** Pointer to VBoxGetXPCOMCFunctions for the loaded VBoxXPCOMC so/dylib/dll. */ 70 70 PFNVBOXGETXPCOMCFUNCTIONS g_pfnGetFunctions = NULL; 71 /** boolean for checking if the VBOX_APP_HOME is already set by the users */72 int g_bVAHSet = 0;73 71 74 72 … … 79 77 * @returns 0 on success, -1 on failure. 80 78 * @param pszHome The director where to try load VBoxXPCOMC from. Can be NULL. 81 */ 82 static int tryLoadOne(const char *pszHome) 79 * @param fSetAppHome Whether to set the VBOX_APP_HOME env.var. or not (boolean). 80 */ 81 static int tryLoadOne(const char *pszHome, int fSetAppHome) 83 82 { 84 83 size_t cchHome = pszHome ? strlen(pszHome) : 0; 85 size_t cb Req;84 size_t cbBufNeeded; 86 85 char szBuf[4096]; 87 86 int rc = -1; … … 90 89 * Construct the full name. 91 90 */ 92 cb Req= cchHome + sizeof("/" DYNLIB_NAME);93 if (cb Req> sizeof(szBuf))94 { 95 sprintf(g_szVBoxErrMsg, "path buffer too small: %u bytes required", (unsigned)cbReq);91 cbBufNeeded = cchHome + sizeof("/" DYNLIB_NAME); 92 if (cbBufNeeded > sizeof(szBuf)) 93 { 94 sprintf(g_szVBoxErrMsg, "path buffer too small: %u bytes needed", (unsigned)cbBufNeeded); 96 95 return -1; 97 96 } 98 memcpy(szBuf, pszHome, cchHome); 99 szBuf[cchHome] = '/'; 100 cchHome++; 97 if (cchHome) 98 { 99 memcpy(szBuf, pszHome, cchHome); 100 szBuf[cchHome] = '/'; 101 cchHome++; 102 } 101 103 memcpy(&szBuf[cchHome], DYNLIB_NAME, sizeof(DYNLIB_NAME)); 102 104 … … 105 107 * Then resolve and call the function table getter. 106 108 */ 107 if ( !g_bVAHSet)108 { 109 /* Override it as we know that user didn't set it110 * and that we only did it in previous iteration111 */112 setenv("VBOX_APP_HOME", pszHome, 1);109 if (fSetAppHome) 110 { 111 if (pszHome) 112 setenv("VBOX_APP_HOME", pszHome, 1 /* always override */); 113 else 114 unsetenv("VBOX_APP_HOME"); 113 115 } 114 116 g_hVBoxXPCOMC = dlopen(szBuf, RTLD_NOW | RTLD_LOCAL); … … 163 165 const char *pszHome = getenv("VBOX_APP_HOME"); 164 166 if (pszHome) 165 { 166 g_bVAHSet = 1; 167 return tryLoadOne(pszHome); 168 } 167 return tryLoadOne(pszHome, 0); 169 168 170 169 /* … … 172 171 */ 173 172 #if defined(__gnu__linux__) || defined(__linux__) 174 if (tryLoadOne("/opt/VirtualBox" ) == 0)175 return 0; 176 if (tryLoadOne("/usr/lib/virtualbox" ) == 0)173 if (tryLoadOne("/opt/VirtualBox", 1) == 0) 174 return 0; 175 if (tryLoadOne("/usr/lib/virtualbox", 1) == 0) 177 176 return 0; 178 177 #elif defined(__sun__) 179 if (tryLoadOne("/opt/VirtualBox/amd64" ) == 0)180 return 0; 181 if (tryLoadOne("/opt/VirtualBox/i386" ) == 0)178 if (tryLoadOne("/opt/VirtualBox/amd64", 1) == 0) 179 return 0; 180 if (tryLoadOne("/opt/VirtualBox/i386", 1) == 0) 182 181 return 0; 183 182 #elif defined(__APPLE__) 184 if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS" ) == 0)183 if (tryLoadOne("/Application/VirtualBox.app/Contents/MacOS", 1) == 0) 185 184 return 0; 186 185 #else … … 191 190 * Finally try the dynamic linker search path. 192 191 */ 193 if (tryLoadOne(NULL ) == 0)192 if (tryLoadOne(NULL, 1) == 0) 194 193 return 0; 195 194
Note:
See TracChangeset
for help on using the changeset viewer.