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