Fix -D option, add DBG() for debug

This commit is contained in:
Kim Woelders
2018-07-05 09:21:22 +02:00
parent cbbb0cd225
commit 9057376656
+13 -13
View File
@@ -71,14 +71,15 @@ static void _log(int prio, const char *fmt, ...)
{
va_list arg;
if (prio >= LOG_DEBUG && ttynvt_param.debug <= 0)
return;
va_start(arg, fmt);
vsyslog(prio, fmt, arg);
va_end(arg);
}
#define DBG(...) \
if (ttynvt_param.debug) _log(LOG_DEBUG, __VA_ARGS__)
static void ttynvt_release(fuse_req_t req, struct fuse_file_info *info)
{
ttynvt_t *tty = (ttynvt_t *) (uintptr_t) info->fh;
@@ -572,13 +573,12 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
telnet_rfc2217_ctl(tty->tn, TNS_CTL_DTR_ON);
}
_log(LOG_DEBUG,
"CFG ioctl: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n",
baudrate(speed), pstr[par], csize, sb,
tio.c_cflag & CRTSCTS ? '+' : '-',
tio.c_cflag & CREAD ? '+' : '-',
tio.c_cflag & HUPCL ? '+' : '-',
tio.c_cflag & CLOCAL ? '+' : '-');
DBG("CFG ioctl: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n",
baudrate(speed), pstr[par], csize, sb,
tio.c_cflag & CRTSCTS ? '+' : '-',
tio.c_cflag & CREAD ? '+' : '-',
tio.c_cflag & HUPCL ? '+' : '-',
tio.c_cflag & CLOCAL ? '+' : '-');
fuse_reply_ioctl(req, 0, 0, 0);
}
@@ -724,8 +724,8 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
tiocm = *(unsigned int *)in_buf;
fuse_reply_ioctl(req, 0, 0, 0);
_log(LOG_DEBUG, "CFG ioctl: DTR=%c RTS=%c\n",
tiocm & TIOCM_DTR ? '1' : '0', tiocm & TIOCM_RTS ? '1' : '0');
DBG("CFG ioctl: DTR=%c RTS=%c\n",
tiocm & TIOCM_DTR ? '1' : '0', tiocm & TIOCM_RTS ? '1' : '0');
mcr &= ~(TIOCM_RTS | TIOCM_DTR);
mcr |= tiocm & (TIOCM_RTS | TIOCM_DTR);
@@ -794,7 +794,7 @@ static const struct cuse_lowlevel_ops ttynvt_op = {
#define TTYNET_OPT(t, p, v) { t, offsetof(struct ttynvt_param, p), v }
static const struct fuse_opt ttynvt_opts[] = {
TTYNET_OPT("-D", debug, 0),
TTYNET_OPT("-D", debug, 1),
TTYNET_OPT("-M %u", major, 1),
TTYNET_OPT("--maj=%u", major, 1),
TTYNET_OPT("-m %u", minor, 1),