/* * Command line handling of dmidecode * This file is part of the dmidecode project. * * (C) 2005 Jean Delvare * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "config.h" #include "types.h" #include "dmidecode.h" #include "dmiopt.h" /* Options are global */ struct opt opt; /* * Handling of option --type */ struct type_keyword { const char *keyword; const u8 *type; }; static const u8 opt_type_bios[]={ 0, 13, 255 }; static const u8 opt_type_system[]={ 1, 12, 15, 23, 32, 255 }; static const u8 opt_type_baseboard[]={ 2, 10, 255 }; static const u8 opt_type_chassis[]={ 3, 255 }; static const u8 opt_type_processor[]={ 4, 255 }; static const u8 opt_type_memory[]={ 5, 6, 16, 17, 255 }; static const u8 opt_type_cache[]={ 7, 255 }; static const u8 opt_type_connector[]={ 8, 255 }; static const u8 opt_type_slot[]={ 9, 255 }; static const struct type_keyword opt_type_keyword[]={ { "bios", opt_type_bios }, { "system", opt_type_system }, { "baseboard", opt_type_baseboard }, { "chassis", opt_type_chassis }, { "processor", opt_type_processor }, { "memory", opt_type_memory }, { "cache", opt_type_cache }, { "connector", opt_type_connector }, { "slot", opt_type_slot }, }; static void print_opt_type_list(void) { unsigned int i; fprintf(stderr, "Valid type keywords are:\n"); for(i=0; i0xff) { fprintf(stderr, "Invalid type number: %lu\n", val); goto exit_free; } p[val]=1; arg=next; while(*arg==',' || *arg==' ') arg++; } found: return p; exit_free: free(p); return NULL; } /* * Handling of option --string */ /* This lookup table could admittedly be reworked for improved performance. Due to the low count of items in there at the moment, it did not seem worth the additional code complexity though. */ static const struct string_keyword opt_string_keyword[]={ { "bios-vendor", 0, 0x04, NULL, NULL }, { "bios-version", 0, 0x05, NULL, NULL }, { "bios-release-date", 0, 0x08, NULL, NULL }, { "system-manufacturer", 1, 0x04, NULL, NULL }, { "system-product-name", 1, 0x05, NULL, NULL }, { "system-version", 1, 0x06, NULL, NULL }, { "system-serial-number", 1, 0x07, NULL, NULL }, { "system-uuid", 1, 0x08, NULL, dmi_system_uuid }, { "baseboard-manufacturer", 2, 0x04, NULL, NULL }, { "baseboard-product-name", 2, 0x05, NULL, NULL }, { "baseboard-version", 2, 0x06, NULL, NULL }, { "baseboard-serial-number", 2, 0x07, NULL, NULL }, { "baseboard-asset-tag", 2, 0x08, NULL, NULL }, { "chassis-manufacturer", 3, 0x04, NULL, NULL }, { "chassis-type", 3, 0x05, dmi_chassis_type, NULL }, { "chassis-version", 3, 0x06, NULL, NULL }, { "chassis-serial-number", 3, 0x07, NULL, NULL }, { "chassis-asset-tag", 3, 0x08, NULL, NULL }, { "processor-family", 4, 0x06, dmi_processor_family, NULL }, { "processor-manufacturer", 4, 0x07, NULL, NULL }, { "processor-version", 4, 0x10, NULL, NULL }, { "processor-frequency", 4, 0x16, NULL, dmi_processor_frequency }, }; static void print_opt_string_list(void) { unsigned int i; fprintf(stderr, "Valid string keywords are:\n"); for(i=0; i