summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2009-04-09 11:49:50 +0200
committerDavid Sommerseth <davids@redhat.com>2009-04-29 11:22:11 +0200
commit581b015c91a3b364b1c1324bed775bfd2ce99dbd (patch)
tree73480a5c6ad37739af13ba5605d40d858c4c288e
parent612445e94781f14af65490b52c898b9eaa5f5e85 (diff)
downloadpython-dmidecode-581b015c91a3b364b1c1324bed775bfd2ce99dbd.tar.gz
python-dmidecode-581b015c91a3b364b1c1324bed775bfd2ce99dbd.tar.xz
python-dmidecode-581b015c91a3b364b1c1324bed775bfd2ce99dbd.zip
Made it compile
-rw-r--r--src/dmidecode.c13
-rw-r--r--src/dmidecodemodule.c23
2 files changed, 18 insertions, 18 deletions
diff --git a/src/dmidecode.c b/src/dmidecode.c
index 773a673..c146969 100644
--- a/src/dmidecode.c
+++ b/src/dmidecode.c
@@ -86,11 +86,6 @@
#define EFI_NOT_FOUND (-1)
#define EFI_NO_SMBIOS (-2)
-static const char *out_of_spec = "<OUT OF SPEC>";
-static const char *bad_index = "<BAD INDEX>";
-
-#define BAD_INDEX PyString_FromString("<BAD INDEX>")
-#define OUT_OF_SPEC PyString_FromString("<OUT OF SPEC>")
/*******************************************************************************
** Type-independant Stuff
@@ -112,7 +107,7 @@ const char *dmi_string(const struct dmi_header *dm, u8 s)
}
if(!*bp)
- return bad_index;
+ return NULL;
/* ASCII filtering */
len = strlen(bp);
@@ -233,7 +228,7 @@ void dmi_dump(xmlNode *node, struct dmi_header * h)
if((h->data)[h->length] || (h->data)[h->length + 1]) {
i = 1;
- while((s = dmi_string(h, i++)) != bad_index) {
+ while((s = dmi_string(h, i++)) != NULL) {
//. FIXME: DUMP
/*
* if(opt.flags & FLAG_DUMP) {
@@ -344,7 +339,7 @@ void dmi_bios_characteristics_x1(xmlNode *node, u8 code)
dmixml_AddAttribute(node, "flags", "0x%04x", code);
for(i = 0; i <= 7; i++) {
- if( code.l & (1 << i) ) {
+ if( code & (1 << i) ) {
dmixml_AddTextChild(node, "characteristic", characteristics[i]);
}
}
@@ -364,7 +359,7 @@ void dmi_bios_characteristics_x2(xmlNode *node, u8 code)
dmixml_AddAttribute(node, "flags", "0x%04x", code);
for(i = 0; i <= 2; i++) {
- if( code.l & (1 << i) ) {
+ if( code & (1 << i) ) {
dmixml_AddTextChild(node, "characteristic", characteristics[i]);
}
}
diff --git a/src/dmidecodemodule.c b/src/dmidecodemodule.c
index 1870e86..9528647 100644
--- a/src/dmidecodemodule.c
+++ b/src/dmidecodemodule.c
@@ -117,7 +117,7 @@ static int dmidecode_set_version(PyObject ** pydata)
ret = 1;
else if(smbios_decode_set_version(buf, opt.devmem, pydata))
found++;
- //. TODO: dmiSetItem(pydata, "efi_address", efiAddress);
+ //. TODO: dmixml_AddAttribute(dmixml_n, "efi_address", efiAddress);
}
}
@@ -154,7 +154,9 @@ static PyObject *dmidecode_get(PyObject * self, const char *section)
if(access(f, R_OK) < 0)
PyErr_SetString(PyExc_IOError, "Permission denied to memory file/device");
- PyObject *pydata = PyDict_New();
+ PyObject *pydata = NULL;
+ xmlNode *dmixml_n = xmlNewNode(NULL, (xmlChar *) "dmidecode");
+ assert( dmixml != NULL );
/***********************************/
/* Read from dump if so instructed */
@@ -164,10 +166,10 @@ static PyObject *dmidecode_get(PyObject * self, const char *section)
//. printf("Reading SMBIOS/DMI data from file %s.\n", dumpfile);
if((buf = mem_chunk(0, 0x20, dumpfile)) != NULL) {
if(memcmp(buf, "_SM_", 4) == 0) {
- if(smbios_decode(buf, dumpfile, pydata))
+ if(smbios_decode(buf, dumpfile, dmixml_n))
found++;
} else if(memcmp(buf, "_DMI_", 5) == 0) {
- if(legacy_decode(buf, dumpfile, pydata))
+ if(legacy_decode(buf, dumpfile, dmixml_n))
found++;
}
} else
@@ -180,12 +182,12 @@ static PyObject *dmidecode_get(PyObject * self, const char *section)
if((buf = mem_chunk(0xF0000, 0x10000, opt.devmem)) != NULL) {
for(fp = 0; fp <= 0xFFF0; fp += 16) {
if(memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0) {
- if(smbios_decode(buf + fp, opt.devmem, pydata)) {
+ if(smbios_decode(buf + fp, opt.devmem, dmixml_n)) {
found++;
fp += 16;
}
} else if(memcmp(buf + fp, "_DMI_", 5) == 0) {
- if(legacy_decode(buf + fp, opt.devmem, pydata))
+ if(legacy_decode(buf + fp, opt.devmem, dmixml_n))
found++;
}
}
@@ -196,7 +198,7 @@ static PyObject *dmidecode_get(PyObject * self, const char *section)
} else {
if((buf = mem_chunk(fp, 0x20, opt.devmem)) == NULL)
ret = 1;
- else if(smbios_decode(buf, opt.devmem, pydata))
+ else if(smbios_decode(buf, opt.devmem, dmixml_n))
found++;
//. TODO: dmiSetItem(pydata, "efi_address", efiAddress);
}
@@ -206,8 +208,11 @@ static PyObject *dmidecode_get(PyObject * self, const char *section)
if(ret == 0) {
free(buf);
} else {
- Py_DECREF(pydata);
- pydata = NULL;
+ xmlFreeNode(dmixml_n);
+ if( pydata != NULL ) {
+ PyDECREF(pydata);
+ pydata = NULL;
+ }
}
//muntrace();