Changeset 58000 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Oct 2, 2015 10:05:38 AM (9 years ago)
- Location:
- trunk/src/VBox/Main/src-server
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/HostUSBDeviceImpl.cpp
r57994 r58000 170 170 if (mUsb->pszManufacturer == NULL || mUsb->pszManufacturer[0] == 0) 171 171 { 172 const char *vendorName = AliasDictionary::findVendor(mUsb->idVendor);172 const char *vendorName = AliasDictionary::findVendor(mUsb->idVendor); 173 173 if (vendorName) 174 174 aManufacturer = vendorName; … … 185 185 if (mUsb->pszProduct == NULL || mUsb->pszProduct[0] == 0) 186 186 { 187 const char *productName = AliasDictionary::findProduct(mUsb->idVendor, mUsb->idProduct);187 const char *productName = AliasDictionary::findProduct(mUsb->idVendor, mUsb->idProduct); 188 188 if (productName) 189 189 aProduct = productName; … … 335 335 name = Utf8StrFmt("%s %s", mUsb->pszManufacturer, mUsb->pszProduct); 336 336 else if (haveManufacturer) 337 name = Utf8StrFmt("%s", mUsb->pszManufacturer);337 name = mUsb->pszManufacturer; 338 338 else if (haveProduct) 339 name = Utf8StrFmt("%s", mUsb->pszProduct);339 name = mUsb->pszProduct; 340 340 else 341 341 { 342 const char* vendorName = AliasDictionary::findVendor(mUsb->idVendor); 343 const char* productName = AliasDictionary::findProduct(mUsb->idVendor, mUsb->idProduct); 344 if (vendorName && productName) 345 { 346 name = Utf8StrFmt("%s %s", vendorName, productName); 347 } 342 const char *pszVendorName = AliasDictionary::findVendor(mUsb->idVendor); 343 const char *pszProductName = AliasDictionary::findProduct(mUsb->idVendor, mUsb->idProduct); 344 if (pszVendorName && pszProductName) 345 name = Utf8StrFmt("%s %s", pszVendorName, pszProductName); 348 346 else 349 347 { 350 name = "<unknown>"; 351 LogRel(("USB: Unknown USB device detected (idVendor: 0x%04x, idProduct: 0x%04x). Please, report the idVendor and idProduct to virtualbox.org.\n", vendorName, productName)); 348 LogRel(("USB: Unknown USB device detected (idVendor: 0x%04x, idProduct: 0x%04x). Please, report the idVendor and idProduct to virtualbox.org.\n", 349 mUsb->idVendor, mUsb->idProduct)); 350 if (pszVendorName) 351 name = pszVendorName; 352 else if (pszProductName) 353 name = pszProductName; 354 else 355 name = "<unknown>"; 352 356 } 353 357 } -
trunk/src/VBox/Main/src-server/USBIdDatabaseGenerator.cpp
r57662 r58000 1 /* $Id$ */ 2 /** @file 3 * USB device vendor and product ID database - generator. 4 */ 5 1 6 /* 2 * Copyright (C) 2006-2015 Oracle Corporation3 *4 * This file is part of VirtualBox Open Source Edition (OSE), as5 * available from http://www.virtualbox.org. This file is free software;6 * you can redistribute it and/or modify it under the terms of the GNU7 * General Public License (GPL) as published by the Free Software8 * Foundation, in version 2 as it comes in the "COPYING" file of the9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.11 */7 * Copyright (C) 2015 Oracle Corporation 8 * 9 * This file is part of VirtualBox Open Source Edition (OSE), as 10 * available from http://www.virtualbox.org. This file is free software; 11 * you can redistribute it and/or modify it under the terms of the GNU 12 * General Public License (GPL) as published by the Free Software 13 * Foundation, in version 2 as it comes in the "COPYING" file of the 14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 */ 12 17 13 18 #include <stdio.h> … … 26 31 using namespace std; 27 32 28 const char *header = 33 static const char * const header = 34 "/** @file\n" 35 " * USB device vendor and product ID database - Autogenerated from <stupid C++ cannot do %s>\n" 36 " */\n" 37 "\n" 29 38 "/*\n" 30 " * Copyright (C) 2015 Oracle Corporation\n"39 " * Copyright (C) 2015 Oracle Corporation\n" 31 40 " *\n" 32 41 " * This file is part of VirtualBox Open Source Edition(OSE), as\n" … … 116 125 switch (res[i]) 117 126 { 118 case '"': 119 case '\\': res.insert(i++, "\\"); break; 120 default: 121 { 122 // encode multibyte UTF-8 symbols to be sure that they 123 // will be safely read by compiler 124 if ((unsigned char)res[i] >= 127) 127 case '"': 128 case '\\': res.insert(i++, "\\"); break; 129 default: 125 130 { 126 size_t start = i; 127 string temp = "\" \""; 128 char buffer[8] = { 0 }; 129 do 131 // encode multibyte UTF-8 symbols to be sure that they 132 // will be safely read by compiler 133 if ((unsigned char)res[i] >= 127) 130 134 { 131 RTStrPrintf(buffer, sizeof(buffer), "\\x%x", (unsigned char)res[i]); 132 temp.append(buffer); 133 } while ((unsigned char)res[++i] & 0x80); 134 // splitting string after escape sequence to finish number sequence 135 // otherwise it could lead to situation when "\x88a" will threathened as 136 // multibyte symbol '\x88a' instead of two symbols '\x88' and 'a' 137 temp.append("\" \""); 138 res.replace(start, i - start, temp); 139 i += temp.length(); 135 size_t start = i; 136 string temp = "\" \""; 137 char buffer[8] = { 0 }; 138 do 139 { 140 RTStrPrintf(buffer, sizeof(buffer), "\\x%x", (unsigned char)res[i]); 141 temp.append(buffer); 142 } while ((unsigned char)res[++i] & 0x80); 143 // splitting string after escape sequence to finish number sequence 144 // otherwise it could lead to situation when "\x88a" will threathened as 145 // multibyte symbol '\x88a' instead of two symbols '\x88' and 'a' 146 temp.append("\" \""); 147 res.replace(start, i - start, temp); 148 i += temp.length(); 149 } 140 150 } 141 }142 151 } 143 152 } … … 234 243 switch (state) 235 244 { 236 case State::lookForStartBlock: 237 { 238 if (line.find(start_block) != string::npos) 239 state = State::lookForEndBlock; 240 break; 241 } 242 case State::lookForEndBlock: 243 { 244 if (line.find(end_block) != string::npos) 245 state = State::finished; 246 else 245 case State::lookForStartBlock: 247 246 { 248 if (!IsCommentOrEmptyLine(line)) 247 if (line.find(start_block) != string::npos) 248 state = State::lookForEndBlock; 249 break; 250 } 251 case State::lookForEndBlock: 252 { 253 if (line.find(end_block) != string::npos) 254 state = State::finished; 255 else 249 256 { 250 if ( line[0] == '\t')257 if (!IsCommentOrEmptyLine(line)) 251 258 { 252 // Parse Product line 253 // first line should be vendor 254 if (vendor.vendorID == 0) 259 if (line[0] == '\t') 255 260 { 256 cerr << "Wrong file format. Product before vendor: " 257 << line.c_str() << "'" << endl; 258 return ERROR_WRONG_FILE_FORMAT; 261 // Parse Product line 262 // first line should be vendor 263 if (vendor.vendorID == 0) 264 { 265 cerr << "Wrong file format. Product before vendor: " 266 << line.c_str() << "'" << endl; 267 return ERROR_WRONG_FILE_FORMAT; 268 } 269 ProductRecord product = { 0, vendor.vendorID, 0, "" }; 270 if (ParseAlias(line.substr(1), product.productID, product.product) != 0) 271 { 272 cerr << "Error in parsing product line: '" 273 << line.c_str() << "'" << endl; 274 return ERROR_IN_PARSE_LINE; 275 } 276 product.key = USBKEY(product.vendorID, product.productID); 277 Assert(product.vendorID != 0); 278 g_products.push_back(product); 259 279 } 260 ProductRecord product = { 0, vendor.vendorID, 0, "" }; 261 if (ParseAlias(line.substr(1), product.productID, product.product) != 0) 280 else 262 281 { 263 cerr << "Error in parsing product line: '" 264 << line.c_str() << "'" << endl; 265 return ERROR_IN_PARSE_LINE; 282 // Parse vendor line 283 if (ParseAlias(line, vendor.vendorID, vendor.vendor) != 0) 284 { 285 cerr << "Error in parsing vendor line: '" 286 << line.c_str() << "'" << endl; 287 return ERROR_IN_PARSE_LINE; 288 } 289 g_vendors.push_back(vendor); 266 290 } 267 product.key = USBKEY(product.vendorID, product.productID);268 Assert(product.vendorID != 0);269 g_products.push_back(product);270 }271 else272 {273 // Parse vendor line274 if (ParseAlias(line, vendor.vendorID, vendor.vendor) != 0)275 {276 cerr << "Error in parsing vendor line: '"277 << line.c_str() << "'" << endl;278 return ERROR_IN_PARSE_LINE;279 }280 g_vendors.push_back(vendor);281 291 } 282 292 } 293 break; 283 294 } 284 break;285 }286 295 } 287 296 } … … 294 303 } 295 304 296 int main(int argc, char *argv[])305 int main(int argc, char *argv[]) 297 306 { 298 307 int rc = RTR3InitExe(argc, &argv, 0); … … 312 321 g_vendors.reserve(3500); 313 322 314 char* outName = NULL; 315 rc = 0; 323 const char *outName = NULL; 316 324 for (int i = 1; i < argc; i++) 317 325 { … … 322 330 } 323 331 324 if (RT_FAILURE(rc = RTStrmOpen(argv[i], "r", &fin))) 332 rc = RTStrmOpen(argv[i], "r", &fin); 333 if (RT_FAILURE(rc)) 325 334 { 326 335 cerr << "Format: " << argv[0] << … … 349 358 { 350 359 cerr << "Warning: Duplicate alias detected. " << *ita << endl; 360 /** @todo r=bird: Why return success (0) when we didn't generate the 361 * file?!?!? */ 351 362 return 0; 352 363 } … … 360 371 } 361 372 373 /** @todo String compression. */ 374 362 375 fout.open(outName); 363 376 if (!fout.is_open()) -
trunk/src/VBox/Main/src-server/USBIdDatabaseStub.cpp
r57358 r58000 1 /* $Id$ */ 2 /** @file 3 * USB device vendor and product ID database - stub. 4 */ 5 1 6 /* 2 * Copyright(C) 2005 - 2015 Oracle Corporation 3 * 4 * This file is part of VirtualBox Open Source Edition(OSE), as 5 * available from http ://www.virtualbox.org. This file is free software; 6 * you can redistribute it and / or modify it under the terms of the GNU 7 * General Public License(GPL) as published by the Free Software 8 * Foundation, in version 2 as it comes in the "COPYING" file of the 9 * VirtualBox OSE distribution.VirtualBox OSE is distributed in the 10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 11 * 12 */ 7 * Copyright (C) 2015 Oracle Corporation 8 * 9 * This file is part of VirtualBox Open Source Edition (OSE), as 10 * available from http://www.virtualbox.org. This file is free software; 11 * you can redistribute it and/or modify it under the terms of the GNU 12 * General Public License (GPL) as published by the Free Software 13 * Foundation, in version 2 as it comes in the "COPYING" file of the 14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 */ 13 17 14 18 #include "USBIdDatabase.h" 15 19 16 /** USB devices aliases array. 17 * Format: VendorId, ProductId, Vendor Name, Product Name 18 * The source of the list is http://www.linux-usb.org/usb.ids 19 */ 20 Product AliasDictionary::productArray[] = {0}; 20 Product AliasDictionary::productArray[] = {0}; 21 const size_t AliasDictionary::products_size = 0; 22 Vendor AliasDictionary::vendorArray[] = {0}; 23 const size_t AliasDictionary::vendors_size = 0; 21 24 22 const size_t AliasDictionary::products_size = sizeof(AliasDictionary::productArray) / sizeof(Product);23 24 Vendor AliasDictionary::vendorArray[] = {0};25 26 const size_t AliasDictionary::vendors_size = sizeof(AliasDictionary::vendorArray) / sizeof(Vendor);
Note:
See TracChangeset
for help on using the changeset viewer.