diff --git a/external/regex/regcomp.c b/external/regex/regcomp.c index 006fe5c..eb6d7a4 100644 --- a/external/regex/regcomp.c +++ b/external/regex/regcomp.c @@ -2510,7 +2510,7 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa, old_tree = NULL; if (elem->token.type == SUBEXP) - postorder (elem, mark_opt_subexp, (void *) (long) elem->token.opr.idx); + postorder (elem, mark_opt_subexp, (void *) (ptrdiff_t) elem->token.opr.idx); tree = create_tree (dfa, elem, NULL, (end == -1 ? OP_DUP_ASTERISK : OP_ALT)); if (BE (tree == NULL, 0)) @@ -3725,7 +3725,7 @@ create_token_tree (re_dfa_t *dfa, bin_tree_t *left, bin_tree_t *right, static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node) { - int idx = (int) (long) extra; + int idx = (int) (ptrdiff_t) extra; if (node->token.type == SUBEXP && node->token.opr.idx == idx) node->token.opt_subexp = 1; diff --git a/src/aclients.c b/src/aclients.c index c51f0e7..b8b2abd 100644 --- a/src/aclients.c +++ b/src/aclients.c @@ -283,10 +283,10 @@ int main (int argc, char *argv[]) #if __WIN32__ if (isdigit(port[j][0])) { - client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_net, (void *)j, 0, NULL); + client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_net, (void *)(ptrdiff_t)j, 0, NULL); } else { - client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_serial, (void *)j, 0, NULL); + client_th[j] = (HANDLE)_beginthreadex (NULL, 0, client_thread_serial, (void *)(ptrdiff_t)j, 0, NULL); } if (client_th[j] == NULL) { printf ("Internal error: Could not create client thread %d.\n", j); @@ -294,10 +294,10 @@ int main (int argc, char *argv[]) } #else if (isdigit(port[j][0])) { - e = pthread_create (&client_tid[j], NULL, client_thread_net, (void *)(long)j); + e = pthread_create (&client_tid[j], NULL, client_thread_net, (void *)(ptrdiff_t)j); } else { - e = pthread_create (&client_tid[j], NULL, client_thread_serial, (void *)(long)j); + e = pthread_create (&client_tid[j], NULL, client_thread_serial, (void *)(ptrdiff_t)j); } if (e != 0) { perror("Internal error: Could not create client thread."); @@ -394,7 +394,7 @@ static void * client_thread_net (void *arg) int use_chan = -1; - my_index = (int)(long)arg; + my_index = (int)(ptrdiff_t)arg; #if DEBUGx printf ("DEBUG: client_thread_net %d start, port = '%s'\n", my_index, port[my_index]); @@ -664,7 +664,7 @@ static unsigned __stdcall client_thread_serial (void *arg) static void * client_thread_serial (void *arg) #endif { - int my_index = (int)(long)arg; + int my_index = (int)(ptrdiff_t)arg; #if __WIN32__ diff --git a/src/beacon.c b/src/beacon.c index 07ea0d0..ddcaf2e 100644 --- a/src/beacon.c +++ b/src/beacon.c @@ -383,7 +383,7 @@ void beacon_init (struct audio_s *pmodem, struct misc_config_s *pconfig, struct #else int e; - e = pthread_create (&beacon_tid, NULL, beacon_thread, (void *)0); + e = pthread_create (&beacon_tid, NULL, beacon_thread, NULL); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create beacon thread"); diff --git a/src/dwgpsd.c b/src/dwgpsd.c index 8e7643c..6326704 100644 --- a/src/dwgpsd.c +++ b/src/dwgpsd.c @@ -193,7 +193,7 @@ int dwgpsd_init (struct misc_config_s *pconfig, int debug) gps_stream(&gpsdata, WATCH_ENABLE | WATCH_JSON, NULL); - e = pthread_create (&read_gps_tid, NULL, read_gpsd_thread, (void *)(long)arg); + e = pthread_create (&read_gps_tid, NULL, read_gpsd_thread, (void *)(ptrdiff_t)arg); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create GPS reader thread"); diff --git a/src/dwgpsnmea.c b/src/dwgpsnmea.c index 1ccda6d..99209f3 100644 --- a/src/dwgpsnmea.c +++ b/src/dwgpsnmea.c @@ -151,7 +151,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug) if (s_gpsnmea_port_fd != MYFDERROR) { #if __WIN32__ - read_gps_th = (HANDLE)_beginthreadex (NULL, 0, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd, 0, NULL); + read_gps_th = (HANDLE)_beginthreadex (NULL, 0, read_gpsnmea_thread, (void*)(ptrdiff_t)s_gpsnmea_port_fd, 0, NULL); if (read_gps_th == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create GPS NMEA listening thread.\n"); @@ -159,7 +159,7 @@ int dwgpsnmea_init (struct misc_config_s *pconfig, int debug) } #else int e; - e = pthread_create (&read_gps_tid, NULL, read_gpsnmea_thread, (void*)(long)s_gpsnmea_port_fd); + e = pthread_create (&read_gps_tid, NULL, read_gpsnmea_thread, (void*)(ptrdiff_t)s_gpsnmea_port_fd); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create GPS NMEA listening thread."); @@ -216,7 +216,7 @@ static unsigned __stdcall read_gpsnmea_thread (void *arg) static void * read_gpsnmea_thread (void *arg) #endif { - MYFDTYPE fd = (MYFDTYPE)(long)arg; + MYFDTYPE fd = (MYFDTYPE)(ptrdiff_t)arg; // Maximum length of message from GPS receiver is 82 according to some people. // Make buffer considerably larger to be safe. @@ -230,7 +230,7 @@ static void * read_gpsnmea_thread (void *arg) if (s_debug >= 2) { text_color_set(DW_COLOR_DEBUG); - dw_printf ("read_gpsnmea_thread (%d)\n", (int)(long)arg); + dw_printf ("read_gpsnmea_thread (%d)\n", (int)(ptrdiff_t)arg); } dwgps_clear (&info); diff --git a/src/igate.c b/src/igate.c index aa9f8c1..19ba037 100644 --- a/src/igate.c +++ b/src/igate.c @@ -466,7 +466,7 @@ void igate_init (struct audio_s *p_audio_config, struct igate_config_s *p_igate_ return; } #else - e = pthread_create (&connect_listen_tid, NULL, connnect_thread, (void *)NULL); + e = pthread_create (&connect_listen_tid, NULL, connnect_thread, NULL); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Internal error: Could not create IGate connection thread"); diff --git a/src/kissnet.c b/src/kissnet.c index ba7aa24..9588347 100644 --- a/src/kissnet.c +++ b/src/kissnet.c @@ -231,14 +231,14 @@ void kissnet_init (struct misc_config_s *mc) * This waits for a client to connect and sets client_sock[n]. */ #if __WIN32__ - connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)kiss_port, 0, NULL); + connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(ptrdiff_t)kiss_port, 0, NULL); if (connect_listen_th == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create KISS socket connect listening thread\n"); return; } #else - e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(long)kiss_port); + e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(ptrdiff_t)kiss_port); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create KISS socket connect listening thread"); @@ -254,14 +254,14 @@ void kissnet_init (struct misc_config_s *mc) for (client = 0; client < MAX_NET_CLIENTS; client++) { #if __WIN32__ - cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, kissnet_listen_thread, (void*)client, 0, NULL); + cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, kissnet_listen_thread, (void*)(ptrdiff_t)client, 0, NULL); if (cmd_listen_th[client] == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create KISS command listening thread for client %d\n", client); return; } #else - e = pthread_create (&(cmd_listen_tid[client]), NULL, kissnet_listen_thread, (void *)(long)client); + e = pthread_create (&(cmd_listen_tid[client]), NULL, kissnet_listen_thread, (void *)(ptrdiff_t)client); if (e != 0) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create KISS command listening thread for client %d\n", client); @@ -305,10 +305,10 @@ static THREAD_F connect_listen_thread (void *arg) SOCKET listen_sock; WSADATA wsadata; - snprintf (kiss_port_str, sizeof(kiss_port_str), "%d", (int)(long)arg); + snprintf (kiss_port_str, sizeof(kiss_port_str), "%d", (int)(ptrdiff_t)arg); #if DEBUG text_color_set(DW_COLOR_DEBUG); - dw_printf ("DEBUG: kissnet port = %d = '%s'\n", (int)(long)arg, kiss_port_str); + dw_printf ("DEBUG: kissnet port = %d = '%s'\n", (int)(ptrdiff_t)arg, kiss_port_str); #endif err = WSAStartup (MAKEWORD(2,2), &wsadata); if (err != 0) { @@ -425,7 +425,7 @@ static THREAD_F connect_listen_thread (void *arg) struct sockaddr_in sockaddr; /* Internet socket address stuct */ socklen_t sockaddr_size = sizeof(struct sockaddr_in); - int kiss_port = (int)(long)arg; + int kiss_port = (int)(ptrdiff_t)arg; int listen_sock; int bcopt = 1; @@ -808,7 +808,7 @@ static THREAD_F kissnet_listen_thread (void *arg) unsigned char ch; - int client = (int)(long)arg; + int client = (int)(ptrdiff_t)arg; #if DEBUG text_color_set(DW_COLOR_DEBUG); diff --git a/src/kissutil.c b/src/kissutil.c index cd1bfb4..6fabc4a 100644 --- a/src/kissutil.c +++ b/src/kissutil.c @@ -285,7 +285,7 @@ int main (int argc, char *argv[]) #if __WIN32__ if (using_tcp) { - tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_net, (void *)99, 0, NULL); + tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_net, (void *)(ptrdiff_t)99, 0, NULL); } else { tnc_th = (HANDLE)_beginthreadex (NULL, 0, tnc_listen_serial, (void *)99, 0, NULL); @@ -296,10 +296,10 @@ int main (int argc, char *argv[]) } #else if (using_tcp) { - e = pthread_create (&tnc_tid, NULL, tnc_listen_net, (void *)(long)99); + e = pthread_create (&tnc_tid, NULL, tnc_listen_net, (void *)(ptrdiff_t)99); } else { - e = pthread_create (&tnc_tid, NULL, tnc_listen_serial, (void *)(long)99); + e = pthread_create (&tnc_tid, NULL, tnc_listen_serial, (void *)(ptrdiff_t)99); } if (e != 0) { perror("Internal error: Could not create TNC listen thread."); diff --git a/src/log.c b/src/log.c index 2894bc3..02aab2a 100644 --- a/src/log.c +++ b/src/log.c @@ -51,6 +51,10 @@ #include #include +#if __WIN32__ +#include // for _mkdir() +#endif + #include "ax25_pad.h" #include "textcolor.h" #include "decode_aprs.h" diff --git a/src/recv.c b/src/recv.c index 65f844e..491ea40 100644 --- a/src/recv.c +++ b/src/recv.c @@ -160,7 +160,7 @@ void recv_init (struct audio_s *pa) #endif #if __WIN32__ - xmit_th[a] = (HANDLE)_beginthreadex (NULL, 0, recv_adev_thread, (void*)(long)a, 0, NULL); + xmit_th[a] = (HANDLE)_beginthreadex (NULL, 0, recv_adev_thread, (void*)(ptrdiff_t)a, 0, NULL); if (xmit_th[a] == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("FATAL: Could not create audio receive thread for device %d.\n", a); @@ -168,7 +168,7 @@ void recv_init (struct audio_s *pa) } #else int e; - e = pthread_create (&xmit_tid[a], NULL, recv_adev_thread, (void *)(long)a); + e = pthread_create (&xmit_tid[a], NULL, recv_adev_thread, (void *)(ptrdiff_t)a); if (e != 0) { text_color_set(DW_COLOR_ERROR); @@ -203,7 +203,7 @@ static unsigned __stdcall recv_adev_thread (void *arg) static void * recv_adev_thread (void *arg) #endif { - int a = (int)(long)arg; // audio device number. + int a = (int)(ptrdiff_t)arg; // audio device number. int eof; /* This audio device can have one (mono) or two (stereo) channels. */ diff --git a/src/server.c b/src/server.c index 53fd592..6726a91 100644 --- a/src/server.c +++ b/src/server.c @@ -461,14 +461,14 @@ void server_init (struct audio_s *audio_config_p, struct misc_config_s *mc) * This waits for a client to connect and sets an available client_sock[n]. */ #if __WIN32__ - connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(unsigned int)server_port, 0, NULL); + connect_listen_th = (HANDLE)_beginthreadex (NULL, 0, connect_listen_thread, (void *)(ptrdiff_t)server_port, 0, NULL); if (connect_listen_th == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create AGW connect listening thread\n"); return; } #else - e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(long)server_port); + e = pthread_create (&connect_listen_tid, NULL, connect_listen_thread, (void *)(ptrdiff_t)server_port); if (e != 0) { text_color_set(DW_COLOR_ERROR); perror("Could not create AGW connect listening thread"); @@ -484,14 +484,14 @@ void server_init (struct audio_s *audio_config_p, struct misc_config_s *mc) for (client = 0; client < MAX_NET_CLIENTS; client++) { #if __WIN32__ - cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, cmd_listen_thread, (void*)client, 0, NULL); + cmd_listen_th[client] = (HANDLE)_beginthreadex (NULL, 0, cmd_listen_thread, (void*)(ptrdiff_t)client, 0, NULL); if (cmd_listen_th[client] == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create AGW command listening thread for client %d\n", client); return; } #else - e = pthread_create (&cmd_listen_tid[client], NULL, cmd_listen_thread, (void *)(long)client); + e = pthread_create (&cmd_listen_tid[client], NULL, cmd_listen_thread, (void *)(ptrdiff_t)client); if (e != 0) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create AGW command listening thread for client %d\n", client); @@ -535,10 +535,10 @@ static THREAD_F connect_listen_thread (void *arg) SOCKET listen_sock; WSADATA wsadata; - snprintf (server_port_str, sizeof(server_port_str), "%d", (int)(long)arg); + snprintf (server_port_str, sizeof(server_port_str), "%d", (int)(ptrdiff_t)arg); #if DEBUG text_color_set(DW_COLOR_DEBUG); - dw_printf ("DEBUG: serverport = %d = '%s'\n", (int)(long)arg, server_port_str); + dw_printf ("DEBUG: serverport = %d = '%s'\n", (int)(ptrdiff_t)arg, server_port_str); #endif err = WSAStartup (MAKEWORD(2,2), &wsadata); if (err != 0) { @@ -658,7 +658,7 @@ static THREAD_F connect_listen_thread (void *arg) struct sockaddr_in sockaddr; /* Internet socket address stuct */ socklen_t sockaddr_size = sizeof(struct sockaddr_in); - int server_port = (int)(long)arg; + int server_port = (int)(ptrdiff_t)arg; int listen_sock; int bcopt = 1; @@ -1265,7 +1265,7 @@ static THREAD_F cmd_listen_thread (void *arg) /* Maximum for 'D': Info part length + 1 */ } cmd; - int client = (int)(long)arg; + int client = (int)(ptrdiff_t)arg; assert (client >= 0 && client < MAX_NET_CLIENTS); diff --git a/src/xmit.c b/src/xmit.c index ca96f55..e70e8b4 100644 --- a/src/xmit.c +++ b/src/xmit.c @@ -279,7 +279,7 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet) if (p_modem->achan[j].medium == MEDIUM_RADIO) { #if __WIN32__ - xmit_th[j] = (HANDLE)_beginthreadex (NULL, 0, xmit_thread, (void*)(long)j, 0, NULL); + xmit_th[j] = (HANDLE)_beginthreadex (NULL, 0, xmit_thread, (void*)(ptrdiff_t)j, 0, NULL); if (xmit_th[j] == NULL) { text_color_set(DW_COLOR_ERROR); dw_printf ("Could not create xmit thread %d\n", j); @@ -310,10 +310,10 @@ void xmit_init (struct audio_s *p_modem, int debug_xmit_packet) perror("pthread_attr_setschedparam"); } - e = pthread_create (&(xmit_tid[j]), &attr, xmit_thread, (void *)(long)j); + e = pthread_create (&(xmit_tid[j]), &attr, xmit_thread, (void *)(ptrdiff_t)j); pthread_attr_destroy (&attr); #else - e = pthread_create (&(xmit_tid[j]), NULL, xmit_thread, (void *)(long)j); + e = pthread_create (&(xmit_tid[j]), NULL, xmit_thread, (void *)(ptrdiff_t)j); #endif if (e != 0) { text_color_set(DW_COLOR_ERROR); @@ -510,7 +510,7 @@ static unsigned __stdcall xmit_thread (void *arg) static void * xmit_thread (void *arg) #endif { - int chan = (int)(long)arg; // channel number. + int chan = (int)(ptrdiff_t)arg; // channel number. packet_t pp; int prio; int ok;