Index: /trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp
===================================================================
--- /trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp	(revision 17711)
+++ /trunk/src/VBox/Main/cbinding/VBoxXPCOMC.cpp	(revision 17712)
@@ -40,5 +40,7 @@
 static nsIComponentManager *manager;
 
-VBOXXPCOMC_DECL(int)
+void VBoxComUninitialize(void);
+
+int
 VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString)
 {
@@ -46,5 +48,5 @@
 }
 
-VBOXXPCOMC_DECL(int)
+int
 VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString)
 {
@@ -52,5 +54,5 @@
 }
 
-VBOXXPCOMC_DECL(void)
+void
 VBoxUtf16Free(PRUnichar *pwszString)
 {
@@ -58,5 +60,5 @@
 }
 
-VBOXXPCOMC_DECL(void)
+void
 VBoxUtf8Free(char *pszString)
 {
@@ -64,5 +66,5 @@
 }
 
-VBOXXPCOMC_DECL(void)
+void
 VBoxComUnallocMem(void *ptr)
 {
@@ -73,5 +75,5 @@
 }
 
-VBOXXPCOMC_DECL(int)
+int
 VBoxSetEnv(const char *pszVar, const char *pszValue)
 {
@@ -79,5 +81,5 @@
 }
 
-VBOXXPCOMC_DECL(const char *)
+const char *
 VBoxGetEnv(const char *pszVar)
 {
@@ -85,5 +87,5 @@
 }
 
-VBOXXPCOMC_DECL(void)
+void
 VBoxComInitialize(IVirtualBox **virtualBox, ISession **session)
 {
@@ -139,5 +141,5 @@
 }
 
-VBOXXPCOMC_DECL(void)
+void
 VBoxComUninitialize(void)
 {
Index: /trunk/src/VBox/Main/cbinding/tstLinuxC.c
===================================================================
--- /trunk/src/VBox/Main/cbinding/tstLinuxC.c	(revision 17711)
+++ /trunk/src/VBox/Main/cbinding/tstLinuxC.c	(revision 17712)
@@ -27,4 +27,6 @@
 #include <sys/stat.h>
 #include "VirtualBox_CXPCOM.h"
+
+PCVBOXXPCOM g_pVBoxFuncs = NULL;
 
 static char *nsIDToString(nsID *guid);
@@ -114,9 +116,9 @@
 
             machine->vtbl->GetName(machine, &machineNameUtf16);
-            VBoxUtf16ToUtf8(machineNameUtf16,&machineName);
+            g_pVBoxFuncs->pfnUtf16ToUtf8(machineNameUtf16,&machineName);
             printf("\tName:        %s\n", machineName);
 
-            VBoxUtf8Free(machineName);
-            VBoxComUnallocMem(machineNameUtf16);
+            g_pVBoxFuncs->pfnUtf8Free(machineName);
+            g_pVBoxFuncs->pfnComUnallocMem(machineNameUtf16);
         }
         else
@@ -135,5 +137,5 @@
 
             free(uuidString);
-            VBoxComUnallocMem(iid);
+            g_pVBoxFuncs->pfnComUnallocMem(iid);
         }
 
@@ -145,9 +147,9 @@
 
                 machine->vtbl->GetSettingsFilePath(machine, &configFile);
-                VBoxUtf16ToUtf8(configFile, &configFile1);
+                g_pVBoxFuncs->pfnUtf16ToUtf8(configFile, &configFile1);
                 printf("\tConfig file: %s\n", configFile1);
 
                 free(configFile1);
-                VBoxComUnallocMem(configFile);
+                g_pVBoxFuncs->pfnComUnallocMem(configFile);
             }
 
@@ -168,11 +170,11 @@
                 virtualBox->vtbl->GetGuestOSType(virtualBox, typeId, &osType);
                 osType->vtbl->GetDescription(osType, &osNameUtf16);
-                VBoxUtf16ToUtf8(osNameUtf16,&osName);
+                g_pVBoxFuncs->pfnUtf16ToUtf8(osNameUtf16,&osName);
                 printf("\tGuest OS:    %s\n\n", osName);
 
                 osType->vtbl->nsisupports.Release((void *)osType);
-                VBoxUtf8Free(osName);
-                VBoxComUnallocMem(osNameUtf16);
-                VBoxComUnallocMem(typeId);
+                g_pVBoxFuncs->pfnUtf8Free(osName);
+                g_pVBoxFuncs->pfnComUnallocMem(osNameUtf16);
+                g_pVBoxFuncs->pfnComUnallocMem(typeId);
             }
         }
@@ -198,5 +200,5 @@
             startVM(virtualBox, session, iid);
 
-            VBoxComUnallocMem(iid);
+            g_pVBoxFuncs->pfnComUnallocMem(iid);
         }
     }
@@ -240,5 +242,5 @@
     }
 
-    VBoxUtf8ToUtf16("gui", &sessionType);
+    g_pVBoxFuncs->pfnUtf8ToUtf16("gui", &sessionType);
 
     rc = virtualBox->vtbl->OpenRemoteSession(
@@ -251,5 +253,5 @@
     );
 
-    VBoxUtf16Free(sessionType);
+    g_pVBoxFuncs->pfnUtf16Free(sessionType);
 
     if (NS_FAILED(rc))
@@ -280,9 +282,9 @@
             progress->vtbl->GetErrorInfo(progress, &errorInfo);
             errorInfo->vtbl->GetText(errorInfo, &textUtf16);
-            VBoxUtf16ToUtf8(textUtf16, &text);
+            g_pVBoxFuncs->pfnUtf16ToUtf8(textUtf16, &text);
             printf("Error: %s\n", text);
 
-            VBoxComUnallocMem(textUtf16);
-            VBoxUtf8Free(text);
+            g_pVBoxFuncs->pfnComUnallocMem(textUtf16);
+            g_pVBoxFuncs->pfnUtf8Free(text);
         }
         else
@@ -309,18 +311,13 @@
     nsresult    rc;     /* Result code of various function (method) calls. */
 
-    /*
-     * Guess where VirtualBox is installed not mentioned in the environment.
-     * (This will be moved to VBoxComInitialize later.)
-     */
-
-    if (!VBoxGetEnv("VBOX_APP_HOME"))
+    if (!getenv("VBOX_APP_HOME"))
     {
         if (stat("/opt/VirtualBox/VBoxXPCOMC.so", &stIgnored) == 0)
         {
-            VBoxSetEnv("VBOX_APP_HOME","/opt/VirtualBox/");
+            setenv("VBOX_APP_HOME","/opt/VirtualBox/", 0 /* no need to overwrite */);
         }
         if (stat("/usr/lib/virtualbox/VBoxXPCOMC.so", &stIgnored) == 0)
         {
-            VBoxSetEnv("VBOX_APP_HOME","/usr/lib/virtualbox/");
+            setenv("VBOX_APP_HOME","/usr/lib/virtualbox/", 0 /* no need to overwrite */);
         }
     }
@@ -329,11 +326,16 @@
 
     /*
-     * VBoxComInitialize does all the necessary startup action and
-     * provides us with pointers to vbox and session handles.
-     * It should be matched by a call to VBoxComUninitialize(vbox)
+     * VBoxGetXPCOMCFunctions() is the only function exported by
+     * VBoxXPCOMC.so. This functions gives you the pointer to the
+     * function table (g_pVBoxFuncs).
+     *
+     * g_pVBoxFuncs->pfnComInitialize does all the necessary startup
+     * action and provides us with pointers to vbox and session handles.
+     * It should be matched by a call to g_pVBoxFuncs->pfnComUninitialize()
      * when done.
      */
 
-    VBoxComInitialize(&vbox, &session);
+    g_pVBoxFuncs = VBoxGetXPCOMCFunctions(VBOX_XPCOMC_VERSION);
+    g_pVBoxFuncs->pfnComInitialize(&vbox, &session);
 
     if (vbox == NULL)
@@ -375,8 +377,8 @@
     {
         char *version = NULL;
-        VBoxUtf16ToUtf8(versionUtf16, &version);
+        g_pVBoxFuncs->pfnUtf16ToUtf8(versionUtf16, &version);
         printf("\tVersion: %s\n", version);
-        VBoxUtf8Free(version);
-        VBoxComUnallocMem(versionUtf16);
+        g_pVBoxFuncs->pfnUtf8Free(version);
+        g_pVBoxFuncs->pfnComUnallocMem(versionUtf16);
     }
     else
@@ -392,8 +394,8 @@
     {
         char *homefolder = NULL;
-        VBoxUtf16ToUtf8(homefolderUtf16, &homefolder);
+        g_pVBoxFuncs->pfnUtf16ToUtf8(homefolderUtf16, &homefolder);
         printf("\tHomeFolder: %s\n", homefolder);
-        VBoxUtf8Free(homefolder);
-        VBoxComUnallocMem(homefolderUtf16);
+        g_pVBoxFuncs->pfnUtf8Free(homefolder);
+        g_pVBoxFuncs->pfnComUnallocMem(homefolderUtf16);
     }
     else
@@ -412,5 +414,5 @@
      */
 
-    VBoxComUninitialize();
+    g_pVBoxFuncs->pfnComUninitialize();
     printf("Finished Main\n");
 
Index: /trunk/src/VBox/Main/cbinding/xpcidl.xsl
===================================================================
--- /trunk/src/VBox/Main/cbinding/xpcidl.xsl	(revision 17711)
+++ /trunk/src/VBox/Main/cbinding/xpcidl.xsl	(revision 17712)
@@ -546,21 +546,4 @@
 extern "C" {
 #endif
-
-/* Initialize/Uninitialize XPCOM. */
-VBOXXPCOMC_DECL(void) VBoxComInitialize(IVirtualBox **virtualBox, ISession **session);
-VBOXXPCOMC_DECL(void) VBoxComUninitialize(void);
-
-/* Deallocation functions. */
-VBOXXPCOMC_DECL(void) VBoxComUnallocMem(void *ptr);
-VBOXXPCOMC_DECL(void) VBoxUtf16Free(PRUnichar *pwszString);
-VBOXXPCOMC_DECL(void) VBoxUtf8Free(char *pszString);
-
-/* Converting to and from UTF-8 and UTF-16. */
-VBOXXPCOMC_DECL(int) VBoxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString);
-VBOXXPCOMC_DECL(int) VBoxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString);
-
-/* Getting and setting the environment variables. */
-VBOXXPCOMC_DECL(const char *) VBoxGetEnv(const char *pszVar);
-VBOXXPCOMC_DECL(int) VBoxSetEnv(const char *pszVar, const char *pszValue);
 
 
