mirror of
https://repo.or.cz/socat.git
synced 2025-07-14 23:33:23 +00:00
socat V1.6.0.0 (initial GIT commit)
This commit is contained in:
commit
b819572f5e
170 changed files with 59193 additions and 0 deletions
67
xioparam.c
Normal file
67
xioparam.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/* $Id: xioparam.c,v 1.10 2006/06/19 20:30:24 gerhard Exp $ */
|
||||
/* Copyright Gerhard Rieger 2001-2006 */
|
||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||
|
||||
/* this file contains the source for xio options handling */
|
||||
|
||||
#include "xiosysincludes.h"
|
||||
#include "xioopen.h"
|
||||
|
||||
/*#include "xioparam.h" are all in xio.h */
|
||||
|
||||
/* options that can be applied to this module */
|
||||
xioopts_t xioopts = {
|
||||
false, /* strictopts */
|
||||
"!!", /* pipesep */
|
||||
":", /* paramsep */
|
||||
",", /* optionsep */
|
||||
':', /* ip4portsep */
|
||||
':', /* ip6portsep */
|
||||
'\0', /* logopt */
|
||||
NULL, /* syslogfac */
|
||||
'4', /* default_ip */
|
||||
'4' /* preferred_ip */
|
||||
} ;
|
||||
|
||||
|
||||
/* 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) {
|
||||
Error1("strdup("F_Zu"): out of memory", strlen(arg)+1);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'o': xioopts.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;
|
||||
default:
|
||||
Error2("xiosetopt('%c', \"%s\"): unknown option",
|
||||
what, arg?arg:"NULL");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int xioinqopt(char what, char *arg, size_t n) {
|
||||
switch (what) {
|
||||
case 's': return xioopts.strictopts;
|
||||
case 'p': strncpy(arg, xioopts.pipesep, n);
|
||||
return 0;
|
||||
case 'o': return xioopts.ip4portsep;
|
||||
case 'l': return xioopts.logopt;
|
||||
default:
|
||||
Error3("xioinqopt('%c', \"%s\", "F_Zu"): unknown option",
|
||||
what, arg, n);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue