1 /* source: xioparam.c */
2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 /* this file contains the source for xio options handling */
7 #include "xiosysincludes.h"
10 /*#include "xioparam.h" are all in xio.h */
12 /* options that can be applied to this module */
13 xioparms_t xioparms
= {
14 false, /* strictopts */
22 WITH_DEFAULT_IPV
, /* default_ip */
23 WITH_DEFAULT_IPV
, /* preferred_ip */
24 false, /* experimental */
25 NULL
, /* sniffleft_name */
26 NULL
, /* sniffright_name */
31 /* allow application to set xioopen options */
32 int xiosetopt(char what
, const char *arg
) {
34 case 's': xioparms
.strictopts
= true; break;
35 case 'p': if ((xioparms
.pipesep
= strdup(arg
)) == NULL
) {
36 Error1("strdup("F_Zu
"): out of memory", strlen(arg
)+1);
40 case 'o': xioparms
.ip4portsep
= arg
[0];
42 Error2("xiosetopt('%c', \"%s\"): port separator must be single character",
47 case 'l': xioparms
.logopt
= *arg
; break;
48 case 'y': xioparms
.syslogfac
= arg
; break;
49 case 'r': xioparms
.sniffleft_name
= arg
; break;
50 case 'R': xioparms
.sniffright_name
= arg
; break;
52 Error2("xiosetopt('%c', \"%s\"): unknown option",
53 what
, arg
?arg
:"NULL");
60 int xioinqopt(char what
, char *arg
, size_t n
) {
62 case 's': return xioparms
.strictopts
;
64 arg
[0] = '\0'; strncat(arg
, xioparms
.pipesep
, n
-1);
66 case 'o': return xioparms
.ip4portsep
;
67 case 'l': return xioparms
.logopt
;
69 if (xioparms
.sniffleft_name
== NULL
) {
72 if (n
< strlen(xioparms
.sniffleft_name
)+1) {
76 strncat(arg
, xioparms
.sniffleft_name
, n
-1);
79 if (xioparms
.sniffright_name
== NULL
) {
82 if (n
< strlen(xioparms
.sniffright_name
)+1) {
86 strncat(arg
, xioparms
.sniffright_name
, n
-1);
89 Error3("xioinqopt('%c', \"%s\", "F_Zu
"): unknown option",