mirror of
https://github.com/digarok/gsplus.git
synced 2024-06-14 03:29:32 +00:00
clean up socket stuff a little bit to compile better with msys2
This commit is contained in:
parent
9f3c0feb39
commit
62dcf4f9d2
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
#include "scc_llap.h"
|
||||
|
||||
#ifdef UNDER_CE
|
||||
|
@ -25,7 +26,6 @@ extern int g_appletalk_turbo;
|
|||
/* my scc port 0 == channel A = slot 1 = c039/c03b */
|
||||
/* port 1 == channel B = slot 2 = c038/c03a */
|
||||
|
||||
#include "scc.h"
|
||||
#define SCC_R14_DPLL_SOURCE_BRG 0x100
|
||||
#define SCC_R14_FM_MODE 0x200
|
||||
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
See LICENSE.txt for license (GPL v2)
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <winsock2.h>
|
||||
#else
|
||||
# include <sys/socket.h>
|
||||
# include <netinet/in.h>
|
||||
# include <netdb.h>
|
||||
typedef int SOCKET;
|
||||
#endif
|
||||
|
||||
#if defined(HPUX) || defined(__linux__) || defined(SOLARIS) || defined(MAC) || defined(__MACH__) || defined(_WIN32)
|
||||
|
@ -28,10 +27,6 @@
|
|||
|
||||
#define SCC_MODEM_MAX_CMD_STR 128
|
||||
|
||||
#ifndef SOCKET
|
||||
# define SOCKET word32 /* for non-windows */
|
||||
#endif
|
||||
|
||||
STRUCT(Scc) {
|
||||
int port;
|
||||
int state /* 0 == disconnected, 1 == real serial port, 2 == socket, 3 == LocalTalk */;
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
/* This is an interface between the SCC emulation and the Virtual Imagewriter. */
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
#include "imagewriter.h"
|
||||
#include "scc.h"
|
||||
|
||||
extern Scc scc_stat[2];
|
||||
extern word32 g_vbl_count;
|
||||
|
||||
|
|
|
@ -7,17 +7,16 @@
|
|||
|
||||
/* This file contains the Mac serial calls */
|
||||
|
||||
#ifdef MAC
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <termios.h>
|
||||
#endif
|
||||
#include <termios.h>
|
||||
|
||||
extern Scc scc_stat[2];
|
||||
extern word32 g_c025_val;
|
||||
|
||||
#ifdef MAC
|
||||
int scc_serial_mac_init(int port) {
|
||||
char str_buf[1024];
|
||||
Scc *scc_ptr;
|
||||
|
|
|
@ -14,17 +14,16 @@
|
|||
#ifndef UNDER_CE //OG
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef __CYGWIN__
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#define socklen_t int
|
||||
#endif
|
||||
|
||||
extern Scc scc_stat[2];
|
||||
extern int g_serial_modem[];
|
||||
|
||||
#if !(defined _WIN32)
|
||||
extern int h_errno;
|
||||
#else
|
||||
#define socklen_t int
|
||||
#endif
|
||||
|
||||
int g_wsastartup_called = 0;
|
||||
typedef unsigned short USHORT;
|
||||
|
||||
|
@ -108,19 +107,17 @@ void scc_socket_maybe_open_incoming(int port, double dcycs) {
|
|||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
printf("sockfd ret: %d\n", sockfd);
|
||||
if(sockfd == -1) {
|
||||
printf("socket ret: %d, errno: %d\n", sockfd, errno);
|
||||
perror("socket");
|
||||
scc_socket_close(port, 0, dcycs);
|
||||
scc_ptr->socket_state = -1;
|
||||
return;
|
||||
}
|
||||
/* printf("socket ret: %d\n", sockfd); */
|
||||
|
||||
on = 1;
|
||||
ret = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&on, sizeof(on));
|
||||
if(ret < 0) {
|
||||
printf("setsockopt REUSEADDR ret: %d, err:%d\n",
|
||||
ret, errno);
|
||||
perror("setsockopt REUSEADDR");
|
||||
scc_socket_close(port, 0, dcycs);
|
||||
scc_ptr->socket_state = -1;
|
||||
return;
|
||||
|
@ -138,7 +135,7 @@ void scc_socket_maybe_open_incoming(int port, double dcycs) {
|
|||
break;
|
||||
}
|
||||
/* else ret to bind was < 0 */
|
||||
printf("bind ret: %d, errno: %d\n", ret, errno);
|
||||
perror("bind");
|
||||
inc++;
|
||||
scc_socket_close_handle(sockfd);
|
||||
printf("Trying next port: %d\n", 6501 + port + inc);
|
||||
|
@ -180,7 +177,7 @@ void scc_socket_open_outgoing(int port, double dcycs) {
|
|||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
printf("sockfd ret: %d\n", sockfd);
|
||||
if(sockfd == -1) {
|
||||
printf("socket ret: %d, errno: %d\n", sockfd, errno);
|
||||
perror("socket");
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
return;
|
||||
}
|
||||
|
@ -190,8 +187,7 @@ void scc_socket_open_outgoing(int port, double dcycs) {
|
|||
ret = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
|
||||
(char *)&on, sizeof(on));
|
||||
if(ret < 0) {
|
||||
printf("setsockopt REUSEADDR ret: %d, err:%d\n",
|
||||
ret, errno);
|
||||
perror("setsockopt REUSEADDR");
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
return;
|
||||
}
|
||||
|
@ -218,9 +214,9 @@ void scc_socket_open_outgoing(int port, double dcycs) {
|
|||
hostentptr = gethostbyname((const char*)&scc_ptr->modem_cmd_str[0]); // OG Added Cast
|
||||
if(hostentptr == 0) {
|
||||
#if defined(_WIN32)
|
||||
fatal_printf("Lookup host %s failed\n", &scc_ptr->modem_cmd_str[0]);
|
||||
fatal_printf("gethostbyname %s failed\n", &scc_ptr->modem_cmd_str[0]);
|
||||
#else
|
||||
fatal_printf("Lookup host %s failed, herrno: %d\n", &scc_ptr->modem_cmd_str[0], h_errno);
|
||||
fatal_printf("gethostbyname %s failed: %s\n", &scc_ptr->modem_cmd_str[0], hstrerror(h_errno));
|
||||
#endif
|
||||
scc_socket_close_handle(sockfd);
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
|
@ -234,7 +230,7 @@ void scc_socket_open_outgoing(int port, double dcycs) {
|
|||
|
||||
ret = connect(sockfd, (struct sockaddr *)&sa_in, sizeof(sa_in));
|
||||
if(ret < 0) {
|
||||
printf("connect ret: %d, errno: %d\n", ret, errno);
|
||||
perror("connect");
|
||||
scc_socket_close_handle(sockfd);
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
return;
|
||||
|
@ -276,14 +272,14 @@ void scc_socket_make_nonblock(int port, double dcycs) {
|
|||
#else
|
||||
flags = fcntl(sockfd, F_GETFL, 0);
|
||||
if(flags == -1) {
|
||||
printf("fcntl GETFL ret: %d, errno: %d\n", flags, errno);
|
||||
perror("fcntl GETFL");
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
scc_ptr->socket_state = -1;
|
||||
return;
|
||||
}
|
||||
ret = fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
|
||||
if(ret == -1) {
|
||||
printf("fcntl SETFL ret: %d, errno: %d\n", ret, errno);
|
||||
perror("fcntl SETFL");
|
||||
scc_socket_close(port, 1, dcycs);
|
||||
scc_ptr->socket_state = -1;
|
||||
return;
|
||||
|
@ -374,12 +370,12 @@ void scc_accept_socket(int port, double dcycs) {
|
|||
/* For Linux, we need to set O_NONBLOCK on the rdwrfd */
|
||||
flags = fcntl(rdwrfd, F_GETFL, 0);
|
||||
if(flags == -1) {
|
||||
printf("fcntl GETFL ret: %d, errno: %d\n", flags,errno);
|
||||
perror("fcntl GETFL");
|
||||
return;
|
||||
}
|
||||
ret = fcntl(rdwrfd, F_SETFL, flags | O_NONBLOCK);
|
||||
if(ret == -1) {
|
||||
printf("fcntl SETFL ret: %d, errno: %d\n", ret, errno);
|
||||
perror("fcntl SETFL");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
/* This file contains the Win32 COM1/COM2 calls */
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "defc.h"
|
||||
#include "scc.h"
|
||||
|
||||
#ifdef __CYGWIN__
|
||||
#include <Windows.h>
|
||||
#include <NspAPI.h>
|
||||
#endif
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define vsnprintf _vsnprintf
|
||||
|
@ -22,7 +22,6 @@
|
|||
extern Scc scc_stat[2];
|
||||
extern word32 g_c025_val;
|
||||
|
||||
#ifdef _WIN32
|
||||
int scc_serial_win_init(int port) {
|
||||
COMMTIMEOUTS commtimeouts;
|
||||
TCHAR str_buf[8];
|
||||
|
|
Loading…
Reference in New Issue
Block a user