qulogic/pidgin

Delete some now-unused networking bits

2020-12-21, Elliott Sales de Andrade
4be4ea8a8dca
Parents ef2638e507a9
Children 48dfed6f4f1f
Delete some now-unused networking bits

* Remove several unnecessary networking headers and types.
* Remove some unused Windows networking wrappers.

Testing Done:
Compile only

Reviewed at https://reviews.imfreedom.org/r/306/
--- a/libpurple/network.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/network.c Mon Dec 21 23:17:45 2020 -0600
@@ -30,9 +30,6 @@
#include <netinet/in.h>
#include <net/if.h>
#include <sys/ioctl.h>
-#ifdef HAVE_GETIFADDRS
-#include <ifaddrs.h>
-#endif
#else
#include <nspapi.h>
#endif
@@ -50,16 +47,6 @@
#include "stun.h"
#include "upnp.h"
-/*
- * Calling sizeof(struct ifreq) isn't always correct on
- * Mac OS X (and maybe others).
- */
-#ifdef _SIZEOF_ADDR_IFREQ
-# define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a)
-#else
-# define HX_SIZE_OF_IFREQ(a) sizeof(a)
-#endif
-
static gboolean force_online = FALSE;
/* Cached IP addresses for STUN and TURN servers (set globally in prefs) */
--- a/libpurple/protocols/bonjour/bonjour_ft.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/protocols/bonjour/bonjour_ft.c Mon Dec 21 23:17:45 2020 -0600
@@ -23,12 +23,6 @@
#include <config.h>
#include <sys/types.h>
-#ifndef _WIN32
-# include <arpa/inet.h>
-# include <netdb.h>
-# include <sys/socket.h>
-#endif
-#include <errno.h>
#include <nice.h>
@@ -37,14 +31,6 @@
#include "bonjour.h"
#include "bonjour_ft.h"
-typedef union
-{
- struct sockaddr sa;
- struct sockaddr_in in;
- struct sockaddr_in6 in6;
- struct sockaddr_storage storage;
-} common_sockaddr_t;
-
static void
bonjour_bytestreams_init(PurpleXfer *xfer);
static void
--- a/libpurple/protocols/bonjour/xmpp.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/protocols/bonjour/xmpp.c Mon Dec 21 23:17:45 2020 -0600
@@ -24,25 +24,12 @@
#include <purple.h>
-#ifndef _WIN32
-#include <net/if.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
#include <sys/types.h>
-/* Solaris */
-#if defined (__SVR4) && defined (__sun)
-#include <sys/sockio.h>
-#endif
-
#include <glib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#include <fcntl.h>
#include "xmpp.h"
#include "parser.h"
@@ -50,12 +37,6 @@
#include "buddy.h"
#include "bonjour_ft.h"
-#ifdef _SIZEOF_ADDR_IFREQ
-# define HX_SIZE_OF_IFREQ(a) _SIZEOF_ADDR_IFREQ(a)
-#else
-# define HX_SIZE_OF_IFREQ(a) sizeof(a)
-#endif
-
#define STREAM_END "</stream:stream>"
/* TODO: specify version='1.0' and send stream features */
#define DOCTYPE "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" \
--- a/libpurple/protocols/jabber/si.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/protocols/jabber/si.c Mon Dec 21 23:17:45 2020 -0600
@@ -26,9 +26,6 @@
#include <errno.h>
#include <sys/types.h>
-#ifndef _WIN32
-# include <sys/socket.h>
-#endif
#include <glib/gi18n-lib.h>
--- a/libpurple/protocols/jabber/useravatar.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/protocols/jabber/useravatar.c Mon Dec 21 23:17:45 2020 -0600
@@ -23,10 +23,6 @@
#include <config.h>
-#ifndef _WIN32
-# include <arpa/inet.h>
-#endif
-
#include <glib/gi18n-lib.h>
#include <purple.h>
--- a/libpurple/stun.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/stun.c Mon Dec 21 23:17:45 2020 -0600
@@ -31,11 +31,6 @@
#include <gio/gio.h>
-/* Solaris */
-#if defined (__SVR4) && defined (__sun)
-#include <sys/sockio.h>
-#endif
-
#include "debug.h"
#include "account.h"
#include "network.h"
@@ -48,10 +43,6 @@
#define ATTRIB_MAPPEDADDRESS 0x0001
-#ifndef _SIZEOF_ADDR_IFREQ
-# define _SIZEOF_ADDR_IFREQ(a) sizeof(a)
-#endif
-
struct stun_header {
guint16 type;
guint16 len;
--- a/libpurple/win32/libc_interface.c Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/win32/libc_interface.c Mon Dec 21 23:17:45 2020 -0600
@@ -42,66 +42,7 @@
# define S_ISDIR(m) (((m)&S_IFDIR)==S_IFDIR)
#endif
-/* helpers */
-static int wpurple_is_socket( int fd ) {
- int optval;
- int optlen = sizeof(int);
-
- if( (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void*)&optval, &optlen)) == SOCKET_ERROR ) {
- int error = WSAGetLastError();
- if( error == WSAENOTSOCK )
- return FALSE;
- else {
- purple_debug(PURPLE_DEBUG_WARNING, "wpurple", "wpurple_is_socket: getsockopt returned error: %d\n", error);
- return FALSE;
- }
- }
- return TRUE;
-}
-
/* socket.h */
-int wpurple_socket (int namespace, int style, int protocol) {
- int ret;
-
- ret = socket( namespace, style, protocol );
-
- if (ret == (int)INVALID_SOCKET) {
- errno = WSAGetLastError();
- return -1;
- }
- return ret;
-}
-
-int wpurple_connect(int socket, struct sockaddr *addr, u_long length) {
- int ret;
-
- ret = connect( socket, addr, length );
-
- if( ret == SOCKET_ERROR ) {
- errno = WSAGetLastError();
- if( errno == WSAEWOULDBLOCK )
- errno = WSAEINPROGRESS;
- return -1;
- }
- return 0;
-}
-
-int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr) {
- if(getsockopt(socket, level, optname, optval, optlenptr) == SOCKET_ERROR ) {
- errno = WSAGetLastError();
- return -1;
- }
- return 0;
-}
-
-int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) {
- if(setsockopt(socket, level, optname, optval, optlen) == SOCKET_ERROR ) {
- errno = WSAGetLastError();
- return -1;
- }
- return 0;
-}
-
int wpurple_getsockname(int socket, struct sockaddr *addr, socklen_t *lenptr) {
if(getsockname(socket, addr, lenptr) == SOCKET_ERROR) {
errno = WSAGetLastError();
@@ -110,34 +51,6 @@
return 0;
}
-int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length) {
- if(bind(socket, addr, length) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- return -1;
- }
- return 0;
-}
-
-int wpurple_listen(int socket, unsigned int n) {
- if(listen(socket, n) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- return -1;
- }
- return 0;
-}
-
-int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen) {
- int ret;
- if ((ret = sendto(socket, buf, len, flags, to, tolen)
- ) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
- errno = EAGAIN;
- return -1;
- }
- return ret;
-}
-
/* fcntl.h */
/* This is not a full implementation of fcntl. Update as needed.. */
int wpurple_fcntl(int socket, int command, ...) {
@@ -238,96 +151,6 @@
}/*end switch*/
}
-/* arpa/inet.h */
-int wpurple_inet_aton(const char *name, struct in_addr *addr) {
- if((addr->s_addr = inet_addr(name)) == INADDR_NONE)
- return 0;
- else
- return 1;
-}
-
-/* Thanks to GNU wget for this inet_ntop() implementation */
-const char *
-wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt)
-{
- /* struct sockaddr can't accomodate struct sockaddr_in6. */
- union {
- struct sockaddr_in6 sin6;
- struct sockaddr_in sin;
- } sa;
- DWORD dstlen = cnt;
- size_t srcsize;
-
- ZeroMemory(&sa, sizeof(sa));
- switch (af)
- {
- case AF_INET:
- sa.sin.sin_family = AF_INET;
- sa.sin.sin_addr = *(struct in_addr *) src;
- srcsize = sizeof (sa.sin);
- break;
- case AF_INET6:
- sa.sin6.sin6_family = AF_INET6;
- sa.sin6.sin6_addr = *(struct in6_addr *) src;
- srcsize = sizeof (sa.sin6);
- break;
- default:
- abort ();
- }
-
- if (WSAAddressToString ((struct sockaddr *) &sa, srcsize, NULL, dst, &dstlen) != 0)
- {
- errno = WSAGetLastError();
- return NULL;
- }
- return (const char *) dst;
-}
-
-int
-wpurple_inet_pton(int af, const char *src, void *dst)
-{
- /* struct sockaddr can't accomodate struct sockaddr_in6. */
- union {
- struct sockaddr_in6 sin6;
- struct sockaddr_in sin;
- } sa;
- int srcsize;
-
- switch(af)
- {
- case AF_INET:
- sa.sin.sin_family = AF_INET;
- srcsize = sizeof (sa.sin);
- break;
- case AF_INET6:
- sa.sin6.sin6_family = AF_INET6;
- srcsize = sizeof (sa.sin6);
- break;
- default:
- errno = WSAEPFNOSUPPORT;
- return -1;
- }
-
- if (WSAStringToAddress((LPTSTR)src, af, NULL, (struct sockaddr *) &sa, &srcsize) != 0)
- {
- errno = WSAGetLastError();
- return -1;
- }
-
- switch(af)
- {
- case AF_INET:
- memcpy(dst, &sa.sin.sin_addr, sizeof(sa.sin.sin_addr));
- break;
- case AF_INET6:
- memcpy(dst, &sa.sin6.sin6_addr, sizeof(sa.sin6.sin6_addr));
- break;
- }
-
- return 1;
-}
-
-
/* netdb.h */
struct hostent* wpurple_gethostbyname(const char *name) {
struct hostent *hp;
@@ -341,94 +164,6 @@
/* unistd.h */
-/*
- * We need to figure out whether fd is a file or socket handle.
- */
-int wpurple_read(int fd, void *buf, unsigned int size) {
- int ret;
-
- if (fd < 0) {
- errno = EBADF;
- g_return_val_if_reached(-1);
- }
-
- if(wpurple_is_socket(fd)) {
- if((ret = recv(fd, buf, size, 0)) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
- errno = EAGAIN;
- return -1;
- }
- else {
- /* success reading socket */
- return ret;
- }
- } else {
- /* fd is not a socket handle.. pass it off to read */
- return _read(fd, buf, size);
- }
-}
-
-int wpurple_send(int fd, const void *buf, unsigned int size, int flags) {
- int ret;
-
- ret = send(fd, buf, size, flags);
-
- if (ret == SOCKET_ERROR) {
- errno = WSAGetLastError();
- if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
- errno = EAGAIN;
- return -1;
- }
- return ret;
-}
-
-int wpurple_write(int fd, const void *buf, unsigned int size) {
-
- if (fd < 0) {
- errno = EBADF;
- g_return_val_if_reached(-1);
- }
-
- if(wpurple_is_socket(fd))
- return wpurple_send(fd, buf, size, 0);
- else
- return _write(fd, buf, size);
-}
-
-int wpurple_recv(int fd, void *buf, size_t len, int flags) {
- int ret;
-
- if((ret = recv(fd, buf, len, flags)) == SOCKET_ERROR) {
- errno = WSAGetLastError();
- if(errno == WSAEWOULDBLOCK || errno == WSAEINPROGRESS)
- errno = EAGAIN;
- return -1;
- } else {
- return ret;
- }
-}
-
-int wpurple_close(int fd) {
- int ret;
-
- if (fd < 0) {
- errno = EBADF;
- g_return_val_if_reached(-1);
- }
-
- if( wpurple_is_socket(fd) ) {
- if( (ret = closesocket(fd)) == SOCKET_ERROR ) {
- errno = WSAGetLastError();
- return -1;
- }
- else
- return 0;
- }
- else
- return _close(fd);
-}
-
int wpurple_gethostname(char *name, size_t size) {
if(gethostname(name, size) == SOCKET_ERROR) {
errno = WSAGetLastError();
@@ -436,24 +171,3 @@
}
return 0;
}
-
-/* sys/time.h */
-
-int wpurple_gettimeofday(struct timeval *p, struct timezone *z) {
- int res = 0;
- struct _timeb timebuffer;
-
- if (z != 0) {
- _tzset();
- z->tz_minuteswest = _timezone/60;
- z->tz_dsttime = _daylight;
- }
-
- if (p != 0) {
- _ftime(&timebuffer);
- p->tv_sec = timebuffer.time; /* seconds since 1-1-1970 */
- p->tv_usec = timebuffer.millitm*1000; /* microseconds */
- }
-
- return res;
-}
--- a/libpurple/win32/libc_interface.h Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/win32/libc_interface.h Mon Dec 21 23:17:45 2020 -0600
@@ -46,36 +46,9 @@
#endif
/* sys/socket.h */
-#define socket( domain, style, protocol ) \
-wpurple_socket( domain, style, protocol )
-
-#define connect( socket, addr, length ) \
-wpurple_connect( socket, addr, length )
-
-#define getsockopt( socket, level, optname, optval, optlenptr ) \
-wpurple_getsockopt( socket, level, optname, optval, optlenptr )
-
-#define setsockopt( socket, level, optname, optval, optlen ) \
-wpurple_setsockopt( socket, level, optname, optval, optlen )
-
#define getsockname( socket, addr, lenptr ) \
wpurple_getsockname( socket, addr, lenptr )
-#define bind( socket, addr, length ) \
-wpurple_bind( socket, addr, length )
-
-#define listen( socket, n ) \
-wpurple_listen( socket, n )
-
-#define sendto(socket, buf, len, flags, to, tolen) \
-wpurple_sendto(socket, buf, len, flags, to, tolen)
-
-#define recv(fd, buf, len, flags) \
-wpurple_recv(fd, buf, len, flags)
-
-#define send(socket, buf, buflen, flags) \
-wpurple_send(socket, buf, buflen, flags)
-
/* sys/ioctl.h */
#define ioctl( fd, command, val ) \
wpurple_ioctl( fd, command, val )
@@ -84,34 +57,10 @@
#define fcntl( fd, command, ... ) \
wpurple_fcntl( fd, command, ##__VA_ARGS__ )
-/* arpa/inet.h */
-#define inet_aton( name, addr ) \
-wpurple_inet_aton( name, addr )
-
-#define inet_ntop( af, src, dst, cnt ) \
-wpurple_inet_ntop( af, src, dst, cnt )
-
-#define inet_pton( af, src, dst ) \
-wpurple_inet_pton( af, src, dst )
-
/* netdb.h */
#define gethostbyname( name ) \
wpurple_gethostbyname( name )
-/* netinet/in.h */
-#define ntohl( netlong ) \
-(unsigned int)ntohl( netlong )
-
-/* unistd.h */
-#define read( fd, buf, buflen ) \
-wpurple_read( fd, buf, buflen )
-
-#define write( socket, buf, buflen ) \
-wpurple_write( socket, buf, buflen )
-
-#define close( fd ) \
-wpurple_close( fd )
-
#define gethostname( name, size ) \
wpurple_gethostname( name, size )
--- a/libpurple/win32/libc_internal.h Mon Dec 21 21:45:26 2020 -0600
+++ b/libpurple/win32/libc_internal.h Mon Dec 21 23:17:45 2020 -0600
@@ -27,22 +27,7 @@
G_BEGIN_DECLS
/* sys/socket.h */
-int wpurple_socket(int domain, int style, int protocol);
-int wpurple_connect(int socket, struct sockaddr *addr, u_long length);
-int wpurple_getsockopt(int socket, int level, int optname, void *optval, socklen_t *optlenptr);
-int wpurple_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen);
int wpurple_getsockname (int socket, struct sockaddr *addr, socklen_t *lenptr);
-int wpurple_bind(int socket, struct sockaddr *addr, socklen_t length);
-int wpurple_listen(int socket, unsigned int n);
-int wpurple_sendto(int socket, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen);
-int wpurple_recv(int fd, void *buf, size_t len, int flags);
-int wpurple_send(int fd, const void *buf, unsigned int size, int flags);
-
-/* arpa/inet.h */
-int wpurple_inet_aton(const char *name, struct in_addr *addr);
-const char *
-wpurple_inet_ntop (int af, const void *src, char *dst, socklen_t cnt);
-int wpurple_inet_pton(int af, const char *src, void *dst);
/* netdb.h */
struct hostent* wpurple_gethostbyname(const char *name);
@@ -99,9 +84,6 @@
int wpurple_gettimeofday(struct timeval *p, struct timezone *z);
/* unistd.h */
-int wpurple_read(int fd, void *buf, unsigned int size);
-int wpurple_write(int fd, const void *buf, unsigned int size);
-int wpurple_close(int fd);
int wpurple_gethostname(char *name, size_t size);
G_END_DECLS
--- a/meson.build Mon Dec 21 21:45:26 2020 -0600
+++ b/meson.build Mon Dec 21 23:17:45 2020 -0600
@@ -174,43 +174,6 @@
FINCH_PLUGINDIR = abslibdir / 'finch-@0@'.format(purple_major_version)
conf.set_quoted('FINCH_PLUGINDIR', FINCH_PLUGINDIR)
-# Check for inet_aton
-if not IS_WIN32
- if not compiler.has_function('inet_aton')
- if not compiler.has_function('inet_aton', args : '-lresolv')
- # FIXME: Someone needs to link with -lresolv if needed.
- error('inet_aton not found')
- endif
- endif
-endif
-if compiler.has_function('gethostent', args : '-lnsl')
- conf.set('HAVE_LIBNSL', true)
-endif
-if IS_WIN32
- conf.set('HAVE_GETADDRINFO', true)
- conf.set('HAVE_INET_NTOP', true)
-else
- if not compiler.has_function('socket')
- if not compiler.has_function('socket', args : '-lsocket')
- error('socket not found')
- endif
- endif
- # If all goes well, by this point the previous two checks will have
- # pulled in -lsocket and -lnsl if we need them.
- if compiler.has_function('getaddrinfo')
- conf.set('HAVE_GETADDRINFO', true)
- else
- if compiler.has_function('getaddrinfo', args : '-lsocket -lnsl')
- conf.set('HAVE_GETADDRINFO', true)
- # FIXME: LIBS += declare_dependency(link_with : ['socket', 'nsl'])
- endif
- endif
- conf.set('HAVE_INET_NTOP',
- compiler.has_function('inet_ntop'))
-endif
-conf.set('HAVE_GETIFADDRS',
- compiler.has_function('getifaddrs'))
-
# Check for socklen_t (in Unix98)
if IS_WIN32
socket_header = 'ws2tcpip.h'
@@ -236,15 +199,6 @@
compiler.has_member('struct sockaddr', 'sa_len',
prefix : '#include <@0@>'.format(socket_header)))
-# Check for v6-only sockets
-if IS_WIN32
- header = 'ws2tcpip.h'
-else
- header = 'netinet/in.h'
-endif
-conf.set('HAVE_IPV6_V6ONLY',
- compiler.has_header_symbol(header, 'IPV6_V6ONLY'))
-
# Windows and Haiku do not use libm for the math functions, they are part
# of the C library
math = compiler.find_library('m')
@@ -664,7 +618,7 @@
#######################################################################
# Check for Cyrus-SASL (for xmpp/irc)
#######################################################################
-foreach func : ['snprintf', 'connect']
+foreach func : ['snprintf']
conf.set('HAVE_' + func.to_upper(),
compiler.has_function(func))
endforeach