Fix mingw build for multicast.c

https://github.com/Hamlib/Hamlib/issues/695
pull/1289/head
Mike Black W9MDB 2023-05-09 07:00:03 -05:00
rodzic 1d96a84b44
commit 7835329e32
1 zmienionych plików z 166 dodań i 173 usunięć

Wyświetl plik

@ -327,10 +327,7 @@ void *multicast_thread(void *vrig)
#ifdef WIN32
static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
{
void GetWinsockErrorString(char *errorBuffer, DWORD errorBufferSize)
{
int errorCode = WSAGetLastError();
DWORD charsWritten;
FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
@ -341,11 +338,12 @@ static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
errorBufferSize,
NULL
);
}
return errorBuffer;
}
#endif
int multicast_init(RIG * rig, char *addr, int port)
{
int multicast_init(RIG *rig, char *addr, int port)
{
#ifdef _WIN32
WSADATA wsaData;
@ -445,10 +443,10 @@ static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
//printf("threadid=%ld\n", rig->state.multicast->threadid);
rig->state.multicast->multicast_running = 1;
return RIG_OK;
}
}
void multicast_close(RIG * rig)
{
void multicast_close(RIG *rig)
{
int retval;
// Leave the multicast group
@ -465,11 +463,11 @@ static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
{
rig_debug(RIG_DEBUG_ERR, "%s: close: %s\n", __func__, strerror(errno));
}
}
}
// if msglen=0 msg is assumed to be a string
int multicast_send(RIG * rig, const char *msg, int msglen)
{
int multicast_send(RIG *rig, const char *msg, int msglen)
{
// Construct the message to send
if (msglen == 0) { msglen = strlen((char *)msg); }
@ -483,19 +481,14 @@ static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
rig_debug(RIG_DEBUG_ERR, "%s: sendto: %s\n", __func__, strerror(errno));
return -RIG_EIO;
}
else
{
// printf("Sent %zd bytes to multicast group %s:%d\n", num_bytes, MULTICAST_ADDR,
// PORT);
}
return num_bytes;
}
}
//#define TEST
#ifdef TEST
int main(int argc, char *argv[])
{
int main(int argc, char *argv[])
{
RIG *rig;
rig_model_t myrig_model;
rig_set_debug_level(RIG_DEBUG_NONE);
@ -520,5 +513,5 @@ static char *GetWinsockLastError(char *errorBuffer, DWORD errorBufferSize)
pthread_join(rig->state.multicast->threadid, NULL);
pthread_exit(NULL);
return 0;
}
}
#endif