summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-07-24 12:02:12 +0000
committernima <nima@abc39116-655e-4be6-ad55-d661dc543056>2008-07-24 12:02:12 +0000
commitc0c4e2446ffca88aed27726fd28f99470fb85d40 (patch)
treeebfc2270976db61f66f960caae96166bb0b50bbd
parent4289505932068a0c071c7c9fb4655678394cb469 (diff)
downloadpython-dmidecode-c0c4e2446ffca88aed27726fd28f99470fb85d40.tar.gz
python-dmidecode-c0c4e2446ffca88aed27726fd28f99470fb85d40.tar.xz
python-dmidecode-c0c4e2446ffca88aed27726fd28f99470fb85d40.zip
Some cleaning, crash in interactive mode on dmidecode.bios() still not fixed.
git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@13 abc39116-655e-4be6-ad55-d661dc543056
-rw-r--r--Makefile4
-rw-r--r--catsprintf.c4
-rw-r--r--dmidecode.c6
-rw-r--r--dmidecodemodule.c5
-rw-r--r--setup.py9
5 files changed, 14 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index a662ff7..8dcae4f 100644
--- a/Makefile
+++ b/Makefile
@@ -47,9 +47,9 @@ PROGRAMS != echo dmidecode ; test `uname -m 2>/dev/null` != ia64 && echo biosdec
mod:
- python setup.py clean
+ sudo python setup.py clean
python setup.py build
- python setup.py install
+ sudo python setup.py install
python -c 'import dmidecode'
all : $(PROGRAMS)
diff --git a/catsprintf.c b/catsprintf.c
index f27ce0f..2b0abb3 100644
--- a/catsprintf.c
+++ b/catsprintf.c
@@ -63,8 +63,8 @@ dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...)
dmi_minor *o = (dmi_minor *)malloc(sizeof(dmi_minor));
o->id = code;
- o->major = &dmiCodesMajor[map_maj[code>>8]];
- o->key = key;
+ o->major = (dmi_codes_major*)&dmiCodesMajor[map_maj[code>>8]];
+ o->key = (char *)key;
vsprintf(o->value, format, arg);
o->next = last;
diff --git a/dmidecode.c b/dmidecode.c
index 96210f6..54b0290 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2641,11 +2641,10 @@ void dmi_decode(struct dmi_header *h, u16 ver, PyObject* pydata) {
}
-
-
+ /********************************************************************************/
dmi_minor* last = dmiAppendObject(++minor, "JUNK", "NODATA");
- char *id = last->major->id;
+ const char *id = last->major->id;
PyObject *pymajor = PyDict_New();
PyDict_SetItem(pymajor, PyString_FromString("code"), PyInt_FromLong((long)last->major->code));
PyDict_SetItem(pymajor, PyString_FromString("id"), PyString_FromString(last->major->id));
@@ -2659,6 +2658,7 @@ void dmi_decode(struct dmi_header *h, u16 ver, PyObject* pydata) {
PyDict_SetItem(pymajor, PyString_FromString("data"), pyminor);
PyDict_SetItem(pydata, PyString_FromString(id), pymajor);
+ /********************************************************************************/
break;
diff --git a/dmidecodemodule.c b/dmidecodemodule.c
index 10ee9fc..5b6f63a 100644
--- a/dmidecodemodule.c
+++ b/dmidecodemodule.c
@@ -4,9 +4,9 @@
static PyObject* dmidecode_get(PyObject *self, char* section) {
//mtrace();
- Py_SetProgramName("dmidecode");
- /*
+ /* This is `embedding API', not applicable to this dmidecode module which is `Extending'
+ Py_SetProgramName("dmidecode");
int argc = 3;
char *argv[4];
argv[0] = "dmidecode";
@@ -35,7 +35,6 @@ static PyObject* dmidecode_get(PyObject *self, char* section) {
if(opt.type==NULL) return NULL;
PyObject* pydata = PyDict_New();
- Py_INCREF(pydata);
/* First try EFI (ia64, Intel-based Mac) */
char efiAddress[32];
diff --git a/setup.py b/setup.py
index 01080a6..5e00cf7 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
from distutils.core import setup, Extension
setup(
- name = "DMIDecode",
+ name = "dmidecode",
version = "1.0",
description = "A python module rewrite of dmidecode",
author = "Nima Talebi",
@@ -9,9 +9,10 @@ setup(
url = "http://projects.autonomy.net.au/dmidecode/",
ext_modules = [
Extension(
- "dmidecode", [ "dmidecodemodule.c", "util.c", "catsprintf.c", "dmioem.c", "biosdecode.c", "dmiopt.c", "dmidecode.c" ],
- library_dirs=[ "/home/nima/dev-room/projects/dmidecode" ],
- libraries=[ "util" ],
+ "dmidecode",
+ sources = [ "dmidecodemodule.c", "util.c", "catsprintf.c", "dmioem.c", "biosdecode.c", "dmiopt.c", "dmidecode.c" ],
+ library_dirs = [ "/home/nima/dev-room/projects/dmidecode" ],
+ libraries = [ "util" ],
)
]
)