summaryrefslogtreecommitdiffstats
path: root/build_tools/bin/check_repo/alpm.c
blob: 0b7cd2c078343ab15b860f0fe759b9a93bc08f1f (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
#include <Python.h>
#include <alpm.h>

static PyObject *
alpm_vercmp(PyObject *self, PyObject *args)
{
	const char *v1, *v2;
	int ret;

	if (!PyArg_ParseTuple(args, "ss", &v1, &v2))
		return NULL;
	ret = alpm_pkg_vercmp(v1, v2);
	return Py_BuildValue("i", ret);
}

static PyMethodDef AlpmMethods[] = {
	{"vercmp",  alpm_vercmp, METH_VARARGS,
		"Execute vercmp."},
	{NULL, NULL, 0, NULL}        /* Sentinel */
};

PyMODINIT_FUNC
initalpm(void)
{
	(void) Py_InitModule("alpm", AlpmMethods);
}

int
main(int argc, char *argv[])
{
	/* Pass argv[0] to the Python interpreter */
	Py_SetProgramName(argv[0]);

	/* Initialize the Python interpreter.  Required. */
	Py_Initialize();

	/* Add a static module */
	initalpm();
	return 0;
}