2 * Copyright (c) 2001-2004 Twisted Matrix Laboratories.
3 * See LICENSE for details.
8 /* portmap.c: A simple Python wrapper for pmap_set(3) and pmap_unset(3) */
12 #include <rpc/pmap_clnt.h>
14 static PyObject * portmap_set(PyObject *self, PyObject *args)
16 unsigned long program, version;
20 if (!PyArg_ParseTuple(args, "llih:set",
21 &program, &version, &protocol, &port))
24 pmap_unset(program, version);
25 pmap_set(program, version, protocol, port);
31 static PyObject * portmap_unset(PyObject *self, PyObject *args)
33 unsigned long program, version;
35 if (!PyArg_ParseTuple(args, "ll:unset",
39 pmap_unset(program, version);
45 static PyMethodDef PortmapMethods[] = {
46 {"set", portmap_set, METH_VARARGS,
47 "Set an entry in the portmapper."},
48 {"unset", portmap_unset, METH_VARARGS,
49 "Unset an entry in the portmapper."},
53 void initportmap(void)
55 (void) Py_InitModule("portmap", PortmapMethods);