diff --git a/examples/server.c b/examples/server.c index d8d2381..635f11b 100644 --- a/examples/server.c +++ b/examples/server.c @@ -54,16 +54,16 @@ int main(int argc, char **argv) { } if (isatty(info.fd) && grantpt(info.fd) == 0 && unlockpt(info.fd) == 0) { - char name[256]; + char *pts; - if (ptsname_r(info.fd, name, sizeof(name)) < 0) { + if ((pts = ptsname(info.fd)) == NULL) { fprintf(stderr, "%s: %s: %s: %s\n", - argv[0], argv[1], "ptsname_r()", strerror(errno)); + argv[0], argv[1], "ptsname()", strerror(errno)); goto error_open; } - fprintf(stderr, "pts %s\n", name); + fprintf(stderr, "pts %s\n", pts); } errno = 0; diff --git a/include/patty/ax25/sock.h b/include/patty/ax25/sock.h index 36e509d..bb72107 100644 --- a/include/patty/ax25/sock.h +++ b/include/patty/ax25/sock.h @@ -73,7 +73,7 @@ typedef struct _patty_ax25_sock { flags_hdlc; int fd; - char path[PATTY_AX25_SOCK_PATH_SIZE]; + char pty[PATTY_AX25_SOCK_PATH_SIZE]; void *tx_buf, *rx_buf; diff --git a/src/server.c b/src/server.c index ad7c3a0..6afffe2 100644 --- a/src/server.c +++ b/src/server.c @@ -555,7 +555,7 @@ static int server_socket(patty_ax25_server *server, int client) { response.ret = sock->fd; response.eno = 0; - memcpy(response.path, sock->path, sizeof(response.path)); + memcpy(response.path, patty_ax25_sock_pty(sock), sizeof(response.path)); return write(client, &response, sizeof(response)); @@ -1201,7 +1201,7 @@ static int handle_sabm(patty_ax25_server *server, fd_watch(server, remote->fd); - if (respond_accept(client, 0, 0, &frame->src, remote->path) < 0) { + if (respond_accept(client, 0, 0, &frame->src, remote->pty) < 0) { goto error_respond_accept; } diff --git a/src/sock.c b/src/sock.c index dc20c59..970040c 100644 --- a/src/sock.c +++ b/src/sock.c @@ -14,6 +14,7 @@ static int bind_pty(patty_ax25_sock *sock) { struct termios t; + char *pty; if ((sock->fd = open("/dev/ptmx", O_RDWR)) < 0) { goto error_open; @@ -27,10 +28,12 @@ static int bind_pty(patty_ax25_sock *sock) { goto error_unlockpt; } - if (ptsname_r(sock->fd, sock->path, sizeof(sock->path)) < 0) { - goto error_ptsname_r; + if ((pty = ptsname(sock->fd)) == NULL) { + goto error_ptsname; } + (void)strncpy(sock->pty, pty, sizeof(sock->pty)); + if (tcgetattr(sock->fd, &t) < 0) { goto error_tcgetattr; } @@ -45,7 +48,7 @@ static int bind_pty(patty_ax25_sock *sock) { error_tcsetattr: error_tcgetattr: -error_ptsname_r: +error_ptsname: error_unlockpt: error_grantpt: close(sock->fd); @@ -299,7 +302,7 @@ error_invalid: } char *patty_ax25_sock_pty(patty_ax25_sock *sock) { - return sock->path; + return sock->pty; } int patty_ax25_sock_bind_if(patty_ax25_sock *sock,