aboutsummaryrefslogtreecommitdiff
blob: 03ba7941e89955e1f5401d3fc558017631c12deb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <Python.h>

static PyObject * pax_getflags(PyObject *, PyObject *);

static PyMethodDef PaxMethods[] = {
	{"getflags",  pax_getflags, METH_VARARGS, "Get the pax flags."},
	{NULL, NULL, 0, NULL}
};

static PyObject *PaxError;

PyMODINIT_FUNC
initpax(void)
{
	PyObject *m;

	m = Py_InitModule("pax", PaxMethods);
	if (m == NULL)
		return;

	PaxError = PyErr_NewException("pax.error", NULL, NULL);
	Py_INCREF(PaxError);
	PyModule_AddObject(m, "error", PaxError);
}


static PyObject *
pax_getflags(PyObject *self, PyObject *args)
{
	const char *value;
	int sts;

	if (!PyArg_ParseTuple(args, "s", &value))
		return NULL;

	printf("%s\n", value);

	sts = 1;

	if (sts < 0)
	{
		PyErr_SetString(PaxError, "pax_getflags failed");
		return NULL;
	}

	return Py_BuildValue("i", sts);
}