dmi_handle_list *dmidecode_match_value(const char *name, const char *value, const unsigned long *dmi_type) { dmi_handle_list *hl = NULL; gchar *full = NULL, *p = NULL, *next_nl = NULL; unsigned int ch = 0; int ln = 0, lnv = 0; if (!name) return NULL; ln = strlen(name); lnv = (value) ? strlen(value) : 0; full = dmidecode_read(dmi_type); if (full) { p = full; while(next_nl = strchr(p, '\n')) { strend(p, '\n'); if (!(sscanf(p, "Handle 0x%X", &ch) > 0) ) { while(*p == '\t') p++; if (strncmp(p, name, ln) == 0) { if (*(p + ln) == ':') { p = p + ln + 1; while(*p == ' ') p++; if (!value || strncmp(p, value, lnv) == 0) hl = dmi_handle_list_add(hl, ch); } } } p = next_nl + 1; } free(full); } return hl; }
char *dmidecode_match(const char *name, const unsigned long *dmi_type, const unsigned long *handle) { gchar *ret = NULL, *full = NULL, *p = NULL, *next_nl = NULL; unsigned int ch = 0; int ln = 0; if (!name) return NULL; ln = strlen(name); full = dmidecode_read(dmi_type); if (full) { p = full; while(next_nl = strchr(p, '\n')) { strend(p, '\n'); if (!(sscanf(p, "Handle 0x%X", &ch) > 0) ) { if (!handle || *handle == ch) { while(*p == '\t') p++; if (strncmp(p, name, ln) == 0) { if (*(p + ln) == ':') { p = p + ln + 1; while(*p == ' ') p++; ret = strdup(p); break; } } } } p = next_nl + 1; } free(full); } return ret; }
dmi_handle_list *dmidecode_handles(const unsigned long *dmi_type) { gchar *full = NULL, *p = NULL, *next_nl = NULL; dmi_handle_list *hl = NULL; unsigned int ch = 0; full = dmidecode_read(dmi_type); if (full) { p = full; while(next_nl = strchr(p, '\n')) { strend(p, '\n'); if (sscanf(p, "Handle 0x%X", &ch) > 0) { hl = dmi_handle_list_add(hl, ch); } p = next_nl + 1; } free(full); } return hl; }
static void baseboard_serial_read(char *buf, int len) { dmidecode_read("baseboard-serial-number", buf, len); }
static void chassis_serial_read(char *buf, int len) { dmidecode_read("chassis-serial-number", buf, len); }
static void system_serial_read(char *buf, int len) { dmidecode_read("system-serial-number", buf, len); }