1 --- rpm-5.4.5/python/spec-py.c.py_macros~ 2012-03-01 22:55:19.592995392 +0100
2 +++ rpm-5.4.5/python/spec-py.c 2012-03-01 22:56:02.081016570 +0100
5 #include <rpmiotypes.h>
7 +#define _MACRO_INTERNAL
12 @@ -146,6 +148,50 @@ spec_get_sources(specObject *s)
17 +spec_get_macros(specObject *s)
21 + PyObject *macroDict;
24 + macroDict = PyDict_New();
28 + spec = specFromSpec(s);
29 + if ( spec != NULL) {
31 + if (mc->macroTable != NULL) {
33 + for (i = 0; i < mc->firstFree; i++) {
36 + if ((me = mc->macroTable[i]) == NULL) {
37 + /* XXX this should never happen */
40 + macro = PyDict_New();
42 + PyMapping_SetItemString(macro, "used", PyInt_FromLong(me->used));
43 + PyMapping_SetItemString(macro, "level", PyInt_FromLong(me->level));
44 + if (me->opts && *me->opts)
45 + PyMapping_SetItemString(macro, "opts", PyString_FromString(me->opts));
46 + if (me->body && *me->body)
47 + PyMapping_SetItemString(macro, "body", PyString_FromString(me->body));
48 + PyMapping_SetItemString(macroDict, strdup(me->name), macro);
62 /*@unchecked@*/ /*@observer@*/
63 @@ -161,6 +207,7 @@ static PyMethodDef spec_Spec_methods[] =
64 {"check", (PyCFunction) spec_get_check, METH_VARARGS, NULL },
65 {"clean", (PyCFunction) spec_get_clean, METH_VARARGS, NULL },
66 {"buildRoot", (PyCFunction) spec_get_buildroot, METH_VARARGS, NULL },
67 + {"macros", (PyCFunction) spec_get_macros, METH_VARARGS, NULL },