mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-20 19:41:47 +00:00
Add a new function to libsensors doing the opposite of
sensors_parse_chip_name(). sensors_snprintf_chip_name() converts a chip name from its internal representation to a human readable string. So far, each user program had to reimplement this function. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4676 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
493d9b27f5
commit
edb42b3c16
7 files changed
+37
-14
No files matched your search
+20
@@ -20,6 +20,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "access.h"
|
||||
#include "error.h"
|
||||
#include "data.h"
|
||||
#include "sensors.h"
|
||||
@@ -154,6 +155,25 @@ ERROR:
|
||||
return -SENSORS_ERR_CHIP_NAME;
|
||||
}
|
||||
|
||||
int sensors_snprintf_chip_name(char *str, size_t size,
|
||||
const sensors_chip_name *chip)
|
||||
{
|
||||
if (sensors_chip_name_has_wildcards(chip))
|
||||
return -SENSORS_ERR_WILDCARDS;
|
||||
|
||||
switch (chip->bus) {
|
||||
case SENSORS_CHIP_NAME_BUS_ISA:
|
||||
return snprintf(str, size, "%s-isa-%04x", chip->prefix,
|
||||
chip->addr);
|
||||
case SENSORS_CHIP_NAME_BUS_PCI:
|
||||
return snprintf(str, size, "%s-pci-%04x", chip->prefix,
|
||||
chip->addr);
|
||||
default:
|
||||
return snprintf(str, size, "%s-i2c-%d-%02x", chip->prefix,
|
||||
chip->bus, chip->addr);
|
||||
}
|
||||
}
|
||||
|
||||
int sensors_parse_i2cbus_name(const char *name, int *res)
|
||||
{
|
||||
char *endptr;
|
||||
|
||||
Reference in new issue
Block a user