From 3e282ee7a0bdded30cf9c797255cc21f32352a44 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Fri, 23 Jun 2023 16:21:05 +0200 Subject: [PATCH] Internal: renamed xioopts_t to xioparms_t --- CHANGES | 2 ++ socat.c | 12 ++++++------ xio-ip.c | 8 ++++---- xio-ipapp.c | 6 +++--- xio-listen.c | 4 ++-- xio-openssl.c | 6 +++--- xio-rawip.c | 4 ++-- xio-socket.c | 8 ++++---- xio-udp.c | 6 +++--- xio.h | 4 ++-- xioinitialize.c | 6 +++--- xioopen.c | 16 ++++++++-------- xioopts.c | 12 ++++++------ xioparam.c | 20 ++++++++++---------- 14 files changed, 58 insertions(+), 56 deletions(-) diff --git a/CHANGES b/CHANGES index 5b019c4..89fa140 100644 --- a/CHANGES +++ b/CHANGES @@ -39,6 +39,8 @@ Coding: socketpair. SIGUSR1 is no longer used for internal synchronization. Tests: UDP4_FORK UDP6_FORK UNIX_FORK + Renamed xioopts_t to xioparms_t to avoid confusion with xioopts module. + ####################### V 1.7.4.5 (not released): Corrections: diff --git a/socat.c b/socat.c index 98c7e7e..1dcd461 100644 --- a/socat.c +++ b/socat.c @@ -325,13 +325,13 @@ int main(int argc, const char *argv[]) { case '6': #endif if (arg1[0][2]) { socat_opt_hint(stderr, arg1[0][1], arg1[0][2]); Exit(1); } - xioopts.default_ip = arg1[0][1]; - xioopts.preferred_ip = arg1[0][1]; + xioparms.default_ip = arg1[0][1]; + xioparms.preferred_ip = arg1[0][1]; break; #endif /* WITH_IP4 || WITH_IP6 */ case '-': if (!strcmp("experimental", &arg1[0][2])) { - xioopts.experimental = true; + xioparms.experimental = true; } else { Error1("unknown option \"%s\"; use option \"-h\" for help", arg1[0]); } @@ -431,8 +431,8 @@ void socat_usage(FILE *fd) { fputs(" -hh like -h, plus a list of all common address option names\n", fd); fputs(" -hhh like -hh, plus a list of all available address option names\n", fd); #endif /* WITH_HELP */ - fputs(" -d[ddd] increase verbosity (use up to 4 times; 2 are recommended)\n", fd); - fputs(" -d0|1|2|3|4 set verbosity level (0: Errors; 4 all including Debug)\n", fd); + fputs(" -d[ddd] increase verbosity (use up to 4 times; 2 are recommended)\n", fd); + fputs(" -d0|1|2|3|4 set verbosity level (0: Errors; 4 all including Debug)\n", fd); #if WITH_FILAN fputs(" -D analyze file descriptors before loop\n", fd); #endif @@ -913,7 +913,7 @@ int _socat(void) { if (socat_opts.logopt == 'm' && xioinqopt('l', NULL, 0) == 'm') { Info("switching to syslog"); - diag_set('y', xioopts.syslogfac); + diag_set('y', xioparms.syslogfac); xiosetopt('l', "\0"); } total_timeout = socat_opts.total_timeout; diff --git a/xio-ip.c b/xio-ip.c index 94abdeb..fe2b608 100644 --- a/xio-ip.c +++ b/xio-ip.c @@ -273,13 +273,13 @@ int xiogetaddrinfo(const char *node, const char *service, service = NULL; /* do not resolve later again */ record = res; - if (family == PF_UNSPEC && xioopts.preferred_ip == '0') { + if (family == PF_UNSPEC && xioparms.preferred_ip == '0') { /* we just take the first result */ family = res[0].ai_addr->sa_family; } if (family == PF_UNSPEC) { int trypf; - trypf = (xioopts.preferred_ip=='6'?PF_INET6:PF_INET); + trypf = (xioparms.preferred_ip=='6'?PF_INET6:PF_INET); /* we must look for a matching entry */ while (record != NULL) { if (record->ai_family == trypf) { @@ -339,7 +339,7 @@ int xiogetaddrinfo(const char *node, const char *service, /* first fallback is getipnodebyname() */ if (family == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - family = xioopts.default_ip=='6'?PF_INET6:PF_INET; + family = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 family = PF_INET6; #else @@ -390,7 +390,7 @@ int xiogetaddrinfo(const char *node, const char *service, be useful somewhere sometimes in a future even for IP6 */ if (family == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - family = xioopts.default_ip=='6'?PF_INET6:PF_INET; + family = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 family = PF_INET6; #else diff --git a/xio-ipapp.c b/xio-ipapp.c index ef92d2c..30f6f8f 100644 --- a/xio-ipapp.c +++ b/xio-ipapp.c @@ -61,9 +61,9 @@ int xioopen_ipapp_connect(int argc, const char *argv[], struct opt *opts, xiosetchilddied(); /* set SIGCHLD handler */ } - if (xioopts.logopt == 'm') { + if (xioparms.logopt == 'm') { Info("starting connect loop, switching to syslog"); - diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; + diag_set('y', xioparms.syslogfac); xioparms.logopt = 'y'; } else { Info("starting connect loop"); } @@ -271,7 +271,7 @@ int xioopen_ipapp_listen(int argc, const char *argv[], struct opt *opts, if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else diff --git a/xio-listen.c b/xio-listen.c index 54d69dc..84771f3 100644 --- a/xio-listen.c +++ b/xio-listen.c @@ -224,9 +224,9 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl return STAT_RETRYLATER; } - if (xioopts.logopt == 'm') { + if (xioparms.logopt == 'm') { Info("starting accept loop, switching to syslog"); - diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; + diag_set('y', xioparms.syslogfac); xioparms.logopt = 'y'; } else { Info("starting accept loop"); } diff --git a/xio-openssl.c b/xio-openssl.c index 311d61b..5ffc1d1 100644 --- a/xio-openssl.c +++ b/xio-openssl.c @@ -301,9 +301,9 @@ static int &needbind, &lowport, socktype); if (result != STAT_OK) return STAT_NORETRY; - if (xioopts.logopt == 'm') { + if (xioparms.logopt == 'm') { Info("starting connect loop, switching to syslog"); - diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; + diag_set('y', xioparms.syslogfac); xioparms.logopt = 'y'; } else { Info("starting connect loop"); } @@ -524,7 +524,7 @@ static int } #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else diff --git a/xio-rawip.c b/xio-rawip.c index 5ba3600..d3340ea 100644 --- a/xio-rawip.c +++ b/xio-rawip.c @@ -226,7 +226,7 @@ int xioopen_rawip_recvfrom(int argc, const char *argv[], struct opt *opts, retropt_socket_pf(opts, &pf); if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else @@ -283,7 +283,7 @@ int xioopen_rawip_recv(int argc, const char *argv[], struct opt *opts, retropt_socket_pf(opts, &pf); if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else diff --git a/xio-socket.c b/xio-socket.c index f1d8410..c2eaa8a 100644 --- a/xio-socket.c +++ b/xio-socket.c @@ -1171,9 +1171,9 @@ int _xioopen_dgram_recvfrom(struct single *xfd, int xioflags, xio_retropt_tcpwrap(xfd, opts); #endif /* && (WITH_TCP || WITH_UDP) && WITH_LIBWRAP */ - if (xioopts.logopt == 'm') { + if (xioparms.logopt == 'm') { Info("starting recvfrom loop, switching to syslog"); - diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; + diag_set('y', xioparms.syslogfac); xioparms.logopt = 'y'; } else { Info("starting recvfrom loop"); } @@ -1375,9 +1375,9 @@ int _xioopen_dgram_recv(struct single *xfd, int xioflags, xio_retropt_tcpwrap(xfd, opts); #endif /* && (WITH_TCP || WITH_UDP) && WITH_LIBWRAP */ - if (xioopts.logopt == 'm') { + if (xioparms.logopt == 'm') { Info("starting recvfrom loop, switching to syslog"); - diag_set('y', xioopts.syslogfac); xioopts.logopt = 'y'; + diag_set('y', xioparms.syslogfac); xioparms.logopt = 'y'; } else { Info("starting recvfrom loop"); } diff --git a/xio-udp.c b/xio-udp.c index 074f4f9..4496963 100644 --- a/xio-udp.c +++ b/xio-udp.c @@ -290,7 +290,7 @@ int xioopen_ipdgram_listen(int argc, const char *argv[], struct opt *opts, if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else @@ -500,7 +500,7 @@ int xioopen_udp_recvfrom(int argc, const char *argv[], struct opt *opts, retropt_socket_pf(opts, &pf); if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else @@ -573,7 +573,7 @@ int xioopen_udp_recv(int argc, const char *argv[], struct opt *opts, retropt_socket_pf(opts, &pf); if (pf == PF_UNSPEC) { #if WITH_IP4 && WITH_IP6 - pf = xioopts.default_ip=='6'?PF_INET6:PF_INET; + pf = xioparms.default_ip=='6'?PF_INET6:PF_INET; #elif WITH_IP6 pf = PF_INET6; #else diff --git a/xio.h b/xio.h index 286cee4..80fdfce 100644 --- a/xio.h +++ b/xio.h @@ -112,7 +112,7 @@ typedef struct { char preferred_ip; /* preferred prot.fam. for name resolution ('0' for unspecified, '4', or '6') */ bool experimental; /* enable some features */ -} xioopts_t; +} xioparms_t; /* pack the description of a lock file */ typedef struct { @@ -121,7 +121,7 @@ typedef struct { struct timespec intervall; /* polling intervall */ } xiolock_t; -extern xioopts_t xioopts; +extern xioparms_t xioparms; #define MAXARGV 8 diff --git a/xioinitialize.c b/xioinitialize.c index 4118ab6..43c2a4d 100644 --- a/xioinitialize.c +++ b/xioinitialize.c @@ -76,7 +76,7 @@ int xioinitialize(void) { switch (default_ip[0]) { case '4': case '6': - xioopts.default_ip = default_ip[0]; break; + xioparms.default_ip = default_ip[0]; break; } } } @@ -87,9 +87,9 @@ int xioinitialize(void) { switch (preferred_ip[0]) { case '4': case '6': - xioopts.preferred_ip = preferred_ip[0]; break; + xioparms.preferred_ip = preferred_ip[0]; break; default: - xioopts.preferred_ip = '0'; break; + xioparms.preferred_ip = '0'; break; } } } diff --git a/xioopen.c b/xioopen.c index b93999b..2d94fa5 100644 --- a/xioopen.c +++ b/xioopen.c @@ -421,9 +421,9 @@ static xiofile_t *xioparse_dual(const char **addr) { } /* and now we see if we reached a dual-address separator */ - if (!strncmp(*addr, xioopts.pipesep, strlen(xioopts.pipesep))) { + if (!strncmp(*addr, xioparms.pipesep, strlen(xioparms.pipesep))) { /* yes we reached it, so we parse the second single address */ - *addr += strlen(xioopts.pipesep); + *addr += strlen(xioparms.pipesep); if ((xfd = xioallocfd()) == NULL) { free(sfd1); /*! and maybe have free some if its contents */ @@ -500,10 +500,10 @@ static xiosingle_t *xioparse_single(const char **addr) { /* init */ i = 0; - /*ends[i++] = xioopts.chainsep;*/ /* default: "|" */ - ends[i++] = xioopts.pipesep; /* default: "!!" */ - ends[i++] = ","/*xioopts.comma*/; /* default: "," */ - ends[i++] = ":"/*xioopts.colon*/; /* default: ":" */ + /*ends[i++] = xioparms.chainsep;*/ /* default: "|" */ + ends[i++] = xioparms.pipesep; /* default: "!!" */ + ends[i++] = ","/*xioparms.comma*/; /* default: "," */ + ends[i++] = ":"/*xioparms.colon*/; /* default: ":" */ ends[i++] = NULL; if ((xfd = xioallocfd()) == NULL) { @@ -567,8 +567,8 @@ static xiosingle_t *xioparse_single(const char **addr) { sfd->tag = XIO_TAG_RDWR; sfd->addr = addrdesc; - while (!strncmp(*addr, xioopts.paramsep, strlen(xioopts.paramsep))) { - *addr += strlen(xioopts.paramsep); + while (!strncmp(*addr, xioparms.paramsep, strlen(xioparms.paramsep))) { + *addr += strlen(xioparms.paramsep); len = sizeof(token); tokp = token; result = nestlex(addr, &tokp, &len, ends, hquotes, squotes, nests, true, true, false); diff --git a/xioopts.c b/xioopts.c index 485fa46..73dac1b 100644 --- a/xioopts.c +++ b/xioopts.c @@ -1890,16 +1890,16 @@ int parseopts_table(const char **a, groups_t groups, struct opt **opts, } ; i = 0; - /*endkey[i++] = xioopts.chainsep;*/ /* default: "|" */ - endkey[i++] = xioopts.pipesep; /* default: "!!" */ - endkey[i++] = ","/*xioopts.comma*/; /* default: "," */ + /*endkey[i++] = xioparms.chainsep;*/ /* default: "|" */ + endkey[i++] = xioparms.pipesep; /* default: "!!" */ + endkey[i++] = ","/*xioparms.comma*/; /* default: "," */ endkey[i++] = "="; endkey[i++] = NULL; i = 0; - /*endval[i++] = xioopts.chainsep;*/ /* default: "|" */ - endval[i++] = xioopts.pipesep; /* default: "!!" */ - endval[i++] = ","/*xioopts.comma*/; /* default: "," */ + /*endval[i++] = xioparms.chainsep;*/ /* default: "|" */ + endval[i++] = xioparms.pipesep; /* default: "!!" */ + endval[i++] = ","/*xioparms.comma*/; /* default: "," */ endval[i++] = NULL; i = 0; diff --git a/xioparam.c b/xioparam.c index 132cf34..4c13c0d 100644 --- a/xioparam.c +++ b/xioparam.c @@ -10,7 +10,7 @@ /*#include "xioparam.h" are all in xio.h */ /* options that can be applied to this module */ -xioopts_t xioopts = { +xioparms_t xioparms = { false, /* strictopts */ "!!", /* pipesep */ ":", /* paramsep */ @@ -28,21 +28,21 @@ xioopts_t xioopts = { /* allow application to set xioopen options */ int xiosetopt(char what, const char *arg) { switch (what) { - case 's': xioopts.strictopts = true; break; - case 'p': if ((xioopts.pipesep = strdup(arg)) == NULL) { + case 's': xioparms.strictopts = true; break; + case 'p': if ((xioparms.pipesep = strdup(arg)) == NULL) { Error1("strdup("F_Zu"): out of memory", strlen(arg)+1); return -1; } break; - case 'o': xioopts.ip4portsep = arg[0]; + case 'o': xioparms.ip4portsep = arg[0]; if (arg[1] != '\0') { Error2("xiosetopt('%c', \"%s\"): port separator must be single character", what, arg); return -1; } break; - case 'l': xioopts.logopt = *arg; break; - case 'y': xioopts.syslogfac = arg; break; + case 'l': xioparms.logopt = *arg; break; + case 'y': xioparms.syslogfac = arg; break; default: Error2("xiosetopt('%c', \"%s\"): unknown option", what, arg?arg:"NULL"); @@ -54,12 +54,12 @@ int xiosetopt(char what, const char *arg) { int xioinqopt(char what, char *arg, size_t n) { switch (what) { - case 's': return xioopts.strictopts; + case 's': return xioparms.strictopts; case 'p': - arg[0] = '\0'; strncat(arg, xioopts.pipesep, n-1); + arg[0] = '\0'; strncat(arg, xioparms.pipesep, n-1); return 0; - case 'o': return xioopts.ip4portsep; - case 'l': return xioopts.logopt; + case 'o': return xioparms.ip4portsep; + case 'l': return xioparms.logopt; default: Error3("xioinqopt('%c', \"%s\", "F_Zu"): unknown option", what, arg, n);