From 46d1b5b23c76ea055aa316f56c00e3a2b8ce9ee3 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 9 May 2025 15:24:59 -0400
Subject: [PATCH] api: Renamed `SDLNet_*` to `NET_*`.
This fits better with the other satellite libraries.
Fixes #130.
---
.wikiheaders-options | 2 +-
CMakeLists.txt | 2 +-
cmake/test/main.c | 4 +-
examples/get-local-addrs.c | 16 +-
examples/resolve-hostnames.c | 20 +--
examples/simple-http-get.c | 24 +--
examples/voipchat.c | 64 +++----
include/SDL3_net/SDL_net.h | 326 +++++++++++++++++------------------
src/SDL_net.c | 234 ++++++++++++-------------
src/SDL_net.sym | 66 +++----
10 files changed, 379 insertions(+), 379 deletions(-)
diff --git a/.wikiheaders-options b/.wikiheaders-options
index fc72c79..ed9e0b0 100644
--- a/.wikiheaders-options
+++ b/.wikiheaders-options
@@ -2,7 +2,7 @@ projectfullname = SDL_net
projectshortname = SDL_net
incsubdir = include/SDL3_net
wikisubdir = SDL3_net
-apiprefixregex = SDLNet_
+apiprefixregex = NET_
mainincludefname = SDL3_net/SDL_net.h
versionfname = include/SDL3_net/SDL_net.h
versionmajorregex = \A\#define\s+SDL_NET_MAJOR_VERSION\s+(\d+)\Z
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5ef9543..e2740a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -281,7 +281,7 @@ if(SDLNET_INSTALL)
sdl_get_git_revision_hash(SDLNET_REVISION)
SDL_generate_manpages(
HEADERS_DIR "${PROJECT_SOURCE_DIR}/include/SDL3_net"
- SYMBOL "SDLNet_Init"
+ SYMBOL "NET_Init"
WIKIHEADERS_PL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/wikiheaders.pl"
REVISION "${SDLNET_REVISION}"
)
diff --git a/cmake/test/main.c b/cmake/test/main.c
index 40ab4d3..27a5999 100644
--- a/cmake/test/main.c
+++ b/cmake/test/main.c
@@ -9,11 +9,11 @@ int main(int argc, char *argv[])
return 1;
}
- if (!SDLNet_Init()) {
+ if (!NET_Init()) {
SDL_Log("SDL_Net_Init() failed: %s", SDL_GetError());
}
- SDLNet_Quit();
+ NET_Quit();
SDL_Quit();
return 0;
}
diff --git a/examples/get-local-addrs.c b/examples/get-local-addrs.c
index 827a6c6..469ea1a 100644
--- a/examples/get-local-addrs.c
+++ b/examples/get-local-addrs.c
@@ -12,32 +12,32 @@
int main(int argc, char **argv)
{
- SDLNet_Address **addrs = NULL;
+ NET_Address **addrs = NULL;
int num_addrs = 0;
int i;
(void)argc;
(void)argv;
- if (!SDLNet_Init()) {
- SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
+ if (!NET_Init()) {
+ SDL_Log("NET_Init() failed: %s", SDL_GetError());
return 1;
}
- addrs = SDLNet_GetLocalAddresses(&num_addrs);
+ addrs = NET_GetLocalAddresses(&num_addrs);
if (addrs == NULL) {
SDL_Log("Failed to determine local addresses: %s", SDL_GetError());
- SDLNet_Quit();
+ NET_Quit();
return 1;
}
SDL_Log("We saw %d local addresses:", num_addrs);
for (i = 0; i < num_addrs; i++) {
- SDL_Log(" - %s", SDLNet_GetAddressString(addrs[i]));
+ SDL_Log(" - %s", NET_GetAddressString(addrs[i]));
}
- SDLNet_FreeLocalAddresses(addrs);
- SDLNet_Quit();
+ NET_FreeLocalAddresses(addrs);
+ NET_Quit();
return 0;
}
diff --git a/examples/resolve-hostnames.c b/examples/resolve-hostnames.c
index 3f7836a..02778f4 100644
--- a/examples/resolve-hostnames.c
+++ b/examples/resolve-hostnames.c
@@ -12,31 +12,31 @@
int main(int argc, char **argv)
{
- if (!SDLNet_Init()) {
- SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
+ if (!NET_Init()) {
+ SDL_Log("NET_Init() failed: %s", SDL_GetError());
return 1;
}
- //SDLNet_SimulateAddressResolutionLoss(3000, 30);
+ //NET_SimulateAddressResolutionLoss(3000, 30);
- SDLNet_Address **addrs = (SDLNet_Address **) SDL_calloc(argc, sizeof (SDLNet_Address *));
+ NET_Address **addrs = (NET_Address **) SDL_calloc(argc, sizeof (NET_Address *));
for (int i = 1; i < argc; i++) {
- addrs[i] = SDLNet_ResolveHostname(argv[i]);
+ addrs[i] = NET_ResolveHostname(argv[i]);
}
for (int i = 1; i < argc; i++) {
- SDLNet_WaitUntilResolved(addrs[i], -1);
+ NET_WaitUntilResolved(addrs[i], -1);
- if (SDLNet_GetAddressStatus(addrs[i]) == -1) {
+ if (NET_GetAddressStatus(addrs[i]) == -1) {
SDL_Log("%s: [FAILED TO RESOLVE: %s]", argv[i], SDL_GetError());
} else {
- SDL_Log("%s: %s", argv[i], SDLNet_GetAddressString(addrs[i]));
+ SDL_Log("%s: %s", argv[i], NET_GetAddressString(addrs[i]));
}
- SDLNet_UnrefAddress(addrs[i]);
+ NET_UnrefAddress(addrs[i]);
}
- SDLNet_Quit();
+ NET_Quit();
return 0;
}
diff --git a/examples/simple-http-get.c b/examples/simple-http-get.c
index 151d723..66ea8db 100644
--- a/examples/simple-http-get.c
+++ b/examples/simple-http-get.c
@@ -13,35 +13,35 @@
int main(int argc, char **argv)
{
- if (!SDLNet_Init()) {
- SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
+ if (!NET_Init()) {
+ SDL_Log("NET_Init() failed: %s", SDL_GetError());
return 1;
}
for (int i = 1; i < argc; i++) {
SDL_Log("Looking up %s ...", argv[i]);
- SDLNet_Address *addr = SDLNet_ResolveHostname(argv[i]);
- if (SDLNet_WaitUntilResolved(addr, -1) == -1) {
+ NET_Address *addr = NET_ResolveHostname(argv[i]);
+ if (NET_WaitUntilResolved(addr, -1) == -1) {
SDL_Log("Failed to lookup %s: %s", argv[i], SDL_GetError());
} else {
- SDL_Log("%s is %s", argv[i], SDLNet_GetAddressString(addr));
+ SDL_Log("%s is %s", argv[i], NET_GetAddressString(addr));
char *req = NULL;
SDL_asprintf(&req, "GET / HTTP/1.0\r\nHost: %s\r\n\r\n", argv[i]);
- SDLNet_StreamSocket *sock = req ? SDLNet_CreateClient(addr, 80) : NULL;
+ NET_StreamSocket *sock = req ? NET_CreateClient(addr, 80) : NULL;
if (!req) {
SDL_Log("Out of memory!");
} else if (!sock) {
SDL_Log("Failed to create stream socket to %s: %s\n", argv[i], SDL_GetError());
- } else if (SDLNet_WaitUntilConnected(sock, -1) < 0) {
+ } else if (NET_WaitUntilConnected(sock, -1) < 0) {
SDL_Log("Failed to connect to %s: %s", argv[i], SDL_GetError());
- } else if (!SDLNet_WriteToStreamSocket(sock, req, SDL_strlen(req))) {
+ } else if (!NET_WriteToStreamSocket(sock, req, SDL_strlen(req))) {
SDL_Log("Failed to write to %s: %s", argv[i], SDL_GetError());
- } else if (SDLNet_WaitUntilStreamSocketDrained(sock, -1) < 0) {
+ } else if (NET_WaitUntilStreamSocketDrained(sock, -1) < 0) {
SDL_Log("Failed to finish write to %s: %s", argv[i], SDL_GetError());
} else {
char buf[512];
int br;
- while ((br = SDLNet_ReadFromStreamSocket(sock, buf, sizeof (buf))) >= 0) {
+ while ((br = NET_ReadFromStreamSocket(sock, buf, sizeof (buf))) >= 0) {
fwrite(buf, 1, br, stdout);
}
@@ -50,7 +50,7 @@ int main(int argc, char **argv)
}
if (sock) {
- SDLNet_DestroyStreamSocket(sock);
+ NET_DestroyStreamSocket(sock);
}
SDL_free(req);
@@ -58,7 +58,7 @@ int main(int argc, char **argv)
}
- SDLNet_Quit();
+ NET_Quit();
return 0;
}
diff --git a/examples/voipchat.c b/examples/voipchat.c
index 22af456..79ea17b 100644
--- a/examples/voipchat.c
+++ b/examples/voipchat.c
@@ -15,7 +15,7 @@
typedef struct Voice
{
SDL_AudioStream *stream;
- SDLNet_Address *addr;
+ NET_Address *addr;
Uint16 port;
Uint64 idnum;
Uint64 last_seen;
@@ -24,8 +24,8 @@ typedef struct Voice
struct Voice *next;
} Voice;
-static SDLNet_DatagramSocket *sock = NULL; /* you talk over this, client or server. */
-static SDLNet_Address *server_addr = NULL; /* address of the server you're talking to, NULL if you _are_ the server. */
+static NET_DatagramSocket *sock = NULL; /* you talk over this, client or server. */
+static NET_Address *server_addr = NULL; /* address of the server you're talking to, NULL if you _are_ the server. */
static Uint16 server_port = 3025;
static int max_datagram = 0;
static Voice *voices = NULL;
@@ -39,11 +39,11 @@ static SDL_AudioStream *capture_stream = NULL;
static const SDL_AudioSpec audio_spec = { SDL_AUDIO_S16LE, 1, 8000 };
static Uint64 scratch_area[512];
-static Voice *FindVoiceByAddr(const SDLNet_Address *addr, const Uint16 port)
+static Voice *FindVoiceByAddr(const NET_Address *addr, const Uint16 port)
{
Voice *i;
for (i = voices; i != NULL; i = i->next) {
- if ((i->port == port) && (SDLNet_CompareAddresses(i->addr, addr) == 0)) {
+ if ((i->port == port) && (NET_CompareAddresses(i->addr, addr) == 0)) {
return i;
}
}
@@ -71,7 +71,7 @@ static void ClearOldVoices(const Uint64 now)
if (!i->stream || (SDL_GetAudioStreamAvailable(i->stream) == 0)) { /* they'll get a reprieve if data is still playing out */
SDL_Log("Destroying voice #%" SDL_PRIu64, i->idnum);
SDL_DestroyAudioStream(i->stream);
- SDLNet_UnrefAddress(i->addr);
+ NET_UnrefAddress(i->addr);
if (i->prev) {
i->prev->next = next;
} else {
@@ -94,8 +94,8 @@ static void SendClientAudioToServer(void)
next_idnum++;
scratch_area[0] = SDL_Swap64LE(0); /* just being nice and leaving space in the buffer for the server to replace. */
scratch_area[1] = SDL_Swap64LE(next_idnum);
- SDL_Log("CLIENT: Sending %d new bytes to server at %s:%d...", br + extra, SDLNet_GetAddressString(server_addr), (int) server_port);
- SDLNet_SendDatagram(sock, server_addr, server_port, scratch_area, br + extra);
+ SDL_Log("CLIENT: Sending %d new bytes to server at %s:%d...", br + extra, NET_GetAddressString(server_addr), (int) server_port);
+ NET_SendDatagram(sock, server_addr, server_port, scratch_area, br + extra);
}
}
@@ -113,20 +113,20 @@ static void mainloop(void)
bool activity = false;
const Uint64 now = SDL_GetTicks();
SDL_Event event;
- SDLNet_Datagram *dgram = NULL;
+ NET_Datagram *dgram = NULL;
int rc;
- while (((rc = SDLNet_ReceiveDatagram(sock, &dgram)) == true) && (dgram != NULL)) {
- SDL_Log("%s: got %d-byte datagram from %s:%d", is_client ? "CLIENT" : "SERVER", (int) dgram->buflen, SDLNet_GetAddressString(dgram->addr), (int) dgram->port);
+ while (((rc = NET_ReceiveDatagram(sock, &dgram)) == true) && (dgram != NULL)) {
+ SDL_Log("%s: got %d-byte datagram from %s:%d", is_client ? "CLIENT" : "SERVER", (int) dgram->buflen, NET_GetAddressString(dgram->addr), (int) dgram->port);
activity = true;
if (!is_client) { /* we're the server? */
Voice *voice = FindVoiceByAddr(dgram->addr, dgram->port);
Voice *i;
if (!voice) {
- SDL_Log("SERVER: Creating voice idnum=%" SDL_PRIu64 " from %s:%d", next_idnum + 1, SDLNet_GetAddressString(dgram->addr), (int) dgram->port);
+ SDL_Log("SERVER: Creating voice idnum=%" SDL_PRIu64 " from %s:%d", next_idnum + 1, NET_GetAddressString(dgram->addr), (int) dgram->port);
voice = (Voice *) SDL_calloc(1, sizeof (Voice));
- voice->addr = SDLNet_RefAddress(dgram->addr);
+ voice->addr = NET_RefAddress(dgram->addr);
voice->port = dgram->port;
voice->idnum = ++next_idnum;
if (voices) {
@@ -142,15 +142,15 @@ static void mainloop(void)
if (dgram->buflen > extra) { /* ignore it if too small, might just be a keepalive packet. */
*((Uint64 *) dgram->buf) = SDL_Swap64LE(voice->idnum); /* the client leaves space to fill this in for convenience. */
for (i = voices; i != NULL; i = i->next) {
- if ((voice->port != i->port) || (SDLNet_CompareAddresses(voice->addr, i->addr) != 0)) { /* don't send client's own voice back to them. */
- SDL_Log("SERVER: sending %d-byte datagram to %s:%d", (int) dgram->buflen, SDLNet_GetAddressString(i->addr), (int) i->port);
- SDLNet_SendDatagram(sock, i->addr, i->port, dgram->buf, dgram->buflen);
+ if ((voice->port != i->port) || (NET_CompareAddresses(voice->addr, i->addr) != 0)) { /* don't send client's own voice back to them. */
+ SDL_Log("SERVER: sending %d-byte datagram to %s:%d", (int) dgram->buflen, NET_GetAddressString(i->addr), (int) i->port);
+ NET_SendDatagram(sock, i->addr, i->port, dgram->buf, dgram->buflen);
}
}
}
} else { /* we're the client. */
- if ((dgram->port != server_port) || (SDLNet_CompareAddresses(dgram->addr, server_addr) != 0)) {
- SDL_Log("CLIENT: Got packet from non-server address %s:%d. Ignoring.", SDLNet_GetAddressString(dgram->addr), (int) dgram->port);
+ if ((dgram->port != server_port) || (NET_CompareAddresses(dgram->addr, server_addr) != 0)) {
+ SDL_Log("CLIENT: Got packet from non-server address %s:%d. Ignoring.", NET_GetAddressString(dgram->addr), (int) dgram->port);
} else if (dgram->buflen < extra) {
SDL_Log("CLIENT: Got bogus packet from the server. Ignoring.");
} else {
@@ -184,7 +184,7 @@ static void mainloop(void)
}
}
- SDLNet_DestroyDatagram(dgram);
+ NET_DestroyDatagram(dgram);
}
while (SDL_PollEvent(&event)) {
@@ -229,8 +229,8 @@ static void mainloop(void)
next_idnum++;
scratch_area[0] = SDL_Swap64LE(0);
scratch_area[1] = SDL_Swap64LE(next_idnum);
- SDL_Log("CLIENT: Sending %d keepalive bytes to server at %s:%d...", extra, SDLNet_GetAddressString(server_addr), (int) server_port);
- SDLNet_SendDatagram(sock, server_addr, server_port, scratch_area, extra);
+ SDL_Log("CLIENT: Sending %d keepalive bytes to server at %s:%d...", extra, NET_GetAddressString(server_addr), (int) server_port);
+ NET_SendDatagram(sock, server_addr, server_port, scratch_area, extra);
last_send_ticks = now;
}
}
@@ -283,10 +283,10 @@ static void run_voipchat(int argc, char **argv)
SDL_Log("SERVER: Listening on port %d", server_port);
} else {
SDL_Log("CLIENT: Resolving server hostname '%s' ...", hostname);
- server_addr = SDLNet_ResolveHostname(hostname);
+ server_addr = NET_ResolveHostname(hostname);
if (server_addr) {
- if (SDLNet_WaitUntilResolved(server_addr, -1) < 0) {
- SDLNet_UnrefAddress(server_addr);
+ if (NET_WaitUntilResolved(server_addr, -1) < 0) {
+ NET_UnrefAddress(server_addr);
server_addr = NULL;
}
}
@@ -297,7 +297,7 @@ static void run_voipchat(int argc, char **argv)
return;
}
- SDL_Log("CLIENT: Server is at %s:%d.", SDLNet_GetAddressString(server_addr), (int) server_port);
+ SDL_Log("CLIENT: Server is at %s:%d.", NET_GetAddressString(server_addr), (int) server_port);
audio_device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_PLAYBACK, &audio_spec);
if (!audio_device) {
@@ -318,12 +318,12 @@ static void run_voipchat(int argc, char **argv)
}
/* server _must_ be on the requested port. Clients can take anything available, server will respond to where it sees it come from. */
- sock = SDLNet_CreateDatagramSocket(NULL, is_server ? server_port : 0);
+ sock = NET_CreateDatagramSocket(NULL, is_server ? server_port : 0);
if (!sock) {
SDL_Log("Failed to create datagram socket: %s", SDL_GetError());
} else {
if (simulate_failure) {
- SDLNet_SimulateDatagramPacketLoss(sock, simulate_failure);
+ NET_SimulateDatagramPacketLoss(sock, simulate_failure);
}
mainloop();
}
@@ -337,9 +337,9 @@ static void run_voipchat(int argc, char **argv)
SDL_CloseAudioDevice(capture_device);
audio_device = capture_device = 0;
- SDLNet_UnrefAddress(server_addr);
+ NET_UnrefAddress(server_addr);
server_addr = NULL;
- SDLNet_DestroyDatagramSocket(sock);
+ NET_DestroyDatagramSocket(sock);
sock = NULL;
}
@@ -351,8 +351,8 @@ int main(int argc, char **argv)
return 1;
}
- if (!SDLNet_Init()) {
- SDL_Log("SDLNet_Init failed: %s\n", SDL_GetError());
+ if (!NET_Init()) {
+ SDL_Log("NET_Init failed: %s\n", SDL_GetError());
SDL_Quit();
return 1;
}
@@ -368,7 +368,7 @@ int main(int argc, char **argv)
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
- SDLNet_Quit();
+ NET_Quit();
SDL_Quit();
return 0;
}
diff --git a/include/SDL3_net/SDL_net.h b/include/SDL3_net/SDL_net.h
index 0a4faab..176757b 100644
--- a/include/SDL3_net/SDL_net.h
+++ b/include/SDL3_net/SDL_net.h
@@ -69,7 +69,7 @@ extern "C" {
*
* \since This function is available since SDL_net 3.0.0.
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_Version(void);
+extern SDL_DECLSPEC int SDLCALL NET_Version(void);
/* init/quit functions... */
@@ -81,7 +81,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_Version(void);
* function can be used.
*
* It is safe to call this multiple times; the library will only initialize
- * once, and won't deinitialize until SDLNet_Quit() has been called a matching
+ * once, and won't deinitialize until NET_Quit() has been called a matching
* number of times. Extra attempts to init report success.
*
* \returns true on success, false on error; call SDL_GetError() for details.
@@ -90,9 +90,9 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_Version(void);
*
* \since This function is available since SDL_net 3.0.0.
*
- * \sa SDLNet_Quit
+ * \sa NET_Quit
*/
-extern SDL_DECLSPEC bool SDLCALL SDLNet_Init(void);
+extern SDL_DECLSPEC bool SDLCALL NET_Init(void);
/**
* Deinitialize the SDL_net library.
@@ -101,24 +101,24 @@ extern SDL_DECLSPEC bool SDLCALL SDLNet_Init(void);
* program.
*
* It is safe to call this multiple times; the library will only deinitialize
- * once, when this function is called the same number of times as SDLNet_Init
+ * once, when this function is called the same number of times as NET_Init
* was successfully called.
*
* Once you have successfully deinitialized the library, it is safe to call
- * SDLNet_Init to reinitialize it for further use.
+ * NET_Init to reinitialize it for further use.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL_Net 3.0.0.
*
- * \sa SDLNet_Quit
+ * \sa NET_Quit
*/
-extern SDL_DECLSPEC void SDLCALL SDLNet_Quit(void);
+extern SDL_DECLSPEC void SDLCALL NET_Quit(void);
/* hostname resolution API... */
-typedef struct SDLNet_Address SDLNet_Address; /**< Opaque struct that deals with computer-readable addresses. */
+typedef struct NET_Address NET_Address; /**< Opaque struct that deals with computer-readable addresses. */
/**
* Resolve a human-readable hostname.
@@ -128,41 +128,41 @@ typedef struct SDLNet_Address SDLNet_Address; /**< Opaque struct that deals wit
* other. This process is known as "resolving" an address.
*
* You can also use this to turn IP address strings (like "159.203.69.7") into
- * SDLNet_Address objects.
+ * NET_Address objects.
*
* Note that resolving an address is an asynchronous operation, since the
* library will need to ask a server on the internet to get the information it
* needs, and this can take time (and possibly fail later). This function will
* not block. It either returns NULL (catastrophic failure) or an unresolved
- * SDLNet_Address. Until the address resolves, it can't be used.
+ * NET_Address. Until the address resolves, it can't be used.
*
* If you want to block until the resolution is finished, you can call
- * SDLNet_WaitUntilResolved(). Otherwise, you can do a non-blocking check with
- * SDLNet_GetAddressStatus().
+ * NET_WaitUntilResolved(). Otherwise, you can do a non-blocking check with
+ * NET_GetAddressStatus().
*
- * When you are done with the returned SDLNet_Address, call
- * SDLNet_UnrefAddress() to dispose of it. You need to do this even if
+ * When you are done with the returned NET_Address, call
+ * NET_UnrefAddress() to dispose of it. You need to do this even if
* resolution later fails asynchronously.
*
* \param host The hostname to resolve.
- * \returns A new SDLNet_Address on success, NULL on error; call
+ * \returns A new NET_Address on success, NULL on error; call
* SDL_GetError() for details.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL_Net 3.0.0.
*
- * \sa SDLNet_WaitUntilResolved
- * \sa SDLNet_GetAddressStatus
- * \sa SDLNet_RefAddress
- * \sa SDLNet_UnrefAddress
+ * \sa NET_WaitUntilResolved
+ * \sa NET_GetAddressStatus
+ * \sa NET_RefAddress
+ * \sa NET_UnrefAddress
*/
-extern SDL_DECLSPEC SDLNet_Address * SDLCALL SDLNet_ResolveHostname(const char *host);
+extern SDL_DECLSPEC NET_Address * SDLCALL NET_ResolveHostname(const char *host);
/**
* Block until an address is resolved.
*
- * The SDLNet_Address objects returned by SDLNet_ResolveHostname take time to
+ * The NET_Address objects returned by NET_ResolveHostname take time to
* do their work, so it is does so _asynchronously_ instead of making your
* program wait an indefinite amount of time.
*
@@ -173,7 +173,7 @@ extern SDL_DECLSPEC SDLNet_Address * SDLCALL SDLNet_ResolveHostname(const char *
* long to wait for resolution to complete. Specifying a timeout of -1
* instructs the library to wait indefinitely, and a timeout of 0 just checks
* the current status and returns immediately (and is functionally equivalent
- * to calling SDLNet_GetAddressStatus).
+ * to calling NET_GetAddressStatus).
*
* Resolution can fail after some time (DNS server took awhile to reply that
* the hostname isn't recognized, etc), so be sure to check the result of this
@@ -183,9 +183,9 @@ extern SDL_DECLSPEC SDLNet_Address * SDLCALL SDLNet_ResolveHostname(const char *
* host represented by the address.
*
* If you don't want your program to block, you can call
- * SDLNet_GetAddressStatus from time to time until you get a non-zero result.
+ * NET_GetAddressStatus from time to time until you get a non-zero result.
*
- * \param address The SDLNet_Address object to wait on.
+ * \param address The NET_Address object to wait on.
* \param timeout Number of milliseconds to wait for resolution to complete.
* -1 to wait indefinitely, 0 to check once without waiting.
* \returns 1 if successfully resolved, -1 if resolution failed, 0 if still
@@ -197,14 +197,14 @@ extern SDL_DECLSPEC SDLNet_Address * SDLCALL SDLNet_ResolveHostname(const char *
*
* \since This function is available since SDL_Net 3.0.0.
*
- * \sa SDLNet_GetAddressStatus
+ * \sa NET_GetAddressStatus
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_WaitUntilResolved(SDLNet_Address *address, Sint32 timeout);
+extern SDL_DECLSPEC int SDLCALL NET_WaitUntilResolved(NET_Address *address, Sint32 timeout);
/**
* Check if an address is resolved, without blocking.
*
- * The SDLNet_Address objects returned by SDLNet_ResolveHostname take time to
+ * The NET_Address objects returned by NET_ResolveHostname take time to
* do their work, so it is does so _asynchronously_ instead of making your
* program wait an indefinite amount of time.
*
@@ -218,7 +218,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_WaitUntilResolved(SDLNet_Address *address
* Once an address is successfully resolved, it can be used to connect to the
* host represented by the address.
*
- * \param address The SDLNet_Address to query.
+ * \param address The NET_Address to query.
* \returns 1 if successfully resolved, -1 if resolution failed, 0 if still
* resolving; if -1, call SDL_GetError() for details.
*
@@ -226,9 +226,9 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_WaitUntilResolved(SDLNet_Address *address
*
* \since This function is available since SDL_Net 3.0.0.
*
- * \sa SDLNet_WaitUntilResolved
+ * \sa NET_WaitUntilResolved
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_GetAddressStatus(SDLNet_Address *address);
+extern SDL_DECLSPEC int SDLCALL NET_GetAddressStatus(NET_Address *address);
/**
* Get a human-readable string from a resolved address.
@@ -238,42 +238,42 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_GetAddressStatus(SDLNet_Address *address)
* "2604:a880:800:a1::71f:3001". It won't be the original hostname (like
* "icculus.org"), but it's suitable for writing to a log file, etc.
*
- * Do not free or modify the returned string; it belongs to the SDLNet_Address
+ * Do not free or modify the returned string; it belongs to the NET_Address
* that was queried, and is valid as long as the object lives. Either make
* sure the address has a reference as long as you need this or make a copy of
* the string.
*
* This will return NULL if resolution is still in progress, or if resolution
- * failed. You can use SDLNet_GetAddressStatus() or SDLNet_WaitUntilResolved()
+ * failed. You can use NET_GetAddressStatus() or NET_WaitUntilResolved()
* to make sure resolution has successfully completed before calling this.
*
- * \param address The SDLNet_Address to query.
+ * \param address The NET_Address to query.
* \returns a string, or NULL on error; call SDL_GetError() for details.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL_Net 3.0.0.
*
- * \sa SDLNet_GetAddressStatus
- * \sa SDLNet_WaitUntilResolved
+ * \sa NET_GetAddressStatus
+ * \sa NET_WaitUntilResolved
*/
-extern SDL_DECLSPEC const char * SDLCALL SDLNet_GetAddressString(SDLNet_Address *address);
+extern SDL_DECLSPEC const char * SDLCALL NET_GetAddressString(NET_Address *address);
/**
- * Add a reference to an SDLNet_Address.
+ * Add a reference to an NET_Address.
*
- * Since several pieces of the library might share a single SDLNet_Address,
+ * Since several pieces of the library might share a single NET_Address,
* including a background thread that's working on resolving, these objects
* are referenced counted. This allows everything that's using it to declare
* they still want it, and drop their reference to the address when they are
* done with it. The object's resources are freed when the last reference is
* dropped.
*
- * This function adds a reference to an SDLNet_Address, increasing its
+ * This function adds a reference to an NET_Address, increasing its
* reference count by one.
*
* The documentation will tell you when the app has to explicitly unref an
- * address. For example, SDLNet_ResolveHostname() creates addresses that are
+ * address. For example, NET_ResolveHostname() creates addresses that are
* already referenced, so the caller needs to unref it when done.
*
* Generally you only have to explicit ref an address when you have different
@@ -285,42 +285,42 @@ extern SDL_DECLSPEC const char * SDLCALL SDLNet_GetAddressString(SDLNet_Address
* ref and assign in one step:
*
* ```c
- * myAddr = SDLNet_RefAddress(yourAddr);
+ * myAddr = NET_RefAddress(yourAddr);
* ```
*
- * \param address The SDLNet_Address to add a reference to.
+ * \param address The NET_Address to add a reference to.
* \returns the same address that was passed as a parameter.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL_Net 3.0.0.
*/
-extern SDL_DECLSPEC SDLNet_Address *SDLCALL SDLNet_RefAddress(SDLNet_Address *address);
+extern SDL_DECLSPEC NET_Address *SDLCALL NET_RefAddress(NET_Address *address);
/**
- * Drop a reference to an SDLNet_Address.
+ * Drop a reference to an NET_Address.
*
- * Since several pieces of the library might share a single SDLNet_Address,
+ * Since several pieces of the library might share a single NET_Address,
* including a background thread that's working on resolving, these objects
* are referenced counted. This allows everything that's using it to declare
* they still want it, and drop their reference to the address when they are
* done with it. The object's resources are freed when the last reference is
* dropped.
*
- * This function drops a reference to an SDLNet_Address, decreasing its
+ * This function drops a reference to an NET_Address, decreasing its
* reference count by one.
*
* The documentation will tell you when the app has to explicitly unref an
- * address. For example, SDLNet_ResolveHostname() creates addresses that are
+ * address. For example, NET_ResolveHostname() creates addresses that are
* already referenced, so the caller needs to unref it when done.
*
- * \param address The SDLNet_Address to drop a reference to.
+ * \param address The NET_Address to drop a reference to.
*
* \threadsafety It is safe to call this function from any thread.
*
* \since This function is available since SDL_Net 3.0.0.
*/
-extern SDL_DECLSPEC void SDLCALL SDLNet_UnrefAddress(SDLNet_Address *address);
+extern SDL_DECLSPEC void SDLCALL NET_UnrefAddress(NET_Address *address);
/**
* Enable simulated address resolution failures.
@@ -351,10 +351,10 @@ extern SDL_DECLSPEC void SDLCALL SDLNet_UnrefAddress(SDLNet_Address *address);
*
* \since This function is available since SDL_Net 3.0.0.
*/
-extern SDL_DECLSPEC void SDLCALL SDLNet_SimulateAddressResolutionLoss(int percent_loss);
+extern SDL_DECLSPEC void SDLCALL NET_SimulateAddressResolutionLoss(int percent_loss);
/**
- * Compare two SDLNet_Address objects.
+ * Compare two NET_Address objects.
*
* This compares two addresses, returning a value that is useful for qsort (or
* SDL_qsort).
@@ -367,7 +367,7 @@ extern SDL_DECLSPEC void SDLCALL SDLNet_SimulateAddressResolutionLoss(int percen
*
* \since This function is available since SDL_Net 3.0.0.
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_CompareAddresses(const SDLNet_Address *a, const SDLNet_Address *b);
+extern SDL_DECLSPEC int SDLCALL NET_CompareAddresses(const NET_Address *a, const NET_Address *b);
/**
* Obtain a list of local addresses on the system.
@@ -381,21 +381,21 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_CompareAddresses(const SDLNet_Address *a,
* addresses that are accessible on the same LAN, but not public ones that are
* accessible from the outside Internet.
*
- * Usually it's better to use SDLNet_CreateServer() or
- * SDLNet_CreateDatagramSocket() with a NULL address, to say "bind to all
+ * Usually it's better to use NET_CreateServer() or
+ * NET_CreateDatagramSocket() with a NULL address, to say "bin
(Patch may be truncated, please check the link at the top of this post.)