summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorjoerg <joerg>2007-06-25 21:38:43 +0000
committerjoerg <joerg>2007-06-25 21:38:43 +0000
commit1ca464685a6636bdaebe59142c7feab8e8ecd802 (patch)
tree29d4b0ae42d41a919a74c0ce661390b5ddeafcfe /pkgtools
parent5185b98af064fc2d268d408e5d0690f0fe037466 (diff)
downloadpkgsrc-1ca464685a6636bdaebe59142c7feab8e8ecd802.tar.gz
Use libnbcompat and fix build issues on Solaris.
Don't depend on sin_len. Slightly factor out code for setting non-blocking IO. Bump to pbulk-0.2. Tested by dmcmahill@.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/pbulk/Makefile10
-rw-r--r--pkgtools/pbulk/files/pbulk/Makefile.inc4
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/alloc.c12
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/atomic.c14
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/event.c26
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/exec.c12
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/match.c18
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/netaddr.c10
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/pbulk.h6
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/read_child.c10
-rw-r--r--pkgtools/pbulk/files/pbulk/lib/read_file.c14
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/client.c18
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/jobs.c18
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/master.c30
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/pbuild.c14
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/pbuild.h4
-rw-r--r--pkgtools/pbulk/files/pbulk/pbuild/stat.c18
-rw-r--r--pkgtools/pbulk/files/pbulk/presolve/presolve.c20
-rw-r--r--pkgtools/pbulk/files/pbulk/pscan/client.c18
-rw-r--r--pkgtools/pbulk/files/pbulk/pscan/jobs.c14
-rw-r--r--pkgtools/pbulk/files/pbulk/pscan/master.c30
-rw-r--r--pkgtools/pbulk/files/pbulk/pscan/pscan.c19
-rw-r--r--pkgtools/pbulk/files/pbulk/pscan/pscan.h4
23 files changed, 212 insertions, 131 deletions
diff --git a/pkgtools/pbulk/Makefile b/pkgtools/pbulk/Makefile
index 6e9e165112e..d733888af97 100644
--- a/pkgtools/pbulk/Makefile
+++ b/pkgtools/pbulk/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.3 2007/06/20 13:31:26 joerg Exp $
+# $NetBSD: Makefile,v 1.4 2007/06/25 21:38:43 joerg Exp $
-DISTNAME= pbulk-0.1
+DISTNAME= pbulk-0.2
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
@@ -55,5 +55,11 @@ USE_BUILTIN.libevent = no
. endif
.endif
+.if ${OPSYS} == "SunOS"
+LDADD+= -lsocket -lresolv
+MAKE_ENV+= LDADD=${LDADD:Q}
+.endif
+
.include "../../devel/libevent/buildlink3.mk"
+.include "../../pkgtools/libnbcompat/inplace.mk"
.include "../../mk/bsd.pkg.mk"
diff --git a/pkgtools/pbulk/files/pbulk/Makefile.inc b/pkgtools/pbulk/files/pbulk/Makefile.inc
index bef4d404b47..11b4bb4a64b 100644
--- a/pkgtools/pbulk/files/pbulk/Makefile.inc
+++ b/pkgtools/pbulk/files/pbulk/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.1.1.1 2007/06/19 19:49:55 joerg Exp $
+# $NetBSD: Makefile.inc,v 1.2 2007/06/25 21:38:43 joerg Exp $
BINDIR?= ${PREFIX}/bin
@@ -16,3 +16,5 @@ CPPFLAGS+=
LDADD+= -levent
.endif
.endif
+
+LDADD+= -lnbcompat
diff --git a/pkgtools/pbulk/files/pbulk/lib/alloc.c b/pkgtools/pbulk/files/pbulk/lib/alloc.c
index 348bd3dc3f8..508bfc91933 100644
--- a/pkgtools/pbulk/files/pbulk/lib/alloc.c
+++ b/pkgtools/pbulk/files/pbulk/lib/alloc.c
@@ -1,4 +1,4 @@
-/* $NetBSD: alloc.c,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: alloc.c,v 1.2 2007/06/25 21:38:43 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,11 +31,13 @@
* SUCH DAMAGE.
*/
-#include <err.h>
+#include <nbcompat.h>
+
+#include <nbcompat/err.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/lib/atomic.c b/pkgtools/pbulk/files/pbulk/lib/atomic.c
index d94267e5966..df2d720fd76 100644
--- a/pkgtools/pbulk/files/pbulk/lib/atomic.c
+++ b/pkgtools/pbulk/files/pbulk/lib/atomic.c
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic.c,v 1.1.1.1 2007/06/19 19:49:59 joerg Exp $ */
+/* $NetBSD: atomic.c,v 1.2 2007/06/25 21:38:43 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,12 +31,14 @@
* SUCH DAMAGE.
*/
-#include <sys/stat.h>
-#include <err.h>
+#include <nbcompat.h>
+
+#include <nbcompat/stat.h>
+#include <nbcompat/err.h>
#include <fcntl.h>
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/lib/event.c b/pkgtools/pbulk/files/pbulk/lib/event.c
index af7e30a9ea0..23d15b27507 100644
--- a/pkgtools/pbulk/files/pbulk/lib/event.c
+++ b/pkgtools/pbulk/files/pbulk/lib/event.c
@@ -1,4 +1,4 @@
-/* $NetBSD: event.c,v 1.2 2007/06/19 20:42:49 joerg Exp $ */
+/* $NetBSD: event.c,v 1.3 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,12 +31,17 @@
* SUCH DAMAGE.
*/
-#include <sys/types.h>
+#include <nbcompat.h>
+
+#include <nbcompat/types.h>
#include <sys/ioctl.h>
-#include <sys/time.h>
+#ifdef __sun
+#include <sys/filio.h>
+#endif
+#include <nbcompat/time.h>
#include <event.h>
-#include <stdlib.h>
-#include <unistd.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
@@ -145,3 +150,14 @@ deferred_write(int fd, const void *buf, size_t buf_len, void *arg,
deferred_write_handler, data);
event_add(&data->ev, NULL);
}
+
+int
+set_nonblocking(int fd)
+{
+ int ioctl_arg;
+
+ ioctl_arg = 1;
+ if (ioctl(fd, FIONBIO, &ioctl_arg) == -1)
+ return -1;
+ return 0;
+}
diff --git a/pkgtools/pbulk/files/pbulk/lib/exec.c b/pkgtools/pbulk/files/pbulk/lib/exec.c
index 2ad8e5b6edc..034e39d10b4 100644
--- a/pkgtools/pbulk/files/pbulk/lib/exec.c
+++ b/pkgtools/pbulk/files/pbulk/lib/exec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: exec.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,10 +31,14 @@
* SUCH DAMAGE.
*/
-#include <err.h>
+#include <nbcompat.h>
+
+#include <nbcompat/err.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <string.h>
-#include <unistd.h>
+#endif
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/lib/match.c b/pkgtools/pbulk/files/pbulk/lib/match.c
index 3e245ccafde..fdd8af26a77 100644
--- a/pkgtools/pbulk/files/pbulk/lib/match.c
+++ b/pkgtools/pbulk/files/pbulk/lib/match.c
@@ -1,4 +1,4 @@
-/* $NetBSD: match.c,v 1.1.1.1 2007/06/19 19:49:59 joerg Exp $ */
+/* $NetBSD: match.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*
* Copyright © 2002 Alistair G. Crooks. All rights reserved.
@@ -28,13 +28,15 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <ctype.h>
-#include <err.h>
-#include <fnmatch.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+#include <nbcompat.h>
+
+#include <nbcompat/ctype.h>
+#include <nbcompat/err.h>
+#include <nbcompat/fnmatch.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/lib/netaddr.c b/pkgtools/pbulk/files/pbulk/lib/netaddr.c
index 9c5e06fcf0b..dd1b021edba 100644
--- a/pkgtools/pbulk/files/pbulk/lib/netaddr.c
+++ b/pkgtools/pbulk/files/pbulk/lib/netaddr.c
@@ -1,4 +1,4 @@
-/* $NetBSD: netaddr.c,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: netaddr.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,12 +31,14 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
-#include <stdlib.h>
-#include <string.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
@@ -68,7 +70,9 @@ parse_sockaddr_in(const char *str, struct sockaddr_in *addr)
return -1;
addr->sin_port = htons((in_port_t)tmp);
addr->sin_addr = in;
+#if !defined(__sun)
addr->sin_len = sizeof(*addr);
+#endif
addr->sin_family = AF_INET;
return 0;
}
diff --git a/pkgtools/pbulk/files/pbulk/lib/pbulk.h b/pkgtools/pbulk/files/pbulk/lib/pbulk.h
index de3cbac1ef0..842281f9748 100644
--- a/pkgtools/pbulk/files/pbulk/lib/pbulk.h
+++ b/pkgtools/pbulk/files/pbulk/lib/pbulk.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pbulk.h,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: pbulk.h,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -32,7 +32,7 @@
*/
#include <netinet/in.h>
-#include <unistd.h>
+#include <nbcompat/unistd.h>
#if defined(__GNUC__) && __GNUC__ >= 2
char *xasprintf(const char *, ...)
@@ -41,6 +41,8 @@ char *xasprintf(const char *, ...)
char *xasprintf(const char *, ...);
#endif
+int set_nonblocking(int);
+
void deferred_read(int fd, void *, size_t, void *,
void (*)(void *), void (*)(void *));
void deferred_write(int fd, const void *, size_t,
diff --git a/pkgtools/pbulk/files/pbulk/lib/read_child.c b/pkgtools/pbulk/files/pbulk/lib/read_child.c
index 6c0e0ad4262..d2cf4f1a13e 100644
--- a/pkgtools/pbulk/files/pbulk/lib/read_child.c
+++ b/pkgtools/pbulk/files/pbulk/lib/read_child.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read_child.c,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: read_child.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,11 +31,13 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/wait.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/lib/read_file.c b/pkgtools/pbulk/files/pbulk/lib/read_file.c
index 3277f88a5a4..473271c8225 100644
--- a/pkgtools/pbulk/files/pbulk/lib/read_file.c
+++ b/pkgtools/pbulk/files/pbulk/lib/read_file.c
@@ -1,4 +1,4 @@
-/* $NetBSD: read_file.c,v 1.1.1.1 2007/06/19 19:49:58 joerg Exp $ */
+/* $NetBSD: read_file.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,12 +31,14 @@
* SUCH DAMAGE.
*/
-#include <sys/stat.h>
-#include <err.h>
+#include <nbcompat.h>
+
+#include <nbcompat/stat.h>
+#include <nbcompat/err.h>
#include <fcntl.h>
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/client.c b/pkgtools/pbulk/files/pbulk/pbuild/client.c
index 7faf5bf2bb6..e85cbcc1809 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/client.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/client.c
@@ -1,4 +1,4 @@
-/* $NetBSD: client.c,v 1.1.1.1 2007/06/19 19:49:56 joerg Exp $ */
+/* $NetBSD: client.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,14 +31,18 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/socket.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <errno.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include <arpa/inet.h>
@@ -60,7 +64,7 @@ client_mode(const char *client_port)
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1)
err(1, "Could not create socket");
- if (connect(fd, (struct sockaddr *)&dst, dst.sin_len) == -1)
+ if (connect(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1)
err(1, "Could not connect socket");
loop:
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/jobs.c b/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
index ee562f61fd2..e15f50dc789 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/jobs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.1.1.1 2007/06/19 19:49:56 joerg Exp $ */
+/* $NetBSD: jobs.c,v 1.2 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,16 +31,18 @@
* SUCH DAMAGE.
*/
-#include <sys/stat.h>
-#include <err.h>
+#include <nbcompat.h>
+
+#include <nbcompat/stat.h>
+#include <nbcompat/err.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/time.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
#include "pbuild.h"
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/master.c b/pkgtools/pbulk/files/pbulk/pbuild/master.c
index aaf43c82bbd..3871efc4215 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/master.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/master.c
@@ -1,4 +1,4 @@
-/* $NetBSD: master.c,v 1.2 2007/06/19 21:06:05 joerg Exp $ */
+/* $NetBSD: master.c,v 1.3 2007/06/25 21:38:44 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,18 +31,23 @@
* SUCH DAMAGE.
*/
-#include <sys/types.h>
+#include <nbcompat.h>
+
+#include <nbcompat/types.h>
#include <sys/ioctl.h>
-#include <sys/queue.h>
+#ifdef __sun
+#include <sys/filio.h>
+#endif
+#include <nbcompat/queue.h>
#include <sys/socket.h>
-#include <sys/time.h>
+#include <nbcompat/time.h>
#include <sys/wait.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <event.h>
#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
#include "pbuild.h"
@@ -221,15 +226,14 @@ listen_handler(int sock, short event, void *arg)
struct build_peer *peer;
struct sockaddr_in src;
socklen_t src_len;
- int fd, ioctl_arg;
+ int fd;
src_len = sizeof(src);
if ((fd = accept(sock, (struct sockaddr *)&src, &src_len)) == -1) {
warn("Could not accept connection");
return;
}
- ioctl_arg = 1;
- if (ioctl(fd, FIONBIO, &ioctl_arg) == -1) {
+ if (set_nonblocking(fd) == -1) {
(void)close(fd);
warn("Could not set non-blocking IO");
return;
@@ -260,9 +264,11 @@ master_mode(const char *master_port, const char *start_script)
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1)
err(1, "Could not create socket");
+#ifdef FIOCLEX
if (ioctl(fd, FIOCLEX, NULL) == -1)
err(1, "Could not set close-on-exec flag");
- if (bind(fd, (struct sockaddr *)&dst, dst.sin_len) == -1)
+#endif
+ if (bind(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1)
err(1, "Could not bind socket");
if (listen(fd, 5) == -1)
err(1, "Could not listen on socket");
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c
index 6d0368a1094..4b8674a5514 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pbuild.c,v 1.1.1.1 2007/06/19 19:49:56 joerg Exp $ */
+/* $NetBSD: pbuild.c,v 1.2 2007/06/25 21:38:45 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,14 +31,16 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/wait.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <errno.h>
#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/time.h>
#include "pbulk.h"
#include "pbuild.h"
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
index 383c2082d05..c5cb5d49a67 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
+++ b/pkgtools/pbulk/files/pbulk/pbuild/pbuild.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pbuild.h,v 1.1.1.1 2007/06/19 19:49:56 joerg Exp $ */
+/* $NetBSD: pbuild.h,v 1.2 2007/06/25 21:38:45 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*/
-#include <sys/queue.h>
+#include <nbcompat/queue.h>
#include <inttypes.h>
enum job_state {
diff --git a/pkgtools/pbulk/files/pbulk/pbuild/stat.c b/pkgtools/pbulk/files/pbulk/pbuild/stat.c
index fe542e3ecb8..7e6d19a0b79 100644
--- a/pkgtools/pbulk/files/pbulk/pbuild/stat.c
+++ b/pkgtools/pbulk/files/pbulk/pbuild/stat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: stat.c,v 1.1.1.1 2007/06/19 19:49:56 joerg Exp $ */
+/* $NetBSD: stat.c,v 1.2 2007/06/25 21:38:45 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,14 +31,18 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/socket.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <errno.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
+#endif
+#include <nbcompat/stdlib.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include <arpa/inet.h>
@@ -61,7 +65,7 @@ stat_mode(const char *client_port)
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1)
err(1, "Could not create socket");
- if (connect(fd, (struct sockaddr *)&dst, dst.sin_len) == -1)
+ if (connect(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1)
err(1, "Could not connect socket");
sent_bytes = write(fd, "S", 1);
diff --git a/pkgtools/pbulk/files/pbulk/presolve/presolve.c b/pkgtools/pbulk/files/pbulk/presolve/presolve.c
index 844af2a3344..3fc7ac97da7 100644
--- a/pkgtools/pbulk/files/pbulk/presolve/presolve.c
+++ b/pkgtools/pbulk/files/pbulk/presolve/presolve.c
@@ -1,4 +1,4 @@
-/* $NetBSD: presolve.c,v 1.1.1.1 2007/06/19 19:49:57 joerg Exp $ */
+/* $NetBSD: presolve.c,v 1.2 2007/06/25 21:38:45 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,16 +31,18 @@
* SUCH DAMAGE.
*/
-#include <sys/queue.h>
+#include <nbcompat.h>
+
+#include <nbcompat/queue.h>
#include <sys/stat.h>
-#include <ctype.h>
-#include <err.h>
+#include <nbcompat/ctype.h>
+#include <nbcompat/err.h>
#include <fcntl.h>
-#include <limits.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/limits.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
diff --git a/pkgtools/pbulk/files/pbulk/pscan/client.c b/pkgtools/pbulk/files/pbulk/pscan/client.c
index c2dcad38cff..49ae4569e4e 100644
--- a/pkgtools/pbulk/files/pbulk/pscan/client.c
+++ b/pkgtools/pbulk/files/pbulk/pscan/client.c
@@ -1,4 +1,4 @@
-/* $NetBSD: client.c,v 1.1.1.1 2007/06/19 19:49:57 joerg Exp $ */
+/* $NetBSD: client.c,v 1.2 2007/06/25 21:38:45 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,13 +31,17 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/socket.h>
-#include <err.h>
+#include <nbcompat/err.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#endif
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include <arpa/inet.h>
@@ -61,7 +65,7 @@ client_mode(const char *client_port)
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1)
err(1, "Could not create socket");
- if (connect(fd, (struct sockaddr *)&dst, dst.sin_len) == -1)
+ if (connect(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1)
err(1, "Could not connect socket");
loop:
diff --git a/pkgtools/pbulk/files/pbulk/pscan/jobs.c b/pkgtools/pbulk/files/pbulk/pscan/jobs.c
index dc2872a53a2..91bab17634b 100644
--- a/pkgtools/pbulk/files/pbulk/pscan/jobs.c
+++ b/pkgtools/pbulk/files/pbulk/pscan/jobs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.2 2007/06/20 13:04:15 joerg Exp $ */
+/* $NetBSD: jobs.c,v 1.3 2007/06/25 21:38:46 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,13 +31,15 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/uio.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
#include "pscan.h"
diff --git a/pkgtools/pbulk/files/pbulk/pscan/master.c b/pkgtools/pbulk/files/pbulk/pscan/master.c
index 89bea5ed1a4..0aebca2a58f 100644
--- a/pkgtools/pbulk/files/pbulk/pscan/master.c
+++ b/pkgtools/pbulk/files/pbulk/pscan/master.c
@@ -1,4 +1,4 @@
-/* $NetBSD: master.c,v 1.2 2007/06/19 21:06:05 joerg Exp $ */
+/* $NetBSD: master.c,v 1.3 2007/06/25 21:38:46 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,18 +31,23 @@
* SUCH DAMAGE.
*/
-#include <sys/types.h>
+#include <nbcompat.h>
+
+#include <nbcompat/types.h>
+#include <nbcompat/queue.h>
#include <sys/ioctl.h>
-#include <sys/queue.h>
+#ifdef __sun
+#include <sys/filio.h>
+#endif
#include <sys/socket.h>
-#include <sys/time.h>
+#include <nbcompat/time.h>
#include <sys/wait.h>
-#include <err.h>
+#include <nbcompat/err.h>
#include <event.h>
#include <signal.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/string.h>
#include "pbulk.h"
#include "pscan.h"
@@ -173,15 +178,14 @@ listen_handler(int sock, short event, void *arg)
struct scan_peer *peer;
struct sockaddr_in src;
socklen_t src_len;
- int fd, ioctl_arg;
+ int fd;
src_len = sizeof(src);
if ((fd = accept(sock, (struct sockaddr *)&src, &src_len)) == -1) {
warn("Could not accept connection");
return;
}
- ioctl_arg = 1;
- if (ioctl(fd, FIONBIO, &ioctl_arg) == -1) {
+ if (set_nonblocking(fd) == -1) {
(void)close(fd);
warn("Could not set non-blocking IO");
return;
@@ -210,9 +214,11 @@ master_mode(const char *master_port, const char *start_script)
fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd == -1)
err(1, "Could not create socket");
+#ifdef FIOCLEX
if (ioctl(fd, FIOCLEX, NULL) == -1)
err(1, "Could not set close-on-exec flag");
- if (bind(fd, (struct sockaddr *)&dst, dst.sin_len) == -1)
+#endif
+ if (bind(fd, (struct sockaddr *)&dst, sizeof(dst)) == -1)
err(1, "Could not bind socket");
if (listen(fd, 5) == -1)
err(1, "Could not listen on socket");
diff --git a/pkgtools/pbulk/files/pbulk/pscan/pscan.c b/pkgtools/pbulk/files/pbulk/pscan/pscan.c
index a078e2b01f8..ab52873a25b 100644
--- a/pkgtools/pbulk/files/pbulk/pscan/pscan.c
+++ b/pkgtools/pbulk/files/pbulk/pscan/pscan.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pscan.c,v 1.1.1.1 2007/06/19 19:49:57 joerg Exp $ */
+/* $NetBSD: pscan.c,v 1.2 2007/06/25 21:38:46 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,16 +31,19 @@
* SUCH DAMAGE.
*/
+#include <nbcompat.h>
+
#include <sys/uio.h>
-#include <err.h>
+#include <nbcompat/err.h>
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#include <limits.h>
+#endif
+#include <nbcompat/limits.h>
#include <signal.h>
-#include <stdio.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+#include <nbcompat/stdio.h>
+#include <nbcompat/stdlib.h>
+#include <nbcompat/string.h>
+#include <nbcompat/unistd.h>
#include "pbulk.h"
#include "pscan.h"
diff --git a/pkgtools/pbulk/files/pbulk/pscan/pscan.h b/pkgtools/pbulk/files/pbulk/pscan/pscan.h
index 988866c14f7..45fb2403c60 100644
--- a/pkgtools/pbulk/files/pbulk/pscan/pscan.h
+++ b/pkgtools/pbulk/files/pbulk/pscan/pscan.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pscan.h,v 1.1.1.1 2007/06/19 19:49:57 joerg Exp $ */
+/* $NetBSD: pscan.h,v 1.2 2007/06/25 21:38:46 joerg Exp $ */
/*-
* Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>.
@@ -31,7 +31,9 @@
* SUCH DAMAGE.
*/
+#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
+#endif
enum job_state {
JOB_OPEN,