Move net_init() and net_cleanup() upwards

These two functions are global, define them at the top of the
implementation file. This is consistent with the header file.
This commit is contained in:
Romain Vimont 2021-10-26 22:49:45 +02:00
parent 5222f213f4
commit eb6afe7669

View File

@ -19,6 +19,26 @@
typedef struct in_addr IN_ADDR;
#endif
bool
net_init(void) {
#ifdef __WINDOWS__
WSADATA wsa;
int res = WSAStartup(MAKEWORD(2, 2), &wsa) < 0;
if (res < 0) {
LOGC("WSAStartup failed with error %d", res);
return false;
}
#endif
return true;
}
void
net_cleanup(void) {
#ifdef __WINDOWS__
WSACleanup();
#endif
}
static void
net_perror(const char *s) {
#ifdef _WIN32
@ -133,26 +153,6 @@ net_shutdown(socket_t socket, int how) {
return !shutdown(socket, how);
}
bool
net_init(void) {
#ifdef __WINDOWS__
WSADATA wsa;
int res = WSAStartup(MAKEWORD(2, 2), &wsa) < 0;
if (res < 0) {
LOGC("WSAStartup failed with error %d", res);
return false;
}
#endif
return true;
}
void
net_cleanup(void) {
#ifdef __WINDOWS__
WSACleanup();
#endif
}
bool
net_close(socket_t socket) {
#ifdef __WINDOWS__