summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn-Mark Bell <jmb@netsurf-browser.org>2024-03-14 00:01:24 +0000
committerJohn-Mark Bell <jmb@netsurf-browser.org>2024-03-14 00:01:24 +0000
commitae8b58e408fb588c3d730a5804270d58cb4cb3ba (patch)
tree9c692fd934d6f665129f6e01375a07fb087268e4
parentbda0a97fea93993eaf3632103d01315fc3b8017d (diff)
downloadnetsurf-ae8b58e408fb588c3d730a5804270d58cb4cb3ba.tar.gz
netsurf-ae8b58e408fb588c3d730a5804270d58cb4cb3ba.tar.bz2
Socket: more fixes for win32/aos3
These special snowflakes have specialised socket close APIs, so ensure that we use the correct one. Additionally, there's no guarantee that their socket() API signature matches the POSIX definition, so wrap it up and cast the result.
-rw-r--r--desktop/gui_factory.c14
-rw-r--r--utils/inet.h5
2 files changed, 17 insertions, 2 deletions
diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c
index d93508890..0d4d9a904 100644
--- a/desktop/gui_factory.c
+++ b/desktop/gui_factory.c
@@ -474,6 +474,16 @@ static char *gui_default_mimetype(const char *path)
return strdup(guit->fetch->filetype(path));
}
+static int gui_default_socket_open(int domain, int type, int protocol)
+{
+ return (int) socket(domain, type, protocol);
+}
+
+static int gui_default_socket_close(int fd)
+{
+ return (int) ns_close_socket(fd);
+}
+
/** verify fetch table is valid */
static nserror verify_fetch_register(struct gui_fetch_table *gft)
{
@@ -501,10 +511,10 @@ static nserror verify_fetch_register(struct gui_fetch_table *gft)
gft->mimetype = gui_default_mimetype;
}
if (gft->socket_open == NULL) {
- gft->socket_open = socket;
+ gft->socket_open = gui_default_socket_open;
}
if (gft->socket_close == NULL) {
- gft->socket_close = close;
+ gft->socket_close = gui_default_socket_close;
}
return NSERROR_OK;
diff --git a/utils/inet.h b/utils/inet.h
index e385982c1..4c7eb2a85 100644
--- a/utils/inet.h
+++ b/utils/inet.h
@@ -40,9 +40,12 @@
#include <arpa/inet.h>
#include <sys/select.h>
+#define ns_close_socket close
+
#ifdef WITH_AMISSL
/* AmiSSL needs everything to be using bsdsocket directly to avoid conflicts */
#include <proto/bsdsocket.h>
+#define ns_close_socket CloseSocket
#endif
#else
@@ -54,6 +57,8 @@
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif
+#define ns_close_socket closesocket
+
#endif