mirror of
https://github.com/tio/tio.git
synced 2026-05-01 14:57:59 +02:00
Configure socket mapping flags from tty parsing logic. Remove duplicate parsing logic in socket
This commit is contained in:
parent
65b3353f57
commit
5651c1c5d7
3 changed files with 10 additions and 41 deletions
44
src/socket.c
44
src/socket.c
|
|
@ -41,9 +41,9 @@ static int sockfd;
|
||||||
static int clientfds[MAX_SOCKET_CLIENTS];
|
static int clientfds[MAX_SOCKET_CLIENTS];
|
||||||
static int socket_family = AF_UNSPEC;
|
static int socket_family = AF_UNSPEC;
|
||||||
static int port_number = SOCKET_PORT_DEFAULT;
|
static int port_number = SOCKET_PORT_DEFAULT;
|
||||||
static bool map_i_nl_cr = false;
|
bool map_i_nl_cr = false;
|
||||||
static bool map_i_cr_nl = false;
|
bool map_i_cr_nl = false;
|
||||||
static bool map_ign_cr = false;
|
bool map_ign_cr = false;
|
||||||
|
|
||||||
static const char *socket_filename(void)
|
static const char *socket_filename(void)
|
||||||
{
|
{
|
||||||
|
|
@ -126,9 +126,6 @@ void socket_configure(void)
|
||||||
struct sockaddr_in6 sockaddr_inet6 = {};
|
struct sockaddr_in6 sockaddr_inet6 = {};
|
||||||
struct sockaddr *sockaddr_p;
|
struct sockaddr *sockaddr_p;
|
||||||
socklen_t socklen;
|
socklen_t socklen;
|
||||||
bool token_found = true;
|
|
||||||
char *token = NULL;
|
|
||||||
char *buffer;
|
|
||||||
|
|
||||||
/* Parse socket string */
|
/* Parse socket string */
|
||||||
|
|
||||||
|
|
@ -181,41 +178,6 @@ void socket_configure(void)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure any specified input mappings */
|
|
||||||
buffer = strdup(option.map);
|
|
||||||
while (token_found == true)
|
|
||||||
{
|
|
||||||
if (token == NULL)
|
|
||||||
{
|
|
||||||
token = strtok(buffer,",");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
token = strtok(NULL, ",");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (token != NULL)
|
|
||||||
{
|
|
||||||
if (strcmp(token,"INLCR") == 0)
|
|
||||||
{
|
|
||||||
map_i_nl_cr = true;
|
|
||||||
}
|
|
||||||
else if (strcmp(token,"IGNCR") == 0)
|
|
||||||
{
|
|
||||||
map_ign_cr = true;
|
|
||||||
}
|
|
||||||
else if (strcmp(token,"ICRNL") == 0)
|
|
||||||
{
|
|
||||||
map_i_cr_nl = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
token_found = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(buffer);
|
|
||||||
|
|
||||||
/* Configure socket */
|
/* Configure socket */
|
||||||
|
|
||||||
switch (socket_family)
|
switch (socket_family)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
|
extern bool map_i_nl_cr;
|
||||||
|
extern bool map_i_cr_nl;
|
||||||
|
extern bool map_ign_cr;
|
||||||
|
|
||||||
void socket_configure(void);
|
void socket_configure(void);
|
||||||
void socket_write(char input_char);
|
void socket_write(char input_char);
|
||||||
int socket_add_fds(fd_set *fds, bool connected);
|
int socket_add_fds(fd_set *fds, bool connected);
|
||||||
|
|
|
||||||
|
|
@ -987,14 +987,17 @@ void tty_configure(void)
|
||||||
if (strcmp(token,"INLCR") == 0)
|
if (strcmp(token,"INLCR") == 0)
|
||||||
{
|
{
|
||||||
tio.c_iflag |= INLCR;
|
tio.c_iflag |= INLCR;
|
||||||
|
map_i_nl_cr = true;
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"IGNCR") == 0)
|
else if (strcmp(token,"IGNCR") == 0)
|
||||||
{
|
{
|
||||||
tio.c_iflag |= IGNCR;
|
tio.c_iflag |= IGNCR;
|
||||||
|
map_ign_cr = true;
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"ICRNL") == 0)
|
else if (strcmp(token,"ICRNL") == 0)
|
||||||
{
|
{
|
||||||
tio.c_iflag |= ICRNL;
|
tio.c_iflag |= ICRNL;
|
||||||
|
map_i_cr_nl = true;
|
||||||
}
|
}
|
||||||
else if (strcmp(token,"OCRNL") == 0)
|
else if (strcmp(token,"OCRNL") == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue