Drop ttynvt prefix from "local" functions

Only keep it on ones that are direct cuse_lowlevel_ops.

Makes it easier to understand things, IMO.
This commit is contained in:
Kim Woelders
2018-07-05 08:04:44 +02:00
parent 4988368662
commit 2fb5ad2599
+36 -38
View File
@@ -65,7 +65,7 @@ typedef struct ttynvt {
tn_ctx_t *tn;
} ttynvt_t;
static void ttynvt_log(int prio, const char *fmt, ...)
static void _log(int prio, const char *fmt, ...)
{
va_list arg;
@@ -81,7 +81,7 @@ static void ttynvt_release(fuse_req_t req, struct fuse_file_info *info)
{
ttynvt_t *tty = (ttynvt_t *) (uintptr_t) info->fh;
ttynvt_log(LOG_INFO, "connection closed\n");
_log(LOG_INFO, "connection closed\n");
close(tty->fds[0].fd);
@@ -99,7 +99,7 @@ static void ttynvt_release(fuse_req_t req, struct fuse_file_info *info)
fuse_reply_err(req, 0);
}
static void ttynvt_notify(ttynvt_t * tty)
static void _notify(ttynvt_t * tty)
{
pthread_mutex_lock(&tty->poll_lock);
if (tty->ph)
@@ -112,7 +112,7 @@ static void ttynvt_notify(ttynvt_t * tty)
pthread_cond_signal(&tty->cond);
}
static void ttynvt_update_notify(ttynvt_t * tty, struct fuse_pollhandle *ph)
static void _update_notify(ttynvt_t * tty, struct fuse_pollhandle *ph)
{
pthread_mutex_lock(&tty->poll_lock);
struct fuse_pollhandle *tmp_ph = tty->ph;
@@ -123,7 +123,7 @@ static void ttynvt_update_notify(ttynvt_t * tty, struct fuse_pollhandle *ph)
fuse_pollhandle_destroy(tmp_ph);
}
static unsigned int ttynvt_write_avail(ttynvt_t * tty)
static unsigned int _write_avail(ttynvt_t * tty)
{
size_t write_avail;
int used;
@@ -138,7 +138,7 @@ static unsigned int ttynvt_write_avail(ttynvt_t * tty)
return write_avail;
}
static int ttynvt_read_avail(ttynvt_t * tty)
static int _read_avail(ttynvt_t * tty)
{
int read_avail;
@@ -150,7 +150,7 @@ static int ttynvt_read_avail(ttynvt_t * tty)
return read_avail;
}
static void *ttynvt_read_net(void *arg)
static void *_read_net(void *arg)
{
ttynvt_t *tty = (ttynvt_t *) arg;
ssize_t res;
@@ -182,7 +182,7 @@ static void *ttynvt_read_net(void *arg)
/*buffer overflow */
tty->blen = 0;
read_avail = RX_BUF_SIZE;
ttynvt_log(LOG_WARNING, "Rx buffer overflow\n");
_log(LOG_WARNING, "Rx buffer overflow\n");
}
res = read(tty->fds[0].fd, tty->buf + tty->blen, read_avail);
if (res <= 0)
@@ -198,7 +198,7 @@ static void *ttynvt_read_net(void *arg)
if (tn_res == 0)
{
tty->rxcnt = tty->blen;
ttynvt_notify(tty);
_notify(tty);
}
pthread_mutex_unlock(&tty->tty_lock);
}
@@ -206,17 +206,17 @@ static void *ttynvt_read_net(void *arg)
}
if (res == 0)
ttynvt_log(LOG_INFO, "Connection closed by remote host\n");
_log(LOG_INFO, "Connection closed by remote host\n");
else
ttynvt_log(LOG_ERR, "Rx read error:%s\n", strerror(errno));
_log(LOG_ERR, "Rx read error:%s\n", strerror(errno));
tty->error = 1;
ttynvt_notify(tty);
_notify(tty);
return 0;
}
static int srv_connect(const char *host, unsigned int port)
static int _srv_connect(const char *host, unsigned int port)
{
struct sockaddr_in serveraddr;
struct hostent *server;
@@ -225,14 +225,14 @@ static int srv_connect(const char *host, unsigned int port)
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
ttynvt_log(LOG_ERR, "Socket open failed: %s\n", strerror(errno));
_log(LOG_ERR, "Socket open failed: %s\n", strerror(errno));
return sockfd;
}
server = gethostbyname(host);
if (server == NULL)
{
ttynvt_log(LOG_ERR, "Cannot resolve host name: %s\n", strerror(errno));
_log(LOG_ERR, "Cannot resolve host name: %s\n", strerror(errno));
close(sockfd);
return -1;
}
@@ -246,8 +246,8 @@ static int srv_connect(const char *host, unsigned int port)
err = connect(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));
if (err < 0)
{
ttynvt_log(LOG_ERR, "Failed to connect to: %s:%u:%s\n",
host, port, strerror(errno));
_log(LOG_ERR, "Failed to connect to: %s:%u:%s\n",
host, port, strerror(errno));
close(sockfd);
return -1;
}
@@ -255,7 +255,7 @@ static int srv_connect(const char *host, unsigned int port)
return sockfd;
}
static int srv_write(void *cctx, const void *buf, int len)
static int _srv_write(void *cctx, const void *buf, int len)
{
ttynvt_t *tty = cctx;
int res;
@@ -265,7 +265,7 @@ static int srv_write(void *cctx, const void *buf, int len)
return res;
}
static int srv_read(void *cctx, int timeout)
static int _srv_read(void *cctx, int timeout)
{
ttynvt_t *tty = cctx;
int res;
@@ -294,13 +294,13 @@ static int srv_read(void *cctx, int timeout)
return 1;
}
static void modem_status_cb(void *cctx, int status)
static void _modem_status_cb(void *cctx, int status)
{
ttynvt_t *tty = cctx;
tty->mcr &= ~(TIOCM_CD | TIOCM_RI | TIOCM_CTS | TIOCM_DSR);
ttynvt_log(LOG_INFO, "Modem status: 0x%02x\n", status);
_log(LOG_INFO, "Modem status: 0x%02x\n", status);
if (status & TNS_STATE_CD)
tty->mcr |= TIOCM_CD;
@@ -326,7 +326,7 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
return;
}
tty->tn = telnet_ctx_init(tty, srv_write, srv_read, modem_status_cb);
tty->tn = telnet_ctx_init(tty, _srv_write, _srv_read, _modem_status_cb);
if (!tty->tn)
{
free(tty);
@@ -334,7 +334,7 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
return;
}
sockfd = srv_connect(ttynvt_param.host, ttynvt_param.port);
sockfd = _srv_connect(ttynvt_param.host, ttynvt_param.port);
if (sockfd < 0)
{
free(tty->tn);
@@ -369,7 +369,7 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
if (pthread_mutex_init(&tty->tty_lock, NULL) < 0 ||
pthread_mutex_init(&tty->poll_lock, NULL) < 0 ||
pthread_cond_init(&tty->cond, NULL) < 0 ||
pthread_create(&tty->thread_id, NULL, &ttynvt_read_net, tty))
pthread_create(&tty->thread_id, NULL, &_read_net, tty))
{
free(tty->tn);
free(tty);
@@ -381,8 +381,8 @@ static void ttynvt_open(fuse_req_t req, struct fuse_file_info *info)
info->nonseekable = 1;
info->direct_io = 1;
ttynvt_log(LOG_INFO, "Open connection to server: %s:%d\n",
ttynvt_param.host, ttynvt_param.port);
_log(LOG_INFO, "Open connection to server: %s:%d\n",
ttynvt_param.host, ttynvt_param.port);
fuse_reply_open(req, info);
}
@@ -397,7 +397,7 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off,
{
if (tty->epipe == 0)
{
ttynvt_log(LOG_WARNING, "Rx EPIPE\n");
_log(LOG_WARNING, "Rx EPIPE\n");
tty->epipe = 1;
fuse_reply_buf(req, tty->buf, 0);
}
@@ -450,7 +450,7 @@ ttynvt_write(fuse_req_t req, const char *data, size_t size, off_t off,
if (tty->nonblock || (info->flags & O_NONBLOCK))
{
size_t write_avail = ttynvt_write_avail(tty);
size_t write_avail = _write_avail(tty);
if (size > write_avail)
size = write_avail;
@@ -570,8 +570,7 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
telnet_rfc2217_ctl(tty->tn, TNS_CTL_DTR_ON);
}
ttynvt_log
(LOG_DEBUG,
_log(LOG_DEBUG,
"CFG ioctl: %u%c%u%u %cCTSRTS %cCREAD %cHUPCL %cCLOCAL\n",
baudrate(speed), pstr[par], csize, sb,
tio.c_cflag & CRTSCTS ? '+' : '-',
@@ -598,7 +597,7 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
* buffer */
if (out_bufsz)
{
size_t rx_size = ttynvt_read_avail(tty);
size_t rx_size = _read_avail(tty);
fuse_reply_ioctl(req, 0, &rx_size, sizeof(size_t));
}
@@ -613,7 +612,7 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
* buffer */
if (out_bufsz)
{
size_t tx_size = ttynvt_write_avail(tty);
size_t tx_size = _write_avail(tty);
fuse_reply_ioctl(req, 0, &tx_size, sizeof(size_t));
}
@@ -723,9 +722,8 @@ ttynvt_ioctl(fuse_req_t req, int cmd, void *arg,
tiocm = *(unsigned int *)in_buf;
fuse_reply_ioctl(req, 0, 0, 0);
ttynvt_log(LOG_DEBUG, "CFG ioctl: DTR=%c RTS=%c\n",
tiocm & TIOCM_DTR ? '1' : '0',
tiocm & TIOCM_RTS ? '1' : '0');
_log(LOG_DEBUG, "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);
@@ -763,12 +761,12 @@ ttynvt_poll(fuse_req_t req, struct fuse_file_info *info,
ttynvt_t *tty = (ttynvt_t *) (uintptr_t) info->fh;
int revents = 0;
ttynvt_update_notify(tty, ph);
_update_notify(tty, ph);
if (ttynvt_write_avail(tty) > 0)
if (_write_avail(tty) > 0)
revents |= POLLOUT;
if (ttynvt_read_avail(tty) > 0)
if (_read_avail(tty) > 0)
revents |= POLLIN;
if (tty->error)