Removed trailing white space from *.h and *.c files

This commit is contained in:
Gerhard Rieger 2023-06-12 23:01:54 +02:00
parent 920d77847d
commit 33896a3f38
38 changed files with 172 additions and 165 deletions

View file

@ -83,6 +83,8 @@ Coding:
Stream dump write now warn on write errors and partial writes (but Stream dump write now warn on write errors and partial writes (but
still do not recover). still do not recover).
Removed trailing white space from *.h and *.c files.
Porting: Porting:
Small correction in configure.ac makes Socat C99 able. Small correction in configure.ac makes Socat C99 able.
Thanks to Florian Weimer from Red Hat for providing a patch. Thanks to Florian Weimer from Red Hat for providing a patch.

View file

@ -89,7 +89,7 @@ static int procgetfdname(int fd, char *filepath, size_t pathsize) {
} }
} }
#endif /* !HAVE_STAT64 */ #endif /* !HAVE_STAT64 */
if (pid < 0) pid = Getpid(); if (pid < 0) pid = Getpid();
snprintf(procpath, sizeof(procpath), "/proc/"F_pid"/" snprintf(procpath, sizeof(procpath), "/proc/"F_pid"/"
#if HAVE_PROC_DIR_PATH #if HAVE_PROC_DIR_PATH
@ -107,7 +107,7 @@ static int procgetfdname(int fd, char *filepath, size_t pathsize) {
return 0; return 0;
} }
#endif /* HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH */ #endif /* HAVE_PROC_DIR_FD || HAVE_PROC_DIR_PATH */
int statname(const char *file, int fd, int filetype, FILE *outfile, int statname(const char *file, int fd, int filetype, FILE *outfile,
char style) { char style) {
char filepath[PATH_MAX]; char filepath[PATH_MAX];
@ -229,7 +229,7 @@ int sockname(int fd, FILE *outfile, char style) {
#if HAVE_GETPROTOBYNUMBER || HAVE_GETPROTOBYNUMBER_R #if HAVE_GETPROTOBYNUMBER || HAVE_GETPROTOBYNUMBER_R
struct protoent protoent, *protoentp; struct protoent protoent, *protoentp;
#endif #endif
#define PROTONAMEMAX 1024 #define PROTONAMEMAX 1024
char protoname[PROTONAMEMAX] = ""; char protoname[PROTONAMEMAX] = "";
#if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE) #if defined(SO_PROTOCOL) || defined(SO_PROTOTYPE)
int proto = 0; int proto = 0;
@ -304,8 +304,8 @@ int sockname(int fd, FILE *outfile, char style) {
} }
#else #else
switch (proto) { switch (proto) {
case IPPROTO_TCP: strcpy(protoname, "tcp"); break; case IPPROTO_TCP: strcpy(protoname, "tcp"); break;
case IPPROTO_UDP: strcpy(protoname, "udp"); break; case IPPROTO_UDP: strcpy(protoname, "udp"); break;
case IPPROTO_SCTP: strcpy(protoname, "sctp"); break; case IPPROTO_SCTP: strcpy(protoname, "sctp"); break;
default: sprintf(protoname, "proto%d", proto); break; default: sprintf(protoname, "proto%d", proto); break;
} }

16
filan.c
View file

@ -3,7 +3,7 @@
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* the subroutine filan makes a "FILe descriptor ANalysis". It checks the /* the subroutine filan makes a "FILe descriptor ANalysis". It checks the
type of file descriptor and tries to retrieve as much info about it as type of file descriptor and tries to retrieve as much info about it as
possible without modifying its state. possible without modifying its state.
NOTE: it works on UNIX (kernel) file descriptors, not on libc files! */ NOTE: it works on UNIX (kernel) file descriptors, not on libc files! */
@ -79,7 +79,7 @@ int filan_file(const char *filename, FILE *outfile) {
default: default:
if ((fd = if ((fd =
Open(filename, O_RDONLY|O_NOCTTY|O_NONBLOCK Open(filename, O_RDONLY|O_NOCTTY|O_NONBLOCK
#ifdef O_NOFOLLOW #ifdef O_NOFOLLOW
|(filan_followsymlinks?0:O_NOFOLLOW) |(filan_followsymlinks?0:O_NOFOLLOW)
#endif #endif
#ifdef O_LARGEFILE #ifdef O_LARGEFILE
@ -91,7 +91,7 @@ int filan_file(const char *filename, FILE *outfile) {
filename, strerror(errno)); filename, strerror(errno));
} }
} }
result = filan_stat(&buf, fd, -1, outfile, filename); result = filan_stat(&buf, fd, -1, outfile, filename);
fputc('\n', outfile); fputc('\n', outfile);
return result; return result;
@ -200,7 +200,7 @@ int filan_fd(int fd, FILE *outfile) {
} }
} }
#endif /* _WITH_SOCKET && defined(MSG_DONTWAIT) */ #endif /* _WITH_SOCKET && defined(MSG_DONTWAIT) */
} }
#endif /* HAVE_POLL */ #endif /* HAVE_POLL */
} }
} }
@ -642,7 +642,7 @@ int sockan(int fd, FILE *outfile) {
# define TYPENAMEMAX 16 # define TYPENAMEMAX 16
char typename[TYPENAMEMAX]; char typename[TYPENAMEMAX];
sockettype(*optval.i, typename, sizeof(typename)); sockettype(*optval.i, typename, sizeof(typename));
Debug3("fd %d: socket of type %d (\"%s\")", fd, *optval.i, Debug3("fd %d: socket of type %d (\"%s\")", fd, *optval.i,
typename); typename);
} }
@ -790,7 +790,7 @@ int ipan(int fd, FILE *outfile) {
const struct sockopt *optname; const struct sockopt *optname;
int optproto; int optproto;
socklen_t optlen = sizeof(optproto); socklen_t optlen = sizeof(optproto);
optname = ipopts; while (optname->so) { optname = ipopts; while (optname->so) {
sockoptan(fd, optname, SOL_IP, outfile); sockoptan(fd, optname, SOL_IP, outfile);
++optname; ++optname;
@ -825,7 +825,7 @@ int ip6an(int fd, FILE *outfile) {
#endif #endif
{0, NULL} } ; {0, NULL} } ;
const struct sockopt *optname; const struct sockopt *optname;
optname = ip6opts; while (optname->so) { optname = ip6opts; while (optname->so) {
sockoptan(fd, optname, SOL_IPV6, outfile); sockoptan(fd, optname, SOL_IPV6, outfile);
++optname; ++optname;
@ -1059,4 +1059,4 @@ static int printtime(FILE *outfile, time_t time) {
fputs(s, outfile); fputs(s, outfile);
} }
return 0; return 0;
} }

View file

@ -73,7 +73,7 @@ static int _nestlex(const char **addr,
/* is this end of input string? */ /* is this end of input string? */
if (*in == 0) { if (*in == 0) {
break; /* end of string */ break; /* end of string */
} }
@ -123,7 +123,7 @@ static int _nestlex(const char **addr,
if (--*len <= 0) { *addr = in; *token = out; return -1; } if (--*len <= 0) { *addr = in; *token = out; return -1; }
} }
} }
break; break;
} }
++quotx; ++quotx;

17
socat.c
View file

@ -230,7 +230,7 @@ int main(int argc, const char *argv[]) {
rto = Strtod(a, (char **)&a, "-t"); rto = Strtod(a, (char **)&a, "-t");
socat_opts.closwait.tv_sec = rto; socat_opts.closwait.tv_sec = rto;
socat_opts.closwait.tv_usec = socat_opts.closwait.tv_usec =
(rto-socat_opts.closwait.tv_sec) * 1000000; (rto-socat_opts.closwait.tv_sec) * 1000000;
break; break;
case 'T': if (arg1[0][2]) { case 'T': if (arg1[0][2]) {
a = *arg1+2; a = *arg1+2;
@ -244,7 +244,7 @@ int main(int argc, const char *argv[]) {
rto = Strtod(a, (char **)&a, "-T"); rto = Strtod(a, (char **)&a, "-T");
socat_opts.total_timeout.tv_sec = rto; socat_opts.total_timeout.tv_sec = rto;
socat_opts.total_timeout.tv_usec = socat_opts.total_timeout.tv_usec =
(rto-socat_opts.total_timeout.tv_sec) * 1000000; (rto-socat_opts.total_timeout.tv_sec) * 1000000;
break; break;
case 'u': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); } case 'u': if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); }
socat_opts.lefttoright = true; break; socat_opts.lefttoright = true; break;
@ -738,8 +738,7 @@ int socat(const char *address1, const char *address2) {
#endif #endif
Info("resolved and opened all sock addresses"); Info("resolved and opened all sock addresses");
return return _socat(); /* nsocks, sockets are visible outside function */
_socat(); /* nsocks, sockets are visible outside function */
} }
/* checks if this is a connection to a child process, and if so, sees if the /* checks if this is a connection to a child process, and if so, sees if the
@ -1041,7 +1040,7 @@ int _socat(void) {
if (closing) { if (closing) {
break; break;
} }
/* one possibility to come here is ignoreeof on some fd, but no EOF /* one possibility to come here is ignoreeof on some fd, but no EOF
and no data on any descriptor - this is no indication for end! */ and no data on any descriptor - this is no indication for end! */
continue; continue;
} }
@ -1051,7 +1050,7 @@ int _socat(void) {
if (fd1in->revents & POLLNVAL) { if (fd1in->revents & POLLNVAL) {
/* this is what we find on Mac OS X when poll()'ing on a device or /* this is what we find on Mac OS X when poll()'ing on a device or
named pipe. a read() might imm. return with 0 bytes, resulting named pipe. a read() might imm. return with 0 bytes, resulting
in a loop? */ in a loop? */
Error1("poll(...[%d]: invalid request", fd1in->fd); Error1("poll(...[%d]: invalid request", fd1in->fd);
free(buff); free(buff);
return -1; return -1;
@ -1137,7 +1136,7 @@ int _socat(void) {
XIO_RDSTREAM(sock2)->actbytes == 0) { XIO_RDSTREAM(sock2)->actbytes == 0) {
/* avoid idle when all readbytes already there */ /* avoid idle when all readbytes already there */
mayrd2 = true; mayrd2 = true;
} }
/* escape char occurred? */ /* escape char occurred? */
if (XIO_RDSTREAM(sock2)->actescape) { if (XIO_RDSTREAM(sock2)->actescape) {
bytes2 = 0; /* indicate EOF */ bytes2 = 0; /* indicate EOF */
@ -1287,7 +1286,7 @@ static int
/* inpipe is suspected to have read data available; read at most bufsiz bytes /* inpipe is suspected to have read data available; read at most bufsiz bytes
and transfer them to outpipe. Perform required data conversions. and transfer them to outpipe. Perform required data conversions.
buff must be a malloc()'ed storage and might be realloc()'ed in this buff must be a malloc()'ed storage and might be realloc()'ed in this
function if more space is required after conversions. function if more space is required after conversions.
Returns the number of bytes written, or 0 on EOF or <0 if an Returns the number of bytes written, or 0 on EOF or <0 if an
error occurred or when data was read but none written due to conversions error occurred or when data was read but none written due to conversions
(with EAGAIN). EAGAIN also occurs when reading from a nonblocking FD where (with EAGAIN). EAGAIN also occurs when reading from a nonblocking FD where
@ -1571,7 +1570,7 @@ void socat_signal(int signum) {
break; break;
case SIGTERM: case SIGTERM:
Warn1("exiting on signal %d", signum); break; Warn1("exiting on signal %d", signum); break;
case SIGHUP: case SIGHUP:
case SIGINT: case SIGINT:
Notice1("exiting on signal %d", signum); break; Notice1("exiting on signal %d", signum); break;
} }

View file

@ -348,7 +348,7 @@ int sycSSL_connect(SSL *ssl) {
Debug1("SSL_connect(%p)", ssl); Debug1("SSL_connect(%p)", ssl);
result = SSL_connect(ssl); result = SSL_connect(ssl);
Debug1("SSL_connect() -> %d", result); Debug1("SSL_connect() -> %d", result);
return result; return result;
} }
int sycSSL_accept(SSL *ssl) { int sycSSL_accept(SSL *ssl) {
@ -356,7 +356,7 @@ int sycSSL_accept(SSL *ssl) {
Debug1("SSL_accept(%p)", ssl); Debug1("SSL_accept(%p)", ssl);
result = SSL_accept(ssl); result = SSL_accept(ssl);
Debug1("SSL_accept() -> %d", result); Debug1("SSL_accept() -> %d", result);
return result; return result;
} }
int sycSSL_read(SSL *ssl, void *buf, int num) { int sycSSL_read(SSL *ssl, void *buf, int num) {
@ -392,7 +392,7 @@ X509 *sycSSL_get_peer_certificate(SSL *ssl) {
} else { } else {
Debug("SSL_get_peer_certificate() -> NULL"); Debug("SSL_get_peer_certificate() -> NULL");
} }
return result; return result;
} }
int sycSSL_shutdown(SSL *ssl) { int sycSSL_shutdown(SSL *ssl) {

16
sycls.c
View file

@ -1097,13 +1097,13 @@ int Connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen) {
Debug18("connect(%d,{0x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x}, "F_Zd")", Debug18("connect(%d,{0x%02x%02x%02x%02x %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x}, "F_Zd")",
sockfd, sockfd,
((unsigned char *)serv_addr)[0], ((unsigned char *)serv_addr)[1], ((unsigned char *)serv_addr)[0], ((unsigned char *)serv_addr)[1],
((unsigned char *)serv_addr)[2], ((unsigned char *)serv_addr)[3], ((unsigned char *)serv_addr)[2], ((unsigned char *)serv_addr)[3],
((unsigned char *)serv_addr)[4], ((unsigned char *)serv_addr)[5], ((unsigned char *)serv_addr)[4], ((unsigned char *)serv_addr)[5],
((unsigned char *)serv_addr)[6], ((unsigned char *)serv_addr)[7], ((unsigned char *)serv_addr)[6], ((unsigned char *)serv_addr)[7],
((unsigned char *)serv_addr)[8], ((unsigned char *)serv_addr)[9], ((unsigned char *)serv_addr)[8], ((unsigned char *)serv_addr)[9],
((unsigned char *)serv_addr)[10], ((unsigned char *)serv_addr)[11], ((unsigned char *)serv_addr)[10], ((unsigned char *)serv_addr)[11],
((unsigned char *)serv_addr)[12], ((unsigned char *)serv_addr)[13], ((unsigned char *)serv_addr)[12], ((unsigned char *)serv_addr)[13],
((unsigned char *)serv_addr)[14], ((unsigned char *)serv_addr)[15], ((unsigned char *)serv_addr)[14], ((unsigned char *)serv_addr)[15],
addrlen); addrlen);
#else #else
Debug4("connect(%d, {%d,%s}, "F_socklen")", Debug4("connect(%d, {%d,%s}, "F_socklen")",
@ -1536,7 +1536,7 @@ int Tcgetattr(int fd, struct termios *termios_p) {
#else #else
Debug6("tcgetattr(, {%08x,%08x,%08x,%08x,%s}) -> %d", Debug6("tcgetattr(, {%08x,%08x,%08x,%08x,%s}) -> %d",
termios_p->c_iflag, termios_p->c_oflag, termios_p->c_iflag, termios_p->c_oflag,
termios_p->c_cflag, termios_p->c_lflag, termios_p->c_cflag, termios_p->c_lflag,
chars, result); chars, result);
#endif #endif
errno = _errno; errno = _errno;

View file

@ -661,7 +661,7 @@ int xiopoll(struct pollfd fds[], unsigned long nfds, struct timeval *timeout) {
#endif /* !HAVE_POLL */ #endif /* !HAVE_POLL */
} }
} }
#if WITH_TCP || WITH_UDP #if WITH_TCP || WITH_UDP
/* returns port in network byte order; /* returns port in network byte order;

View file

@ -78,11 +78,11 @@ static char *diag_ulong_to_dec(char *field, size_t n, unsigned long ulo, int lea
while (--i >= 0) { while (--i >= 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
/* this function converts a signed long number to decimal ASCII /* this function converts a signed long number to decimal ASCII
and pads it with space or '0' when size and leading0 are set appropriately and pads it with space or '0' when size and leading0 are set appropriately
it is async signal safe and thread safe it is async signal safe and thread safe
it returns NULL if n==0 it returns NULL if n==0
@ -110,7 +110,7 @@ static char *diag_long_to_dec(char *field, size_t n, long lo, int leading0, int
if (size >= n) size = n-1; if (size >= n) size = n-1;
i = size - strlen(np); i = size - strlen(np);
if (leading0) { if (leading0) {
if (minus) --i; if (minus) --i;
while (--i >= 0) { while (--i >= 0) {
*--np = '0'; *--np = '0';
} }
@ -156,7 +156,7 @@ static char *diag_ulong_to_hex(char *field, size_t n, unsigned long ulo, int lea
while (--i >= 0) { while (--i >= 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
@ -188,7 +188,7 @@ static char *diag_ulong_to_oct(char *field, size_t n, unsigned long ulo, int lea
while (--i >= 0) { while (--i >= 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
@ -240,11 +240,11 @@ static char *diag_ulonglong_to_dec(char *field, size_t n, unsigned long long ull
while (i-- > 0) { while (i-- > 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
/* this function converts a signed long long number to decimal ASCII /* this function converts a signed long long number to decimal ASCII
and pads it with space or '0' when size and leading0 are set appropriately and pads it with space or '0' when size and leading0 are set appropriately
it is async signal safe and thread safe it is async signal safe and thread safe
it returns NULL if n==0 it returns NULL if n==0
@ -272,7 +272,7 @@ static char *diag_longlong_to_dec(char *field, size_t n, long long ll, int leadi
if (size >= n) size = n-1; if (size >= n) size = n-1;
i = size - strlen(np); i = size - strlen(np);
if (leading0) { if (leading0) {
if (minus) --i; if (minus) --i;
while (--i >= 0) { while (--i >= 0) {
*--np = '0'; *--np = '0';
} }
@ -283,7 +283,7 @@ static char *diag_longlong_to_dec(char *field, size_t n, long long ll, int leadi
*--np = ' '; *--np = ' ';
} }
} }
} }
return np; return np;
} }
@ -316,7 +316,7 @@ static char *diag_ulonglong_to_hex(char *field, size_t n, unsigned long long ull
while (i-- > 0) { while (i-- > 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
@ -348,7 +348,7 @@ static char *diag_ulonglong_to_oct(char *field, size_t n, unsigned long long ull
while (--i >= 0) { while (--i >= 0) {
*--np = c; *--np = c;
} }
} }
return np; return np;
} }
@ -369,7 +369,7 @@ int vsnprintf_r(char *str, size_t size, const char *format, va_list ap) {
--size; /* without trailing \0 */ --size; /* without trailing \0 */
while (c = *format++) { while (c = *format++) {
if (c == '\\') { if (c == '\\') {
} else if (c == '%') { } else if (c == '%') {
#if HAVE_TYPE_LONGLONG #if HAVE_TYPE_LONGLONG
# define num_buff_len ((sizeof(unsigned long long)*8+2)/3+1) /* hold up to u long long in octal w/ \0 */ # define num_buff_len ((sizeof(unsigned long long)*8+2)/3+1) /* hold up to u long long in octal w/ \0 */
@ -389,7 +389,7 @@ int vsnprintf_r(char *str, size_t size, const char *format, va_list ap) {
c = *format++; c = *format++;
if (c == '\0') { break; } if (c == '\0') { break; }
/* flag characters */ /* flag characters */
switch (c) { switch (c) {
case '0': leading0 = 1; c = *format++; break; case '0': leading0 = 1; c = *format++; break;
@ -423,13 +423,13 @@ int vsnprintf_r(char *str, size_t size, const char *format, va_list ap) {
case 'h': case 'h':
lengthmod = c; lengthmod = c;
if ((c = *format++) == 'h') { if ((c = *format++) == 'h') {
lengthmod = 'H'; c = *format++; lengthmod = 'H'; c = *format++;
} }
break; break;
case 'l': case 'l':
lengthmod = c; lengthmod = c;
if ((c = *format++) == 'l') { if ((c = *format++) == 'l') {
lengthmod = 'L'; c = *format++; lengthmod = 'L'; c = *format++;
} }
break; break;
} }

View file

@ -37,7 +37,7 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
if (argc != 2) { if (argc != 2) {
Error3("\"%s:%s\": wrong number of parameters (%d instead of 1)", argv[0], argv[1], argc-1); Error3("\"%s:%s\": wrong number of parameters (%d instead of 1)", argv[0], argv[1], argc-1);
} }
retropt_bool(opts, OPT_DASH, &dash); retropt_bool(opts, OPT_DASH, &dash);
status = _xioopen_foxec(xioflags, &fd->stream, groups, &opts, &duptostderr); status = _xioopen_foxec(xioflags, &fd->stream, groups, &opts, &duptostderr);
@ -126,11 +126,17 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
Execvp(token, pargv); Execvp(token, pargv);
/* here we come only if execvp() failed */ /* here we come only if execvp() failed */
switch (pargc) { switch (pargc) {
case 1: Error3("execvp(\"%s\", \"%s\"): %s", token, pargv[0], strerror(errno)); break; case 1:
case 2: Error4("execvp(\"%s\", \"%s\", \"%s\"): %s", token, pargv[0], pargv[1], strerror(errno)); break; Error3("execvp(\"%s\", \"%s\"): %s",
token, pargv[0], strerror(errno)); break;
case 2:
Error4("execvp(\"%s\", \"%s\", \"%s\"): %s",
token, pargv[0], pargv[1], strerror(errno)); break;
case 3: case 3:
default: default:
Error5("execvp(\"%s\", \"%s\", \"%s\", \"%s\", ...): %s", token, pargv[0], pargv[1], pargv[2], strerror(errno)); break; Error5("execvp(\"%s\", \"%s\", \"%s\", \"%s\", ...): %s", token,
pargv[0], pargv[1], pargv[2], strerror(errno));
break;
} }
Exit(1); /* this child process */ Exit(1); /* this child process */
} }

View file

@ -112,7 +112,7 @@ static int xioopen_gopen(int argc, const char *argv[], struct opt *opts, int xio
applyopts_cloexec(fd->stream.fd, opts); applyopts_cloexec(fd->stream.fd, opts);
} }
if ((result = applyopts2(fd->stream.fd, opts, PH_PASTSOCKET, PH_CONNECTED)) < 0) if ((result = applyopts2(fd->stream.fd, opts, PH_PASTSOCKET, PH_CONNECTED)) < 0)
return result; return result;
if ((result = _xio_openlate(&fd->stream, opts)) < 0) if ((result = _xio_openlate(&fd->stream, opts)) < 0)

View file

@ -187,7 +187,7 @@ int xiogetaddrinfo(const char *node, const char *service,
Warn2("xiogetaddrinfo(, \"%s\", ...): extra trailing data \"%s\"", Warn2("xiogetaddrinfo(, \"%s\", ...): extra trailing data \"%s\"",
service, extra); service, extra);
} }
service = NULL; service = NULL;
} }
/* the resolver functions might handle numeric forms of node names by /* the resolver functions might handle numeric forms of node names by
@ -448,7 +448,7 @@ int xiogetaddrinfo(const char *node, const char *service,
case PF_INET6: sau->ip6.sin6_port = port; break; case PF_INET6: sau->ip6.sin6_port = port; break;
#endif /* WITH_IP6 */ #endif /* WITH_IP6 */
} }
} }
#endif /* WITH_TCP || WITH_UDP */ #endif /* WITH_TCP || WITH_UDP */
if (numnode) free(numnode); if (numnode) free(numnode);
@ -506,7 +506,7 @@ int xiolog_ancillary_ip(struct cmsghdr *cmsg, int *num,
*num = 3; *num = 3;
typbuff[0] = '\0'; strncat(typbuff, "IP_PKTINFO", typlen-1); typbuff[0] = '\0'; strncat(typbuff, "IP_PKTINFO", typlen-1);
snprintf(nambuff, namlen, "%s%c%s%c%s", "if", '\0', "locaddr", '\0', "dstaddr"); snprintf(nambuff, namlen, "%s%c%s%c%s", "if", '\0', "locaddr", '\0', "dstaddr");
snprintf(envbuff, envlen, "%s%c%s%c%s", "IP_IF", '\0', snprintf(envbuff, envlen, "%s%c%s%c%s", "IP_IF", '\0',
"IP_LOCADDR", '\0', "IP_DSTADDR"); "IP_LOCADDR", '\0', "IP_DSTADDR");
snprintf(valbuff, vallen, "%s%c%s%c%s", snprintf(valbuff, vallen, "%s%c%s%c%s",
xiogetifname(pktinfo->ipi_ifindex, scratch1, -1), '\0', xiogetifname(pktinfo->ipi_ifindex, scratch1, -1), '\0',

View file

@ -228,7 +228,7 @@ int xiocheckrange_ip6(struct sockaddr_in6 *pa, struct xiorange *range) {
masked.u6_addr32[1] != rangeaddr->u6_addr32[1] || masked.u6_addr32[1] != rangeaddr->u6_addr32[1] ||
masked.u6_addr32[2] != rangeaddr->u6_addr32[2] || masked.u6_addr32[2] != rangeaddr->u6_addr32[2] ||
masked.u6_addr32[3] != rangeaddr->u6_addr32[3]) { masked.u6_addr32[3] != rangeaddr->u6_addr32[3]) {
Debug1("client address %s is not permitted", peername); Debug1("client address %s is not permitted", peername);
return -1; return -1;
} }
return 0; return 0;

View file

@ -85,7 +85,7 @@ int applyopts_named(const char *filename, struct opt *opts, unsigned int phase)
} }
/* perform actions that are common to all NAMED group addresses: checking if /* perform actions that are common to all NAMED group addresses: checking if
the entry exists, parsing options, ev.removing old filesystem entry or the entry exists, parsing options, ev.removing old filesystem entry or
setting early owners and permissions. setting early owners and permissions.
It applies options of PH_EARLY and PH_PREOPEN. It applies options of PH_EARLY and PH_PREOPEN.

View file

@ -21,7 +21,7 @@
#include "xio-openssl.h" #include "xio-openssl.h"
/* the openssl library requires a file descriptor for external communications. /* the openssl library requires a file descriptor for external communications.
so our best effort is to provide any possible kind of un*x file descriptor so our best effort is to provide any possible kind of un*x file descriptor
(not only tcp, but also pipes, stdin, files...) (not only tcp, but also pipes, stdin, files...)
for tcp we want to provide support for socks and proxy. for tcp we want to provide support for socks and proxy.
read and write functions must use the openssl crypt versions. read and write functions must use the openssl crypt versions.
@ -261,7 +261,7 @@ static int
retropt_bool(opts, OPT_OPENSSL_NO_SNI, &opt_no_sni); retropt_bool(opts, OPT_OPENSSL_NO_SNI, &opt_no_sni);
retropt_string(opts, OPT_OPENSSL_SNIHOST, (char **)&opt_snihost); retropt_string(opts, OPT_OPENSSL_SNIHOST, (char **)&opt_snihost);
#endif #endif
if (opt_commonname == NULL) { if (opt_commonname == NULL) {
opt_commonname = strdup(hostname); opt_commonname = strdup(hostname);
if (opt_commonname == NULL) { if (opt_commonname == NULL) {
@ -530,7 +530,7 @@ static int
#else #else
pf = PF_INET; pf = PF_INET;
#endif #endif
portname = argv[1]; portname = argv[1];
xfd->howtoend = END_SHUTDOWN; xfd->howtoend = END_SHUTDOWN;
@ -1643,7 +1643,7 @@ static bool openssl_check_peername(X509_NAME *name, const char *peername) {
const unsigned char *text; const unsigned char *text;
ind = X509_NAME_get_index_by_NID(name, NID_commonName, -1); ind = X509_NAME_get_index_by_NID(name, NID_commonName, -1);
if (ind < 0) { if (ind < 0) {
Info("no COMMONNAME field in peer certificate"); Info("no COMMONNAME field in peer certificate");
return false; return false;
} }
entry = X509_NAME_get_entry(name, ind); entry = X509_NAME_get_entry(name, ind);
@ -1740,7 +1740,7 @@ static int openssl_handle_peer_certificate(struct single *xfd,
extstr = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext))); extstr = OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(ext)));
if (!strcasecmp(extstr, "subjectAltName")) { if (!strcasecmp(extstr, "subjectAltName")) {
void *names; void *names;
if (!(meth = X509V3_EXT_get(ext))) break; if (!(meth = X509V3_EXT_get(ext))) break;
names = X509_get_ext_d2i(peer_cert, NID_subject_alt_name, NULL, NULL); names = X509_get_ext_d2i(peer_cert, NID_subject_alt_name, NULL, NULL);
if (names) { if (names) {
int numalts; int numalts;

View file

@ -484,7 +484,7 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
/*0 Info2("dup(%d) -> %d", rdpip[1], tmpo);*/ /*0 Info2("dup(%d) -> %d", rdpip[1], tmpo);*/
wrpip[0] = tmpo; wrpip[0] = tmpo;
} }
if (rw != XIO_WRONLY && rdpip[1] != fdo) { if (rw != XIO_WRONLY && rdpip[1] != fdo) {
/* make sure that the internal diagnostic socket pair fds do not conflict /* make sure that the internal diagnostic socket pair fds do not conflict
with our choices */ with our choices */

View file

@ -220,7 +220,7 @@ static int xioopen_proxy_connect(int argc, const char *argv[], struct opt *opts,
{ {
break; break;
} }
} while (true); /* end of complete open loop - drop out on success */ } while (true); /* end of complete open loop - drop out on success */
Notice4("successfully connected to %s:%u via proxy %s:%s", Notice4("successfully connected to %s:%u via proxy %s:%s",
@ -258,7 +258,7 @@ int _xioopen_proxy_prepare(struct proxyvars *proxyvars, struct opt *opts,
Error2("open(\"%s\", O_RDONLY): %s", proxyvars->authfile, strerror(errno)); Error2("open(\"%s\", O_RDONLY): %s", proxyvars->authfile, strerror(errno));
return STAT_NORETRY; return STAT_NORETRY;
} }
/* go to the end of our proxy auth file to /* go to the end of our proxy auth file to
figure out how long our proxy auth is */ figure out how long our proxy auth is */
if ((length = Lseek(authfd, 0, SEEK_END)) < 0) { if ((length = Lseek(authfd, 0, SEEK_END)) < 0) {
Error2("lseek(<%s>, 0, SEEK_END): %s", Error2("lseek(<%s>, 0, SEEK_END): %s",
@ -323,7 +323,7 @@ int _xioopen_proxy_connect(struct single *xfd,
int rv; int rv;
char buff[BUFLEN+1]; /* for receiving HTTP reply headers */ char buff[BUFLEN+1]; /* for receiving HTTP reply headers */
#if CONNLEN > BUFLEN #if CONNLEN > BUFLEN
#error not enough buffer space #error not enough buffer space
#endif #endif
char textbuff[2*BUFLEN+1]; /* just for sanitizing print data */ char textbuff[2*BUFLEN+1]; /* just for sanitizing print data */
char *eol = buff; char *eol = buff;
@ -410,7 +410,7 @@ int _xioopen_proxy_connect(struct single *xfd,
state = XIOSTATE_ERROR; state = XIOSTATE_ERROR;
break; /* leave read cycles */ break; /* leave read cycles */
} }
switch (state) { switch (state) {
case XIOSTATE_HTTP1: case XIOSTATE_HTTP1:
@ -448,7 +448,7 @@ int _xioopen_proxy_connect(struct single *xfd,
} }
state = XIOSTATE_HTTP4; state = XIOSTATE_HTTP4;
break; break;
case XIOSTATE_HTTP4: case XIOSTATE_HTTP4:
/* within header */ /* within header */
if (*(buff+offset) == '\r') { if (*(buff+offset) == '\r') {
@ -564,7 +564,7 @@ int _xioopen_proxy_connect(struct single *xfd,
*/ */
ptr += 3; ptr += 3;
while (*ptr == ' ') ++ptr; while (*ptr == ' ') ++ptr;
Msg2(level, "%s: %s", request, ptr); Msg2(level, "%s: %s", request, ptr);
return STAT_RETRYLATER; return STAT_RETRYLATER;
} }

View file

@ -43,7 +43,7 @@ static int xioopen_pty(int argc, const char *argv[], struct opt *opts, int xiofl
bool opt_unlink_close = true; /* remove symlink afterwards */ bool opt_unlink_close = true; /* remove symlink afterwards */
bool wait_slave = false; /* true would be better for many platforms, but bool wait_slave = false; /* true would be better for many platforms, but
some OSes cannot handle this, and for common some OSes cannot handle this, and for common
default behaviour as well as backward default behaviour as well as backward
compatibility we choose "no" as default */ compatibility we choose "no" as default */
struct timespec pollintv = { PTY_INTERVALL }; struct timespec pollintv = { PTY_INTERVALL };

View file

@ -82,7 +82,7 @@ int xioopen_rawip_sendto(int argc, const char *argv[], struct opt *opts,
} }
/* /*
applies and consumes the following options: applies and consumes the following options:
PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECTED, PH_LATE PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECTED, PH_LATE
OFUNC_OFFSET OFUNC_OFFSET
OPT_PROTOCOL_FAMILY, OPT_BIND, OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER, OPT_PROTOCOL_FAMILY, OPT_BIND, OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER,

View file

@ -51,7 +51,7 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
int dummy1, int socktype, int dummy3); int dummy1, int socktype, int dummy3);
static static
int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts, int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
int xioflags, xiofile_t *xfd, unsigned groups, int xioflags, xiofile_t *xfd, unsigned groups,
int dumy1, int dummy2, int dummy3); int dumy1, int dummy2, int dummy3);
static static
@ -257,7 +257,7 @@ int xioopen_socket_connect(int argc, const char *argv[], struct opt *opts,
Error1("data too long: \"%s\"", address); Error1("data too long: \"%s\"", address);
} else if (result > 0) { } else if (result > 0) {
Error1("syntax error in \"%s\"", address); Error1("syntax error in \"%s\"", address);
} }
them.soa.sa_family = pf; them.soa.sa_family = pf;
themlen = themsize + themlen = themsize +
#if HAVE_STRUCT_SOCKADDR_SALEN #if HAVE_STRUCT_SOCKADDR_SALEN
@ -522,7 +522,7 @@ int xioopen_socket_recvfrom(int argc, const char *argv[], struct opt *opts,
Error1("data too long: \"%s\"", address); Error1("data too long: \"%s\"", address);
} else if (result > 0) { } else if (result > 0) {
Error1("syntax error in \"%s\"", address); Error1("syntax error in \"%s\"", address);
} }
us->soa.sa_family = pf; us->soa.sa_family = pf;
uslen = ussize + sizeof(us->soa.sa_family) uslen = ussize + sizeof(us->soa.sa_family)
#if HAVE_STRUCT_SOCKADDR_SALEN #if HAVE_STRUCT_SOCKADDR_SALEN
@ -599,7 +599,7 @@ int xioopen_socket_recv(int argc, const char *argv[], struct opt *opts,
Error1("data too long: \"%s\"", address); Error1("data too long: \"%s\"", address);
} else if (result > 0) { } else if (result > 0) {
Error1("syntax error in \"%s\"", address); Error1("syntax error in \"%s\"", address);
} }
us.soa.sa_family = pf; us.soa.sa_family = pf;
uslen = ussize + sizeof(sa_family_t) uslen = ussize + sizeof(sa_family_t)
#if HAVE_STRUCT_SOCKADDR_SALEN #if HAVE_STRUCT_SOCKADDR_SALEN
@ -751,10 +751,10 @@ int xiogetpacketinfo(int fd)
/* A subroutine that is common to all socket addresses that want to connect() /* A subroutine that is common to all socket addresses that want to connect()
a socket to a peer. a socket to a peer.
Applies and consumes the following options: Applies and consumes the following options:
PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECT, PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECT,
PH_CONNECTED, PH_LATE, PH_CONNECTED, PH_LATE,
OFUNC_OFFSET, OFUNC_OFFSET,
OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER, OPT_GROUP, OPT_CLOEXEC OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER, OPT_GROUP, OPT_CLOEXEC
Does not fork, does not retry. Does not fork, does not retry.
returns 0 on success. returns 0 on success.
@ -777,7 +777,7 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
#endif #endif
if ((xfd->fd = xiosocket(opts, pf, socktype, protocol, level)) < 0) { if ((xfd->fd = xiosocket(opts, pf, socktype, protocol, level)) < 0) {
return STAT_RETRYLATER; return STAT_RETRYLATER;
} }
applyopts_offset(xfd, opts); applyopts_offset(xfd, opts);
@ -923,7 +923,7 @@ int _xioopen_connect(struct single *xfd, union sockaddr_union *us, size_t uslen,
applies and consumes the following option: applies and consumes the following option:
PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECT, PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_CONNECT,
PH_CONNECTED, PH_LATE, PH_CONNECTED, PH_LATE,
OFUNC_OFFSET, OFUNC_OFFSET,
OPT_FORK, OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER, OPT_GROUP, OPT_CLOEXEC OPT_FORK, OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_USER, OPT_GROUP, OPT_CLOEXEC
returns 0 on success. returns 0 on success.
*/ */
@ -1042,7 +1042,7 @@ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
#endif #endif
if ((xfd->fd = xiosocket(opts, pf, socktype, ipproto, level)) < 0) { if ((xfd->fd = xiosocket(opts, pf, socktype, ipproto, level)) < 0) {
return STAT_RETRYLATER; return STAT_RETRYLATER;
} }
applyopts_offset(xfd, opts); applyopts_offset(xfd, opts);
@ -1187,7 +1187,7 @@ void xiosigaction_hasread(int signum
This function does not retry. If you need retries, handle this is a This function does not retry. If you need retries, handle this is a
loop in the calling function. loop in the calling function.
after fork, we set the forever/retry of the child process to 0 after fork, we set the forever/retry of the child process to 0
applies and consumes the following options: applies and consumes the following options:
PH_INIT, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_EARLY, PH_PREOPEN, PH_FD, PH_INIT, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_EARLY, PH_PREOPEN, PH_FD,
PH_CONNECTED, PH_LATE, PH_LATE2 PH_CONNECTED, PH_LATE, PH_LATE2
OPT_FORK, OPT_SO_TYPE, OPT_SO_PROTOTYPE, cloexec, OPT_RANGE, tcpwrap OPT_FORK, OPT_SO_TYPE, OPT_SO_PROTOTYPE, cloexec, OPT_RANGE, tcpwrap
@ -1967,7 +1967,7 @@ int xioparsenetwork(const char *rangename, int pf, struct xiorange *range) {
Error1("syntax error in \"%s\"", addrname); Error1("syntax error in \"%s\"", addrname);
free(addrname); return STAT_NORETRY; free(addrname); return STAT_NORETRY;
} }
free(addrname); free(addrname);
result = result =
dalan(maskname, (uint8_t *)&range->netmask.soa.sa_data, &masklen, dalan(maskname, (uint8_t *)&range->netmask.soa.sa_data, &masklen,
sizeof(range->netaddr)-(size_t)(&((struct sockaddr *)0)->sa_data) sizeof(range->netaddr)-(size_t)(&((struct sockaddr *)0)->sa_data)
@ -1998,7 +1998,7 @@ int xioparsenetwork(const char *rangename, int pf, struct xiorange *range) {
} }
/* parses a string of form address/bits or address:mask, and fills the fields /* parses a string of form address/bits or address:mask, and fills the fields
of the range union. The addr component is masked with mask. */ of the range union. The addr component is masked with mask. */
int xioparserange(const char *rangename, int pf, struct xiorange *range) { int xioparserange(const char *rangename, int pf, struct xiorange *range) {
int i; int i;
@ -2031,10 +2031,10 @@ int xioparserange(const char *rangename, int pf, struct xiorange *range) {
} }
/* set environment variables describing (part of) a socket address, e.g. /* set environment variables describing (part of) a socket address, e.g.
SOCAT_SOCKADDR. lr (local/remote) specifies a string like "SOCK" or "PEER". SOCAT_SOCKADDR. lr (local/remote) specifies a string like "SOCK" or "PEER".
proto should correspond to the third parameter of socket(2) and is used to proto should correspond to the third parameter of socket(2) and is used to
determine the presence of port information. */ determine the presence of port information. */
int xiosetsockaddrenv(const char *lr, int xiosetsockaddrenv(const char *lr,
union sockaddr_union *sau, socklen_t salen, union sockaddr_union *sau, socklen_t salen,
int proto) { int proto) {
@ -2064,7 +2064,7 @@ int xiosetsockaddrenv(const char *lr,
xiosetenv(namebuff, valuebuff, 1, NULL); xiosetenv(namebuff, valuebuff, 1, NULL);
namebuff[strlen(lr)] = '\0'; ++idx; namebuff[strlen(lr)] = '\0'; ++idx;
} while (result > 0); } while (result > 0);
break; break;
#endif /* WITH_IP4 */ #endif /* WITH_IP4 */
#if WITH_IP6 #if WITH_IP6
case PF_INET6: case PF_INET6:
@ -2111,7 +2111,7 @@ int xiosetsockaddrenv(const char *lr,
/* retrieves options so-type and so-prototype from opts, calls socket, and /* retrieves options so-type and so-prototype from opts, calls socket, and
ev. generates an appropriate error message. ev. generates an appropriate error message.
returns 0 on success or -1 if an error occurred. */ returns 0 on success or -1 if an error occurred. */
int int
xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) { xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) {
int result; int result;
@ -2131,7 +2131,7 @@ xiosocket(struct opt *opts, int pf, int socktype, int proto, int msglevel) {
/* retrieves options so-type and so-prototype from opts, calls socketpair, and /* retrieves options so-type and so-prototype from opts, calls socketpair, and
ev. generates an appropriate error message. ev. generates an appropriate error message.
returns 0 on success or -1 if an error occurred. */ returns 0 on success or -1 if an error occurred. */
int int
xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]) { xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]) {
int result; int result;

View file

@ -97,7 +97,7 @@ extern int _xioopen_connect(struct single *fd,
bool alt, int level); bool alt, int level);
/* common to xioopen_udp_sendto, ..unix_sendto, ..rawip */ /* common to xioopen_udp_sendto, ..unix_sendto, ..rawip */
extern extern
int _xioopen_dgram_sendto(/* them is already in xfd->peersa */ int _xioopen_dgram_sendto(/* them is already in xfd->peersa */
union sockaddr_union *us, socklen_t uslen, union sockaddr_union *us, socklen_t uslen,
struct opt *opts, struct opt *opts,
@ -115,7 +115,7 @@ int _xioopen_dgram_recv(struct single *xfd, int xioflags,
int level); int level);
extern extern
int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv); int xiodopacketinfo(struct msghdr *msgh, bool withlog, bool withenv);
extern extern
int xiogetpacketsrc(int fd, struct msghdr *msgh, int flags); int xiogetpacketsrc(int fd, struct msghdr *msgh, int flags);
extern extern
int xiocheckpeer(xiosingle_t *xfd, int xiocheckpeer(xiosingle_t *xfd,
@ -126,12 +126,12 @@ int xiosetsockaddrenv(const char *lr, union sockaddr_union *sau, socklen_t salen
extern extern
int xioparsenetwork(const char *rangename, int pf, int xioparsenetwork(const char *rangename, int pf,
struct xiorange *range); struct xiorange *range);
extern extern
int xioparserange(const char *rangename, int pf, struct xiorange *range); int xioparserange(const char *rangename, int pf, struct xiorange *range);
extern int extern int
xiosocket(struct opt *opts, int pf, int socktype, int proto, int level); xiosocket(struct opt *opts, int pf, int socktype, int proto, int level);
extern int extern int
xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]); xiosocketpair(struct opt *opts, int pf, int socktype, int proto, int sv[2]);
#endif /* !defined(__xio_socket_h_included) */ #endif /* !defined(__xio_socket_h_included) */

View file

@ -3,7 +3,7 @@
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* when including this file select one part that you need by defining the /* when including this file select one part that you need by defining the
appropriate CPP define: appropriate CPP define:
(none): standard define, variable, and function declarations (none): standard define, variable, and function declarations
ENABLE_OPTCODE: option codes for use in enum e_optcode ENABLE_OPTCODE: option codes for use in enum e_optcode

View file

@ -125,7 +125,7 @@ int xio_tcpwrap_check(xiosingle_t *xfd, union sockaddr_union *us,
if (inet_ntop(us->soa.sa_family, if (inet_ntop(us->soa.sa_family,
#if WITH_IP6 #if WITH_IP6
us->soa.sa_family==PF_INET6 ? us->soa.sa_family==PF_INET6 ?
(void *)&us->ip6.sin6_addr : (void *)&us->ip6.sin6_addr :
#endif #endif
(void *)&us->ip4.sin_addr, (void *)&us->ip4.sin_addr,
serveraddr, sizeof(serveraddr)) == NULL) { serveraddr, sizeof(serveraddr)) == NULL) {

View file

@ -520,7 +520,7 @@ int xioopen_udp_recvfrom(int argc, const char *argv[], struct opt *opts,
{ {
union sockaddr_union la; union sockaddr_union la;
socklen_t lalen = sizeof(la); socklen_t lalen = sizeof(la);
if (retropt_bind(opts, pf, socktype, ipproto, &la.soa, &lalen, 1, if (retropt_bind(opts, pf, socktype, ipproto, &la.soa, &lalen, 1,
xfd->stream.para.socket.ip.res_opts[0], xfd->stream.para.socket.ip.res_opts[0],
xfd->stream.para.socket.ip.res_opts[1]) xfd->stream.para.socket.ip.res_opts[1])
@ -594,7 +594,7 @@ int xioopen_udp_recv(int argc, const char *argv[], struct opt *opts,
{ {
union sockaddr_union la; union sockaddr_union la;
socklen_t lalen = sizeof(la); socklen_t lalen = sizeof(la);
if (retropt_bind(opts, pf, socktype, ipproto, if (retropt_bind(opts, pf, socktype, ipproto,
&xfd->stream.para.socket.la.soa, &lalen, 1, &xfd->stream.para.socket.la.soa, &lalen, 1,
xfd->stream.para.socket.ip.res_opts[0], xfd->stream.para.socket.ip.res_opts[0],

View file

@ -17,7 +17,7 @@
/* to avoid unneccessary runtime if () conditionals when no abstract support is /* to avoid unneccessary runtime if () conditionals when no abstract support is
compiled in (or at least to give optimizing compilers a good chance) we need compiled in (or at least to give optimizing compilers a good chance) we need
a constant that can be used in C expressions */ a constant that can be used in C expressions */
#if WITH_ABSTRACT_UNIXSOCKET #if WITH_ABSTRACT_UNIXSOCKET
# define ABSTRACT 1 # define ABSTRACT 1
#else #else
@ -589,7 +589,7 @@ static int xioopen_unix_client(int argc, const char *argv[], struct opt *opts, i
Error2("%s: wrong number of parameters (%d instead of 1)", argv[0], argc-1); Error2("%s: wrong number of parameters (%d instead of 1)", argv[0], argc-1);
} }
return return
_xioopen_unix_client(&xxfd->stream, xioflags, groups, abstract, opts, _xioopen_unix_client(&xxfd->stream, xioflags, groups, abstract, opts,
argv[1]); argv[1]);
} }
@ -600,11 +600,11 @@ static int xioopen_unix_client(int argc, const char *argv[], struct opt *opts, i
applies and consumes the following option: applies and consumes the following option:
PH_INIT, PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND, PH_INIT, PH_PASTSOCKET, PH_FD, PH_PREBIND, PH_BIND, PH_PASTBIND,
PH_CONNECTED, PH_LATE, ?PH_CONNECT PH_CONNECTED, PH_LATE, ?PH_CONNECT
OFUNC_OFFSET, OFUNC_OFFSET,
OPT_PROTOCOL_FAMILY, OPT_UNIX_TIGHTSOCKLEN, OPT_UNLINK_CLOSE, OPT_BIND, OPT_PROTOCOL_FAMILY, OPT_UNIX_TIGHTSOCKLEN, OPT_UNLINK_CLOSE, OPT_BIND,
OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_CLOEXEC, OPT_USER, OPT_GROUP, ?OPT_FORK, OPT_SO_TYPE, OPT_SO_PROTOTYPE, OPT_CLOEXEC, OPT_USER, OPT_GROUP, ?OPT_FORK,
*/ */
int int
_xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups, _xioopen_unix_client(xiosingle_t *xfd, int xioflags, unsigned groups,
int abstract, struct opt *opts, const char *name) { int abstract, struct opt *opts, const char *name) {
const struct opt *namedopt; const struct opt *namedopt;

6
xio.h
View file

@ -132,7 +132,7 @@ struct para_ip {
} ; } ;
#endif /* _WITH_IP4 || _WITH_IP6 */ #endif /* _WITH_IP4 || _WITH_IP6 */
/* a non-dual file descriptor */ /* a non-dual file descriptor */
typedef struct single { typedef struct single {
enum xiotag tag; /* see enum xiotag */ enum xiotag tag; /* see enum xiotag */
const struct addrdesc *addr; const struct addrdesc *addr;
@ -145,7 +145,7 @@ typedef struct single {
#endif /* WITH_RETRY */ #endif /* WITH_RETRY */
bool ignoreeof; /* option ignoreeof; do not pass eof condition to app*/ bool ignoreeof; /* option ignoreeof; do not pass eof condition to app*/
int eof; /* 1..exec'd child has died, but no explicit eof int eof; /* 1..exec'd child has died, but no explicit eof
occurred occurred
2..fd0 has reached EOF, but check for ignoreeof 2..fd0 has reached EOF, but check for ignoreeof
3..fd0 has reached EOF (definitely; never with 3..fd0 has reached EOF (definitely; never with
ignoreeof! */ ignoreeof! */
@ -360,7 +360,7 @@ union integral {
#if HAVE_STRUCT_LINGER #if HAVE_STRUCT_LINGER
struct linger u_linger; struct linger u_linger;
#endif /* HAVE_STRUCT_LINGER */ #endif /* HAVE_STRUCT_LINGER */
#if HAVE_STRUCT_TIMESPEC #if HAVE_STRUCT_TIMESPEC
struct timespec u_timespec; struct timespec u_timespec;
#endif /* HAVE_STRUCT_TIMESPEC */ #endif /* HAVE_STRUCT_TIMESPEC */
#if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IP_MREQN #if HAVE_STRUCT_IP_MREQ || HAVE_STRUCT_IP_MREQN

View file

@ -85,7 +85,7 @@ int xioclose1(struct single *pipe) {
if (pipe->havelock) { if (pipe->havelock) {
xiounlock(pipe->lock.lockfile); xiounlock(pipe->lock.lockfile);
pipe->havelock = false; pipe->havelock = false;
} }
if (pipe->opt_unlink_close && pipe->unlink_close) { if (pipe->opt_unlink_close && pipe->unlink_close) {
if (Unlink(pipe->unlink_close) < 0) { if (Unlink(pipe->unlink_close) < 0) {
Info2("unlink(\"%s\"): %s", pipe->unlink_close, strerror(errno)); Info2("unlink(\"%s\"): %s", pipe->unlink_close, strerror(errno));

View file

@ -11,7 +11,7 @@
/* this function closes all open xio sockets on exit, if they are still open. /* this function closes all open xio sockets on exit, if they are still open.
It must be registered with atexit(). */ It must be registered with atexit(). */
void xioexit(void) { void xioexit(void) {
int i; int i;

View file

@ -59,7 +59,7 @@ static char *optionphasenames[] = {
"PRESOCKET", "SOCKET", "PASTSOCKET", "PRESOCKET", "SOCKET", "PASTSOCKET",
"PREBIGEN", "BIGEN", "PASTBIGEN", "PREBIGEN", "BIGEN", "PASTBIGEN",
"FD", "FD",
"PREBIND", "BIND", "PASTBIND", "PREBIND", "BIND", "PASTBIND",
"PRELISTEN", "LISTEN", "PASTLISTEN", "PRELISTEN", "LISTEN", "PASTLISTEN",
"PRECONNECT", "CONNECT", "PASTCONNECT", "PRECONNECT", "CONNECT", "PASTCONNECT",
"PREACCEPT", "ACCEPT", "PASTACCEPT", "PREACCEPT", "ACCEPT", "PASTACCEPT",

View file

@ -49,7 +49,7 @@ int xiogetlock(const char *lockfile) {
Error2("mkstemp(\"%s\"): %s", s, strerror(errno)); Error2("mkstemp(\"%s\"): %s", s, strerror(errno));
return -1; return -1;
} }
pid = Getpid(); pid = Getpid();
bytes = sprintf(pidbuf, F_pid"\n", pid); bytes = sprintf(pidbuf, F_pid"\n", pid);
if (writefull(fd, pidbuf, bytes) < 0) { if (writefull(fd, pidbuf, bytes) < 0) {

View file

@ -608,7 +608,7 @@ int xioopen_single(xiofile_t *xfd, int xioflags) {
xfd->stream.flags |= (xioflags & XIO_ACCMODE); xfd->stream.flags |= (xioflags & XIO_ACCMODE);
addrdesc = xfd->stream.addr; addrdesc = xfd->stream.addr;
result = (*addrdesc->func)(xfd->stream.argc, xfd->stream.argv, result = (*addrdesc->func)(xfd->stream.argc, xfd->stream.argv,
xfd->stream.opts, xioflags, xfd, xfd->stream.opts, xioflags, xfd,
addrdesc->groups, addrdesc->arg1, addrdesc->groups, addrdesc->arg1,
addrdesc->arg2, addrdesc->arg3); addrdesc->arg2, addrdesc->arg3);
return result; return result;

View file

@ -20,37 +20,37 @@ bool xioopts_ignoregroups;
#if WITH_NAMED #if WITH_NAMED
# define IF_NAMED(a,b) {a,b}, # define IF_NAMED(a,b) {a,b},
#else #else
# define IF_NAMED(a,b) # define IF_NAMED(a,b)
#endif #endif
#if WITH_PIPE || WITH_GOPEN #if WITH_PIPE || WITH_GOPEN
# define IF_OPEN(a,b) {a,b}, # define IF_OPEN(a,b) {a,b},
#else #else
# define IF_OPEN(a,b) # define IF_OPEN(a,b)
#endif #endif
#if WITH_TERMIOS #if WITH_TERMIOS
# define IF_TERMIOS(a,b) {a,b}, # define IF_TERMIOS(a,b) {a,b},
#else #else
# define IF_TERMIOS(a,b) # define IF_TERMIOS(a,b)
#endif #endif
#if WITH_EXEC #if WITH_EXEC
# define IF_EXEC(a,b) {a,b}, # define IF_EXEC(a,b) {a,b},
#else #else
# define IF_EXEC(a,b) # define IF_EXEC(a,b)
#endif #endif
#if _WITH_SOCKET #if _WITH_SOCKET
# define IF_SOCKET(a,b) {a,b}, # define IF_SOCKET(a,b) {a,b},
#else #else
# define IF_SOCKET(a,b) # define IF_SOCKET(a,b)
#endif #endif
#if WITH_LISTEN #if WITH_LISTEN
# define IF_LISTEN(a,b) {a,b}, # define IF_LISTEN(a,b) {a,b},
#else #else
# define IF_LISTEN(a,b) # define IF_LISTEN(a,b)
#endif #endif
#if (WITH_UDP || WITH_TCP) && WITH_LISTEN #if (WITH_UDP || WITH_TCP) && WITH_LISTEN
@ -62,49 +62,49 @@ bool xioopts_ignoregroups;
#if WITH_IP4 || WITH_IP6 #if WITH_IP4 || WITH_IP6
# define IF_IP(a,b) {a,b}, # define IF_IP(a,b) {a,b},
#else #else
# define IF_IP(a,b) # define IF_IP(a,b)
#endif #endif
#if WITH_IP6 #if WITH_IP6
# define IF_IP6(a,b) {a,b}, # define IF_IP6(a,b) {a,b},
#else #else
# define IF_IP6(a,b) # define IF_IP6(a,b)
#endif #endif
#if WITH_TCP|WITH_UDP #if WITH_TCP|WITH_UDP
# define IF_IPAPP(a,b) {a,b}, # define IF_IPAPP(a,b) {a,b},
#else #else
# define IF_IPAPP(a,b) # define IF_IPAPP(a,b)
#endif #endif
#if WITH_TCP #if WITH_TCP
# define IF_TCP(a,b) {a,b}, # define IF_TCP(a,b) {a,b},
#else #else
# define IF_TCP(a,b) # define IF_TCP(a,b)
#endif #endif
#if WITH_UDP #if WITH_UDP
# define IF_UDP(a,b) {a,b}, # define IF_UDP(a,b) {a,b},
#else #else
# define IF_UDP(a,b) # define IF_UDP(a,b)
#endif #endif
#if WITH_SCTP #if WITH_SCTP
# define IF_SCTP(a,b) {a,b}, # define IF_SCTP(a,b) {a,b},
#else #else
# define IF_SCTP(a,b) # define IF_SCTP(a,b)
#endif #endif
#if WITH_SOCKS4 #if WITH_SOCKS4
# define IF_SOCKS4(a,b) {a,b}, # define IF_SOCKS4(a,b) {a,b},
#else #else
# define IF_SOCKS4(a,b) # define IF_SOCKS4(a,b)
#endif #endif
#if WITH_PROXY #if WITH_PROXY
# define IF_PROXY(a,b) {a,b}, # define IF_PROXY(a,b) {a,b},
#else #else
# define IF_PROXY(a,b) # define IF_PROXY(a,b)
#endif #endif
#if WITH_READLINE #if WITH_READLINE
@ -140,7 +140,7 @@ bool xioopts_ignoregroups;
#if WITH_RETRY #if WITH_RETRY
# define IF_RETRY(a,b) {a,b}, # define IF_RETRY(a,b) {a,b},
#else #else
# define IF_RETRY(a,b) # define IF_RETRY(a,b)
#endif #endif
@ -1003,7 +1003,7 @@ const struct optname optionnames[] = {
#ifdef O_NOFOLLOW #ifdef O_NOFOLLOW
IF_OPEN ("nofollow", &opt_o_nofollow) IF_OPEN ("nofollow", &opt_o_nofollow)
#endif #endif
IF_EXEC ("nofork", &opt_nofork) IF_EXEC ("nofork", &opt_nofork)
#ifdef O_NOINHERIT #ifdef O_NOINHERIT
IF_ANY ("noinherit", &opt_o_noinherit) IF_ANY ("noinherit", &opt_o_noinherit)
#endif #endif
@ -1843,20 +1843,20 @@ const struct optname optionnames[] = {
} ; } ;
/* walks the text argument a and writes its options that conform to groups /* walks the text argument a and writes its options that conform to groups
to the array opts. Uses the option table 'optionnames'. to the array opts. Uses the option table 'optionnames'.
returns 0 on success, -1 on error, 1 on unknown/wrong option returns 0 on success, -1 on error, 1 on unknown/wrong option
*/ */
int parseopts(const char **a, unsigned int groups, struct opt **opts) { int parseopts(const char **a, unsigned int groups, struct opt **opts) {
return parseopts_table(a, groups, opts, optionnames, return parseopts_table(a, groups, opts, optionnames,
sizeof(optionnames)/sizeof(struct optname)-1); sizeof(optionnames)/sizeof(struct optname)-1);
} }
/* walks the text argument a and writes its options that conform to groups /* walks the text argument a and writes its options that conform to groups
to the array opts. Uses the specified option table. to the array opts. Uses the specified option table.
returns 0 on success, -1 on error, 1 on unknown/wrong option returns 0 on success, -1 on error, 1 on unknown/wrong option
*/ */
int parseopts_table(const char **a, unsigned int groups, struct opt **opts, int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
const struct optname optionnames[], size_t optionnum) { const struct optname optionnames[], size_t optionnum) {
@ -1956,7 +1956,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
#endif #endif
} }
(*opts)[i].desc = ent->desc; (*opts)[i].desc = ent->desc;
if (!strncmp(*a, assign_str, strlen(assign_str))) { if (!strncmp(*a, assign_str, strlen(assign_str))) {
/* there is an assignment (mostly "=") */ /* there is an assignment (mostly "=") */
(*a) += strlen(assign_str); (*a) += strlen(assign_str);
@ -2211,7 +2211,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
#if LATER #if LATER
case TYPE_INT3: case TYPE_INT3:
break; break;
#endif #endif
@ -2525,7 +2525,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
*buffp++ = '\0'; *buffp++ = '\0';
(*opts)[i].value.u_ip_mreq.param2 = strdup(buff); /*!!! NULL */ (*opts)[i].value.u_ip_mreq.param2 = strdup(buff); /*!!! NULL */
#if HAVE_STRUCT_IP_MREQN #if HAVE_STRUCT_IP_MREQN
if (*tokp++ == ':') { if (*tokp++ == ':') {
strncpy((*opts)[i].value.u_ip_mreq.ifindex, tokp, IF_NAMESIZE); /* ok */ strncpy((*opts)[i].value.u_ip_mreq.ifindex, tokp, IF_NAMESIZE); /* ok */
Info4("setting option \"%s\" to {\"%s\",\"%s\",\"%s\"}", Info4("setting option \"%s\" to {\"%s\",\"%s\",\"%s\"}",
@ -2605,7 +2605,7 @@ int parseopts_table(const char **a, unsigned int groups, struct opt **opts,
Error("!!!"); Error("!!!");
} }
//(*opts)[i].value.u_bin.b_len //(*opts)[i].value.u_bin.b_len
} }
break; break;
#endif /* LATER */ #endif /* LATER */
@ -2758,7 +2758,7 @@ int showleft(const struct opt *opts) {
/* does not set GROUP_FD; cannot determine GROUP_TERMIOS ! */ /* does not set GROUP_FD; cannot determine GROUP_TERMIOS ! */
int _groupbits(mode_t mode) { int _groupbits(mode_t mode) {
unsigned int result = 0; unsigned int result = 0;
switch ((mode&S_IFMT)>>12) { switch ((mode&S_IFMT)>>12) {
case (S_IFIFO>>12): /* 1, FIFO */ case (S_IFIFO>>12): /* 1, FIFO */
result = GROUP_FIFO; break; result = GROUP_FIFO; break;
@ -2851,8 +2851,8 @@ int retropt_timespec(struct opt *opts, int optcode, struct timespec *result) {
opt->desc = ODESC_DONE; opt->desc = ODESC_DONE;
return 0; return 0;
} }
/* Looks for the first option of type <optcode>. If the option is found, /* Looks for the first option of type <optcode>. If the option is found,
this function stores its bool value in *result, "consumes" the this function stores its bool value in *result, "consumes" the
option, and returns 0. option, and returns 0.
@ -3135,7 +3135,7 @@ int retropt_bind(struct opt *opts,
!= STAT_OK) { != STAT_OK) {
Error("error resolving bind option"); Error("error resolving bind option");
return STAT_NORETRY; return STAT_NORETRY;
} }
break; break;
#endif /* WITH_IP4 || WITH_IP6 */ #endif /* WITH_IP4 || WITH_IP6 */
@ -3485,7 +3485,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
opt->desc->type); opt->desc->type);
} }
#endif /* _WITH_SOCKET */ #endif /* _WITH_SOCKET */
#if HAVE_FLOCK #if HAVE_FLOCK
} else if (opt->desc->func == OFUNC_FLOCK) { } else if (opt->desc->func == OFUNC_FLOCK) {
if (Flock(fd, opt->desc->major) < 0) { if (Flock(fd, opt->desc->major) < 0) {
@ -3537,7 +3537,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
opt->desc = ODESC_ERROR; ++opt; continue; opt->desc = ODESC_ERROR; ++opt; continue;
} }
#endif /* HAVE_FTRUNCATE64 */ #endif /* HAVE_FTRUNCATE64 */
break; break;
case OPT_F_SETLK_RD: case OPT_F_SETLK_RD:
case OPT_F_SETLK_WR: case OPT_F_SETLK_WR:
case OPT_F_SETLKW_RD: case OPT_F_SETLKW_RD:
@ -3554,7 +3554,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
opt->desc = ODESC_ERROR; ++opt; continue; opt->desc = ODESC_ERROR; ++opt; continue;
} }
} }
break; break;
case OPT_SETUID_EARLY: case OPT_SETUID_EARLY:
case OPT_SETUID: case OPT_SETUID:
if (Setuid(opt->value.u_uidt) < 0) { if (Setuid(opt->value.u_uidt) < 0) {
@ -3666,7 +3666,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) {
} else { } else {
if (Setsid() < 0) { if (Setsid() < 0) {
Error1("setsid(): %s", strerror(errno)); Error1("setsid(): %s", strerror(errno));
} }
} }
} }
break; break;
@ -3807,7 +3807,7 @@ int applyopts_flags(struct opt *opts, int group, flags_t *result) {
if (!opts) return 0; if (!opts) return 0;
while (opt->desc != ODESC_END) { while (opt->desc != ODESC_END) {
if (opt->desc != ODESC_DONE && if (opt->desc != ODESC_DONE &&
(opt->desc->group & group)) { (opt->desc->group & group)) {
if (opt->desc->func == OFUNC_FLAG) { if (opt->desc->func == OFUNC_FLAG) {
if (opt->value.u_bool) { if (opt->value.u_bool) {
@ -3984,7 +3984,7 @@ int applyopts_single(struct single *xfd, struct opt *opts, enum e_phase phase) {
} }
xfd->havelock = true; xfd->havelock = true;
break; break;
default: default:
/* just store the value in the correct component of struct single */ /* just store the value in the correct component of struct single */
if (opt->desc->type == TYPE_CONST) { if (opt->desc->type == TYPE_CONST) {
@ -4069,7 +4069,7 @@ mc:addr
if (ifindex(opt->value.u_ip_mreq.ifindex, if (ifindex(opt->value.u_ip_mreq.ifindex,
(unsigned int *)&ip4_mreqn.mreqn.imr_ifindex, -1) (unsigned int *)&ip4_mreqn.mreqn.imr_ifindex, -1)
< 0) { < 0) {
Error1("cannot resolve interface \"%s\"", Error1("cannot resolve interface \"%s\"",
opt->value.u_ip_mreq.ifindex); opt->value.u_ip_mreq.ifindex);
} }
#endif /* HAVE_STRUCT_IP_MREQN */ #endif /* HAVE_STRUCT_IP_MREQN */
@ -4095,7 +4095,7 @@ mc:addr
ip4_mreqn.mreq.imr_interface = sockaddr2.ip4.sin_addr; ip4_mreqn.mreq.imr_interface = sockaddr2.ip4.sin_addr;
} }
} }
#if LATER #if LATER
if (0) { if (0) {
; /* for canonical reasons */ ; /* for canonical reasons */

View file

@ -120,10 +120,10 @@ enum e_func {
/* for simpler handling of option-to-connection-type relations we define /* for simpler handling of option-to-connection-type relations we define
groups. to keep the search for options simple, we allow each option to groups. to keep the search for options simple, we allow each option to
belong to at most one group only. (we have a dummy GROUP_NONE for those belong to at most one group only. (we have a dummy GROUP_NONE for those
that don't want to belong to any...) that don't want to belong to any...)
The caller of parseopts() specifies per bitpatter a set of groups where it The caller of parseopts() specifies per bitpatter a set of groups where it
accepts options from. accepts options from.
*/ */
/*- the group bits are: /*- the group bits are:

View file

@ -47,7 +47,7 @@ int xiosetopt(char what, const char *arg) {
what, arg?arg:"NULL"); what, arg?arg:"NULL");
return -1; return -1;
} }
return 0; return 0;
} }
@ -64,5 +64,5 @@ int xioinqopt(char what, char *arg, size_t n) {
what, arg, n); what, arg, n);
return -1; return -1;
} }
return 0; return 0;
} }

View file

@ -12,7 +12,7 @@
#include "xio-readline.h" #include "xio-readline.h"
#include "xio-openssl.h" #include "xio-openssl.h"
/* xioread() performs read() or recvfrom() /* xioread() performs read() or recvfrom()
If result is < 0, errno is valid */ If result is < 0, errno is valid */
ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) { ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) {
@ -97,7 +97,7 @@ ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) {
case XIOREAD_READLINE: case XIOREAD_READLINE:
if ((bytes = xioread_readline(pipe, buff, bufsiz)) < 0) { if ((bytes = xioread_readline(pipe, buff, bufsiz)) < 0) {
return -1; return -1;
} }
break; break;
#endif /* WITH_READLINE */ #endif /* WITH_READLINE */
@ -163,7 +163,7 @@ ssize_t xioread(xiofile_t *file, void *buff, size_t bufsiz) {
} }
} }
#endif /* defined(PF_PACKET) && defined(PACKET_OUTGOING) */ #endif /* defined(PF_PACKET) && defined(PACKET_OUTGOING) */
Notice2("received packet with "F_Zu" bytes from %s", Notice2("received packet with "F_Zu" bytes from %s",
bytes, bytes,
sockaddr_info(&from.soa, fromlen, infobuff, sizeof(infobuff))); sockaddr_info(&from.soa, fromlen, infobuff, sizeof(infobuff)));

View file

@ -84,9 +84,9 @@ int xioshutdown(xiofile_t *sock, int how) {
if (Close(sock->stream.para.bipipe.fdout) < 0) { if (Close(sock->stream.para.bipipe.fdout) < 0) {
Info2("close(%d): %s", Info2("close(%d): %s",
sock->stream.para.bipipe.fdout, strerror(errno)); sock->stream.para.bipipe.fdout, strerror(errno));
} }
} }
} else if ((sock->stream.dtype & XIODATA_MASK) == XIODATA_2PIPE) { } else if ((sock->stream.dtype & XIODATA_MASK) == XIODATA_2PIPE) {
if ((how+1)&1) { if ((how+1)&1) {
if (Close(sock->stream.fd) < 0) { if (Close(sock->stream.fd) < 0) {
@ -98,7 +98,7 @@ int xioshutdown(xiofile_t *sock, int how) {
if (Close(sock->stream.para.exec.fdout) < 0) { if (Close(sock->stream.para.exec.fdout) < 0) {
Info2("close(%d): %s", Info2("close(%d): %s",
sock->stream.para.exec.fdout, strerror(errno)); sock->stream.para.exec.fdout, strerror(errno));
} }
} }
#if _WITH_SOCKET #if _WITH_SOCKET
} else if (sock->stream.howtoend == END_SHUTDOWN) { } else if (sock->stream.howtoend == END_SHUTDOWN) {

View file

@ -79,7 +79,7 @@ void socatsignalpass(int sig) {
} }
/* register the sub process pid for passing of signals of type signum. /* register the sub process pid for passing of signals of type signum.
Only for SIGHUP, SIGINT, and SIGQUIT! Only for SIGHUP, SIGINT, and SIGQUIT!
returns 0 on success or <0 if an error occurred */ returns 0 on success or <0 if an error occurred */
int xio_opt_signal(pid_t pid, int signum) { int xio_opt_signal(pid_t pid, int signum) {

View file

@ -86,7 +86,7 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
char infobuff[256]; char infobuff[256];
_errno = errno; _errno = errno;
Error6("sendto(%d, %p, "F_Zu", 0, %s, "F_socklen"): %s", Error6("sendto(%d, %p, "F_Zu", 0, %s, "F_socklen"): %s",
pipe->fd, buff, bytes, pipe->fd, buff, bytes,
sockaddr_info(&pipe->peersa.soa, pipe->salen, sockaddr_info(&pipe->peersa.soa, pipe->salen,
infobuff, sizeof(infobuff)), infobuff, sizeof(infobuff)),
pipe->salen, strerror(_errno)); pipe->salen, strerror(_errno));
@ -96,7 +96,7 @@ ssize_t xiowrite(xiofile_t *file, const void *buff, size_t bytes) {
if ((size_t)writt < bytes) { if ((size_t)writt < bytes) {
char infobuff[256]; char infobuff[256];
Warn7("sendto(%d, %p, "F_Zu", 0, %s, "F_socklen") only wrote "F_Zu" of "F_Zu" bytes", Warn7("sendto(%d, %p, "F_Zu", 0, %s, "F_socklen") only wrote "F_Zu" of "F_Zu" bytes",
pipe->fd, buff, bytes, pipe->fd, buff, bytes,
sockaddr_info(&pipe->peersa.soa, pipe->salen, sockaddr_info(&pipe->peersa.soa, pipe->salen,
infobuff, sizeof(infobuff)), infobuff, sizeof(infobuff)),
pipe->salen, writt, bytes); pipe->salen, writt, bytes);