Index: /trunk/src/VBox/Main/src-server/USBIdDatabaseGenerator.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/USBIdDatabaseGenerator.cpp	(revision 59734)
+++ /trunk/src/VBox/Main/src-server/USBIdDatabaseGenerator.cpp	(revision 59735)
@@ -22,7 +22,4 @@
 #include <stdio.h>
 
-#include <fstream>
-#include <iostream>
-#include <iomanip>
 #include <algorithm>
 #include <map>
@@ -59,57 +56,6 @@
 static bool g_fVerbose = false;
 
-static const char * const header =
-    "/** @file\n"
-    " * USB device vendor and product ID database - Autogenerated from <stupid C++ cannot do %s>\n"
-    " */\n"
-    "\n"
-    "/*\n"
-    " * Copyright (C) 2015-2016 Oracle Corporation\n"
-    " *\n"
-    " * This file is part of VirtualBox Open Source Edition(OSE), as\n"
-    " * available from http ://www.virtualbox.org. This file is free software;\n"
-    " * you can redistribute it and / or modify it under the terms of the GNU\n"
-    " * General Public License(GPL) as published by the Free Software\n"
-    " * Foundation, in version 2 as it comes in the \"COPYING\" file of the\n"
-    " * VirtualBox OSE distribution.VirtualBox OSE is distributed in the\n"
-    " * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.\n"
-    " */"
-    "\n"
-    "\n"
-    "#include \"USBIdDatabase.h\"\n"
-    "\n";
-static const char * const product_header =
-    "/**\n"
-    " * USB devices aliases array.\n"
-    " * Format: VendorId, ProductId, Vendor Name, Product Name\n"
-    " * The source of the list is http://www.linux-usb.org/usb.ids\n"
-    " */\n"
-    "USBIDDBPROD const USBIdDatabase::s_aProducts[] =\n"
-    "{\n";
-const char * const product_part2 =
-    "};\n"
-    "\n"
-    "\nconst RTBLDPROGSTRREF USBIdDatabase::s_aProductNames[] =\n"
-    "{\n";
-const char * const product_footer =
-    "};\n"
-    "\n"
-    "const size_t USBIdDatabase::s_cProducts = RT_ELEMENTS(USBIdDatabase::s_aProducts);\n";
-
-const char * const vendor_header =
-    "\nUSBIDDBVENDOR const USBIdDatabase::s_aVendors[] =\n"
-    "{\n";
-const char * const vendor_part2 =
-    "};\n"
-    "\n"
-    "\nconst RTBLDPROGSTRREF USBIdDatabase::s_aVendorNames[] =\n"
-    "{\n";
-const char * const vendor_footer =
-    "};\n"
-    "\n"
-    "const size_t USBIdDatabase::s_cVendors = RT_ELEMENTS(USBIdDatabase::s_aVendors);\n";
-
-const char * const start_block = "# Vendors, devices and interfaces. Please keep sorted.";
-const char * const end_block = "# List of known device classes, subclasses and protocols";
+const char * const g_pszStartBlock = "# Vendors, devices and interfaces. Please keep sorted.";
+const char * const g_pszEndBlock   = "# List of known device classes, subclasses and protocols";
 
 
@@ -147,5 +93,5 @@
 
 typedef std::vector<ProductRecord> ProductsSet;
-typedef std::vector<VendorRecord> VendorsSet;
+typedef std::vector<VendorRecord>  VendorsSet;
 
 
@@ -153,6 +99,6 @@
 *   Global Variables                                                                                                             *
 *********************************************************************************************************************************/
-ProductsSet g_products;
-VendorsSet g_vendors;
+static ProductsSet g_products;
+static VendorsSet  g_vendors;
 
 /** The size of all the raw strings, including terminators. */
@@ -185,5 +131,5 @@
  * Input file parsing.
  */
-int ParseAlias(char *pszLine, size_t& id, std::string& desc)
+static int ParseAlias(char *pszLine, size_t& id, std::string& desc)
 {
     /* First there's a hexadeciman number. */
@@ -223,5 +169,5 @@
 }
 
-bool IsCommentOrEmptyLine(const char *pszLine)
+static bool IsCommentOrEmptyLine(const char *pszLine)
 {
     pszLine = RTStrStripL(pszLine);
@@ -229,5 +175,5 @@
 }
 
-int ParseUsbIds(PRTSTREAM instream)
+static int ParseUsbIds(PRTSTREAM instream)
 {
     /*
@@ -249,5 +195,5 @@
             if (!fLookingForData)
             {
-                if (!strstr(szLine, end_block))
+                if (!strstr(szLine, g_pszEndBlock))
                 {
                     if (!IsCommentOrEmptyLine(szLine))
@@ -281,5 +227,5 @@
                     return RTEXITCODE_SUCCESS;
             }
-            else if (strstr(szLine, start_block))
+            else if (strstr(szLine, g_pszStartBlock))
                 fLookingForData = false;
         }
@@ -291,4 +237,67 @@
 }
 
+static void WriteSourceFile(FILE *pOut, const char *argv0, PBLDPROGSTRTAB pStrTab)
+{
+    fprintf(pOut,
+            "/** @file\n"
+            " * USB device vendor and product ID database - Autogenerated by %s\n"
+            " */\n"
+            "\n"
+            "/*\n"
+            " * Copyright (C) 2015-2016 Oracle Corporation\n"
+            " *\n"
+            " * This file is part of VirtualBox Open Source Edition(OSE), as\n"
+            " * available from http ://www.virtualbox.org. This file is free software;\n"
+            " * you can redistribute it and / or modify it under the terms of the GNU\n"
+            " * General Public License(GPL) as published by the Free Software\n"
+            " * Foundation, in version 2 as it comes in the \"COPYING\" file of the\n"
+            " * VirtualBox OSE distribution.VirtualBox OSE is distributed in the\n"
+            " * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.\n"
+            " */"
+            "\n"
+            "\n"
+            "#include \"USBIdDatabase.h\"\n"
+            "\n",
+            argv0);
+
+    BldProgStrTab_WriteStringTable(pStrTab, pOut, "", "USBIdDatabase::s_", "StrTab");
+
+    fputs("/**\n"
+          " * USB devices aliases array.\n"
+          " * Format: VendorId, ProductId, Vendor Name, Product Name\n"
+          " * The source of the list is http://www.linux-usb.org/usb.ids\n"
+          " */\n"
+          "USBIDDBPROD const USBIdDatabase::s_aProducts[] =\n"
+          "{\n", pOut);
+    for (ProductsSet::iterator itp = g_products.begin(); itp != g_products.end(); ++itp)
+        fprintf(pOut, "    { 0x%04x },\n", itp->productID);
+    fputs("};\n"
+          "\n"
+          "\n"
+          "const RTBLDPROGSTRREF USBIdDatabase::s_aProductNames[] =\n"
+          "{\n", pOut);
+    for (ProductsSet::iterator itp = g_products.begin(); itp != g_products.end(); ++itp)
+        fprintf(pOut, "{ 0x%06x, 0x%02x },\n", itp->StrRef.offStrTab, itp->StrRef.cchString);
+    fputs("};\n"
+          "\n"
+          "const size_t USBIdDatabase::s_cProducts = RT_ELEMENTS(USBIdDatabase::s_aProducts);\n"
+          "\n", pOut);
+
+    fputs("USBIDDBVENDOR const USBIdDatabase::s_aVendors[] =\n"
+          "{\n", pOut);
+    for (VendorsSet::iterator itv = g_vendors.begin(); itv != g_vendors.end(); ++itv)
+        fprintf(pOut, "    { 0x%04x, 0x%04x, 0x%04x },\n", itv->vendorID, itv->iProduct, itv->cProducts);
+    fputs("};\n"
+          "\n"
+          "\n"
+          "const RTBLDPROGSTRREF USBIdDatabase::s_aVendorNames[] =\n"
+          "{\n", pOut);
+    for (VendorsSet::iterator itv = g_vendors.begin(); itv != g_vendors.end(); ++itv)
+        fprintf(pOut, "{ 0x%06x, 0x%02x },\n", itv->StrRef.offStrTab, itv->StrRef.cchString);
+    fputs("};\n"
+          "\n"
+          "const size_t USBIdDatabase::s_cVendors = RT_ELEMENTS(USBIdDatabase::s_aVendors);\n"
+          "\n", pOut);
+}
 
 static int usage(FILE *pOut, const char *argv0)
@@ -445,23 +454,5 @@
         return RTMsgErrorExit((RTEXITCODE)ERROR_OPEN_FILE, "Error opening '%s' for writing", pszOutFile);
 
-    fputs(header, pOut);
-    BldProgStrTab_WriteStringTable(&StrTab, pOut, "", "USBIdDatabase::s_", "StrTab");
-
-    fputs(product_header, pOut);
-    for (ProductsSet::iterator itp = g_products.begin(); itp != g_products.end(); ++itp)
-        fprintf(pOut, "    { 0x%04x },\n", itp->productID);
-
-    fputs(product_part2, pOut);
-    for (ProductsSet::iterator itp = g_products.begin(); itp != g_products.end(); ++itp)
-        fprintf(pOut, "{ 0x%06x, 0x%02x },\n", itp->StrRef.offStrTab, itp->StrRef.cchString);
-    fputs(product_footer, pOut);
-
-    fputs(vendor_header, pOut);
-    for (VendorsSet::iterator itv = g_vendors.begin(); itv != g_vendors.end(); ++itv)
-        fprintf(pOut, "    { 0x%04x, 0x%04x, 0x%04x },\n", itv->vendorID, itv->iProduct, itv->cProducts);
-    fputs(vendor_part2, pOut);
-    for (VendorsSet::iterator itv = g_vendors.begin(); itv != g_vendors.end(); ++itv)
-        fprintf(pOut, "{ 0x%06x, 0x%02x },\n", itv->StrRef.offStrTab, itv->StrRef.cchString);
-    fputs(vendor_footer, pOut);
+    WriteSourceFile(pOut, argv[0], &StrTab);
 
     if (ferror(pOut))
