diff options
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | src/config.h | 4 | ||||
-rw-r--r-- | src/util.c | 9 | ||||
-rw-r--r-- | src/util.h | 1 | ||||
-rw-r--r-- | src/xmlpythonizer.c | 21 |
5 files changed, 35 insertions, 6 deletions
@@ -36,6 +36,11 @@ vpath %.c $(SRC_D) vpath %.h $(SRC_D) vpath % $(OBJ_D) +ifeq (0,1) +TEMP: + sudo make install + sudo python -c 'import dmidecode; print "-"*80; print dmidecode.slot(); print "-"*80; print dmidecode.type(1)' +endif ############################################################################### build: $(PY)-dmidecode.so @@ -57,6 +62,7 @@ clean : $(PY) src/setup.py clean -$(RM) *.so lib/*.o core -rm -rf build .dpkg + cd unit-tests && $(MAKE) clean tarball: rm -rf $(PACKAGE)-$(VERSION) 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 @@ -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); +} + + @@ -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 ) { |