summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-08-06 07:19:27 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-08-06 07:19:27 +0000
commitea79c3b4226de0671d67bc2a178a21c116ee9e99 (patch)
tree616a5953b8daf163199d3ebe398ab7ba60ecce94
parent4bf9a5a95007e5d75bdc47381150d590934c24cc (diff)
downloadpython-dmidecode-ea79c3b4226de0671d67bc2a178a21c116ee9e99.tar.gz
python-dmidecode-ea79c3b4226de0671d67bc2a178a21c116ee9e99.tar.xz
python-dmidecode-ea79c3b4226de0671d67bc2a178a21c116ee9e99.zip
Completed functions for `case 26'.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@48 abc39116-655e-4be6-ad55-d661dc543056
-rw-r--r--dmidecode.c47
1 files changed, 26 insertions, 21 deletions
diff --git a/dmidecode.c b/dmidecode.c
index d37f832..74c2c27 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2384,7 +2384,7 @@ static PyObject *dmi_hardware_security_status(u8 code) {
** 3.3.26 System Power Controls (Type 25)
*/
-static PyObject *dmi_power_controls_power_on(u8 *p, char *_) {
+static PyObject *dmi_power_controls_power_on(u8 *p) {
/* 3.3.26.1 */
PyObject *data = PyList_New(5);
@@ -2401,7 +2401,7 @@ static PyObject *dmi_power_controls_power_on(u8 *p, char *_) {
* 3.3.27 Voltage Probe (Type 26)
*/
-static const char *dmi_voltage_probe_location(u8 code) {
+static PyObject *dmi_voltage_probe_location(u8 code) {
/* 3.3.27.1 */
static const char *location[]={
"Other", /* 0x01 */
@@ -2416,13 +2416,14 @@ static const char *dmi_voltage_probe_location(u8 code) {
"Power Unit",
"Add-in Card" /* 0x0B */
};
+ PyObject *data;
- if(code>=0x01 && code<=0x0B)
- return location[code-0x01];
- return out_of_spec;
+ if(code>=0x01 && code<=0x0B) data = PyString_FromString(location[code-0x01]);
+ else data = PyString_FromString(out_of_spec);
+ return data;
}
-static const char *dmi_probe_status(u8 code) {
+static PyObject *dmi_probe_status(u8 code) {
/* 3.3.27.1 */
static const char *status[]={
"Other", /* 0x01 */
@@ -2432,28 +2433,32 @@ static const char *dmi_probe_status(u8 code) {
"Critical",
"Non-recoverable" /* 0x06 */
};
+ PyObject *data;
- if(code>=0x01 && code<=0x06)
- return status[code-0x01];
- return out_of_spec;
+ if(code>=0x01 && code<=0x06) data = PyString_FromString(status[code-0x01]);
+ else data = PyString_FromString(out_of_spec);
+ return data;
}
-static const char *dmi_voltage_probe_value(u16 code, char *_) {
- if(code==0x8000) sprintf(_, "Unknown");
- else sprintf(_, "%.3f V", (float)(i16)code/1000);
- return _;
+static PyObject *dmi_voltage_probe_value(u16 code) {
+ PyObject *data;
+ if(code==0x8000) data = PyString_FromString("Unknown");
+ else data = PyString_FromFormat("%.3f V", (float)(i16)code/1000);
+ return data;
}
-static const char *dmi_voltage_probe_resolution(u16 code, char *_) {
- if(code==0x8000) sprintf(_, "Unknown");
- else sprintf(_, "%.1f mV", (float)code/10);
- return _;
+static PyObject *dmi_voltage_probe_resolution(u16 code) {
+ PyObject *data;
+ if(code==0x8000) data = PyString_FromString("Unknown");
+ else data = PyString_FromFormat("%.1f mV", (float)code/10);
+ return data;
}
-static const char *dmi_probe_accuracy(u16 code, char *_) {
- if(code==0x8000) sprintf(_, "Unknown");
- else sprintf(_, "%.2f%%", (float)code/100);
- return _;
+static PyObject *dmi_probe_accuracy(u16 code) {
+ PyObject *data;
+ if(code==0x8000) data = PyString_FromString("Unknown");
+ else data = PyString_FromString("%.2f%%", (float)code/100);
+ return data;
}
/*******************************************************************************