diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-09 17:16:40 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-12-09 17:16:40 +0000 |
commit | e557bab0dcaf35f003fa755b74e4c80000e05e42 (patch) | |
tree | 3bc4d8aeb04117b324f1b9b182c923e259a657c7 /src | |
parent | 86312d159d55e99db5a5c82d9c50f31a1fe28199 (diff) | |
download | skalibs-e557bab0dcaf35f003fa755b74e4c80000e05e42.tar.xz |
Get rid of webipc.h and DJBUNIX_FLAG_*
Decent semantic header separation is hard. It's always
an ongoing process. Here socket.h always included webipc.h
for listen(), and webipc.h always included djbunix.h for
socket_internal() and socketpair_internal(). That's ugh.
Just move all the socket stuff into one socket header.
Of course, djbunix.h is still needed most of the time for
fd_close() and other operations on fds, but those are
generic anyway.
Also, O_CLOEXEC exists everywhere now, so we can use it as well
as O_NONBLOCK instead of redefining the flags in djbunix.h.
Diffstat (limited to 'src')
29 files changed, 139 insertions, 141 deletions
diff --git a/src/include/skalibs/djbunix.h b/src/include/skalibs/djbunix.h index 1f356e1..d0775fe 100644 --- a/src/include/skalibs/djbunix.h +++ b/src/include/skalibs/djbunix.h @@ -6,21 +6,19 @@ #include <sys/types.h> #include <sys/uio.h> #include <sys/wait.h> +#include <fcntl.h> #include <skalibs/gccattributes.h> #include <skalibs/stralloc.h> -#define DJBUNIX_FLAG_NB 0x01U -#define DJBUNIX_FLAG_COE 0x02U - extern int coe (int) ; extern int uncoe (int) ; extern int ndelay_on (int) ; extern int ndelay_off (int) ; extern int pipe_internal (int *, unsigned int) ; -#define pipenb(p) pipe_internal(p, DJBUNIX_FLAG_NB) -#define pipecoe(p) pipe_internal(p, DJBUNIX_FLAG_COE) -#define pipenbcoe(p) pipe_internal(p, DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define pipenb(p) pipe_internal(p, O_NONBLOCK) +#define pipecoe(p) pipe_internal(p, O_CLOEXEC) +#define pipenbcoe(p) pipe_internal(p, O_NONBLOCK|O_CLOEXEC) extern int fd_copy (int, int) ; extern int fd_copy2 (int, int, int, int) ; extern int fd_move (int, int) ; @@ -57,8 +55,6 @@ extern int open_trunc (char const *) ; extern int openc_trunc (char const *) ; extern int open_write (char const *) ; extern int openc_write (char const *) ; -extern int socket_internal (int, int, int, unsigned int) ; -extern int socketpair_internal (int, int, int, unsigned int, int *) ; extern size_t path_canonicalize (char *, char const *, int) ; diff --git a/src/include/skalibs/socket.h b/src/include/skalibs/socket.h index 11ad1db..a114f29 100644 --- a/src/include/skalibs/socket.h +++ b/src/include/skalibs/socket.h @@ -3,18 +3,69 @@ #ifndef SOCKET_H #define SOCKET_H -#include <sys/types.h> +#include <stddef.h> #include <stdint.h> +#include <fcntl.h> + #include <skalibs/gccattributes.h> +#include <skalibs/posixplz.h> #include <skalibs/tai.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> typedef ssize_t socket_io_func_t (int, char *, size_t, char *, uint16_t *) ; typedef socket_io_func_t *socket_io_func_t_ref ; +extern int socket_internal (int, int, int, unsigned int) ; +extern int socketpair_internal (int, int, int, unsigned int, int *) ; + + + /* UNIX domain sockets */ + +#define IPCPATH_MAX 107 + +#define ipc_stream() ipc_stream_nb() +#define ipc_stream_b() ipc_stream_internal(0) +#define ipc_stream_nb() ipc_stream_internal(O_NONBLOCK) +#define ipc_stream_coe() ipc_stream_internal(O_CLOEXEC) +#define ipc_stream_nbcoe() ipc_stream_internal(O_NONBLOCK|O_CLOEXEC) +extern int ipc_stream_internal (unsigned int) ; + +#define ipc_datagram() ipc_datagram_nb() +#define ipc_datagram_b() ipc_datagram_internal(0) +#define ipc_datagram_nb() ipc_datagram_internal(O_NONBLOCK) +#define ipc_datagram_coe() ipc_datagram_internal(O_CLOEXEC) +#define ipc_datagram_nbcoe() ipc_datagram_internal(O_NONBLOCK|O_CLOEXEC) +extern int ipc_datagram_internal (unsigned int) ; + +#define ipc_pair(sv) ipc_pair_nb(sv) +#define ipc_pair_b(sv) ipc_pair_internal((sv), 0) +#define ipc_pair_nb(sv) ipc_pair_internal((sv), O_NONBLOCK) +#define ipc_pair_coe(sv) ipc_pair_internal((sv), O_CLOEXEC) +#define ipc_pair_nbcoe(sv) ipc_pair_internal((sv), O_NONBLOCK|O_CLOEXEC) +extern int ipc_pair_internal (int *, unsigned int) ; + +extern int ipc_bind (int, char const *) ; +extern int ipc_bind_reuse (int, char const *) ; +extern int ipc_bind_reuse_lock (int, char const *, int *) ; +extern int ipc_listen (int, int) ; + +#define ipc_accept(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), 0) +#define ipc_accept_nb(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_NONBLOCK) +#define ipc_accept_coe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_CLOEXEC) +#define ipc_accept_nbcoe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), O_NONBLOCK|O_CLOEXEC) +extern int ipc_accept_internal (int, char *, size_t, int *, unsigned int) ; + +extern int ipc_local (int, char *, size_t, int *) ; + +extern int ipc_connect (int, char const *) ; +extern int ipc_connected (int) ; +extern int ipc_timed_connect (int, char const *, tain_t const *, tain_t *) ; +#define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP) + +extern ssize_t ipc_send (int, char const *, size_t, char const *) ; +extern ssize_t ipc_recv (int, char *, size_t, char *) ; + - /* INET and INET6 domain socket operations */ + /* INET and INET6 domain sockets */ #define socket_tcp() socket_tcp4() #define socket_tcp_b() socket_tcp4_b() @@ -24,16 +75,16 @@ typedef socket_io_func_t *socket_io_func_t_ref ; #define socket_tcp4() socket_tcp4_nb() #define socket_tcp4_b() socket_tcp4_internal(0) -#define socket_tcp4_nb() socket_tcp4_internal(DJBUNIX_FLAG_NB) -#define socket_tcp4_coe() socket_tcp4_internal(DJBUNIX_FLAG_COE) -#define socket_tcp4_nbcoe() socket_tcp4_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_tcp4_nb() socket_tcp4_internal(O_NONBLOCK) +#define socket_tcp4_coe() socket_tcp4_internal(O_CLOEXEC) +#define socket_tcp4_nbcoe() socket_tcp4_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_tcp4_internal (unsigned int) ; #define socket_tcp6() socket_tcp6_nb() #define socket_tcp6_b() socket_tcp6_internal(0) -#define socket_tcp6_nb() socket_tcp6_internal(DJBUNIX_FLAG_NB) -#define socket_tcp6_coe() socket_tcp6_internal(DJBUNIX_FLAG_COE) -#define socket_tcp6_nbcoe() socket_tcp6_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_tcp6_nb() socket_tcp6_internal(O_NONBLOCK) +#define socket_tcp6_coe() socket_tcp6_internal(O_CLOEXEC) +#define socket_tcp6_nbcoe() socket_tcp6_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_tcp6_internal (unsigned int) ; #define socket_udp() socket_udp4() @@ -44,16 +95,16 @@ extern int socket_tcp6_internal (unsigned int) ; #define socket_udp4() socket_udp4_nb() #define socket_udp4_b() socket_udp4_internal(0) -#define socket_udp4_nb() socket_udp4_internal(DJBUNIX_FLAG_NB) -#define socket_udp4_coe() socket_udp4_internal(DJBUNIX_FLAG_COE) -#define socket_udp4_nbcoe() socket_udp4_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_udp4_nb() socket_udp4_internal(O_NONBLOCK) +#define socket_udp4_coe() socket_udp4_internal(O_CLOEXEC) +#define socket_udp4_nbcoe() socket_udp4_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_udp4_internal (unsigned int) ; #define socket_udp6() socket_udp6_nb() #define socket_udp6_b() socket_udp6_internal(0) -#define socket_udp6_nb() socket_udp6_internal(DJBUNIX_FLAG_NB) -#define socket_udp6_coe() socket_udp6_internal(DJBUNIX_FLAG_COE) -#define socket_udp6_nbcoe() socket_udp6_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_udp6_nb() socket_udp6_internal(O_NONBLOCK) +#define socket_udp6_coe() socket_udp6_internal(O_CLOEXEC) +#define socket_udp6_nbcoe() socket_udp6_internal(O_NONBLOCK|O_CLOEXEC) extern int socket_udp6_internal (unsigned int) ; extern int socket_waitconn (int, tain_t const *, tain_t *) ; @@ -79,9 +130,9 @@ extern int socket_bind6 (int, char const *, uint16_t) ; extern int socket_bind6_reuse (int, char const *, uint16_t) ; #define socket_accept4(s, ip, port) socket_accept4_internal(s, ip, (port), 0) -#define socket_accept4_nb(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB) -#define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_COE) -#define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_accept4_nb(s, ip, port) socket_accept4_internal(s, ip, (port), O_NONBLOCK) +#define socket_accept4_coe(s, ip, port) socket_accept4_internal(s, ip, (port), O_CLOEXEC) +#define socket_accept4_nbcoe(s, ip, port) socket_accept4_internal(s, ip, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept4_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func_t socket_recv4 ; extern ssize_t socket_send4 (int, char const *, size_t, char const *, uint16_t) ; @@ -90,9 +141,9 @@ extern int socket_local4 (int, char *, uint16_t *) ; extern int socket_remote4 (int, char *, uint16_t *) ; #define socket_accept6(s, ip6, port) socket_accept6_internal(s, ip6, (port), 0) -#define socket_accept6_nb(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB) -#define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_COE) -#define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) +#define socket_accept6_nb(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_NONBLOCK) +#define socket_accept6_coe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_CLOEXEC) +#define socket_accept6_nbcoe(s, ip6, port) socket_accept6_internal(s, ip6, (port), O_NONBLOCK|O_CLOEXEC) extern int socket_accept6_internal (int, char *, uint16_t *, unsigned int) ; extern socket_io_func_t socket_recv6 ; extern ssize_t socket_send6 (int, char const *, size_t, char const *, uint16_t) ; diff --git a/src/include/skalibs/stddjb.h b/src/include/skalibs/stddjb.h index 071c913..b15bff3 100644 --- a/src/include/skalibs/stddjb.h +++ b/src/include/skalibs/stddjb.h @@ -51,6 +51,5 @@ #include <skalibs/strerr.h> #include <skalibs/strerr2.h> #include <skalibs/tai.h> -#include <skalibs/webipc.h> #endif diff --git a/src/include/skalibs/webipc.h b/src/include/skalibs/webipc.h deleted file mode 100644 index 2a7e95e..0000000 --- a/src/include/skalibs/webipc.h +++ /dev/null @@ -1,63 +0,0 @@ -/* ISC license. */ - -#ifndef WEBIPC_H -#define WEBIPC_H - - /* - UNIX domain socket functions. - "web" stands for William E. Baxter, the original author, who kindly - permitted me to modify and release his code as a part of skalibs. - It has nothing to do with the World Wide Web. - */ - -#define IPCPATH_MAX 107 - -#include <sys/types.h> -#include <skalibs/posixplz.h> -#include <skalibs/tai.h> -#include <skalibs/djbunix.h> - -#define ipc_stream() ipc_stream_nb() -#define ipc_stream_b() ipc_stream_internal(0) -#define ipc_stream_nb() ipc_stream_internal(DJBUNIX_FLAG_NB) -#define ipc_stream_coe() ipc_stream_internal(DJBUNIX_FLAG_COE) -#define ipc_stream_nbcoe() ipc_stream_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int ipc_stream_internal (unsigned int) ; - -#define ipc_datagram() ipc_datagram_nb() -#define ipc_datagram_b() ipc_datagram_internal(0) -#define ipc_datagram_nb() ipc_datagram_internal(DJBUNIX_FLAG_NB) -#define ipc_datagram_coe() ipc_datagram_internal(DJBUNIX_FLAG_COE) -#define ipc_datagram_nbcoe() ipc_datagram_internal(DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int ipc_datagram_internal (unsigned int) ; - -#define ipc_pair(sv) ipc_pair_nb(sv) -#define ipc_pair_b(sv) ipc_pair_internal((sv), 0) -#define ipc_pair_nb(sv) ipc_pair_internal((sv), DJBUNIX_FLAG_NB) -#define ipc_pair_coe(sv) ipc_pair_internal((sv), DJBUNIX_FLAG_COE) -#define ipc_pair_nbcoe(sv) ipc_pair_internal((sv), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int ipc_pair_internal (int *, unsigned int) ; - -extern int ipc_bind (int, char const *) ; -extern int ipc_bind_reuse (int, char const *) ; -extern int ipc_bind_reuse_lock (int, char const *, int *) ; -extern int ipc_listen (int, int) ; - -#define ipc_accept(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), 0) -#define ipc_accept_nb(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB) -#define ipc_accept_coe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_COE) -#define ipc_accept_nbcoe(s, path, len, trunc) ipc_accept_internal(s, path, len, (trunc), DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE) -extern int ipc_accept_internal (int, char *, size_t, int *, unsigned int) ; - -#define ipc_eid getpeereid -extern int ipc_local (int, char *, size_t, int *) ; - -extern int ipc_connect (int, char const *) ; -extern int ipc_connected (int) ; -extern int ipc_timed_connect (int, char const *, tain_t const *, tain_t *) ; -#define ipc_timed_connect_g(fd, path, deadline) ipc_timed_connect(fd, path, (deadline), &STAMP) - -extern ssize_t ipc_send (int, char const *, size_t, char const *) ; -extern ssize_t ipc_recv (int, char *, size_t, char *) ; - -#endif diff --git a/src/libstddjb/child_spawn1_socket.c b/src/libstddjb/child_spawn1_socket.c index 7263ff6..0bb2da9 100644 --- a/src/libstddjb/child_spawn1_socket.c +++ b/src/libstddjb/child_spawn1_socket.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/djbunix.h> #include "djbunix-internal.h" diff --git a/src/libstddjb/ipc_accept.c b/src/libstddjb/ipc_accept.c index b0b44c3..9d5d82c 100644 --- a/src/libstddjb/ipc_accept.c +++ b/src/libstddjb/ipc_accept.c @@ -6,9 +6,11 @@ #include <sys/un.h> #include <string.h> #include <errno.h> +#include <fcntl.h> + #include <skalibs/bytestr.h> #include <skalibs/djbunix.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int options) { @@ -18,15 +20,15 @@ int ipc_accept_internal (int s, char *p, size_t l, int *trunc, unsigned int opti memset(&sa, 0, dummy) ; do #ifdef SKALIBS_HASACCEPT4 - fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; + fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd == -1) && (errno == EINTR)) ; if (fd == -1) return -1 ; #ifndef SKALIBS_HASACCEPT4 - if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) - || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) + if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) + || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; diff --git a/src/libstddjb/ipc_bind.c b/src/libstddjb/ipc_bind.c index d40a7ef..c26fb1d 100644 --- a/src/libstddjb/ipc_bind.c +++ b/src/libstddjb/ipc_bind.c @@ -1,13 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> - #include <sys/socket.h> #include <sys/un.h> #include <string.h> #include <errno.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/posixishard.h> int ipc_bind (int s, char const *p) diff --git a/src/libstddjb/ipc_bind_reuse.c b/src/libstddjb/ipc_bind_reuse.c index ce5c7a4..193d10c 100644 --- a/src/libstddjb/ipc_bind_reuse.c +++ b/src/libstddjb/ipc_bind_reuse.c @@ -1,6 +1,6 @@ /* ISC license. */ -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_bind_reuse (int s, char const *p) { diff --git a/src/libstddjb/ipc_bind_reuse_lock.c b/src/libstddjb/ipc_bind_reuse_lock.c index b1bccfd..c872e44 100644 --- a/src/libstddjb/ipc_bind_reuse_lock.c +++ b/src/libstddjb/ipc_bind_reuse_lock.c @@ -8,7 +8,7 @@ #include <sys/socket.h> #include <skalibs/djbunix.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_bind_reuse_lock (int s, char const *p, int *fdlock) { @@ -24,8 +24,10 @@ int ipc_bind_reuse_lock (int s, char const *p, int *fdlock) r = fd_lock(fd, 1, 1) ; if (r < 0) return -1 ; if (!r) return (errno = EBUSY, -1) ; + r = errno ; setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof opt) ; - unlink(p) ; + errno = r ; + unlink_void(p) ; if (ipc_bind(s, p) < 0) return -1 ; *fdlock = fd ; return 0 ; diff --git a/src/libstddjb/ipc_connect.c b/src/libstddjb/ipc_connect.c index c00f683..7ccba09 100644 --- a/src/libstddjb/ipc_connect.c +++ b/src/libstddjb/ipc_connect.c @@ -1,13 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> - #include <errno.h> #include <sys/socket.h> #include <sys/un.h> #include <string.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/posixishard.h> int ipc_connect (int s, char const *p) diff --git a/src/libstddjb/ipc_connected.c b/src/libstddjb/ipc_connected.c index a079fd5..310649b 100644 --- a/src/libstddjb/ipc_connected.c +++ b/src/libstddjb/ipc_connected.c @@ -3,8 +3,9 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <sys/un.h> + #include <skalibs/allreadwrite.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_connected (int s) { diff --git a/src/libstddjb/ipc_dgram.c b/src/libstddjb/ipc_dgram.c index ac61ee7..78ea032 100644 --- a/src/libstddjb/ipc_dgram.c +++ b/src/libstddjb/ipc_dgram.c @@ -2,8 +2,7 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_datagram_internal (unsigned int flags) { diff --git a/src/libstddjb/ipc_listen.c b/src/libstddjb/ipc_listen.c index a96be58..141a2ea 100644 --- a/src/libstddjb/ipc_listen.c +++ b/src/libstddjb/ipc_listen.c @@ -2,7 +2,7 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_listen (int s, int backlog) { diff --git a/src/libstddjb/ipc_local.c b/src/libstddjb/ipc_local.c index e617264..849d9ce 100644 --- a/src/libstddjb/ipc_local.c +++ b/src/libstddjb/ipc_local.c @@ -4,8 +4,9 @@ #include <sys/socket.h> #include <sys/un.h> #include <string.h> + #include <skalibs/bytestr.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_local (int s, char *p, size_t l, int *trunc) { diff --git a/src/libstddjb/ipc_pair.c b/src/libstddjb/ipc_pair.c index 6038d17..5400e63 100644 --- a/src/libstddjb/ipc_pair.c +++ b/src/libstddjb/ipc_pair.c @@ -2,8 +2,7 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_pair_internal (int *sv, unsigned int flags) { diff --git a/src/libstddjb/ipc_recv.c b/src/libstddjb/ipc_recv.c index 4c235bb..407b3cc 100644 --- a/src/libstddjb/ipc_recv.c +++ b/src/libstddjb/ipc_recv.c @@ -1,13 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> - +#include <string.h> #include <errno.h> #include <sys/socket.h> #include <sys/un.h> -#include <string.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/posixishard.h> ssize_t ipc_recv (int fd, char *s, size_t len, char *path) diff --git a/src/libstddjb/ipc_send.c b/src/libstddjb/ipc_send.c index 2615a16..b9cfe49 100644 --- a/src/libstddjb/ipc_send.c +++ b/src/libstddjb/ipc_send.c @@ -1,13 +1,12 @@ /* ISC license. */ #include <skalibs/nonposix.h> - #include <errno.h> #include <sys/socket.h> #include <sys/un.h> #include <string.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/posixishard.h> ssize_t ipc_send (int fd, char const *s, size_t len, char const *path) diff --git a/src/libstddjb/ipc_stream.c b/src/libstddjb/ipc_stream.c index c2c6c1b..265236d 100644 --- a/src/libstddjb/ipc_stream.c +++ b/src/libstddjb/ipc_stream.c @@ -2,8 +2,7 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> -#include <skalibs/djbunix.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_stream_internal (unsigned int flags) { diff --git a/src/libstddjb/ipc_timed_connect.c b/src/libstddjb/ipc_timed_connect.c index e08b32b..ff88018 100644 --- a/src/libstddjb/ipc_timed_connect.c +++ b/src/libstddjb/ipc_timed_connect.c @@ -1,9 +1,10 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/error.h> #include <skalibs/iopause.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> int ipc_timed_connect (int s, char const *path, tain_t const *deadline, tain_t *stamp) { diff --git a/src/libstddjb/pipe_internal.c b/src/libstddjb/pipe_internal.c index 598ab9c..dc7cfe6 100644 --- a/src/libstddjb/pipe_internal.c +++ b/src/libstddjb/pipe_internal.c @@ -6,26 +6,28 @@ #include <skalibs/nonposix.h> #include <unistd.h> -#include <fcntl.h> + #include <skalibs/djbunix.h> int pipe_internal (int *p, unsigned int flags) { - return pipe2(p, ((flags & DJBUNIX_FLAG_COE) ? O_CLOEXEC : 0) | ((flags & DJBUNIX_FLAG_NB) ? O_NONBLOCK : 0)) ; + return pipe2(p, flags) ; } #else #include <unistd.h> +#include <fcntl.h> + #include <skalibs/djbunix.h> int pipe_internal (int *p, unsigned int flags) { int pi[2] ; if (pipe(pi) < 0) return -1 ; - if (flags & DJBUNIX_FLAG_COE) + if (flags & O_CLOEXEC) if ((coe(pi[0]) < 0) || (coe(pi[1]) < 0)) goto err ; - if (flags & DJBUNIX_FLAG_NB) + if (flags & O_NONBLOCK) if ((ndelay_on(pi[0]) < 0) || (ndelay_on(pi[1]) < 0)) goto err ; p[0] = pi[0] ; p[1] = pi[1] ; return 0 ; diff --git a/src/libstddjb/socket_accept4.c b/src/libstddjb/socket_accept4.c index 40dff91..2016777 100644 --- a/src/libstddjb/socket_accept4.c +++ b/src/libstddjb/socket_accept4.c @@ -6,6 +6,8 @@ #include <netinet/in.h> #include <string.h> #include <errno.h> +#include <fcntl.h> + #include <skalibs/uint16.h> #include <skalibs/djbunix.h> #include <skalibs/socket.h> @@ -17,15 +19,15 @@ int socket_accept4_internal (int s, char *ip, uint16_t *port, unsigned int optio int fd ; do #ifdef SKALIBS_HASACCEPT4 - fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; + fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd < 0) && (errno == EINTR)) ; if (fd < 0) return -1 ; #ifndef SKALIBS_HASACCEPT4 - if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) - || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) + if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) + || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; diff --git a/src/libstddjb/socket_accept6.c b/src/libstddjb/socket_accept6.c index 5bd72b4..f5156ca 100644 --- a/src/libstddjb/socket_accept6.c +++ b/src/libstddjb/socket_accept6.c @@ -6,6 +6,8 @@ #include <netinet/in.h> #include <string.h> #include <errno.h> +#include <fcntl.h> + #include <skalibs/uint16.h> #include <skalibs/djbunix.h> #include <skalibs/ip46.h> @@ -20,15 +22,15 @@ int socket_accept6_internal (int s, char *ip6, uint16_t *port, unsigned int opti int fd ; do #ifdef SKALIBS_HASACCEPT4 - fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((options & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0)) ; + fd = accept4(s, (struct sockaddr *)&sa, &dummy, ((options & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((options & O_CLOEXEC) ? SOCK_CLOEXEC : 0)) ; #else fd = accept(s, (struct sockaddr *)&sa, &dummy) ; #endif while ((fd < 0) && (errno == EINTR)) ; if (fd < 0) return -1 ; #ifndef SKALIBS_HASACCEPT4 - if ((((options & DJBUNIX_FLAG_NB) ? ndelay_on(fd) : ndelay_off(fd)) < 0) - || (((options & DJBUNIX_FLAG_COE) ? coe(fd) : uncoe(fd)) < 0)) + if ((((options & O_NONBLOCK) ? ndelay_on(fd) : ndelay_off(fd)) < 0) + || (((options & O_CLOEXEC) ? coe(fd) : uncoe(fd)) < 0)) { fd_close(fd) ; return -1 ; diff --git a/src/libstddjb/socket_internal.c b/src/libstddjb/socket_internal.c index 848b156..852f323 100644 --- a/src/libstddjb/socket_internal.c +++ b/src/libstddjb/socket_internal.c @@ -3,13 +3,16 @@ #include <skalibs/sysdeps.h> #include <skalibs/nonposix.h> #include <sys/socket.h> +#include <fcntl.h> + #include <skalibs/djbunix.h> +#include <skalibs/socket.h> #ifdef SKALIBS_HASACCEPT4 int socket_internal (int domain, int type, int protocol, unsigned int flags) { - return socket(domain, type | ((flags & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((flags & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0), protocol) ; + return socket(domain, type | ((flags & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((flags & O_CLOEXEC) ? SOCK_CLOEXEC : 0), protocol) ; } #else @@ -18,8 +21,8 @@ int socket_internal (int domain, int type, int protocol, unsigned int flags) { int s = socket(domain, type, protocol) ; if (s == -1) return -1 ; - if ((((flags & DJBUNIX_FLAG_NB) ? ndelay_on(s) : ndelay_off(s)) < 0) - || (((flags & DJBUNIX_FLAG_COE) ? coe(s) : uncoe(s)) < 0)) + if ((((flags & O_NONBLOCK) ? ndelay_on(s) : ndelay_off(s)) < 0) + || (((flags & O_CLOEXEC) ? coe(s) : uncoe(s)) < 0)) { fd_close(s) ; return -1 ; diff --git a/src/libstddjb/socket_tcp4.c b/src/libstddjb/socket_tcp4.c index 8eecb67..5705af2 100644 --- a/src/libstddjb/socket_tcp4.c +++ b/src/libstddjb/socket_tcp4.c @@ -3,6 +3,7 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <netinet/in.h> + #include <skalibs/socket.h> int socket_tcp4_internal (unsigned int flags) diff --git a/src/libstddjb/socketpair_internal.c b/src/libstddjb/socketpair_internal.c index a31228f..0cedce2 100644 --- a/src/libstddjb/socketpair_internal.c +++ b/src/libstddjb/socketpair_internal.c @@ -4,13 +4,16 @@ #include <skalibs/nonposix.h> #include <sys/socket.h> #include <errno.h> +#include <fcntl.h> + #include <skalibs/djbunix.h> +#include <skalibs/socket.h> #ifdef SKALIBS_HASACCEPT4 int socketpair_internal (int domain, int type, int protocol, unsigned int flags, int *sv) { - return socketpair(domain, type | ((flags & DJBUNIX_FLAG_NB) ? SOCK_NONBLOCK : 0) | ((flags & DJBUNIX_FLAG_COE) ? SOCK_CLOEXEC : 0), protocol, sv) ; + return socketpair(domain, type | ((flags & O_NONBLOCK) ? SOCK_NONBLOCK : 0) | ((flags & O_CLOEXEC) ? SOCK_CLOEXEC : 0), protocol, sv) ; } #else @@ -19,7 +22,7 @@ int socketpair_internal (int domain, int type, int protocol, unsigned int flags, { int fd[2] ; if (socketpair(domain, type, protocol, fd) < 0) return -1 ; - if (flags & DJBUNIX_FLAG_NB) + if (flags & O_NONBLOCK) { if (ndelay_on(fd[0]) < 0) goto err ; if (ndelay_on(fd[1]) < 0) goto err ; @@ -29,7 +32,7 @@ int socketpair_internal (int domain, int type, int protocol, unsigned int flags, if (ndelay_off(fd[0]) < 0) goto err ; if (ndelay_off(fd[1]) < 0) goto err ; } - if (flags & DJBUNIX_FLAG_COE) + if (flags & O_CLOEXEC) { if (coe(fd[0]) < 0) goto err ; if (coe(fd[1]) < 0) goto err ; diff --git a/src/libunixonacid/ipc_timed_recv.c b/src/libunixonacid/ipc_timed_recv.c index ca3b57f..5710a8c 100644 --- a/src/libunixonacid/ipc_timed_recv.c +++ b/src/libunixonacid/ipc_timed_recv.c @@ -2,7 +2,7 @@ #include <skalibs/functypes.h> #include <skalibs/allreadwrite.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/unix-timed.h> struct blah_s diff --git a/src/libunixonacid/skaclient_server_ack.c b/src/libunixonacid/skaclient_server_ack.c index 9bad7cc..cec61d1 100644 --- a/src/libunixonacid/skaclient_server_ack.c +++ b/src/libunixonacid/skaclient_server_ack.c @@ -6,7 +6,7 @@ #include <skalibs/djbunix.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/posixishard.h> int skaclient_server_ack (unixmessage_t const *clientmsg, unixmessage_sender_t *out, unixmessage_sender_t *asyncout, char const *before, size_t beforelen, char const *after, size_t afterlen) diff --git a/src/libunixonacid/skaclient_start_async.c b/src/libunixonacid/skaclient_start_async.c index d678a85..3847ec0 100644 --- a/src/libunixonacid/skaclient_start_async.c +++ b/src/libunixonacid/skaclient_start_async.c @@ -1,11 +1,13 @@ /* ISC license. */ #include <errno.h> + #include <skalibs/error.h> #include <skalibs/kolbak.h> #include <skalibs/skaclient.h> #include <skalibs/unixmessage.h> -#include <skalibs/webipc.h> +#include <skalibs/djbunix.h> +#include <skalibs/socket.h> #include "skaclient-internal.h" int skaclient_start_async ( diff --git a/src/libunixonacid/textclient_start.c b/src/libunixonacid/textclient_start.c index e8a6d0c..ee2f800 100644 --- a/src/libunixonacid/textclient_start.c +++ b/src/libunixonacid/textclient_start.c @@ -4,7 +4,7 @@ #include <string.h> #include <errno.h> -#include <skalibs/webipc.h> +#include <skalibs/socket.h> #include <skalibs/djbunix.h> #include <skalibs/textmessage.h> #include <skalibs/textclient.h> |