mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
libsupport: Add xgetpeername
The patch adds redirections for getpeername. Reviewed-by: Arjun Shankar <arjun@redhat.com>
This commit is contained in:
parent
42e48e720c
commit
6687a6e3f9
@ -131,6 +131,7 @@ libsupport-routines = \
|
||||
xfreopen \
|
||||
xftruncate \
|
||||
xgetline \
|
||||
xgetpeername \
|
||||
xgetsockname \
|
||||
xlisten \
|
||||
xlseek \
|
||||
|
30
support/xgetpeername.c
Normal file
30
support/xgetpeername.c
Normal file
@ -0,0 +1,30 @@
|
||||
/* getpeername with error checking.
|
||||
Copyright (C) 2024 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, see
|
||||
<https://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <support/xsocket.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <support/check.h>
|
||||
|
||||
void
|
||||
xgetpeername (int fd, struct sockaddr *sa, socklen_t *plen)
|
||||
{
|
||||
if (getpeername (fd, sa, plen) != 0)
|
||||
FAIL_EXIT1 ("getpeername (%d): %m", fd);
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
int xsocket (int, int, int);
|
||||
void xsetsockopt (int, int, int, const void *, socklen_t);
|
||||
void xgetsockname (int, struct sockaddr *, socklen_t *);
|
||||
void xgetpeername (int, struct sockaddr *, socklen_t *);
|
||||
void xconnect (int, const struct sockaddr *, socklen_t);
|
||||
void xbind (int, const struct sockaddr *, socklen_t);
|
||||
void xlisten (int, int);
|
||||
|
Loading…
Reference in New Issue
Block a user