From 3c78c1ef20182ab39bde47677ee615bbbd208837 Mon Sep 17 00:00:00 2001 From: nima Date: Wed, 29 Oct 2008 07:04:03 +0000 Subject: Cleanup. git-svn-id: svn://svn.autonomy.net.au/python-dmidecode@76 abc39116-655e-4be6-ad55-d661dc543056 --- dmihelper.c | 37 ++++++++++++++++++++----------------- dmihelper.h | 3 +-- global.h | 7 ------- 3 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 global.h diff --git a/dmihelper.c b/dmihelper.c index bee466f..17f85f9 100644 --- a/dmihelper.c +++ b/dmihelper.c @@ -1,7 +1,7 @@ #include #include -#include "catsprintf.h" +#include "dmihelper.h" dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...) { static dmi_minor* last = NULL; @@ -32,6 +32,20 @@ dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...) return o; } +int dmiSetItem(PyObject* dict, const char *key, const char *format, ...) { + va_list arg; + va_start(arg, format); + char buffer[2048]; + vsprintf(buffer, format, arg); + va_end(arg); + //printf("DEBUG: Setting k:%s, f:%s s:%s...", key, format, buffer); + PyDict_SetItem(dict, PyString_FromString(key), PyString_FromString(buffer)); + //printf("Done.\n"); + return 0; +} + + +/* NOTE: Decomissioned helper function... void dmiAppendData(PyObject *pydata, const int count) { dmi_minor* last = dmiAppendObject(count, "JUNK", "NODATA"); @@ -77,34 +91,23 @@ void dmiAppendData(PyObject *pydata, const int count) { Py_DECREF(_key); Py_DECREF(pymajor); } +*/ -int dmiSetItem(PyObject* dict, const char *key, const char *format, ...) { - va_list arg; - va_start(arg, format); - char buffer[2048]; - vsprintf(buffer, format, arg); - va_end(arg); - //printf("DEBUG: Setting k:%s, f:%s s:%s...", key, format, buffer); - PyDict_SetItem(dict, PyString_FromString(key), PyString_FromString(buffer)); - //printf("Done.\n"); - return 0; -} - -/* +/* NOTE: Decomissioned helper function... int catsprintf(char *buf, const char *format, ...) { if(format == NULL) { bzero(buf, strlen(buf)); return 0; } - va_list arg; /* will point to each unnamed argument in turn * / - va_start(arg, format); /* point to first element after fmt * / + va_list arg; // will point to each unnamed argument in turn + va_start(arg, format); // point to first element after fmt char b[8192]; int c = vsprintf (b, format, arg); strcat(buf, b); - va_end(arg); /* cleanup * / + va_end(arg); // cleanp return c; } diff --git a/dmihelper.h b/dmihelper.h index fbe9958..c4dcd53 100644 --- a/dmihelper.h +++ b/dmihelper.h @@ -78,9 +78,8 @@ typedef struct _dmi_minor { struct _dmi_minor* next; } dmi_minor; -//int catsprintf(char *buf, const char *format, ...); void dmiAppendData(PyObject *pydata, const int count); -dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...); int dmiSetItem(PyObject* dict, const char *key, const char *format, ...); +dmi_minor* dmiAppendObject(long code, char const *key, const char *format, ...); #endif diff --git a/global.h b/global.h deleted file mode 100644 index a1a911a..0000000 --- a/global.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef GLOB -#define GLOB 1 - -struct opt opt; -char buffer[50000]; - -#endif -- cgit