diff options
author | Burt P <pburt0@gmail.com> | 2018-05-27 19:14:06 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-05-29 07:08:46 -0700 |
commit | b1e053e8bd24fbd38dff52b601adb2acdd763d70 (patch) | |
tree | d8ba170355023df0eed907a238faf9f97c85a5a5 | |
parent | adb872ec12aa96ac72fa7f237244d9c8f8f66314 (diff) |
vendor.c/vendor.ids: create vendor.ids
Create a new, more easily maintained, file for vendor information.
Installs with hardinfo, but can be sync-ed if that function ever
gets restored.
Reading the old vendor.conf format is still fully supported, AFAIK.
Signed-off-by: Burt P <pburt0@gmail.com>
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | hardinfo/vendor.c | 240 | ||||
-rw-r--r-- | vendor.ids | 355 |
3 files changed, 494 insertions, 102 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 21cc9184..6ec2b045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,7 @@ set(HARDINFO_MODULES set(HARDINFO_RESOURCES "benchmark.conf" "benchmark.data" + "vendor.ids" ) set(HARDINFO_MANPAGES diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index 5b9238ff..81b30863 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -26,72 +26,8 @@ #include "config.h" #include "hardinfo.h" -/* { match_string, name, url } */ +/* { match_string, match_case, name, url } */ static Vendor vendors[] = { - { "ASUS", 0, "ASUS", "www.asus.com" }, /* "ASUSTek" is common */ - { "ATI", 1, "ATI Technologies", "www.ati.com" }, - { "Advanced Micro Devices", 0, "Advanced Micro Devices", "www.amd.com" }, - { "AMD", 1, "Advanced Micro Devices", "www.amd.com" }, - { "AMD/ATI", 1, "Advanced Micro Devices (formerly ATI)", "www.amd.com" }, - { "nVidia", 0, "nVidia", "www.nvidia.com" }, - { "3Com", 0, "3Com", "www.3com.com" }, - { "Intel", 0, "Intel", "www.intel.com" }, - { "Cirrus Logic", 0, "Cirrus Logic", "www.cirrus.com" }, - { "VIA", 1, "VIA Technologies", "www.via.com.tw" }, - { "NEC", 1, "NEC Corporation", "www.nec.com"}, - { "Realtek", 0, "Realtek", "www.realtek.com.tw"}, - { "Toshiba", 0, "Toshiba", "www.toshiba.com"}, - { "LITE-ON", 1, "LITE-ON", "www.liteonit.com"}, - { "Maxtor", 0, "Maxtor", "www.maxtor.com"}, - { "Samsung", 0, "Samsung", "www.samsung.com"}, - { "Pioneer", 0, "Pioneer", "www.pioneer-eur.com"}, - { "Plextor", 0, "Plextor", "www.plextor.be"}, - { "WDC", 1, "Western Digital", "www.wdc.com"}, - { "HL-DT-ST", 1, "LG Electronics", "www.lge.com"}, - { "Lexmark", 0, "Lexmark", "www.lexmark.com"}, - { "Creative Labs", 0, "Creative Labs", "www.creative.com"}, - { "Brooktree", 0, "Conexant", "www.brooktree.com"}, - { "Atheros", 0, "Atheros Communications", "www.atheros.com"}, - { "MATSHITA", 0, "Panasonic", "www.panasonic.com"}, - { "Silicon Image", 0, "Silicon Image", "www.siliconimage.com"}, - { "Silicon Integrated Image", 0, "Silicon Image", "www.siliconimage.com"}, - { "Broadcom", 0, "Broadcom", "www.broadcom.com"}, - { "Apple", 0, "Apple", "www.apple.com"}, - { "IBM", 1, "IBM", "www.ibm.com"}, - { "Dell", 0, "Dell Computer", "www.dell.com"}, - { "Logitech", 0, "Logitech International", "www.logitech.com"}, - { "FUJITSU", 0, "Fujitsu", "www.fujitsu.com"}, - { "CDU", 1, "Sony", "www.sony.com"}, - { "SanDisk", 0, "SanDisk", "www.sandisk.com"}, - { "ExcelStor", 0, "ExcelStor Technology", "www.excelstor.com"}, - { "D-Link", 0, "D-Link", "www.dlink.com.tw"}, - { "Giga-byte", 0, "Gigabyte Technology", "www.gigabyte.com.tw"}, - { "Gigabyte", 0, "Gigabyte Technology", "www.gigabyte.com.tw"}, - { "C-Media", 0, "C-Media Electronics", "www.cmedia.com.tw"}, - { "Avermedia", 0, "AVerMedia Technologies", "www.aver.com"}, - { "Philips", 0, "Philips", "www.philips.com"}, - { "RaLink", 0, "Ralink Technology", "www.ralinktech.com"}, - { "Siemens", 0, "Siemens AG", "www.siemens.com"}, - { "Hewlett-Packard", 0, "Hewlett-Packard", "www.hp.com"}, - { "HP", 1, "Hewlett-Packard", "www.hp.com"}, - { "TEAC", 1, "TEAC America", "www.teac.com"}, - { "Microsoft", 0, "Microsoft", "www.microsoft.com"}, - {" Memorex", 0, "Memorex Products", "www.memorex.com"}, - { "eMPIA", 1, "eMPIA Technology", "www.empiatech.com.tw"}, - { "Canon", 0, "Canon", "www.canon.com"}, - { "A4Tech", 0, "A4tech", "www.a4tech.com"}, - { "ALCOR", 0, "Alcor", "www.alcor.org"}, - { "Vimicro", 0, "Vimicro", "www.vimicro.com"}, - { "OTi", 1, "Ours Technology", "www.oti.com.tw"}, - { "BENQ", 0, "BenQ", "www.benq.com"}, - { "Acer", 0, "Acer", "www.acer.com"}, - { "QUANTUM", 0, "Quantum", "www.quantum.com"}, - { "Kingston", 0, "Kingston", "www.kingston.com"}, - { "Chicony", 0, "Chicony", "www.chicony.com.tw"}, - { "Genius", 0, "Genius", "www.genius.ru"}, - { "KYE", 1, "KYE Systems", "www.genius-kye.com"}, - { "ST", 1, "SEAGATE", "www.seagate.com"}, - /* BIOS manufacturers */ { "American Megatrends", 0, "American Megatrends", "www.ami.com"}, { "Award", 0, "Award Software International", "www.award-bios.com"}, @@ -133,33 +69,12 @@ gint vendor_sort (gconstpointer a, gconstpointer b) { return 1; } -void vendor_init(void) -{ - gint i; - gchar *path; - static SyncEntry se = { - .fancy_name = "Update vendor list", - .name = "RecvVendorList", - .save_to = "vendor.conf", - .get_data = NULL - }; - - DEBUG("initializing vendor list"); - sync_manager_add_entry(&se); - - path = g_build_filename(g_get_user_config_dir(), "hardinfo", "vendor.conf", NULL); - if (!g_file_test(path, G_FILE_TEST_EXISTS)) { - DEBUG("local vendor.conf not found, trying system-wise"); - g_free(path); - path = g_build_filename(params.path_data, "vendor.conf", NULL); - } - - if (g_file_test(path, G_FILE_TEST_EXISTS)) { +static int read_from_vendor_conf(const char *path) { GKeyFile *vendors; gchar *tmp; - gint num_vendors; + gint num_vendors, i, count = 0; /* num_vendors is file-reported, count is actual */ - DEBUG("loading %s", path); + DEBUG("using vendor.conf format loader for %s", path); vendors = g_key_file_new(); if (g_key_file_load_from_file(vendors, path, 0, NULL)) { @@ -175,23 +90,139 @@ void vendor_init(void) /* try old name */ v->match_string = g_key_file_get_string(vendors, tmp, "id", NULL); } - v->match_case = g_key_file_get_integer(vendors, tmp, "match_case", NULL); - v->name = g_key_file_get_string(vendors, tmp, "name", NULL); - v->url = g_key_file_get_string(vendors, tmp, "url", NULL); - - vendor_list = g_slist_prepend(vendor_list, v); + if (v->match_string) { + v->match_case = g_key_file_get_integer(vendors, tmp, "match_case", NULL); + v->name = g_key_file_get_string(vendors, tmp, "name", NULL); + v->url = g_key_file_get_string(vendors, tmp, "url", NULL); + + vendor_list = g_slist_prepend(vendor_list, v); + count++; + } else { + /* don't add if match_string is null */ + g_free(v); + } g_free(tmp); } - } + g_key_file_free(vendors); + DEBUG("... found %d match strings", count); + return count; + } + g_key_file_free(vendors); + return 0; +} + +static int read_from_vendor_ids(const char *path) { +#define VEN_BUFF_SIZE 128 +#define VEN_FFWD() while(isspace((unsigned char)*p)) p++; +#define VEN_CHK(TOK) (strncmp(p, TOK, tl = strlen(TOK)) == 0) + char buff[VEN_BUFF_SIZE]; + char name[VEN_BUFF_SIZE]; + char url[VEN_BUFF_SIZE]; + int count = 0; + FILE *fd; + char *p, *b; + int tl; + + DEBUG("using vendor.ids format loader for %s", path); + + fd = fopen(path, "r"); + if (!fd) return 0; + + while (fgets(buff, VEN_BUFF_SIZE, fd)) { + b = strchr(buff, '\n'); + if (b) *b = 0; + p = buff; + VEN_FFWD(); + if (VEN_CHK("name ")) + strncpy(name, p + tl, VEN_BUFF_SIZE - 1); + if (VEN_CHK("url ")) + strncpy(url, p + tl, VEN_BUFF_SIZE - 1); + + if (VEN_CHK("match_string ")) { + Vendor *v = g_new0(Vendor, 1); + v->match_string = strdup(p+tl); + v->match_case = 0; + v->name = strdup(name); + v->url = strdup(url); + vendor_list = g_slist_prepend(vendor_list, v); + count++; + } + + if (VEN_CHK("match_string_case ")) { + Vendor *v = g_new0(Vendor, 1); + v->match_string = strdup(p+tl); + v->match_case = 1; + v->name = strdup(name); + v->url = strdup(url); + vendor_list = g_slist_prepend(vendor_list, v); + count++; + } + } + + fclose(fd); + + DEBUG("... found %d match strings", count); + + return count; +} + + +void vendor_init(void) +{ + gchar *path; + static SyncEntry se = { + .fancy_name = "Update vendor list", + .name = "RecvVendorList", + .save_to = "vendor.ids", + .get_data = NULL + }; + + DEBUG("initializing vendor list"); + sync_manager_add_entry(&se); + + char *file_search_order[] = { + /* new format */ + g_build_filename(g_get_user_config_dir(), "hardinfo", "vendor.ids", NULL), + g_build_filename(params.path_data, "vendor.ids", NULL), + /* old format */ + g_build_filename(g_get_user_config_dir(), "hardinfo", "vendor.conf", NULL), + g_build_filename(g_get_home_dir(), ".hardinfo", "vendor.conf", NULL), /* old place */ + g_build_filename(params.path_data, "vendor.conf", NULL), + NULL + }; + + int n = 0; + while (file_search_order[n]) { + DEBUG("searching for vendor data at %s ...", file_search_order[n]); + if (!access(file_search_order[n], R_OK)) { + path = file_search_order[n]; + DEBUG("... file exists."); + break; + } + n++; + } + + int fail = 1; - g_key_file_free(vendors); - } else { - DEBUG("system-wise vendor.conf not found, using internal database"); + /* new format */ + if (path && strstr(path, "vendor.ids")) { + fail = !read_from_vendor_ids(path); + } - for (i = G_N_ELEMENTS(vendors) - 1; i >= 0; i--) { - vendor_list = g_slist_prepend(vendor_list, (gpointer) &vendors[i]); - } + /* old format */ + if (path && strstr(path, "vendor.conf")) { + fail = !read_from_vendor_conf(path); + } + + if (fail) { + gint i; + + DEBUG("vendor data not found, using internal database"); + + for (i = G_N_ELEMENTS(vendors) - 1; i >= 0; i--) { + vendor_list = g_slist_prepend(vendor_list, (gpointer) &vendors[i]); + } } /* sort the vendor list by length of match string so that short strings are @@ -199,7 +230,12 @@ void vendor_init(void) * example: ST matches ASUSTeK but SEAGATE is not ASUS */ vendor_list = g_slist_sort(vendor_list, &vendor_sort); - g_free(path); + /* free search location strings */ + n = 0; + while (file_search_order[n]) { + free(file_search_order[n]); + n++; + } } const gchar *vendor_get_name(const gchar * id_str) diff --git a/vendor.ids b/vendor.ids new file mode 100644 index 00000000..736547c1 --- /dev/null +++ b/vendor.ids @@ -0,0 +1,355 @@ +# +# Vendor Name and URL +# +# Syntax: +# name <name> +# url <url> +# [match_string|match_string_case] <match> +# ... +# [match_string|match_string_case] <match> +# [match_string|match_string_case] <match> +# +# +# Except for the newline, trailing whitespace is included in the string. +# Match strings should be unique. +# + +name ASUS + url www.asus.com + # "ASUSTek" is common + match_string ASUSTek + match_string ASUS + +name Advanced Micro Devices + url www.amd.com + match_string Advanced Micro Devices + match_string_case AMD + +name Advanced Micro Devices (formerly ATI) + url www.amd.com + match_string ATI Technologies + match_string_case AMD/ATI + match_string_case ATI + +name nVidia + url www.nvidia.com + match_string nVidia + +name 3Com + url www.3com.com + match_string 3Com + +name Intel + url www.intel.com + match_string Intel + +name Cirrus Logic + url www.cirrus.com + match_string Cirrus Logic + +name VIA Technologies + url www.via.com.tw + match_string_case VIA + +name NEC Corporation + url www.nec.com + match_string_case NEC + +name Realtek + url www.realtek.com.tw + match_string Realtek + +name Toshiba + url www.toshiba.com + match_string Toshiba + +name LITE-ON + url www.liteonit.com + match_string_case LITE-ON + +name Maxtor + url www.maxtor.com + match_string Maxtor + +name Samsung + url www.samsung.com + match_string Samsung + +name Pioneer + url www.pioneer-eur.com + match_string Pioneer + +name Plextor + url www.plextor.be + match_string Plextor + +name Western Digital + url www.wdc.com + match_string_case WDC + +name LG Electronics + url www.lge.com + match_string_case HL-DT-ST + +name Lexmark + url www.lexmark.com + match_string Lexmark + +name Creative Labs + url www.creative.com + match_string Creative Labs + +name Conexant + url www.brooktree.com + match_string Brooktree + +name Atheros Communications + url www.atheros.com + match_string Atheros + +name Panasonic + url www.panasonic.com + match_string MATSHITA + +name Silicon Image + url www.siliconimage.com + match_string Silicon Image + match_string Silicon Integrated Image + +name Broadcom + url www.broadcom.com + match_string Broadcom + +name Apple + url www.apple.com + match_string Apple + +name IBM + url www.ibm.com + match_string_case IBM + +name Dell Computer + url www.dell.com + match_string Dell + +name Logitech International + url www.logitech.com + match_string Logitech + +name Fujitsu + url www.fujitsu.com + match_string FUJITSU + +name Sony + url www.sony.com + match_string_case CDU + +name SanDisk + url www.sandisk.com + match_string SanDisk + +name ExcelStor Technology + url www.excelstor.com + match_string ExcelStor + +name D-Link + url www.dlink.com.tw + match_string D-Link + +name Gigabyte Technology + url www.gigabyte.com.tw + match_string Giga-byte + match_string Gigabyte + +name C-Media Electronics + url www.cmedia.com.tw + match_string C-Media + +name AVerMedia Technologies + url www.aver.com + match_string Avermedia + +name Philips + url www.philips.com + match_string Philips + +name Ralink Technology + url www.ralinktech.com + match_string RaLink + +name Siemens AG + url www.siemens.com + match_string Siemens + +name Hewlett-Packard + url www.hp.com + match_string Hewlett-Packard + match_string_case HP + +name TEAC America + url www.teac.com + match_string_case TEAC + +name Microsoft + url www.microsoft.com + match_string Microsoft + +name Memorex Products + url www.memorex.com + match_string Memorex + +name eMPIA Technology + url www.empiatech.com.tw + match_string_case eMPIA + +name Canon + url www.canon.com + match_string Canon + +name A4tech + url www.a4tech.com + match_string A4Tech + +name Alcor + url www.alcor.org + match_string ALCOR + +name Vimicro + url www.vimicro.com + match_string Vimicro + +name Ours Technology + url www.oti.com.tw + match_string_case OTi + +name BenQ + url www.benq.com + match_string BENQ + +name Acer + url www.acer.com + match_string Acer + +name Quantum + url www.quantum.com + match_string QUANTUM + +name Kingston + url www.kingston.com + match_string Kingston + +name Chicony + url www.chicony.com.tw + match_string Chicony + +name Genius + url www.genius.ru + match_string Genius + +name KYE Systems + url www.genius-kye.com + match_string_case KYE + +name SEAGATE + url www.seagate.com + match_string_case ST + +# +# BIOS manufacturers +# + +name American Megatrends + url www.ami.com + match_string American Megatrends + +name Award Software International + url www.award-bios.com + match_string Award + +name Phoenix Technologies + url www.phoenix.com + match_string Phoenix + +# +# x86 vendor strings +# + +name Advanced Micro Devices + url www.amd.com + match_string AMDisbetter! + +name Advanced Micro Devices + url www.amd.com + match_string AuthenticAMD + +name VIA (formerly Centaur Technology) + url www.via.tw + match_string CentaurHauls + +name Cyrix + url + match_string CyrixInstead + +name Intel + url www.intel.com + match_string GenuineIntel + +name Transmeta + url + match_string TransmetaCPU + +name Transmeta + url + match_string GenuineTMx86 + +name National Semiconductor + url + match_string Geode by NSC + +name NexGen + url + match_string NexGenDriven + +name Rise Technology + url + match_string RiseRiseRise + +name Silicon Integrated Systems + url + match_string SiS SiS SiS + +name United Microelectronics Corporation + url + match_string UMC UMC UMC + +name VIA + url www.via.tw + match_string VIA VIA VIA + +name DMP Electronics + url + match_string Vortex86 SoC + +# +# x86 VM vendor strings +# + +name KVM + url + match_string KVMKVMKVM + +name Microsoft Hyper-V + url www.microsoft.com + match_string Microsoft Hv + +name Parallels + url + match_string lrpepyh vr + +name VMware + url + match_string VMwareVMware + +name Xen HVM + url + match_string XenVMMXenVMM |