From ea79c3b4226de0671d67bc2a178a21c116ee9e99 Mon Sep 17 00:00:00 2001 From: nima Date: Wed, 6 Aug 2008 07:19:27 +0000 Subject: Completed functions for `case 26'. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@48 abc39116-655e-4be6-ad55-d661dc543056 --- dmidecode.c | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'dmidecode.c') 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; } /******************************************************************************* -- cgit