Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Import version 20030429.1

  • Loading branch information...
commit 1aaeaaba63ee6ebbb3c1ef979e18205ef43388c9 1 parent b6c4024
@tv42 authored
View
11 debian/changelog
@@ -1,3 +1,14 @@
+eunuchs (20030429.1) unstable; urgency=low
+
+ * Change Debian section to python.
+ * Remove a cut-paste silliness that seemed to trigger gcc
+ errors. (But only on sparc. Weird.) (closes: #190431)
+ * Don't bother printing file names with find when not using
+ xargs.
+ * Add socketpair(2).
+
+ -- Tommi Virtanen <tv@debian.org> Tue, 29 Apr 2003 20:34:53 +0300
+
eunuchs (20030419.1) unstable; urgency=low
* Change Build-Depends-Indep to Build-Depends. Stupid cut-paste
View
2  debian/control
@@ -1,5 +1,5 @@
Source: eunuchs
-Section: devel
+Section: python
Priority: optional
Maintainer: Tommi Virtanen <tv@debian.org>
Standards-Version: 3.5.6
View
2  debian/rules
@@ -65,7 +65,7 @@ install-python-%:
'$(call docdir,python$*-eunuchs)/changelog'
gzip -9f \
'$(call docdir,python$*-eunuchs)/changelog'
- find examples -name SCCS -prune -o -type f -print0 -exec \
+ find examples -name SCCS -prune -o -type f -exec \
install -D -m0644 '{}' '$(call docdir,python$*-eunuchs)/{}' \;
binary-arch-python-%: install-python-%
View
67 examples/test-socketpair.py
@@ -0,0 +1,67 @@
+#!/usr/bin/python
+import socket, os, errno
+
+from eunuchs.socketpair import socketpair
+
+# set things up so the fds we get are deterministic
+for fd in xrange(3,100):
+ try:
+ os.close(fd)
+ except OSError, e:
+ if e.errno == errno.EBADF:
+ # wasn't open
+ pass
+ else:
+ raise
+
+a,b = socketpair()
+assert a == 3
+assert b == 4
+
+a,b = socketpair()
+assert a == 5
+assert b == 6
+
+a,b = socketpair(socket.AF_UNIX)
+assert a == 7
+assert b == 8
+
+a,b = socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
+assert a == 9
+assert b == 10
+
+a,b = socketpair(socket.AF_UNIX, socket.SOCK_STREAM, 0)
+assert a == 11
+assert b == 12
+
+a,b = socketpair(family=socket.AF_UNIX)
+assert a == 13
+assert b == 14
+
+a,b = socketpair(family=socket.AF_UNIX, type=socket.SOCK_STREAM)
+assert a == 15
+assert b == 16
+
+a,b = socketpair(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
+assert a == 17
+assert b == 18
+
+a,b = socketpair(type=socket.SOCK_STREAM, proto=0, family=socket.AF_UNIX)
+assert a == 19
+assert b == 20
+
+a,b = socketpair(type=socket.SOCK_STREAM, proto=0)
+assert a == 21
+assert b == 22
+
+a,b = socketpair(family=socket.AF_UNIX, proto=0)
+assert a == 23
+assert b == 24
+
+a,b = socketpair(family=socket.AF_UNIX, type=socket.SOCK_STREAM)
+assert a == 25
+assert b == 26
+
+a,b = socketpair(proto=0)
+assert a == 27
+assert b == 28
View
1  lib/eunuchs/sendmsg.c
@@ -122,7 +122,6 @@ static PyObject *my_sendmsg(PyObject *self, PyObject *args, PyObject *keywds) {
msg.msg_controllen = real_controllen;
}
- inet_ntoa(sa.sin_addr), ntohs(sa.sin_port),
ret = sendmsg(fd, &msg, flags);
if (ret<0) {
PyErr_SetFromErrno(PyExc_OSError);
View
43 lib/eunuchs/socketpair.c
@@ -0,0 +1,43 @@
+#include <Python.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+/* int socketpair(int domain, int type, int protocol, int sv[2]); */
+static PyObject *my_socketpair(PyObject *self, PyObject *args, PyObject *keywds) {
+ int family = AF_UNIX;
+ int type = SOCK_STREAM;
+ int proto = 0;
+ int sv[2];
+ int ret;
+
+ static char *kwlist[] = {"family",
+ "type",
+ "proto",
+ NULL};
+
+ if (!PyArg_ParseTupleAndKeywords(args, keywds, "|iii", kwlist,
+ &family,
+ &type,
+ &proto))
+ return NULL;
+ ret = socketpair(family, type, proto, sv);
+ if (ret<0) {
+ PyErr_SetFromErrno(PyExc_OSError);
+ return NULL;
+ }
+
+ return Py_BuildValue("ii", sv[0], sv[1]);
+}
+
+static PyMethodDef my_methods[] = {
+ {
+ "socketpair", (PyCFunction)my_socketpair, METH_VARARGS|METH_KEYWORDS,
+ "socketpair([family[, type[, proto]]]) -> (fd, fd)"
+ },
+
+ {NULL, NULL, 0, NULL}
+};
+
+void initsocketpair(void) {
+ Py_InitModule("socketpair", my_methods);
+}
View
5 setup.py
@@ -23,6 +23,8 @@
- recvmsg(2) and sendmsg(2), including use of cmsg(3)
+- socketpair(2)
+
""".strip(),
author="Tommi Virtanen",
author_email="tv@debian.org",
@@ -36,5 +38,6 @@
ext_package="eunuchs",
ext_modules=[Extension(module, ["lib/eunuchs/%s.c" % module],
extra_compile_args=['-Werror'])
- for module in ('fchdir', 'recvmsg', 'sendmsg')],
+ for module in ('fchdir', 'recvmsg', 'sendmsg',
+ 'socketpair')],
)

0 comments on commit 1aaeaab

Please sign in to comment.
Something went wrong with that request. Please try again.