Back to index

lshw  02.16
pnp.cc
Go to the documentation of this file.
00001 /*
00002  * pnp.cc
00003  *
00004  *
00005  *
00006  *
00007  *
00008  */
00009 #include "version.h"
00010 #include "pnp.h"
00011 
00012 #include <stdlib.h>
00013 #include <string.h>
00014 
00015 __ID("@(#) $Id: pnp.cc 2433 2012-01-10 22:01:30Z lyonel $");
00016 
00017 static const char *pnp_vendors[] =
00018 {
00019   "ABP", "Advansys",
00020   "ACC", "Accton",
00021   "ACE", "Accton",
00022   "ACR", "Acer",
00023   "ADP", "Adaptec",
00024   "ADV", "AMD",
00025   "AIR", "AIR",
00026   "AMI", "AMI",
00027   "ASU", "ASUS",
00028   "ATI", "ATI",
00029   "ATK", "Allied Telesyn",
00030   "AZT", "Aztech",
00031   "BAN", "Banya",
00032   "BRI", "Boca Research",
00033   "BUS", "Buslogic",
00034   "CCI", "Cache Computers Inc.",
00035   "CHA", "Chase",
00036   "CMD", "CMD Technology, Inc.",
00037   "COG", "Cogent",
00038   "CPQ", "Compaq",
00039   "CRS", "Crescendo",
00040   "CSC", "Crystal",
00041   "CSI", "CSI",
00042   "CTL", "Creative Labs",
00043   "DBI", "Digi",
00044   "DEC", "Digital Equipment",
00045   "DEL", "Dell",
00046   "DBK", "Databook",
00047   "EGL", "Eagle Technology",
00048   "ELS", "ELSA",
00049   "ESS", "ESS",
00050   "FAR", "Farallon",
00051   "FDC", "Future Domain",
00052   "HWP", "Hewlett-Packard",
00053   "IBM", "IBM",
00054   "INT", "Intel",
00055   "ISA", "Iomega",
00056   "MDG", "Madge",
00057   "MDY", "Microdyne",
00058   "MET", "Metheus",
00059   "MIC", "Micronics",
00060   "MLX", "Mylex",
00061   "NEC", "NEC",
00062   "NVL", "Novell",
00063   "OLC", "Olicom",
00064   "PRO", "Proteon",
00065   "RII", "Racal",
00066   "RTL", "Realtek",
00067   "SCM", "SCM",
00068   "SEC", "SAMSUNG",
00069   "SKD", "SysKonnect",
00070   "SMC", "SMC",
00071   "SNI", "Siemens Nixdorf",
00072   "STL", "Stallion Technologies",
00073   "SUP", "SupraExpress",
00074   "SVE", "SVEC",
00075   "TCC", "Thomas-Conrad",
00076   "TCI", "Tulip",
00077   "TCM", "3Com",
00078   "TCO", "Thomas-Conrad",
00079   "TEC", "Tecmar",
00080   "TRU", "Truevision",
00081   "TOS", "Toshiba",
00082   "TYN", "Tyan",
00083   "UBI", "Ungermann-Bass",
00084   "USC", "UltraStor",
00085   "VDM", "Vadem",
00086   "VMI", "Vermont",
00087   "WDC", "Western Digital",
00088   "ZDS", "Zeos",
00089   NULL, NULL
00090 };
00091 
00092 const char *vendorname(const char *id)
00093 {
00094   int i = 0;
00095   if (id == NULL)
00096     return "";
00097 
00098   while (pnp_vendors[i])
00099   {
00100     if (strncmp(pnp_vendors[i], id, strlen(pnp_vendors[i])) == 0)
00101       return pnp_vendors[i + 1];
00102     i += 2;
00103   }
00104 
00105   return "";
00106 }
00107 
00108 
00109 hw::hwClass pnp_class(const string & pnpid)
00110 {
00111   long numericid = 0;
00112 
00113   if (pnpid.substr(0, 3) != "PNP")
00114     return hw::generic;
00115 
00116   numericid = strtol(pnpid.substr(3).c_str(), NULL, 16);
00117 
00118   if (numericid < 0x0300)
00119     return hw::system;
00120   if (numericid >= 0x300 && numericid < 0x0400)
00121     return hw::input;                             // keyboards
00122   if (numericid >= 0x400 && numericid < 0x0500)
00123     return hw::printer;                           // parallel
00124   if (numericid >= 0x500 && numericid < 0x0600)
00125     return hw::communication;                     // serial
00126   if (numericid >= 0x600 && numericid < 0x0800)
00127     return hw::storage;                           // ide
00128   if (numericid >= 0x900 && numericid < 0x0A00)
00129     return hw::display;                           // vga
00130   if (numericid == 0x802)
00131     return hw::multimedia;                        // Microsoft Sound System compatible device
00132   if (numericid >= 0xA00 && numericid < 0x0B00)
00133     return hw::bridge;                            // isa,pci...
00134   if (numericid >= 0xE00 && numericid < 0x0F00)
00135     return hw::bridge;                            // pcmcia
00136   if (numericid >= 0xF00 && numericid < 0x1000)
00137     return hw::input;                             // mice
00138   if (numericid < 0x8000)
00139     return hw::system;
00140 
00141   if (numericid >= 0x8000 && numericid < 0x9000)
00142     return hw::network;                           // network
00143   if (numericid >= 0xA000 && numericid < 0xB000)
00144     return hw::storage;                           // scsi&cd
00145   if (numericid >= 0xB000 && numericid < 0xC000)
00146     return hw::multimedia;                        // multimedia
00147   if (numericid >= 0xC000 && numericid < 0xD000)
00148     return hw::communication;                     // modems
00149 
00150   return hw::generic;
00151 }