~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/twisted/runner/portmap.c

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2001-2004 Twisted Matrix Laboratories.
 
3
 * See LICENSE for details.
 
4
 
 
5
 * 
 
6
 */
 
7
 
 
8
/* portmap.c: A simple Python wrapper for pmap_set(3) and pmap_unset(3) */
 
9
 
 
10
#include <Python.h>
 
11
#include <rpc/rpc.h>
 
12
#include <rpc/pmap_clnt.h>
 
13
 
 
14
static PyObject * portmap_set(PyObject *self, PyObject *args)
 
15
{
 
16
        unsigned long program, version;
 
17
        int protocol;
 
18
        unsigned short port;
 
19
        
 
20
        if (!PyArg_ParseTuple(args, "llih:set", 
 
21
                              &program, &version, &protocol, &port))
 
22
                return NULL;
 
23
 
 
24
        pmap_unset(program, version);
 
25
        pmap_set(program, version, protocol, port);
 
26
        
 
27
        Py_INCREF(Py_None);
 
28
        return Py_None;
 
29
}
 
30
 
 
31
static PyObject * portmap_unset(PyObject *self, PyObject *args)
 
32
{
 
33
        unsigned long program, version;
 
34
        
 
35
        if (!PyArg_ParseTuple(args, "ll:unset",
 
36
                              &program, &version))
 
37
                return NULL;
 
38
 
 
39
        pmap_unset(program, version);
 
40
        
 
41
        Py_INCREF(Py_None);
 
42
        return Py_None;
 
43
}
 
44
 
 
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."},
 
50
        {NULL, NULL, 0, NULL}
 
51
};
 
52
 
 
53
void initportmap(void)
 
54
{
 
55
        (void) Py_InitModule("portmap", PortmapMethods);
 
56
}
 
57