Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 397f6800 authored by rswindell's avatar rswindell

Changed DLL exported functions to use __stdcall when built with Borland C++.

This is apparently the only way to generated MSVC __cdecl-compatible names.
The stack maintenance isn't supposed to be compatible, but it appears to work. <shrug>
parent 34e27551
......@@ -39,8 +39,8 @@
#ifndef __FLAT__
#define __FLAT__
#endif
#ifdef LZH_VB_COMPATIBLE
#define LZHCALL __stdcall /* VB Compatible */
#ifdef __BORLANDC__
#define LZHCALL __stdcall
#else
#define LZHCALL
#endif
......
......@@ -42,20 +42,33 @@
extern "C" {
#endif
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef SBBS
#define BBS_CALL __declspec( dllexport )
#ifdef SBBS_EXPORTS
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define BBS_CALL __declspec( dllimport )
#define DLLCALL
#endif
#else /* !_WIN32 */
#define BBS_CALL
#else
#define DLLEXPORT
#define DLLCALL
#endif
/* arg is pointer to static bbs_startup_t* */
BBS_CALL void bbs_thread(void* arg);
BBS_CALL void bbs_terminate(void);
BBS_CALL char* bbs_ver(void);
DLLEXPORT void DLLCALL bbs_thread(void* arg);
DLLEXPORT void DLLCALL bbs_terminate(void);
DLLEXPORT char* DLLCALL bbs_ver(void);
#ifdef __cplusplus
}
......
......@@ -42,7 +42,7 @@
/* Need fields .name ,.dir and .offset to get other info */
/* Does not fill .dateuled or .datedled fields. */
/****************************************************************************/
BOOL getfiledat(scfg_t* cfg, file_t* f)
BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f)
{
char buf[F_LEN+1],str[256],tmp[128];
int file;
......@@ -114,7 +114,7 @@ BOOL getfiledat(scfg_t* cfg, file_t* f)
/* Puts filedata into DIR_code.DAT file */
/* Called from removefiles */
/****************************************************************************/
BOOL putfiledat(scfg_t* cfg, file_t* f)
BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f)
{
char buf[F_LEN+1],str[256],tmp[128];
int file;
......@@ -168,7 +168,7 @@ BOOL putfiledat(scfg_t* cfg, file_t* f)
/* changes the .datoffset field only */
/* returns 1 if added successfully, 0 if not. */
/****************************************************************************/
BOOL addfiledat(scfg_t* cfg, file_t* f)
BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f)
{
char str[256],fname[13],c,fdat[F_LEN+1];
char tmp[128];
......@@ -358,7 +358,7 @@ BOOL addfiledat(scfg_t* cfg, file_t* f)
/* Need fields .name and .dir filled. */
/* only fills .offset, .dateuled, and .datedled */
/****************************************************************************/
BOOL getfileixb(scfg_t* cfg, file_t* f)
BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f)
{
char str[256],fname[13];
uchar HUGE16 * ixbbuf;
......@@ -414,7 +414,7 @@ BOOL getfileixb(scfg_t* cfg, file_t* f)
/****************************************************************************/
/* Removes DAT and IXB entries for the file in the struct 'f' */
/****************************************************************************/
BOOL removefiledat(scfg_t* cfg, file_t* f)
BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f)
{
char c,str[256],ixbname[12],HUGE16 *ixbbuf,fname[13];
int file;
......@@ -486,7 +486,7 @@ BOOL removefiledat(scfg_t* cfg, file_t* f)
/* it returns the 1, else returns 0. */
/* Called from upload and bulkupload */
/****************************************************************************/
BOOL findfile(scfg_t* cfg, uint dirnum, char *filename)
BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename)
{
char str[256],c,fname[13],HUGE16 *ixbbuf;
int file;
......@@ -525,7 +525,7 @@ BOOL findfile(scfg_t* cfg, uint dirnum, char *filename)
/****************************************************************************/
/* Turns FILE.EXT into FILE .EXT */
/****************************************************************************/
char * padfname(char *filename, char *str)
char* DLLCALL padfname(char *filename, char *str)
{
char c,d;
......@@ -549,7 +549,7 @@ char * padfname(char *filename, char *str)
/****************************************************************************/
/* Turns FILE .EXT into FILE.EXT */
/****************************************************************************/
char * unpadfname(char *filename, char *str)
char* DLLCALL unpadfname(char *filename, char *str)
{
char c,d;
......@@ -563,7 +563,7 @@ char * unpadfname(char *filename, char *str)
/* Removes any files in the user transfer index (XFER.IXT) that match the */
/* specifications of dest, or source user, or filename or any combination. */
/****************************************************************************/
BOOL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname)
BOOL DLLCALL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname)
{
char str[256],*ixtbuf;
int file;
......
......@@ -56,11 +56,8 @@
#include <sys/stat.h> /* S_IWRITE */
/* Synchronet-specific headers */
#include "sbbsinet.h"
#include "sbbswrap.h"
#include "scfgdefs.h"
#include "sbbs.h"
#include "ftpsrvr.h"
#include "userdat.h"
#include "telnet.h"
/* Constants */
......@@ -86,27 +83,6 @@
static const char *mon[]={"Jan","Feb","Mar","Apr","May","Jun"
,"Jul","Aug","Sep","Oct","Nov","Dec"};
#ifdef _WIN32
#define IMPORT __declspec(dllimport)
#else
#define IMPORT
#endif
IMPORT BOOL load_cfg(scfg_t* cfg, char* text[]);
IMPORT BOOL getfileixb(scfg_t* cfg, file_t* f);
IMPORT BOOL getfiledat(scfg_t* cfg, file_t* f);
IMPORT BOOL putfiledat(scfg_t* cfg, file_t* f);
IMPORT BOOL removefiledat(scfg_t* cfg, file_t* f);
IMPORT BOOL addfiledat(scfg_t* cfg, file_t* f);
IMPORT BOOL findfile(scfg_t* cfg, uint dirnum, char *filename);
IMPORT char* padfname(char *filename, char *str);
IMPORT char* unpadfname(char *filename, char *str);
IMPORT BOOL trashcan(scfg_t* cfg, char *insearch, char *name);
BOOL direxist(char *dir)
{
if(access(dir,0)==0)
......@@ -466,7 +442,7 @@ int sockreadline(SOCKET socket, char* buf, int len, time_t* lastactive)
return(rd);
}
void ftp_terminate(void)
void DLLCALL ftp_terminate(void)
{
if(server_socket!=INVALID_SOCKET) {
lprintf("FTP Terminate: closing socket %d",server_socket);
......@@ -2925,7 +2901,7 @@ static void cleanup(int code)
thread_down();
}
char* ftp_ver(void)
char* DLLCALL ftp_ver(void)
{
static char ver[256];
char compiler[32];
......@@ -2945,7 +2921,7 @@ char* ftp_ver(void)
return(ver);
}
void ftp_server(void* arg)
void DLLCALL ftp_server(void* arg)
{
char compiler[32];
SOCKADDR_IN server_addr;
......
......@@ -95,23 +95,36 @@ typedef struct {
#define FTP_OPT_NO_HOST_LOOKUP (1<<11)
#define FTP_OPT_MUTE (1<<31)
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef FTPSRVR_EXPORTS
#define FTP_CALL __declspec( dllexport )
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define FTP_CALL __declspec( dllimport )
#define DLLCALL
#endif
#else /* !_WIN32 */
#define FTP_CALL
#else
#define DLLEXPORT
#define DLLCALL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* arg is pointer to static ftp_startup_t */
FTP_CALL void ftp_server(void* arg);
FTP_CALL void ftp_terminate(void);
FTP_CALL char* ftp_ver(void);
DLLEXPORT void DLLCALL ftp_server(void* arg);
DLLEXPORT void DLLCALL ftp_terminate(void);
DLLEXPORT char* DLLCALL ftp_ver(void);
#ifdef __cplusplus
}
#endif
\ No newline at end of file
......@@ -40,7 +40,7 @@
/****************************************************************************/
/* Initializes system and node configuration information and data variables */
/****************************************************************************/
BOOL load_cfg(scfg_t* cfg, char* text[])
BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[])
{
char str[256],fname[13];
int i;
......
......@@ -54,32 +54,13 @@
#include <errno.h> /* errno */
/* Synchronet-specific headers */
#include "scfgdefs.h"
#include "sbbs.h"
#include "mailsrvr.h"
#include "userdat.h"
#include "smblib.h"
#include "crc32.h"
#include "sbbsinet.h"
#include "sbbswrap.h"
/* Constants */
#define MAIL_VERSION "1.10"
#ifdef _WIN32
#define IMPORT __declspec(dllimport)
#else
#define IMPORT
#endif
IMPORT BOOL load_cfg(scfg_t* cfg, char* text[]);
IMPORT ushort crc16(char *str);
IMPORT char * zonestr(short zone);
IMPORT int putsmsg(scfg_t* cfg, int usernumber, char *strin);
IMPORT mail_t* loadmail(smb_t* smb, ulong* msgs, uint usernumber
,int which, long mode);
IMPORT void freemail(mail_t* mail);
IMPORT BOOL trashcan(scfg_t* cfg, char *insearch, char *name);
int dns_getmx(char* name, char* mx, char* mx2, DWORD intf, DWORD ip_addr, BOOL use_tcp);
#define SMTP_OK "250 OK"
......@@ -2210,7 +2191,7 @@ static void sendmail_thread(void* arg)
thread_down();
}
void mail_terminate(void)
void DLLCALL mail_terminate(void)
{
if(server_socket!=INVALID_SOCKET) {
lprintf("MAIL Terminate: closing socket %d",server_socket);
......@@ -2245,7 +2226,7 @@ static void cleanup(int code)
thread_down();
}
char* mail_ver(void)
char* DLLCALL mail_ver(void)
{
static char ver[256];
char compiler[32];
......@@ -2267,7 +2248,7 @@ char* mail_ver(void)
return(ver);
}
void mail_server(void* arg)
void DLLCALL mail_server(void* arg)
{
char compiler[32];
SOCKADDR_IN server_addr;
......
......@@ -102,23 +102,36 @@ typedef struct {
#define MAIL_OPT_USE_TCP_DNS (1<<12)
#define MAIL_OPT_MUTE (1<<31)
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef MAILSRVR_EXPORTS
#define MAIL_CALL __declspec( dllexport )
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define MAIL_CALL __declspec( dllimport )
#define DLLCALL
#endif
#else /* !_WIN32 */
#define MAIL_CALL
#else
#define DLLEXPORT
#define DLLCALL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* arg is pointer to static mail_startup_t* */
MAIL_CALL void mail_server(void* arg);
MAIL_CALL void mail_terminate(void);
MAIL_CALL char* mail_ver(void);
DLLEXPORT void DLLCALL mail_server(void* arg);
DLLEXPORT void DLLCALL mail_terminate(void);
DLLEXPORT char* DLLCALL mail_ver(void);
#ifdef __cplusplus
}
#endif
\ No newline at end of file
......@@ -189,7 +189,7 @@ void ucrc16(uchar ch, ushort *rcrc)
/****************************************************************************/
/* Returns CRC-16 of string (not including terminating NULL) */
/****************************************************************************/
ushort crc16(char *str)
ushort DLLCALL crc16(char *str)
{
int i=0;
ushort crc=0;
......@@ -239,7 +239,7 @@ int strsame(char *str1, char *str2)
/****************************************************************************/
/* Converts when_t.zone into ASCII format */
/****************************************************************************/
char *zonestr(short zone)
char* DLLCALL zonestr(short zone)
{
static char str[32];
......
......@@ -669,14 +669,23 @@ public:
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef SBBS_EXPORTS
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define DLLCALL
#endif
#else /* !_WIN32 */
#define DLLEXPORT
#define DLLCALL
#endif
#ifdef __cplusplus
......@@ -684,27 +693,27 @@ extern "C" {
#endif
/* main.cpp */
DLLEXPORT BOOL getstats(scfg_t* cfg, char node, stats_t* stats);
DLLEXPORT BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats);
/* mail.cpp */
DLLEXPORT int getmail(scfg_t* cfg, int usernumber, BOOL sent);
DLLEXPORT mail_t* loadmail(smb_t* smb, long* msgs, uint usernumber
DLLEXPORT int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent);
DLLEXPORT mail_t* DLLCALL loadmail(smb_t* smb, ulong* msgs, uint usernumber
,int which, long mode);
DLLEXPORT void freemail(mail_t* mail);
DLLEXPORT void DLLCALL freemail(mail_t* mail);
/* filedat.c */
DLLEXPORT BOOL getfileixb(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL getfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL putfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL removefiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL addfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL findfile(scfg_t* cfg, uint dirnum, char *filename);
DLLEXPORT char * padfname(char *filename, char *str);
DLLEXPORT char * unpadfname(char *filename, char *str);
DLLEXPORT BOOL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname);
DLLEXPORT BOOL DLLCALL getfileixb(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL getfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL putfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL removefiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL addfiledat(scfg_t* cfg, file_t* f);
DLLEXPORT BOOL DLLCALL findfile(scfg_t* cfg, uint dirnum, char *filename);
DLLEXPORT char * DLLCALL padfname(char *filename, char *str);
DLLEXPORT char * DLLCALL unpadfname(char *filename, char *str);
DLLEXPORT BOOL DLLCALL rmuserxfers(scfg_t* cfg, int fromuser, int destuser, char *fname);
/* str.cpp */
DLLEXPORT BOOL trashcan(scfg_t* cfg, char *insearch, char *name);
DLLEXPORT BOOL DLLCALL trashcan(scfg_t* cfg, char *insearch, char *name);
/* misc.c */
int nopen(char *str, int access);
......@@ -724,13 +733,13 @@ extern "C" {
char * hexplus(uint num, char *str); /* Hex plus for 3 digits up to 9000 */
uint hptoi(char *str);
DLLEXPORT ushort crc16(char *str);
DLLEXPORT char * zonestr(short zone);
DLLEXPORT int putsmsg(scfg_t* cfg, int usernumber, char *strin);
DLLEXPORT ushort DLLCALL crc16(char *str);
DLLEXPORT char * DLLCALL zonestr(short zone);
DLLEXPORT int DLLCALL putsmsg(scfg_t* cfg, int usernumber, char *strin);
/* load_cfg.C */
DLLEXPORT BOOL load_cfg(scfg_t* cfg, char* text[]);
DLLEXPORT BOOL DLLCALL load_cfg(scfg_t* cfg, char* text[]);
char * readtext(long *line, FILE *stream);
BOOL md(char *path);
......
......@@ -43,6 +43,9 @@
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#ifdef _WIN32
#ifdef WRAPPER_DLL
......@@ -50,8 +53,14 @@
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define DLLCALL
#endif
#else /* !_WIN32 */
#define DLLEXPORT
#define DLLCALL
#endif
#ifdef __cplusplus
......@@ -81,10 +90,10 @@ extern "C" {
#define _mkdir(dir) mkdir(dir,0777)
#define _rmdir(dir) rmdir(dir)
DLLEXPORT void sbbs_beep(int freq, int dur);
DLLEXPORT long filelength(int fd);
DLLEXPORT char* strupr(char* str);
DLLEXPORT char* strlwr(char* str);
DLLEXPORT void DLLCALL sbbs_beep(int freq, int dur);
DLLEXPORT long DLLCALL filelength(int fd);
DLLEXPORT char* DLLCALL strupr(char* str);
DLLEXPORT char* DLLCALL strlwr(char* str);
#else /* Unsupported OS */
......@@ -146,7 +155,7 @@ extern "C" {
#if defined(__BORLANDC__)
#define sbbs_random(x) random(x)
#else
DLLEXPORT int sbbs_random(int n);
DLLEXPORT int DLLCALL sbbs_random(int n);
#endif
#if __BORLANDC__ > 0x0410
......@@ -154,16 +163,16 @@ extern "C" {
#endif
#if !defined(_MSC_VER) && !defined(__BORLANDC__)
DLLEXPORT char* ultoa(ulong, char*, int radix);
DLLEXPORT char* DLLCALL ultoa(ulong, char*, int radix);
#endif
/* General file system wrappers for all platforms and compilers */
DLLEXPORT BOOL fexist(char *filespec);
DLLEXPORT long flength(char *filename);
DLLEXPORT long fdate(char *filename);
DLLEXPORT int getfattr(char* filename);
DLLEXPORT ulong getfreediskspace(char* path);
DLLEXPORT BOOL DLLCALL fexist(char *filespec);
DLLEXPORT long DLLCALL flength(char *filename);
DLLEXPORT long DLLCALL fdate(char *filename);
DLLEXPORT int DLLCALL getfattr(char* filename);
DLLEXPORT ulong DLLCALL getfreediskspace(char* path);
#ifdef __cplusplus
}
......
......@@ -715,7 +715,7 @@ void sbbs_t::dirinfo(uint dirnum)
/* Searches the file <name>.CAN in the TEXT directory for matches */
/* Returns 1 if found in list, 0 if not. */
/****************************************************************************/
extern "C" BOOL trashcan(scfg_t* cfg, char* insearch, char* name)
extern "C" BOOL DLLCALL trashcan(scfg_t* cfg, char* insearch, char* name)
{
char* p;
char str[128];
......
......@@ -47,7 +47,7 @@ char* nulstr="";
/* Returns the number of the perfect matched username or 0 if no match */
/* Called from functions waitforcall and newuser */
/****************************************************************************/
uint matchuser(scfg_t* cfg, char *name)
uint DLLCALL matchuser(scfg_t* cfg, char *name)
{
int file;
char str[256],c;
......@@ -78,7 +78,7 @@ uint matchuser(scfg_t* cfg, char *name)
/* Returns the number of the last user in USER.DAT (deleted ones too) */
/* Called from function useredit */
/****************************************************************************/
uint lastuser(scfg_t* cfg)
uint DLLCALL lastuser(scfg_t* cfg)
{
char str[256];
long length;
......@@ -93,7 +93,7 @@ uint lastuser(scfg_t* cfg)
/* Fills the structure 'user' with info for user.number from USER.DAT */
/* Called from functions useredit, waitforcall and main_sec */
/****************************************************************************/
int getuserdat(scfg_t* cfg, user_t *user)
int DLLCALL getuserdat(scfg_t* cfg, user_t *user)
{
char userdat[U_LEN+1],str[U_LEN+1],tmp[64];
int i,file;
......@@ -266,7 +266,7 @@ int getuserdat(scfg_t* cfg, user_t *user)
/* Writes into user.number's slot in USER.DAT data in structure 'user' */
/* Called from functions newuser, useredit and main */
/****************************************************************************/
int putuserdat(scfg_t* cfg, user_t* user)
int DLLCALL putuserdat(scfg_t* cfg, user_t* user)
{
int i,file;
char userdat[U_LEN+1],str[U_LEN+1];
......@@ -418,7 +418,7 @@ int putuserdat(scfg_t* cfg, user_t* user)
/* Returns the username in 'str' that corresponds to the 'usernumber' */
/* Called from functions everywhere */
/****************************************************************************/
char *username(scfg_t* cfg, int usernumber,char *strin)
char* DLLCALL username(scfg_t* cfg, int usernumber,char *strin)
{
char str[256];
char c;
......@@ -453,7 +453,7 @@ char *username(scfg_t* cfg, int usernumber,char *strin)
/* Places into 'strout' CR or ETX terminated string starting at */
/* 'start' and ending at 'start'+'length' or terminator from 'strin' */
/****************************************************************************/
void getrec(char *strin,int start,int length,char *strout)
void DLLCALL getrec(char *strin,int start,int length,char *strout)
{
int i=0,stop;
......@@ -470,7 +470,7 @@ void getrec(char *strin,int start,int length,char *strout)
/* Places into 'strout', 'strin' starting at 'start' and ending at */
/* 'start'+'length' */
/****************************************************************************/
void putrec(char *strout,int start,int length,char *strin)
void DLLCALL putrec(char *strout,int start,int length,char *strin)
{
int i=0,j;
......@@ -487,7 +487,7 @@ void putrec(char *strout,int start,int length,char *strin)
/* Called from functions statusline, main_sec, xfer_sec, useredit and */
/* text files */
/****************************************************************************/
char getage(scfg_t* cfg, char *birth)
char DLLCALL getage(scfg_t* cfg, char *birth)
{
char age;
struct tm * tm;
......@@ -529,7 +529,7 @@ char getage(scfg_t* cfg, char *birth)
/* from NODE.DAB */
/* if lockit is non-zero, locks this node's record. putnodedat() unlocks it */
/****************************************************************************/
int getnodedat(scfg_t* cfg, uint number, node_t *node, char lockit)
int DLLCALL getnodedat(scfg_t* cfg, uint number, node_t *node, char lockit)
{
char str[256];
int count=0;
......@@ -570,7 +570,7 @@ int getnodedat(scfg_t* cfg, uint number, node_t *node, char lockit)
/* getnodedat(num,&node,1); must have been called before calling this func */
/* NOTE: ------^ the indicates the node record has been locked */
/****************************************************************************/
int putnodedat(scfg_t* cfg, uint number, node_t* node)
int DLLCALL putnodedat(scfg_t* cfg, uint number, node_t* node)
{