1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-07-11 22:23:24 +00:00

On bad parameter number print syntax; struct single pointers are now mostly called sfd

This commit is contained in:
Gerhard Rieger 2023-07-13 09:06:35 +02:00
parent 5eebca3a5b
commit 50b199dcd9
42 changed files with 1354 additions and 1163 deletions

View file

@ -14,8 +14,8 @@
#if WITH_FDNUM
static int xioopen_fdnum(int argc, const char *argv[], struct opt *opts, int rw, xiofile_t *xfd, groups_t groups, int dummy1, int dummy2, int dummy3);
static int xioopen_accept_fd(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, groups_t groups, int dummy1, int dummy2, int dummy3);
static int xioopen_fdnum(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc);
static int xioopen_accept_fd(int argc, const char *argv[], struct opt *opts, int xioflags, xiofile_t *xfd, const struct addrdesc *addrdesc);
const struct addrdesc xioaddr_fd = { "FD", 1+XIO_RDWR, xioopen_fdnum, GROUP_FD|GROUP_FIFO|GROUP_CHR|GROUP_BLK|GROUP_FILE|GROUP_SOCKET|GROUP_TERMIOS|GROUP_SOCK_UNIX|GROUP_SOCK_IP|GROUP_IPAPP, 0, 0, 0 HELP(":<fdnum>") };
@ -25,9 +25,14 @@ const struct addrdesc xioaddr_accept_fd = { "ACCEPT-FD", 1+XIO_RDWR, xioopen_acc
/* use some file descriptor and apply the options. Set the FD_CLOEXEC flag. */
static int xioopen_fdnum(int argc, const char *argv[], struct opt *opts,
int xioflags, xiofile_t *xfd, groups_t groups,
int dummy1, int dummy2, int dummy3) {
static int xioopen_fdnum(
int argc,
const char *argv[],
struct opt *opts,
int xioflags,
xiofile_t *xfd,
const struct addrdesc *addrdesc)
{
char *a1;
int rw = (xioflags&XIO_ACCMODE);
int numfd;
@ -46,7 +51,7 @@ static int xioopen_fdnum(int argc, const char *argv[], struct opt *opts,
Warn2("fcntl(%d, F_SETFD, FD_CLOEXEC): %s", numfd, strerror(errno));
}
Notice2("using file descriptor %d for %s", numfd, ddirection[rw]);
if ((result = xioopen_fd(opts, rw, &xfd->stream, numfd, dummy2, dummy3)) < 0) {
if ((result = xioopen_fd(opts, rw, &xfd->stream, numfd)) < 0) {
return result;
}
return 0;
@ -61,10 +66,7 @@ static int xioopen_accept_fd(
struct opt *opts,
int xioflags,
xiofile_t *xfd,
groups_t groups,
int dummy1,
int dummy2,
int dummy3)
const struct addrdesc *addrdesc)
{
char *a1;
int rw = (xioflags&XIO_ACCMODE);
@ -74,7 +76,8 @@ static int xioopen_accept_fd(
int result;
if (argc != 2) {
Error2("%s: wrong number of parameters (%d instead of 1)", argv[0], argc-1);
xio_syntax(argv[0], 1, argc-1, addrdesc->syntax);
return STAT_NORETRY;
}
numfd = strtoul(argv[1], &a1, 0);
@ -103,29 +106,29 @@ static int xioopen_accept_fd(
#if WITH_FD
/* retrieve and apply options to a standard file descriptor.
Do not set FD_CLOEXEC flag. */
int xioopen_fd(struct opt *opts, int rw, xiosingle_t *xfd, int numfd, int dummy2, int dummy3) {
/* Retrieves and apply options to a standard file descriptor.
Does not set FD_CLOEXEC flag. */
int xioopen_fd(struct opt *opts, int rw, struct single *sfd, int numfd) {
xfd->fd = numfd;
xfd->howtoend = END_NONE;
sfd->fd = numfd;
sfd->howtoend = END_NONE;
#if WITH_TERMIOS
if (Isatty(xfd->fd)) {
if (Tcgetattr(xfd->fd, &xfd->savetty) < 0) {
if (Isatty(sfd->fd)) {
if (Tcgetattr(sfd->fd, &sfd->savetty) < 0) {
Warn2("cannot query current terminal settings on fd %d: %s",
xfd->fd, strerror(errno));
sfd->fd, strerror(errno));
} else {
xfd->ttyvalid = true;
sfd->ttyvalid = true;
}
}
#endif /* WITH_TERMIOS */
if (applyopts_single(xfd, opts, PH_INIT) < 0)
if (applyopts_single(sfd, opts, PH_INIT) < 0)
return -1;
applyopts2(xfd, -1, opts, PH_INIT, PH_FD);
applyopts2(sfd, -1, opts, PH_INIT, PH_FD);
return _xio_openlate(xfd, opts);
return _xio_openlate(sfd, opts);
}
#endif /* WITH_FD */