aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2008-04-21 18:30:26 +0000
committerXin LI <delphij@FreeBSD.org>2008-04-21 18:30:26 +0000
commitc7c53f7a0355239b6dd9bcb403c7e820fbc9577b (patch)
treef2a256283a3dbe01137ee7299617bd1c938d92e7
parentb2f6436d8f7147ff2b48cd694b1f70130a384c97 (diff)
downloadsrc-c7c53f7a0355239b6dd9bcb403c7e820fbc9577b.tar.gz
src-c7c53f7a0355239b6dd9bcb403c7e820fbc9577b.zip
Import netcat as of today's OPENBSD_4_3 snapshot.vendor/netcat/4.3
Notes
Notes: svn path=/vendor/netcat/dist/; revision=178382 svn path=/vendor/netcat/4.3/; revision=178384; tag=vendor/netcat/4.3
-rw-r--r--contrib/netcat/atomicio.c29
-rw-r--r--contrib/netcat/atomicio.h8
-rw-r--r--contrib/netcat/nc.14
3 files changed, 26 insertions, 15 deletions
diff --git a/contrib/netcat/atomicio.c b/contrib/netcat/atomicio.c
index c3f26846df9d..e9d98b3561e8 100644
--- a/contrib/netcat/atomicio.c
+++ b/contrib/netcat/atomicio.c
@@ -1,7 +1,7 @@
-/* $OpenBSD: atomicio.c,v 1.8 2006/02/11 19:31:18 otto Exp $ */
-
+/* $OpenBSD: atomicio.c,v 1.9 2007/09/07 14:50:44 tobias Exp $ */
/*
- * Copyright (c) 2005 Anil Madhavapeddy. All rights served.
+ * Copyright (c) 2006 Damien Miller. All rights reserved.
+ * Copyright (c) 2005 Anil Madhavapeddy. All rights reserved.
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
* All rights reserved.
*
@@ -26,32 +26,37 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/types.h>
-#include <sys/uio.h>
+#include <sys/param.h>
+
#include <errno.h>
+#include <poll.h>
#include <unistd.h>
+
#include "atomicio.h"
/*
* ensure all of data on socket comes through. f==read || f==vwrite
*/
size_t
-atomicio(f, fd, _s, n)
- ssize_t (*f) (int, void *, size_t);
- int fd;
- void *_s;
- size_t n;
+atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
{
char *s = _s;
size_t pos = 0;
ssize_t res;
+ struct pollfd pfd;
+ pfd.fd = fd;
+ pfd.events = f == read ? POLLIN : POLLOUT;
while (n > pos) {
res = (f) (fd, s + pos, n - pos);
switch (res) {
case -1:
- if (errno == EINTR || errno == EAGAIN)
+ if (errno == EINTR)
+ continue;
+ if (errno == EAGAIN) {
+ (void)poll(&pfd, 1, -1);
continue;
+ }
return 0;
case 0:
errno = EPIPE;
@@ -60,5 +65,5 @@ atomicio(f, fd, _s, n)
pos += (size_t)res;
}
}
- return pos;
+ return (pos);
}
diff --git a/contrib/netcat/atomicio.h b/contrib/netcat/atomicio.h
index 551a0565da82..7bf5b25418cf 100644
--- a/contrib/netcat/atomicio.h
+++ b/contrib/netcat/atomicio.h
@@ -1,6 +1,7 @@
-/* $OpenBSD: atomicio.h,v 1.1 2005/05/24 20:13:28 avsm Exp $ */
+/* $OpenBSD: atomicio.h,v 1.2 2007/09/07 14:50:44 tobias Exp $ */
/*
+ * Copyright (c) 2006 Damien Miller. All rights reserved.
* Copyright (c) 1995,1999 Theo de Raadt. All rights reserved.
* All rights reserved.
*
@@ -25,9 +26,14 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef _ATOMICIO_H
+#define _ATOMICIO_H
+
/*
* Ensure all of data on socket comes through. f==read || f==vwrite
*/
size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t);
#define vwrite (ssize_t (*)(int, void *, size_t))write
+
+#endif /* _ATOMICIO_H */
diff --git a/contrib/netcat/nc.1 b/contrib/netcat/nc.1
index 69fd5ed3c1d0..daa521cf554b 100644
--- a/contrib/netcat/nc.1
+++ b/contrib/netcat/nc.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: nc.1,v 1.44 2006/12/02 01:08:30 jmc Exp $
+.\" $OpenBSD: nc.1,v 1.45 2007/05/31 19:20:13 jmc Exp $
.\"
.\" Copyright (c) 1996 David Sacerdote
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 25, 2001
+.Dd $Mdocdate$
.Dt NC 1
.Os
.Sh NAME