Skip to content

Commit

Permalink
Merge pull request #392 from jmalak/system-fix
Browse files Browse the repository at this point in the history
correct use of _System calling convention
  • Loading branch information
davidrg authored Oct 31, 2024
2 parents df1cac7 + 7211b81 commit 5be2479
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 121 deletions.
4 changes: 2 additions & 2 deletions kermit/k95/ckonssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ int parse_displayname(char *displayname, int *familyp, char **hostp,
* this DLL provides.
* @param params SSH initialisation parameters from Kermit 95
*/
int _System ssh_dll_init(ssh_init_parameters_t *params) {
int CKSSHAPI ssh_dll_init(ssh_init_parameters_t *params) {
p_get_current_terminal_dimensions = params->p_get_current_terminal_dimensions;
p_get_current_terminal_type = params->p_get_current_terminal_type;
p_ssh_get_uid = params->p_ssh_get_uid;
Expand Down Expand Up @@ -483,7 +483,7 @@ int _System ssh_dll_init(ssh_init_parameters_t *params) {
#undef free
#undef strdup

static void
void
fatal(char *msg) {
if (!msg) msg = "";

Expand Down
23 changes: 15 additions & 8 deletions kermit/k95/ckop.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@

#include "p_type.h"
#include "p.h"
#ifdef XYZ_DLL
#define XYZ_DLL_CLIENT
#include "ckop.h"
#endif /* XYZ_DLL */
#include "p_global.h"
#include "p_callbk.h"
#include "p_common.h"
Expand All @@ -47,8 +50,7 @@ extern int rpackets, spackets, spktl, rpktl, what ;
#ifdef XYZ_DLL
#ifdef OS2
static HMODULE dll_handle;
typedef U32 (_System * p_transfer_t)(P_CFG *);
p_transfer_t p_transfer = NULL;
p_transfer_func *p_transfer = NULL;
#endif /* OS2 */

#define PINBUFSIZE 8192
Expand All @@ -71,7 +73,7 @@ load_p_dll(void) {
debug(F101,"load_p_dll - Unable to load module: rc","",rc);
return rc;
}
p_transfer = (p_transfer_t)GetProcAddress( dll_handle, "p_transfer" ) ;
p_transfer = (p_transfer_func *)GetProcAddress( dll_handle, "p_transfer" ) ;
if ( !p_transfer )
{
rc = GetLastError() ;
Expand Down Expand Up @@ -118,13 +120,15 @@ unload_p_dll(void) {
#endif /* XYZ_DLL */


U32 _System
U32
CKDEVAPI
pushback_func( U8 * buf, U32 len )
{
return le_puts( buf, len );
}

U32 _System
U32
CKDEVAPI
in_func( U8 * buf, U32 len, U32 * bytes_received )
{
extern int network, carrier;
Expand Down Expand Up @@ -172,7 +176,8 @@ in_func( U8 * buf, U32 len, U32 * bytes_received )
return(ERROR_NO_DATA); /* Either no data was received or timeout */
}

U32 _System
U32
CKDEVAPI
out_func( U8 * buf, U32 len, U32 * bytes_written )
{
int rc = 0 ;
Expand Down Expand Up @@ -205,7 +210,8 @@ USHORT DosDevIOCtl32(PVOID pData, USHORT cbData, PVOID pParms, USHORT cbParms,
USHORT usFunction, USHORT usCategory, HFILE hDevice);
#endif /* OS2ONLY */

U32 _System
U32
CKDEVAPI
break_func( U8 on )
{
extern int ttmdm ;
Expand Down Expand Up @@ -245,7 +251,8 @@ break_func( U8 on )
return 0;
}

U32 _System
U32
CKDEVAPI
available_func( U32 * available )
{
int rc = ttchk() ;
Expand Down
19 changes: 17 additions & 2 deletions kermit/k95/ckop.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,25 @@
/* You may modify, recompile and distribute this file freely. */
/*****************************************************************************/

#ifdef NT
#define CKDEVDLLENTRY
#else /* NT */
#ifdef OS2
#define CKDEVDLLENTRY _System
#else /* OS2 */
#define CKDEVDLLENTRY
#endif /* OS2 */
#endif /* NT */

typedef U32 CKDEVDLLENTRY p_transfer_func(P_CFG *);
#ifdef XYZ_DLL
extern U32 (_System * p_transfer)(P_CFG *);
#ifdef XYZ_DLL_CLIENT
extern p_transfer_func * p_transfer;
#else /* XYZ_DLL_CLIENT */
extern p_transfer_func p_transfer;
#endif /* XYZ_DLL_CLIENT */
#else /* XYZ_DLL */
U32 _System p_transfer(P_CFG *);
extern p_transfer_func p_transfer;
#endif /* XYZ_DLL */
extern int load_p_dll(void);
extern int unload_p_dll(void);
Expand Down
86 changes: 43 additions & 43 deletions kermit/k95/ckossh.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,52 +199,52 @@ SOCKET ssh_open_socket(char* host, char* port) {

/* Typedefs for all the function pointers we *could* receive from an SSH
* subsystem DLL */
typedef int (_System * p_ssh_dll_init_t)(ssh_init_parameters_t *);
typedef int (_System * p_ssh_set_iparam_t)(int, int);
typedef int (_System * p_ssh_get_iparam_t)(int);
typedef int (_System * p_ssh_set_sparam_t)(int, const char*);
typedef const char* (_System * p_ssh_get_sparam_t)(int);
typedef int (_System * p_ssh_set_identity_files_t)(const char**);
typedef int (_System * p_ssh_get_socket_t)();
typedef int (_System * p_ssh_open_t)();
typedef int (_System * p_ssh_clos_t)();
typedef int (_System * p_ssh_tchk_t)();
typedef int (_System * p_ssh_flui_t)();
typedef int (_System * p_ssh_break_t)();
typedef int (_System * p_ssh_inc_t)(int);
typedef int (_System * p_ssh_xin_t)(int, char*);
typedef int (_System * p_ssh_toc_t)(int);
typedef int (_System * p_ssh_tol_t)(char*,int);
typedef int (_System * p_ssh_snaws_t)();
typedef const char* (_System * p_ssh_proto_ver_t)();
typedef const char* (_System * p_ssh_impl_ver_t)();
typedef int (_System * p_sshkey_create_t)(char *, int, char *, int, char *);
typedef int (_System * p_sshkey_display_fingerprint_t)(char *, int);
typedef int (_System * p_sshkey_display_public_t)(char *, char *);
typedef int (_System * p_sshkey_display_public_as_ssh2_t)(char *,char *);
typedef int (_System * p_sshkey_change_passphrase_t)(char *, char *, char *);
typedef int (_System * p_ssh_fwd_remote_port_t)(char*, int, char *, int, BOOL);
typedef int (_System * p_ssh_fwd_local_port_t)(char*, int,char *,int, BOOL);
typedef int (_System * p_ssh_fwd_clear_local_ports_t)(BOOL);
typedef int (_System * p_ssh_fwd_clear_remote_ports_t)(BOOL);
typedef int (_System * p_ssh_fwd_remove_remote_port_t)(int, BOOL);
typedef int (_System * p_ssh_fwd_remove_local_port_t)(int, BOOL);
typedef ssh_port_forward_t* (_System * p_ssh_fwd_get_ports_t)();
typedef int (CKSSHAPI * p_ssh_dll_init_t)(ssh_init_parameters_t *);
typedef int (CKSSHAPI * p_ssh_set_iparam_t)(int, int);
typedef int (CKSSHAPI * p_ssh_get_iparam_t)(int);
typedef int (CKSSHAPI * p_ssh_set_sparam_t)(int, const char*);
typedef const char* (CKSSHAPI * p_ssh_get_sparam_t)(int);
typedef int (CKSSHAPI * p_ssh_set_identity_files_t)(const char**);
typedef int (CKSSHAPI * p_ssh_get_socket_t)();
typedef int (CKSSHAPI * p_ssh_open_t)();
typedef int (CKSSHAPI * p_ssh_clos_t)();
typedef int (CKSSHAPI * p_ssh_tchk_t)();
typedef int (CKSSHAPI * p_ssh_flui_t)();
typedef int (CKSSHAPI * p_ssh_break_t)();
typedef int (CKSSHAPI * p_ssh_inc_t)(int);
typedef int (CKSSHAPI * p_ssh_xin_t)(int, char*);
typedef int (CKSSHAPI * p_ssh_toc_t)(int);
typedef int (CKSSHAPI * p_ssh_tol_t)(char*,int);
typedef int (CKSSHAPI * p_ssh_snaws_t)();
typedef const char* (CKSSHAPI * p_ssh_proto_ver_t)();
typedef const char* (CKSSHAPI * p_ssh_impl_ver_t)();
typedef int (CKSSHAPI * p_sshkey_create_t)(char *, int, char *, int, char *);
typedef int (CKSSHAPI * p_sshkey_display_fingerprint_t)(char *, int);
typedef int (CKSSHAPI * p_sshkey_display_public_t)(char *, char *);
typedef int (CKSSHAPI * p_sshkey_display_public_as_ssh2_t)(char *,char *);
typedef int (CKSSHAPI * p_sshkey_change_passphrase_t)(char *, char *, char *);
typedef int (CKSSHAPI * p_ssh_fwd_remote_port_t)(char*, int, char *, int, BOOL);
typedef int (CKSSHAPI * p_ssh_fwd_local_port_t)(char*, int,char *,int, BOOL);
typedef int (CKSSHAPI * p_ssh_fwd_clear_local_ports_t)(BOOL);
typedef int (CKSSHAPI * p_ssh_fwd_clear_remote_ports_t)(BOOL);
typedef int (CKSSHAPI * p_ssh_fwd_remove_remote_port_t)(int, BOOL);
typedef int (CKSSHAPI * p_ssh_fwd_remove_local_port_t)(int, BOOL);
typedef ssh_port_forward_t* (CKSSHAPI * p_ssh_fwd_get_ports_t)();
#ifdef SSHTEST
typedef int (_System * p_sshkey_v1_change_comment_t)(char *, char *, char *);
typedef int (CKSSHAPI * p_sshkey_v1_change_comment_t)(char *, char *, char *);
#endif /* SSHTEST */
/*typedef char * (*p_sshkey_default_file_t)(int);*/
typedef void (_System * p_ssh_v2_rekey_t)();
typedef int (_System * p_ssh_agent_delete_file_t)(const char *);
typedef int (_System * p_ssh_agent_delete_all_t)();
typedef int (_System * p_ssh_agent_add_file_t)(const char*);
typedef int (_System * p_ssh_agent_list_identities_t)(int);
typedef void (_System * p_ssh_unload_t)();
typedef const char* (_System * p_ssh_dll_ver_t)();
typedef ktab_ret (_System * p_ssh_get_keytab_t)(int keytab_id);
typedef int (_System * p_ssh_feature_supported_t)(int feature_id);
typedef const char** (_System *p_ssh_get_set_help_t)();
typedef const char** (_System *p_ssh_get_help_t)();
typedef void (CKSSHAPI * p_ssh_v2_rekey_t)();
typedef int (CKSSHAPI * p_ssh_agent_delete_file_t)(const char *);
typedef int (CKSSHAPI * p_ssh_agent_delete_all_t)();
typedef int (CKSSHAPI * p_ssh_agent_add_file_t)(const char*);
typedef int (CKSSHAPI * p_ssh_agent_list_identities_t)(int);
typedef void (CKSSHAPI * p_ssh_unload_t)();
typedef const char* (CKSSHAPI * p_ssh_dll_ver_t)();
typedef ktab_ret (CKSSHAPI * p_ssh_get_keytab_t)(int keytab_id);
typedef int (CKSSHAPI * p_ssh_feature_supported_t)(int feature_id);
typedef const char** (CKSSHAPI *p_ssh_get_set_help_t)();
typedef const char** (CKSSHAPI *p_ssh_get_help_t)();

/* Function pointers received from the currently loaded SSH subsystem DLL */
static p_ssh_dll_init_t p_ssh_init = NULL;
Expand Down
62 changes: 33 additions & 29 deletions kermit/k95/ckossh.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#ifndef _CKOSSH_H
#define _CKOSSH_H

#ifdef NT
#define CKSSHAPI
#else /* NT */
#ifdef OS2
#define CKSSHAPI _System
#else /* OS2 */
#define CKSSHAPI
#endif /* OS2 */
#endif /* NT */

#ifndef SSH_PF_T
#define SSH_PF_T
/* Note: This also exists in ckolsshs.h */
Expand Down Expand Up @@ -198,12 +208,6 @@ _PROTOTYP(int ssh_feature_supported,(int feature_id));
_PROTOTYP(void ssh_initialise,(void));
#endif

#ifdef NT
#ifndef _System
#define _System
#endif /* _System */
#endif /* NT */

#ifndef SOCKET
/* On OS/2, SOCKET is just int. */
#define SOCKET int
Expand All @@ -217,34 +221,34 @@ typedef struct {

/* Version 1 */
int version;
void (* _System p_install_funcs)(const char*, const void*);
void (* _System p_get_current_terminal_dimensions)(int* rows, int* cols);
const char* (* _System p_get_current_terminal_type)();
const char* (* _System p_ssh_get_uid)();
const char* (* _System p_ssh_get_pw)();
int (* _System p_ssh_get_nodelay_enabled)();
SOCKET (* _System p_ssh_open_socket)(char* host, char* port);
int (* _System p_dodebug)(int,char *,char *,CK_OFF_T);
int (* _System p_vscrnprintf)(const char *, ...);
int (* _System p_uq_txt)(char *,char *,int,char **,char *,int,char *,int);
int (* _System p_uq_mtxt) (char *,char **,int,struct txtbox[]);
int (* _System p_uq_ok)(char *,char *,int,char **,int);
int (* _System p_uq_file)(char *,char *,int,char **,char *,char *,int);
int (* _System p_zmkdir)(char *);
int (* _System p_ckmakxmsg)(char * buf, int len, char *s1, char *s2, char *s3,
void (* CKSSHAPI p_install_funcs)(const char*, const void*);
void (* CKSSHAPI p_get_current_terminal_dimensions)(int* rows, int* cols);
const char* (* CKSSHAPI p_get_current_terminal_type)();
const char* (* CKSSHAPI p_ssh_get_uid)();
const char* (* CKSSHAPI p_ssh_get_pw)();
int (* CKSSHAPI p_ssh_get_nodelay_enabled)();
SOCKET (* CKSSHAPI p_ssh_open_socket)(char* host, char* port);
int (* CKSSHAPI p_dodebug)(int,char *,char *,CK_OFF_T);
int (* CKSSHAPI p_vscrnprintf)(const char *, ...);
int (* CKSSHAPI p_uq_txt)(char *,char *,int,char **,char *,int,char *,int);
int (* CKSSHAPI p_uq_mtxt) (char *,char **,int,struct txtbox[]);
int (* CKSSHAPI p_uq_ok)(char *,char *,int,char **,int);
int (* CKSSHAPI p_uq_file)(char *,char *,int,char **,char *,char *,int);
int (* CKSSHAPI p_zmkdir)(char *);
int (* CKSSHAPI p_ckmakxmsg)(char * buf, int len, char *s1, char *s2, char *s3,
char *s4, char *s5, char *s6, char *s7, char *s8, char *s9,
char *s10, char *s11, char *s12);
char* (* _System p_whoami)();
char* (* _System p_GetAppData)(int);
char* (* _System p_GetHomePath)();
char* (* _System p_GetHomeDrive)();
int (* _System p_ckstrncpy)(char * dest, const char * src, int len);
int (* _System p_debug_logging)();
char* (* CKSSHAPI p_whoami)();
char* (* CKSSHAPI p_GetAppData)(int);
char* (* CKSSHAPI p_GetHomePath)();
char* (* CKSSHAPI p_GetHomeDrive)();
int (* CKSSHAPI p_ckstrncpy)(char * dest, const char * src, int len);
int (* CKSSHAPI p_debug_logging)();

/* Returns a statically allocated string containing the currently
* configured X11 display
*/
unsigned char* (* _System p_get_display)();
unsigned char* (* CKSSHAPI p_get_display)();

/* Utility function for parsing the display name. Result is returned
* via:
Expand All @@ -254,7 +258,7 @@ typedef struct {
* *scrnump - Screen number
* **restp - Anything else at the end
*/
int (* _System p_parse_displayname)(char *displayname, int *familyp,
int (* CKSSHAPI p_parse_displayname)(char *displayname, int *familyp,
char **hostp, int *dpynump, int *scrnump, char **restp);
} ssh_init_parameters_t;

Expand Down
Loading

0 comments on commit 5be2479

Please sign in to comment.