Skip to content

Commit

Permalink
Merge pull request davidrg#412 from jmalak/cleanup-3
Browse files Browse the repository at this point in the history
correct various type mismatches
  • Loading branch information
davidrg authored Nov 10, 2024
2 parents ebe6d63 + 0c9765f commit b180150
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion kermit/k95/ckoco3.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ extern ascreen /* For saving screens: */

extern ascreen mousescreen; /* Screen during mouse actions */

extern unsigned char /* Video attribute bytes */
unsigned char /* Video attribute bytes */
attribute=NUL, /* Current video attribute byte */
underlineattribute=NUL,
savedattribute[VNUM]={0,0,0,0}, /* Saved video attribute byte */
Expand Down
6 changes: 5 additions & 1 deletion kermit/k95/p.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,12 @@

#ifdef NT
#define _Inline __inline
#ifndef __GNUC__
#define APIRET DWORD
#else
#else /* __GNUC__ */
#define APIRET unsigned __LONG32
#endif /* __GNUC__ */
#else /* NT */
#ifdef __WATCOMC__
#define _Inline inline
#endif /* __WATCOMC__ */
Expand Down
8 changes: 6 additions & 2 deletions kermit/k95/p_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ typedef unsigned long BOOLEAN;

#ifdef XYZ_DLL
#ifdef NT
#ifndef __GNUC__
#ifndef __WATCOMC__
#if !defined(_MSC_VER) || _MSC_VER > 800
/* Visual C++ 1.0 32-bit edition (MSC_VER==800) and Open Watcom don't like this */
typedef long APIRET ;
typedef long APIRET;
#endif
#endif /* __WATCOMC__ */
#else /* __GNUC__ */
#define APIRET unsigned __LONG32
#endif /* __GNUC__ */
#define DosSleep Sleep
#endif
#endif /* NT */
#else /* XYZ_DLL */
typedef long APIRET ;
#define DosSleep msleep
Expand Down
3 changes: 2 additions & 1 deletion kermit/k95/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@
#include <sys\types.h>
#include <sys\stat.h>
#include <io.h>
/* Watcom defines it and it does so differently */
#include <ctype.h>
/* Watcom uses POSIX definition */
#ifndef __WATCOMC__
#define S_IFMT 0xF000
#endif
Expand Down
1 change: 1 addition & 0 deletions kermit/k95/textps.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ char *copyright = "Copyright (C) 1991, 1996, Trustees of Columbia University";
#endif /* CHARSET */

#include <stdio.h> /* For EOF definition */
#include <stdlib.h> /* For atol and exit definition */
#ifdef OS2NTDOS
#include <io.h> /* For isatty() */
#include <string.h>
Expand Down
4 changes: 2 additions & 2 deletions kermit/p95/pdll_async.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ _Inline void async_getch_buf(void) {

#ifdef NT
extern OVERLAPPED overlapped_read;
extern int nActuallyRead ;
extern U32 nActuallyRead ;
#endif /* NT */
APIRET rc=0;
U32 tmout_cnt;
Expand Down Expand Up @@ -259,7 +259,7 @@ _Inline void async_flush_outbuf(void) {

#ifdef NT
extern OVERLAPPED overlapped_write;
extern int nActuallyWritten ;
extern U32 nActuallyWritten ;

if ( overlapped_write.hEvent == (HANDLE) -1 )
{
Expand Down
4 changes: 2 additions & 2 deletions kermit/p95/pdll_global.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ U32 send_rz_cr = 0;

#ifdef NT
OVERLAPPED overlapped_read = {0L,0L,0L,0L,(HANDLE)-1};
int nActuallyRead = 0;
U32 nActuallyRead = 0;
OVERLAPPED overlapped_write = {0L,0L,0L,0L,(HANDLE)-1};
int nActuallyWritten = 0;
U32 nActuallyWritten = 0;
#endif /* NT */

6 changes: 5 additions & 1 deletion kermit/p95/pdll_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ p_transfer() P_CFG *param_p_cfg ;
}
dev_type = p_cfg->dev_type;
dev_path = p_cfg->dev_path;
dev_handle = p_cfg->dev_handle;
#ifdef NT
dev_handle = (HANDLE)p_cfg->dev_handle;
#else
dev_handle = (HFILE)p_cfg->dev_handle;
#endif
socket_remote = p_cfg->socket_host;
socket_port = p_cfg->socket_port;

Expand Down
52 changes: 29 additions & 23 deletions kermit/p95/pdll_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
#endif /* __GNUC__ */
#endif

#ifdef NT
#define socket_handle (*(SOCKET *)&dev_handle)
#else /* NT */
#define socket_handle (*(int *)&dev_handle)
#endif /* NT */

_Inline void tcp_open(void) {

U32 true = 1;
Expand All @@ -47,15 +53,15 @@ _Inline void tcp_open(void) {
#endif

#ifdef NT
if (!dev_handle)
if (!socket_handle)
if( WSAStartup( MAKEWORD( 2, 0 ), &wsadata ) )
#else
if (sock_init())
#endif
p_error(P_ERROR_SOCK_INIT, 0,
MODULE_SOCKET, __LINE__, 0);

if (!dev_handle) {
if (!socket_handle) {
if (dev_server) {
if ((passive_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1)
p_error(P_ERROR_SOCKET, sock_errno(),
Expand Down Expand Up @@ -104,23 +110,23 @@ ioctl(passive_socket, FIONBIO, (char *)&true, sizeof(U32))
MODULE_SOCKET, __LINE__, (intptr_t)socket_remote);
server.sin_addr.s_addr = *((unsigned long *)hostnm->h_addr);
}
if ((dev_handle = socket(AF_INET, SOCK_STREAM, 0)) == -1)
if ((socket_handle = socket(AF_INET, SOCK_STREAM, 0)) == -1)
p_error(P_ERROR_SOCKET, sock_errno(),
MODULE_SOCKET, __LINE__, 0);
if (connect(dev_handle,
if (connect(socket_handle,
(struct sockaddr *)&server, sizeof(server)) == -1)
p_error(P_ERROR_CONNECT, sock_errno(),
MODULE_SOCKET, __LINE__, dev_handle);
MODULE_SOCKET, __LINE__, socket_handle);
if (
#ifdef NT
ioctlsocket( dev_handle, FIONBIO, &true )
ioctlsocket( socket_handle, FIONBIO, &true )
#else
ioctl(dev_handle, FIONBIO, (char *)&true, sizeof(U32))
ioctl(socket_handle, FIONBIO, (char *)&true, sizeof(U32))
#endif
)
p_error(P_ERROR_IOCTL, sock_errno(),
MODULE_SOCKET, __LINE__,
dev_handle);
socket_handle);
}
}
}
Expand All @@ -133,10 +139,10 @@ _Inline U32 tcp_connect(void) {
struct sockaddr_in client; /* client address information */

namelen = sizeof(client);
dev_handle = accept(passive_socket,
socket_handle = accept(passive_socket,
(struct sockaddr *)&client,
(int *)&namelen);
if (dev_handle == -1) {
if (socket_handle == -1) {
if (sock_errno() ==
#ifdef NT
WSAEWOULDBLOCK
Expand All @@ -163,22 +169,22 @@ _Inline U32 tcp_connect(void) {

if (
#ifdef NT
ioctlsocket( dev_handle, FIONBIO, &true )
ioctlsocket( socket_handle, FIONBIO, &true )
#else
ioctl(dev_handle, FIONBIO, (char *)&true, sizeof(U32))
ioctl(socket_handle, FIONBIO, (char *)&true, sizeof(U32))
#endif
)
p_error(P_ERROR_IOCTL, sock_errno(),
MODULE_SOCKET, __LINE__,
dev_handle);
socket_handle);
return(1);
}

_Inline void tcp_close(void) {

if (dev_server)
soclose(passive_socket);
soclose(dev_handle);
soclose(socket_handle);
}

_Inline U32 tcp_incoming(void) {
Expand All @@ -188,20 +194,20 @@ _Inline U32 tcp_incoming(void) {
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(dev_handle, &rfds);
FD_SET(socket_handle, &rfds);
tv.tv_sec = tv.tv_usec = 0L;
if ( select(FD_SETSIZE, &rfds, NULL, NULL, &tv ) > 0 &&
FD_ISSET(dev_handle, &rfds) )
FD_ISSET(socket_handle, &rfds) )
return 1 ;
else return 0 ;
#else
rc = select((int *)&dev_handle,
rc = select(&socket_handle,
1, 0, 0, /* Num of read, write and */
/* special sockets */
0); /* No timeout */
if (rc == -1)
p_error(P_ERROR_SELECT, sock_errno(),
MODULE_SOCKET, __LINE__, dev_handle);
MODULE_SOCKET, __LINE__, socket_handle);
#endif
if (rc)
return(1);
Expand All @@ -216,7 +222,7 @@ _Inline void tcp_getch_buf(void) {
inbuf_idx = 0;
inbuf_len = 0;
for (tmout_cnt = 0; tmout_cnt < timeouts_per_call; tmout_cnt++) {
inbuf_len = recv(dev_handle, inbuf, inbuf_size, 0);
inbuf_len = recv(socket_handle, inbuf, inbuf_size, 0);
if ((S32)inbuf_len > 0) { /* Data received ok? */
return;
} else if (inbuf_len == -1 && sock_errno() ==
Expand All @@ -230,7 +236,7 @@ _Inline void tcp_getch_buf(void) {
DosSleep(30);
} else
p_error(P_ERROR_RECV, sock_errno(),
MODULE_SOCKET, __LINE__, dev_handle);
MODULE_SOCKET, __LINE__, socket_handle);
}
}

Expand All @@ -242,7 +248,7 @@ _Inline void tcp_flush_outbuf(void) {

buf = outbuf;
for (cnt = 0; cnt < 300; cnt++) {
ret_val = send(dev_handle, buf, outbuf_idx, 0);
ret_val = send(socket_handle, buf, outbuf_idx, 0);
if (ret_val == outbuf_idx) { /* Data sent ok? */
outbuf_idx = 0;
return;
Expand All @@ -258,7 +264,7 @@ _Inline void tcp_flush_outbuf(void) {
else if (ret_val == -1)
p_error(P_ERROR_SEND, sock_errno(),
MODULE_SOCKET, __LINE__,
dev_handle);
socket_handle);
else { /* We got something transferred... */
DosSleep(10);
buf += ret_val;
Expand All @@ -267,7 +273,7 @@ _Inline void tcp_flush_outbuf(void) {
}
p_error(P_ERROR_SEND, sock_errno(),
MODULE_SOCKET, __LINE__,
dev_handle);
socket_handle);
}

_Inline U32 tcp_connected(void) {
Expand Down

0 comments on commit b180150

Please sign in to comment.