summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNima Talebi <nima@autonomy.net.au>2009-05-23 23:02:46 +1000
committerNima Talebi <nima@autonomy.net.au>2009-05-23 23:02:46 +1000
commit6b1598c8b98699b115525155b43d19365e79dd08 (patch)
tree347a2f697ae3def6297d1c8c5dc25568c56a9393 /src
parent076bcc59efb4cb0cd0dd274d58f3706b2fd3aa13 (diff)
downloadpython-dmidecode-6b1598c8b98699b115525155b43d19365e79dd08.tar.gz
python-dmidecode-6b1598c8b98699b115525155b43d19365e79dd08.tar.xz
python-dmidecode-6b1598c8b98699b115525155b43d19365e79dd08.zip
Reimplementing the type() function - WIP
Diffstat (limited to 'src')
-rw-r--r--src/config.h4
-rw-r--r--src/util.c9
-rw-r--r--src/util.h1
-rw-r--r--src/xmlpythonizer.c21
4 files changed, 29 insertions, 6 deletions
diff --git a/src/config.h b/src/config.h
index a2e7e58..8eb38ad 100644
--- a/src/config.h
+++ b/src/config.h
@@ -27,4 +27,8 @@
#define PYTHON_XML_MAP "/usr/share/python-dmidecode/pythonmap.xml"
#endif
+#ifndef PYTHON_XML_TYPEMAP
+#define PYTHON_XML_TYPEMAP "/usr/share/python-dmidecode/typemap.xml"
+#endif
+
#endif
diff --git a/src/util.c b/src/util.c
index d9ac510..58fd5ec 100644
--- a/src/util.c
+++ b/src/util.c
@@ -189,3 +189,12 @@ int write_dump(size_t base, size_t len, const void *data, const char *dumpfile,
fclose(f);
return -1;
}
+
+int is_int(const char *s)
+{
+ char _s[3];
+ snprintf(_s, 3, "%ld", strtol(s, (char **)NULL, 10));
+ return !strcmp(s, _s);
+}
+
+
diff --git a/src/util.h b/src/util.h
index 3effd0c..e216566 100644
--- a/src/util.h
+++ b/src/util.h
@@ -28,3 +28,4 @@
int checksum(const u8 * buf, size_t len);
void *mem_chunk(size_t base, size_t len, const char *devmem);
int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
+int is_int(const char *s);
diff --git a/src/xmlpythonizer.c b/src/xmlpythonizer.c
index f1d755e..ea78b94 100644
--- a/src/xmlpythonizer.c
+++ b/src/xmlpythonizer.c
@@ -35,6 +35,7 @@
#include <libxml/tree.h>
#include <libxml/xpath.h>
+#include "util.h"
#include "dmixml.h"
#include "xmlpythonizer.h"
@@ -338,14 +339,22 @@ ptzMAP *dmiMAP_ParseMappingXML(xmlDoc *xmlmap, const char *mapname) {
return NULL;
}
- // 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;
+ 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;
+ }
}
}
+ } else {
+ //. FIXME
+ char msg[8194];
+ snprintf(msg, 8193, "Not (yet) implemented%c", 0);
+ PyErr_SetString(PyExc_SystemError, msg);
+ return NULL;
}
if( node == NULL ) {