nexmon – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /* source: xioparam.c */ |
2 | /* Copyright Gerhard Rieger */ |
||
3 | /* Published under the GNU General Public License V.2, see file COPYING */ |
||
4 | |||
5 | /* this file contains the source for xio options handling */ |
||
6 | |||
7 | #include "xiosysincludes.h" |
||
8 | #include "xioopen.h" |
||
9 | |||
10 | /*#include "xioparam.h" are all in xio.h */ |
||
11 | |||
12 | /* options that can be applied to this module */ |
||
13 | xioopts_t xioopts = { |
||
14 | false, /* strictopts */ |
||
15 | "%", /* pipesep */ |
||
16 | ":", /* paramsep */ |
||
17 | ",", /* optionsep */ |
||
18 | ':', /* ip4portsep */ |
||
19 | ':', /* ip6portsep */ |
||
20 | NULL, /* syslogfac */ |
||
21 | '4', /* default_ip */ |
||
22 | '4', /* preferred_ip */ |
||
23 | "^", /* reversechar */ |
||
24 | "|", /* chainsep */ |
||
25 | 8192, /* bufsiz */ |
||
26 | false, /* verbose */ |
||
27 | false, /* verbhex */ |
||
28 | 0, /* debug */ |
||
29 | 's', /* logopt */ |
||
30 | {0,0}, /* total_timeout */ |
||
31 | {1,0}, /* pollintv */ |
||
32 | {0,500000}, /* closwait */ |
||
33 | false, /* lefttoright */ |
||
34 | false, /* righttoleft */ |
||
35 | 0, /* pipetype: two unidirectional socketpairs */ |
||
36 | } ; |
||
37 | xioopts_t *xioparams = &xioopts; |
||
38 | |||
39 | |||
40 | /* allow application to set xioopen options */ |
||
41 | int xiosetopt(char what, const char *arg) { |
||
42 | switch (what) { |
||
43 | case 's': xioopts.strictopts = true; break; |
||
44 | case 'p': if ((xioopts.pipesep = strdup(arg)) == NULL) { |
||
45 | Error1("strdup("F_Zu"): out of memory", strlen(arg)+1); |
||
46 | return -1; |
||
47 | } |
||
48 | break; |
||
49 | case 'o': xioopts.ip4portsep = arg[0]; |
||
50 | if (arg[1] != '\0') { |
||
51 | Error2("xiosetopt('%c', \"%s\"): port separator must be single character", |
||
52 | what, arg); |
||
53 | return -1; |
||
54 | } |
||
55 | break; |
||
56 | case 'l': xioopts.logopt = *arg; break; |
||
57 | case 'y': xioopts.syslogfac = arg; break; |
||
58 | default: |
||
59 | Error2("xiosetopt('%c', \"%s\"): unknown option", |
||
60 | what, arg?arg:"NULL"); |
||
61 | return -1; |
||
62 | } |
||
63 | return 0; |
||
64 | } |
||
65 | |||
66 | |||
67 | int xioinqopt(char what, char *arg, size_t n) { |
||
68 | switch (what) { |
||
69 | case 's': return xioopts.strictopts; |
||
70 | case 'p': |
||
71 | arg[0] = '\0'; strncat(arg, xioopts.pipesep, n-1); |
||
72 | return 0; |
||
73 | case 'o': return xioopts.ip4portsep; |
||
74 | case 'l': return xioopts.logopt; |
||
75 | default: |
||
76 | Error3("xioinqopt('%c', \"%s\", "F_Zu"): unknown option", |
||
77 | what, arg, n); |
||
78 | return -1; |
||
79 | } |
||
80 | return 0; |
||
81 | } |