|
Packit Service |
7203c3 |
#include "rpmsystem-py.h"
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
#include <rpm/rpmmacro.h>
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
#include "header-py.h" /* XXX for pyrpmError, doh */
|
|
Packit Service |
7203c3 |
#include "rpmmacro-py.h"
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyObject *
|
|
Packit Service |
7203c3 |
rpmmacro_AddMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
const char * name, * val;
|
|
Packit Service |
7203c3 |
char * kwlist[] = {"name", "value", NULL};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss:AddMacro", kwlist,
|
|
Packit Service |
7203c3 |
&name, &val))
|
|
Packit Service |
7203c3 |
return NULL;
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
rpmPushMacro(NULL, name, NULL, val, -1);
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
Py_RETURN_NONE;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyObject *
|
|
Packit Service |
7203c3 |
rpmmacro_DelMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
const char * name;
|
|
Packit Service |
7203c3 |
char * kwlist[] = {"name", NULL};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s:DelMacro", kwlist, &name))
|
|
Packit Service |
7203c3 |
return NULL;
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
rpmPopMacro(NULL, name);
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
Py_RETURN_NONE;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
PyObject *
|
|
Packit Service |
7203c3 |
rpmmacro_ExpandMacro(PyObject * self, PyObject * args, PyObject * kwds)
|
|
Packit Service |
7203c3 |
{
|
|
Packit Service |
7203c3 |
const char *macro;
|
|
Packit Service |
7203c3 |
PyObject *res = NULL;
|
|
Packit Service |
7203c3 |
int num = 0;
|
|
Packit Service |
7203c3 |
char * kwlist[] = {"macro", "numeric", NULL};
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i", kwlist, ¯o, &num))
|
|
Packit Service |
7203c3 |
return NULL;
|
|
Packit Service |
7203c3 |
|
|
Packit Service |
7203c3 |
if (num) {
|
|
Packit Service |
7203c3 |
res = Py_BuildValue("i", rpmExpandNumeric(macro));
|
|
Packit Service |
7203c3 |
} else {
|
|
Packit Service |
7203c3 |
char *str = NULL;
|
|
Packit Service |
7203c3 |
if (rpmExpandMacros(NULL, macro, &str, 0) < 0)
|
|
Packit Service |
7203c3 |
PyErr_SetString(pyrpmError, "error expanding macro");
|
|
Packit Service |
7203c3 |
else
|
|
Packit Service |
d188d8 |
res = utf8FromString(str);
|
|
Packit Service |
7203c3 |
free(str);
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
return res;
|
|
Packit Service |
7203c3 |
}
|
|
Packit Service |
7203c3 |
|