summaryrefslogtreecommitdiffstats
path: root/src/xmlpythonizer.c
diff options
context:
space:
mode:
authorNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
committerNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
commitaf27ba4dd2ffdef8e4ee3abf187475c1b3303f71 (patch)
treee81421584332fb363e7b5ba22fecd585b083226e /src/xmlpythonizer.c
parent6b1598c8b98699b115525155b43d19365e79dd08 (diff)
downloadpython-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.gz
python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.xz
python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.zip
Completed preliminary reimplementation of type()
Updated test unit to match. Throw an exception instead of returning None/False in some functions.
Diffstat (limited to 'src/xmlpythonizer.c')
-rw-r--r--src/xmlpythonizer.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/xmlpythonizer.c b/src/xmlpythonizer.c
index ea78b94..836e4da 100644
--- a/src/xmlpythonizer.c
+++ b/src/xmlpythonizer.c
@@ -339,22 +339,29 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) {
return NULL;
}
- if(!is_int(mapname)) {
- // Find the <Mapping> section matching our request (mapname)
- for( node = node->children->next; node != NULL; node = node->next ) {
- if( xmlStrcmp(node->name, (xmlChar *) "Mapping") == 0) {
- char *name = dmixml_GetAttrValue(node, "name");
- if( (name != NULL) && (strcmp(name, mapname) == 0) ) {
- break;
- }
+ int type_id = is_int(mapname);
+ if(type_id > -1) {
+ //FIXME
+ char *python_xml_typemap = strdup(PYTHON_XML_TYPEMAP);
+ xmlDoc *typemappingxml = xmlReadFile(python_xml_typemap, NULL, 0);
+ xmlNode *node = xmlDocGetRootElement(typemappingxml);
+ xmlNode *wally;
+ char type_id_hex[5];
+ snprintf(type_id_hex, 5, "0x%02x", type_id);
+ wally = dmixml_FindNodeByAttr(node, "id", type_id_hex);
+ if(wally) {
+ mapname = dmixml_GetAttrValue(wally, "value");
+ }
+ }
+
+ // Find the <Mapping> section matching our request (mapname)
+ for( node = node->children->next; node != NULL; node = node->next ) {
+ if( xmlStrcmp(node->name, (xmlChar *) "Mapping") == 0) {
+ char *name = dmixml_GetAttrValue(node, "name");
+ if( (name != NULL) && (strcmp(name, mapname) == 0) ) {
+ break;
}
}
- } else {
- //. FIXME
- char msg[8194];
- snprintf(msg, 8193, "Not (yet) implemented%c", 0);
- PyErr_SetString(PyExc_SystemError, msg);
- return NULL;
}
if( node == NULL ) {