1
0
Fork 0

Cleanup: Removed unused parts from net/

This commit is contained in:
Philipp Schafft 2022-03-19 10:15:56 +00:00
parent 617d219021
commit 4c8da7bdc4
4 changed files with 1 additions and 134 deletions

View File

@ -2,7 +2,7 @@
AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = BUILDING COPYING README TODO test_resolver.c
EXTRA_DIST = BUILDING COPYING README TODO
noinst_LTLIBRARIES = libicenet.la
noinst_HEADERS = resolver.h sock.h

View File

@ -102,26 +102,6 @@ void sock_shutdown(void)
resolver_shutdown();
}
/* sock_get_localip
**
** gets the local ip address for the machine
** the ip it returns *should* be on the internet.
** in any case, it's as close as we can hope to get
** unless someone has better ideas on how to do this
*/
char *sock_get_localip(char *buff, int len)
{
char temp[1024];
if (gethostname(temp, sizeof(temp)) != 0)
return NULL;
if (resolver_getip(temp, buff, len))
return buff;
return NULL;
}
/* sock_error
**
** returns the last socket error
@ -175,32 +155,6 @@ int sock_recoverable(int error)
}
}
int sock_stalled (int error)
{
switch (error)
{
case EAGAIN:
case EINPROGRESS:
case EALREADY:
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
#if defined (WSAEWOULDBLOCK) && WSAEWOULDBLOCK != EWOULDBLOCK
case WSAEWOULDBLOCK:
#endif
#if defined (WSAEINPROGRESS) && WSAEINPROGRESS != EINPROGRESS
case WSAEINPROGRESS:
#endif
#ifdef ERESTART
case ERESTART:
#endif
return 1;
default:
return 0;
}
}
static int sock_connect_pending (int error)
{
return error == EINPROGRESS || error == EALREADY;
@ -319,45 +273,6 @@ int sock_close(sock_t sock)
#endif
}
/* sock_writev
*
* write multiple buffers at once, return bytes actually written
*/
#ifdef HAVE_WRITEV
ssize_t sock_writev (sock_t sock, const struct iovec *iov, size_t count)
{
return writev (sock, iov, count);
}
#else
ssize_t sock_writev (sock_t sock, const struct iovec *iov, size_t count)
{
int i = count, accum = 0, ret;
const struct iovec *v = iov;
while (i)
{
if (v->iov_base && v->iov_len)
{
ret = sock_write_bytes (sock, v->iov_base, v->iov_len);
if (ret == -1 && accum==0)
return -1;
if (ret == -1)
ret = 0;
accum += ret;
if (ret < (int)v->iov_len)
break;
}
v++;
i--;
}
return accum;
}
#endif
/* sock_write_bytes
**
** write bytes to the socket
@ -377,16 +292,6 @@ int sock_write_bytes(sock_t sock, const void *buff, size_t len)
return send(sock, buff, len, 0);
}
/* sock_write_string
**
** writes a string to a socket
** This function must only be called with a blocking socket.
*/
int sock_write_string(sock_t sock, const char *buff)
{
return (sock_write_bytes(sock, buff, strlen(buff)) > 0);
}
/* sock_write
**
** write a formatted string to the socket

View File

@ -44,18 +44,6 @@
#include <compat.h>
#endif
#ifdef HAVE_SYS_UIO_H
#include <sys/uio.h>
#else
#ifndef _SYS_UIO_H
struct iovec
{
void *iov_base;
size_t iov_len;
};
#endif
#endif
#if !defined(HAVE_INET_ATON) && defined(HAVE_INET_PTON)
#define inet_aton(a,b) inet_pton(AF_INET, (a), (b))
#endif
@ -90,11 +78,9 @@ typedef enum {
#ifdef _mangle
# define sock_initialize _mangle(sock_initialize)
# define sock_shutdown _mangle(sock_shutdown)
# define sock_get_localip _mangle(sock_get_localip)
# define sock_error _mangle(sock_error)
# define sock_set_error _mangle(sock_set_error)
# define sock_recoverable _mangle(sock_recoverable)
# define sock_stalled _mangle(sock_stalled)
# define sock_valid_socket _mangle(sock_valid_socket)
# define sock_set_blocking _mangle(sock_set_blocking)
# define sock_set_nolinger _mangle(sock_set_nolinger)
@ -108,8 +94,6 @@ typedef enum {
# define sock_write_bytes _mangle(sock_write_bytes)
# define sock_write _mangle(sock_write)
# define sock_write_fmt _mangle(sock_write_fmt)
# define sock_write_string _mangle(sock_write_string)
# define sock_writev _mangle(sock_writev)
# define sock_read_bytes _mangle(sock_read_bytes)
# define sock_read_line _mangle(sock_read_line)
# define sock_get_server_socket _mangle(sock_get_server_socket)
@ -124,10 +108,8 @@ typedef enum {
/* Misc socket functions */
void sock_initialize(void);
void sock_shutdown(void);
char *sock_get_localip(char *buff, int len);
int sock_error(void);
int sock_recoverable(int error);
int sock_stalled(int error);
int sock_valid_socket(sock_t sock);
int sock_active (sock_t sock);
int sock_set_blocking(sock_t sock, int block);
@ -148,9 +130,6 @@ int sock_connected(sock_t sock, int timeout);
int sock_write_bytes(sock_t sock, const void *buff, size_t len);
int sock_write(sock_t sock, const char *fmt, ...);
int sock_write_fmt(sock_t sock, const char *fmt, va_list ap);
int sock_write_string(sock_t sock, const char *buff);
ssize_t sock_writev (sock_t sock, const struct iovec *iov, size_t count);
/* Socket read functions */
int sock_read_bytes(sock_t sock, char *buff, size_t len);

View File

@ -1,17 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include "resolver.h"
int main()
{
char buff[1024];
resolver_initialize();
printf("I got %s, when looking up %s.\n", resolver_getip("bach.greenwitch.com", buff, 1024), "bach.greenwitch.com");
printf("I got %s, when looking up %s.\n", resolver_getname("207.181.249.14", buff, 1024), "207.181.249.14");
return 0;
}